Blob Blame History Raw
From c815f8ce277750699eeadd33f6ee0733589db3ce Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 23 Sep 2015 09:29:11 -0400
Subject: [PATCH 1/3] GtkAppChooserButton: Hide compat desktop entries

RHEL maintains some NoDisplay compat desktop entries to keep old user
mime associations working in the 7.1 to 7.2 rebase.

These NoDisplay desktop files aren't meant to show up in the UI but do
in the details panel of control-center (since GtkAppChooserButton
specifically wants to show NoDisplay desktop files, see bug 702681)

This commit checks a downstream specific key, X-RHEL-AliasOf, that is
used to mark desktop files that are compat entries.  An example of the
use would be in totem.desktop:

X-RHEL-AliasOf=org.gnome.Totem

https://bugzilla.redhat.com/show_bug.cgi?id=1259292
---
 gtk/gtkappchooserbutton.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c
index ea4bd90..d129786 100644
--- a/gtk/gtkappchooserbutton.c
+++ b/gtk/gtkappchooserbutton.c
@@ -34,60 +34,61 @@
  *
  * The list of applications shown in a #GtkAppChooserButton includes
  * the recommended applications for the given content type. When
  * #GtkAppChooserButton:show-default-item is set, the default application
  * is also included. To let the user chooser other applications,
  * you can set the #GtkAppChooserButton:show-dialog-item property,
  * which allows to open a full #GtkAppChooserDialog.
  *
  * It is possible to add custom items to the list, using
  * gtk_app_chooser_button_append_custom_item(). These items cause
  * the #GtkAppChooserButton::custom-item-activated signal to be
  * emitted when they are selected.
  *
  * To track changes in the selected application, use the
  * #GtkComboBox::changed signal.
  */
 #include "config.h"
 
 #include "gtkappchooserbutton.h"
 
 #include "gtkappchooser.h"
 #include "gtkappchooserdialog.h"
 #include "gtkappchooserprivate.h"
 #include "gtkcelllayout.h"
 #include "gtkcellrendererpixbuf.h"
 #include "gtkcellrenderertext.h"
 #include "gtkcombobox.h"
 #include "gtkdialog.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
