[PATCH] GtkFileChooserDefault: Only show filter hbox if filters exist
- From: Christian Neumair <chris gnome-de org>
- To: gtk-devel-list gnome org
- Subject: [PATCH] GtkFileChooserDefault: Only show filter hbox if filters exist
- Date: Sun, 04 Apr 2004 15:02:57 +0200
Currently, GtkFileChooserDefault always displays the type filter hbox,
ignoring whether there actually are any filters. This results in a
visual gap of the add/remove buttons' height below the file list if
there aren't any filters.
This patch does the following:
- slight cleanups (remove all references to "toolbar" which doesn't
exist anymore)
- there used to be two encapsulated hboxes for the format_combo which
doesn't make sense
- Add filter_combo_hbox widget to object. Its visibility state is
toggled on filter addition/removal. If you don't want any additional
widgets inside the hbox, I could change it to format_combo->parent as
well, but this would be hacky.
regs,
Chris
Index: gtk/gtkfilechooserdefault.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdefault.c,v
retrieving revision 1.166
diff -u -r1.166 gtkfilechooserdefault.c
--- gtk/gtkfilechooserdefault.c 2 Apr 2004 00:35:07 -0000 1.166
+++ gtk/gtkfilechooserdefault.c 4 Apr 2004 12:54:18 -0000
@@ -115,6 +115,7 @@
GtkFileSystemModel *browse_files_model;
+ GtkWidget *filter_combo_hbox;
GtkWidget *filter_combo;
GtkWidget *preview_box;
GtkWidget *preview_label;
@@ -1454,7 +1455,7 @@
NULL);
}
-/* Callback used when the "New Folder" toolbar button is clicked */
+/* Callback used when the "New Folder" button is clicked */
static void
new_folder_button_clicked (GtkButton *button,
GtkFileChooserDefault *impl)
@@ -2779,18 +2780,17 @@
static GtkWidget *
create_filename_entry_and_filter_combo (GtkFileChooserDefault *impl)
{
- GtkWidget *hbox;
GtkWidget *widget;
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
+ impl->filter_combo_hbox = gtk_hbox_new (FALSE, 12);
/* Filter combo */
widget = filter_create (impl);
- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ gtk_box_pack_end (GTK_BOX (impl->filter_combo_hbox), widget, FALSE, FALSE, 0);
- return hbox;
+ return impl->filter_combo_hbox;
}
static GtkWidget *
@@ -2849,12 +2849,9 @@
/* Don't show preview box initially */
/* Filename entry and filter combo */
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_size_group_add_widget (size_group, hbox);
widget = create_filename_entry_and_filter_combo (impl);
- gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_box_pack_end (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
return vbox;
}
@@ -4159,13 +4156,15 @@
/* Shows or hides the filter widgets */
static void
-toolbar_show_filters (GtkFileChooserDefault *impl,
- gboolean show)
+show_filters (GtkFileChooserDefault *impl,
+ gboolean show)
{
- if (show)
- gtk_widget_show (impl->filter_combo);
- else
- gtk_widget_hide (impl->filter_combo);
+ if (show) {
+ gtk_widget_show (impl->filter_combo_hbox);
+ }
+ else {
+ gtk_widget_hide (impl->filter_combo_hbox);
+ }
}
static void
@@ -4194,7 +4193,7 @@
if (!g_slist_find (impl->filters, impl->current_filter))
set_current_filter (impl, filter);
- toolbar_show_filters (impl, TRUE);
+ show_filters (impl, TRUE);
}
static void
@@ -4232,7 +4231,7 @@
g_object_unref (filter);
if (!impl->filters)
- toolbar_show_filters (impl, FALSE);
+ show_filters (impl, FALSE);
}
static GSList *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]