use radio buttons for file and dir mode in popup menu
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 27 Jun 2009 20:47:17 +0000 (20:47 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 27 Jun 2009 20:47:17 +0000 (20:47 +0000)
src/layout_util.c
src/view_dir.c
src/view_file.c

index 9db99c9..6e9c595 100644 (file)
@@ -611,7 +611,7 @@ static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current,
        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 GtkToggleActionEntry menu_toggle_entries[] = {
 };
 
 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 @@ static void layout_util_sync_views(LayoutWindow *lw)
        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);
index d861618..5ba3077 100644 (file)
@@ -521,12 +521,11 @@ static void vd_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data)
        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 @@ GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd)
        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);
 
index d29c846..1862458 100644 (file)
@@ -467,18 +467,10 @@ static void vf_pop_menu_toggle_mark_sel_cb(GtkWidget *widget, gpointer data)
 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 @@ GtkWidget *vf_pop_menu(ViewFile *vf)
        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)
        {