summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-30 23:29:50 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-30 23:29:50 +0000
commitd5b7d7a78c0fb2e41d5966a0778b08f8d8e35ea4 (patch)
tree3cfe3274a6b9c1d8df4a45e311e672aed08bf0cd /tools
parent1dcacffc325e50754d4cc3338822d1f03c8b6e45 (diff)
2005-01-30 Havoc Pennington <hp@redhat.com>
* tools/dbus-names-model.c (have_names_notify): fix this * dbus/dbus-message.c (_dbus_message_iter_get_args_valist): clean up the string array handling a bit
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-names-model.c71
-rw-r--r--tools/dbus-viewer.c13
2 files changed, 20 insertions, 64 deletions
diff --git a/tools/dbus-names-model.c b/tools/dbus-names-model.c
index 09f1236d..4353daa8 100644
--- a/tools/dbus-names-model.c
+++ b/tools/dbus-names-model.c
@@ -25,63 +25,11 @@
enum
{
- MODEL_COLUMN_NAME_DATA,
+ MODEL_COLUMN_NAME,
MODEL_COLUMN_LAST
};
-typedef struct
-{
- int refcount;
- char *name;
-} NameData;
-
-static NameData*
-name_data_new (const char *name)
-{
- NameData *nd;
-
- nd = g_new0 (NameData, 1);
-
- nd->refcount = 1;
- nd->name = g_strdup (name);
-
- return nd;
-}
-
-static NameData*
-name_data_ref (NameData *nd)
-{
- nd->refcount += 1;
- return nd;
-}
-
-static void
-name_data_unref (NameData *nd)
-{
- nd->refcount -= 1;
- if (nd->refcount == 0)
- {
- g_free (nd->name);
- g_free (nd);
- }
-}
-
-static GType
-name_data_get_gtype (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static ("NameData",
- (GBoxedCopyFunc) name_data_ref,
- (GBoxedFreeFunc) name_data_unref);
-
- return our_type;
-}
-
-#define NAME_DATA_TYPE (name_data_get_gtype())
-
typedef struct NamesModel NamesModel;
typedef struct NamesModelClass NamesModelClass;
@@ -134,26 +82,29 @@ have_names_notify (DBusGPendingCall *call,
g_assert (error != NULL);
g_printerr (_("Failed to load names on the bus: %s\n"), error->message);
+ g_error_free (error);
return;
}
i = 0;
while (names[i])
{
- NameData *nd;
GtkTreeIter iter;
-
- nd = name_data_new (names[i]);
+ g_assert (i < n_elements);
+
+#if 0
+ g_printerr ("%d of %d: %s\n",
+ i, n_elements, names[i]);
+#endif
+
gtk_tree_store_append (GTK_TREE_STORE (names_model),
&iter, NULL);
gtk_tree_store_set (GTK_TREE_STORE (names_model),
&iter,
- MODEL_COLUMN_NAME_DATA, nd,
+ MODEL_COLUMN_NAME, names[i],
-1);
-
- name_data_unref (nd);
++i;
}
@@ -315,7 +266,7 @@ names_model_init (NamesModel *names_model)
tree_store = GTK_TREE_STORE (names_model);
- types[0] = NAME_DATA_TYPE;
+ types[0] = G_TYPE_STRING; /* name */
gtk_tree_store_set_column_types (tree_store, MODEL_COLUMN_LAST, types);
}
diff --git a/tools/dbus-viewer.c b/tools/dbus-viewer.c
index 524030c6..41660135 100644
--- a/tools/dbus-viewer.c
+++ b/tools/dbus-viewer.c
@@ -76,22 +76,27 @@ tree_window_new (DBusGConnection *connection,
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (w->window), vbox);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (vbox), hbox);
-
/* Create names option menu */
if (connection)
{
+ GtkCellRenderer *cell;
w->names_model = names_model;
combo = gtk_combo_box_new_with_model (w->names_model);
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
+ "text", 0,
+ NULL);
+
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
}
/* Create tree view */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (vbox), hbox);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),