View Issue Details

IDProjectCategoryView StatusLast Update
0038292LazarusWidgetsetpublic2021-02-02 17:27
ReporterCudaText man_ Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
OSUbuntu 20.04 x64 
Product Version2.1 (SVN) 
Summary0038292: gtk2: issue with too long TOpenDialog/TSaveDialog.Filter
Descriptionrun attached demo. on qt5, too long Filter string is cropped and dialog looks OK.
on gtk2, too long filter string shows as-is, this gives the dialog huge width (dialog occupies 2 monitors, which are placed left/right).
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

CudaText man_

2021-01-02 15:32

reporter   ~0128020

CudaText man_

2021-01-02 15:33

reporter   ~0128021

filter_qt5.png (45,209 bytes)   
filter_qt5.png (45,209 bytes)   
filter_gtk2.png (77,391 bytes)   
filter_gtk2.png (77,391 bytes)   

Bart Broersma

2021-01-02 17:45

developer   ~0128027

Isn't that just how GTK2 handles that internally
I don't see any properties in https://developer.gnome.org/gtk2/stable/GtkFileChooser.html or https://developer.gnome.org/gtk2/stable/GtkFileChooserDialog.html to prevent that from happening?

Zeljan Rikalo

2021-01-19 13:48

developer   ~0128413

IMO this is gtk2 problem, by design.

Bart Broersma

2021-01-19 14:51

developer   ~0128416

In that case, close as not fixable?
(I'm not the GTK expert)

Zeljan Rikalo

2021-01-19 16:35

developer   ~0128426

@Bart, someone can make pure gtk2 program (without lcl) and proove this. IMO it's pretty easy, but I have not time to do that atm.

August Klein

2021-01-19 19:37

reporter   ~0128431

Last edited: 2021-01-19 19:42

View 2 revisions

Yes, this is the normal behavior for gtk2 if you set a large filter.
I upload a tiny program written in C and a screenshot.

However with pure Gtk you add various filters and sets a human-readable name for them (added as items into combobox).
screenshot.png (589,223 bytes)
test.c (2,304 bytes)   
/*
gcc -o test test.c $(pkg-config --cflags --libs gtk+-2.0)
*/

#include <gtk/gtk.h>

static void
select_file (GtkWidget* sender, gpointer parent)
{
  gchar* filename = NULL;
  GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;


  GtkWidget *dialog;

  dialog = gtk_file_chooser_dialog_new ("Select...",
                                        (GtkWindow*) parent,
                                        action,
                                        "_Open",
                                        GTK_RESPONSE_ACCEPT,
                                        "_Cancel",
                                        GTK_RESPONSE_CANCEL,
                                        NULL);


  GtkFileFilter *filter = gtk_file_filter_new ();
  gtk_file_filter_add_pattern (filter, "*");
  gtk_file_filter_set_name (filter,
"test ******************************************************************************************\
***********************************************************************************************\
***********************************************************************************************\
***********************************************************************************************");

  gtk_file_chooser_add_filter ((GtkFileChooser*)dialog, filter);

  if (gtk_dialog_run ((GtkDialog*) dialog) == ((gint) GTK_RESPONSE_ACCEPT))
    filename = gtk_file_chooser_get_filename ((GtkFileChooser*) dialog);

  gtk_widget_destroy (dialog);

  if (filename)
    g_print (filename);
}

int
main(int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *vbox;

  GtkWidget *button;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_resize(GTK_WINDOW(window), 800, 600);
  gtk_window_set_title(GTK_WINDOW(window), "File Selection");

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), vbox);

  button = gtk_button_new_with_label("Click me");

  gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5);

  g_signal_connect(G_OBJECT(button), "clicked", 
        G_CALLBACK(select_file), window);

  g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
test.c (2,304 bytes)   

Juha Manninen

2021-02-02 17:27

developer   ~0128743

Native behavior. No change required.

Issue History

Date Modified Username Field Change
2021-01-02 15:32 CudaText man_ New Issue
2021-01-02 15:32 CudaText man_ Note Added: 0128020
2021-01-02 15:32 CudaText man_ File Added: tst-filedialog-long-filter.zip
2021-01-02 15:33 CudaText man_ Note Added: 0128021
2021-01-02 15:33 CudaText man_ File Added: filter_qt5.png
2021-01-02 15:33 CudaText man_ File Added: filter_gtk2.png
2021-01-02 17:45 Bart Broersma Note Added: 0128027
2021-01-19 13:48 Zeljan Rikalo Note Added: 0128413
2021-01-19 14:51 Bart Broersma Note Added: 0128416
2021-01-19 16:35 Zeljan Rikalo Note Added: 0128426
2021-01-19 19:37 August Klein Note Added: 0128431
2021-01-19 19:37 August Klein File Added: screenshot.png
2021-01-19 19:37 August Klein File Added: test.c
2021-01-19 19:42 August Klein Note Edited: 0128431 View Revisions
2021-02-02 17:27 Juha Manninen Assigned To => Juha Manninen
2021-02-02 17:27 Juha Manninen Status new => resolved
2021-02-02 17:27 Juha Manninen Resolution open => no change required
2021-02-02 17:27 Juha Manninen LazTarget => -
2021-02-02 17:27 Juha Manninen Widgetset GTK 2 => GTK 2
2021-02-02 17:27 Juha Manninen Note Added: 0128743