[Xfce4-commits] <midori:master> Recognize custom commands with "application" preference proxies

Christian Dywan noreply at xfce.org
Mon Nov 2 22:08:03 CET 2009


Updating branch refs/heads/master
         to 219872aa8f7f3c0a6650956289f3b0a29ca13244 (commit)
       from 4fbbc43e421d8f7649a3c9cab8d9c50cf8405e29 (commit)

commit 219872aa8f7f3c0a6650956289f3b0a29ca13244
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Nov 2 22:02:16 2009 +0100

    Recognize custom commands with "application" preference proxies
    
    Entering commands isn't possible yet but existing commands are
    preserved and shown in the combo box.

 katze/katze-utils.c |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index b046249..5fc0efd 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -75,6 +75,21 @@ proxy_combo_box_text_changed_cb (GtkComboBox* button,
     g_object_set (object, property, text, NULL);
 }
 
+static const gchar*
+katze_app_info_get_commandline (GAppInfo* info)
+{
+    const gchar* exe;
+
+    #if GLIB_CHECK_VERSION (2, 20, 0)
+    exe = g_app_info_get_commandline (info);
+    #else
+    exe = g_object_get_data (G_OBJECT (info), "katze-cmdline");
+    #endif
+    if (!exe)
+        exe = g_app_info_get_executable (info);
+    return exe;
+}
+
 static void
 proxy_combo_box_apps_changed_cb (GtkComboBox* button,
                                  GObject*     object)
@@ -93,12 +108,7 @@ proxy_combo_box_apps_changed_cb (GtkComboBox* button,
 
         if (info)
         {
-            #if 0 /* GLIB_CHECK_VERSION (2, 20, 0) */
-            /* FIXME: Implement non-trivial command lines */
-            exe = g_app_info_get_commandline (info);
-            #else
-            exe = g_app_info_get_executable (info);
-            #endif
+            exe = katze_app_info_get_commandline (info);
             g_object_set (object, property, exe, NULL);
             g_object_unref (info);
         }
@@ -467,16 +477,32 @@ katze_property_proxy (gpointer     object,
 
                 gtk_list_store_insert_with_values (model, &iter, G_MAXINT,
                     0, info, 1, icon_name, 2, name, -1);
-                if (string && g_strrstr (g_app_info_get_executable (info), string))
+                if (string && !strcmp (katze_app_info_get_commandline (info), string))
                     gtk_combo_box_set_active_iter (combo, &iter);
 
                 g_free (icon_name);
             }
 
+            /* FIXME: Implement entering a custom command
+            gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
+                0, NULL, 1, NULL, 2, _("Custom..."), -1); */
+
             if (gtk_combo_box_get_active (combo) == -1)
             {
                 if (string)
-                    /* FIXME: Support custom command */;
+                {
+                    GtkTreeIter iter;
+
+                    info = g_app_info_create_from_commandline (string,
+                        NULL, G_APP_INFO_CREATE_NONE, NULL);
+                    #if !GLIB_CHECK_VERSION (2, 20, 0)
+                    g_object_set_data (G_OBJECT (info), "katze-cmdline");
+                    #endif
+                    gtk_list_store_insert_with_values (model, &iter, G_MAXINT,
+                        0, info, 1, NULL, 2, string, -1);
+                    gtk_combo_box_set_active_iter (combo, &iter);
+                    g_object_unref (info);
+                }
                 else
                     gtk_combo_box_set_active_iter (combo, &iter_none);
             }



More information about the Xfce4-commits mailing list