comparison src/view_dir.c @ 1666:fa942b3f0ef5

created Files and Folders submenu
author nadvornik
date Sat, 27 Jun 2009 17:54:31 +0000
parents 349ebc02b8e2
children 8ebc26a4383f
comparison
equal deleted inserted replaced
1665:9a081164e6e3 1666:fa942b3f0ef5
64 64
65 65
66 66
67 static void vd_notify_cb(FileData *fd, NotifyType type, gpointer data); 67 static void vd_notify_cb(FileData *fd, NotifyType type, gpointer data);
68 68
69 GtkRadioActionEntry menu_view_dir_radio_entries[] = {
70 { "FolderList", NULL, N_("_List"), "<meta>L", NULL, DIRVIEW_LIST },
71 { "FolderTree", NULL, N_("_Tree"), "<control>T", NULL, DIRVIEW_TREE },
72 };
73
74 static void vd_destroy_cb(GtkWidget *widget, gpointer data) 69 static void vd_destroy_cb(GtkWidget *widget, gpointer data)
75 { 70 {
76 ViewDir *vd = data; 71 ViewDir *vd = data;
77 72
78 file_data_unregister_notify_func(vd_notify_cb, vd); 73 file_data_unregister_notify_func(vd_notify_cb, vd);
99 g_free(vd); 94 g_free(vd);
100 } 95 }
101 96
102 ViewDir *vd_new(DirViewType type, FileData *dir_fd) 97 ViewDir *vd_new(DirViewType type, FileData *dir_fd)
103 { 98 {
104 g_assert(VIEW_DIR_TYPES_COUNT <= G_N_ELEMENTS(menu_view_dir_radio_entries));
105
106 ViewDir *vd = g_new0(ViewDir, 1); 99 ViewDir *vd = g_new0(ViewDir, 1);
107 100
108 vd->widget = gtk_scrolled_window_new(NULL, NULL); 101 vd->widget = gtk_scrolled_window_new(NULL, NULL);
109 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vd->widget), GTK_SHADOW_IN); 102 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vd->widget), GTK_SHADOW_IN);
110 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vd->widget), 103 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vd->widget),
609 } 602 }
610 603
611 GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd) 604 GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd)
612 { 605 {
613 GtkWidget *menu; 606 GtkWidget *menu;
614 GtkWidget *submenu;
615 GtkWidget *item; 607 GtkWidget *item;
616 gboolean active; 608 gboolean active;
617 gboolean rename_delete_active = FALSE; 609 gboolean rename_delete_active = FALSE;
618 gboolean new_folder_active = FALSE; 610 gboolean new_folder_active = FALSE;
619 gint i;
620 611
621 active = (fd != NULL); 612 active = (fd != NULL);
622 switch (vd->type) 613 switch (vd->type)
623 { 614 {
624 case DIRVIEW_LIST: 615 case DIRVIEW_LIST:
680 menu_item_add(menu, _("_Copy path"), 671 menu_item_add(menu, _("_Copy path"),
681 G_CALLBACK(vd_pop_menu_copy_path_cb), vd); 672 G_CALLBACK(vd_pop_menu_copy_path_cb), vd);
682 673
683 menu_item_add_divider(menu); 674 menu_item_add_divider(menu);
684 675
685 item = menu_item_add(menu, _("_View as"), NULL, NULL); 676
686 submenu = gtk_menu_new(); 677 item = menu_item_add_check(menu, _("View as _List"), vd->type == DIRVIEW_LIST,
687 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); 678 G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd);
688 679 g_object_set_data(G_OBJECT(item), VIEW_DIR_AS_SUBMENU_KEY, GINT_TO_POINTER(DIRVIEW_LIST));
689 for (i = 0; i < VIEW_DIR_TYPES_COUNT; i++) 680
690 { 681 item = menu_item_add_check(menu, _("View as _Tree"), vd->type == DIRVIEW_TREE,
691 item = menu_item_add_check(submenu, _(menu_view_dir_radio_entries[i].label), 682 G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd);
692 ((gint) vd->type == menu_view_dir_radio_entries[i].value), 683 g_object_set_data(G_OBJECT(item), VIEW_DIR_AS_SUBMENU_KEY, GINT_TO_POINTER(DIRVIEW_TREE));
693 G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd); 684
694 g_object_set_data(G_OBJECT(item), VIEW_DIR_AS_SUBMENU_KEY, GINT_TO_POINTER(menu_view_dir_radio_entries[i].value)); 685 menu_item_add_divider(menu);
695 }
696 686
697 menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files, 687 menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files,
698 G_CALLBACK(vd_toggle_show_hidden_files_cb), vd); 688 G_CALLBACK(vd_toggle_show_hidden_files_cb), vd);
699 689
700 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, 690 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,