[Xfce4-commits] <ristretto:ristretto-0.0> Add initial code to implement the open-with menu
Stephan Arts
noreply at xfce.org
Sun Oct 23 19:20:18 CEST 2011
Updating branch refs/heads/ristretto-0.0
to 3e7c0bb6540eaef683a6aff3306ed53d1ff5c2e9 (commit)
from a4f7e2f0e83118bfd8cb5ff2cee068c60f19efe3 (commit)
commit 3e7c0bb6540eaef683a6aff3306ed53d1ff5c2e9
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Sep 23 00:15:52 2009 +0200
Add initial code to implement the open-with menu
ChangeLog | 5 +++++
src/main_window.c | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6b8721e..77d4312 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-09-22 Stephan Arts <stephan at xfce.org>
+ * src/main_window.c: Add initial code for implementation of the
+ 'open-with' menu
+
+2009-09-22 Stephan Arts <stephan at xfce.org>
+
* src/main_window.c,
src/picture_viewer.c: Do not change zoom-mode when switching to
fullscreen, recalculate scale when fitting image to window (zoom-fit)
diff --git a/src/main_window.c b/src/main_window.c
index d95959c..2904117 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -701,9 +701,16 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
{
gchar *path, *basename, *title, *status;
GFile *file = NULL;
+ GFileInfo *file_info = NULL;
RsttoImage *cur_image;
gint position, count, width, height;
RsttoImageList *image_list = window->priv->props.image_list;
+ GList *app_list, *iter;
+ const gchar *content_type;
+ GtkWidget *open_with_menu = gtk_menu_new();
+ GtkWidget *open_with_window_menu = gtk_menu_new();
+ gtk_menu_item_set_submenu (gtk_ui_manager_get_widget ( window->priv->ui_manager, "/image-viewer-menu/open-with-menu"), open_with_menu);
+ gtk_menu_item_set_submenu (gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/open-with-menu"), open_with_window_menu);
if (window->priv->props.image_list)
{
@@ -712,12 +719,29 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
cur_image = rstto_image_list_iter_get_image (window->priv->iter);
if (cur_image)
{
+ file = rstto_image_get_file (cur_image);
+ file_info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL);
+ content_type = g_file_info_get_content_type (file_info);
+ app_list = g_app_info_get_all_for_type (content_type);
+
+ for (iter = app_list; iter; iter = g_list_next (iter))
+ {
+ GtkWidget *menu_item = gtk_image_menu_item_new_with_label (g_app_info_get_name (iter->data));
+ gtk_menu_shell_append (GTK_MENU_SHELL (open_with_menu), menu_item);
+ gtk_widget_set_sensitive (menu_item, FALSE);
+
+ menu_item = gtk_image_menu_item_new_with_label (g_app_info_get_name (iter->data));
+ gtk_menu_shell_append (GTK_MENU_SHELL (open_with_window_menu), menu_item);
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ gtk_widget_show_all (open_with_menu);
+ gtk_widget_show_all (open_with_window_menu);
g_signal_connect (G_OBJECT (cur_image), "updated", G_CALLBACK (cb_rstto_main_window_image_updated), window);
width = rstto_image_get_width(cur_image);
height = rstto_image_get_height(cur_image);
- file = rstto_image_get_file (cur_image);
path = g_file_get_path (file);
basename = g_path_get_basename (path);
@@ -737,6 +761,18 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
}
else
{
+ GtkWidget *menu_item = gtk_image_menu_item_new_with_label (_("Empty"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (open_with_menu), menu_item);
+ gtk_widget_set_sensitive (menu_item, FALSE);
+
+
+ menu_item = gtk_image_menu_item_new_with_label (_("Empty"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (open_with_window_menu), menu_item);
+ gtk_widget_set_sensitive (menu_item, FALSE);
+
+ gtk_widget_show_all (open_with_menu);
+ gtk_widget_show_all (open_with_window_menu);
+
title = g_strdup (RISTRETTO_APP_TITLE);
status = g_strdup (_("Press open to select an image"));
}
More information about the Xfce4-commits
mailing list