[gnome-shell] app-system: Don't show items with NoDisplay parents in the search



commit df56ff4f097ab4109a40fc928199abfe6511a4b7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jun 19 11:35:05 2012 -0400

    app-system: Don't show items with NoDisplay parents in the search
    
    Additionally, require gnome-menus 3.5.3, as we're using new API
    introduced there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=658176

 configure.ac           |    4 +++-
 src/shell-app-system.c |   17 ++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d59eab6..06d8564 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,7 @@ POLKIT_MIN_VERSION=0.100
 STARTUP_NOTIFICATION_MIN_VERSION=0.11
 GCR_MIN_VERSION=3.3.90
 GNOME_DESKTOP_REQUIRED_VERSION=3.5.1
+GNOME_MENUS_REQUIRED_VERSION=3.5.3
 
 AC_ARG_WITH(folks,
             AS_HELP_STRING([--with-folks],
@@ -100,7 +101,8 @@ PKG_CHECK_MODULES(GNOME_SHELL, gio-unix-2.0 >= $GIO_MIN_VERSION
 			       $FOLKS_REQUIREMENT
                                libmutter >= $MUTTER_MIN_VERSION
                                gjs-internals-1.0 >= $GJS_MIN_VERSION
-			       libgnome-menu-3.0 $recorder_modules
+			       libgnome-menu-3.0 >= $GNOME_MENUS_REQUIRED_VERSION
+                               $recorder_modules
                                gdk-x11-3.0 libsoup-2.4
                                gl
 			       clutter-x11-1.0 >= $CLUTTER_MIN_VERSION
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 6210220..7f34c28 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -41,6 +41,7 @@ struct _ShellAppSystemPrivate {
   GMenuTree *apps_tree;
 
   GHashTable *running_apps;
+  GHashTable *visible_id_to_app;
   GHashTable *id_to_app;
 
   GSList *known_vendor_prefixes;
@@ -92,14 +93,16 @@ shell_app_system_init (ShellAppSystem *self)
   priv->id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,
                                            NULL,
                                            (GDestroyNotify)g_object_unref);
+
+  /* All the objects in this hash table are owned by id_to_app */
+  priv->visible_id_to_app = g_hash_table_new (g_str_hash, g_str_equal);
+
   priv->setting_id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                    NULL,
                                                    (GDestroyNotify)g_object_unref);
 
-  /* For now, we want to pick up Evince, Nautilus, etc.  We'll
-   * handle NODISPLAY semantics at a higher level or investigate them
-   * case by case.
-   */
+  /* We want to track NoDisplay apps, so we add INCLUDE_NODISPLAY. We'll
+   * filter NoDisplay apps out when showing them to the user. */
   priv->apps_tree = gmenu_tree_new ("applications.menu", GMENU_TREE_FLAGS_INCLUDE_NODISPLAY);
   g_signal_connect (priv->apps_tree, "changed", G_CALLBACK (on_apps_tree_changed_cb), self);
 
@@ -121,6 +124,7 @@ shell_app_system_finalize (GObject *object)
 
   g_hash_table_destroy (priv->running_apps);
   g_hash_table_destroy (priv->id_to_app);
+  g_hash_table_destroy (priv->visible_id_to_app);
   g_hash_table_destroy (priv->setting_id_to_app);
 
   g_slist_free_full (priv->known_vendor_prefixes, g_free);
@@ -308,6 +312,7 @@ on_apps_tree_changed_cb (GMenuTree *tree,
 
   g_assert (tree == self->priv->apps_tree);
 
+  g_hash_table_remove_all (self->priv->visible_id_to_app);
   g_slist_free_full (self->priv->known_vendor_prefixes, g_free);
   self->priv->known_vendor_prefixes = NULL;
 
@@ -369,6 +374,8 @@ on_apps_tree_changed_cb (GMenuTree *tree,
        * string is pointed to.
        */
       g_hash_table_replace (self->priv->id_to_app, (char*)id, app);
+      if (!gmenu_tree_entry_get_is_nodisplay_recurse (entry))
+        g_hash_table_replace (self->priv->visible_id_to_app, (char*)id, app);
 
       if (old_entry)
         gmenu_tree_item_unref (old_entry);
@@ -778,7 +785,7 @@ GSList *
 shell_app_system_initial_search (ShellAppSystem  *self,
                                  GSList          *terms)
 {
-  return search_tree (self, terms, self->priv->id_to_app);
+  return search_tree (self, terms, self->priv->visible_id_to_app);
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]