[glade3] 2010-03-26 Tristan Van Berkom <tvb gnome org>



commit b6abe222bdf31f9adcfb85f10fa6d539ab572cb7
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Fri Mar 26 13:48:01 2010 -0400

    2010-03-26  Tristan Van Berkom <tvb gnome org>
    
    	* gladeui/glade-palette.c: Left aligned and ellipsize end widget group titles (restored normal
    	  Glade palette behavior) and added tooltip to group title (closing bug 558983).
    
    	* src/glade-window.c: Added an idle function to reload GtkPaned positions from the session data
    	  in the case the window fires up maximized.

 ChangeLog               |    8 ++++
 gladeui/glade-palette.c |   18 +++++++-
 src/glade-window.c      |  103 +++++++++++++++++++++++++++++------------------
 3 files changed, 87 insertions(+), 42 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 061de15..2741b54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-26  Tristan Van Berkom <tvb gnome org>
+
+	* gladeui/glade-palette.c: Left aligned and ellipsize end widget group titles (restored normal
+	  Glade palette behavior) and added tooltip to group title (closing bug 558983).
+
+	* src/glade-window.c: Added an idle function to reload GtkPaned positions from the session data
+	  in the case the window fires up maximized.
+
 2010-03-25  Tristan Van Berkom <tvb gnome org>
 
 	* gladeui/Makefile.am, gladeui/glade-palette.c:
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index f5b6a74..3d9b5ff 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -594,13 +594,25 @@ static GtkWidget*
 glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group)
 {
 	GladePalettePrivate *priv;
-	GtkWidget           *item_group;
-	GtkWidget           *item;
+	GtkWidget           *item_group, *item, *label;
 	GList               *l;
 
 	priv = palette->priv;
 
-	item_group = gtk_tool_item_group_new (glade_widget_group_get_title (group));
+	/* Give the item group a left aligned label */
+	label = gtk_label_new (glade_widget_group_get_title (group));
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+	gtk_widget_show (label);
+
+	item_group = (GtkWidget *)g_object_new (GTK_TYPE_TOOL_ITEM_GROUP,
+						"label-widget", label,
+						NULL);
+
+	/* Tell the item group to ellipsize our custom label for us */
+	gtk_tool_item_group_set_ellipsize (GTK_TOOL_ITEM_GROUP (item_group), 
+					   PANGO_ELLIPSIZE_END);
+
+	gtk_widget_set_tooltip_text (item_group, glade_widget_group_get_title (group));
 
 	/* Go through all the widget classes in this catalog. */
 	for (l = (GList *) glade_widget_group_get_adaptors (group); l; l = l->next)
diff --git a/src/glade-window.c b/src/glade-window.c
index 6f7c1d3..138a648 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -472,25 +472,6 @@ update_default_path (GladeWindow *window, GladeProject *project)
 	g_free (path);
 }
 
