[gtk+] inspector: Allow extensions to request a picker
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Allow extensions to request a picker
- Date: Wed, 10 Dec 2014 01:58:26 +0000 (UTC)
commit 702b647d4e18b20b1b8056f584a80f9c37bddb83
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 9 18:22:12 2014 -0500
inspector: Allow extensions to request a picker
Look for a 'use-picker' property on the extension page
and add a picker button to the header bar if says so.
gtk/inspector/window.c | 36 +++++++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index a7b5f82..ceba1fa 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -150,8 +150,10 @@ gtk_inspector_window_init (GtkInspectorWindow *iw)
GIOExtension *extension = l->data;
GType type;
GtkWidget *widget;
+ const char *name;
char *title;
- GtkWidget *box;
+ GtkWidget *button;
+ gboolean use_picker;
type = g_io_extension_get_type (extension);
@@ -159,16 +161,32 @@ gtk_inspector_window_init (GtkInspectorWindow *iw)
iw->extra_pages = g_list_prepend (iw->extra_pages, widget);
+ name = g_io_extension_get_name (extension);
g_object_get (widget, "title", &title, NULL);
- gtk_stack_add_titled (GTK_STACK (iw->top_stack), widget,
- g_io_extension_get_name (extension),
- title);
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_stack_add_named (GTK_STACK (iw->button_stack), box,
- g_io_extension_get_name (extension));
-
- gtk_widget_show (box);
+
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (widget), "use-picker"))
+ g_object_get (widget, "use-picker", &use_picker, NULL);
+ else
+ use_picker = FALSE;
+
+ if (use_picker)
+ {
+ button = gtk_button_new_from_icon_name ("find-location-symbolic",
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_halign (button, GTK_ALIGN_START);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (gtk_inspector_on_inspect), iw);
+ }
+ else
+ button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+ gtk_stack_add_titled (GTK_STACK (iw->top_stack), widget, name, title);
+ gtk_stack_add_named (GTK_STACK (iw->button_stack), button, name);
gtk_widget_show (widget);
+ gtk_widget_show (button);
+
+ g_free (title);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]