[Xfce4-commits] [xfce/xfdesktop] 05/13: Show sub directories in template menu

noreply at xfce.org noreply at xfce.org
Tue Mar 3 18:21:02 CET 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 3317d343085f0d796532e8641e6ce3a0cdd89d38
Author: Thaddaeus Tintenfisch <thad.fisch at gmail.com>
Date:   Thu Feb 26 22:35:02 2015 +0100

    Show sub directories in template menu
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 src/xfdesktop-file-icon-manager.c |   36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c
index 86c1979..0b2b37b 100644
--- a/src/xfdesktop-file-icon-manager.c
+++ b/src/xfdesktop-file-icon-manager.c
@@ -1201,7 +1201,7 @@ xfdesktop_file_icon_menu_fill_template_menu(GtkWidget *menu,
                                             XfdesktopFileIconManager *fmanager)
 {
     GFileEnumerator *enumerator;
-    GtkWidget *item, *image;
+    GtkWidget *item, *image, *submenu;
     GFileInfo *info;
     GFile *file;
     GIcon *icon;
@@ -1224,12 +1224,6 @@ xfdesktop_file_icon_menu_fill_template_menu(GtkWidget *menu,
      * help in instances where the XDG_TEMPLATES_DIR has a large number of
      * files in it. */
     while((info = g_file_enumerator_next_file(enumerator, NULL, NULL)) && items < fmanager->priv->max_templates) {
-        /* Skip directories */
-        if(g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY) {
-           g_object_unref(info);
-           continue;
-        }
-
         /* skip hidden & backup files */
         if(g_file_info_get_is_hidden(info) || g_file_info_get_is_backup(info)) {
             g_object_unref(info);
@@ -1251,6 +1245,18 @@ xfdesktop_file_icon_menu_fill_template_menu(GtkWidget *menu,
         file = lp->data;
         info = g_object_get_data(G_OBJECT(file), "info");
 
+        /* create and fill template submenu */
+        if(g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY) {
+            submenu = gtk_menu_new();
+
+            xfdesktop_file_icon_menu_fill_template_menu(submenu, file, fmanager);
+
+            if(!gtk_container_get_children((GtkContainer*) submenu)) {
+                g_object_unref(file);
+                continue;
+            }
+        }
+
         /* generate a label by stripping off the extension */
         label = g_strdup(g_file_info_get_display_name(info));
         dot = g_utf8_strrchr(label, -1, '.');
@@ -1267,15 +1273,19 @@ xfdesktop_file_icon_menu_fill_template_menu(GtkWidget *menu,
         gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
 
         /* add the item to the menu */
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
         gtk_widget_show(item);
+        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
-        g_object_set_data_full(G_OBJECT(item), "file",
-                               g_object_ref(file), g_object_unref);
+        if(g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY)
+            gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
+        else {
+            g_object_set_data_full(G_OBJECT(item), "file",
+                                   g_object_ref(file), g_object_unref);
 
-        g_signal_connect(G_OBJECT(item), "activate",
-                         G_CALLBACK(xfdesktop_file_icon_template_item_activated),
-                         fmanager);
+            g_signal_connect(G_OBJECT(item), "activate",
+                             G_CALLBACK(xfdesktop_file_icon_template_item_activated),
+                             fmanager);
+        }
 
         g_object_unref(file);
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list