-static gboolean
-window_state_event_cb (GtkWidget *widget,
-			   GdkEventWindowState *event,
-			   GladeWindow *window)
-{
-	if (event->changed_mask &
-	    (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
-	{
-		gboolean show;
-
-		show = !(event->new_window_state &
-			(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN));
-
-		gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar), show);
-	}
-
-	return FALSE;
-}
-
 static GtkWidget *
 create_recent_chooser_menu (GladeWindow *window, GtkRecentManager *manager)
 {
@@ -2869,6 +2850,28 @@ key_file_get_window_position (GKeyFile     *config,
 	g_free (key_maximized);
 }
 
+
+static void
+load_paned_position (GKeyFile *config, GtkWidget *pane, const gchar *name, gint default_position)
+{
+	gtk_paned_set_position (GTK_PANED (pane),
+				key_file_get_int (config, name, "position", default_position));
+}
+
+static gboolean
+fix_paned_positions_idle (GladeWindow *window)
+{
+	/* When initially maximized/fullscreened we need to deffer this operation 
+	 */
+	GKeyFile *config = glade_app_get_config ();
+			
+	load_paned_position (config, window->priv->left_pane, "left_pane", 200);
+	load_paned_position (config, window->priv->center_pane, "center_pane", 400);
+	load_paned_position (config, window->priv->right_pane, "right_pane", 220);
+
+	return FALSE;
+}
+
 static void
 glade_window_set_initial_size (GladeWindow *window, GKeyFile *config)
 {
@@ -2878,8 +2881,17 @@ glade_window_set_initial_size (GladeWindow *window, GKeyFile *config)
 
 	gboolean maximized;
 	key_file_get_window_position (config, "main", &position, NULL, &maximized);
-	if(maximized)
+	if (maximized)
+	{
 		gtk_window_maximize (GTK_WINDOW (window));
+		g_idle_add ((GSourceFunc)fix_paned_positions_idle, window);
+	}
+
+	if (position.width <= 0 || position.height <= 0)
+	{
+		position.width  = GLADE_WINDOW_DEFAULT_WIDTH;
+		position.height = GLADE_WINDOW_DEFAULT_HEIGHT;
+	}
 
 	gtk_window_set_default_size (GTK_WINDOW (window), position.width, position.height);
 
@@ -2888,24 +2900,41 @@ glade_window_set_initial_size (GladeWindow *window, GKeyFile *config)
 }
 
 static void
-load_paned_position (GKeyFile *config, GtkWidget *pane, const gchar *name, gint default_position)
-{
-	gtk_paned_set_position (GTK_PANED (pane),
-				key_file_get_int (config, name, "position", default_position));
-}
-
-static void
 glade_window_config_load (GladeWindow *window)
 {
 	GKeyFile *config = glade_app_get_config ();
-	
-	glade_window_set_initial_size (window, config);
-	
-	load_paned_position (config, window->priv->center_pane, "center_pane", 400);
+
+	glade_window_set_initial_size (window, config);	
+
 	load_paned_position (config, window->priv->left_pane, "left_pane", 200);
+	load_paned_position (config, window->priv->center_pane, "center_pane", 400);
 	load_paned_position (config, window->priv->right_pane, "right_pane", 220);
 }
 
+static gboolean
+glade_window_state_event (GtkWidget           *widget,
+			  GdkEventWindowState *event)
+{
+	GladeWindow *window = GLADE_WINDOW (widget);
+
+	/* Incase GtkWindow decides to do something */
+	if (GTK_WIDGET_CLASS (glade_window_parent_class)->window_state_event)
+		GTK_WIDGET_CLASS (glade_window_parent_class)->window_state_event (widget, event);
+
+	if (event->changed_mask &
+	    (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
+	{
+		gboolean show;
+
+		show = !(event->new_window_state &
+			(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN));
+
+		gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar), show);
+	}
+
+	return FALSE;
+}
+
 static void
 show_dock_first_time (GladeWindow    *window,
 		      guint           dock_type,
@@ -3162,14 +3191,10 @@ glade_window_init (GladeWindow *window)
 			  window);
 			  
 	/* GtkWindow events */
-	g_signal_connect (window, "window-state-event",
-			  G_CALLBACK (window_state_event_cb),
-			  window);
-
 	g_signal_connect (G_OBJECT (window), "key-press-event",
 			  G_CALLBACK (glade_utils_hijack_key_press), window);
 
-       /* GladeApp signals */
+	/* GladeApp signals */
 	g_signal_connect (G_OBJECT (priv->app), "update-ui",
 			  G_CALLBACK (update_ui),
 			  window);
@@ -3187,8 +3212,7 @@ glade_window_init (GladeWindow *window)
 	accel_group = gtk_ui_manager_get_accel_group(priv->ui);
 
 	gtk_window_add_accel_group (GTK_WINDOW (glade_app_get_clipboard_view ()), accel_group);
-	
-	/* Load widget state */
+
 	glade_window_config_load (window);
 
 #ifdef MAC_INTEGRATION
@@ -3217,7 +3241,8 @@ glade_window_class_init (GladeWindowClass *klass)
 	object_class->dispose  = glade_window_dispose;
 	object_class->finalize = glade_window_finalize;
 
-	widget_class->configure_event = glade_window_configure_event;
+	widget_class->configure_event    = glade_window_configure_event;
+	widget_class->window_state_event = glade_window_state_event;
 
 	g_type_class_add_private (klass, sizeof (GladeWindowPrivate));
 }



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