[eog/wip/gaction-migration: 1/5] eog-window.c: GtkAction -> GAction
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog/wip/gaction-migration: 1/5] eog-window.c: GtkAction -> GAction
- Date: Wed, 17 Dec 2014 19:11:00 +0000 (UTC)
commit 8b1fc17689d3a73abcabfb55de4721c1f7eac22b
Author: Jente Hidskes <hjdskes gmail com>
Date: Thu Dec 11 20:01:23 2014 +0100
eog-window.c: GtkAction -> GAction
This patch replaces all the GtkAction related code in eog-window.c to its
GAction equivalents.
Some things to note:
1) I only changed the lines required to change, to keep the diff as small
as possible. I do think some parts in eog-window.c can do with some
cleanup and a consistent style needs to be applied. (I tried to match up
with whatever style was used in the function I was working in.)
2) I renamed _some_ functions and arguments to better indicate what they're
for, but only those lines I already touched anyway.
3) actions_window is now directly mapped onto the
GtkApplicationWindow/EogWindow.
4) We might want to change the action names to short, lowercase names as the
documentation suggests.
5) The UI is not working anymore, due to incompatibility: it requires
GtkAction. This left me unable to test some/most of the changes, however
I quickly added some accelerators to those actions I could and it all
seems to be working so I have faith the other changes will to.
What's left to do:
1) Test all changes.
2) Remove deprecated and not-working UI code.
3) Add accelerators to all actions.
https://bugzilla.gnome.org/show_bug.cgi?id=741050
src/eog-window.c | 1075 +++++++++++++++++++++---------------------------------
1 files changed, 422 insertions(+), 653 deletions(-)
---
diff --git a/src/eog-window.c b/src/eog-window.c
index 5eb89f2..ba2226f 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -143,10 +143,7 @@ struct _EogWindowPrivate {
GtkWidget *toolbar;
GtkWidget *properties_dlg;
- GtkActionGroup *actions_window;
- GtkActionGroup *actions_image;
- GtkActionGroup *actions_gallery;
- GtkActionGroup *actions_recent;
+ GSimpleActionGroup *actions_recent;
GtkWidget *fullscreen_popup;
GSource *fullscreen_timeout_source;
@@ -175,7 +172,7 @@ struct _EogWindowPrivate {
EogWindowGalleryPos gallery_position;
gboolean gallery_resizable;
- GtkActionGroup *actions_open_with;
+ GSimpleActionGroup *actions_open_with;
guint open_with_menu_id;
gboolean save_disabled;
@@ -192,12 +189,12 @@ struct _EogWindowPrivate {
G_DEFINE_TYPE_WITH_PRIVATE (EogWindow, eog_window, GTK_TYPE_APPLICATION_WINDOW);
-static void eog_window_cmd_fullscreen (GtkAction *action, gpointer user_data);
+static void eog_window_action_toggle_fullscreen (GSimpleAction *action, GVariant *state, gpointer user_data);
static void eog_window_run_fullscreen (EogWindow *window, gboolean slideshow);
-static void eog_window_cmd_save (GtkAction *action, gpointer user_data);
-static void eog_window_cmd_save_as (GtkAction *action, gpointer user_data);
-static void eog_window_cmd_slideshow (GtkAction *action, gpointer user_data);
-static void eog_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data);
+static void eog_window_action_save (GSimpleAction *action, GVariant *variant, gpointer user_data);
+static void eog_window_action_save_as (GSimpleAction *action, GVariant *variant, gpointer user_data);
+static void eog_window_action_toggle_slideshow (GSimpleAction *action, GVariant *state, gpointer user_data);
+static void eog_window_action_pause_slideshow (GSimpleAction *action, GVariant *variant, gpointer user_data);
static void eog_window_stop_fullscreen (EogWindow *window, gboolean slideshow);
static void eog_job_load_cb (EogJobLoad *job, gpointer data);
static void eog_job_save_progress_cb (EogJobSave *job, float progress, gpointer data);
@@ -206,7 +203,7 @@ static void eog_job_transform_cb (EogJobTransform *job, gpointer data);
static void fullscreen_set_timeout (EogWindow *window);
static void fullscreen_clear_timeout (EogWindow *window);
static void update_action_groups_state (EogWindow *window);
-static void open_with_launch_application_cb (GtkAction *action, gpointer callback_data);
+static void open_with_launch_application_cb (GAction *action, gpointer callback_data);
static void eog_window_update_openwith_menu (EogWindow *window, EogImage *image);
static void eog_window_list_store_image_added (GtkTreeModel *tree_model,
GtkTreePath *path,
@@ -239,7 +236,7 @@ _eog_zoom_shrink_to_boolean (GBinding *binding, const GValue *source,
gboolean is_fit;
is_fit = (mode == EOG_ZOOM_MODE_SHRINK_TO_FIT);
- g_value_set_boolean (target, is_fit);
+ g_value_set_variant (target, g_variant_new_boolean (is_fit));
return TRUE;
}
@@ -355,7 +352,7 @@ eog_window_can_save_changed_cb (GSettings *settings,
EogWindowPrivate *priv;
EogWindow *window;
gboolean save_disabled = FALSE;
- GtkAction *action_save, *action_save_as;
+ GAction *action_save, *action_save_as;
eog_debug (DEBUG_PREFERENCES);
@@ -369,21 +366,23 @@ eog_window_can_save_changed_cb (GSettings *settings,
priv->save_disabled = save_disabled;
action_save =
- gtk_action_group_get_action (priv->actions_image, "ImageSave");
+ g_action_map_lookup_action (G_ACTION_MAP (window),
+ "ImageSave");
action_save_as =
- gtk_action_group_get_action (priv->actions_image, "ImageSaveAs");
+ g_action_map_lookup_action (G_ACTION_MAP (window),
+ "ImageSaveAs");
if (priv->save_disabled) {
- gtk_action_set_sensitive (action_save, FALSE);
- gtk_action_set_sensitive (action_save_as, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save), FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save_as), FALSE);
} else {
EogImage *image = eog_window_get_image (window);
if (EOG_IS_IMAGE (image)) {
- gtk_action_set_sensitive (action_save,
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save),
eog_image_is_modified (image));
- gtk_action_set_sensitive (action_save_as, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save_as), TRUE);
}
}
}
@@ -588,11 +587,11 @@ static void
update_action_groups_state (EogWindow *window)
{
EogWindowPrivate *priv;
- GtkAction *action_gallery;
- GtkAction *action_sidebar;
- GtkAction *action_fscreen;
- GtkAction *action_sshow;
- GtkAction *action_print;
+ GAction *action_gallery;
+ GAction *action_sidebar;
+ GAction *action_fscreen;
+ GAction *action_sshow;
+ GAction *action_print;
gboolean print_disabled = FALSE;
gboolean show_image_gallery = FALSE;
gint n_images = 0;
@@ -604,23 +603,23 @@ update_action_groups_state (EogWindow *window)
priv = window->priv;
action_gallery =
- gtk_action_group_get_action (priv->actions_window,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewImageGallery");
action_sidebar =
- gtk_action_group_get_action (priv->actions_window,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSidebar");
action_fscreen =
- gtk_action_group_get_action (priv->actions_image,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewFullscreen");
action_sshow =
- gtk_action_group_get_action (priv->actions_gallery,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSlideshow");
action_print =
- gtk_action_group_get_action (priv->actions_image,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ImagePrint");
g_assert (action_gallery != NULL);
@@ -636,12 +635,12 @@ update_action_groups_state (EogWindow *window)
if (n_images == 0) {
gtk_widget_hide (priv->layout);
- gtk_action_group_set_sensitive (priv->actions_window, TRUE);
+ /*gtk_action_group_set_sensitive (window, TRUE);
gtk_action_group_set_sensitive (priv->actions_image, FALSE);
- gtk_action_group_set_sensitive (priv->actions_gallery, FALSE);
+ gtk_action_group_set_sensitive (priv->actions_gallery, FALSE);*/
- gtk_action_set_sensitive (action_fscreen, FALSE);
- gtk_action_set_sensitive (action_sshow, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_fscreen), FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_sshow), FALSE);
/* If there are no images on model, initialization
stops here. */
@@ -670,23 +669,23 @@ update_action_groups_state (EogWindow *window)
if (show_image_gallery)
gtk_widget_show (priv->nav);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_gallery),
- show_image_gallery);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action_gallery),
+ g_variant_new_boolean
(show_image_gallery));
- gtk_action_group_set_sensitive (priv->actions_window, TRUE);
- gtk_action_group_set_sensitive (priv->actions_image, TRUE);
+ /*gtk_action_group_set_sensitive (window, TRUE);
+ gtk_action_group_set_sensitive (priv->actions_image, TRUE);*/
- gtk_action_set_sensitive (action_fscreen, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_fscreen), TRUE);
if (n_images == 1) {
- gtk_action_group_set_sensitive (priv->actions_gallery,
- FALSE);
- gtk_action_set_sensitive (action_gallery, FALSE);
- gtk_action_set_sensitive (action_sshow, FALSE);
+ /*gtk_action_group_set_sensitive (priv->actions_gallery,
+ FALSE);*/
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_gallery), FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_sshow), FALSE);
} else {
- gtk_action_group_set_sensitive (priv->actions_gallery,
- TRUE);
- gtk_action_set_sensitive (action_sshow, TRUE);
+ /*gtk_action_group_set_sensitive (priv->actions_gallery,
+ TRUE);*/
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_sshow), TRUE);
}
if (show_image_gallery)
@@ -699,11 +698,11 @@ update_action_groups_state (EogWindow *window)
EOG_CONF_DESKTOP_CAN_PRINT);
if (print_disabled) {
- gtk_action_set_sensitive (action_print, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_print), FALSE);
}
if (eog_sidebar_is_empty (EOG_SIDEBAR (priv->sidebar))) {
- gtk_action_set_sensitive (action_sidebar, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_sidebar), FALSE);
gtk_widget_hide (priv->sidebar);
}
}
@@ -712,7 +711,7 @@ static void
update_selection_ui_visibility (EogWindow *window)
{
EogWindowPrivate *priv;
- GtkAction *wallpaper_action;
+ GAction *wallpaper_action;
gint n_selected;
priv = window->priv;
@@ -720,13 +719,13 @@ update_selection_ui_visibility (EogWindow *window)
n_selected = eog_thumb_view_get_n_selected (EOG_THUMB_VIEW (priv->thumbview));
wallpaper_action =
- gtk_action_group_get_action (priv->actions_image,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSetAsWallpaper");
if (n_selected == 1) {
- gtk_action_set_sensitive (wallpaper_action, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (wallpaper_action), TRUE);
} else {
- gtk_action_set_sensitive (wallpaper_action, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (wallpaper_action), FALSE);
}
}
@@ -922,7 +921,7 @@ eog_window_display_image (EogWindow *window, EogImage *image)
}
static void
-open_with_launch_application_cb (GtkAction *action, gpointer data) {
+open_with_launch_application_cb (GAction *action, gpointer data) {
EogImage *image;
GAppInfo *app;
GFile *file;
@@ -949,9 +948,8 @@ eog_window_update_openwith_menu (EogWindow *window, EogImage *image)
GFile *file;
GFileInfo *file_info;
GList *iter;
- gchar *label, *tip;
const gchar *mime_type;
- GtkAction *action;
+ GSimpleAction *action;
EogWindowPrivate *priv;
GList *apps;
guint action_id = 0;
@@ -997,7 +995,7 @@ eog_window_update_openwith_menu (EogWindow *window, EogImage *image)
if (!apps)
return;
- priv->actions_open_with = gtk_action_group_new ("OpenWithActions");
+ priv->actions_open_with = g_simple_action_group_new ();
gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_open_with, -1);
priv->open_with_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
@@ -1019,20 +1017,9 @@ eog_window_update_openwith_menu (EogWindow *window, EogImage *image)
g_snprintf (name, sizeof (name), "OpenWith%u", action_id++);
- label = g_strdup (g_app_info_get_name (app));
- tip = g_strdup_printf (_("Use \"%s\" to open the selected image"), g_app_info_get_name
(app));
-
- action = gtk_action_new (name, label, tip, NULL);
+ action = g_simple_action_new (name, NULL);
app_icon = g_app_info_get_icon (app);
- if (G_LIKELY (app_icon != NULL)) {
- g_object_ref (app_icon);
- gtk_action_set_gicon (action, app_icon);
- g_object_unref (app_icon);
- }
-
- g_free (label);
- g_free (tip);
g_object_set_data_full (G_OBJECT (action), "app", app,
(GDestroyNotify) g_object_unref);
@@ -1042,7 +1029,8 @@ eog_window_update_openwith_menu (EogWindow *window, EogImage *image)
G_CALLBACK (open_with_launch_application_cb),
image);
- gtk_action_group_add_action (priv->actions_open_with, action);
+ g_action_map_add_action (G_ACTION_MAP (priv->actions_open_with),
+ G_ACTION (action));
g_object_unref (action);
gtk_ui_manager_add_ui (priv->ui_mgr,
@@ -1098,10 +1086,10 @@ eog_window_update_openwith_menu (EogWindow *window, EogImage *image)
g_list_free (apps);
- action = gtk_action_group_get_action (window->priv->actions_image,
- "OpenEditor");
+ action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window),
+ "OpenEditor"));
if (action != NULL) {
- gtk_action_set_sensitive (action, edit_button_active);
+ g_simple_action_set_enabled (action, edit_button_active);
}
}
@@ -1291,7 +1279,7 @@ eog_window_error_message_area_response (GtkInfoBar *message_area,
gint response_id,
EogWindow *window)
{
- GtkAction *action_save_as;
+ GAction *action_save_as;
g_return_if_fail (GTK_IS_INFO_BAR (message_area));
g_return_if_fail (EOG_IS_WINDOW (window));
@@ -1310,9 +1298,10 @@ eog_window_error_message_area_response (GtkInfoBar *message_area,
break;
case EOG_ERROR_MESSAGE_AREA_RESPONSE_SAVEAS:
/* trigger save as command for current image */
- action_save_as = gtk_action_group_get_action (window->priv->actions_image,
+ action_save_as =
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSaveAs");
- eog_window_cmd_save_as (action_save_as, window);
+ eog_window_action_save_as (G_SIMPLE_ACTION (action_save_as), NULL, window);
break;
}
}
@@ -1322,7 +1311,7 @@ eog_job_load_cb (EogJobLoad *job, gpointer data)
{
EogWindow *window;
EogWindowPrivate *priv;
- GtkAction *action_undo, *action_save;
+ GAction *action_undo, *action_save;
g_return_if_fail (EOG_IS_WINDOW (data));
@@ -1355,7 +1344,7 @@ eog_job_load_cb (EogJobLoad *job, gpointer data)
priv->display_profile);
#endif
- gtk_action_group_set_sensitive (priv->actions_image, TRUE);
+ /*gtk_action_group_set_sensitive (priv->actions_image, TRUE);*/
/* Make sure the window is really realized
* before displaying the image. The ScrollView needs that. */
@@ -1402,7 +1391,7 @@ eog_job_load_cb (EogJobLoad *job, gpointer data)
g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
}
- gtk_action_group_set_sensitive (priv->actions_image, FALSE);
+ /*gtk_action_group_set_sensitive (priv->actions_image, FALSE);*/
}
eog_window_clear_load_job (window);
@@ -1416,13 +1405,17 @@ eog_job_load_cb (EogJobLoad *job, gpointer data)
window);
}
- action_save = gtk_action_group_get_action (priv->actions_image, "ImageSave");
- action_undo = gtk_action_group_get_action (priv->actions_image, "EditUndo");
+ action_save = g_action_map_lookup_action (G_ACTION_MAP (window),
+ "ImageSave");
+ action_undo = g_action_map_lookup_action (G_ACTION_MAP (window),
+ "EditUndo");
/* Set Save and Undo sensitive according to image state.
* Respect lockdown in case of Save.*/
- gtk_action_set_sensitive (action_save, (!priv->save_disabled && eog_image_is_modified (job->image)));
- gtk_action_set_sensitive (action_undo, eog_image_is_modified (job->image));
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save),
+ (!priv->save_disabled && eog_image_is_modified (job->image)));
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_undo),
+ eog_image_is_modified (job->image));
g_object_unref (job->image);
}
@@ -1448,7 +1441,7 @@ static void
eog_job_transform_cb (EogJobTransform *job, gpointer data)
{
EogWindow *window;
- GtkAction *action_undo, *action_save;
+ GAction *action_undo, *action_save;
EogImage *image;
g_return_if_fail (EOG_IS_WINDOW (data));
@@ -1458,17 +1451,21 @@ eog_job_transform_cb (EogJobTransform *job, gpointer data)
eog_window_clear_transform_job (window);
action_undo =
- gtk_action_group_get_action (window->priv->actions_image, "EditUndo");
+ g_action_map_lookup_action (G_ACTION_MAP (window),
+ "EditUndo");
action_save =
- gtk_action_group_get_action (window->priv->actions_image, "ImageSave");
+ g_action_map_lookup_action (G_ACTION_MAP (window),
+ "ImageSave");
image = eog_window_get_image (window);
- gtk_action_set_sensitive (action_undo, eog_image_is_modified (image));
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_undo),
+ eog_image_is_modified (image));
if (!window->priv->save_disabled)
{
- gtk_action_set_sensitive (action_save, eog_image_is_modified (image));
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save),
+ eog_image_is_modified (image));
}
}
@@ -1586,8 +1583,8 @@ static void
view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
{
EogWindow *window;
- GtkAction *action_zoom_in;
- GtkAction *action_zoom_out;
+ GAction *action_zoom_in;
+ GAction *action_zoom_out;
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -1596,21 +1593,21 @@ view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
update_status_bar (window);
action_zoom_in =
- gtk_action_group_get_action (window->priv->actions_image,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewZoomIn");
action_zoom_out =
- gtk_action_group_get_action (window->priv->actions_image,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewZoomOut");
- gtk_action_set_sensitive (action_zoom_in,
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_zoom_in),
!eog_scroll_view_get_zoom_is_max (EOG_SCROLL_VIEW (window->priv->view)));
- gtk_action_set_sensitive (action_zoom_out,
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_zoom_out),
!eog_scroll_view_get_zoom_is_min (EOG_SCROLL_VIEW (window->priv->view)));
}
static void
-eog_window_open_recent_cb (GtkAction *action, EogWindow *window)
+eog_window_open_recent_cb (GAction *action, EogWindow *window)
{
GtkRecentInfo *info;
const gchar *uri;
@@ -1658,55 +1655,55 @@ file_open_dialog_response_cb (GtkWidget *chooser,
static void
eog_window_update_fullscreen_action (EogWindow *window)
{
- GtkAction *action;
+ GAction *action;
- action = gtk_action_group_get_action (window->priv->actions_image,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewFullscreen");
g_signal_handlers_block_by_func
- (action, G_CALLBACK (eog_window_cmd_fullscreen), window);
+ (action, G_CALLBACK (eog_window_action_toggle_fullscreen), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- window->priv->mode == EOG_WINDOW_MODE_FULLSCREEN);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action),
+ g_variant_new_boolean (window->priv->mode == EOG_WINDOW_MODE_FULLSCREEN));
g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (eog_window_cmd_fullscreen), window);
+ (action, G_CALLBACK (eog_window_action_toggle_fullscreen), window);
}
static void
eog_window_update_slideshow_action (EogWindow *window)
{
- GtkAction *action;
+ GAction *action;
- action = gtk_action_group_get_action (window->priv->actions_gallery,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSlideshow");
g_signal_handlers_block_by_func
- (action, G_CALLBACK (eog_window_cmd_slideshow), window);
+ (action, G_CALLBACK (eog_window_action_toggle_slideshow), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- window->priv->mode == EOG_WINDOW_MODE_SLIDESHOW);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action),
+ g_variant_new_boolean (window->priv->mode == EOG_WINDOW_MODE_SLIDESHOW));
g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (eog_window_cmd_slideshow), window);
+ (action, G_CALLBACK (eog_window_action_toggle_slideshow), window);
}
static void
eog_window_update_pause_slideshow_action (EogWindow *window)
{
- GtkAction *action;
+ GAction *action;
- action = gtk_action_group_get_action (window->priv->actions_image,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"PauseSlideshow");
g_signal_handlers_block_by_func
- (action, G_CALLBACK (eog_window_cmd_pause_slideshow), window);
+ (action, G_CALLBACK (eog_window_action_pause_slideshow), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
- window->priv->mode != EOG_WINDOW_MODE_SLIDESHOW);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action),
+ g_variant_new_boolean (window->priv->mode != EOG_WINDOW_MODE_SLIDESHOW));
g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (eog_window_cmd_pause_slideshow), window);
+ (action, G_CALLBACK (eog_window_action_pause_slideshow), window);
}
static gboolean
@@ -1873,20 +1870,20 @@ fullscreen_leave_notify_cb (GtkWidget *widget,
static void
exit_fullscreen_button_clicked_cb (GtkWidget *button, EogWindow *window)
{
- GtkAction *action;
+ GAction *action;
eog_debug (DEBUG_WINDOW);
if (window->priv->mode == EOG_WINDOW_MODE_SLIDESHOW) {
- action = gtk_action_group_get_action (window->priv->actions_gallery,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSlideshow");
} else {
- action = gtk_action_group_get_action (window->priv->actions_image,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewFullscreen");
}
g_return_if_fail (action != NULL);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (FALSE));
}
static GtkWidget *
@@ -1949,8 +1946,7 @@ update_ui_visibility (EogWindow *window)
{
EogWindowPrivate *priv;
- GtkAction *action;
- GtkWidget *menubar;
+ GAction *action;
gboolean fullscreen_mode, visible;
@@ -1963,32 +1959,29 @@ update_ui_visibility (EogWindow *window)
fullscreen_mode = priv->mode == EOG_WINDOW_MODE_FULLSCREEN ||
priv->mode == EOG_WINDOW_MODE_SLIDESHOW;
- menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
- g_assert (GTK_IS_WIDGET (menubar));
-
visible = g_settings_get_boolean (priv->ui_settings,
EOG_CONF_UI_TOOLBAR);
visible = visible && !fullscreen_mode;
- action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/ToolbarToggle");
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewToolbar");
g_assert (action != NULL);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (visible));
g_object_set (G_OBJECT (priv->toolbar), "visible", visible, NULL);
visible = g_settings_get_boolean (priv->ui_settings,
EOG_CONF_UI_STATUSBAR);
visible = visible && !fullscreen_mode;
- action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/StatusbarToggle");
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewStatusbar");
g_assert (action != NULL);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (visible));
g_object_set (G_OBJECT (priv->statusbar), "visible", visible, NULL);
if (priv->status != EOG_WINDOW_STATUS_INIT) {
visible = g_settings_get_boolean (priv->ui_settings,
EOG_CONF_UI_IMAGE_GALLERY);
visible = visible && priv->mode != EOG_WINDOW_MODE_SLIDESHOW;
- action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/ImageGalleryToggle");
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewImageGallery");
g_assert (action != NULL);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (visible));
if (visible) {
gtk_widget_show (priv->nav);
} else {
@@ -1999,9 +1992,9 @@ update_ui_visibility (EogWindow *window)
visible = g_settings_get_boolean (priv->ui_settings,
EOG_CONF_UI_SIDEBAR);
visible = visible && !fullscreen_mode;
- action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/SidebarToggle");
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewSidebar");
g_assert (action != NULL);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (visible));
if (visible) {
gtk_widget_show (priv->sidebar);
} else {
@@ -2278,7 +2271,9 @@ eog_window_print (EogWindow *window)
}
static void
-eog_window_cmd_file_open (GtkAction *action, gpointer user_data)
+eog_window_action_file_open (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindow *window;
EogWindowPrivate *priv;
@@ -2332,7 +2327,7 @@ static void
eog_job_close_save_cb (EogJobSave *job, gpointer user_data)
{
EogWindow *window = EOG_WINDOW (user_data);
- GtkAction *action_save;
+ GAction *action_save;
g_signal_handlers_disconnect_by_func (job,
eog_job_close_save_cb,
@@ -2343,7 +2338,7 @@ eog_job_close_save_cb (EogJobSave *job, gpointer user_data)
window->priv->save_job = NULL;
/* recover save action from actions group */
- action_save = gtk_action_group_get_action (window->priv->actions_image,
+ action_save = g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSave");
/* check if job contains any error */
@@ -2378,7 +2373,7 @@ eog_job_close_save_cb (EogJobSave *job, gpointer user_data)
update_status_bar (window);
- gtk_action_set_sensitive (action_save, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save), TRUE);
}
}
@@ -2389,7 +2384,7 @@ close_confirmation_dialog_response_handler (EogCloseConfirmationDialog *dlg,
{
GList *selected_images;
EogWindowPrivate *priv;
- GtkAction *action_save_as;
+ GAction *action_save_as;
priv = window->priv;
@@ -2417,9 +2412,9 @@ close_confirmation_dialog_response_handler (EogCloseConfirmationDialog *dlg,
g_list_first (selected_images)->data,
TRUE);
- action_save_as = gtk_action_group_get_action (priv->actions_image,
+ action_save_as = g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSaveAs");
- eog_window_cmd_save_as (action_save_as, window);
+ eog_window_action_save_as (G_SIMPLE_ACTION (action_save_as), NULL, window);
break;
case EOG_CLOSE_CONFIRMATION_DIALOG_RESPONSE_CLOSE:
@@ -2486,7 +2481,9 @@ eog_window_unsaved_images_confirm (EogWindow *window)
}
static void
-eog_window_cmd_close_window (GtkAction *action, gpointer user_data)
+eog_window_action_close_window (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -2494,7 +2491,9 @@ eog_window_cmd_close_window (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_preferences (GtkAction *action, gpointer user_data)
+eog_window_action_preferences (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -2504,7 +2503,7 @@ eog_window_cmd_preferences (GtkAction *action, gpointer user_data)
#define EOG_TB_EDITOR_DLG_RESET_RESPONSE 128
static void
-eog_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
+eog_window_action_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
{
EogWindow *window = EOG_WINDOW (data);
@@ -2544,12 +2543,14 @@ eog_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
}
static void
-eog_window_cmd_edit_toolbar (GtkAction *action, gpointer *user_data)
+eog_window_action_edit_toolbar (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window;
GtkWidget *dialog;
GtkWidget *editor;
- GtkAction *tb_action;
+ GAction *tb_action;
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -2593,32 +2594,33 @@ eog_window_cmd_edit_toolbar (GtkAction *action, gpointer *user_data)
g_signal_connect (dialog,
"response",
- G_CALLBACK (eog_window_cmd_edit_toolbar_cb),
+ G_CALLBACK (eog_window_action_edit_toolbar_cb),
window);
gtk_widget_show_all (dialog);
- tb_action = gtk_action_group_get_action (window->priv->actions_window,
+ tb_action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewToolbar");
/* Bind sensitivity of ViewToolbar action to the dialog's visibility.
* This will make it sensitive again once the dialog goes away.
*/
if(tb_action)
g_object_bind_property (dialog, "visible",
- tb_action, "sensitive",
+ tb_action, "enabled",
G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN);
/* Do the same for the EditToolbar action to avoid spawning
* additional (useless) editor windows. */
g_object_bind_property (dialog, "visible",
- action, "sensitive",
+ action, "enabled",
G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN);
-
}
static void
-eog_window_cmd_help (GtkAction *action, gpointer user_data)
+eog_window_action_help (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window;
@@ -2630,16 +2632,19 @@ eog_window_cmd_help (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_about (GtkAction *action, gpointer user_data)
+eog_window_action_about (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
eog_window_show_about_dialog (EOG_WINDOW (user_data));
-
}
static void
-eog_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
+eog_window_action_show_hide_bar (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
{
EogWindow *window;
EogWindowPrivate *priv;
@@ -2653,23 +2658,23 @@ eog_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
if (priv->mode != EOG_WINDOW_MODE_NORMAL &&
priv->mode != EOG_WINDOW_MODE_FULLSCREEN) return;
- visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ visible = g_variant_get_boolean (state);
- if (g_ascii_strcasecmp (gtk_action_get_name (action), "ViewToolbar") == 0) {
+ if (g_ascii_strcasecmp (g_action_get_name (G_ACTION (action)), "ViewToolbar") == 0) {
g_object_set (G_OBJECT (priv->toolbar), "visible", visible, NULL);
if (priv->mode == EOG_WINDOW_MODE_NORMAL)
g_settings_set_boolean (priv->ui_settings,
EOG_CONF_UI_TOOLBAR, visible);
- } else if (g_ascii_strcasecmp (gtk_action_get_name (action), "ViewStatusbar") == 0) {
+ } else if (g_ascii_strcasecmp (g_action_get_name (G_ACTION (action)), "ViewStatusbar") == 0) {
g_object_set (G_OBJECT (priv->statusbar), "visible", visible, NULL);
if (priv->mode == EOG_WINDOW_MODE_NORMAL)
g_settings_set_boolean (priv->ui_settings,
EOG_CONF_UI_STATUSBAR, visible);
- } else if (g_ascii_strcasecmp (gtk_action_get_name (action), "ViewImageGallery") == 0) {
+ } else if (g_ascii_strcasecmp (g_action_get_name (G_ACTION (action)), "ViewImageGallery") == 0) {
if (visible) {
/* Make sure the focus widget is realized to
* avoid warnings on keypress events */
@@ -2695,7 +2700,7 @@ eog_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
g_settings_set_boolean (priv->ui_settings,
EOG_CONF_UI_IMAGE_GALLERY, visible);
- } else if (g_ascii_strcasecmp (gtk_action_get_name (action), "ViewSidebar") == 0) {
+ } else if (g_ascii_strcasecmp (g_action_get_name (G_ACTION (action)), "ViewSidebar") == 0) {
if (visible) {
gtk_widget_show (priv->sidebar);
} else {
@@ -2704,6 +2709,8 @@ eog_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
g_settings_set_boolean (priv->ui_settings, EOG_CONF_UI_SIDEBAR,
visible);
}
+
+ g_simple_action_set_state (action, state);
}
static void
@@ -2826,7 +2833,7 @@ static void
eog_job_save_cb (EogJobSave *job, gpointer user_data)
{
EogWindow *window = EOG_WINDOW (user_data);
- GtkAction *action_save;
+ GAction *action_save;
g_signal_handlers_disconnect_by_func (job,
eog_job_save_cb,
@@ -2841,7 +2848,7 @@ eog_job_save_cb (EogJobSave *job, gpointer user_data)
window->priv->save_job = NULL;
/* recover save action from actions group */
- action_save = gtk_action_group_get_action (window->priv->actions_image,
+ action_save = g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSave");
/* check if job contains any error */
@@ -2850,7 +2857,7 @@ eog_job_save_cb (EogJobSave *job, gpointer user_data)
gtk_window_set_title (GTK_WINDOW (window),
eog_image_get_caption (job->current_image));
- gtk_action_set_sensitive (action_save, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save), FALSE);
} else {
GtkWidget *message_area;
@@ -2876,7 +2883,7 @@ eog_job_save_cb (EogJobSave *job, gpointer user_data)
update_status_bar (window);
- gtk_action_set_sensitive (action_save, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action_save), TRUE);
}
}
@@ -2885,7 +2892,7 @@ eog_job_copy_cb (EogJobCopy *job, gpointer user_data)
{
EogWindow *window = EOG_WINDOW (user_data);
gchar *filepath, *basename, *filename, *extension;
- GtkAction *action;
+ GAction *action;
GFile *source_file, *dest_file;
GTimeVal mtime;
@@ -2924,9 +2931,9 @@ eog_job_copy_cb (EogJobCopy *job, gpointer user_data)
gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
window->priv->copy_file_cid);
- action = gtk_action_group_get_action (window->priv->actions_image,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSetAsWallpaper");
- gtk_action_set_sensitive (action, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
window->priv->copy_job = NULL;
@@ -2961,7 +2968,9 @@ eog_window_save_images (EogWindow *window, GList *images)
}
static void
-eog_window_cmd_save (GtkAction *action, gpointer user_data)
+eog_window_action_save (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindowPrivate *priv;
EogWindow *window;
@@ -3023,7 +3032,9 @@ eog_window_retrieve_save_as_file (EogWindow *window, EogImage *image)
}
static void
-eog_window_cmd_save_as (GtkAction *action, gpointer user_data)
+eog_window_action_save_as (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindowPrivate *priv;
EogWindow *window;
@@ -3105,7 +3116,9 @@ eog_window_cmd_save_as (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
+eog_window_action_open_containing_folder (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindowPrivate *priv;
GFile *file;
@@ -3125,7 +3138,9 @@ eog_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_print (GtkAction *action, gpointer user_data)
+eog_window_action_print (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window = EOG_WINDOW (user_data);
@@ -3142,14 +3157,14 @@ eog_window_get_properties_dialog (EogWindow *window)
priv = window->priv;
if (priv->properties_dlg == NULL) {
- GtkAction *next_image_action, *previous_image_action;
+ GAction *next_image_action, *previous_image_action;
next_image_action =
- gtk_action_group_get_action (priv->actions_gallery,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"GoNext");
previous_image_action =
- gtk_action_group_get_action (priv->actions_gallery,
+ g_action_map_lookup_action (G_ACTION_MAP (window),
"GoPrevious");
priv->properties_dlg =
eog_properties_dialog_new (GTK_WINDOW (window),
@@ -3169,7 +3184,9 @@ eog_window_get_properties_dialog (EogWindow *window)
}
static void
-eog_window_cmd_properties (GtkAction *action, gpointer user_data)
+eog_window_action_properties (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window = EOG_WINDOW (user_data);
GtkWidget *dialog;
@@ -3179,7 +3196,9 @@ eog_window_cmd_properties (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_undo (GtkAction *action, gpointer user_data)
+eog_window_action_undo (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -3187,7 +3206,9 @@ eog_window_cmd_undo (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_flip_horizontal (GtkAction *action, gpointer user_data)
+eog_window_action_flip_horizontal (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -3196,7 +3217,9 @@ eog_window_cmd_flip_horizontal (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_flip_vertical (GtkAction *action, gpointer user_data)
+eog_window_action_flip_vertical (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -3205,7 +3228,9 @@ eog_window_cmd_flip_vertical (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_rotate_90 (GtkAction *action, gpointer user_data)
+eog_window_action_rotate_90 (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -3214,7 +3239,9 @@ eog_window_cmd_rotate_90 (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_rotate_270 (GtkAction *action, gpointer user_data)
+eog_window_action_rotate_270 (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
g_return_if_fail (EOG_IS_WINDOW (user_data));
@@ -3223,7 +3250,9 @@ eog_window_cmd_rotate_270 (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_wallpaper (GtkAction *action, gpointer user_data)
+eog_window_action_wallpaper (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window;
EogWindowPrivate *priv;
@@ -3252,11 +3281,11 @@ eog_window_cmd_wallpaper (GtkAction *action, gpointer user_data)
if (filename == NULL || !eog_util_file_is_persistent (file))
{
GList *files = NULL;
- GtkAction *action;
+ GAction *action;
- action = gtk_action_group_get_action (window->priv->actions_image,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ImageSetAsWallpaper");
- gtk_action_set_sensitive (action, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
priv->copy_file_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
"copy_file_cid");
@@ -3548,7 +3577,9 @@ eog_window_force_image_delete (EogWindow *window,
}
static void
-eog_window_cmd_delete (GtkAction *action, gpointer user_data)
+eog_window_action_delete (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window;
GList *images;
@@ -3700,7 +3731,9 @@ move_to_trash_real (EogImage *image, GError **error)
}
static void
-eog_window_cmd_copy_image (GtkAction *action, gpointer user_data)
+eog_window_action_copy_image (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
GtkClipboard *clipboard;
EogWindow *window;
@@ -3725,7 +3758,9 @@ eog_window_cmd_copy_image (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
+eog_window_action_move_to_trash (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
GList *images;
GList *it;
@@ -3759,7 +3794,7 @@ eog_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
can_trash = eog_window_all_images_trasheable (images);
- if (g_ascii_strcasecmp (gtk_action_get_name (action), "Delete") == 0 ||
+ if (g_ascii_strcasecmp (g_action_get_name (G_ACTION (action)), "Delete") == 0 ||
can_trash == FALSE) {
response = show_move_to_trash_confirm_dialog (window, images, can_trash);
@@ -3827,7 +3862,9 @@ eog_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
+eog_window_action_toggle_fullscreen (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
{
EogWindow *window;
gboolean fullscreen;
@@ -3838,7 +3875,7 @@ eog_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
window = EOG_WINDOW (user_data);
- fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ fullscreen = g_variant_get_boolean (state);
if (fullscreen) {
eog_window_run_fullscreen (window, FALSE);
@@ -3848,7 +3885,9 @@ eog_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_slideshow (GtkAction *action, gpointer user_data)
+eog_window_action_toggle_slideshow (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
{
EogWindow *window;
gboolean slideshow;
@@ -3859,7 +3898,7 @@ eog_window_cmd_slideshow (GtkAction *action, gpointer user_data)
window = EOG_WINDOW (user_data);
- slideshow = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ slideshow = g_variant_get_boolean (state);
if (slideshow) {
eog_window_run_fullscreen (window, TRUE);
@@ -3869,7 +3908,9 @@ eog_window_cmd_slideshow (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data)
+eog_window_action_pause_slideshow (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindow *window;
gboolean slideshow;
@@ -3889,7 +3930,9 @@ eog_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_zoom_in (GtkAction *action, gpointer user_data)
+eog_window_action_zoom_in (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -3905,7 +3948,9 @@ eog_window_cmd_zoom_in (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_zoom_out (GtkAction *action, gpointer user_data)
+eog_window_action_zoom_out (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -3921,7 +3966,9 @@ eog_window_cmd_zoom_out (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_zoom_normal (GtkAction *action, gpointer user_data)
+eog_window_action_zoom_normal (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -3937,7 +3984,9 @@ eog_window_cmd_zoom_normal (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
+eog_window_action_toggle_zoom_fit (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
{
EogWindowPrivate *priv;
EogZoomMode mode;
@@ -3948,7 +3997,7 @@ eog_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
priv = EOG_WINDOW (user_data)->priv;
- mode = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))
+ mode = g_variant_get_boolean (state)
? EOG_ZOOM_MODE_SHRINK_TO_FIT : EOG_ZOOM_MODE_FREE;
if (priv->view) {
@@ -3958,7 +4007,9 @@ eog_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_go_prev (GtkAction *action, gpointer user_data)
+eog_window_action_go_prev (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -3973,7 +4024,9 @@ eog_window_cmd_go_prev (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_go_next (GtkAction *action, gpointer user_data)
+eog_window_action_go_next (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -3988,7 +4041,9 @@ eog_window_cmd_go_next (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_go_first (GtkAction *action, gpointer user_data)
+eog_window_action_go_first (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -4003,7 +4058,9 @@ eog_window_cmd_go_first (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_go_last (GtkAction *action, gpointer user_data)
+eog_window_action_go_last (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -4018,7 +4075,9 @@ eog_window_cmd_go_last (GtkAction *action, gpointer user_data)
}
static void
-eog_window_cmd_go_random (GtkAction *action, gpointer user_data)
+eog_window_action_go_random (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
EogWindowPrivate *priv;
@@ -4032,235 +4091,6 @@ eog_window_cmd_go_random (GtkAction *action, gpointer user_data)
EOG_THUMB_VIEW_SELECT_RANDOM);
}
-static const GtkActionEntry action_entries_window[] = {
- { "Image", NULL, N_("_Image") },
- { "Edit", NULL, N_("_Edit") },
- { "View", NULL, N_("_View") },
- { "Go", NULL, N_("_Go") },
- { "Tools", NULL, N_("_Tools") },
- { "Help", NULL, N_("_Help") },
-
- { "ImageOpen", "document-open", N_("_Open…"), "<control>O",
- N_("Open a file"),
- G_CALLBACK (eog_window_cmd_file_open) },
- { "ImageClose", "window-close", N_("_Close"), "<control>W",
- N_("Close window"),
- G_CALLBACK (eog_window_cmd_close_window) },
- { "EditToolbar", NULL, N_("T_oolbar"), NULL,
- N_("Edit the application toolbar"),
- G_CALLBACK (eog_window_cmd_edit_toolbar) },
- { "EditPreferences", "preferences-desktop", N_("Prefere_nces"), NULL,
- N_("Preferences for Image Viewer"),
- G_CALLBACK (eog_window_cmd_preferences) },
- { "HelpManual", "help-browser", N_("_Contents"), "F1",
- N_("Help on this application"),
- G_CALLBACK (eog_window_cmd_help) },
- { "HelpAbout", "help-about", N_("_About"), NULL,
- N_("About this application"),
- G_CALLBACK (eog_window_cmd_about) }
-};
-
-static const GtkToggleActionEntry toggle_entries_window[] = {
- { "ViewToolbar", NULL, N_("_Toolbar"), NULL,
- N_("Changes the visibility of the toolbar in the current window"),
- G_CALLBACK (eog_window_cmd_show_hide_bar), TRUE },
- { "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
- N_("Changes the visibility of the statusbar in the current window"),
- G_CALLBACK (eog_window_cmd_show_hide_bar), TRUE },
- { "ViewImageGallery", "eog-image-gallery", N_("_Image Gallery"), "F9",
- N_("Changes the visibility of the image gallery pane in the current window"),
- G_CALLBACK (eog_window_cmd_show_hide_bar), TRUE },
- { "ViewSidebar", NULL, N_("Side _Pane"), "<control>F9",
- N_("Changes the visibility of the side pane in the current window"),
- G_CALLBACK (eog_window_cmd_show_hide_bar), TRUE },
-};
-
-static const GtkActionEntry action_entries_image[] = {
- { "ImageSave", "document-save", N_("_Save"), "<control>s",
- N_("Save changes in currently selected images"),
- G_CALLBACK (eog_window_cmd_save) },
- { "ImageOpenWith", NULL, N_("Open _with"), NULL,
- N_("Open the selected image with a different application"),
- NULL},
- { "ImageSaveAs", "document-save-as", N_("Save _As…"), "<control><shift>s",
- N_("Save the selected images with a different name"),
- G_CALLBACK (eog_window_cmd_save_as) },
- { "ImageOpenContainingFolder", "folder", N_("Show Containing _Folder"), NULL,
- N_("Show the folder which contains this file in the file manager"),
- G_CALLBACK (eog_window_cmd_open_containing_folder) },
- { "ImagePrint", "document-print", N_("_Print…"), "<control>p",
- N_("Print the selected image"),
- G_CALLBACK (eog_window_cmd_print) },
- { "ImageProperties", "document-properties", N_("Prope_rties"), "<alt>Return",
- N_("Show the properties and metadata of the selected image"),
- G_CALLBACK (eog_window_cmd_properties) },
- { "EditUndo", "edit-undo", N_("_Undo"), "<control>z",
- N_("Undo the last change in the image"),
- G_CALLBACK (eog_window_cmd_undo) },
- { "EditFlipHorizontal", "object-flip-horizontal", N_("Flip _Horizontal"), NULL,
- N_("Mirror the image horizontally"),
- G_CALLBACK (eog_window_cmd_flip_horizontal) },
- { "EditFlipVertical", "object-flip-vertical", N_("Flip _Vertical"), NULL,
- N_("Mirror the image vertically"),
- G_CALLBACK (eog_window_cmd_flip_vertical) },
- { "EditRotate90", "object-rotate-right", N_("_Rotate Clockwise"), "<control>r",
- N_("Rotate the image 90 degrees to the right"),
- G_CALLBACK (eog_window_cmd_rotate_90) },
- { "EditRotate270", "object-rotate-left", N_("Rotate Counterc_lockwise"), "<ctrl><shift>r",
- N_("Rotate the image 90 degrees to the left"),
- G_CALLBACK (eog_window_cmd_rotate_270) },
- { "ImageSetAsWallpaper", NULL, N_("Set as Wa_llpaper"),
- "<control>F8", N_("Set the selected image as the wallpaper"),
- G_CALLBACK (eog_window_cmd_wallpaper) },
- { "EditMoveToTrash", "user-trash", N_("Move to _Trash"), NULL,
- N_("Move the selected image to the trash folder"),
- G_CALLBACK (eog_window_cmd_move_to_trash) },
- { "EditDelete", "edit-delete", N_("_Delete Image"), "<shift>Delete",
- N_("Delete the selected image"),
- G_CALLBACK (eog_window_cmd_delete) },
- { "EditCopyImage", "edit-copy", N_("_Copy"), "<control>C",
- N_("Copy the selected image to the clipboard"),
- G_CALLBACK (eog_window_cmd_copy_image) },
- { "ViewZoomIn", "zoom-in", N_("_Zoom In"), "<control>plus",
- N_("Enlarge the image"),
- G_CALLBACK (eog_window_cmd_zoom_in) },
- { "ViewZoomOut", "zoom-out", N_("Zoom _Out"), "<control>minus",
- N_("Shrink the image"),
- G_CALLBACK (eog_window_cmd_zoom_out) },
- { "ViewZoomNormal", "zoom-original", N_("_Normal Size"), "<control>0",
- N_("Show the image at its normal size"),
- G_CALLBACK (eog_window_cmd_zoom_normal) },
- { "ControlEqual", "zoom-in", N_("_Zoom In"), "<control>equal",
- N_("Enlarge the image"),
- G_CALLBACK (eog_window_cmd_zoom_in) },
- { "ControlKpAdd", "zoom-in", N_("_Zoom In"), "<control>KP_Add",
- N_("Shrink the image"),
- G_CALLBACK (eog_window_cmd_zoom_in) },
- { "ControlKpSub", "zoom-in", N_("Zoom _Out"), "<control>KP_Subtract",
- N_("Shrink the image"),
- G_CALLBACK (eog_window_cmd_zoom_out) },
- { "Delete", NULL, N_("Move to _Trash"), "Delete",
- NULL,
- G_CALLBACK (eog_window_cmd_move_to_trash) },
-};
-
-static const GtkToggleActionEntry toggle_entries_image[] = {
- { "ViewFullscreen", "view-fullscreen", N_("_Fullscreen"), "F11",
- N_("Show the current image in fullscreen mode"),
- G_CALLBACK (eog_window_cmd_fullscreen), FALSE },
- { "PauseSlideshow", "media-playback-pause", N_("Pause Slideshow"),
- NULL, N_("Pause or resume the slideshow"),
- G_CALLBACK (eog_window_cmd_pause_slideshow), FALSE },
- { "ViewZoomFit", "zoom-fit-best", N_("_Best Fit"), "F",
- N_("Fit the image to the window"),
- G_CALLBACK (eog_window_cmd_zoom_fit) },
-};
-
-static const GtkActionEntry action_entries_gallery[] = {
- { "GoPrevious", "go-previous", N_("_Previous Image"), "Left",
- N_("Go to the previous image of the gallery"),
- G_CALLBACK (eog_window_cmd_go_prev) },
- { "GoNext", "go-next", N_("_Next Image"), "Right",
- N_("Go to the next image of the gallery"),
- G_CALLBACK (eog_window_cmd_go_next) },
- { "GoFirst", "go-first", N_("_First Image"), "<Alt>Home",
- N_("Go to the first image of the gallery"),
- G_CALLBACK (eog_window_cmd_go_first) },
- { "GoLast", "go-last", N_("_Last Image"), "<Alt>End",
- N_("Go to the last image of the gallery"),
- G_CALLBACK (eog_window_cmd_go_last) },
- { "GoRandom", NULL, N_("_Random Image"), "<control>M",
- N_("Go to a random image of the gallery"),
- G_CALLBACK (eog_window_cmd_go_random) },
- { "BackSpace", NULL, N_("_Previous Image"), "BackSpace",
- NULL,
- G_CALLBACK (eog_window_cmd_go_prev) },
- { "Home", NULL, N_("_First Image"), "Home",
- NULL,
- G_CALLBACK (eog_window_cmd_go_first) },
- { "End", NULL, N_("_Last Image"), "End",
- NULL,
- G_CALLBACK (eog_window_cmd_go_last) },
-};
-
-static void
-eog_window_action_go_prev (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_window_cmd_go_prev (NULL, user_data);
-}
-
-static void
-eog_window_action_go_next (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_window_cmd_go_next (NULL, user_data);
-}
-
-static void
-eog_window_action_go_first (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_window_cmd_go_first (NULL, user_data);
-}
-
-static void
-eog_window_action_go_last (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_window_cmd_go_last (NULL, user_data);
-}
-
-static void
-eog_window_action_go_random (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_window_cmd_go_random (NULL, user_data);
-}
-
-static void
-eog_window_action_rotate_90 (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_debug (DEBUG_WINDOW);
-
- eog_window_cmd_rotate_90 (NULL, user_data);
-}
-
-static void
-eog_window_action_rotate_270 (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_debug (DEBUG_WINDOW);
-
- eog_window_cmd_rotate_270 (NULL, user_data);
-}
-
-static void
-eog_window_action_zoom_in (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_debug (DEBUG_WINDOW);
- eog_window_cmd_zoom_in (NULL, user_data);
-}
-
-static void
-eog_window_action_zoom_out (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- eog_debug (DEBUG_WINDOW);
- eog_window_cmd_zoom_out (NULL, user_data);
-}
-
static void
eog_window_action_zoom_best_fit (GSimpleAction *action,
GVariant *parameter,
@@ -4313,30 +4143,57 @@ readonly_state_handler (GSimpleAction *action,
}
static const GActionEntry window_actions[] = {
- { "go-previous", eog_window_action_go_prev },
- { "go-next", eog_window_action_go_next },
- { "go-first", eog_window_action_go_first },
- { "go-last", eog_window_action_go_last },
- { "go-random", eog_window_action_go_random },
- { "rotate-right", eog_window_action_rotate_90 },
- { "rotate-left", eog_window_action_rotate_270 },
- { "zoom-in", eog_window_action_zoom_in },
- { "zoom-out", eog_window_action_zoom_out },
- { "zoom-fit", eog_window_action_zoom_best_fit },
- { "zoom-set", eog_window_action_set_zoom, "d" },
- { "current-image", NULL, NULL, "@(ii) (0, 0)", readonly_state_handler }
-};
-
-static const GtkToggleActionEntry toggle_entries_gallery[] = {
- { "ViewSlideshow", "slideshow-play", N_("S_lideshow"), "F5",
- N_("Start a slideshow view of the images"),
- G_CALLBACK (eog_window_cmd_slideshow), FALSE },
+ /* Stateless actions on the window. */
+ { "ImageOpen", eog_window_action_file_open },
+ { "ImageOpenWith", NULL },
+ { "ImageOpenContainingFolder", eog_window_action_open_containing_folder },
+ { "ImageSave", eog_window_action_save },
+ { "ImageSaveAs", eog_window_action_save_as },
+ { "ImageClose", eog_window_action_close_window },
+ { "ImagePrint", eog_window_action_print },
+ { "ImageProperties", eog_window_action_properties },
+ { "ImageSetAsWallpaper", eog_window_action_wallpaper },
+ { "EditToolbar", eog_window_action_edit_toolbar },
+ { "EditPreferences", eog_window_action_preferences },
+ { "HelpManual", eog_window_action_help },
+ { "HelpAbout", eog_window_action_about },
+
+ /* Stateless actions on the image. */
+ { "GoPrevious", eog_window_action_go_prev },
+ { "GoNext", eog_window_action_go_next },
+ { "GoFirst", eog_window_action_go_first },
+ { "GoLast", eog_window_action_go_last },
+ { "GoRandom", eog_window_action_go_random },
+ { "EditRotate90", eog_window_action_rotate_90 },
+ { "EditRotate270", eog_window_action_rotate_270 },
+ { "EditFlipHorizontal", eog_window_action_flip_horizontal },
+ { "EditFlipVertical", eog_window_action_flip_vertical },
+ { "EditMoveToTrash", eog_window_action_move_to_trash },
+ { "EditDelete", eog_window_action_delete },
+ { "EditCopyImage", eog_window_action_copy_image },
+ { "EditUndo", eog_window_action_undo },
+ { "ViewZoomIn", eog_window_action_zoom_in },
+ { "ViewZoomOut", eog_window_action_zoom_out },
+ { "ViewZoomFit", eog_window_action_zoom_best_fit },
+ { "ViewZoomNormal", eog_window_action_zoom_normal },
+ { "ViewZoomSet", eog_window_action_set_zoom, "d" },
+
+ /* Stateful actions. */
+ { "current-image", NULL, NULL, "@(ii) (0, 0)", readonly_state_handler },
+ { "ViewToolbar", NULL, NULL, "true", eog_window_action_show_hide_bar },
+ { "ViewStatusbar", NULL, NULL, "true", eog_window_action_show_hide_bar },
+ { "ViewImageGallery", NULL, NULL, "true", eog_window_action_show_hide_bar },
+ { "ViewSidebar", NULL, NULL, "true", eog_window_action_show_hide_bar },
+ { "ViewSlideshow", NULL, NULL, "false", eog_window_action_toggle_slideshow },
+ { "ViewFullscreen", NULL, NULL, "false", eog_window_action_toggle_fullscreen },
+ { "PauseSlideshow", NULL, NULL, "false", eog_window_action_pause_slideshow },
+ { "ViewZoomFit", NULL, NULL, "true", eog_window_action_toggle_zoom_fit },
};
static void
menu_item_select_cb (GtkMenuItem *proxy, EogWindow *window)
{
- GtkAction *action;
+ GAction *action;
char *message;
action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
@@ -4361,7 +4218,7 @@ menu_item_deselect_cb (GtkMenuItem *proxy, EogWindow *window)
static void
connect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
+ GAction *action,
GtkWidget *proxy,
EogWindow *window)
{
@@ -4375,7 +4232,7 @@ connect_proxy_cb (GtkUIManager *manager,
static void
disconnect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
+ GAction *action,
GtkWidget *proxy,
EogWindow *window)
{
@@ -4387,85 +4244,75 @@ disconnect_proxy_cb (GtkUIManager *manager,
}
}
-static void
-set_action_properties (EogWindow *window,
- GtkActionGroup *window_group,
- GtkActionGroup *image_group,
- GtkActionGroup *gallery_group)
+static gboolean
+_sync_map_get_bool_variant (GBinding *binding, const GValue *source,
+ GValue *target, gpointer user_data)
{
- GtkAction *action;
- EogWindowPrivate *priv = window->priv;
- gboolean rtl;
-
- rtl = gtk_widget_get_direction (GTK_WIDGET (window)) == GTK_TEXT_DIR_RTL;
-
- action = gtk_action_group_get_action (gallery_group, "GoPrevious");
- g_object_set (action, "icon-name", rtl ? "go-previous-rtl" : "go-previous", NULL);
- g_object_set (action, "short_label", _("Previous"), NULL);
- g_object_set (action, "is-important", TRUE, NULL);
-
- action = gtk_action_group_get_action (gallery_group, "GoNext");
- g_object_set (action, "icon-name", rtl ? "go-next-rtl" : "go-next", NULL);
- g_object_set (action, "short_label", _("Next"), NULL);
- g_object_set (action, "is-important", TRUE, NULL);
+ GVariant *variant;
- action = gtk_action_group_get_action (image_group, "EditUndo");
- g_object_set (action, "icon-name", rtl ? "edit-undo-rtl" : "edit-undo", NULL);
+ variant = g_value_dup_variant (source);
+ g_value_set_boolean (target, g_variant_get_boolean (variant));
- action = gtk_action_group_get_action (image_group, "EditRotate90");
- g_object_set (action, "short_label", _("Right"), NULL);
-
- action = gtk_action_group_get_action (image_group, "EditRotate270");
- g_object_set (action, "short_label", _("Left"), NULL);
-
- action = gtk_action_group_get_action (image_group, "ImageOpenContainingFolder");
- g_object_set (action, "short_label", _("Show Folder"), NULL);
+ g_variant_unref (variant);
+ return TRUE;
+}
- action = gtk_action_group_get_action (image_group, "ViewZoomIn");
- g_object_set (action, "short_label", _("In"), NULL);
+static void
+eog_window_ui_settings_changed_cb (GSettings *settings,
+ gchar *key,
+ gpointer user_data)
+{
+ EogWindow *window;
+ GVariant *new_state = NULL;
+ GVariant *old_state;
+ GAction *action = NULL;
- action = gtk_action_group_get_action (image_group, "ViewZoomOut");
- g_object_set (action, "short_label", _("Out"), NULL);
+ g_return_if_fail (EOG_IS_WINDOW (user_data));
- action = gtk_action_group_get_action (image_group, "ViewZoomNormal");
- g_object_set (action, "short_label", _("Normal"), NULL);
+ window = EOG_WINDOW (user_data);
+ if (g_ascii_strcasecmp (key, EOG_CONF_UI_IMAGE_GALLERY) == 0) {
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewImageGallery");
+ } else if (g_ascii_strcasecmp (key, EOG_CONF_UI_SIDEBAR) == 0) {
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewSidebar");
+ } else if (g_ascii_strcasecmp (key, EOG_CONF_UI_STATUSBAR) == 0) {
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewStatusbar");
+ } else if (g_ascii_strcasecmp (key, EOG_CONF_UI_TOOLBAR) == 0) {
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewToolbar");
+ }
- action = gtk_action_group_get_action (image_group, "ViewZoomFit");
- g_object_set (action, "short_label", _("Fit"), NULL);
+ g_assert (action != NULL);
- action = gtk_action_group_get_action (window_group, "ViewImageGallery");
- g_object_set (action, "short_label", _("Gallery"), NULL);
- g_settings_bind (priv->ui_settings, EOG_CONF_UI_IMAGE_GALLERY, action,
- "active", G_SETTINGS_BIND_GET);
+ new_state = g_settings_get_value (settings, key);
+ g_assert (new_state != NULL);
- action = gtk_action_group_get_action (window_group, "ViewSidebar");
- g_settings_bind (priv->ui_settings, EOG_CONF_UI_SIDEBAR, action,
- "active", G_SETTINGS_BIND_GET);
+ old_state = g_action_get_state (action);
- action = gtk_action_group_get_action (window_group, "ViewStatusbar");
- g_settings_bind (priv->ui_settings, EOG_CONF_UI_STATUSBAR, action,
- "active", G_SETTINGS_BIND_GET);
+ if (g_variant_get_boolean (new_state) != g_variant_get_boolean (old_state))
+ g_action_change_state (action, new_state);
+}
- action = gtk_action_group_get_action (window_group, "ViewToolbar");
- g_settings_bind (priv->ui_settings, EOG_CONF_UI_TOOLBAR, action,
- "active", G_SETTINGS_BIND_GET);
+static void
+set_action_properties (EogWindow *window)
+{
+ GAction *action;
+ EogWindowPrivate *priv = window->priv;
- action = gtk_action_group_get_action (image_group, "EditMoveToTrash");
- g_object_set (action, "short_label", C_("action (to trash)", "Trash"), NULL);
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "ViewToolbar");
/* Only allow editing the toolbar if it is visible */
- action = gtk_action_group_get_action (window_group, "ViewToolbar");
if (G_LIKELY (action != NULL)) {
- GtkAction *tbedit_action;
+ GAction *tbedit_action;
- tbedit_action = gtk_action_group_get_action (window_group,
+ tbedit_action = g_action_map_lookup_action (G_ACTION_MAP (window),
"EditToolbar");
if (G_LIKELY (tbedit_action != NULL)) {
// The binding should free itself when the actions do
- g_object_bind_property (action, "active",
- tbedit_action, "sensitive",
- G_BINDING_SYNC_CREATE);
+ g_object_bind_property_full (action, "state",
+ tbedit_action, "enabled",
+ G_BINDING_SYNC_CREATE,
+ _sync_map_get_bool_variant,
+ NULL, NULL, NULL);
} else {
g_warn_if_reached ();
}
@@ -4516,7 +4363,10 @@ static void
eog_window_update_recent_files_menu (EogWindow *window)
{
EogWindowPrivate *priv;
- GList *actions = NULL, *li = NULL, *items = NULL;
+ GAction *action;
+ gchar **action_names, *action_name;
+ guint i;
+ GList *li = NULL, *items = NULL;
guint count_recent = 0;
priv = window->priv;
@@ -4524,18 +4374,20 @@ eog_window_update_recent_files_menu (EogWindow *window)
if (priv->recent_menu_id != 0)
gtk_ui_manager_remove_ui (priv->ui_mgr, priv->recent_menu_id);
- actions = gtk_action_group_list_actions (priv->actions_recent);
+ action_names = g_action_group_list_actions (G_ACTION_GROUP (priv->actions_recent));
- for (li = actions; li != NULL; li = li->next) {
- g_signal_handlers_disconnect_by_func (GTK_ACTION (li->data),
+ for (i = 0; i < g_strv_length (action_names); i++) {
+ action_name = action_names[i];
+ action = g_action_map_lookup_action (G_ACTION_MAP (priv->actions_recent), action_name);
+ g_signal_handlers_disconnect_by_func (action,
G_CALLBACK(eog_window_open_recent_cb),
window);
- gtk_action_group_remove_action (priv->actions_recent,
- GTK_ACTION (li->data));
+ g_action_map_remove_action (G_ACTION_MAP (priv->actions_recent),
+ action_name);
}
- g_list_free (actions);
+ g_strfreev (action_names);
priv->recent_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
items = gtk_recent_manager_get_items (gtk_recent_manager_get_default());
@@ -4543,11 +4395,7 @@ eog_window_update_recent_files_menu (EogWindow *window)
for (li = items; li != NULL && count_recent < EOG_RECENT_FILES_LIMIT; li = li->next) {
gchar *action_name;
- gchar *label;
- gchar *tip;
- gchar **display_name;
- gchar *label_filename;
- GtkAction *action;
+ GSimpleAction *action;
GtkRecentInfo *info = li->data;
/* Sorting moves non-EOG files to the end of the list.
@@ -4558,37 +4406,18 @@ eog_window_update_recent_files_menu (EogWindow *window)
count_recent++;
action_name = g_strdup_printf ("recent-info-%d", count_recent);
- display_name = g_strsplit (gtk_recent_info_get_display_name (info), "_", -1);
- label_filename = g_strjoinv ("__", display_name);
- label = g_strdup_printf ("%s_%d. %s",
- (is_rtl ? "\xE2\x80\x8F" : ""), count_recent, label_filename);
- g_free (label_filename);
- g_strfreev (display_name);
-
- tip = gtk_recent_info_get_uri_display (info);
-
- /* This is a workaround for a bug (#351945) regarding
- * gtk_recent_info_get_uri_display() and remote URIs.
- * gnome_vfs_format_uri_for_display is sufficient here
- * since the password gets stripped when adding the
- * file to the recently used list. */
- if (tip == NULL)
- tip = g_uri_unescape_string (gtk_recent_info_get_uri (info), NULL);
-
- action = gtk_action_new (action_name, label, tip, NULL);
- gtk_action_set_always_show_image (action, TRUE);
+
+ action = g_simple_action_new (action_name, NULL);
g_object_set_data_full (G_OBJECT (action), "gtk-recent-info",
gtk_recent_info_ref (info),
(GDestroyNotify) gtk_recent_info_unref);
- g_object_set (G_OBJECT (action), "icon-name", "image-x-generic", NULL);
-
g_signal_connect (action, "activate",
G_CALLBACK (eog_window_open_recent_cb),
window);
- gtk_action_group_add_action (priv->actions_recent, action);
+ g_action_map_add_action (G_ACTION_MAP (priv->actions_recent), G_ACTION (action));
g_object_unref (action);
@@ -4598,8 +4427,6 @@ eog_window_update_recent_files_menu (EogWindow *window)
GTK_UI_MANAGER_AUTO, FALSE);
g_free (action_name);
- g_free (label);
- g_free (tip);
}
g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
@@ -4664,16 +4491,21 @@ eog_window_set_drag_dest (EogWindow *window)
static void
eog_window_sidebar_visibility_changed (GtkWidget *widget, EogWindow *window)
{
- GtkAction *action;
+ GAction *action;
+ GVariant *state;
gboolean visible;
+ gboolean active;
visible = gtk_widget_get_visible (window->priv->sidebar);
- action = gtk_action_group_get_action (window->priv->actions_window,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSidebar");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ state = g_action_get_state (action);
+ active = g_variant_get_boolean (state);
+ if (active != visible)
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (visible));
+ g_variant_unref (state);
/* Focus the image */
if (!visible && window->priv->image != NULL)
@@ -4686,34 +4518,39 @@ eog_window_sidebar_page_added (EogSidebar *sidebar,
EogWindow *window)
{
if (eog_sidebar_get_n_pages (sidebar) == 1) {
- GtkAction *action;
+ GAction *action;
+ GVariant *state;
gboolean show;
- action = gtk_action_group_get_action (window->priv->actions_window,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSidebar");
- gtk_action_set_sensitive (action, TRUE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
- show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ state = g_action_get_state (action);
+ show = g_variant_get_boolean (state);
if (show)
gtk_widget_show (GTK_WIDGET (sidebar));
+
+ g_variant_unref (state);
}
}
+
static void
eog_window_sidebar_page_removed (EogSidebar *sidebar,
GtkWidget *main_widget,
EogWindow *window)
{
if (eog_sidebar_is_empty (sidebar)) {
- GtkAction *action;
+ GAction *action;
gtk_widget_hide (GTK_WIDGET (sidebar));
- action = gtk_action_group_get_action (window->priv->actions_window,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewSidebar");
- gtk_action_set_sensitive (action, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
}
@@ -4739,9 +4576,9 @@ get_appinfo_for_editor (EogWindow *window)
* to the "available" list of the EggToolbarsModel (for which
* there is no API to remove it). If later the editor no longer
* existed when constructing a new window, we'd be unable to
- * construct a GtkAction for the editor for that window, causing
+ * construct a GAction for the editor for that window, causing
* assertion failures when viewing the "Edit Toolbars" dialog
- * (item is available, but can't find the GtkAction for it).
+ * (item is available, but can't find the GAction for it).
*
* By ensuring we keep the GAppInfo around, we avoid the
* possibility of that situation occurring.
@@ -4767,7 +4604,7 @@ get_appinfo_for_editor (EogWindow *window)
}
static void
-eog_window_open_editor (GtkAction *action,
+eog_window_open_editor (GAction *action,
EogWindow *window)
{
GdkAppLaunchContext *context;
@@ -4805,8 +4642,7 @@ eog_window_add_open_editor_action (EogWindow *window)
{
EggToolbarsModel *model;
GAppInfo *app_info;
- GtkAction *action;
- gchar *tooltip;
+ GSimpleAction *action;
app_info = get_appinfo_for_editor (window);
@@ -4817,19 +4653,14 @@ eog_window_add_open_editor_action (EogWindow *window)
egg_toolbars_model_set_name_flags (model, "OpenEditor",
EGG_TB_MODEL_NAME_KNOWN);
- tooltip = g_strdup_printf (_("Edit the current image using %s"),
- g_app_info_get_name (app_info));
- action = gtk_action_new ("OpenEditor", _("Edit Image"), tooltip, NULL);
- gtk_action_set_gicon (action, g_app_info_get_icon (app_info));
- gtk_action_set_is_important (action, TRUE);
+ action = g_simple_action_new ("OpenEditor", NULL);
g_signal_connect (action, "activate",
G_CALLBACK (eog_window_open_editor), window);
- gtk_action_group_add_action (window->priv->actions_image, action);
+ g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
g_object_unref (action);
- g_free (tooltip);
}
static void
@@ -4844,14 +4675,14 @@ static void
eog_window_view_next_image_cb (EogScrollView *view,
EogWindow *window)
{
- eog_window_cmd_go_next (NULL, window);
+ eog_window_action_go_next (NULL, NULL, window);
}
static void
eog_window_view_previous_image_cb (EogScrollView *view,
EogWindow *window)
{
- eog_window_cmd_go_prev (NULL, window);
+ eog_window_action_go_prev (NULL, NULL, window);
}
static void
@@ -4866,7 +4697,7 @@ eog_window_construct_ui (EogWindow *window)
GtkWidget *view_popup;
GtkWidget *hpaned;
GtkWidget *menuitem;
- GtkAction *action = NULL;
+ GAction *action = NULL;
g_return_if_fail (EOG_IS_WINDOW (window));
@@ -4878,60 +4709,9 @@ eog_window_construct_ui (EogWindow *window)
gtk_widget_show (priv->box);
priv->ui_mgr = gtk_ui_manager_new ();
- priv->actions_window = gtk_action_group_new ("MenuActionsWindow");
-
- gtk_action_group_set_translation_domain (priv->actions_window,
- GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (priv->actions_window,
- action_entries_window,
- G_N_ELEMENTS (action_entries_window),
- window);
-
- gtk_action_group_add_toggle_actions (priv->actions_window,
- toggle_entries_window,
- G_N_ELEMENTS (toggle_entries_window),
- window);
-
- gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_window, 0);
-
- priv->actions_image = gtk_action_group_new ("MenuActionsImage");
- gtk_action_group_set_translation_domain (priv->actions_image,
- GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (priv->actions_image,
- action_entries_image,
- G_N_ELEMENTS (action_entries_image),
- window);
-
eog_window_add_open_editor_action (window);
- gtk_action_group_add_toggle_actions (priv->actions_image,
- toggle_entries_image,
- G_N_ELEMENTS (toggle_entries_image),
- window);
-
- gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_image, 0);
-
- priv->actions_gallery = gtk_action_group_new ("MenuActionsGallery");
- gtk_action_group_set_translation_domain (priv->actions_gallery,
- GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (priv->actions_gallery,
- action_entries_gallery,
- G_N_ELEMENTS (action_entries_gallery),
- window);
-
- gtk_action_group_add_toggle_actions (priv->actions_gallery,
- toggle_entries_gallery,
- G_N_ELEMENTS (toggle_entries_gallery),
- window);
-
- set_action_properties (window, priv->actions_window,
- priv->actions_image,
- priv->actions_gallery);
-
- gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_gallery, 0);
+ set_action_properties (window);
if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
"/org/gnome/eog/ui/eog-ui.xml",
@@ -4989,12 +4769,10 @@ eog_window_construct_ui (EogWindow *window)
gtk_widget_show (priv->toolbar);
- gtk_window_add_accel_group (GTK_WINDOW (window),
- gtk_ui_manager_get_accel_group (priv->ui_mgr));
+ /*gtk_window_add_accel_group (GTK_WINDOW (window),
+ gtk_ui_manager_get_accel_group (priv->ui_mgr));*/
- priv->actions_recent = gtk_action_group_new ("RecentFilesActions");
- gtk_action_group_set_translation_domain (priv->actions_recent,
- GETTEXT_PACKAGE);
+ priv->actions_recent = g_simple_action_group_new ();
g_signal_connect (gtk_recent_manager_get_default (), "changed",
G_CALLBACK (eog_window_recent_manager_changed_cb),
@@ -5078,12 +4856,12 @@ eog_window_construct_ui (EogWindow *window)
"zoom_changed",
G_CALLBACK (view_zoom_changed_cb),
window);
- action = gtk_action_group_get_action (priv->actions_image,
+ action = g_action_map_lookup_action (G_ACTION_MAP (window),
"ViewZoomFit");
if (action != NULL) {
/* Binding will be destroyed when the objects finalize */
g_object_bind_property_full (priv->view, "zoom-mode",
- action, "active",
+ action, "state",
G_BINDING_SYNC_CREATE,
_eog_zoom_shrink_to_boolean,
NULL, NULL, NULL);
@@ -5181,6 +4959,14 @@ eog_window_init (EogWindow *window)
priv->view_settings = g_settings_new (EOG_CONF_VIEW);
priv->lockdown_settings = g_settings_new (EOG_CONF_DESKTOP_LOCKDOWN_SCHEMA);
+ /* Creating a binding between the ui settings and the related GActions does
+ * not trigger the state changed handler since the state is updated directly
+ * via the "state" property. Requesting a state change via this callback,
+ * however, works. */
+ g_signal_connect (priv->ui_settings, "changed",
+ G_CALLBACK (eog_window_ui_settings_changed_cb),
+ window);
+
window->priv->store = NULL;
window->priv->image = NULL;
@@ -5275,21 +5061,6 @@ eog_window_dispose (GObject *object)
priv->image = NULL;
}
- if (priv->actions_window != NULL) {
- g_object_unref (priv->actions_window);
- priv->actions_window = NULL;
- }
-
- if (priv->actions_image != NULL) {
- g_object_unref (priv->actions_image);
- priv->actions_image = NULL;
- }
-
- if (priv->actions_gallery != NULL) {
- g_object_unref (priv->actions_gallery);
- priv->actions_gallery = NULL;
- }
-
if (priv->actions_recent != NULL) {
g_object_unref (priv->actions_recent);
priv->actions_recent = NULL;
@@ -5427,9 +5198,9 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
}
if ((event->state & modifiers) == GDK_SHIFT_MASK) {
- eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
+ eog_window_action_go_prev (NULL, NULL, EOG_WINDOW (widget));
} else {
- eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
+ eog_window_action_go_next (NULL, NULL, EOG_WINDOW (widget));
}
result = TRUE;
}
@@ -5449,7 +5220,7 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
} else if (EOG_WINDOW (widget)->priv->mode == EOG_WINDOW_MODE_SLIDESHOW) {
eog_window_stop_fullscreen (EOG_WINDOW (widget), TRUE);
} else {
- eog_window_cmd_close_window (NULL, EOG_WINDOW (widget));
+ eog_window_action_close_window (NULL, NULL, EOG_WINDOW (widget));
return TRUE;
}
break;
@@ -5458,9 +5229,9 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
if ((event->state & modifiers) == 0) {
/* Left and Up move to previous image */
if (is_rtl) { /* move to next in RTL mode */
- eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
+ eog_window_action_go_next (NULL, NULL, EOG_WINDOW (widget));
} else {
- eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
+ eog_window_action_go_prev (NULL, NULL, EOG_WINDOW (widget));
}
result = TRUE;
}
@@ -5470,9 +5241,9 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
if ((event->state & modifiers) == 0) {
/* Right and Down move to next image */
if (is_rtl) { /* move to previous in RTL mode */
- eog_window_cmd_go_prev (NULL, EOG_WINDOW (widget));
+ eog_window_action_go_prev (NULL, NULL, EOG_WINDOW (widget));
} else {
- eog_window_cmd_go_next (NULL, EOG_WINDOW (widget));
+ eog_window_action_go_next (NULL, NULL, EOG_WINDOW (widget));
}
result = TRUE;
}
@@ -5484,8 +5255,7 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
/* If the iconview is not visible skip to the
* previous image manually as it won't handle
* the keypress then. */
- eog_window_cmd_go_prev (NULL,
- EOG_WINDOW (widget));
+ eog_window_action_go_prev (NULL, NULL, EOG_WINDOW (widget));
result = TRUE;
} else
handle_selection = TRUE;
@@ -5499,8 +5269,7 @@ eog_window_key_press (GtkWidget *widget, GdkEventKey *event)
/* If the iconview is not visible skip to the
* next image manually as it won't handle
* the keypress then. */
- eog_window_cmd_go_next (NULL,
- EOG_WINDOW (widget));
+ eog_window_action_go_next (NULL, NULL, EOG_WINDOW (widget));
result = TRUE;
} else
handle_selection = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]