Blame SOURCES/app-chooser-fixes.patch

e340b5
From 775c174c07120760820d68e44402b9da547a0263 Mon Sep 17 00:00:00 2001
e340b5
From: Ray Strode <rstrode@redhat.com>
e340b5
Date: Wed, 23 Sep 2015 09:29:11 -0400
e340b5
Subject: [PATCH] GtkAppChooserButton: Hide compat desktop entries
e340b5
e340b5
RHEL maintains some NoDisplay compat desktop entries to keep old user
e340b5
mime associations working in the 7.1 to 7.2 rebase.
e340b5
e340b5
These NoDisplay desktop files aren't meant to show up in the UI but do
e340b5
in the details panel of control-center (since GtkAppChooserButton
e340b5
specifically wants to show NoDisplay desktop files, see bug 702681)
e340b5
e340b5
This commit checks a downstream specific key, X-RHEL-AliasOf, that is
e340b5
used to mark desktop files that are compat entries.  An example of the
e340b5
use would be in totem.desktop:
e340b5
e340b5
X-RHEL-AliasOf=org.gnome.Totem
e340b5
e340b5
https://bugzilla.redhat.com/show_bug.cgi?id=1259292
e340b5
---
e340b5
 gtk/gtkappchooserbutton.c | 6 +++++-
e340b5
 1 file changed, 5 insertions(+), 1 deletion(-)
e340b5
e340b5
diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c
e340b5
index c0af584..78df7f1 100644
e340b5
--- a/gtk/gtkappchooserbutton.c
e340b5
+++ b/gtk/gtkappchooserbutton.c
e340b5
@@ -33,60 +33,61 @@
e340b5
  *
e340b5
  * The list of applications shown in a #GtkAppChooserButton includes
e340b5
  * the recommended applications for the given content type. When
e340b5
  * #GtkAppChooserButton:show-default-item is set, the default application
e340b5
  * is also included. To let the user chooser other applications,
e340b5
  * you can set the #GtkAppChooserButton:show-dialog-item property,
e340b5
  * which allows to open a full #GtkAppChooserDialog.
e340b5
  *
e340b5
  * It is possible to add custom items to the list, using
e340b5
  * gtk_app_chooser_button_append_custom_item(). These items cause
e340b5
  * the #GtkAppChooserButton::custom-item-activated signal to be
e340b5
  * emitted when they are selected.
e340b5
  *
e340b5
  * To track changes in the selected application, use the
e340b5
  * #GtkComboBox::changed signal.
e340b5
  */
e340b5
 #include "config.h"
e340b5
 
e340b5
 #include "gtkappchooserbutton.h"
e340b5
 
e340b5
 #include "gtkappchooser.h"
e340b5
 #include "gtkappchooserdialog.h"
e340b5
 #include "gtkappchooserprivate.h"
e340b5
 #include "gtkcelllayout.h"
e340b5
 #include "gtkcellrendererpixbuf.h"
e340b5
 #include "gtkcellrenderertext.h"
e340b5
 #include "gtkcombobox.h"
e340b5
 #include "gtkdialog.h"
e340b5
 #include "gtkintl.h"
e340b5
 #include "gtkmarshalers.h"
e340b5
+#include "gio/gdesktopappinfo.h"
e340b5
 
e340b5
 enum {
e340b5
   PROP_SHOW_DIALOG_ITEM = 1,
e340b5
   PROP_SHOW_DEFAULT_ITEM,
e340b5
   PROP_HEADING,
e340b5
   NUM_PROPERTIES,
e340b5
 
e340b5
   PROP_CONTENT_TYPE = NUM_PROPERTIES
e340b5
 };
e340b5
 
e340b5
 enum {
e340b5
   SIGNAL_CUSTOM_ITEM_ACTIVATED,
e340b5
   NUM_SIGNALS
e340b5
 };
e340b5
 
e340b5
 enum {
e340b5
   COLUMN_APP_INFO,
e340b5
   COLUMN_NAME,
e340b5
   COLUMN_LABEL,
e340b5
   COLUMN_ICON,
e340b5
   COLUMN_CUSTOM,
e340b5
   COLUMN_SEPARATOR,
e340b5
   NUM_COLUMNS,
e340b5
 };