+#include "gio/gdesktopappinfo.h"
 
 enum {
   PROP_CONTENT_TYPE = 1,
   PROP_SHOW_DIALOG_ITEM,
   PROP_SHOW_DEFAULT_ITEM,
   PROP_HEADING
 };
 
 enum {
   SIGNAL_CUSTOM_ITEM_ACTIVATED,
   NUM_SIGNALS
 };
 
 enum {
   COLUMN_APP_INFO,
   COLUMN_NAME,
   COLUMN_LABEL,
   COLUMN_ICON,
   COLUMN_CUSTOM,
   COLUMN_SEPARATOR,
   NUM_COLUMNS,
 };
 
 #define CUSTOM_ITEM_OTHER_APP "gtk-internal-item-other-app"
 
 static void app_chooser_iface_init (GtkAppChooserIface *iface);
 
 static void real_insert_custom_item (GtkAppChooserButton *self,
                                      const gchar *name,
                                      const gchar *label,
@@ -308,78 +309,81 @@ insert_one_application (GtkAppChooserButton *self,
 
   gtk_list_store_set (self->priv->store, iter,
                       COLUMN_APP_INFO, app,
                       COLUMN_LABEL, g_app_info_get_name (app),
                       COLUMN_ICON, icon,
                       COLUMN_CUSTOM, FALSE,
                       -1);
 
   g_object_unref (icon);
 }
 
 static void
 gtk_app_chooser_button_populate (GtkAppChooserButton *self)
 {
   GList *recommended_apps = NULL, *l;
   GAppInfo *app, *default_app = NULL;
   GtkTreeIter iter, iter2;
   gboolean cycled_recommended;
 
 #ifndef G_OS_WIN32
   if (self->priv->content_type)
     recommended_apps = g_app_info_get_recommended_for_type (self->priv->content_type);
 #endif
   cycled_recommended = FALSE;
 
   if (self->priv->show_default_item)
     {
       if (self->priv->content_type)
         default_app = g_app_info_get_default_for_type (self->priv->content_type, FALSE);
 
-      if (default_app != NULL)
+      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")))
         {
           get_first_iter (self->priv->store, &iter);
           cycled_recommended = TRUE;
 
           insert_one_application (self, default_app, &iter);
 
           g_object_unref (default_app);
         }
     }
 
   for (l = recommended_apps; l != NULL; l = l->next)
     {
       app = l->data;
 
       if (default_app != NULL && g_app_info_equal (app, default_app))
         continue;
 
+      if (G_IS_DESKTOP_APP_INFO (app) && g_desktop_app_info_has_key (G_DESKTOP_APP_INFO (app), "X-RHEL-AliasOf"))
+        continue;
+
       if (cycled_recommended)
         {
           gtk_list_store_insert_after (self->priv->store, &iter2, &iter);
           iter = iter2;
         }
       else
         {
           get_first_iter (self->priv->store, &iter);
           cycled_recommended = TRUE;
         }
 
       insert_one_application (self, app, &iter);
     }
 
   if (recommended_apps != NULL)
     g_list_free_full (recommended_apps, g_object_unref);
 
   if (!cycled_recommended)
     gtk_app_chooser_button_ensure_dialog_item (self, NULL);
   else
     gtk_app_chooser_button_ensure_dialog_item (self, &iter);
 
   gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);
 }
 
 static void
 gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
 {
   GtkCellRenderer *cell;
   GtkCellArea *area;
-- 
2.5.0


From 6fc9af4caea6e4dd86b2808b2fd01b8d7b624100 Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Tue, 22 Sep 2015 16:07:13 -0400
Subject: [PATCH 2/3] app chooser widget: protect against show_all

The visibility of the 'no apps' placeholder is managed by
the dialog, it should not be affected by gtk_widget_show_all.

https://bugzilla.gnome.org/show_bug.cgi?id=748080
---
 gtk/resources/ui/gtkappchooserwidget.ui | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gtk/resources/ui/gtkappchooserwidget.ui b/gtk/resources/ui/gtkappchooserwidget.ui
index 4b23628..3cc65f7 100644
--- a/gtk/resources/ui/gtkappchooserwidget.ui
+++ b/gtk/resources/ui/gtkappchooserwidget.ui
@@ -71,60 +71,61 @@
                         <attribute name="visible">6</attribute>
                         <attribute name="markup">7</attribute>
                       </attributes>
                     </child>
                     <child>
                       <object class="GtkCellRendererText" id="secondary_padding"/>
                     </child>
                     <child>
                       <object class="GtkCellRendererPixbuf" id="app_icon"/>
                       <attributes>
                         <attribute name="gicon">1</attribute>
                       </attributes>
                     </child>
                     <child>
                       <object class="GtkCellRendererText" id="app_name">
                         <property name="ellipsize">end</property>
                       </object>
                       <attributes>
                         <attribute name="markup">3</attribute>
                       </attributes>
                     </child>
                   </object>
                 </child>
               </object>
             </child>
           </object>
         </child>
         <child type="overlay">
           <object class="GtkBox" id="no_apps">
             <property name="orientation">vertical</property>
+            <property name="no-show-all">True</property>
             <property name="halign">center</property>
             <property name="valign">center</property>
             <child>
               <object class="GtkImage">
                 <property name="visible">True</property>
                 <property name="icon-name">gnome-software-symbolic</property>
                 <property name="pixel-size">48</property>
                 <property name="margin">12</property>
                 <style>
                   <class name="dim-label"/>
                 </style>
               </object>
             </child>
             <child>
               <object class="GtkLabel" id="no_apps_label">
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">No applications found.</property>
                 <property name="halign">center</property>
                 <property name="valign">center</property>
                 <attributes>
                   <attribute name="scale" value="1.2"/>
                 </attributes>
                 <style>
                   <class name="dim-label"/>
                 </style>
               </object>
             </child>
           </object>
         </child>
       </object>
-- 
2.5.0


From 0bd4176f0cd7e5febd6434e94a822dc9626f6d88 Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Tue, 22 Sep 2015 15:14:00 -0400
Subject: [PATCH 3/3] app chooser: Avoid duplicates

At the time we populate the model "initially" in constructed(),
it has already been filled and cleared a couple of times (we do
that every time one of the construct properties gets set). So
we can't assume that the model is empty, and have to clear it
first. Otherwise, we add duplicates to the list.

https://bugzilla.gnome.org/show_bug.cgi?id=748080
---
 gtk/gtkappchooserwidget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c
index 01f9a4b..5c90460 100644
--- a/gtk/gtkappchooserwidget.c
+++ b/gtk/gtkappchooserwidget.c
@@ -786,61 +786,61 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self)
                                                         FALSE,
                                                         FALSE,
                                                         all_applications, exclude_apps);
     }
 
   if (!apps_added)
     update_no_applications_label (self);
 
   gtk_widget_set_visible (self->priv->no_apps, !apps_added);
 
   gtk_app_chooser_widget_select_first (self);
 
   if (default_app != NULL)
     g_object_unref (default_app);
 
   g_list_free_full (all_applications, g_object_unref);
   g_list_free_full (recommended_apps, g_object_unref);
   g_list_free_full (fallback_apps, g_object_unref);
   g_list_free (exclude_apps);
 }
 
 static void
 gtk_app_chooser_widget_initialize_items (GtkAppChooserWidget *self)
 {
   /* initial padding */
   g_object_set (self->priv->padding_renderer,
                 "xpad", self->priv->show_all ? 0 : 6,
                 NULL);
 
   /* populate the widget */
-  gtk_app_chooser_widget_real_add_items (self);
+  gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
 }
 
 static void
 app_info_changed (GAppInfoMonitor     *monitor,
                   GtkAppChooserWidget *self)
 {
   gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
 }
 
 static void
 gtk_app_chooser_widget_set_property (GObject      *object,
                                      guint         property_id,
                                      const GValue *value,
                                      GParamSpec   *pspec)
 {
   GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (object);
 
   switch (property_id)
     {
     case PROP_CONTENT_TYPE:
       self->priv->content_type = g_value_dup_string (value);
       break;
     case PROP_SHOW_DEFAULT:
       gtk_app_chooser_widget_set_show_default (self, g_value_get_boolean (value));
       break;
     case PROP_SHOW_RECOMMENDED:
       gtk_app_chooser_widget_set_show_recommended (self, g_value_get_boolean (value));
       break;
     case PROP_SHOW_FALLBACK:
       gtk_app_chooser_widget_set_show_fallback (self, g_value_get_boolean (value));
-- 
2.5.0