changeset 156:dd6dc0a55d3d

better integration of split image functions into menu
author nadvornik
date Sat, 15 Dec 2007 17:58:51 +0000
parents d06bccc7551e
children b73743a01384
files src/layout_image.c src/layout_util.c
diffstat 2 files changed, 53 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout_image.c	Fri Dec 14 21:51:46 2007 +0000
+++ b/src/layout_image.c	Sat Dec 15 17:58:51 2007 +0000
@@ -703,43 +703,6 @@
 	layout_tools_hide_toggle(lw);
 }
 
-static void li_pop_menu_split_none_cb(GtkWidget *widget, gpointer data)
-{
-	LayoutWindow *lw = data;
-	layout_split_change(lw, SPLIT_NONE);
-}
-
-static void li_pop_menu_split_hor_cb(GtkWidget *widget, gpointer data)
-{
-	LayoutWindow *lw = data;
-	layout_split_change(lw, SPLIT_HOR);
-}
-
-static void li_pop_menu_split_vert_cb(GtkWidget *widget, gpointer data)
-{
-	LayoutWindow *lw = data;
-	layout_split_change(lw, SPLIT_VERT);
-}
-
-static void li_pop_menu_split_quad_cb(GtkWidget *widget, gpointer data)
-{
-	LayoutWindow *lw = data;
-	layout_split_change(lw, SPLIT_QUAD);
-}
-
-static void li_pop_menu_connect_scroll_cb(GtkWidget *widget, gpointer data)
-{
-	LayoutWindow *lw = data;
-	lw->connect_scroll = !lw->connect_scroll;
-}
-
-static void li_pop_menu_connect_zoom_cb(GtkWidget *widget, gpointer data)
-{
-	LayoutWindow *lw = data;
-	lw->connect_zoom = !lw->connect_zoom;
-}
-
-
 static GtkWidget *layout_image_pop_menu(LayoutWindow *lw)
 {
 	GtkWidget *menu;
@@ -758,18 +721,6 @@
 	menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(li_pop_menu_zoom_1_1_cb), lw);
 	menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(li_pop_menu_zoom_fit_cb), lw);
 	menu_item_add_divider(menu);
-	if (!fullscreen)
-		{
-		menu_item_add(menu, _("No split"), G_CALLBACK(li_pop_menu_split_none_cb), lw);
-		menu_item_add(menu, _("Split horizontaly"), G_CALLBACK(li_pop_menu_split_hor_cb), lw);
-		menu_item_add(menu, _("Split verticaly"), G_CALLBACK(li_pop_menu_split_vert_cb), lw);
-		menu_item_add(menu, _("Split quad"), G_CALLBACK(li_pop_menu_split_quad_cb), lw);
-		menu_item_add_check(menu, _("Connected scroll"), lw->connect_scroll,
-				   G_CALLBACK(li_pop_menu_connect_scroll_cb), lw);
-		menu_item_add_check(menu, _("Connected zoom"), lw->connect_zoom,
-				   G_CALLBACK(li_pop_menu_connect_zoom_cb), lw);
-		menu_item_add_divider(menu);
-		}
 
 	submenu = submenu_add_edit(menu, &item, G_CALLBACK(li_pop_menu_edit_cb), lw);
 	if (!path) gtk_widget_set_sensitive(item, FALSE);
@@ -1797,10 +1748,11 @@
 		layout_image_activate(lw, 0);
 		}
 
+	/* horizontal split means vpaned and vice versa */
 	if (horizontal)
+		paned = gtk_vpaned_new ();
+	else
 		paned = gtk_hpaned_new ();
-	else
-		paned = gtk_vpaned_new ();
 
 	gtk_paned_pack1 (GTK_PANED (paned), lw->split_images[0]->widget, TRUE, TRUE);
 	gtk_paned_pack2 (GTK_PANED (paned), lw->split_images[1]->widget, TRUE, TRUE);
--- a/src/layout_util.c	Fri Dec 14 21:51:46 2007 +0000
+++ b/src/layout_util.c	Sat Dec 15 17:58:51 2007 +0000
@@ -489,6 +489,29 @@
 	layout_image_zoom_set(lw, 0.0);
 }
 
