r6866 - bigboard/trunk/applet



Author: hp
Date: 2007-11-02 14:31:27 -0500 (Fri, 02 Nov 2007)
New Revision: 6866

Modified:
   bigboard/trunk/applet/apps.c
   bigboard/trunk/applet/bigboard-button.c
   bigboard/trunk/applet/http.c
   bigboard/trunk/applet/launchers.c
   bigboard/trunk/applet/self.c
Log:
- fix application launching (was failing to split the desktop names by ';'), add error dialog if it fails
- remove the borders from app launcher buttons so images are not chopped off
- essentially pointless changes to scaling of the "self" icon
- don't keep around self_query in self.c, this isn't resolving all the issues here but Owen is working on ddm fixes to resolve them



Modified: bigboard/trunk/applet/apps.c
===================================================================
--- bigboard/trunk/applet/apps.c	2007-11-02 17:58:34 UTC (rev 6865)
+++ bigboard/trunk/applet/apps.c	2007-11-02 19:31:27 UTC (rev 6866)
@@ -75,8 +75,10 @@
 {
     App *app;
     GdkPixbuf *scaled;
-    
+
+#ifdef VERBOSE_HTTP
     g_debug("Got reply to http GET for app icon");
+#endif
     
     app = data;
     
@@ -112,7 +114,7 @@
         return;
 
     if (app->icon_url) {
-        g_debug("Sending http request for app icon %s", app->icon_url);
+        /* g_debug("Sending http request for app icon %s", app->icon_url); */
         http_get_pixbuf(connection,
                         app->icon_url,
                         on_got_icon,

Modified: bigboard/trunk/applet/bigboard-button.c
===================================================================
--- bigboard/trunk/applet/bigboard-button.c	2007-11-02 17:58:34 UTC (rev 6865)
+++ bigboard/trunk/applet/bigboard-button.c	2007-11-02 19:31:27 UTC (rev 6866)
@@ -175,6 +175,8 @@
 
         DBusConnection *connection;
         HippoDBusProxy *bb_proxy;
+
+        guint update_icon_idle;
 } ButtonData;
 
 static void display_help_dialog         (BonoboUIComponent *uic,
@@ -183,7 +185,7 @@
 static void display_about_dialog        (BonoboUIComponent *uic,
                                          ButtonData        *button_data,
                                          const gchar       *verbname);
-static void update_icon                 (ButtonData        *button_data);
+static void queue_update_icon           (ButtonData        *button_data);
 static void update_button_state         (ButtonData        *button_data);
 static void update_button_display       (ButtonData        *button_data);
 static void update_showing_bigboard     (ButtonData        *button_data,
@@ -194,6 +196,9 @@
                                          ButtonData        *button_data);
 static void user_photo_changed_callback (GdkPixbuf         *pixbuf,
                                          void              *data);
+static void button_size_allocated       (GtkWidget         *button,
+                                         GtkAllocation     *allocation,
+                                         ButtonData        *button_data);
 
 static void
 handle_popped_out_changed(DBusConnection *connection,
@@ -280,7 +285,11 @@
 
         button_data->orient = new_orient;
 
-        update_icon (button_data);
+        /* orientation change changes which size we want to pick */
+        g_debug("simulating size allocate due to orientation change");
+        button_size_allocated(button_data->button, &button_data->button->allocation, button_data);
+        
+        queue_update_icon (button_data);        
 }
 
 static void
@@ -300,7 +309,7 @@
 
         button_data->size = size;
 
-        update_icon (button_data);
+        queue_update_icon (button_data);
 }
 
 /* this is when the panel size changes */
@@ -309,6 +318,7 @@
                        GtkAllocation   *allocation,
                        ButtonData      *button_data)
 {
+        g_debug("Got size allocation %dx%d", allocation->width, allocation->height);
         switch (button_data->orient) {
         case GTK_ORIENTATION_HORIZONTAL:
                 update_size (button_data, allocation->height);
@@ -319,50 +329,52 @@
         }
 }
 
-static void
-update_icon (ButtonData *button_data)
+static gboolean
+update_icon_idle (ButtonData *button_data)
 {
         int width, height;
         GdkPixbuf *icon;
         GdkPixbuf *scaled;
         int        icon_size;
         GError    *error;
-        int        focus_width = 0;
-        int        focus_pad = 0;
-        int        thickness = 0;
         int        xrequest, yrequest;
+        GtkRequisition empty_button_request;
 
         /* FIXME this function could do a lot more short-circuiting and maybe
          * save some effort
          */
-
+        g_debug("Updating icon, allocated size=%d", button_data->size);
+        
         if (!button_data->icon_theme)
-                return;
+                goto done;
 
         gtk_image_clear (GTK_IMAGE (button_data->image));
-
-        gtk_widget_style_get (button_data->button,
-                              "focus-line-width", &focus_width,
-                              "focus-padding", &focus_pad,
-                              NULL);
-
+        
+        gtk_widget_set_size_request (button_data->image, 10, 10); /* we undo this later, it's just in case the button special-cases 0x0 contents */
+        gtk_widget_size_request (GTK_WIDGET(button_data->button), &empty_button_request);
+        empty_button_request.width -= 10;
+        empty_button_request.height -= 10;
+        
+        icon_size = 0;
         xrequest = -1;
         yrequest = -1;
         switch (button_data->orient) {
         case GTK_ORIENTATION_HORIZONTAL:
-                thickness = button_data->button->style->ythickness;
-                xrequest = button_data->size - 2 * (focus_width + focus_pad + thickness);
+                xrequest = button_data->size - empty_button_request.width;
+                if (xrequest < 0)
+                        xrequest = 0;
                 yrequest = 12;
+                icon_size = xrequest;
                 break;
         case GTK_ORIENTATION_VERTICAL:
-                thickness = button_data->button->style->xthickness;
                 xrequest = 12;
-                yrequest = button_data->size - 2 * (focus_width + focus_pad + thickness);
+                yrequest = button_data->size - empty_button_request.height;
+                if (yrequest < 0)
+                        yrequest = 0;
+                icon_size = yrequest;
                 break;
         }
 
-        icon_size = button_data->size - 2 * (focus_width + focus_pad + thickness);
-
         /* clamp icon size to a max of 60 which is the native server-side size
          */
         if (icon_size < 22)
@@ -376,6 +388,9 @@
         else
                 icon_size = 60;
 
+        g_debug("Settled on icon size %d, and image widget request %dx%d, based on empty button request %dx%d",
+                icon_size, xrequest, yrequest, empty_button_request.width, empty_button_request.height);
+        
         if (button_data->user_photo) {
                 icon = button_data->user_photo;
                 g_object_ref(icon);
@@ -399,7 +414,7 @@
                         gtk_image_set_from_stock (GTK_IMAGE (button_data->image),
                                                   GTK_STOCK_MISSING_IMAGE,
                                                   GTK_ICON_SIZE_SMALL_TOOLBAR);
-                        return;
+                        goto done;
                 }
         }
 
@@ -411,11 +426,11 @@
         /* Make it fit on the given panel */
         switch (button_data->orient) {
         case GTK_ORIENTATION_HORIZONTAL:
-                width = (icon_size * width) / height;
+                width = (icon_size * width) / (double) height;
                 height = icon_size;
                 break;
         case GTK_ORIENTATION_VERTICAL:
-                height = (icon_size * height) / width;
+                height = (icon_size * height) / (double) width;
                 width = icon_size;
                 break;
         }
@@ -440,8 +455,29 @@
         gtk_widget_set_size_request(button_data->image, xrequest, yrequest);
 
         g_object_unref (icon);
+
+#ifdef GUI_LOG
+        {
+                GtkRequisition with_image_request;
+                gtk_widget_size_request(button_data->button, &with_image_request);
+                g_debug("Entire button will request %dx%d", with_image_request.width, with_image_request.height);
+        }
+#endif
+        
+done:
+        button_data->update_icon_idle = 0;
+        return FALSE;
 }
 
