changeset 1668:8ebc26a4383f

use radio buttons for file and dir mode in popup menu
author nadvornik
date Sat, 27 Jun 2009 20:47:17 +0000
parents 0806ccdfe06b
children daab013a0dcf
files src/layout_util.c src/view_dir.c src/view_file.c
diffstat 3 files changed, 14 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout_util.c	Sat Jun 27 20:12:56 2009 +0000
+++ b/src/layout_util.c	Sat Jun 27 20:47:17 2009 +0000
@@ -611,7 +611,7 @@
 	LayoutWindow *lw = data;
 	
 	layout_exit_fullscreen(lw);
-	layout_views_set(lw, lw->options.dir_view_type, (gtk_radio_action_get_current_value(action) == 1) ? FILEVIEW_ICON : FILEVIEW_LIST);
+	layout_views_set(lw, lw->options.dir_view_type, (FileViewType) gtk_radio_action_get_current_value(action));
 }
 
 static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
@@ -1415,8 +1415,8 @@
 };
 
 static GtkRadioActionEntry menu_radio_entries[] = {
-  { "ViewList",		NULL,			N_("Image _List"),			"<control>L",		N_("View Images as List"),		0 },
-  { "ViewIcons",	NULL,			N_("I_cons"),				"<control>I",		N_("View Images as Icons"),		1 }
+  { "ViewList",		NULL,			N_("Image _List"),			"<control>L",		N_("View Images as List"),		FILEVIEW_LIST },
+  { "ViewIcons",	NULL,			N_("I_cons"),				"<control>I",		N_("View Images as Icons"),		FILEVIEW_ICON }
 };
 
 static GtkRadioActionEntry menu_view_dir_radio_entries[] = {
@@ -2284,7 +2284,7 @@
 	radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->split_mode);
 
 	action = gtk_action_group_get_action(lw->action_group, "ViewIcons");
-	gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.file_view_type);
+	radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->options.file_view_type);
 
 	action = gtk_action_group_get_action(lw->action_group, "FloatTools");
 	gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->options.tools_float);
--- a/src/view_dir.c	Sat Jun 27 20:12:56 2009 +0000
+++ b/src/view_dir.c	Sat Jun 27 20:47:17 2009 +0000
@@ -521,12 +521,11 @@
 	file_util_copy_path_to_clipboard(vd->click_fd);
 }
 
-#define VIEW_DIR_AS_SUBMENU_KEY "view_dir_as_submenu"
 static void vd_pop_submenu_dir_view_as_cb(GtkWidget *widget, gpointer data)
 {
 	ViewDir *vd = data;
 
-	DirViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), VIEW_DIR_AS_SUBMENU_KEY));
+	DirViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data"));
 	layout_views_set(vd->layout, new_type, vd->layout->options.file_view_type);
 }
 
@@ -674,13 +673,11 @@
 	menu_item_add_divider(menu);
 
 
-	item = menu_item_add_check(menu, _("View as _List"), vd->type == DIRVIEW_LIST,
+	item = menu_item_add_radio(menu, _("View as _List"), GINT_TO_POINTER(DIRVIEW_LIST), vd->type == DIRVIEW_LIST,
                                            G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd);
-	g_object_set_data(G_OBJECT(item), VIEW_DIR_AS_SUBMENU_KEY, GINT_TO_POINTER(DIRVIEW_LIST));
 
-	item = menu_item_add_check(menu, _("View as _Tree"), vd->type == DIRVIEW_TREE,
+	item = menu_item_add_radio(menu, _("View as _Tree"), GINT_TO_POINTER(DIRVIEW_TREE), vd->type == DIRVIEW_TREE,
                                            G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd);
-	g_object_set_data(G_OBJECT(item), VIEW_DIR_AS_SUBMENU_KEY, GINT_TO_POINTER(DIRVIEW_TREE));
 
 	menu_item_add_divider(menu);
 
--- a/src/view_file.c	Sat Jun 27 20:12:56 2009 +0000
+++ b/src/view_file.c	Sat Jun 27 20:47:17 2009 +0000
@@ -467,18 +467,10 @@
 static void vf_pop_menu_toggle_view_type_cb(GtkWidget *widget, gpointer data)
 {
 	ViewFile *vf = data;
-	
+	FileViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data"));
 	if (!vf->layout) return;
 
-	switch (vf->type)
-	{
-	case FILEVIEW_LIST:
-		layout_views_set(vf->layout, vf->layout->options.dir_view_type, FILEVIEW_ICON);
-		break;
-	case FILEVIEW_ICON:
-		layout_views_set(vf->layout, vf->layout->options.dir_view_type, FILEVIEW_LIST);
-		break;
-	}
+	layout_views_set(vf->layout, vf->layout->options.dir_view_type, new_type);
 }
 
 static void vf_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
@@ -611,8 +603,11 @@
 	item = menu_item_add(menu, _("_Sort"), NULL, NULL);
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
 
-	menu_item_add_check(menu, _("View as _icons"), (vf->type == FILEVIEW_ICON),
-			    G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);
+	item = menu_item_add_radio(menu, _("View as _List"), GINT_TO_POINTER(FILEVIEW_LIST), vf->type == FILEVIEW_LIST,
+                                           G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);
+
+	item = menu_item_add_radio(menu, _("View as _Icons"), GINT_TO_POINTER(FILEVIEW_ICON), vf->type == FILEVIEW_ICON,
+                                           G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);
 
 	switch (vf->type)
 	{