+static void layout_menu_split_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data)
+{
+	LayoutWindow *lw = data;
+	ImageSplitMode mode = gtk_radio_action_get_current_value(action);
+	
+	if (mode == lw->split_mode) mode = 0; /* toggle back */
+
+	layout_split_change(lw, mode);
+}
+
+static void layout_menu_connect_scroll_cb(GtkToggleAction *action, gpointer data)
+{
+	LayoutWindow *lw = data;
+	lw->connect_scroll = gtk_toggle_action_get_active(action);
+}
+
+static void layout_menu_connect_zoom_cb(GtkToggleAction *action, gpointer data)
+{
+	LayoutWindow *lw = data;
+	lw->connect_zoom = gtk_toggle_action_get_active(action);
+}
+
+
 static void layout_menu_thumb_cb(GtkToggleAction *action, gpointer data)
 {
 	LayoutWindow *lw = data;
@@ -785,6 +808,7 @@
   { "EditMenu",		NULL,		N_("_Edit") },
   { "AdjustMenu",	NULL,		N_("_Adjust") },
   { "ViewMenu",		NULL,		N_("_View") },
+  { "SplitMenu",	NULL,		N_("_Split") },
   { "HelpMenu",		NULL,		N_("_Help") },
 
   { "NewWindow",	GTK_STOCK_NEW,	N_("New _window"),	NULL,		NULL,	CB(layout_menu_new_window_cb) },
@@ -830,6 +854,9 @@
   { "ZoomOut",	GTK_STOCK_ZOOM_OUT,	N_("Zoom _out"),	"minus",	NULL,	CB(layout_menu_zoom_out_cb) },
   { "Zoom100",	GTK_STOCK_ZOOM_100,	N_("Zoom _1:1"),	"Z",		NULL,	CB(layout_menu_zoom_1_1_cb) },
   { "ZoomFit",	GTK_STOCK_ZOOM_FIT,	N_("_Zoom to fit"),	"X",		NULL,	CB(layout_menu_zoom_fit_cb) },
+
+
+
   { "FullScreen",	NULL,		N_("F_ull screen"),	"F",		NULL,	CB(layout_menu_fullscreen_cb) },
   { "HideTools",	NULL,		N_("_Hide file list"),	"<control>H",	NULL,	CB(layout_menu_hide_cb) },
   { "SlideShow",	NULL,		N_("Toggle _slideshow"),"S",		NULL,	CB(layout_menu_slideshow_cb) },
@@ -843,13 +870,15 @@
 
 static GtkToggleActionEntry menu_toggle_entries[] = {
   { "Thumbnails",	NULL,		N_("_Thumbnails"),	"T",		NULL,	CB(layout_menu_thumb_cb) },
-  { "Marks",        NULL,		N_("_Marks"),	"M",		NULL,	CB(layout_menu_marks_cb) },  
+  { "Marks",        	NULL,		N_("_Marks"),		"M",		NULL,	CB(layout_menu_marks_cb) },  
   { "FolderTree",	NULL,		N_("Tr_ee"),		"<control>T",	NULL,	CB(layout_menu_tree_cb) },
   { "FloatTools",	NULL,		N_("_Float file list"),	"L",		NULL,	CB(layout_menu_float_cb) },
   { "HideToolbar",	NULL,		N_("Hide tool_bar"),	NULL,		NULL,	CB(layout_menu_toolbar_cb) },
   { "SBarKeywords",	NULL,		N_("_Keywords"),	"<control>K",	NULL,	CB(layout_menu_bar_info_cb) },
   { "SBarExif",		NULL,		N_("E_xif data"),	"<control>E",	NULL,	CB(layout_menu_bar_exif_cb) },
-  { "SBarSort",		NULL,		N_("Sort _manager"),	"<control>S",	NULL,	CB(layout_menu_bar_sort_cb) }
+  { "SBarSort",		NULL,		N_("Sort _manager"),	"<control>S",	NULL,	CB(layout_menu_bar_sort_cb) },
+  { "ConnectScroll",	NULL,		N_("Connected scroll"),	"<control>U",	NULL,	CB(layout_menu_connect_scroll_cb) },
+  { "ConnectZoom",	NULL,		N_("Connected zoom"),	"<control>Y",	NULL,	CB(layout_menu_connect_zoom_cb) }
 };
 
 static GtkRadioActionEntry menu_radio_entries[] = {
@@ -857,6 +886,13 @@
   { "ViewIcons",	NULL,		N_("I_cons"),		"<control>I",	NULL,	1 }
 };
 
+static GtkRadioActionEntry menu_split_radio_entries[] = {
+  { "SplitHorizontal",	NULL,		N_("Horizontal"),	"E",		NULL,	SPLIT_HOR },
+  { "SplitVertical",	NULL,		N_("Vertical"),		"U",		NULL,	SPLIT_VERT },
+  { "SplitQuad",	NULL,		N_("Quad"),		"Q",		NULL,	SPLIT_QUAD },
+  { "SplitSingle",	NULL,		N_("Single"),		"Y",		NULL,	SPLIT_NONE }
+};
+
 #undef CB
 
 static const char *menu_ui_description =
@@ -920,6 +956,15 @@
 "      <menuitem action='Zoom100'/>"
 "      <menuitem action='ZoomFit'/>"
 "      <separator/>"
+"      <menu action='SplitMenu'>"
+"        <menuitem action='SplitHorizontal'/>"
+"        <menuitem action='SplitVertical'/>"
+"        <menuitem action='SplitQuad'/>"
+"        <menuitem action='SplitSingle'/>"
+"      </menu>"
+"      <menuitem action='ConnectScroll'/>"
+"      <menuitem action='ConnectZoom'/>"
+"      <separator/>"
 "      <menuitem action='Thumbnails'/>"
 "      <menuitem action='Marks'/>"
 "      <menuitem action='ViewList'/>"
@@ -972,6 +1017,9 @@
 	gtk_action_group_add_radio_actions(lw->action_group,
 					   menu_radio_entries, G_N_ELEMENTS(menu_radio_entries),
 					   0, G_CALLBACK(layout_menu_list_cb), lw);
+	gtk_action_group_add_radio_actions(lw->action_group,
+					   menu_split_radio_entries, G_N_ELEMENTS(menu_split_radio_entries),
+					   0, G_CALLBACK(layout_menu_split_cb), lw);
 
 	lw->ui_manager = gtk_ui_manager_new();
 	gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE);