diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-06-23 18:37:38 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-06-23 18:37:38 -0500 |
commit | 1f0bfc0aab8b824134da5a8402a9422f0ad34464 (patch) | |
tree | 9ab99a49272c88d0c2c9ac1b6bf3fd5613049dc9 | |
parent | 8008ec3c0dbd2dca7697f4f22c90f1d84819d1e0 (diff) | |
download | ayatana-ido-1f0bfc0aab8b824134da5a8402a9422f0ad34464.tar.gz ayatana-ido-1f0bfc0aab8b824134da5a8402a9422f0ad34464.tar.bz2 ayatana-ido-1f0bfc0aab8b824134da5a8402a9422f0ad34464.zip |
silence console warnings when a NULL filename is passed into ido_user_menu_item_set_icon_from_filename()
-rw-r--r-- | example/menus.c | 47 | ||||
-rw-r--r-- | src/idousermenuitem.c | 4 |
2 files changed, 28 insertions, 23 deletions
diff --git a/example/menus.c b/example/menus.c index da2103a..d30f920 100644 --- a/example/menus.c +++ b/example/menus.c @@ -26,8 +26,8 @@ create_user_menu (const char * username, gboolean is_active) { GtkWidget * ret; - GFile * file = g_file_new_for_path (filename); - GIcon * icon = g_file_icon_new (file); + GFile * file = filename ? g_file_new_for_path (filename) : NULL; + GIcon * icon = file ? g_file_icon_new (file) : NULL; ret = g_object_new (IDO_USER_MENU_ITEM_TYPE, "label", username, @@ -36,8 +36,8 @@ create_user_menu (const char * username, "is-current-user", is_active, NULL); - g_object_unref (icon); - g_object_unref (file); + g_clear_object (&icon); + g_clear_object (&file); return ret; } @@ -122,23 +122,28 @@ main (int argc, char *argv[]) *** 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); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + create_user_menu ("Guest", + NULL, + FALSE, FALSE)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + create_user_menu ("Bobby Fischer", + "/usr/share/pixmaps/faces/chess.jpg", + FALSE, FALSE)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + create_user_menu ("Linus Torvalds", + "/usr/share/pixmaps/faces/penguin.jpg", + TRUE, FALSE)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + create_user_menu ("Mark Shuttleworth", + "/usr/share/pixmaps/faces/astronaut.jpg", + TRUE, TRUE)); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), ido_user_menu_item_new ()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ()); /* Add the menubar */ gtk_menu_shell_append (GTK_MENU_SHELL (menubar), root); diff --git a/src/idousermenuitem.c b/src/idousermenuitem.c index ab95d66..e6ba710 100644 --- a/src/idousermenuitem.c +++ b/src/idousermenuitem.c @@ -308,8 +308,8 @@ ido_user_menu_item_set_icon (IdoUserMenuItem * self, GIcon * icon) void ido_user_menu_item_set_icon_from_file (IdoUserMenuItem * self, const char * filename) { - GFile * file = g_file_new_for_path (filename); - GIcon * icon = g_file_icon_new (file); + GFile * file = filename ? g_file_new_for_path (filename) : NULL; + GIcon * icon = file ? g_file_icon_new (file) : NULL; ido_user_menu_item_set_icon (self, icon); |