aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/menus.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/example/menus.c b/example/menus.c
index 5687b8e..da2103a 100644
--- a/example/menus.c
+++ b/example/menus.c
@@ -4,6 +4,7 @@
#include "idocalendarmenuitem.h"
#include "idoentrymenuitem.h"
#include "idoswitchmenuitem.h"
+#include "idousermenuitem.h"
#include "config.h"
static void
@@ -18,6 +19,28 @@ slider_released (GtkWidget *widget, gpointer user_data)
g_print ("released\n");
}
+static GtkWidget *
+create_user_menu (const char * username,
+ const char * filename,
+ gboolean is_logged_in,
+ gboolean is_active)
+{
+ GtkWidget * ret;
+ GFile * file = g_file_new_for_path (filename);
+ GIcon * icon = g_file_icon_new (file);
+
+ ret = g_object_new (IDO_USER_MENU_ITEM_TYPE,
+ "label", username,
+ "icon", icon,
+ "is-logged-in", is_logged_in,
+ "is-current-user", is_active,
+ NULL);
+
+ g_object_unref (icon);
+ g_object_unref (file);
+ return ret;
+}
+
int
main (int argc, char *argv[])
{
@@ -92,10 +115,31 @@ main (int argc, char *argv[])
image = ido_scale_menu_item_get_secondary_image (IDO_SCALE_MENU_ITEM (menuitem));
gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-
g_signal_connect (menuitem, "slider-grabbed", G_CALLBACK (slider_grabbed), NULL);
g_signal_connect (menuitem, "slider-released", G_CALLBACK (slider_released), NULL);
+ /**
+ *** Users
+ **/
+
+ menuitem = create_user_menu ("Guest", NULL, FALSE, FALSE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+ menuitem = ido_user_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+ menuitem = create_user_menu ("Bobby Fischer", "/usr/share/pixmaps/faces/chess.jpg", FALSE, FALSE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+ menuitem = create_user_menu ("Linus Torvalds", "/usr/share/pixmaps/faces/penguin.jpg", TRUE, FALSE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+ menuitem = create_user_menu ("Mark Shuttleworth", "/usr/share/pixmaps/faces/astronaut.jpg", TRUE, TRUE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+ menuitem = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
/* Add the menubar */
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), root);