r6862 - in bigboard/trunk: . applet bigboard



Author: hp
Date: 2007-11-01 16:52:56 -0500 (Thu, 01 Nov 2007)
New Revision: 6862

Modified:
   bigboard/trunk/applet/bigboard-button.c
   bigboard/trunk/applet/hippo-dbus-helper-rename.h
   bigboard/trunk/applet/hippo-dbus-helper.c
   bigboard/trunk/applet/hippo-dbus-helper.h
   bigboard/trunk/applet/self.c
   bigboard/trunk/bigboard/libgimmie.py
   bigboard/trunk/main.py
Log:
- go back to showing picture on bigboard applet always; the "3 pixels wide" applet doesn't seem like a workable hack. Use pressed in/out to show state for now.
- clarify, comment, and clean up the "expanded" / "popped out" / "visible" API in bigboard/main.py
- the applet has nothing to do with "minimized mode/autohide/expanded" so remove that from the applet
- pass X timestamp from applet to bigboard when activating bigboard, which may fix some focus problems, depending



Modified: bigboard/trunk/applet/bigboard-button.c
===================================================================
--- bigboard/trunk/applet/bigboard-button.c	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/applet/bigboard-button.c	2007-11-01 21:52:56 UTC (rev 6862)
@@ -190,15 +190,15 @@
                                          gboolean           showing_bigboard);
 static void theme_changed_callback      (GtkIconTheme      *icon_theme,
                                          ButtonData        *button_data);
-static void button_clicked_callback     (GtkWidget         *button,
+static void button_toggled_callback     (GtkWidget         *button,
                                          ButtonData        *button_data);
 static void user_photo_changed_callback (GdkPixbuf         *pixbuf,
                                          void              *data);
 
 static void
-handle_expanded_changed(DBusConnection *connection,
-                        DBusMessage    *message,
-                        void           *data)
+handle_popped_out_changed(DBusConnection *connection,
+                          DBusMessage    *message,
+                          void           *data)
 {
         dbus_bool_t is_expanded;
         ButtonData *button_data;
@@ -207,11 +207,11 @@
 
         if (!dbus_message_get_args(message, NULL, DBUS_TYPE_BOOLEAN, &is_expanded,
                                    DBUS_TYPE_INVALID)) {
-                g_warning ("Expanded signal from bigboard has wrong signature");
+                g_warning ("PoppedOutChanged signal from bigboard has wrong signature");
                 return;
         }
 
-        g_debug ("got bb expanded state: %d\n", is_expanded);
+        g_debug ("got bb PoppedOutChanged: %d\n", is_expanded);
         update_showing_bigboard (button_data, is_expanded);
 }
 
@@ -227,7 +227,7 @@
 
         /* request the expanded state */
         hippo_dbus_proxy_VOID__VOID (button_data->bb_proxy,
-                                     "EmitExpandedChanged");
+                                     "EmitPoppedOutChanged");
         g_debug ("got bb available\n");
 }
 
@@ -246,7 +246,7 @@
 }
 
 static const HippoDBusSignalTracker signal_handlers[] = {
-        { "org.gnome.BigBoard.Panel", "ExpandedChanged", handle_expanded_changed },
+        { "org.gnome.BigBoard.Panel", "PoppedOutChanged", handle_popped_out_changed },
         { NULL, NULL, NULL }
 };
 
@@ -341,12 +341,6 @@
 
         gtk_image_clear (GTK_IMAGE (button_data->image));
 
-        if (button_data->showing_bigboard) {
-                g_debug ("showing bb, not setting icon\n");
-                gtk_widget_set_size_request(button_data->image, 1, 1);
-                return;
-        }
-
         gtk_widget_style_get (button_data->button,
                               "focus-line-width", &focus_width,
                               "focus-padding", &focus_pad,
@@ -455,21 +449,23 @@
 };
 
 /* This updates things that should be consistent with the button's appearance,
- * and update_button_state updates the button appearance itself
+ * and update_button_state updates the button's active flag (whether it's toggled on).
  */
 static void
 update_button_display (ButtonData *button_data)
 {
-        if (!button_data->showing_bigboard)
+        update_icon (button_data);
+        
+        if (button_data->showing_bigboard)
+                wncklet_set_tooltip (button_data->button, _("Click here to hide the desktop sidebar."));
+        else
                 wncklet_set_tooltip (button_data->button, _("Click here to show the desktop sidebar."));
-        else
-                wncklet_set_tooltip (button_data->button, NULL);
 }
 
 static void
 update_button_state (ButtonData *button_data)
 {
-        update_icon (button_data);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_data->button), button_data->showing_bigboard);
         update_button_display (button_data);
 }
 
