[gthumb] collapse the comment dialog height after closing the tag list



commit 9b996f33da0b858d1b6cc16377e002e90d7e1486
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Aug 4 20:53:24 2010 +0200

    collapse the comment dialog height after closing the tag list

 extensions/edit_metadata/gth-edit-comment-page.c |   67 +++++++++++++++-------
 gthumb/gth-tags-entry.c                          |   34 +++++++----
 gthumb/gth-tags-entry.h                          |    4 +
 3 files changed, 70 insertions(+), 35 deletions(-)
---
diff --git a/extensions/edit_metadata/gth-edit-comment-page.c b/extensions/edit_metadata/gth-edit-comment-page.c
index a50d17a..b073b98 100644
--- a/extensions/edit_metadata/gth-edit-comment-page.c
+++ b/extensions/edit_metadata/gth-edit-comment-page.c
@@ -406,6 +406,24 @@ date_combobox_changed_cb (GtkComboBox *widget,
 
 
 static void
+tags_entry_list_collapsed_cb (GthTagsEntry *widget,
+			      gpointer     user_data)
+{
+	GtkWidget *toplevel;
+	int        width;
+
+	/* collapse the dialog height */
+
+	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (widget));
+	if (! gtk_widget_is_toplevel (toplevel))
+		return;
+
+	gtk_window_get_size (GTK_WINDOW (toplevel), &width, NULL);
+	gtk_window_resize (GTK_WINDOW (toplevel), width, 1);
+}
+
+
+static void
 gth_edit_comment_page_init (GthEditCommentPage *self)
 {
 	self->priv = GTH_EDIT_COMMENT_PAGE_GET_PRIVATE (self);
@@ -414,35 +432,40 @@ gth_edit_comment_page_init (GthEditCommentPage *self)
 	gtk_container_set_border_width (GTK_CONTAINER (self), 12);
 
 	self->priv->builder = _gtk_builder_new_from_file ("edit-comment-page.ui", "edit_metadata");
-  	gtk_box_pack_start (GTK_BOX (self), _gtk_builder_get_widget (self->priv->builder, "content"), TRUE, TRUE, 0);
-
-  	self->priv->date_combobox = gtk_combo_box_new_text ();
-  	_gtk_combo_box_append_texts (GTK_COMBO_BOX (self->priv->date_combobox),
-  				     _("No date"),
-  				     _("The following date"),
-  				     _("Current date"),
-  				     _("Date photo was taken"),
-  				     _("Last modified date"),
-  				     _("File creation date"),
-  				     _("Do not modify"),
-  				     NULL);
-  	gtk_widget_show (self->priv->date_combobox);
-  	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_combobox_container")), self->priv->date_combobox, TRUE, TRUE, 0);
-
-  	g_signal_connect (self->priv->date_combobox,
+	gtk_box_pack_start (GTK_BOX (self), _gtk_builder_get_widget (self->priv->builder, "content"), TRUE, TRUE, 0);
+
+	self->priv->date_combobox = gtk_combo_box_new_text ();
+	_gtk_combo_box_append_texts (GTK_COMBO_BOX (self->priv->date_combobox),
+				     _("No date"),
+				     _("The following date"),
+				     _("Current date"),
+				     _("Date photo was taken"),
+				     _("Last modified date"),
+				     _("File creation date"),
+				     _("Do not modify"),
+				     NULL);
+	gtk_widget_show (self->priv->date_combobox);
+	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_combobox_container")), self->priv->date_combobox, TRUE, TRUE, 0);
+
+	g_signal_connect (self->priv->date_combobox,
 			  "changed",
 			  G_CALLBACK (date_combobox_changed_cb),
 			  self);
 
-  	self->priv->date_selector = gth_time_selector_new ();
-  	gtk_widget_show (self->priv->date_selector);
-  	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_selector_container")), self->priv->date_selector, FALSE, FALSE, 0);
+	self->priv->date_selector = gth_time_selector_new ();
+	gtk_widget_show (self->priv->date_selector);
+	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_selector_container")), self->priv->date_selector, FALSE, FALSE, 0);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("date_label")), self->priv->date_combobox);
 
-  	self->priv->tags_entry = gth_tags_entry_new ();
-  	gtk_widget_show (self->priv->tags_entry);
-  	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("tags_entry_container")), self->priv->tags_entry, FALSE, FALSE, 0);
+	self->priv->tags_entry = gth_tags_entry_new ();
+	gtk_widget_show (self->priv->tags_entry);
+	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("tags_entry_container")), self->priv->tags_entry, FALSE, FALSE, 0);
 	gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("tags_label")), self->priv->tags_entry);
+
+	g_signal_connect (self->priv->tags_entry,
+			  "list-collapsed",
+			  G_CALLBACK (tags_entry_list_collapsed_cb),
+			  self);
 }
 
 
diff --git a/gthumb/gth-tags-entry.c b/gthumb/gth-tags-entry.c
index f8251ae..cb6a428 100644
--- a/gthumb/gth-tags-entry.c
+++ b/gthumb/gth-tags-entry.c
@@ -45,6 +45,13 @@ enum {
 };
 
 
+/* Signals */
+enum {
+	LIST_COLLAPSED,
+	LAST_SIGNAL
+};
+
+
 typedef struct {
 	char     *name;
 	gboolean  used;
@@ -74,6 +81,7 @@ struct _GthTagsEntryPrivate {
 
 
 static gpointer parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
 
 
 static void
@@ -117,6 +125,18 @@ gth_tags_entry_class_init (GthTagsEntryClass *klass)
 
 	widget_class = (GtkWidgetClass *) klass;
 	widget_class->grab_focus = gth_tags_entry_grab_focus;
+
+	/* signals */
+
+	signals[LIST_COLLAPSED] =
+		g_signal_new ("list-collapsed",
+			      G_TYPE_FROM_CLASS (klass),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GthTagsEntryClass, list_collapsed),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE,
+			      0);
 }
 
 
@@ -623,19 +643,7 @@ static void
 tag_list_unmap_cb (GtkWidget    *widget,
 		   GthTagsEntry *self)
 {
-	GtkWidget   *toplevel;
-        GdkGeometry  geometry;
-
-        toplevel = gtk_widget_get_toplevel (widget);
-        if (! gtk_widget_is_toplevel (toplevel))
-        	return;
-
-        geometry.max_height = -1;
-        geometry.max_width = G_MAXINT;
-        gtk_window_set_geometry_hints (GTK_WINDOW (toplevel),
-				       toplevel,
-                                       &geometry,
-                                       GDK_HINT_MAX_SIZE);
+        g_signal_emit (self, signals[LIST_COLLAPSED], 0);
 }
 
 
diff --git a/gthumb/gth-tags-entry.h b/gthumb/gth-tags-entry.h
index f60d6c9..123ad70 100644
--- a/gthumb/gth-tags-entry.h
+++ b/gthumb/gth-tags-entry.h
@@ -45,6 +45,10 @@ struct _GthTagsEntry {
 
 struct _GthTagsEntryClass {
 	GtkVBoxClass parent_class;
+
+	/*< signals >*/
+
+	void (*list_collapsed) (GthTagsEntry *self);
 };
 
 GType        gth_tags_entry_get_type  (void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]