[frogr] Open a picture in the external viewer from the main view (#653993)
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Open a picture in the external viewer from the main view (#653993)
- Date: Fri, 8 Jul 2011 12:54:22 +0000 (UTC)
commit 8cd8a09e99edfbf7668dbe309682b033d06dc3f2
Author: Joaquim Rocha <jrocha igalia com>
Date: Thu Jul 7 17:20:28 2011 +0200
Open a picture in the external viewer from the main view (#653993)
Add a new entry under the context and the "Actions" menu to open
the selected pictures in the external image viewer.
https://bugzilla.gnome.org/show_bug.cgi?id=653993
data/gtkbuilder/frogr-main-view.xml | 34 +++++++++++++++++++++++++++++++++-
src/frogr-main-view.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/data/gtkbuilder/frogr-main-view.xml b/data/gtkbuilder/frogr-main-view.xml
index 0a34d4f..2b77a01 100644
--- a/data/gtkbuilder/frogr-main-view.xml
+++ b/data/gtkbuilder/frogr-main-view.xml
@@ -44,6 +44,10 @@
<property name="stock_id">gtk-help</property>
<signal name="activate" handler="_on_action_activated" swapped="no"/>
</object>
+ <object class="GtkAction" id="open_in_external_viewer_action">
+ <property name="label" translatable="yes">Open in E_xternal Viewer</property>
+ <signal name="activate" handler="_on_action_activated" swapped="no"/>
+ </object>
<object class="GtkAction" id="preferences_action">
<property name="label" translatable="yes">_Preferencesâ</property>
<property name="stock_id">gtk-preferences</property>
@@ -153,7 +157,21 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="remove_pictures_ctxt_menu_item">
+ <object class="GtkMenuItem" id="open_in_external_viewer_ctxt_menu_item">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="related_action">open_in_external_viewer_action</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="remove_pictures_menu_item">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="related_action">remove_pictures_action</property>
@@ -423,6 +441,20 @@
</object>
</child>
<child>
+ <object class="GtkMenuItem" id="open_in_external_viewer_menu_item">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="related_action">open_in_external_viewer_action</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="upload_all_menu_item">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 48d95f6..fc0f228 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -95,6 +95,7 @@ typedef struct _FrogrMainViewPrivate {
GtkAction *add_pictures_action;
GtkAction *remove_pictures_action;
GtkAction *upload_pictures_action;
+ GtkAction *open_in_external_viewer_action;
GtkAction *auth_action;
GtkAction *preferences_action;
GtkAction *add_tags_action;
@@ -161,6 +162,7 @@ static gint _n_pictures (FrogrMainView *self);
static gint _n_selected_pictures (FrogrMainView *self);
static void _add_picture_to_ui (FrogrMainView *self, FrogrPicture *picture);
static void _remove_picture_from_ui (FrogrMainView *self, FrogrPicture *picture);
+static void _open_pictures_in_external_viewer (FrogrMainView *self);
static void _add_pictures_dialog_response_cb (GtkDialog *dialog,
gint response,
@@ -396,6 +398,8 @@ _on_action_activated (GtkAction *action, gpointer data)
_remove_selected_pictures (mainview);
else if (action == priv->upload_pictures_action)
_upload_pictures (mainview);
+ else if (action == priv->open_in_external_viewer_action)
+ _open_pictures_in_external_viewer (mainview);
else if (action == priv->auth_action)
frogr_controller_show_auth_dialog (priv->controller);
else if (action == priv->preferences_action)
@@ -967,6 +971,31 @@ _edit_selected_pictures (FrogrMainView *self)
}
static void
+_open_pictures_in_external_viewer (FrogrMainView *self)
+{
+ gchar *uris = NULL;
+ GSList *pictures, *current_pic;
+ FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
+
+ if (!_pictures_selected_required_check (self))
+ return;
+
+ pictures = current_pic = _get_selected_pictures (self);
+ while (current_pic)
+ {
+ FrogrPicture *picture = FROGR_PICTURE (current_pic->data);
+ gchar *current_uris = uris;
+ uris = g_strconcat (frogr_picture_get_fileuri (picture), " ", current_uris);
+ g_free (current_uris);
+ current_pic = g_slist_next (current_pic);
+ }
+ g_slist_foreach (pictures, (GFunc) g_object_unref, NULL);
+ g_slist_free (pictures);
+ frogr_util_open_multiple_uris (uris);
+ g_free (uris);
+}
+
+static void
_remove_selected_pictures (FrogrMainView *self)
{
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
@@ -1380,6 +1409,7 @@ _update_ui (FrogrMainView *self)
gtk_action_set_sensitive (priv->add_pictures_action, FALSE);
gtk_action_set_sensitive (priv->remove_pictures_action, FALSE);
gtk_action_set_sensitive (priv->upload_pictures_action, FALSE);
+ gtk_action_set_sensitive (priv->open_in_external_viewer_action, FALSE);
gtk_action_set_sensitive (priv->auth_action, FALSE);
gtk_action_set_sensitive (priv->add_tags_action, FALSE);
gtk_action_set_sensitive (priv->edit_details_action, FALSE);
@@ -1397,6 +1427,7 @@ _update_ui (FrogrMainView *self)
gtk_action_set_sensitive (priv->add_pictures_action, TRUE);
gtk_action_set_sensitive (priv->remove_pictures_action, has_pics);
gtk_action_set_sensitive (priv->upload_pictures_action, has_pics);
+ gtk_action_set_sensitive (priv->open_in_external_viewer_action, has_pics);
gtk_action_set_sensitive (priv->auth_action, TRUE);
gtk_action_set_sensitive (priv->add_tags_action, has_pics);
gtk_action_set_sensitive (priv->edit_details_action, has_pics);
@@ -1569,6 +1600,9 @@ frogr_main_view_init (FrogrMainView *self)
GTK_ACTION (gtk_builder_get_object (builder, "remove_pictures_action"));
priv->upload_pictures_action =
GTK_ACTION (gtk_builder_get_object (builder, "upload_pictures_action"));
+ priv->open_in_external_viewer_action =
+ GTK_ACTION (gtk_builder_get_object (builder,
+ "open_in_external_viewer_action"));
priv->auth_action =
GTK_ACTION (gtk_builder_get_object (builder, "auth_action"));
priv->preferences_action =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]