fepitre / rpms / gtk3

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