All pastes #438449 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-13 16:57 UTC
rendered paste body
Index: libmokoui/moko-tool-box.c
===================================================================
--- libmokoui/moko-tool-box.c   (Revision 1737)
+++ libmokoui/moko-tool-box.c   (Arbeitskopie)
@@ -40,6 +40,7 @@
     GtkWidget* buttonbox;      /* GtkHBox   */
     GtkWidget* searchbar_page; /* MokoFixed */
     GtkWidget* entry;          /* GtkEntry  */
+    gboolean   searchbar_is_visible;
 } MokoToolBoxPriv;
 
 /* add your signals here */
@@ -56,17 +57,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, !priv->searchbar_is_visible);
 }
 
 static gboolean _entry_focus_in(GtkWidget *widget, GdkEventFocus *event, MokoToolBox* self)
@@ -113,6 +105,9 @@
     moko_debug( "moko_tool_box_init" );
     gtk_notebook_set_show_border( GTK_NOTEBOOK(self), FALSE );
     gtk_notebook_set_show_tabs( GTK_NOTEBOOK(self), FALSE );
+
+    MokoToolBoxPriv* priv = MOKO_TOOL_BOX_GET_PRIVATE(self);
+    priv->searchbar_is_visible = FALSE;
 }
 
 //FIXME 1st: rewrite moko_tool_box_new / moko_tool_box_new_with_search for using g_object properties
@@ -181,7 +176,21 @@
 }
 
 /* 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));
+
+    priv->searchbar_is_visible = visible;
+    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
Index: libmokoui/moko-tool-box.h
===================================================================
--- libmokoui/moko-tool-box.h   (Revision 1737)
+++ libmokoui/moko-tool-box.h   (Arbeitskopie)
@@ -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);