+static void
+queue_update_icon(ButtonData *button_data)
+{
+        if (button_data->update_icon_idle == 0) {
+                button_data->update_icon_idle =
+                        g_idle_add((GSourceFunc) update_icon_idle, button_data);
+        }
+}
+
 static const BonoboUIVerb bigboard_button_menu_verbs [] = {
         BONOBO_UI_UNSAFE_VERB ("BigBoardButtonHelp",        display_help_dialog),
         BONOBO_UI_UNSAFE_VERB ("BigBoardButtonAbout",       display_about_dialog),
@@ -454,7 +490,7 @@
 static void
 update_button_display (ButtonData *button_data)
 {
-        update_icon (button_data);
+        queue_update_icon (button_data);
         
         if (button_data->showing_bigboard)
                 wncklet_set_tooltip (button_data->button, _("Click here to hide the desktop sidebar."));
@@ -511,6 +547,11 @@
                 button_data->button_activate = 0;
         }
 
+        if (button_data->update_icon_idle != 0) {
+                g_source_remove (button_data->update_icon_idle);
+                button_data->update_icon_idle = 0;
+        }
+        
         if (button_data->icon_theme != NULL) {
                 g_signal_handlers_disconnect_by_func (button_data->icon_theme,
                                                       theme_changed_callback,
@@ -608,7 +649,7 @@
 theme_changed_callback (GtkIconTheme    *icon_theme,
                         ButtonData      *button_data)
 {
-        update_icon (button_data);
+        queue_update_icon (button_data);
 }
 
 static void
@@ -629,7 +670,6 @@
         update_button_display (button_data);
 }
 
-
 static ButtonData*
 bigboard_button_add_to_widget (GtkWidget *applet)
 {
@@ -726,6 +766,39 @@
         return button_data;
 }
 
+#ifdef GUI_LOG
+static void
+log_to_text_view(const char *message)
+{
+        static GtkWidget *window = NULL;
+        static GtkWidget *textview = NULL;
+        GtkTextBuffer *buffer;
+        GtkTextIter iter;
+        
+        if (window == NULL) {
+                GtkWidget *sw;
+                
+                window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+                g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK(gtk_widget_destroyed), &window);
+                
+                textview = gtk_text_view_new();
+                sw = gtk_scrolled_window_new(NULL, NULL);
+                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+                gtk_container_add(GTK_CONTAINER(window), sw);
+                gtk_container_add(GTK_CONTAINER(sw), textview);
+                gtk_window_set_default_size(GTK_WINDOW(window), 500, 700);
+
+                gtk_widget_show_all(window);
+        }
+
+        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+        gtk_text_buffer_get_end_iter(buffer, &iter);
+        gtk_text_buffer_insert(buffer, &iter, message, -1);
+        gtk_text_buffer_insert(buffer, &iter, "\n", -1);
+}
+#endif
+
 static gboolean log_debug_messages = FALSE;
 
 static void
@@ -770,6 +843,7 @@
 
         gstr = g_string_new(log_domain);
 
+        g_string_append(gstr, " ");
         g_string_append(gstr, prefix);
         g_string_append(gstr, message);
 
@@ -778,7 +852,11 @@
                 g_string_erase(gstr, gstr->len - 1, 1);
         }
 
