[gthumb/ext: 46/79] Save and restore the paned position correctly
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 46/79] Save and restore the paned position correctly
- Date: Sun, 2 Aug 2009 20:28:58 +0000 (UTC)
commit 9ad1d76a839259a369ff3408e8ce64b27a2f17d5
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jul 14 15:43:29 2009 +0200
Save and restore the paned position correctly
gthumb/gth-browser.c | 20 +++++--
gthumb/gtk-utils.c | 40 +++++++++++++
gthumb/gtk-utils.h | 159 +++++++++++++++++++++++++------------------------
3 files changed, 136 insertions(+), 83 deletions(-)
---
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index c14fc9f..a6d9d13 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -1505,6 +1505,7 @@ _gth_browser_close_final_step (gpointer user_data)
gboolean last_window;
GdkWindowState state;
gboolean maximized;
+ int pos;
browser_list = g_list_remove (browser_list, browser);
last_window = gth_window_get_n_windows () == 1;
@@ -1521,9 +1522,17 @@ _gth_browser_close_final_step (gpointer user_data)
eel_gconf_set_integer (PREF_UI_WINDOW_HEIGHT, height);
}
- eel_gconf_set_integer (PREF_UI_BROWSER_SIDEBAR_WIDTH, gtk_paned_get_position (GTK_PANED (browser->priv->browser_container)));
- eel_gconf_set_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, gtk_paned_get_position (GTK_PANED (browser->priv->viewer_pane)));
- eel_gconf_set_integer (PREF_UI_PROPERTIES_HEIGHT, gtk_paned_get_position (GTK_PANED (browser->priv->browser_sidebar)));
+ pos = gtk_paned_get_position (GTK_PANED (browser->priv->browser_container));
+ if (pos > 0)
+ eel_gconf_set_integer (PREF_UI_BROWSER_SIDEBAR_WIDTH, pos);
+
+ pos = _gtk_paned_get_position2 (GTK_PANED (browser->priv->viewer_pane));
+ if (pos > 0)
+ eel_gconf_set_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, pos);
+
+ pos = _gtk_paned_get_position2 (GTK_PANED (browser->priv->browser_sidebar));
+ if (pos > 0)
+ eel_gconf_set_integer (PREF_UI_PROPERTIES_HEIGHT, pos);
/**/
@@ -2712,7 +2721,6 @@ _gth_browser_construct (GthBrowser *browser)
/* content */
browser->priv->viewer_pane = gtk_hpaned_new ();
- gtk_paned_set_position (GTK_PANED (browser->priv->viewer_pane), eel_gconf_get_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, DEFAULT_UI_WINDOW_WIDTH - DEF_SIDEBAR_WIDTH));
gtk_widget_show (browser->priv->viewer_pane);
gth_window_attach_content (GTH_WINDOW (browser), GTH_BROWSER_PAGE_VIEWER, browser->priv->viewer_pane);
@@ -2781,7 +2789,6 @@ _gth_browser_construct (GthBrowser *browser)
/* the browser sidebar */
browser->priv->browser_sidebar = gtk_vpaned_new ();
- gtk_paned_set_position (GTK_PANED (browser->priv->browser_sidebar), eel_gconf_get_integer (PREF_UI_PROPERTIES_HEIGHT, DEF_PROPERTIES_HEIGHT));
gtk_widget_show (browser->priv->browser_sidebar);
gtk_paned_pack1 (GTK_PANED (browser->priv->browser_container), browser->priv->browser_sidebar, FALSE, TRUE);
@@ -2939,6 +2946,9 @@ _gth_browser_construct (GthBrowser *browser)
/* init browser data */
+ _gtk_paned_set_position2 (GTK_PANED (browser->priv->viewer_pane), eel_gconf_get_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, DEFAULT_UI_WINDOW_WIDTH - DEF_SIDEBAR_WIDTH));
+ _gtk_paned_set_position2 (GTK_PANED (browser->priv->browser_sidebar), eel_gconf_get_integer (PREF_UI_PROPERTIES_HEIGHT, DEF_PROPERTIES_HEIGHT));
+
_gth_browser_set_toolbar_visibility (browser, eel_gconf_get_boolean (PREF_UI_TOOLBAR_VISIBLE, TRUE));
_gth_browser_update_toolbar_style (browser);
_gth_browser_update_entry_point_list (browser);
diff --git a/gthumb/gtk-utils.c b/gthumb/gtk-utils.c
index dd52bfa..e1566e2 100644
--- a/gthumb/gtk-utils.c
+++ b/gthumb/gtk-utils.c
@@ -1009,3 +1009,43 @@ _gtk_tree_path_list_free (GList *list)
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_list_free (list);
}
+
+
+int
+_gtk_paned_get_position2 (GtkPaned *paned)
+{
+ GtkRequisition requisition;
+ int pos;
+ int size;
+
+ if (! GTK_WIDGET_VISIBLE (paned))
+ return 0;
+
+ pos = gtk_paned_get_position (paned);
+
+ gtk_window_get_size (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (paned))), &(requisition.width), &(requisition.height));
+ if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL)
+ size = requisition.width;
+ else
+ size = requisition.height;
+
+ return size - pos;
+}
+
+
+void
+_gtk_paned_set_position2 (GtkPaned *paned,
+ int pos)
+{
+ GtkRequisition requisition;
+ int size;
+
+ gtk_window_get_size (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (paned))), &(requisition.width), &(requisition.height));
+ if (gtk_orientable_get_orientation (GTK_ORIENTABLE (paned)) == GTK_ORIENTATION_HORIZONTAL)
+ size = requisition.width;
+ else
+ size = requisition.height;
+
+ if (pos > 0)
+ gtk_paned_set_position (paned, size - pos);
+}
diff --git a/gthumb/gtk-utils.h b/gthumb/gtk-utils.h
index 98ce8c3..7eecc74 100644
--- a/gthumb/gtk-utils.h
+++ b/gthumb/gtk-utils.h
@@ -29,91 +29,94 @@
G_BEGIN_DECLS
-GtkWidget* _gtk_message_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *stock_id,
- const char *message,
- const char *secondary_message,
- const char *first_button_text,
- ...);
+GtkWidget* _gtk_message_dialog_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *stock_id,
+ const char *message,
+ const char *secondary_message,
+ const char *first_button_text,
+ ...);
GtkWidget*
-_gtk_message_dialog_with_checkbutton_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *stock_id,
- const char *message,
- const char *secondary_message,
- const char *gconf_key,
- const char *check_button_label,
- const char *first_button_text,
- ...);
-gchar* _gtk_request_dialog_run (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *message,
- const char *default_value,
- int max_length,
- const char *no_button_text,
- const char *yes_button_text);
-GtkWidget* _gtk_yesno_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *message,
- const char *no_button_text,
- const char *yes_button_text);
+_gtk_message_dialog_with_checkbutton_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *stock_id,
+ const char *message,
+ const char *secondary_message,
+ const char *gconf_key,
+ const char *check_button_label,
+ const char *first_button_text,
+ ...);
+gchar* _gtk_request_dialog_run (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *message,
+ const char *default_value,
+ int max_length,
+ const char *no_button_text,
+ const char *yes_button_text);
+GtkWidget* _gtk_yesno_dialog_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *message,
+ const char *no_button_text,
+ const char *yes_button_text);
GtkWidget*
-_gtk_yesno_dialog_with_checkbutton_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *message,
- const char *no_button_text,
- const char *yes_button_text,
- const char *check_button_label,
- const char *gconf_key);
+_gtk_yesno_dialog_with_checkbutton_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *message,
+ const char *no_button_text,
+ const char *yes_button_text,
+ const char *check_button_label,
+ const char *gconf_key);
void
-_gtk_error_dialog_from_gerror_run (GtkWindow *parent,
- const char *title,
- GError **gerror);
+_gtk_error_dialog_from_gerror_run (GtkWindow *parent,
+ const char *title,
+ GError **gerror);
void
-_gtk_error_dialog_from_gerror_show (GtkWindow *parent,
- const char *title,
- GError **gerror);
-void _gtk_error_dialog_run (GtkWindow *parent,
- const gchar *format,
- ...) G_GNUC_PRINTF (2, 3);
-void _gtk_info_dialog_run (GtkWindow *parent,
- const gchar *format,
- ...) G_GNUC_PRINTF (2, 3);
-GdkPixbuf * _g_icon_get_pixbuf (GIcon *icon,
- int size,
- GtkIconTheme *icon_theme);
-GdkPixbuf * get_mime_type_pixbuf (const char *mime_type,
- int icon_size,
- GtkIconTheme *icon_theme);
-int _gtk_icon_get_pixel_size (GtkWidget *widget,
- GtkIconSize size);
-void show_help_dialog (GtkWindow *parent,
- const char *section);
+_gtk_error_dialog_from_gerror_show (GtkWindow *parent,
+ const char *title,
+ GError **gerror);
+void _gtk_error_dialog_run (GtkWindow *parent,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
+void _gtk_info_dialog_run (GtkWindow *parent,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
+GdkPixbuf * _g_icon_get_pixbuf (GIcon *icon,
+ int size,
+ GtkIconTheme *icon_theme);
+GdkPixbuf * get_mime_type_pixbuf (const char *mime_type,
+ int icon_size,
+ GtkIconTheme *icon_theme);
+int _gtk_icon_get_pixel_size (GtkWidget *widget,
+ GtkIconSize size);
+void show_help_dialog (GtkWindow *parent,
+ const char *section);
void _gtk_container_remove_children
- (GtkContainer *container,
- gpointer start_after_this,
- gpointer stop_before_this);
-int _gtk_container_get_pos (GtkContainer *container,
- GtkWidget *child);
-guint _gtk_container_get_n_children (GtkContainer *container);
+ (GtkContainer *container,
+ gpointer start_after_this,
+ gpointer stop_before_this);
+int _gtk_container_get_pos (GtkContainer *container,
+ GtkWidget *child);
+guint _gtk_container_get_n_children (GtkContainer *container);
GtkBuilder *
- _gtk_builder_new_from_file (const char *filename,
- const char *extension);
+ _gtk_builder_new_from_file (const char *filename,
+ const char *extension);
GtkWidget *
- _gtk_builder_get_widget (GtkBuilder *builder,
- const char *name);
-GtkWidget * _gtk_combo_box_new_with_texts (const char *first_text,
- ...);
-void _gtk_combo_box_append_texts (GtkComboBox *combo_box,
- const char *first_text,
- ...);
-GtkWidget * _gtk_image_new_from_xpm_data (char *xpm_data[]);
-GtkWidget * _gtk_image_new_from_inline (const guint8 *data);
-void _gtk_widget_get_screen_size (GtkWidget *widget,
- int *width,
- int *height);
-void _gtk_tree_path_list_free (GList *list);
+ _gtk_builder_get_widget (GtkBuilder *builder,
+ const char *name);
+GtkWidget * _gtk_combo_box_new_with_texts (const char *first_text,
+ ...);
+void _gtk_combo_box_append_texts (GtkComboBox *combo_box,
+ const char *first_text,
+ ...);
+GtkWidget * _gtk_image_new_from_xpm_data (char *xpm_data[]);
+GtkWidget * _gtk_image_new_from_inline (const guint8 *data);
+void _gtk_widget_get_screen_size (GtkWidget *widget,
+ int *width,
+ int *height);
+void _gtk_tree_path_list_free (GList *list);
+int _gtk_paned_get_position2 (GtkPaned *paned);
+void _gtk_paned_set_position2 (GtkPaned *paned,
+ int pos);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]