e340b5
 
e340b5
 #define CUSTOM_ITEM_OTHER_APP "gtk-internal-item-other-app"
e340b5
 
e340b5
 static void app_chooser_iface_init  (GtkAppChooserIface *iface);
e340b5
 
e340b5
 static void real_insert_custom_item (GtkAppChooserButton *self,
e340b5
@@ -312,78 +313,81 @@ insert_one_application (GtkAppChooserButton *self,
e340b5
 
e340b5
   gtk_list_store_set (self->priv->store, iter,
e340b5
                       COLUMN_APP_INFO, app,
e340b5
                       COLUMN_LABEL, g_app_info_get_name (app),
e340b5
                       COLUMN_ICON, icon,
e340b5
                       COLUMN_CUSTOM, FALSE,
e340b5
                       -1);
e340b5
 
e340b5
   g_object_unref (icon);
e340b5
 }
e340b5
 
e340b5
 static void
e340b5
 gtk_app_chooser_button_populate (GtkAppChooserButton *self)
e340b5
 {
e340b5
   GList *recommended_apps = NULL, *l;
e340b5
   GAppInfo *app, *default_app = NULL;
e340b5
   GtkTreeIter iter, iter2;
e340b5
   gboolean cycled_recommended;
e340b5
 
e340b5
 #ifndef G_OS_WIN32
e340b5
   if (self->priv->content_type)
e340b5
     recommended_apps = g_app_info_get_recommended_for_type (self->priv->content_type);
e340b5
 #endif
e340b5
   cycled_recommended = FALSE;
e340b5
 
e340b5
   if (self->priv->show_default_item)
e340b5
     {
e340b5
       if (self->priv->content_type)
e340b5
         default_app = g_app_info_get_default_for_type (self->priv->content_type, FALSE);
e340b5
 
e340b5
-      if (default_app != NULL)
e340b5
+      if (default_app != NULL && (!G_IS_DESKTOP_APP_INFO (default_app) || !g_desktop_app_info_has_key (G_DESKTOP_APP_INFO (default_app), "X-RHEL-AliasOf")))
e340b5
         {
e340b5
           get_first_iter (self->priv->store, &iter);
e340b5
           cycled_recommended = TRUE;
e340b5
 
e340b5
           insert_one_application (self, default_app, &iter);
e340b5
 
e340b5
           g_object_unref (default_app);
e340b5
         }
e340b5
     }
e340b5
 
e340b5
   for (l = recommended_apps; l != NULL; l = l->next)
e340b5
     {
e340b5
       app = l->data;
e340b5
 
e340b5
       if (default_app != NULL && g_app_info_equal (app, default_app))
e340b5
         continue;
e340b5
 
e340b5
+      if (G_IS_DESKTOP_APP_INFO (app) && g_desktop_app_info_has_key (G_DESKTOP_APP_INFO (app), "X-RHEL-AliasOf"))
e340b5
+        continue;
e340b5
+
e340b5
       if (cycled_recommended)
e340b5
         {
e340b5
           gtk_list_store_insert_after (self->priv->store, &iter2, &iter);
e340b5
           iter = iter2;
e340b5
         }
e340b5
       else
e340b5
         {
e340b5
           get_first_iter (self->priv->store, &iter);
e340b5
           cycled_recommended = TRUE;
e340b5
         }
e340b5
 
e340b5
       insert_one_application (self, app, &iter);
e340b5
     }
e340b5
 
e340b5
   if (recommended_apps != NULL)
e340b5
     g_list_free_full (recommended_apps, g_object_unref);
e340b5
 
e340b5
   if (!cycled_recommended)
e340b5
     gtk_app_chooser_button_ensure_dialog_item (self, NULL);
e340b5
   else
e340b5
     gtk_app_chooser_button_ensure_dialog_item (self, &iter);
e340b5
 
e340b5
   gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);
e340b5
 }
e340b5
 
e340b5
 static void
e340b5
 gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
e340b5
 {
e340b5
   GtkCellRenderer *cell;
e340b5
   GtkCellArea *area;
e340b5
-- 
e340b5
2.5.0
e340b5