r1749 - trunk/src/target/OM-2007/openmoko-libs/libmokoui

zecke at sita.openmoko.org zecke at sita.openmoko.org
Sat Apr 14 01:28:01 CEST 2007


Author: zecke
Date: 2007-04-14 01:28:00 +0200 (Sat, 14 Apr 2007)
New Revision: 1749

Modified:
   trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.c
   trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.h
Log:
2007-04-14 Holger Freyther <zecke at selfish.org>
	* moko-tool-box.h: Introduce new method moko_tool_box_make_search_visible

	* moko-tool-box.c: (_button_release) use moko_tool_box_make_search_visible
	and use GTK_WIDGET_DRAWABLE to decide if the GtkEntry is currently visible
	to the user.
	(moko_tool_box_search_visible) show/hide the search bar on demand


Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.c	2007-04-13 23:03:31 UTC (rev 1748)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.c	2007-04-13 23:28:00 UTC (rev 1749)
@@ -56,17 +56,8 @@
 
 static void _button_release(GtkWidget* w, MokoToolBox* self)
 {
-    MokoToolBoxPriv* priv = MOKO_TOOL_BOX_GET_PRIVATE(self);
-    static int current_page = 1;
-    gtk_notebook_set_current_page( GTK_NOTEBOOK(self), current_page );
-    moko_debug( "moko_tool_box_button_release: current_page is now: %d", current_page );
-
-    if( current_page == 1 )
-        gtk_widget_grab_focus (GTK_WIDGET (priv->entry));
-
-    current_page = 1 - current_page;
-    g_signal_emit( G_OBJECT(self), current_page ? moko_tool_box_signals[SEARCHBOX_INVISIBLE] : moko_tool_box_signals[SEARCHBOX_VISIBLE], 0, NULL );
-
+    MokoToolBoxPriv *priv = MOKO_TOOL_BOX_GET_PRIVATE(self);
+    moko_tool_box_make_search_visible (self, !GTK_WIDGET_DRAWABLE(priv->entry) );
 }
 
 static gboolean _entry_focus_in(GtkWidget *widget, GdkEventFocus *event, MokoToolBox* self)
@@ -181,7 +172,20 @@
 }
 
 /* add new methods here */
+void moko_tool_box_make_search_visible(MokoToolBox *self, gboolean visible)
+{
+    MokoToolBoxPriv *priv = MOKO_TOOL_BOX_GET_PRIVATE(self);
+    g_return_if_fail (priv->entry != NULL);
 
+    gtk_notebook_set_current_page( GTK_NOTEBOOK(self), visible );
+    moko_debug( "%s: current_page is now: %d", __FUNCTION__, visible );
+
+    if( visible )
+        gtk_widget_grab_focus (GTK_WIDGET (priv->entry));
+
+    g_signal_emit( G_OBJECT(self), visible ? moko_tool_box_signals[SEARCHBOX_VISIBLE] : moko_tool_box_signals[SEARCHBOX_INVISIBLE], 0, NULL );
+}
+
 void moko_tool_box_add_search_button(MokoToolBox* self)
 {
 #if 0

Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.h
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.h	2007-04-13 23:03:31 UTC (rev 1748)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-tool-box.h	2007-04-13 23:28:00 UTC (rev 1749)
@@ -57,7 +57,9 @@
 GtkWidget*     moko_tool_box_new_with_search();
 void           moko_tool_box_clear(MokoToolBox* self);
 
-GtkWidget* moko_tool_box_get_button_box( MokoToolBox* self );
+void moko_tool_box_make_search_visible(MokoToolBox *self, gboolean visible);
+
+GtkWidget* moko_tool_box_get_button_box(MokoToolBox* self );
 GtkWidget* moko_tool_box_get_entry(MokoToolBox* self);
 GtkWidget* moko_tool_box_add_action_button(MokoToolBox* self);
 





More information about the commitlog mailing list