Allow xfce_header_new to use a default icon

This commit is contained in:
Christian Dywan 2008-12-12 10:11:45 +01:00
parent df6afd7caa
commit 08af3f6773

View file

@ -230,10 +230,23 @@ sokoke_get_desktop (void)
#endif #endif
} }
/**
* sokoke_xfce_header_new:
* @icon: an icon name
* @title: the title of the header
*
* Creates an Xfce style header *if* Xfce is running.
*
* Return value: A #GtkWidget or %NULL
*
* Since 0.1.2 @icon may be NULL, and a default is used.
**/
GtkWidget* GtkWidget*
sokoke_xfce_header_new (const gchar* icon, sokoke_xfce_header_new (const gchar* icon,
const gchar* title) const gchar* title)
{ {
g_return_val_if_fail (title, NULL);
/* Create an xfce header with icon and title /* Create an xfce header with icon and title
This returns NULL if the desktop is not Xfce */ This returns NULL if the desktop is not Xfce */
if (sokoke_get_desktop () == SOKOKE_DESKTOP_XFCE) if (sokoke_get_desktop () == SOKOKE_DESKTOP_XFCE)
@ -251,7 +264,11 @@ sokoke_xfce_header_new (const gchar* icon,
&entry->style->base[GTK_STATE_NORMAL]); &entry->style->base[GTK_STATE_NORMAL]);
hbox = gtk_hbox_new (FALSE, 12); hbox = gtk_hbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
if (icon)
image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG); image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG);
else
image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
label = gtk_label_new (NULL); label = gtk_label_new (NULL);
gtk_widget_modify_fg (label, GTK_STATE_NORMAL gtk_widget_modify_fg (label, GTK_STATE_NORMAL