← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~bratsche/indicator-me/auto-select-entry into lp:indicator-me

 

Cody Russell has proposed merging lp:~bratsche/indicator-me/auto-select-entry into lp:indicator-me.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  #528302 The text field should receive focus automatically
  https://bugs.launchpad.net/bugs/528302

-- 
https://code.launchpad.net/~bratsche/indicator-me/auto-select-entry/+merge/21177
Your team ayatana-commits is subscribed to branch lp:indicator-me.
=== modified file 'src/indicator-me.c'
--- src/indicator-me.c	2010-03-11 17:10:36 +0000
+++ src/indicator-me.c	2010-03-11 20:26:16 +0000
@@ -7,17 +7,18 @@
 
   Authors:
   Ted Gould <ted@xxxxxxxxxxxxx>
+  Cody Russell <cody.russell@xxxxxxxxxxxxx>
 
-  This program is free software: you can redistribute it and/or modify it 
-  under the terms of the GNU General Public License version 3, as published 
+  This program is free software: you can redistribute it and/or modify it
+  under the terms of the GNU General Public License version 3, as published
   by the Free Software Foundation.
 
-  This program is distributed in the hope that it will be useful, but 
-  WITHOUT ANY WARRANTY; without even the implied warranties of 
-  MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranties of
+  MERCHANTABILITY, SATISFACTORY QUALITY, 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 
+  You should have received a copy of the GNU General Public License along
   with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
@@ -253,9 +254,32 @@
 }
 
 static gboolean
+menu_visibility_changed (GtkWidget          *widget,
+                         IdoEntryMenuItem   *menuitem)
+{
+  gtk_menu_shell_select_item (GTK_MENU_SHELL (widget), GTK_WIDGET (menuitem));
+
+  return FALSE;
+}
+
+static void
+entry_parent_changed (GtkWidget *widget,
+                      gpointer   user_data)
+{
+  GtkWidget *parent = gtk_widget_get_parent (widget);
+
+  if (parent && GTK_IS_MENU_SHELL (parent))
+    {
+      g_signal_connect (parent,
+                        "map", G_CALLBACK (menu_visibility_changed),
+                        widget);
+    }
+}
+
+static gboolean
 new_entry_item (DbusmenuMenuitem * newitem,
                 DbusmenuMenuitem * parent,
-                DbusmenuClient * client)
+                DbusmenuClient   * client)
 {
 	g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
 	g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
@@ -267,6 +291,10 @@
 		gtk_entry_set_text(entry, dbusmenu_menuitem_property_get(newitem, DBUSMENU_ENTRY_MENUITEM_PROP_TEXT));
 	gtk_entry_set_width_chars (entry, 23); /* set some nice aspect ratio for the menu */
 
+  g_signal_connect (ido,
+                    "notify::parent", G_CALLBACK (entry_parent_changed),
+                    NULL);
+
 	dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);
 	/* disconnect the activate signal that newitem_base connected with the wrong
 	   widget, ie menuitem, and re-connect it with the /entry/ instead */


Follow ups