Commit de573cf3 authored by Felix Riemann's avatar Felix Riemann

postasa: Disable upload action if no images are selected

Nothing would happen, so don't offer it.

https://bugzilla.gnome.org/show_bug.cgi?id=755244
parent 39e8d056
......@@ -774,6 +774,35 @@ login_get_dialog (EogPostasaPlugin *plugin)
/*** EogPlugin Functions ***/
static void
eog_postasa_plugin_update_action_state (EogPostasaPlugin *plugin)
{
EogPostasaPluginPrivate *priv = plugin->priv;
GAction *action;
EogThumbView *thumbview;
gboolean enable = FALSE;
thumbview = EOG_THUMB_VIEW (eog_window_get_thumb_view (priv->eog_window));
if (G_LIKELY (thumbview))
{
enable = (eog_thumb_view_get_n_selected (thumbview) != 0);
}
action = g_action_map_lookup_action (G_ACTION_MAP (priv->eog_window),
EOG_POSTASA_PLUGIN_ACTION);
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enable);
}
static void
_selection_changed_cb (EogThumbView *thumbview, gpointer user_data)
{
EogPostasaPlugin *plugin = EOG_POSTASA_PLUGIN (user_data);
if (G_LIKELY (plugin))
eog_postasa_plugin_update_action_state (plugin);
}
/**
* impl_activate:
*
......@@ -802,6 +831,12 @@ impl_activate (EogWindowActivatable *activatable)
G_ACTION (action));
g_object_unref (action);
g_signal_connect (G_OBJECT (eog_window_get_thumb_view (plugin->priv->eog_window)),
"selection-changed",
G_CALLBACK (_selection_changed_cb),
plugin);
eog_postasa_plugin_update_action_state (plugin);
/* Append entry to the window's gear menu */
menu = g_menu_new ();
g_menu_append (menu, _("Upload to PicasaWeb"),
......@@ -850,6 +885,9 @@ impl_deactivate (EogWindowActivatable *activatable)
}
}
g_signal_handlers_disconnect_by_func (eog_window_get_thumb_view (plugin->priv->eog_window),
_selection_changed_cb, plugin);
/* Finally remove action */
g_action_map_remove_action (G_ACTION_MAP (plugin->priv->eog_window),
EOG_POSTASA_PLUGIN_ACTION);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment