From 91c5d53355be8a4b303ad8fa9052de2b8823218f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Rodr=C3=ADguez?= <ruben@trisquel.info>
Date: Wed, 21 May 2014 02:55:11 +0200
Subject: [PATCH] Updated indicator-applet

---
 .../indicator-applet-scroll-arrows.patch      | 40 +++++------
 helpers/make-indicator-applet                 | 67 +++++++++++++++++++
 2 files changed, 84 insertions(+), 23 deletions(-)
 create mode 100644 helpers/make-indicator-applet

diff --git a/helpers/DATA/indicator-applet/indicator-applet-scroll-arrows.patch b/helpers/DATA/indicator-applet/indicator-applet-scroll-arrows.patch
index a6fb9ce5..122e9221 100644
--- a/helpers/DATA/indicator-applet/indicator-applet-scroll-arrows.patch
+++ b/helpers/DATA/indicator-applet/indicator-applet-scroll-arrows.patch
@@ -1,42 +1,36 @@
 # Fixes https://bugs.launchpad.net/indicator-applet/+bug/965953
-
-diff --git indicator-applet/src/applet-main.c indicator-applet/src/applet-main.c
---- indicator-applet/src/applet-main.c
-+++ indicator-applet/src/applet-main.c
-@@ -362,6 +362,24 @@ accessible_desc_update (IndicatorObject 
+--- indicator-applet-12.10.2+14.04.20140403/src/applet-main.c	2014-04-03 01:10:57.000000000 +0000
++++ indicator-applet-12.10.2+14.04.20140403.mod/src/applet-main.c	2014-05-20 21:34:34.856698376 +0000
+@@ -364,6 +364,24 @@
    return;
  }
  
-+static gboolean
++static void
 +do_menu_reposition(gpointer menu)
 +{
-+  gtk_widget_set_size_request(menu, -1, -1);
++  gtk_widget_set_size_request(menu, 0,0);
++  while (gtk_events_pending ())
++    gtk_main_iteration ();
 +  gtk_menu_reposition(menu);
-+  g_timeout_add(20, (GSourceFunc) gtk_menu_reposition, (gpointer) menu);
-+  g_timeout_add(20, (GSourceFunc) gtk_menu_reposition, (gpointer) menu);
-+  return 0;
++  while (gtk_events_pending ())
++    gtk_main_iteration ();
 +}
 +
 +static void
 +on_menuitem_show (GtkMenuItem *menuitem, gpointer menu)
-+{ 
-+  gtk_widget_set_size_request(menu, -1, 500);
-+  gtk_menu_reposition(menu);
++{
++  gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL,NULL);
 +  g_idle_add((GSourceFunc) do_menu_reposition, (gpointer) menu);
 +}
 +
- static void
- entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+ static GtkWidget*
+ create_menuitem (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
  {
-@@ -435,6 +450,11 @@ entry_added (IndicatorObject * io, Indic
- 
-   if (entry->menu != NULL) {
+@@ -415,6 +433,7 @@
      gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
-+    g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(on_menuitem_show), entry->menu);
-+    gtk_menu_set_reserve_toggle_size(entry->menu, TRUE);
-+    gtk_widget_set_size_request(entry->menu, -1, -1);
-+    gtk_widget_set_size_request(entry->menu, -1, 500);
-+    gtk_menu_reposition(entry->menu);
    }
  
++  g_signal_connect(G_OBJECT(entry->menu), "show", G_CALLBACK(on_menuitem_show), entry->menu); 
    place_in_menu(menubar, menuitem, io, entry);
+ 
+   return menuitem;
diff --git a/helpers/make-indicator-applet b/helpers/make-indicator-applet
new file mode 100644
index 00000000..65d19820
--- /dev/null
+++ b/helpers/make-indicator-applet
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+#    Copyright (C) 2008-2010  Rubén Rodríguez <ruben@trisquel.info>
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+
+VERSION=2
+
+. ./config
+
+# Fixes https://bugs.launchpad.net/indicator-applet/+bug/965953
+
+cat << EOF | patch -p1
+--- indicator-applet-12.10.2+14.04.20140403/src/applet-main.c	2014-04-03 01:10:57.000000000 +0000
++++ indicator-applet-12.10.2+14.04.20140403.mod/src/applet-main.c	2014-05-20 21:34:34.856698376 +0000
+@@ -364,6 +364,24 @@
+   return;
+ }
+ 
++static void
++do_menu_reposition(gpointer menu)
++{
++  gtk_widget_set_size_request(menu, 0,0);
++  while (gtk_events_pending ())
++    gtk_main_iteration ();
++  gtk_menu_reposition(menu);
++  while (gtk_events_pending ())
++    gtk_main_iteration ();
++}
++
++static void
++on_menuitem_show (GtkMenuItem *menuitem, gpointer menu)
++{
++  gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL,NULL);
++  g_idle_add((GSourceFunc) do_menu_reposition, (gpointer) menu);
++}
++
+ static GtkWidget*
+ create_menuitem (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+ {
+@@ -415,6 +433,7 @@
+     gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
+   }
+ 
++  g_signal_connect(G_OBJECT(entry->menu), "show", G_CALLBACK(on_menuitem_show), entry->menu); 
+   place_in_menu(menubar, menuitem, io, entry);
+ 
+   return menuitem;
+EOF
+
+changelog "Fixes LP:965953"
+
+compile
+
-- 
GitLab