r191 - in trunk/src/target/OM-2007: applications/openmoko-chordmaster libraries/mokoui

mickey at gta01.hmw-consulting.de mickey at gta01.hmw-consulting.de
Sun Nov 5 00:14:51 CET 2006


Author: mickey
Date: 2006-11-04 23:14:50 +0000 (Sat, 04 Nov 2006)
New Revision: 191

Modified:
   trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c
   trunk/src/target/OM-2007/libraries/mokoui/moko-menubox.c
Log:
mokoui/menubox: make moko_menu_box_set_active_filter actually work


Modified: trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c	2006-11-04 21:49:15 UTC (rev 190)
+++ trunk/src/target/OM-2007/applications/openmoko-chordmaster/main.c	2006-11-04 23:14:50 UTC (rev 191)
@@ -73,13 +73,15 @@
 
     /* filter menu */
     GtkMenu* filtmenu = GTK_MENU(gtk_menu_new());
-    gtk_menu_shell_append( filtmenu, gtk_menu_item_new_with_label( "All" ) );
     for (GSList* c = chordsdb_get_categories( d->chordsdb ); c; c = g_slist_next(c) )
     {
         gchar* category = (gchar*) c->data;
         g_debug( "adding category '%s'", category );
         gtk_menu_shell_append( filtmenu, gtk_menu_item_new_with_label( category ) );
     }
+    gtk_menu_shell_append( filtmenu, gtk_separator_menu_item_new() );
+    gtk_menu_shell_append( filtmenu, gtk_menu_item_new_with_label( "All" ) );
+
     moko_paned_window_set_filter_menu( d->window, filtmenu );
     MokoMenuBox* menubox = moko_paned_window_get_menubox( d->window );
     g_signal_connect( G_OBJECT(menubox), "filter_changed", G_CALLBACK(cb_filter_changed), d );

Modified: trunk/src/target/OM-2007/libraries/mokoui/moko-menubox.c
===================================================================
--- trunk/src/target/OM-2007/libraries/mokoui/moko-menubox.c	2006-11-04 21:49:15 UTC (rev 190)
+++ trunk/src/target/OM-2007/libraries/mokoui/moko-menubox.c	2006-11-04 23:14:50 UTC (rev 191)
@@ -213,20 +213,30 @@
 
     MokoMenuBoxPriv* priv = MOKO_MENU_BOX_GET_PRIVATE(self);
 
+    guint index = 0;
     GList* child = gtk_container_get_children( GTK_CONTAINER(priv->filtermenu) );
-    while (child && GTK_IS_MENU_ITEM(child->data))
+    while (child && GTK_IS_MENU_ITEM(child->data) )
     {
         GtkWidget *label = GTK_BIN(child->data)->child;
+        if ( !label )
+        {
+            ++index;
+            child = g_list_next(child);
+            continue;
+        }
         g_assert( GTK_IS_LABEL(label) );
         gchar* ltext;
         gtk_label_get( GTK_LABEL(label), &ltext );
+        g_debug( "moko_menu_box_set_active_filter: comparing '%s' with '%s'", ltext, text );
         if ( strcmp( ltext, text ) == 0 )
         {
             g_debug( "moko_menu_box_set_active_filter: match found" );
-            gtk_menu_item_activate( child->data );
+            //FIXME this is a bit hackish or is it?
+            gtk_menu_set_active( GTK_MENU(priv->filtermenu), index );
             cb_filter_menu_update( priv->filtermenu, self ); //need to sync. manually, since we it didn't go through popupmenu
             break;
         }
+        ++index;
         child = g_list_next(child);
     }
     if (!child)





More information about the commitlog mailing list