-        g_print("%s\n", gstr->str);
+#ifdef GUI_LOG
+        log_to_text_view(gstr->str);
+#else
+        g_printerr("%s\n", gstr->str);
+#endif
         g_string_free(gstr, TRUE);
 
 #ifdef G_OS_WIN32
@@ -798,6 +876,10 @@
 {
         ButtonData *button_data;
 
+#ifdef GUI_LOG
+        log_debug_messages = TRUE;
+#endif
+        
         g_log_set_default_handler(log_handler, NULL);
         g_log_set_handler(G_LOG_DOMAIN,
                           (GLogLevelFlags) (G_LOG_LEVEL_DEBUG | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
@@ -807,6 +889,7 @@
 
         button_data = bigboard_button_add_to_widget (GTK_WIDGET (applet));
 
+        g_debug ("Got panel applet size %d", panel_applet_get_size (applet));
         update_size (button_data,
                      panel_applet_get_size (applet));
 

Modified: bigboard/trunk/applet/http.c
===================================================================
--- bigboard/trunk/applet/http.c	2007-11-02 17:58:34 UTC (rev 6865)
+++ bigboard/trunk/applet/http.c	2007-11-02 19:31:27 UTC (rev 6866)
@@ -85,7 +85,9 @@
     const char *what;
     Request *r;
 
+#ifdef VERBOSE_HTTP
     g_debug("Got Error() in http sink");
+#endif
     
     r = object;
     
@@ -109,7 +111,9 @@
     const char *content_type;
     gint64 estimated_size;
 
+#ifdef VERBOSE_HTTP
     g_debug("Got Begin() in http sink");
+#endif
     
     r = object;
 
@@ -130,8 +134,10 @@
     r->content_type = g_strdup(content_type);
     r->content = g_string_sized_new(MIN(estimated_size, 1024*64) + 16);
 
+#ifdef VERBOSE_HTTP
     g_debug("  content-type '%s' estimated size %d", content_type, (int) estimated_size);
-
+#endif
+    
     return dbus_message_new_method_return(message);
 }
 
@@ -142,7 +148,9 @@
 {
     Request *r;
 
+#ifdef VERBOSE_HTTP
     g_debug("Got End() in http sink");
+#endif
     
     r = object;
 
@@ -177,7 +185,9 @@
     gint64 estimated_remaining;
     DBusMessageIter toplevel_iter, array_iter;
 
+#ifdef VERBOSE_HTTP
     g_debug("Got Data() in http sink");
+#endif
     
     r = object;
 
@@ -236,7 +246,9 @@
 {
     Request *r = data;
 
+#ifdef VERBOSE_HTTP
     g_debug("Got reply to http request message");
+#endif
     
     if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
         const char *message = NULL;
@@ -311,8 +323,10 @@
     Request *r;
 
     r = data;
-    
+
+#ifdef VERBOSE_HTTP
     g_debug("Got reply to http GET for pixbuf");
+#endif
     
     if (content_type == NULL) {
         g_printerr("Failed to download image: %s\n",
@@ -403,8 +417,10 @@
                                        DBUS_TYPE_INVALID);
     hippo_dbus_proxy_unref(proxy);
 
+#ifdef VERBOSE_HTTP
     g_debug("requesting http url '%s' using sink path '%s'",
             r->url, r->sink_path);
+#endif
 }
 
 void

Modified: bigboard/trunk/applet/launchers.c
===================================================================
--- bigboard/trunk/applet/launchers.c	2007-11-02 17:58:34 UTC (rev 6865)
+++ bigboard/trunk/applet/launchers.c	2007-11-02 19:31:27 UTC (rev 6866)
@@ -24,7 +24,8 @@
 
     icon = app_get_icon(app);
     
-    image = gtk_bin_get_child(GTK_BIN(button));
+    image = gtk_bin_get_child(GTK_BIN(button));    
+    
     gtk_image_set_from_pixbuf(GTK_IMAGE(image), icon);
     
     if (icon == NULL)
@@ -105,7 +106,7 @@
         return FALSE;
     }
 
-    return desktop_launch(screen, desktop_names, error);
+    return desktop_launch_list(screen, desktop_names, error);
 }
 
 static void
@@ -120,7 +121,18 @@
     error = NULL;
     if (!app_launch(app, gtk_widget_get_screen(button),
                     &error)) {
-        g_printerr("Failed to launch app: %s\n", error->message);
+        GtkWidget *dialog;
+        dialog = gtk_message_dialog_new_with_markup (NULL, /* parent */
+                                                     GTK_DIALOG_NO_SEPARATOR,
+                                                     GTK_MESSAGE_ERROR,
+                                                     GTK_BUTTONS_CLOSE,
+                                                     "<b>%s</b>\n%s",
+                                                     "Unable to start application",
+                                                     error->message);
+        g_signal_connect(dialog, "response", G_CALLBACK(gtk_object_destroy), NULL);
+        gtk_window_present(GTK_WINDOW(dialog));
+        
+        /* g_printerr("Failed to launch app: %s\n", error->message); */
         g_error_free(error);
     }
 }
@@ -135,15 +147,20 @@
     button = gtk_button_new();
     image = gtk_image_new();
     gtk_widget_show(image);
-
+    
     gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
     gtk_widget_set_name (button, "bigboard-button-launcher-button");
     gtk_rc_parse_string ("\n"
                          "   style \"bigboard-button-launcher-button-style\"\n"
                          "   {\n"
+                         "      xthickness=0\n"
+                         "      ythickness=0\n"                         
                          "      GtkWidget::focus-line-width=0\n"
                          "      GtkWidget::focus-padding=0\n"
-                         "      GtkButton::interior-focus=0\n"
+                         "      GtkButton::default-border={0,0,0,0}\n"
+                         "      GtkButton::default-outside-border={0,0,0,0}\n"
+                         "      GtkButton::inner-border={0,0,0,0}\n" 
+                         "      GtkButton::interior-focus=0\n"                         
                              "   }\n"
                          "\n"
                          "    widget \"*.bigboard-button-launcher-button\" style \"bigboard-button-launcher-button-style\"\n"
@@ -256,7 +273,7 @@
     GtkWidget *hbox;
     LaunchersData *ld;
     
-    hbox = gtk_hbox_new(FALSE, 0);
+    hbox = gtk_hbox_new(FALSE, 1);
 
     ld = g_new0(LaunchersData, 1);
     ld->box = hbox;

Modified: bigboard/trunk/applet/self.c
===================================================================
--- bigboard/trunk/applet/self.c	2007-11-02 17:58:34 UTC (rev 6865)
+++ bigboard/trunk/applet/self.c	2007-11-02 19:31:27 UTC (rev 6866)
@@ -21,7 +21,6 @@
 
 typedef struct {
     DDMDataModel *ddm_model;
-    DDMDataQuery *self_query;
     DDMDataResource *self_resource;
     char *photo_url;
     GdkPixbuf *icon;
@@ -326,16 +325,19 @@
 {
     SelfData *sd = data;
 
-    if (connected && sd->self_query == NULL) {        
-        sd->self_query =
-            ddm_data_model_query_resource(ddm_model,
-                                          /* the child fetch in [] does not work yet */
-                                          "online-desktop:/o/global", "self [ photoUrl;topApplications+ ]");
+    if (connected) {        
+        DDMDataQuery *query;
 
-        ddm_data_query_set_multi_handler(sd->self_query,
+        query = ddm_data_model_query_resource(ddm_model,
+                                              /* the child fetch in [] does not work yet */
+                                              "online-desktop:/o/global", "self [ photoUrl;topApplications+ ]");
+
+        /* query frees itself when either handler is called */
+        
+        ddm_data_query_set_multi_handler(query,
                                          on_query_response, sd);    
         
-        ddm_data_query_set_error_handler(sd->self_query,
+        ddm_data_query_set_error_handler(query,
                                          on_query_error, sd);
     }
 }



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