dbus/tools dbus-names-model.c,1.1,1.2 dbus-viewer.c,1.7,1.8

Havoc Pennington hp at freedesktop.org
Sun Jan 30 15:29:52 PST 2005


Update of /cvs/dbus/dbus/tools
In directory gabe:/tmp/cvs-serv18563/tools

Modified Files:
	dbus-names-model.c dbus-viewer.c 
Log Message:
2005-01-30  Havoc Pennington  <hp at 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 



Index: dbus-names-model.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-names-model.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-names-model.c	30 Jan 2005 23:06:32 -0000	1.1
+++ dbus-names-model.c	30 Jan 2005 23:29:50 -0000	1.2
@@ -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 @@
       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 @@
 
   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);
 }
 

Index: dbus-viewer.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-viewer.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-viewer.c	30 Jan 2005 23:06:32 -0000	1.7
+++ dbus-viewer.c	30 Jan 2005 23:29:50 -0000	1.8
@@ -76,22 +76,27 @@
 
   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),



More information about the dbus-commit mailing list