summaryrefslogtreecommitdiff
path: root/src/nautilus-zoom-control.c
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2000-09-25 21:00:31 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2000-09-25 21:00:31 +0000
commite0692b06d8bb931a19e265ee178ba97d07be6f18 (patch)
tree637102037d0447770f26ae166b844fb7a3db4a19 /src/nautilus-zoom-control.c
parent2a0db776871eb248e7ec10144a4d8b379528d79d (diff)
downloadnautilus-e0692b06d8bb931a19e265ee178ba97d07be6f18.tar.gz
Some work on the "sidebar panel has failed" situation.
* src/nautilus-window-manage-views.c: (nautilus_window_update_state): Don't report sidebar panel failure when the view that failed was the content view. Doh! It had been putting up two dialogs, one for the content view and one for some mysterious unknown sidebar panel. (nautilus_window_set_state_info): Added a g_warning when the state is set to VIEW_ERROR. This will stop in the debugger to make it easier to tell what's generating the error (but without the debugger will just spew one line of spam). (nautilus_window_end_location_change_callback): Check if window is visible before trying to set the initial position. This prevents a return_if_fail complaint in some cases in the window-position-saving code when using use-new-window mode. Fixed bug 3262 (Zoom control context menu should use radio buttons, not checkboxes) * src/nautilus-zoom-control.c: Added marking_menu_items boolean to details struct. (create_zoom_menu_item): Now takes a radio button item as a parameter (from which to get the group) and returns the new radio button item (to use for the next time) and sets marking_menu_items to TRUE while creating menu items. Oh yeah, also creates a radio item instead of a check item. (zoom_menu_callback): Now bails out early if marking_menu_items. (create_zoom_menu): Passes the result of each create_zoom_menu_item into the next call, to get all the radio items in the same group.
Diffstat (limited to 'src/nautilus-zoom-control.c')
-rw-r--r--src/nautilus-zoom-control.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/nautilus-zoom-control.c b/src/nautilus-zoom-control.c
index aa054af7e..a0658ab54 100644
--- a/src/nautilus-zoom-control.c
+++ b/src/nautilus-zoom-control.c
@@ -77,6 +77,8 @@ struct NautilusZoomControlDetails {
GdkPixbuf *zoom_increment_image;
GdkPixbuf *number_strip;
PrelightMode prelight_mode;
+
+ gboolean marking_menu_items;
};
@@ -526,8 +528,14 @@ zoom_menu_callback (GtkMenuItem *item, gpointer callback_data)
double zoom_level;
NautilusZoomControl *zoom_control;
- zoom_level = * (double *) gtk_object_get_data (GTK_OBJECT (item), "zoom_level");
zoom_control = NAUTILUS_ZOOM_CONTROL (callback_data);
+
+ /* Don't do anything if we're just setting the toggle state of menu items. */
+ if (zoom_control->details->marking_menu_items) {
+ return;
+ }
+
+ zoom_level = * (double *) gtk_object_get_data (GTK_OBJECT (item), "zoom_level");
/* Check to see if we can zoom out */
if ((zoom_control->details->min_zoom_level <= zoom_level && zoom_level < zoom_control->details->zoom_level) ||
@@ -536,21 +544,30 @@ zoom_menu_callback (GtkMenuItem *item, gpointer callback_data)
}
}
-static void
-create_zoom_menu_item (GtkMenu *menu, GtkWidget *widget, double zoom_level)
+static GtkRadioMenuItem *
+create_zoom_menu_item (GtkMenu *menu, GtkWidget *widget, double zoom_level, GtkRadioMenuItem *previous_radio_item)
{
GtkWidget *menu_item;
double *zoom_level_ptr;
char item_text[8];
NautilusZoomControl *zoom_control;
+ GSList *radio_item_group;
zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
+
+ /* Set flag so that callback isn't activated when set_active called
+ * to set toggle state of other radio items.
+ */
+ zoom_control->details->marking_menu_items = TRUE;
/* This is marked for localization in case the % sign is not
* appropriate in some locale. I guess that's unlikely.
*/
g_snprintf (item_text, sizeof (item_text), _("%.0f%%"), 100.0 * zoom_level);
- menu_item = gtk_check_menu_item_new_with_label (item_text);
+ radio_item_group = previous_radio_item == NULL
+ ? NULL
+ : gtk_radio_menu_item_group (previous_radio_item);
+ menu_item = gtk_radio_menu_item_new_with_label (radio_item_group, item_text);
zoom_level_ptr = g_new (double, 1);
*zoom_level_ptr = zoom_level;
@@ -566,6 +583,10 @@ create_zoom_menu_item (GtkMenu *menu, GtkWidget *widget, double zoom_level)
gtk_widget_show (menu_item);
gtk_menu_append (menu, menu_item);
+
+ zoom_control->details->marking_menu_items = FALSE;
+
+ return GTK_RADIO_MENU_ITEM (menu_item);
}
static GtkMenu*
@@ -573,13 +594,15 @@ create_zoom_menu(GtkWidget *zoom_control)
{
GList *p;
GtkMenu *menu;
+ GtkRadioMenuItem *menu_item;
menu = GTK_MENU (gtk_menu_new ());
p = NAUTILUS_ZOOM_CONTROL (zoom_control)->details->preferred_zoom_levels;
-
+
+ menu_item = NULL;
while (p != NULL) {
- create_zoom_menu_item (menu, zoom_control, * (double *) p->data);
+ menu_item = create_zoom_menu_item (menu, zoom_control, * (double *) p->data, menu_item);
p = g_list_next (p);
}