Blame SOURCES/app-chooser-fixes.patch

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