Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GNOME
gThumb
Commits
d02c5d93
Commit
d02c5d93
authored
Nov 09, 2019
by
Paolo Bacchilega
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file tools: converted accelerators to customizable shortcuts
parent
4e6b7990
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
54 deletions
+141
-54
extensions/file_tools/actions.c
extensions/file_tools/actions.c
+80
-0
extensions/file_tools/actions.h
extensions/file_tools/actions.h
+29
-0
extensions/file_tools/callbacks.c
extensions/file_tools/callbacks.c
+29
-51
extensions/file_tools/callbacks.h
extensions/file_tools/callbacks.h
+1
-2
extensions/file_tools/main.c
extensions/file_tools/main.c
+1
-1
extensions/file_tools/meson.build
extensions/file_tools/meson.build
+1
-0
No files found.
extensions/file_tools/actions.c
0 → 100644
View file @
d02c5d93
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2019 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <gthumb.h>
#include <extensions/image_viewer/gth-image-viewer-page.h>
#include "actions.h"
#include "gth-file-tool-adjust-contrast.h"
#include "gth-file-tool-crop.h"
#include "gth-file-tool-flip.h"
#include "gth-file-tool-mirror.h"
#include "gth-file-tool-resize.h"
#include "gth-file-tool-rotate-left.h"
#include "gth-file-tool-rotate-right.h"
void
gth_browser_activate_file_tool
(
GSimpleAction
*
action
,
GVariant
*
parameter
,
gpointer
user_data
)
{
GthBrowser
*
browser
=
user_data
;
GtkWidget
*
sidebar
;
GtkWidget
*
toolbox
;
GthViewerPage
*
page
;
const
char
*
tool_name
;
GthFileTool
*
tool
;
sidebar
=
gth_browser_get_viewer_sidebar
(
browser
);
toolbox
=
gth_sidebar_get_toolbox
(
GTH_SIDEBAR
(
sidebar
));
if
(
gth_toolbox_tool_is_active
(
GTH_TOOLBOX
(
toolbox
)))
return
;
page
=
gth_browser_get_viewer_page
(
browser
);
if
(
!
GTH_IS_IMAGE_VIEWER_PAGE
(
page
))
return
;
tool_name
=
g_variant_get_string
(
parameter
,
NULL
);
tool
=
NULL
;
if
(
g_strcmp0
(
tool_name
,
"adjust-contrast"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_ADJUST_CONTRAST
);
if
(
g_strcmp0
(
tool_name
,
"flip"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_FLIP
);
if
(
g_strcmp0
(
tool_name
,
"mirror"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_MIRROR
);
if
(
g_strcmp0
(
tool_name
,
"rotate-right"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_ROTATE_RIGHT
);
if
(
g_strcmp0
(
tool_name
,
"rotate-left"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_ROTATE_LEFT
);
if
(
g_strcmp0
(
tool_name
,
"crop"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_CROP
);
if
(
g_strcmp0
(
tool_name
,
"resize"
)
==
0
)
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_RESIZE
);
if
(
tool
!=
NULL
)
{
if
(
gth_window_get_current_page
(
GTH_WINDOW
(
browser
))
==
GTH_BROWSER_PAGE_BROWSER
)
gth_window_set_current_page
(
GTH_WINDOW
(
browser
),
GTH_BROWSER_PAGE_VIEWER
);
gth_file_tool_activate
(
tool
);
}
}
extensions/file_tools/actions.h
0 → 100644
View file @
d02c5d93
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2019 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACTIONS_H
#define ACTIONS_H
#include <gthumb.h>
DEF_ACTION_CALLBACK
(
gth_browser_activate_file_tool
)
#endif
/* ACTIONS_H */
extensions/file_tools/callbacks.c
View file @
d02c5d93
...
...
@@ -26,6 +26,7 @@
#include <gdk/gdkkeysyms.h>
#include <gthumb.h>
#include <extensions/image_viewer/gth-image-viewer-page.h>
#include "actions.h"
#include "callbacks.h"
#include "gth-file-tool-adjust-contrast.h"
#include "gth-file-tool-crop.h"
...
...
@@ -36,60 +37,37 @@
#include "gth-file-tool-rotate-right.h"
gpointer
file_tools__gth_browser_file_list_key_press_cb
(
GthBrowser
*
browser
,
GdkEventKey
*
event
)
{
gpointer
result
=
NULL
;
GtkWidget
*
sidebar
;
GtkWidget
*
toolbox
;
GthFileTool
*
tool
=
NULL
;
guint
modifiers
;
GthViewerPage
*
page
;
sidebar
=
gth_browser_get_viewer_sidebar
(
browser
);
toolbox
=
gth_sidebar_get_toolbox
(
GTH_SIDEBAR
(
sidebar
));
if
(
gth_toolbox_tool_is_active
(
GTH_TOOLBOX
(
toolbox
)))
return
NULL
;
static
const
GActionEntry
actions
[]
=
{
{
"file-tool-adjust-contrast"
,
gth_browser_activate_file_tool
,
"s"
,
"'adjust-contrast'"
},
{
"file-tool-flip"
,
gth_browser_activate_file_tool
,
"s"
,
"'flip'"
},
{
"file-tool-mirror"
,
gth_browser_activate_file_tool
,
"s"
,
"'mirror'"
},
{
"file-tool-rotate-right"
,
gth_browser_activate_file_tool
,
"s"
,
"'rotate-right'"
},
{
"file-tool-rotate-left"
,
gth_browser_activate_file_tool
,
"s"
,
"'rotate-left'"
},
{
"file-tool-crop"
,
gth_browser_activate_file_tool
,
"s"
,
"'crop'"
},
{
"file-tool-resize"
,
gth_browser_activate_file_tool
,
"s"
,
"'resize'"
},
};
modifiers
=
gtk_accelerator_get_default_mod_mask
();
if
(((
event
->
state
&
modifiers
)
!=
0
)
&&
((
event
->
state
&
modifiers
)
!=
GDK_SHIFT_MASK
))
return
NULL
;
page
=
gth_browser_get_viewer_page
(
browser
);
if
(
!
GTH_IS_IMAGE_VIEWER_PAGE
(
page
))
return
NULL
;
static
const
GthShortcut
shortcuts
[]
=
{
{
"file-tool-adjust-contrast"
,
N_
(
"Adjust Contrast"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"A"
},
{
"file-tool-flip"
,
N_
(
"Flip"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"L"
},
{
"file-tool-mirror"
,
N_
(
"Mirror"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"M"
},
{
"file-tool-rotate-right"
,
N_
(
"Rotate Right"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"R"
},
{
"file-tool-rotate-left"
,
N_
(
"Rotate Left"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"<shift>R"
},
{
"file-tool-crop"
,
N_
(
"Crop"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"<shift>C"
},
{
"file-tool-resize"
,
N_
(
"Resize"
),
GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER
,
GTH_SHORTCUT_CATEGORY_IMAGE_EDIT
,
"<shift>S"
},
};
switch
(
event
->
keyval
)
{
case
GDK_KEY_a
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_ADJUST_CONTRAST
);
break
;
case
GDK_KEY_l
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_FLIP
);
break
;
case
GDK_KEY_m
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_MIRROR
);
break
;
case
GDK_KEY_r
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_ROTATE_RIGHT
);
break
;
case
GDK_KEY_R
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_ROTATE_LEFT
);
break
;
case
GDK_KEY_C
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_CROP
);
break
;
case
GDK_KEY_S
:
tool
=
(
GthFileTool
*
)
gth_toolbox_get_tool
(
GTH_TOOLBOX
(
toolbox
),
GTH_TYPE_FILE_TOOL_RESIZE
);
break
;
}
if
(
tool
!=
NULL
)
{
if
(
gth_window_get_current_page
(
GTH_WINDOW
(
browser
))
==
GTH_BROWSER_PAGE_BROWSER
)
gth_window_set_current_page
(
GTH_WINDOW
(
browser
),
GTH_BROWSER_PAGE_VIEWER
);
gth_file_tool_activate
(
tool
);
result
=
GINT_TO_POINTER
(
1
);
}
void
file_tools__gth_browser_construct_cb
(
GthBrowser
*
browser
)
{
g_action_map_add_action_entries
(
G_ACTION_MAP
(
browser
),
actions
,
G_N_ELEMENTS
(
actions
),
browser
);
return
result
;
gth_window_add_shortcuts
(
GTH_WINDOW
(
browser
),
shortcuts
,
G_N_ELEMENTS
(
shortcuts
));
}
extensions/file_tools/callbacks.h
View file @
d02c5d93
...
...
@@ -24,7 +24,6 @@
#include <gthumb.h>
gpointer
file_tools__gth_browser_file_list_key_press_cb
(
GthBrowser
*
browser
,
GdkEventKey
*
event
);
void
file_tools__gth_browser_construct_cb
(
GthBrowser
*
browser
);
#endif
/* CALLBACKS_H */
extensions/file_tools/main.c
View file @
d02c5d93
...
...
@@ -74,7 +74,7 @@ gthumb_extension_activate (void)
gth_main_register_type
(
"file-tools"
,
GTH_TYPE_FILE_TOOL_RESIZE
);
gth_main_register_type
(
"file-tools"
,
GTH_TYPE_FILE_TOOL_CROP
);
gth_hook_add_callback
(
"gth-browser-
file-list-key-press
"
,
10
,
G_CALLBACK
(
file_tools__gth_browser_
file_list_key_press
_cb
),
NULL
);
gth_hook_add_callback
(
"gth-browser-
construct
"
,
10
,
G_CALLBACK
(
file_tools__gth_browser_
construct
_cb
),
NULL
);
/**
* Add a filter to the filter list shown in the Effects tool
...
...
extensions/file_tools/meson.build
View file @
d02c5d93
...
...
@@ -38,6 +38,7 @@ header_files = [
enum_files = gnome.mkenums_simple('file-tools-enum-types', sources: header_files)
source_files = files(
'actions.c',
'cairo-blur.c',
'cairo-effects.c',
'cairo-rotate.c',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment