[I had already sent this to to the list before I was subscribed, so this mail is a dupe of a second one, awaiting moderator approval. I apologize in advance if the first mail also gets posted.] I have made a patch that allows to use arbitrary icons with components. These icons are shown in the component selector widget. (See http://me.in-berlin.de/~jroger/bonobo-icon.png for a screen-shot.) The icon's filename is supplied as oaf_attribute like this: <oaf_attribute name="icon" type="string" value="/usr/share/pixmaps/bonobo/blank-tile.png"/> I have attached the patch and three example icons. Please consider this for inclusion in bonobo. - Sebastian
diff -u --recursive bonobo-0.37/bonobo/bonobo-object-directory.c bonobo-0.37.new/bonobo/bonobo-object-directory.c --- bonobo-0.37/bonobo/bonobo-object-directory.c Fri Feb 9 06:32:14 2001 +++ bonobo-0.37.new/bonobo/bonobo-object-directory.c Mon Mar 5 03:43:30 2001 @@ -25,12 +25,14 @@ gchar* iid; gchar* name; gchar* desc; + gchar* icon; }; ODServerInfo* bonobo_directory_new_server_info (const gchar *iid, const gchar *name, - const gchar *desc) + const gchar *desc, + const gchar *icon) { ODServerInfo *info; @@ -40,6 +42,7 @@ info->iid = iid ? g_strdup (iid) : NULL; info->name = name ? g_strdup (name) : NULL; info->desc = desc ? g_strdup (desc) : NULL; + info->icon = icon ? g_strdup (icon) : NULL; return info; } @@ -62,6 +65,12 @@ return info->desc; } +const gchar* +bonobo_directory_get_server_info_icon (ODServerInfo *info) +{ + return info->icon; +} + void bonobo_directory_server_info_ref (ODServerInfo *info) { @@ -80,6 +89,7 @@ g_free (info->iid); g_free (info->name); g_free (info->desc); + g_free (info->icon); g_free (info); } } @@ -165,7 +175,7 @@ for (i = 0; i < servers->_length; i++) { OAF_ServerInfo *oafinfo = &servers->_buffer[i]; ODServerInfo *info; - gchar *name = NULL, *desc = NULL; + gchar *name = NULL, *desc = NULL, *icon = NULL; for (j = 0; j < oafinfo->props._length; j++) { @@ -178,6 +188,9 @@ else if (strcmp (oafinfo->props._buffer[j].name, "description") == 0) desc = oafinfo->props._buffer[j].v._u.value_string; + + else if (strcmp (oafinfo->props._buffer[j].name, "icon") == 0) + icon = oafinfo->props._buffer[j].v._u.value_string; } /* @@ -193,10 +206,11 @@ if (!desc) desc = name; - + info = bonobo_directory_new_server_info (oafinfo->iid, name, - desc); + desc, + icon); retval = g_list_prepend (retval, info); } diff -u --recursive bonobo-0.37/bonobo/bonobo-object-directory.h bonobo-0.37.new/bonobo/bonobo-object-directory.h --- bonobo-0.37/bonobo/bonobo-object-directory.h Fri Feb 9 06:32:26 2001 +++ bonobo-0.37.new/bonobo/bonobo-object-directory.h Mon Mar 5 03:43:55 2001 @@ -39,10 +39,12 @@ ODServerInfo *bonobo_directory_new_server_info (const gchar *iid, const gchar *name, - const gchar *desc); + const gchar *desc, + const gchar *icon); const gchar *bonobo_directory_get_server_info_id (ODServerInfo *info); const gchar *bonobo_directory_get_server_info_name (ODServerInfo *info); const gchar *bonobo_directory_get_server_info_description (ODServerInfo *info); +const gchar *bonobo_directory_get_server_info_icon (ODServerInfo *info); void bonobo_directory_server_info_ref (ODServerInfo *info); void bonobo_directory_server_info_unref (ODServerInfo *info); diff -u --recursive bonobo-0.37/bonobo/bonobo-selector-widget.c bonobo-0.37.new/bonobo/bonobo-selector-widget.c --- bonobo-0.37/bonobo/bonobo-selector-widget.c Fri Feb 9 06:32:17 2001 +++ bonobo-0.37.new/bonobo/bonobo-selector-widget.c Mon Mar 5 04:01:19 2001 @@ -40,6 +40,7 @@ struct _BonoboSelectorWidgetPrivate { GtkWidget *clist; + GtkWidget *icon; GtkWidget *desc_label; GList *servers; }; @@ -188,11 +189,20 @@ } else { GtkCListClass *cl; - gchar *text; + gchar *text, *icon; gtk_clist_get_text (GTK_CLIST (clist), row, 2, &text); gtk_label_set_text (GTK_LABEL (sel->priv->desc_label), text); + + gtk_clist_get_text (GTK_CLIST (clist), row, + 3, &icon); + if (strcmp (icon, "")) + gnome_pixmap_load_file (GNOME_PIXMAP (sel->priv->icon), + icon); + else + gnome_pixmap_load_xpm_d (GNOME_PIXMAP (sel->priv->icon), + bonobo_insert_component_xpm); cl = gtk_type_class (GTK_TYPE_CLIST); @@ -205,11 +215,11 @@ bonobo_selector_widget_init (GtkWidget *widget) { BonoboSelectorWidget *sel = BONOBO_SELECTOR_WIDGET (widget); - GtkWidget *scrolled, *pixmap; + GtkWidget *scrolled; GtkWidget *hbox; GtkWidget *frame; BonoboSelectorWidgetPrivate *priv; - gchar *titles [] = { N_("Name"), "Description", "ID", NULL }; + gchar *titles [] = { N_("Name"), "Description", "ID", "Icon", NULL }; g_return_if_fail (sel != NULL); @@ -220,13 +230,14 @@ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - priv->clist = gtk_clist_new_with_titles (3, titles); + priv->clist = gtk_clist_new_with_titles (4, titles); gtk_clist_set_selection_mode (GTK_CLIST (priv->clist), GTK_SELECTION_BROWSE); gtk_signal_connect (GTK_OBJECT (priv->clist), "select-row", GTK_SIGNAL_FUNC (select_row), sel); gtk_clist_set_column_visibility (GTK_CLIST (priv->clist), 1, FALSE); gtk_clist_set_column_visibility (GTK_CLIST (priv->clist), 2, FALSE); + gtk_clist_set_column_visibility (GTK_CLIST (priv->clist), 3, FALSE); gtk_clist_column_titles_passive (GTK_CLIST (priv->clist)); gtk_container_add (GTK_CONTAINER (scrolled), priv->clist); @@ -243,8 +254,8 @@ hbox = gtk_hbox_new (FALSE, 0); - pixmap = gnome_pixmap_new_from_xpm_d (bonobo_insert_component_xpm); - gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, TRUE, GNOME_PAD_SMALL); + priv->icon = gnome_pixmap_new_from_xpm_d (bonobo_insert_component_xpm); + gtk_box_pack_start (GTK_BOX (hbox), priv->icon, FALSE, TRUE, GNOME_PAD_SMALL); gtk_box_pack_start (GTK_BOX (hbox), priv->desc_label, TRUE, TRUE, GNOME_PAD_SMALL); gtk_container_add (GTK_CONTAINER (frame), hbox); @@ -276,12 +287,15 @@ GList *l; for (l = servers; l; l = l->next) { - const gchar *text [4]; + const gchar *icon; + const gchar *text [5]; text [0] = bonobo_directory_get_server_info_name (l->data); text [1] = bonobo_directory_get_server_info_id (l->data); text [2] = bonobo_directory_get_server_info_description (l->data); - text [3] = NULL; + icon = bonobo_directory_get_server_info_icon (l->data); + text [3] = icon ? icon : ""; + text [4] = NULL; gtk_clist_append (GTK_CLIST (priv->clist), (gchar **) text); }
Attachment:
blank-tile.png
Description: PNG image
Attachment:
eog-tile.png
Description: PNG image
Attachment:
paint-tile.png
Description: PNG image