[gimp/gtk3-port: 386/460] app: behold unseen fancy shit in preferences
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 386/460] app: behold unseen fancy shit in preferences
- Date: Sun, 20 May 2018 15:44:02 +0000 (UTC)
commit 0b4cc9dec700d95259f6f2a11c37788355009cac
Author: Michael Natterer <mitch gimp org>
Date: Wed May 9 11:20:11 2018 +0200
app: behold unseen fancy shit in preferences
app/widgets/gimpprefsbox.c | 124 ++++++++-----------------------------------
1 files changed, 23 insertions(+), 101 deletions(-)
---
diff --git a/app/widgets/gimpprefsbox.c b/app/widgets/gimpprefsbox.c
index 66d95aa..5e655fc 100644
--- a/app/widgets/gimpprefsbox.c
+++ b/app/widgets/gimpprefsbox.c
@@ -41,8 +41,7 @@ enum
COLUMN_PAGE_ICON_NAME,
COLUMN_PAGE_ICON_SIZE,
COLUMN_PAGE_TITLE,
- COLUMN_PAGE_HELP_ID,
- COLUMN_PAGE_INDEX
+ COLUMN_PAGE_HELP_ID
};
@@ -50,14 +49,13 @@ struct _GimpPrefsBoxPrivate
{
GtkTreeStore *store;
GtkWidget *tree_view;
- GtkWidget *notebook;
+ GtkWidget *stack;
GtkWidget *label;
GtkWidget *image;
gint tree_icon_size;
gint page_icon_size;
- gint page_index;
gchar *page_icon_name;
gchar *page_help_id;
};
@@ -65,14 +63,10 @@ struct _GimpPrefsBoxPrivate
#define GET_PRIVATE(obj) (((GimpPrefsBox *) (obj))->priv)
-static void gimp_prefs_box_finalize (GObject *object);
+static void gimp_prefs_box_finalize (GObject *object);
-static void gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
- GimpPrefsBox *box);
-static void gimp_prefs_box_notebook_page_callback (GtkNotebook *notebook,
- gpointer page,
- guint page_num,
- GimpPrefsBox *box);
+static void gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
+ GimpPrefsBox *box);
G_DEFINE_TYPE (GimpPrefsBox, gimp_prefs_box, GTK_TYPE_BOX)
@@ -126,15 +120,14 @@ gimp_prefs_box_init (GimpPrefsBox *box)
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
- private->store = gtk_tree_store_new (8,
+ private->store = gtk_tree_store_new (7,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INT);
+ G_TYPE_STRING);
private->tree_view =
gtk_tree_view_new_with_model (GTK_TREE_MODEL (private->store));
g_object_unref (private->store);
@@ -162,7 +155,7 @@ gimp_prefs_box_init (GimpPrefsBox *box)
gtk_widget_show (private->tree_view);
- /* the notebook */
+ /* the stack */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_box_pack_start (GTK_BOX (box), vbox, TRUE, TRUE, 0);
@@ -195,20 +188,17 @@ gimp_prefs_box_init (GimpPrefsBox *box)
gtk_box_pack_end (GTK_BOX (hbox), private->image, FALSE, FALSE, 0);
gtk_widget_show (private->image);
- /* The main preferences notebook */
- private->notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (private->notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (private->notebook), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), private->notebook, TRUE, TRUE, 0);
- gtk_widget_show (private->notebook);
+ /* The main preferences stack */
+ private->stack = gtk_stack_new ();
+ gtk_stack_set_transition_type (GTK_STACK (private->stack),
+ GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
+ gtk_box_pack_start (GTK_BOX (vbox), private->stack, TRUE, TRUE, 0);
+ gtk_widget_show (private->stack);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (private->tree_view));
g_signal_connect (sel, "changed",
G_CALLBACK (gimp_prefs_box_tree_select_callback),
box);
- g_signal_connect (private->notebook, "switch-page",
- G_CALLBACK (gimp_prefs_box_notebook_page_callback),
- box);
}
static void
@@ -232,7 +222,7 @@ gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
gchar *page_title;
gchar *page_icon_name;
gint page_icon_size;
- gint page_index;
+ gchar *page_help_id;
if (! gtk_tree_selection_get_selected (sel, &model, &iter))
return;
@@ -241,7 +231,7 @@ gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
COLUMN_PAGE_ICON_NAME, &page_icon_name,
COLUMN_PAGE_ICON_SIZE, &page_icon_size,
COLUMN_PAGE_TITLE, &page_title,
- COLUMN_PAGE_INDEX, &page_index,
+ COLUMN_PAGE_HELP_ID, &page_help_id,
-1);
gtk_label_set_text (GTK_LABEL (private->label), page_title);
@@ -252,78 +242,10 @@ gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
page_icon_size);
g_free (page_icon_name);
- g_signal_handlers_block_by_func (private->notebook,
- gimp_prefs_box_notebook_page_callback,
- sel);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (private->notebook),
- page_index);
-
- g_signal_handlers_unblock_by_func (private->notebook,
- gimp_prefs_box_notebook_page_callback,
- sel);
-}
+ gtk_stack_set_visible_child_name (GTK_STACK (private->stack),
+ page_help_id);
-static void
-gimp_prefs_box_notebook_page_callback (GtkNotebook *notebook,
- gpointer page,
- guint page_num,
- GimpPrefsBox *box)
-{
- GimpPrefsBoxPrivate *private = GET_PRIVATE (box);
- GtkTreeSelection *sel;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean iter_valid;
-
- sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (private->tree_view));
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (private->tree_view));
-
- for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
- iter_valid;
- iter_valid = gtk_tree_model_iter_next (model, &iter))
- {
- gint index;
-
- gtk_tree_model_get (model, &iter,
- COLUMN_PAGE_INDEX, &index,
- -1);
-
- if (index == page_num)
- {
- gtk_tree_selection_select_iter (sel, &iter);
- return;
- }
-
- if (gtk_tree_model_iter_has_child (model, &iter))
- {
- gint num_children;
- gint i;
-
- num_children = gtk_tree_model_iter_n_children (model, &iter);
-
- for (i = 0; i < num_children; i++)
- {
- GtkTreeIter child_iter;
-
- gtk_tree_model_iter_nth_child (model, &child_iter, &iter, i);
- gtk_tree_model_get (model, &child_iter,
- COLUMN_PAGE_INDEX, &index,
- -1);
-
- if (index == page_num)
- {
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (model, &child_iter);
- gtk_tree_view_expand_to_path (GTK_TREE_VIEW (private->tree_view),
- path);
- gtk_tree_selection_select_iter (sel, &child_iter);
- return;
- }
- }
- }
- }
+ g_free (page_help_id);
}
@@ -355,7 +277,8 @@ gimp_prefs_box_add_page (GimpPrefsBox *box,
private = GET_PRIVATE (box);
page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- gtk_notebook_append_page (GTK_NOTEBOOK (private->notebook), page_vbox, NULL);
+ gtk_stack_add_named (GTK_STACK (private->stack), page_vbox,
+ help_id /* EEK */);
gtk_widget_show (page_vbox);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
@@ -384,7 +307,6 @@ gimp_prefs_box_add_page (GimpPrefsBox *box,
COLUMN_PAGE_ICON_SIZE, private->page_icon_size,
COLUMN_PAGE_TITLE , page_title,
COLUMN_PAGE_HELP_ID, help_id,
- COLUMN_PAGE_INDEX, private->page_index++,
-1);
return vbox;
@@ -460,7 +382,7 @@ gimp_prefs_box_set_page_scrollable (GimpPrefsBox *box,
scrolled_win = gtk_widget_get_ancestor (page, GTK_TYPE_SCROLLED_WINDOW);
page_vbox = gtk_widget_get_parent (scrolled_win);
- g_return_if_fail (gtk_widget_get_parent (page_vbox) == private->notebook);
+ g_return_if_fail (gtk_widget_get_parent (page_vbox) == private->stack);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_NEVER,
@@ -488,7 +410,7 @@ gimp_prefs_box_set_page_resettable (GimpPrefsBox *box,
scrolled_win = gtk_widget_get_ancestor (page, GTK_TYPE_SCROLLED_WINDOW);
page_vbox = gtk_widget_get_parent (scrolled_win);
- g_return_val_if_fail (gtk_widget_get_parent (page_vbox) == private->notebook,
+ g_return_val_if_fail (gtk_widget_get_parent (page_vbox) == private->stack,
NULL);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]