glade3 r1944 - in trunk: . gladeui src
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r1944 - in trunk: . gladeui src
- Date: Sat, 20 Sep 2008 21:32:00 +0000 (UTC)
Author: tvb
Date: Sat Sep 20 21:32:00 2008
New Revision: 1944
URL: http://svn.gnome.org/viewvc/glade3?rev=1944&view=rev
Log:
* src/glade-window.c, gladeui/glade-inspector.c, gladeui/glade-utils.c,
gladeui/glade-app.c:
- Made sure that the first toplevel in the project is selected and visible
at load time in both the workspace and inspector
- Sorted objects from widgets in the inspector view.
Modified:
trunk/ChangeLog
trunk/gladeui/glade-app.c
trunk/gladeui/glade-inspector.c
trunk/gladeui/glade-utils.c
trunk/src/glade-window.c
Modified: trunk/gladeui/glade-app.c
==============================================================================
--- trunk/gladeui/glade-app.c (original)
+++ trunk/gladeui/glade-app.c Sat Sep 20 21:32:00 2008
@@ -998,9 +998,13 @@
node = g_list_next (node))
{
GObject *obj = G_OBJECT (node->data);
+
if (GTK_IS_WINDOW (obj))
+ {
+ glade_project_selection_set (project, obj, TRUE);
glade_widget_show (glade_widget_get_from_gobject (obj));
- break;
+ break;
+ }
}
}
Modified: trunk/gladeui/glade-inspector.c
==============================================================================
--- trunk/gladeui/glade-inspector.c (original)
+++ trunk/gladeui/glade-inspector.c Sat Sep 20 21:32:00 2008
@@ -67,6 +67,7 @@
enum
{
+ TITLE_COLUMN,
WIDGET_COLUMN,
N_COLUMNS
};
@@ -75,6 +76,8 @@
{
GtkWidget *view;
GtkTreeStore *model;
+ GtkTreeIter widgets_iter;
+ GtkTreeIter objects_iter;
GladeProject *project;
};
@@ -143,13 +146,6 @@
}
static void
-inspector_notify_cb (GObject *object,
- GParamSpec *pspec)
-{
- update_model (GLADE_INSPECTOR (object));
-}
-
-static void
glade_inspector_class_init (GladeInspectorClass *klass)
{
GObjectClass *object_class;
@@ -218,7 +214,7 @@
priv->project = NULL;
priv->view = gtk_tree_view_new ();
- priv->model = gtk_tree_store_new (N_COLUMNS, G_TYPE_POINTER);
+ priv->model = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), GTK_TREE_MODEL (priv->model));
g_object_unref (G_OBJECT (priv->model));
@@ -236,9 +232,6 @@
g_signal_connect (G_OBJECT (priv->view), "button-press-event",
G_CALLBACK (button_press_cb), inspector);
- g_signal_connect (G_OBJECT (inspector), "notify::project",
- G_CALLBACK (inspector_notify_cb),
- NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
@@ -323,20 +316,41 @@
if (!priv->project)
return;
- /* make a list of only the toplevel widgets */
+ /* make a list of only the toplevel window widgets */
+ for (l = (GList *) glade_project_get_objects (priv->project); l; l = l->next)
+ {
+ GObject *object = G_OBJECT (l->data);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ g_assert (gwidget);
+
+ if (gwidget->parent == NULL && GTK_IS_WINDOW (object))
+ toplevels = g_list_prepend (toplevels, object);
+ }
+ toplevels = g_list_reverse (toplevels);
+
+ /* recursively fill model */
+ gtk_tree_store_append (priv->model, &priv->widgets_iter, NULL);
+ gtk_tree_store_set (priv->model, &priv->widgets_iter, TITLE_COLUMN, _("Widgets"), -1);
+ fill_model (priv->model, toplevels, &priv->widgets_iter);
+ g_list_free (toplevels);
+
+ /* make a list of only the toplevel non-window widgets */
+ toplevels = NULL;
for (l = (GList *) glade_project_get_objects (priv->project); l; l = l->next)
{
GObject *object = G_OBJECT (l->data);
GladeWidget *gwidget = glade_widget_get_from_gobject (object);
g_assert (gwidget);
- if (gwidget->parent == NULL)
+ if (gwidget->parent == NULL && !GTK_IS_WINDOW (object))
toplevels = g_list_prepend (toplevels, object);
}
toplevels = g_list_reverse (toplevels);
/* recursively fill model */
- fill_model (priv->model, toplevels, NULL);
+ gtk_tree_store_append (priv->model, &priv->objects_iter, NULL);
+ gtk_tree_store_set (priv->model, &priv->objects_iter, TITLE_COLUMN, _("Objects"), -1);
+ fill_model (priv->model, toplevels, &priv->objects_iter);
g_list_free (toplevels);
}
@@ -358,6 +372,14 @@
if (!parent_iter && parent_widget)
return;
+ if (!parent_iter)
+ {
+ if (GTK_IS_WINDOW (widget->object))
+ parent_iter = &inspector->priv->widgets_iter;
+ else
+ parent_iter = &inspector->priv->objects_iter;
+ }
+
gtk_tree_store_append (inspector->priv->model, &widget_iter, parent_iter);
gtk_tree_store_set (inspector->priv->model, &widget_iter, WIDGET_COLUMN, widget, -1);
@@ -567,40 +589,63 @@
{
CellType type = GPOINTER_TO_INT (data);
GladeWidget *widget;
- gchar *icon_name, *text = NULL, *child_type;
+ gchar *icon_name, *text = NULL, *child_type, *title;
- gtk_tree_model_get (tree_model, iter, WIDGET_COLUMN, &widget, -1);
+ gtk_tree_model_get (tree_model, iter,
+ TITLE_COLUMN, &title,
+ WIDGET_COLUMN, &widget,
+ -1);
- /* The cell exists, but no widget has been associated with it */
- if (!GLADE_IS_WIDGET (widget))
+ /* The cell exists, but no widget or title has been associated with it */
+ if (!GLADE_IS_WIDGET (widget) && !title)
return;
- g_return_if_fail (widget->name != NULL);
- g_return_if_fail (widget->adaptor != NULL);
- g_return_if_fail (widget->adaptor->name != NULL);
-
switch (type)
{
case CELL_ICON:
- g_object_get (widget->adaptor, "icon-name", &icon_name, NULL);
- g_object_set (G_OBJECT (cell), "icon-name", icon_name, NULL);
- g_free (icon_name);
+ if (widget)
+ {
+ g_object_get (widget->adaptor, "icon-name", &icon_name, NULL);
+ g_object_set (G_OBJECT (cell), "icon-name", icon_name, NULL);
+ g_free (icon_name);
+ }
+ else
+ g_object_set (G_OBJECT (cell), "icon-name", NULL, NULL);
break;
case CELL_NAME:
- g_object_set (G_OBJECT (cell), "text", widget->name, NULL);
+ if (widget)
+ g_object_set (G_OBJECT (cell),
+ "text", widget->name,
+ "weight", PANGO_WEIGHT_NORMAL,
+ NULL);
+ else if (title)
+ g_object_set (G_OBJECT (cell),
+ "text", title,
+ "weight", PANGO_WEIGHT_BOLD,
+ NULL);
+ else
+ g_object_set (G_OBJECT (cell),
+ "text", "dummy",
+ "weight", PANGO_WEIGHT_NORMAL,
+ NULL);
break;
case CELL_MISC:
- /* special child type / internal child */
- if (glade_widget_get_internal (widget) != NULL)
- text = g_strdup_printf (_("(internal %s)"),
- glade_widget_get_internal (widget));
- else if ((child_type = g_object_get_data (glade_widget_get_object (widget),
- "special-child-type")) != NULL)
- text = g_strdup_printf (_("(%s child)"), child_type);
-
- g_object_set (G_OBJECT (cell), "text", text ? text : " ", NULL);
- if (text) g_free (text);
+ if (widget)
+ {
+ /* special child type / internal child */
+ if (glade_widget_get_internal (widget) != NULL)
+ text = g_strdup_printf (_("(internal %s)"),
+ glade_widget_get_internal (widget));
+ else if ((child_type = g_object_get_data (glade_widget_get_object (widget),
+ "special-child-type")) != NULL)
+ text = g_strdup_printf (_("(%s child)"), child_type);
+
+ g_object_set (G_OBJECT (cell), "text", text ? text : " ", NULL);
+ if (text) g_free (text);
+ }
+ else
+ g_object_set (G_OBJECT (cell), "text", " ", NULL);
break;
default:
break;
@@ -735,6 +780,8 @@
connect_project_signals (inspector, inspector->priv->project);
}
+ update_model (inspector);
+
g_object_notify (G_OBJECT (inspector), "project");
}
@@ -815,11 +862,17 @@
GtkWidget *
glade_inspector_new_with_project (GladeProject *project)
{
+ GladeInspector *inspector;
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- return g_object_new (GLADE_TYPE_INSPECTOR,
- "project", project,
- NULL);
+ inspector = g_object_new (GLADE_TYPE_INSPECTOR,
+ "project", project,
+ NULL);
+
+ /* Make sure we expended to the right path */
+ project_selection_changed_cb (project, inspector);
+
+ return inspector;
}
Modified: trunk/gladeui/glade-utils.c
==============================================================================
--- trunk/gladeui/glade-utils.c (original)
+++ trunk/gladeui/glade-utils.c Sat Sep 20 21:32:00 2008
@@ -1074,11 +1074,7 @@
while (retval == NULL)
{
gtk_tree_model_get (model, next, column, &widget, -1);
- if (widget == NULL) {
- g_warning ("Could not get the glade widget from the model");
- break;
- }
- else if (widget == findme)
+ if (widget == findme)
{
retval = gtk_tree_iter_copy (next);
break;
Modified: trunk/src/glade-window.c
==============================================================================
--- trunk/src/glade-window.c (original)
+++ trunk/src/glade-window.c Sat Sep 20 21:32:00 2008
@@ -2505,7 +2505,9 @@
gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (view), NULL);
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), -1);
-
+
+ /* Kick the inspector in the balls here... */
+ glade_project_selection_changed (project);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]