@@ -479,9 +475,10 @@
 {
         if ((showing_bigboard != FALSE) == button_data->showing_bigboard)
                 return;
-
+        
         button_data->showing_bigboard = showing_bigboard != FALSE;
-
+        g_debug("Set showing_bigboard=%d", button_data->showing_bigboard);
+        
         update_button_state (button_data);
 }
 
@@ -598,8 +595,6 @@
 
         screen = gtk_widget_get_screen (button_data->applet);
 
-        /* FIXME set initial button state according to whether board is showing */
-
         button_data->icon_theme = gtk_icon_theme_get_for_screen (screen);
         wncklet_connect_while_alive (button_data->icon_theme, "changed",
                                      G_CALLBACK (theme_changed_callback),
@@ -631,7 +626,7 @@
                 g_object_unref(button_data->user_photo);
         button_data->user_photo = pixbuf;
 
-        update_button_state (button_data);
+        update_button_display (button_data);
 }
 
 
@@ -655,7 +650,7 @@
         g_signal_connect (G_OBJECT (button_data->applet), "realize",
                           G_CALLBACK (bigboard_button_applet_realized), button_data);
 
-        button_data->button = gtk_button_new ();
+        button_data->button = gtk_toggle_button_new ();
 
         gtk_widget_set_name (button_data->button, "bigboard-button");
         gtk_rc_parse_string ("\n"
@@ -674,8 +669,8 @@
         g_signal_connect (G_OBJECT (button_data->button), "button_press_event",
                           G_CALLBACK (do_not_eat_button_press), NULL);
 
-        g_signal_connect (G_OBJECT (button_data->button), "clicked",
-                          G_CALLBACK (button_clicked_callback), button_data);
+        g_signal_connect (G_OBJECT (button_data->button), "toggled",
+                          G_CALLBACK (button_toggled_callback), button_data);
 
         gtk_container_set_border_width (GTK_CONTAINER (button_data->button), 0);
         gtk_container_add (GTK_CONTAINER (button_data->button), button_data->image);
@@ -886,11 +881,16 @@
 }
 
 static void
-button_clicked_callback (GtkWidget       *button,
+button_toggled_callback (GtkWidget       *button,
                          ButtonData      *button_data)
 {
         if (button_data->bb_proxy) {
-                hippo_dbus_proxy_VOID__VOID (button_data->bb_proxy, "TogglePopout");
+                if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) {
+                        hippo_dbus_proxy_VOID__UINT32 (button_data->bb_proxy, "Popout",
+                                                       gtk_get_current_event_time());
+                } else {
+                        hippo_dbus_proxy_VOID__VOID (button_data->bb_proxy, "Unpopout");
+                }
         }
 
         update_button_display (button_data);
@@ -965,7 +965,8 @@
                           log_handler, NULL);
 
         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
+        gtk_window_move(GTK_WINDOW(window), 300, 400);
+        
         bigboard_button_add_to_widget (window);
 
         g_signal_connect (G_OBJECT (window),

Modified: bigboard/trunk/applet/hippo-dbus-helper-rename.h
===================================================================
--- bigboard/trunk/applet/hippo-dbus-helper-rename.h	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/applet/hippo-dbus-helper-rename.h	2007-11-01 21:52:56 UTC (rev 6862)
@@ -37,6 +37,7 @@
 #define hippo_dbus_proxy_INT32__VOID bigboard_applet_dbus_proxy_INT32__VOID
 #define hippo_dbus_proxy_STRING__INT32 bigboard_applet_dbus_proxy_STRING__INT32
 #define hippo_dbus_proxy_VOID__VOID bigboard_applet_dbus_proxy_VOID__VOID
+#define hippo_dbus_proxy_VOID__UINT32 bigboard_applet_dbus_proxy_VOID__UINT32
 #define hippo_dbus_proxy_call_method_async bigboard_applet_dbus_proxy_call_method_async
 #define hippo_dbus_proxy_call_method_async_appender bigboard_applet_dbus_proxy_call_method_async_appender
 #define hippo_dbus_proxy_call_method_async_valist bigboard_applet_dbus_proxy_call_method_async_valist

Modified: bigboard/trunk/applet/hippo-dbus-helper.c
===================================================================
--- bigboard/trunk/applet/hippo-dbus-helper.c	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/applet/hippo-dbus-helper.c	2007-11-01 21:52:56 UTC (rev 6862)
@@ -991,7 +991,8 @@
             g_warning("no memory to append signal args");
         }
     }
-    
+
+    /* FIXME this is broken, signals only have in_args, not out_args */
     if (!dbus_message_has_signature(message, member->out_args)) {
         g_warning("Tried to emit signal %s %s with args %s but should have been %s",
                   interface, signal_name, dbus_message_get_signature(message), member->out_args);
@@ -1004,6 +1005,23 @@
     dbus_message_unref(message);
 }
 
+static void
+emit_signal_appender(DBusConnection          *connection,
+                            const char              *path,
+                            const char              *interface,
+                            const char              *signal_name,
+                            HippoDBusArgAppender     appender,
+                            void                    *appender_data,
+                            int                      first_arg_type,
+                            ...)
+{
+  va_list args;
+
+  va_start(args, first_arg_type);
+  emit_signal_valist_appender(connection, path, interface, signal_name, appender, appender_data, first_arg_type, args);
+  va_end(args);
+}
+
 void
 hippo_dbus_helper_emit_signal_valist(DBusConnection          *connection,
                                      const char              *path,
@@ -1024,10 +1042,8 @@
                                         HippoDBusArgAppender     appender,
                                         void                    *appender_data)
 {
-    va_list dummy_args;
-    
-    emit_signal_valist_appender(connection, path, interface, signal_name,
-                                appender, appender_data, DBUS_TYPE_INVALID, dummy_args);
+    emit_signal_appender(connection, path, interface, signal_name,
+                         appender, appender_data, DBUS_TYPE_INVALID);
 }
 
 void
@@ -1861,7 +1877,6 @@
     }
 }
 
-
 static DBusMessage*
 call_method_sync_valist_appender (HippoDBusProxy          *proxy,
                                   const char              *method,
@@ -1917,6 +1932,24 @@
     return NULL;
 }
 
+static DBusMessage*
+call_method_sync_appender (HippoDBusProxy          *proxy,
+                           const char              *method,
+                           DBusError               *error,
+                           HippoDBusArgAppender     appender,
+                           void                    *appender_data,
+                           int                      first_arg_type,
+                           ...)
+{
+    DBusMessage *result;
+    va_list args;
+
+    va_start(args, first_arg_type);
+    result = call_method_sync_valist_appender(proxy, method, error, appender, appender_data, first_arg_type, args);
+    va_end(args);
+    return result;
+}
+
 DBusMessage*
 hippo_dbus_proxy_call_method_sync_valist (HippoDBusProxy          *proxy,
                                           const char              *method,
@@ -1935,11 +1968,8 @@
                                              HippoDBusArgAppender   appender,
                                              void                  *appender_data)
 {
-    va_list dummy_valist;
-    
-    return call_method_sync_valist_appender(proxy, method, error,
-                                            appender, appender_data, DBUS_TYPE_INVALID,
-                                            dummy_valist);
+    return call_method_sync_appender(proxy, method, error,
+                                     appender, appender_data, DBUS_TYPE_INVALID);
 }
 
 DBusMessage*
@@ -2119,6 +2149,24 @@
     return;
 }
 
+static void
+call_method_async_appender(HippoDBusProxy          *proxy,
+                           const char              *method,
+                           HippoDBusReplyHandler    handler,
+                           void                    *data,
+                           DBusFreeFunction         free_data_func,
+                           HippoDBusArgAppender     appender,
+                           void                    *appender_data,
+                           int                      first_arg_type,
+                           ...)
+{
+  va_list args;
+
+  va_start(args, first_arg_type);
+  call_method_async_valist_appender(proxy, method, handler, data, free_data_func, appender, appender_data, first_arg_type, args);
+  va_end(args);
+}
+
 void
 hippo_dbus_proxy_call_method_async_valist(HippoDBusProxy          *proxy,
                                           const char              *method,
@@ -2141,10 +2189,8 @@
                                              HippoDBusArgAppender   appender,
                                              void                  *appender_data)
 {
-    va_list dummy_args;
-    
-    call_method_async_valist_appender(proxy, method, handler, data, free_data_func,
-                                      appender, appender_data, DBUS_TYPE_INVALID, dummy_args);
+    call_method_async_appender(proxy, method, handler, data, free_data_func,
+                               appender, appender_data, DBUS_TYPE_INVALID);
 }
 
 
@@ -2242,6 +2288,23 @@
 }
 
 dbus_bool_t
+hippo_dbus_proxy_VOID__UINT32 (HippoDBusProxy  *proxy,
+                               const char      *method,
+                               dbus_uint32_t    in1)
+{
+    DBusMessage *reply;
+    DBusError derror;
+    
+    dbus_error_init(&derror);    
+    reply = hippo_dbus_proxy_call_method_sync(proxy, method, &derror,
+                                              DBUS_TYPE_UINT32, &in1,
+                                              DBUS_TYPE_INVALID);
+    
+    return hippo_dbus_proxy_finish_method_call_freeing_reply(reply, method, &derror,
+                                                             DBUS_TYPE_INVALID);
+}
+
+dbus_bool_t
 hippo_dbus_proxy_INT32__VOID(HippoDBusProxy *proxy,
                              const char     *method,
                              dbus_int32_t   *out1_p)
@@ -2261,7 +2324,7 @@
 dbus_bool_t
 hippo_dbus_proxy_INT32__INT32(HippoDBusProxy *proxy,
                               const char     *method,
-                              dbus_int32_t    in1_p,
+                              dbus_int32_t    in1,
                               dbus_int32_t   *out1_p)
 {
     DBusMessage *reply;
@@ -2269,7 +2332,7 @@
 
     dbus_error_init(&derror);    
     reply = hippo_dbus_proxy_call_method_sync(proxy, method, &derror,
-                                              DBUS_TYPE_INT32, &in1_p,
+                                              DBUS_TYPE_INT32, &in1,
                                               DBUS_TYPE_INVALID);
     
     return hippo_dbus_proxy_finish_method_call_freeing_reply(reply, method, &derror,

Modified: bigboard/trunk/applet/hippo-dbus-helper.h
===================================================================
--- bigboard/trunk/applet/hippo-dbus-helper.h	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/applet/hippo-dbus-helper.h	2007-11-01 21:52:56 UTC (rev 6862)
@@ -85,7 +85,7 @@
     HippoDBusMemberType member_type;
     const char *name;
     const char *in_args;
-    const char *out_args;
+    const char *out_args; /* FIXME right now for signals we use out_args, should be in_args */
     /* for a signal the handler is NULL
      */
     HippoDBusHandler handler;
@@ -109,6 +109,8 @@
 
 struct HippoDBusSignalTracker
 {
+    /* FIXME there's no way to specify the object path */
+    /* FIXME specify the signature so it can be automatically checked */
     const char *interface;
     const char *signal;
     HippoDBusSignalHandler handler;
@@ -268,31 +270,34 @@
 
 dbus_bool_t hippo_dbus_proxy_VOID__VOID               (HippoDBusProxy  *proxy,
                                                        const char      *method);
+dbus_bool_t hippo_dbus_proxy_VOID__UINT32             (HippoDBusProxy  *proxy,
+                                                       const char      *method,
+                                                       dbus_uint32_t    in1);
 dbus_bool_t hippo_dbus_proxy_INT32__VOID              (HippoDBusProxy  *proxy,
                                                        const char      *method,
                                                        dbus_int32_t    *out1_p);
 dbus_bool_t hippo_dbus_proxy_INT32__INT32             (HippoDBusProxy  *proxy,
                                                        const char      *method,
-                                                       dbus_int32_t     in1_p,
+                                                       dbus_int32_t     in1,
                                                        dbus_int32_t    *out1_p);
 dbus_bool_t hippo_dbus_proxy_ARRAYINT32__INT32        (HippoDBusProxy  *proxy,
                                                        const char      *method,
-                                                       dbus_int32_t     in1_p,
+                                                       dbus_int32_t     in1,
                                                        dbus_int32_t   **out1_p,
-                                                       dbus_int32_t    *out1_len);
+                                                       dbus_int32_t    *out1_len_p);
 dbus_bool_t hippo_dbus_proxy_ARRAYINT32__VOID         (HippoDBusProxy  *proxy,
                                                        const char      *method,
                                                        dbus_int32_t   **out1_p,
-                                                       dbus_int32_t    *out1_len);
+                                                       dbus_int32_t    *out1_len_p);
 dbus_bool_t hippo_dbus_proxy_ARRAYINT32__INT32_STRING (HippoDBusProxy  *proxy,
                                                        const char      *method,
-                                                       dbus_int32_t     in1_p,
-                                                       const char      *in2_p,
+                                                       dbus_int32_t     in1,
+                                                       const char      *in2,
                                                        dbus_int32_t   **out1_p,
-                                                       dbus_int32_t    *out1_len);
+                                                       dbus_int32_t    *out1_len_p);
 dbus_bool_t hippo_dbus_proxy_STRING__INT32            (HippoDBusProxy  *proxy,
                                                        const char      *method,
-                                                       dbus_int32_t     in1_p,
+                                                       dbus_int32_t     in1,
                                                        char           **out1_p);
 
 

Modified: bigboard/trunk/applet/self.c
===================================================================
--- bigboard/trunk/applet/self.c	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/applet/self.c	2007-11-01 21:52:56 UTC (rev 6862)
@@ -138,8 +138,8 @@
     int usage_a;
     int usage_b;
 
-    usage_a = app_get_usage_count(a);
-    usage_b = app_get_usage_count(b);
+    usage_a = app_get_usage_count((void*)a);
+    usage_b = app_get_usage_count((void*)b);
 
     if (usage_a < usage_b)
         return 1;

Modified: bigboard/trunk/bigboard/libgimmie.py
===================================================================
--- bigboard/trunk/bigboard/libgimmie.py	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/bigboard/libgimmie.py	2007-11-01 21:52:56 UTC (rev 6862)
@@ -61,6 +61,8 @@
         and/or desktop icons will not overlap this window\'s allocated area.
         See http://standards.freedesktop.org/wm-spec/latest for details.
         '''
+        _logger.debug("Setting WM strut, remove=%d, window=%s" % (remove, str(self.window)))
+        
         if self.window and remove:
             self.window.property_delete("_NET_WM_STRUT")
             return
@@ -69,7 +71,7 @@
         
         if self.edge_gravity != gtk.gdk.GRAVITY_WEST:
             raise "haven't implemented gravities other than WEST"
-        
+
         if self.window:
             # values are left, right, top, bottom
             propvals = [0, 0, 0, 0]

Modified: bigboard/trunk/main.py
===================================================================
--- bigboard/trunk/main.py	2007-11-01 21:46:56 UTC (rev 6861)
+++ bigboard/trunk/main.py	2007-11-01 21:52:56 UTC (rev 6862)
@@ -384,7 +384,7 @@
         _logger.info("constructing")
                 
         self._dw = Sidebar(True, GCONF_PREFIX + 'visible')
-        self._shown = False
+        self.__popped_out = False
         self.__shell = None
         
         gconf_client = gconf.client_get_default()
@@ -445,8 +445,10 @@
         self.__self_stock.connect('info-loaded', lambda *args: self.__initial_appearance())
         self.__search_stock.connect('match-selected', self.__on_search_match_selected)
 
-        gconf_client.notify_add(GCONF_PREFIX + 'visible', self.__sync_visible)
-        self.__sync_visible()
+        ## visible=True means we never hide, visible=False means we "autohide" and popout
+        ## when the hotkey or applet is used
+        gconf_client.notify_add(GCONF_PREFIX + 'visible', self.__sync_visible_mode)
+        self.__sync_visible_mode()
         
     @log_except(_logger)
     def __initial_appearance(self):
@@ -476,7 +478,7 @@
     @log_except()
     def __on_focus(self):
         _logger.debug("got focus keypress")
-        self.toggle_popout()
+        self.toggle_popout(gtk.get_current_event_time())
 
     def __append_metainfo(self, metainfo, **kwargs):
         try:
@@ -526,40 +528,9 @@
     
     @log_except()
     def __on_search_match_selected(self, search):
-        self.action_taken()
+        self.action_taken()        
         
-    def __handle_deactivation(self, immediate=False):
-        vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
-        if not vis and self.__autohide_id == 0:
-            _logger.debug("enqueued autohide timeout")            
-            self.__autohide_id = gobject.timeout_add(immediate and 1 or 1500, self.__idle_do_hide)        
-            
     @log_except()
-    def __idle_do_hide(self):
-        _logger.debug("in idle hide")
-        self.__autohide_id = 0
-        vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
-        if vis:
-            return  
-        _logger.debug("setting shown=False")      
-        self._shown = False
-        self._dw.hide()
-        
-    @log_except()
-    def __sync_visible(self, *args):
-        vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
-        self.__queue_strut()
-        if vis:
-            self._dw.show()
-            self.ExpandedChanged(True)
-        else:
-            self._dw.hide()
-            if not gconf.client_get_default().get_bool(GCONF_PREFIX + 'first_time_minimize_seen'):
-                dialog = FirstTimeMinimizeDialog(True)
-                dialog.show_all()        
-            self.ExpandedChanged(False)
-        
-    @log_except()
     def _toggle_size(self):
         _logger.debug("toggling size")
         expanded = gconf.client_get_default().get_bool(GCONF_PREFIX + 'expand')
@@ -578,74 +549,121 @@
 
     @log_except()
     def __idle_do_strut(self):
-        _logger.debug("idle strut set")
+        _logger.debug("setting strut in idle")
         self._dw.do_set_wm_strut()
-        _logger.debug("idle strut set complete")
         return False
 
     def __queue_strut(self):
         # TODO - this is kind of gross; we need the strut change to happen after
         # the resize, but that appears to be an ultra-low priority internally
         # so we can't easily queue something directly after.
-        gobject.timeout_add(250, self.__idle_do_strut)
+        call_timeout_once(250, self.__idle_do_strut)
         
-    def show(self):
-        self.__sync_visible()
-        
     def get_desktop_path(self):
-        return DESKTOP_PATH
+        return DESKTOP_PATH        
 
+    ## There are two aspects to the sidebar state:
+    ## the "visible" gconf key is like the old gnome-panel "autohide"
+    ## preference. i.e. if !visible, the sidebar is normally collapsed
+    ## and you have to use a hotkey or the applet to pop it out.
+    ## So the second piece of state is self.__popped_out, which is whether
+    ## the sidebar is currently popped out. If visible=True, the sidebar
+    ## is always popped out, i.e. self.__popped_out should be True always.
+
+    ## Shows the sidebar
     def __handle_activation(self):
+        if not self.__popped_out:
+            _logger.debug("popping out")
+            self._dw.show()
+            self.__queue_strut()
+            self.__popped_out = True
+            self.EmitPoppedOutChanged()
+
+    ## Hides the sidebar, possibly after a delay, only if visible mode is False
+    def __handle_deactivation(self, immediate=False):
         vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
-        if not vis:
-            _logger.debug("showing all")
-            self._dw.show_all()
-            self._shown = True
-        if self.__get_size() == Stock.SIZE_BEAR:
-            self._toggle_size()        
+        if self.__popped_out and not vis and self.__autohide_id == 0:
+            _logger.debug("enqueued autohide timeout")            
+            self.__autohide_id = gobject.timeout_add(immediate and 1 or 1500, self.__idle_do_hide)        
+            
+    @log_except()
+    def __idle_do_hide(self):
+        _logger.debug("in idle hide")
+        self.__autohide_id = 0
+        vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
+        if vis or not self.__popped_out:
+            return  
 
-    def toggle_popout(self):
-        if not self._shown:
-            _logger.debug("handling popout activation")
+        _logger.debug("unpopping out")
+        self.__popped_out = False
+        self._dw.hide()
+        self.__queue_strut()
+        self.EmitPoppedOutChanged()
+
+    ## syncs our current state to a change in the gconf setting for visible mode
+    @log_except()
+    def __sync_visible_mode(self, *args):
+        vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
+        if vis and not self.__popped_out:
             self.__handle_activation()
-            self._dw.present_with_time(gtk.get_current_event_time())
-            self.__search_stock.focus()
-        else:
-            _logger.debug("handling popout deactivation")            
-            self.__handle_deactivation(True)
+        elif not vis:
+            self.__handle_deactivation()
+            if not gconf.client_get_default().get_bool(GCONF_PREFIX + 'first_time_minimize_seen'):
+                dialog = FirstTimeMinimizeDialog(True)
+                dialog.show_all()
 
-    def __do_unexpand(self):
-        gconf.client_get_default().set_bool(GCONF_PREFIX + 'visible', False)
+        ## this is needed because the Sidebar widget knows about the 'visible' gconf key,
+        ## and if we're not in visible mode (in autohide mode), it never sets the strut.
+        ## However the Sidebar widget does not itself listen for changes on the gconf key.
+        self.__queue_strut()
+        
+    ## Pops out the sidebar, and focuses it (if the sidebar is in visible mode, only has to focus)
+    def __do_popout(self, xtimestamp):
+        if not self.__popped_out:
+            _logger.debug("popout requested")
+            self.__handle_activation()
 
-    @dbus.service.method(BUS_IFACE_PANEL)
-    def Unexpand(self):
-        _logger.debug("got unexpand method call")
-        return self.__do_unexpand()
+        ## focus even if we were already shown
+        self._dw.present_with_time(xtimestamp)
+        self.__search_stock.focus()
 
-    def __do_expand(self):
-        gconf.client_get_default().set_bool(GCONF_PREFIX + 'visible', True)
+    ## Hides the sidebar, only if not in visible mode
+    def __do_unpopout(self):
+        if self.__popped_out:
+            _logger.debug("unpopout requested")            
+            self.__handle_deactivation(True)
 
-    def toggle_expand(self):
+    def toggle_popout(self, xtimestamp):
+        if self.__popped_out:
+            self.__do_unpopout()
+        else:
+            self.__do_popout(xtimestamp)
+
+    def __set_visible_mode(self, setting):
         vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
-        vis = not vis
-        gconf.client_get_default().set_bool(GCONF_PREFIX + 'visible', vis)
+        if setting != vis:
+            gconf.client_get_default().set_bool(GCONF_PREFIX + 'visible', setting)
 
     @dbus.service.method(BUS_IFACE_PANEL)
-    def Expand(self):
-        _logger.debug("got expand method call")
-        return self.__do_expand()
-
-    @dbus.service.method(BUS_IFACE_PANEL)
-    def EmitExpandedChanged(self):
-        _logger.debug("got emitExpandedChanged method call")
-        self.ExpandedChanged(gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible'))
+    def EmitPoppedOutChanged(self):
+        _logger.debug("got emitPoppedOutChanged method call")        
+        self.PoppedOutChanged(self.__popped_out)
         
     @dbus.service.method(BUS_IFACE_PANEL)
-    def TogglePopout(self):
-        _logger.debug("got toggle popout method call")
-        return self.toggle_popout()  
+    def Popout(self, xtimestamp):
+        _logger.debug("got popout method call")
+        return self.__do_popout(xtimestamp)
 
     @dbus.service.method(BUS_IFACE_PANEL)
+    def Unpopout(self):
+        _logger.debug("got unpopout method call")
+
+        ## force us into autohide mode, since otherwise unpopout would not make sense
+        self.__set_visible_mode(False)
+
+        return self.__do_unpopout()
+
+    @dbus.service.method(BUS_IFACE_PANEL)
     def Reboot(self):
         import subprocess
         args = [REEXEC_CMD]
@@ -702,7 +720,7 @@
 
     @dbus.service.signal(BUS_IFACE_PANEL,
                          signature='b')
-    def ExpandedChanged(self, is_expanded):
+    def PoppedOutChanged(self, is_popped_out):
         pass
 
 # TODO: figure out an algorithm for removing pixbufs from the cache
@@ -838,8 +856,6 @@
     
     _logger.debug("Creating panel")
     panel = BigBoardPanel(bus_name)
-    
-    panel.show()
 
     bigboard.google.init()
     #bigboard.presence.get_presence() # for side effect of creating Presence object



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]