mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 08:40:08 +00:00
inspector: some code reshuffling
This commit is contained in:
parent
6a9ea3487e
commit
2e4c87038e
@ -763,7 +763,7 @@ font_changed (GObject *object, GParamSpec *pspec, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
property_widget (GObject *object,
|
property_editor (GObject *object,
|
||||||
GParamSpec *spec,
|
GParamSpec *spec,
|
||||||
GtkInspectorPropEditor *editor)
|
GtkInspectorPropEditor *editor)
|
||||||
{
|
{
|
||||||
@ -1074,7 +1074,8 @@ gtk_cell_layout_get_model (GtkCellLayout *layout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
model_properties (GtkButton *button, GtkInspectorPropEditor *editor)
|
model_properties (GtkButton *button,
|
||||||
|
GtkInspectorPropEditor *editor)
|
||||||
{
|
{
|
||||||
GObject *model;
|
GObject *model;
|
||||||
|
|
||||||
@ -1083,14 +1084,15 @@ model_properties (GtkButton *button, GtkInspectorPropEditor *editor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
attribute_mapping_changed (GtkComboBox *box, GtkInspectorPropEditor *editor)
|
attribute_mapping_changed (GtkComboBox *combo,
|
||||||
|
GtkInspectorPropEditor *editor)
|
||||||
{
|
{
|
||||||
gint col;
|
gint col;
|
||||||
gpointer layout;
|
gpointer layout;
|
||||||
GtkCellRenderer *cell;
|
GtkCellRenderer *cell;
|
||||||
GtkCellArea *area;
|
GtkCellArea *area;
|
||||||
|
|
||||||
col = gtk_combo_box_get_active (box) - 1;
|
col = gtk_combo_box_get_active (combo) - 1;
|
||||||
layout = g_object_get_data (editor->priv->object, "gtk-inspector-cell-layout");
|
layout = g_object_get_data (editor->priv->object, "gtk-inspector-cell-layout");
|
||||||
if (GTK_IS_CELL_LAYOUT (layout))
|
if (GTK_IS_CELL_LAYOUT (layout))
|
||||||
{
|
{
|
||||||
@ -1103,6 +1105,86 @@ attribute_mapping_changed (GtkComboBox *box, GtkInspectorPropEditor *editor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
attribute_editor (GObject *object,
|
||||||
|
GParamSpec *spec,
|
||||||
|
GtkInspectorPropEditor *editor)
|
||||||
|
{
|
||||||
|
gpointer layout;
|
||||||
|
GtkCellArea *area;
|
||||||
|
GtkTreeModel *model = NULL;
|
||||||
|
gint col = -1;
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkWidget *button;
|
||||||
|
GtkWidget *vbox;
|
||||||
|
GtkWidget *box;
|
||||||
|
GtkWidget *combo;
|
||||||
|
gchar *text;
|
||||||
|
gint i;
|
||||||
|
gboolean sensitive;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
GtkListStore *store;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
layout = g_object_get_data (object, "gtk-inspector-cell-layout");
|
||||||
|
if (GTK_IS_CELL_LAYOUT (layout))
|
||||||
|
{
|
||||||
|
area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (layout));
|
||||||
|
col = gtk_cell_area_attribute_get_column (area,
|
||||||
|
GTK_CELL_RENDERER (object),
|
||||||
|
editor->priv->name);
|
||||||
|
model = gtk_cell_layout_get_model (GTK_CELL_LAYOUT (layout));
|
||||||
|
}
|
||||||
|
|
||||||
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
|
||||||
|
label = gtk_label_new (_("Attribute mapping"));
|
||||||
|
gtk_widget_set_margin_top (label, 10);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||||
|
|
||||||
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Model:")));
|
||||||
|
text = g_strdup_printf (_("%p (%s)"), model, g_type_name (G_TYPE_FROM_INSTANCE (model)));
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (text));
|
||||||
|
g_free (text);
|
||||||
|
button = gtk_button_new_with_label (_("Properties"));
|
||||||
|
g_object_set_data (G_OBJECT (button), "model", model);
|
||||||
|
g_signal_connect (button, "clicked", G_CALLBACK (model_properties), editor);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), button);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), box);
|
||||||
|
|
||||||
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Column:")));
|
||||||
|
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
|
||||||
|
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
||||||
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
|
||||||
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
|
||||||
|
"text", 0,
|
||||||
|
"sensitive", 1,
|
||||||
|
NULL);
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter, 0, _("None"), 1, TRUE, -1);
|
||||||
|
for (i = 0; i < gtk_tree_model_get_n_columns (model); i++)
|
||||||
|
{
|
||||||
|
text = g_strdup_printf ("%d", i);
|
||||||
|
sensitive = g_value_type_transformable (gtk_tree_model_get_column_type (model, i),
|
||||||
|
spec->value_type);
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter, 0, text, 1, sensitive, -1);
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), col + 1);
|
||||||
|
attribute_mapping_changed (GTK_COMBO_BOX (combo), editor);
|
||||||
|
g_signal_connect (combo, "changed",
|
||||||
|
G_CALLBACK (attribute_mapping_changed), editor);
|
||||||
|
gtk_container_add (GTK_CONTAINER (box), combo);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), box);
|
||||||
|
gtk_widget_show_all (vbox);
|
||||||
|
|
||||||
|
return vbox;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
constructed (GObject *object)
|
constructed (GObject *object)
|
||||||
{
|
{
|
||||||
@ -1123,84 +1205,13 @@ constructed (GObject *object)
|
|||||||
if (!can_modify)
|
if (!can_modify)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
editor->priv->editor = property_widget (editor->priv->object, spec, editor);
|
editor->priv->editor = property_editor (editor->priv->object, spec, editor);
|
||||||
gtk_widget_show (editor->priv->editor);
|
gtk_widget_show (editor->priv->editor);
|
||||||
gtk_container_add (GTK_CONTAINER (editor), editor->priv->editor);
|
gtk_container_add (GTK_CONTAINER (editor), editor->priv->editor);
|
||||||
|
|
||||||
if (GTK_IS_CELL_RENDERER (editor->priv->object))
|
if (GTK_IS_CELL_RENDERER (editor->priv->object))
|
||||||
{
|
gtk_container_add (GTK_CONTAINER (editor),
|
||||||
gpointer layout;
|
attribute_editor (editor->priv->object, spec, editor));
|
||||||
GtkCellArea *area;
|
|
||||||
GtkTreeModel *model = NULL;
|
|
||||||
gint col = -1;
|
|
||||||
GtkWidget *button;
|
|
||||||
GtkWidget *box;
|
|
||||||
GtkWidget *combo;
|
|
||||||
gchar *text;
|
|
||||||
gint i;
|
|
||||||
gboolean sensitive;
|
|
||||||
GtkCellRenderer *renderer;
|
|
||||||
GtkListStore *store;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
layout = g_object_get_data (editor->priv->object, "gtk-inspector-cell-layout");
|
|
||||||
if (GTK_IS_CELL_LAYOUT (layout))
|
|
||||||
{
|
|
||||||
area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (layout));
|
|
||||||
col = gtk_cell_area_attribute_get_column (area,
|
|
||||||
GTK_CELL_RENDERER (editor->priv->object),
|
|
||||||
editor->priv->name);
|
|
||||||
model = gtk_cell_layout_get_model (GTK_CELL_LAYOUT (layout));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (col != -1)
|
|
||||||
gtk_widget_set_sensitive (editor->priv->editor, FALSE);
|
|
||||||
|
|
||||||
label = gtk_label_new (_("Attribute mapping"));
|
|
||||||
gtk_widget_set_margin_top (label, 10);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
gtk_container_add (GTK_CONTAINER (editor), label);
|
|
||||||
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Model:")));
|
|
||||||
text = g_strdup_printf (_("%p (%s)"), model, g_type_name (G_TYPE_FROM_INSTANCE (model)));
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (text));
|
|
||||||
g_free (text);
|
|
||||||
button = gtk_button_new_with_label (_("Properties"));
|
|
||||||
g_object_set_data (G_OBJECT (button), "model", model);
|
|
||||||
g_signal_connect (button, "clicked", G_CALLBACK (model_properties), editor);
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), button);
|
|
||||||
gtk_widget_show_all (box);
|
|
||||||
gtk_container_add (GTK_CONTAINER (editor), box);
|
|
||||||
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Column:")));
|
|
||||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
|
|
||||||
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
|
||||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
|
|
||||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
|
|
||||||
"text", 0,
|
|
||||||
"sensitive", 1,
|
|
||||||
NULL);
|
|
||||||
gtk_list_store_append (store, &iter);
|
|
||||||
gtk_list_store_set (store, &iter, 0, _("None"), 1, TRUE, -1);
|
|
||||||
for (i = 0; i < gtk_tree_model_get_n_columns (model); i++)
|
|
||||||
{
|
|
||||||
text = g_strdup_printf ("%d", i);
|
|
||||||
sensitive = g_value_type_transformable (gtk_tree_model_get_column_type (model, i),
|
|
||||||
spec->value_type);
|
|
||||||
gtk_list_store_append (store, &iter);
|
|
||||||
gtk_list_store_set (store, &iter, 0, text, 1, sensitive, -1);
|
|
||||||
g_free (text);
|
|
||||||
}
|
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), col + 1);
|
|
||||||
g_signal_connect (combo, "changed",
|
|
||||||
G_CALLBACK (attribute_mapping_changed), editor);
|
|
||||||
gtk_container_add (GTK_CONTAINER (box), combo);
|
|
||||||
gtk_widget_show_all (box);
|
|
||||||
gtk_container_add (GTK_CONTAINER (editor), box);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user