Fix crash when loading collection listing inexistent files.
[geeqie.git] / src / ui_menu.c
index e0dee7e..0219978 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * (SLIK) SimpLIstic sKin functions
  * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -54,7 +55,7 @@ GtkWidget *menu_item_add_stock(GtkWidget *menu, const gchar *label, const gchar
        GtkWidget *image;
 
        item = gtk_image_menu_item_new_with_mnemonic(label);
-       image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+       image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
        gtk_widget_show(image);
        menu_item_finish(menu, item, func, data);
@@ -62,7 +63,7 @@ GtkWidget *menu_item_add_stock(GtkWidget *menu, const gchar *label, const gchar
        return item;
 }
 
-GtkWidget *menu_item_add_sensitive(GtkWidget *menu, const gchar *label, gint sensitive,
+GtkWidget *menu_item_add_sensitive(GtkWidget *menu, const gchar *label, gboolean sensitive,
                                   GCallback func, gpointer data)
 {
        GtkWidget *item;
@@ -73,7 +74,7 @@ GtkWidget *menu_item_add_sensitive(GtkWidget *menu, const gchar *label, gint sen
        return item;
 }
 
-GtkWidget *menu_item_add_stock_sensitive(GtkWidget *menu, const gchar *label, const gchar *stock_id, gint sensitive,
+GtkWidget *menu_item_add_stock_sensitive(GtkWidget *menu, const gchar *label, const gchar *stock_id, gboolean sensitive,
                                         GCallback func, gpointer data)
 {
        GtkWidget *item;
@@ -84,7 +85,7 @@ GtkWidget *menu_item_add_stock_sensitive(GtkWidget *menu, const gchar *label, co
        return item;
 }
 
-GtkWidget *menu_item_add_check(GtkWidget *menu, const gchar *label, gint active,
+GtkWidget *menu_item_add_check(GtkWidget *menu, const gchar *label, gboolean active,
                               GCallback func, gpointer data)
 {
        GtkWidget *item;
@@ -96,18 +97,12 @@ GtkWidget *menu_item_add_check(GtkWidget *menu, const gchar *label, gint active,
        return item;
 }
 
-GtkWidget *menu_item_add_radio(GtkWidget *menu, GtkWidget *parent,
-                              const gchar *label, gint active,
+GtkWidget *menu_item_add_radio(GtkWidget *menu, const gchar *label, gpointer item_data, gboolean active,
                               GCallback func, gpointer data)
 {
-       GtkWidget *item;
-       GSList *group = NULL;
-
-       if (parent) group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(parent));
-
-       item = gtk_radio_menu_item_new_with_mnemonic(group, label);
-       if (active) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active);
-       menu_item_finish(menu, item, func, data);
+       GtkWidget *item = menu_item_add_check(menu, label, active, func, data);
+       g_object_set_data(G_OBJECT(item), "menu_item_radio_data", item_data);
+       g_object_set(G_OBJECT(item), "draw-as-radio", TRUE, NULL);
 
        return item;
 }
@@ -162,14 +157,16 @@ GtkWidget *popup_menu_short_lived(void)
        return menu;
 }
 
-gint popup_menu_position_clamp(GtkMenu *menu, gint *x, gint *y, gint height)
+gboolean popup_menu_position_clamp(GtkMenu *menu, gint *x, gint *y, gint height)
 {
-       gint adjusted = FALSE;
+       gboolean adjusted = FALSE;
        gint w, h;
        gint xw, xh;
+       GtkRequisition requisition;
 
-       w = GTK_WIDGET(menu)->requisition.width;
-       h = GTK_WIDGET(menu)->requisition.height;
+       gtk_widget_get_requisition(GTK_WIDGET(menu), &requisition);
+       w = requisition.width;
+       h = requisition.height;
        xw = gdk_screen_width();
        xh = gdk_screen_height();
 
@@ -204,3 +201,4 @@ gint popup_menu_position_clamp(GtkMenu *menu, gint *x, gint *y, gint height)
 
        return adjusted;
 }
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */