⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layout_util.c

📁 Gqview,Linux下基于GTK+库写成的轻量级而能丰富的图像浏览程序。
💻 C
📖 第 1 页 / 共 3 页
字号:
}static void layout_menu_fullscreen_cb(GtkAction *action, gpointer data){	LayoutWindow *lw = data;	layout_image_full_screen_toggle(lw);}static void layout_menu_refresh_cb(GtkAction *action, gpointer data){	LayoutWindow *lw = data;	layout_refresh(lw);}static void layout_menu_float_cb(GtkToggleAction *action, gpointer data){	LayoutWindow *lw = data;	if (lw->tools_float != gtk_toggle_action_get_active(action))		{		layout_tools_float_toggle(lw);		}}static void layout_menu_hide_cb(GtkAction *action, gpointer data){	LayoutWindow *lw = data;	layout_tools_hide_toggle(lw);}static void layout_menu_toolbar_cb(GtkToggleAction *action, gpointer data){	LayoutWindow *lw = data;	if (lw->toolbar_hidden != gtk_toggle_action_get_active(action))		{		layout_toolbar_toggle(lw);		}}static void layout_menu_bar_info_cb(GtkToggleAction *action, gpointer data){	LayoutWindow *lw = data;	if (lw->bar_info_enabled != gtk_toggle_action_get_active(action))		{		layout_bar_info_toggle(lw);		}}static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data){	LayoutWindow *lw = data;	if (lw->bar_exif_enabled != gtk_toggle_action_get_active(action))		{		layout_bar_exif_toggle(lw);		}}static void layout_menu_bar_sort_cb(GtkToggleAction *action, gpointer data){	LayoutWindow *lw = data;	if (lw->bar_sort_enabled != gtk_toggle_action_get_active(action))		{		layout_bar_sort_toggle(lw);		}}static void layout_menu_slideshow_cb(GtkAction *action, gpointer data){	LayoutWindow *lw = data;	layout_image_slideshow_toggle(lw);}static void layout_menu_help_cb(GtkAction *action, gpointer data){	help_window_show("html_contents");}static void layout_menu_help_keys_cb(GtkAction *action, gpointer data){	help_window_show("documentation");}static void layout_menu_notes_cb(GtkAction *action, gpointer data){	help_window_show("release_notes");}static void layout_menu_about_cb(GtkAction *action, gpointer data){	show_about_window();}/* *----------------------------------------------------------------------------- * edit menu *----------------------------------------------------------------------------- */ static void layout_menu_edit_cb(GtkAction *action, gpointer data){	LayoutWindow *lw = data;	GList *list;	gint n;	n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "edit_index"));	list = layout_selection_list(lw);	start_editor_from_path_list(n, list);	path_list_free(list);}static void layout_menu_edit_update(LayoutWindow *lw){	gint i;	/* main edit menu */	if (!lw->action_group) return;	for (i = 0; i < 10; i++)		{		gchar *key;		GtkAction *action;		key = g_strdup_printf("Editor%d", i);		action = gtk_action_group_get_action(lw->action_group, key);		g_object_set_data(G_OBJECT(action), "edit_index", GINT_TO_POINTER(i));		if (editor_command[i] && strlen(editor_command[i]) > 0)			{			gchar *text;			if (editor_name[i] && strlen(editor_name[i]) > 0)				{				text = g_strdup_printf(_("in %s..."), editor_name[i]);				}			else				{				text = g_strdup(_("in (unknown)..."));				}			g_object_set(action, "label", text,					     "sensitive", TRUE, NULL);			g_free(text);			}		else			{			g_object_set(action, "label", _("empty"),					     "sensitive", FALSE, NULL);			}		g_free(key);		}}void layout_edit_update_all(void){	GList *work;	work = layout_window_list;	while (work)		{		LayoutWindow *lw = work->data;		work = work->next;		layout_menu_edit_update(lw);		}}/* *----------------------------------------------------------------------------- * recent menu *----------------------------------------------------------------------------- */static void layout_menu_recent_cb(GtkWidget *widget, gpointer data){	gint n;	gchar *path;	n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index"));	path = g_list_nth_data(history_list_get_by_key("recent"), n);	if (!path) return;	/* make a copy of it */	path = g_strdup(path);	collection_window_new(path);	g_free(path);}static void layout_menu_recent_update(LayoutWindow *lw){	GtkWidget *menu;	GtkWidget *recent;	GtkWidget *item;	GList *list;	gint n;	if (!lw->ui_manager) return;	list = history_list_get_by_key("recent");	n = 0;	menu = gtk_menu_new();	while (list)		{		item = menu_item_add_simple(menu, filename_from_path((gchar *)list->data),					    G_CALLBACK(layout_menu_recent_cb), lw);		g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n));		list = list->next;		n++;		}	if (n == 0)		{		menu_item_add(menu, _("Empty"), NULL, NULL);		}	recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenRecent");	gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu);	gtk_widget_set_sensitive(recent, (n != 0));}void layout_recent_update_all(void){	GList *work;	work = layout_window_list;	while (work)		{		LayoutWindow *lw = work->data;		work = work->next;		layout_menu_recent_update(lw);		}}void layout_recent_add_path(const gchar *path){	if (!path) return;	history_list_add_to_key("recent", path, recent_list_max);	layout_recent_update_all();}/* *----------------------------------------------------------------------------- * menu *----------------------------------------------------------------------------- */ #define CB G_CALLBACKstatic GtkActionEntry menu_entries[] = {  { "FileMenu",		NULL,		N_("_File") },  { "EditMenu",		NULL,		N_("_Edit") },  { "AdjustMenu",	NULL,		N_("_Adjust") },  { "ViewMenu",		NULL,		N_("_View") },  { "HelpMenu",		NULL,		N_("_Help") },  { "NewWindow",	GTK_STOCK_NEW,	N_("New _window"),	NULL,		NULL,	CB(layout_menu_new_window_cb) },  { "NewCollection",	GTK_STOCK_INDEX,N_("_New collection"),	"C",		NULL,	CB(layout_menu_new_cb) },  { "OpenCollection",	GTK_STOCK_OPEN,	N_("_Open collection..."),"O",		NULL,	CB(layout_menu_open_cb) },  { "OpenRecent",	NULL,		N_("Open _recent") },  { "Search",		GTK_STOCK_FIND,	N_("_Search..."),	"F3",		NULL,	CB(layout_menu_search_cb) },  { "FindDupes",	GTK_STOCK_FIND,	N_("_Find duplicates..."),"D",		NULL,	CB(layout_menu_dupes_cb) },  { "PanView",		NULL,		N_("Pan _view"),	"<control>J",	NULL,	CB(layout_menu_pan_cb) },  { "Print",		GTK_STOCK_PRINT,N_("_Print..."),	"<shift>P",	NULL,	CB(layout_menu_print_cb) },  { "NewFolder",	NULL,		N_("N_ew folder..."),	"<control>F",	NULL,	CB(layout_menu_dir_cb) },  { "Copy",		NULL,		N_("_Copy..."),		"<control>C",	NULL,	CB(layout_menu_copy_cb) },  { "Move",		NULL,		N_("_Move..."),		"<control>M",	NULL,	CB(layout_menu_move_cb) },  { "Rename",		NULL,		N_("_Rename..."),	"<control>R",	NULL,	CB(layout_menu_rename_cb) },  { "Delete",	GTK_STOCK_DELETE,	N_("_Delete..."),	"<control>D",	NULL,	CB(layout_menu_delete_cb) },  { "CloseWindow",	GTK_STOCK_CLOSE,N_("C_lose window"),	"<control>W",	NULL,	CB(layout_menu_close_cb) },  { "Quit",		GTK_STOCK_QUIT, N_("_Quit"),		"<control>Q",	NULL,	CB(layout_menu_exit_cb) },  { "Editor0",		NULL,		"editor0",		"<control>1",	NULL,	CB(layout_menu_edit_cb) },  { "Editor1",		NULL,		"editor1",		"<control>2",	NULL,	CB(layout_menu_edit_cb) },  { "Editor2",		NULL,		"editor2",		"<control>3",	NULL,	CB(layout_menu_edit_cb) },  { "Editor3",		NULL,		"editor3",		"<control>4",	NULL,	CB(layout_menu_edit_cb) },  { "Editor4",		NULL,		"editor4",		"<control>5",	NULL,	CB(layout_menu_edit_cb) },  { "Editor5",		NULL,		"editor5",		"<control>6",	NULL,	CB(layout_menu_edit_cb) },  { "Editor6",		NULL,		"editor6",		"<control>7",	NULL,	CB(layout_menu_edit_cb) },  { "Editor7",		NULL,		"editor7",		"<control>8",	NULL,	CB(layout_menu_edit_cb) },  { "Editor8",		NULL,		"editor8",		"<control>9",	NULL,	CB(layout_menu_edit_cb) },  { "Editor9",		NULL,		"editor9",		"<control>0",	NULL,	CB(layout_menu_edit_cb) },  { "RotateCW",		NULL,	N_("_Rotate clockwise"),	"bracketright",	NULL,	CB(layout_menu_alter_90_cb) },  { "RotateCCW",	NULL,	N_("Rotate _counterclockwise"),	"bracketleft",	NULL,	CB(layout_menu_alter_90cc_cb) },  { "Rotate180",	NULL,		N_("Rotate 1_80"),	"<shift>R",	NULL,	CB(layout_menu_alter_180_cb) },  { "Mirror",		NULL,		N_("_Mirror"),		"<shift>M",	NULL,	CB(layout_menu_alter_mirror_cb) },  { "Flip",		NULL,		N_("_Flip"),		"<shift>F",	NULL,	CB(layout_menu_alter_flip_cb) },  { "Properties",GTK_STOCK_PROPERTIES,	N_("_Properties"),	"<control>P",	NULL,	CB(layout_menu_info_cb) },  { "SelectAll",	NULL,		N_("Select _all"),	"<control>A",	NULL,	CB(layout_menu_select_all_cb) },  { "SelectNone",	NULL,		N_("Select _none"), "<control><shift>A",NULL,	CB(layout_menu_unselect_all_cb) },  { "Preferences",GTK_STOCK_PREFERENCES,N_("P_references..."),	"<control>O",	NULL,	CB(layout_menu_config_cb) },  { "Maintenance",	NULL,		N_("_Thumbnail maintenance..."),NULL,	NULL,	CB(layout_menu_remove_thumb_cb) },  { "Wallpaper",	NULL,		N_("Set as _wallpaper"),NULL,		NULL,	CB(layout_menu_wallpaper_cb) },  { "ZoomIn",	GTK_STOCK_ZOOM_IN,	N_("Zoom _in"),		"equal",	NULL,	CB(layout_menu_zoom_in_cb) },  { "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) },  { "Refresh",	GTK_STOCK_REFRESH,	N_("_Refresh"),		"R",		NULL,	CB(layout_menu_refresh_cb) },  { "HelpContents",	GTK_STOCK_HELP,	N_("_Contents"),	"F1",		NULL,	CB(layout_menu_help_cb) },  { "HelpShortcuts",	NULL,		N_("_Keyboard shortcuts"),NULL,		NULL,	CB(layout_menu_help_keys_cb) },  { "HelpNotes",	NULL,		N_("_Release notes"),	NULL,		NULL,	CB(layout_menu_notes_cb) },  { "About",		NULL,		N_("_About"),		NULL,		NULL,	CB(layout_menu_about_cb) }};static GtkToggleActionEntry menu_toggle_entries[] = {  { "Thumbnails",	NULL,		N_("_Thumbnails"),	"T",		NULL,	CB(layout_menu_thumb_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) }};static GtkRadioActionEntry menu_radio_entries[] = {  { "ViewList",		NULL,		N_("_List"),		"<control>L",	NULL,	0 },  { "ViewIcons",	NULL,		N_("I_cons"),		"<control>I",	NULL,	1 }};#undef CBstatic const char *menu_ui_description ="<ui>""  <menubar name='MainMenu'>""    <menu action='FileMenu'>""      <menuitem action='NewWindow'/>""      <menuitem action='NewCollection'/>""      <menuitem action='OpenCollection'/>""      <menuitem action='OpenRecent'/>""      <separator/>""      <menuitem action='Search'/>""      <menuitem action='FindDupes'/>""      <menuitem action='PanView'/>""      <separator/>""      <menuitem action='Print'/>""      <menuitem action='NewFolder'/>""      <separator/>""      <menuitem action='Copy'/>""      <menuitem action='Move'/>""      <menuitem action='Rename'/>""      <menuitem action='Delete'/>""      <separator/>""      <menuitem action='CloseWindow'/>""      <menuitem action='Quit'/>""    </menu>""    <menu action='EditMenu'>""      <menuitem action='Editor0'/>""      <menuitem action='Editor1'/>""      <menuitem action='Editor2'/>""      <menuitem action='Editor3'/>""      <menuitem action='Editor4'/>""      <menuitem action='Editor5'/>""      <menuitem action='Editor6'/>""      <menuitem action='Editor7'/>""      <menuitem action='Editor8'/>""      <menuitem action='Editor9'/>""      <separator/>""      <menu action='AdjustMenu'>""        <menuitem action='RotateCW'/>""        <menuitem action='RotateCCW'/>""        <menuitem action='Rotate180'/>""        <menuitem action='Mirror'/>""        <menuitem action='Flip'/>""      </menu>""      <menuitem action='Properties'/>""      <separator/>""      <menuitem action='SelectAll'/>""      <menuitem action='SelectNone'/>""      <separator/>""      <menuitem action='Preferences'/>""      <menuitem action='Maintenance'/>""      <separator/>""      <menuitem action='Wallpaper'/>""    </menu>""    <menu action='ViewMenu'>""      <separator/>""      <menuitem action='ZoomIn'/>""      <menuitem action='ZoomOut'/>""      <menuitem action='Zoom100'/>""      <menuitem action='ZoomFit'/>""      <separator/>""      <menuitem action='Thumbnails'/>""      <menuitem action='ViewList'/>""      <menuitem action='ViewIcons'/>""      <separator/>""      <menuitem action='FolderTree'/>""      <menuitem action='FullScreen'/>""      <separator/>""      <menuitem action='FloatTools'/>""      <menuitem action='HideTools'/>""      <menuitem action='HideToolbar'/>""      <separator/>""      <menuitem action='SBarKeywords'/>""      <menuitem action='SBarExif'/>""      <menuitem action='SBarSort'/>""      <separator/>""      <menuitem action='SlideShow'/>""      <menuitem action='Refresh'/>""    </menu>""    <menu action='HelpMenu'>""      <separator/>""      <menuitem action='HelpContents'/>""      <menuitem action='HelpShortcuts'/>""      <menuitem action='HelpNotes'/>""      <separator/>""      <menuitem action='About'/>""    </menu>""  </menubar>""</ui>";static gchar *menu_translate(const gchar *path, gpointer data){	return _(path);}void layout_actions_setup(LayoutWindow *lw){	GError *error;	if (lw->ui_manager) return;	lw->action_group = gtk_action_group_new ("MenuActions");	gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL);	gtk_action_group_add_actions(lw->action_group,				     menu_entries, G_N_ELEMENTS(menu_entries), lw);	gtk_action_group_add_toggle_actions(lw->action_group,					    menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw);	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);	lw->ui_manager = gtk_ui_manager_new();	gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE);	gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0);	error = NULL;	if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error))		{		g_message ("building menus failed: %s", error->message);		g_error_free (error);		exit (EXIT_FAILURE);		}}void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window){	GtkAccelGroup *group;	if (!lw->ui_manager) return;	group = gtk_ui_manager_get_accel_group(lw->ui_manager);	gtk_window_add_accel_group(GTK_WINDOW(window), group);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -