mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
inspector: Improve tab switching
Switch the object and resource trees away from activate-on-single-click and add a 'view details' button.
This commit is contained in:
parent
32326f826f
commit
70c3241bd3
@ -99,9 +99,8 @@ on_row_activated (GtkTreeView *tree,
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
static void
|
||||
on_selection_changed (GtkTreeSelection *selection,
|
||||
GtkInspectorObjectTree *wt)
|
||||
GObject *
|
||||
gtk_inspector_object_tree_get_selected (GtkInspectorObjectTree *wt)
|
||||
{
|
||||
GObject *object;
|
||||
GtkTreeIter iter;
|
||||
@ -114,6 +113,17 @@ on_selection_changed (GtkTreeSelection *selection,
|
||||
gtk_tree_model_get (model, &iter,
|
||||
OBJECT, &object,
|
||||
-1);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
on_selection_changed (GtkTreeSelection *selection,
|
||||
GtkInspectorObjectTree *wt)
|
||||
{
|
||||
GObject *object;
|
||||
|
||||
object = gtk_inspector_object_tree_get_selected (wt);
|
||||
if (object)
|
||||
g_signal_emit (wt, signals[OBJECT_SELECTED], 0, object);
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ gboolean gtk_inspector_object_tree_find_object (GtkInspectorObjectTree
|
||||
GObject *object,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
GObject *gtk_inspector_object_tree_get_selected (GtkInspectorObjectTree *wt);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
<property name="model">model</property>
|
||||
<property name="enable-search">True</property>
|
||||
<property name="search-column">2</property>
|
||||
<property name="activate-on-single-click">True</property>
|
||||
<signal name="row-activated" handler="on_row_activated"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection">
|
||||
|
@ -335,9 +335,12 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
||||
guint num_properties;
|
||||
guint i;
|
||||
|
||||
if (pl->priv->object == object || !object)
|
||||
if (!object)
|
||||
return FALSE;
|
||||
|
||||
if (pl->priv->object == object)
|
||||
return TRUE;
|
||||
|
||||
cleanup_object (pl);
|
||||
|
||||
if (!object)
|
||||
|
@ -29,7 +29,7 @@
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CLOSE_DETAILS_BUTTON
|
||||
PROP_BUTTONS
|
||||
};
|
||||
|
||||
enum
|
||||
@ -53,6 +53,8 @@ struct _GtkInspectorResourceListPrivate
|
||||
GtkWidget *info_grid;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *tree;
|
||||
GtkWidget *buttons;
|
||||
GtkWidget *open_details_button;
|
||||
GtkWidget *close_details_button;
|
||||
GtkTreeViewColumn *count_column;
|
||||
GtkCellRenderer *count_renderer;
|
||||
@ -215,8 +217,34 @@ row_activated (GtkTreeView *treeview,
|
||||
GtkTreeViewColumn *column,
|
||||
GtkInspectorResourceList *sl)
|
||||
{
|
||||
if (populate_details (sl, path))
|
||||
if (!populate_details (sl, path))
|
||||
return;
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "details");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "details");
|
||||
}
|
||||
|
||||
static void
|
||||
open_details (GtkWidget *button,
|
||||
GtkInspectorResourceList *sl)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sl->priv->tree));
|
||||
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
return;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
if (populate_details (sl, path))
|
||||
{
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "details");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "details");
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -224,6 +252,7 @@ close_details (GtkWidget *button,
|
||||
GtkInspectorResourceList *sl)
|
||||
{
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "list");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "list");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -231,14 +260,11 @@ visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorResourc
|
||||
{
|
||||
const gchar *child;
|
||||
gboolean resources_visible;
|
||||
gboolean resource_details_visible;
|
||||
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl))));
|
||||
resources_visible = g_strcmp0 (child, "resources") == 0;
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (sl->priv->stack));
|
||||
resource_details_visible = g_strcmp0 (child, "details") == 0;
|
||||
|
||||
gtk_widget_set_visible (sl->priv->close_details_button, resources_visible && resource_details_visible);
|
||||
gtk_widget_set_visible (sl->priv->buttons, resources_visible);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -329,6 +355,8 @@ constructed (GObject *object)
|
||||
{
|
||||
GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object);
|
||||
|
||||
g_signal_connect (rl->priv->open_details_button, "clicked",
|
||||
G_CALLBACK (open_details), rl);
|
||||
g_signal_connect (rl->priv->close_details_button, "clicked",
|
||||
G_CALLBACK (close_details), rl);
|
||||
|
||||
@ -345,8 +373,8 @@ get_property (GObject *object,
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_CLOSE_DETAILS_BUTTON:
|
||||
g_value_take_object (value, rl->priv->close_details_button);
|
||||
case PROP_BUTTONS:
|
||||
g_value_take_object (value, rl->priv->buttons);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -365,8 +393,10 @@ set_property (GObject *object,
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_CLOSE_DETAILS_BUTTON:
|
||||
rl->priv->close_details_button = g_value_get_object (value);
|
||||
case PROP_BUTTONS:
|
||||
rl->priv->buttons = g_value_get_object (value);
|
||||
rl->priv->open_details_button = gtk_stack_get_child_by_name (GTK_STACK (rl->priv->buttons), "list");
|
||||
rl->priv->close_details_button = gtk_stack_get_child_by_name (GTK_STACK (rl->priv->buttons), "details");
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -387,8 +417,8 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
|
||||
|
||||
widget_class->parent_set = parent_set;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CLOSE_DETAILS_BUTTON,
|
||||
g_param_spec_object ("close-details-button", NULL, NULL,
|
||||
g_object_class_install_property (object_class, PROP_BUTTONS,
|
||||
g_param_spec_object ("buttons", NULL, NULL,
|
||||
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/resource-list.ui");
|
||||
|
@ -27,11 +27,10 @@
|
||||
<object class="GtkTreeView" id="tree">
|
||||
<property name="visible">True</property>
|
||||
<property name="model">model</property>
|
||||
<property name="activate-on-single-click">True</property>
|
||||
<signal name="row-activated" handler="row_activated"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection">
|
||||
<property name="mode">none</property>
|
||||
<property name="mode">single</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -52,16 +52,12 @@
|
||||
|
||||
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
|
||||
|
||||
static void
|
||||
on_object_activated (GtkInspectorObjectTree *wt,
|
||||
GObject *selected,
|
||||
const gchar *name,
|
||||
GtkInspectorWindow *iw)
|
||||
static gboolean
|
||||
set_selected_object (GtkInspectorWindow *iw,
|
||||
GObject *selected)
|
||||
{
|
||||
const gchar *tab;
|
||||
|
||||
if (!gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->prop_list), selected))
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
|
||||
gtk_inspector_style_prop_list_set_object (GTK_INSPECTOR_STYLE_PROP_LIST (iw->style_prop_list), selected);
|
||||
@ -77,11 +73,26 @@ on_object_activated (GtkInspectorObjectTree *wt,
|
||||
gtk_inspector_menu_set_object (GTK_INSPECTOR_MENU (iw->menu), selected);
|
||||
gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
on_object_activated (GtkInspectorObjectTree *wt,
|
||||
GObject *selected,
|
||||
const gchar *name,
|
||||
GtkInspectorWindow *iw)
|
||||
{
|
||||
const gchar *tab;
|
||||
|
||||
if (!set_selected_object (iw, selected))
|
||||
return;
|
||||
|
||||
tab = g_object_get_data (G_OBJECT (wt), "next-tab");
|
||||
if (tab)
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_details), tab);
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -94,9 +105,24 @@ on_object_selected (GtkInspectorObjectTree *wt,
|
||||
}
|
||||
|
||||
static void
|
||||
close_details (GtkWidget *button, GtkInspectorWindow *iw)
|
||||
close_object_details (GtkWidget *button, GtkInspectorWindow *iw)
|
||||
{
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-tree");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "list");
|
||||
}
|
||||
|
||||
static void
|
||||
open_object_details (GtkWidget *button, GtkInspectorWindow *iw)
|
||||
{
|
||||
GObject *selected;
|
||||
|
||||
selected = gtk_inspector_object_tree_get_selected (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree));
|
||||
|
||||
if (!set_selected_object (iw, selected))
|
||||
return;
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -104,15 +130,12 @@ visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorWindow
|
||||
{
|
||||
const gchar *child;
|
||||
gboolean objects_visible;
|
||||
gboolean object_details_visible;
|
||||
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (iw->top_stack));
|
||||
objects_visible = g_strcmp0 (child, "objects") == 0;
|
||||
child = gtk_stack_get_visible_child_name (GTK_STACK (iw->object_stack));
|
||||
object_details_visible = g_strcmp0 (child, "object-details") == 0;
|
||||
|
||||
gtk_widget_set_visible (iw->select_object, objects_visible);
|
||||
gtk_widget_set_visible (iw->close_object_details, objects_visible && object_details_visible);
|
||||
gtk_widget_set_visible (iw->object_buttons, objects_visible);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -152,7 +175,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_tree);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, close_object_details);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_buttons);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, select_object);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, child_prop_list);
|
||||
@ -172,7 +195,8 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_object_selected);
|
||||
gtk_widget_class_bind_template_callback (widget_class, close_details);
|
||||
gtk_widget_class_bind_template_callback (widget_class, open_object_details);
|
||||
gtk_widget_class_bind_template_callback (widget_class, close_object_details);
|
||||
}
|
||||
|
||||
static GdkScreen *
|
||||
|
@ -46,7 +46,7 @@ typedef struct
|
||||
GtkWidget *object_tree;
|
||||
GtkWidget *object_id;
|
||||
GtkWidget *object_details;
|
||||
GtkWidget *close_object_details;
|
||||
GtkWidget *object_buttons;
|
||||
GtkWidget *select_object;
|
||||
GtkWidget *prop_list;
|
||||
GtkWidget *child_prop_list;
|
||||
|
@ -31,11 +31,37 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="close_object_details">
|
||||
<object class="GtkStack" id="object_buttons">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Show Details</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="open_object_details"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">dialog-information-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">list</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Show all Objects</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="close_details"/>
|
||||
<signal name="clicked" handler="close_object_details"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
@ -47,16 +73,44 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">details</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="close_resource_details">
|
||||
<object class="GtkStack" id="resource_buttons">
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Show Details</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">dialog-information-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">list</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Show all Resources</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="clicked" handler="close_details"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
@ -68,6 +122,11 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">details</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
</packing>
|
||||
@ -266,7 +325,7 @@
|
||||
<child>
|
||||
<object class="GtkInspectorResourceList">
|
||||
<property name="visible">True</property>
|
||||
<property name="close-details-button">close_resource_details</property>
|
||||
<property name="buttons">resource_buttons</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">resources</property>
|
||||
|
@ -1,5 +1,7 @@
|
||||
N_("Select an Object");
|
||||
N_("Show Details");
|
||||
N_("Show all Objects");
|
||||
N_("Show Details");
|
||||
N_("Show all Resources");
|
||||
N_("Miscellaneous");
|
||||
N_("Properties");
|
||||
|
Loading…
Reference in New Issue
Block a user