forked from AuroraMiddleware/gtk
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 *
|
||||
property_widget (GObject *object,
|
||||
property_editor (GObject *object,
|
||||
GParamSpec *spec,
|
||||
GtkInspectorPropEditor *editor)
|
||||
{
|
||||
@ -1074,7 +1074,8 @@ gtk_cell_layout_get_model (GtkCellLayout *layout)
|
||||
}
|
||||
|
||||
static void
|
||||
model_properties (GtkButton *button, GtkInspectorPropEditor *editor)
|
||||
model_properties (GtkButton *button,
|
||||
GtkInspectorPropEditor *editor)
|
||||
{
|
||||
GObject *model;
|
||||
|
||||
@ -1083,14 +1084,15 @@ model_properties (GtkButton *button, GtkInspectorPropEditor *editor)
|
||||
}
|
||||
|
||||
static void
|
||||
attribute_mapping_changed (GtkComboBox *box, GtkInspectorPropEditor *editor)
|
||||
attribute_mapping_changed (GtkComboBox *combo,
|
||||
GtkInspectorPropEditor *editor)
|
||||
{
|
||||
gint col;
|
||||
gpointer layout;
|
||||
GtkCellRenderer *cell;
|
||||
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");
|
||||
if (GTK_IS_CELL_LAYOUT (layout))
|
||||
{
|
||||
@ -1103,37 +1105,18 @@ attribute_mapping_changed (GtkComboBox *box, GtkInspectorPropEditor *editor)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GtkInspectorPropEditor *editor = GTK_INSPECTOR_PROP_EDITOR (object);
|
||||
GParamSpec *spec;
|
||||
GtkWidget *label;
|
||||
gboolean can_modify;
|
||||
|
||||
spec = find_property (editor);
|
||||
|
||||
label = gtk_label_new (g_param_spec_get_nick (spec));
|
||||
gtk_widget_show (label);
|
||||
gtk_container_add (GTK_CONTAINER (editor), label);
|
||||
|
||||
can_modify = ((spec->flags & G_PARAM_WRITABLE) != 0 &&
|
||||
(spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0);
|
||||
|
||||
if (!can_modify)
|
||||
return;
|
||||
|
||||
editor->priv->editor = property_widget (editor->priv->object, spec, editor);
|
||||
gtk_widget_show (editor->priv->editor);
|
||||
gtk_container_add (GTK_CONTAINER (editor), editor->priv->editor);
|
||||
|
||||
if (GTK_IS_CELL_RENDERER (editor->priv->object))
|
||||
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;
|
||||
@ -1143,23 +1126,21 @@ constructed (GObject *object)
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
layout = g_object_get_data (editor->priv->object, "gtk-inspector-cell-layout");
|
||||
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 (editor->priv->object),
|
||||
GTK_CELL_RENDERER (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);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
|
||||
label = gtk_label_new (_("Attribute mapping"));
|
||||
gtk_widget_set_margin_top (label, 10);
|
||||
gtk_widget_show (label);
|
||||
gtk_container_add (GTK_CONTAINER (editor), label);
|
||||
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:")));
|
||||
@ -1170,8 +1151,7 @@ constructed (GObject *object)
|
||||
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);
|
||||
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:")));
|
||||
@ -1195,12 +1175,43 @@ constructed (GObject *object)
|
||||
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_widget_show_all (box);
|
||||
gtk_container_add (GTK_CONTAINER (editor), box);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), box);
|
||||
gtk_widget_show_all (vbox);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
GtkInspectorPropEditor *editor = GTK_INSPECTOR_PROP_EDITOR (object);
|
||||
GParamSpec *spec;
|
||||
GtkWidget *label;
|
||||
gboolean can_modify;
|
||||
|
||||
spec = find_property (editor);
|
||||
|
||||
label = gtk_label_new (g_param_spec_get_nick (spec));
|
||||
gtk_widget_show (label);
|
||||
gtk_container_add (GTK_CONTAINER (editor), label);
|
||||
|
||||
can_modify = ((spec->flags & G_PARAM_WRITABLE) != 0 &&
|
||||
(spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0);
|
||||
|
||||
if (!can_modify)
|
||||
return;
|
||||
|
||||
editor->priv->editor = property_editor (editor->priv->object, spec, editor);
|
||||
gtk_widget_show (editor->priv->editor);
|
||||
gtk_container_add (GTK_CONTAINER (editor), editor->priv->editor);
|
||||
|
||||
if (GTK_IS_CELL_RENDERER (editor->priv->object))
|
||||
gtk_container_add (GTK_CONTAINER (editor),
|
||||
attribute_editor (editor->priv->object, spec, editor));
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user