Skip to contentSkip to conversation

Upgrade to Gtk+3

PATCH New Jussi Kukkonen 1 participant 26 messages May 3, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Upgrade to Gtk+3

Apologies for one more patch bomb: This is an upgrade for matchbox-panel-2 to use modern dependencies, mostly Gtk+3. Most commits are again from Ross, I just fixed bugs and replaced some deprecated code.

This patchset is part of the quest to make Sato compatible with GTK+3. Complete WIP collection of patches can be found in jku/matchbox-wip branch at git://git.yoctoproject.org/poky-contrib

-Jussi

The following changes since commit a0b5fca04da208990f3c40e65dbb045da4cdb35e:

showdesktop: Make sure active state is initialized (2016-03-21 11:27:08 +0000)

are available in the git repository at:

git://github.com/jku/matchbox-panel-2 gtk3
https://github.com/jku/matchbox-panel-2/tree/gtk3

Jussi Kukkonen (6):
Fix a crash on startup
Don't use deprecated GtkMisc
Update .pc-file to require Gtk+-3.0
Draw systray icons in their actual locations
mb-panel: size request needs to be set before realize
windowselector: Port to ScalingImage2

Ross Burton (19):
build: check for GTK+3, and require 3.0
windowselector: port to GTK+ 3
startup: port to GTK+ 3
startup-notify: port to GTK+ 3
showdesktop: port to GTK+ 3
launcher: port to GTK+ 3
mb-panel: port to GTK+3
notify: port to GTK+ 3
systray: port to GTK+ 3
data: ship our own icons here instead of in sato-icon-theme
po: update POTFILES.in
build: bump version to 2.9
scaling-image: fix whitespace
scaling-image: port to GTK+ 3 API
mb-panel: allow resizing, but hide the grip
mb-panel: replace --titlebar with --mode
scaling-image2: revised and slimmer scaling image implementation
applets: add scaling-image2 to the test harness
showdesktop: port to use scaling-image2

 Makefile.am                              |   2 +-
 applets/Makefile.applets                 |   3 +-
 applets/launcher/launcher.c              |  12 +-
 applets/notify/applet.c                  |  19 +-
 applets/notify/mb-notification.c         |  40 +-
 applets/showdesktop/showdesktop.c        |  28 +-
 applets/startup-notify/startup.c         |  65 ++-
 applets/startup/startup.c                |  63 +--
 applets/systray/Makefile.am              |  20 +-
 applets/systray/fixedtip.c               | 275 ++++++++++
 applets/systray/fixedtip.h               |  68 +++
 applets/systray/na-marshal.list          |   3 -
 applets/systray/na-tray-child.c          | 526 +++++++++++++++++++
 applets/systray/na-tray-child.h          |  71 +++
 applets/systray/na-tray-manager.c        | 570 +++++++++++---------
 applets/systray/na-tray-manager.h        |  32 +-
 applets/systray/na-tray.c                | 865 +++++++++++++++++++++++++++++++
 applets/systray/na-tray.h                |  76 +++
 applets/systray/systray.c                |  91 +---
 applets/windowselector/windowselector.c  |  43 +-
 configure.ac                             |  11 +-
 data/16x16/panel-task-switcher.png       | Bin 0 -> 432 bytes
 data/16x16/panel-user-desktop.png        | Bin 0 -> 393 bytes
 data/22x22/panel-task-switcher.png       | Bin 0 -> 636 bytes
 data/22x22/panel-user-desktop.png        | Bin 0 -> 517 bytes
 data/32x32/panel-task-switcher.png       | Bin 0 -> 965 bytes
 data/32x32/panel-user-desktop.png        | Bin 0 -> 734 bytes
 data/48x48/panel-task-switcher.png       | Bin 0 -> 1588 bytes
 data/48x48/panel-user-desktop.png        | Bin 0 -> 1115 bytes
 data/64x64/panel-task-switcher.png       | Bin 0 -> 2328 bytes
 data/64x64/panel-user-desktop.png        | Bin 0 -> 1491 bytes
 data/Makefile.am                         |  18 +
 matchbox-panel.pc.in                     |   2 +-
 matchbox-panel/Makefile.am               |   4 +-
 matchbox-panel/mb-panel-scaling-image.c  |  37 +-
 matchbox-panel/mb-panel-scaling-image2.c | 451 ++++++++++++++++
 matchbox-panel/mb-panel-scaling-image2.h |  64 +++
 matchbox-panel/mb-panel.c                | 401 +++++++-------
 po/POTFILES.in                           |  24 +-
 39 files changed, 3209 insertions(+), 675 deletions(-)
 create mode 100644 applets/systray/fixedtip.c
 create mode 100644 applets/systray/fixedtip.h
 delete mode 100644 applets/systray/na-marshal.list
 create mode 100644 applets/systray/na-tray-child.c
 create mode 100644 applets/systray/na-tray-child.h
 create mode 100644 applets/systray/na-tray.c
 create mode 100644 applets/systray/na-tray.h
 create mode 100644 data/16x16/panel-task-switcher.png
 create mode 100644 data/16x16/panel-user-desktop.png
 create mode 100644 data/22x22/panel-task-switcher.png
 create mode 100644 data/22x22/panel-user-desktop.png
 create mode 100644 data/32x32/panel-task-switcher.png
 create mode 100644 data/32x32/panel-user-desktop.png
 create mode 100644 data/48x48/panel-task-switcher.png
 create mode 100644 data/48x48/panel-user-desktop.png
 create mode 100644 data/64x64/panel-task-switcher.png
 create mode 100644 data/64x64/panel-user-desktop.png
 create mode 100644 data/Makefile.am
 create mode 100644 matchbox-panel/mb-panel-scaling-image2.c
 create mode 100644 matchbox-panel/mb-panel-scaling-image2.h
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/25 build: check for GTK+3, and require 3.0

From: Ross Burton <[email protected]>

---
 configure.ac | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
configure.ac +5 -3
index 55de6ae..4f38032 100644
@@ -17,10 +17,12 @@ GNOME_COMPILE_WARNINGS
 # base deps
 PKG_CHECK_MODULES(MATCHBOX_PANEL,
                   glib-2.0
+                  gmodule-export-2.0
                   x11
-                  gdk-x11-2.0
-                  gtk+-2.0 >= 2.18
-                  gmodule-export-2.0)
+                  gdk-x11-3.0
+                  gtk+-3.0)
+
+AC_DEFINE_UNQUOTED(GDK_VERSION_MIN_REQUIRED, [GDK_VERSION_3_0], [GTK+ API we require])
 
 # startup-notification
 AC_ARG_ENABLE(startup_notification,
Signature · 1 line
2.8.1
#2 lore raw

PATCH 2/25 windowselector: port to GTK+ 3

From: Ross Burton <[email protected]>

---
 applets/windowselector/windowselector.c | 39 ++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 18 deletions(-)
applets/windowselector/windowselector.c +21 -18
index 4608a85..9c1dadf 100644
@@ -1,4 +1,4 @@
-/* 
+/*
  * (C) 2006, 2007 OpenedHand Ltd.
  *
  * Authors: Jorn Baayen <[email protected]>
@@ -148,8 +148,9 @@ get_text_property (WindowSelectorApplet *applet,
         if (gdk_error_trap_pop () || result == 0)
                 return NULL;
 
-        count = gdk_text_property_to_utf8_list
-                        (gdk_x11_xatom_to_atom (text.encoding),
+        count = gdk_text_property_to_utf8_list_for_display
+                        (display,
+                         gdk_x11_xatom_to_atom (text.encoding),
                          text.format,
                          text.value,
                          text.nitems,
@@ -370,7 +371,7 @@ get_current_app_window (WindowSelectorApplet *applet)
 
 
         result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
-                                     GDK_WINDOW_XWINDOW (applet->root_window),
+                                     GDK_WINDOW_XID (applet->root_window),
                                      applet->atoms[_MB_CURRENT_APP_WINDOW],
                                      0, 1,
                                      False,
@@ -412,18 +413,18 @@ window_menu_item_activate_cb (GtkWidget            *widget,
                         (g_object_get_data (G_OBJECT (widget), "window"));
         screen = GDK_SCREEN_XSCREEN (gtk_widget_get_screen (widget));
         toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet->button));
-  
+
         /* Send _NET_ACTIVE_WINDOW message */
         xev.xclient.type = ClientMessage;
         xev.xclient.serial = 0;
         xev.xclient.send_event = True;
         xev.xclient.display = DisplayOfScreen (screen);
         xev.xclient.window = window;
-        xev.xclient.message_type = applet->atoms[_NET_ACTIVE_WINDOW]; 
+        xev.xclient.message_type = applet->atoms[_NET_ACTIVE_WINDOW];
         xev.xclient.format = 32;
         xev.xclient.data.l[0] = 2;
         xev.xclient.data.l[1] = gtk_get_current_event_time ();
-        xev.xclient.data.l[2] = GDK_WINDOW_XWINDOW (toplevel->window);
+        xev.xclient.data.l[2] = GDK_WINDOW_XID (gtk_widget_get_window (toplevel));
         xev.xclient.data.l[3] = 0;
         xev.xclient.data.l[4] = 0;
 
@@ -431,7 +432,7 @@ window_menu_item_activate_cb (GtkWidget            *widget,
 	            RootWindowOfScreen (screen),
                     False,
 	            SubstructureRedirectMask,
-	            &xev);        
+	            &xev);
 }
 
 
@@ -460,7 +461,7 @@ rebuild_menu (WindowSelectorApplet *applet)
 
         gdk_error_trap_push ();
         result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
-                                     GDK_WINDOW_XWINDOW (applet->root_window),
+                                     GDK_WINDOW_XID (applet->root_window),
                                      applet->atoms
                                              [_MB_APP_WINDOW_LIST_STACKING],
                                      0,
@@ -563,11 +564,13 @@ position_menu (GtkMenu  *menu,
                gpointer  user_data)
 {
         WindowSelectorApplet *applet = user_data;
-        
-        gdk_window_get_origin (applet->button->window, x, y);
-        
-        *x += applet->button->allocation.x;
-        *y += applet->button->allocation.height;
+        GtkAllocation allocation;
+
+        gdk_window_get_origin (gtk_widget_get_window (applet->button), x, y);
+        gtk_widget_get_allocation (applet->button, &allocation);
+
+        *x += allocation.x;
+        *y += allocation.height;
         *push_in = TRUE;
 }
 
@@ -658,7 +661,7 @@ filter_func (GdkXEvent            *xevent,
                     applet->atoms[_MB_APP_WINDOW_LIST_STACKING]) {
                         /* _MB_APP_WINDOW_LIST_STACKING changed.
                          * Rebuild menu if around. */
-                        if (applet->menu && GTK_WIDGET_VISIBLE (applet->menu))
+                        if (applet->menu && gtk_widget_get_visible (applet->menu))
                                 rebuild_menu (applet);
                 }
                 if (xev->xproperty.atom ==
@@ -744,7 +747,7 @@ screen_changed_cb (GtkWidget         *button,
                                applet);
         
         /* Rebuild menu if around */
-        if (applet->menu && GTK_WIDGET_VISIBLE (applet->menu))
+        if (applet->menu && gtk_widget_get_visible (applet->menu))
                 rebuild_menu (applet);
 
         update_current_app (applet);
@@ -800,12 +803,12 @@ mb_panel_applet_create (const char    *id,
                                 applet->image);
                 break;
         case MODE_ICON_NAME:
-                hbox = gtk_hbox_new (FALSE, 4);
+                hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
                 applet->label = gtk_label_new (NULL);
                 applet->image = gtk_image_new ();
                 gtk_box_pack_start (GTK_BOX (hbox), applet->image,
                                 FALSE, FALSE, 2);
-                gtk_box_pack_start (GTK_BOX (hbox), applet->label, 
+                gtk_box_pack_start (GTK_BOX (hbox), applet->label,
                                 TRUE, TRUE, 0);
                 gtk_container_add (GTK_CONTAINER (applet->button), hbox);
                 break;
Signature · 1 line
2.8.1
#3 lore raw

PATCH 3/25 startup: port to GTK+ 3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/startup/startup.c | 63 +++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 29 deletions(-)
applets/startup/startup.c +34 -29
index 3554d4c..1b304da 100644
@@ -1,10 +1,13 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
 /*
  * startup-monitor - A tray app that provides feedback
  *                             on application startup.
  *
- * Copyright 2004 - 2007, Openedhand Ltd.
+ * Copyright 2004 - 2013, Intel Corp
  * By Matthew Allum <[email protected]>,
  * Stefan Schmidt <[email protected]>
+ * Ross Burton <[email protected]>
  *
  * Based on mb-applet-startup-monitor
  *
@@ -16,7 +19,6 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
  */
 
 #include <stdio.h>
@@ -38,7 +40,7 @@
 #include <matchbox-panel/mb-panel.h>
 #include <matchbox-panel/mb-panel-scaling-image.h>
 
-#define TIMEOUT                   20
+#define TIMEOUT 20
 #define HOURGLASS_PIXMAPS 8
 
 typedef struct LaunchItem {
@@ -66,6 +68,7 @@ static gboolean timeout (StartupApplet *applet);
 static void
 startup_applet_free (StartupApplet *applet)
 {
+	/* TODO: this should be in unrealize */
         gdk_window_remove_filter (applet->root_window,
                                   (GdkFilterFunc) filter_func, applet);
         g_slice_free (StartupApplet, applet);
@@ -218,12 +221,38 @@ filter_func (GdkXEvent     *gdk_xevent,
         return GDK_FILTER_CONTINUE;
 }
 
+static void
+on_realize (GtkWidget *widget, gpointer user_data)
+{
+        StartupApplet *applet = user_data;
+        GdkDisplay *display;
+        GdkScreen *screen;
+        Display *xdisplay;
+
+        screen = gtk_widget_get_screen (widget);
+        display = gdk_screen_get_display (screen);
+        xdisplay = GDK_DISPLAY_XDISPLAY (display);
+
+        applet->root_window = gdk_screen_get_root_window (screen);
+
+        applet->sn_display = sn_display_new (xdisplay, NULL, NULL);
+        applet->sn_context = sn_monitor_context_new (applet->sn_display,
+                                                     gdk_screen_get_number (screen),
+                                                     monitor_event_func,
+                                                     applet, NULL);
+
+        XSelectInput (xdisplay,
+                      GDK_WINDOW_XID (applet->root_window),
+                      PropertyChangeMask);
+
+        gdk_window_add_filter (applet->root_window, (GdkFilterFunc)filter_func, applet);
+}
+
 G_MODULE_EXPORT GtkWidget *
 mb_panel_applet_create (const char    *id,
                         GtkOrientation orientation)
 {
         StartupApplet *applet;
-        Display *xdisplay;
 
         /* Create applet data structure */
         applet = g_slice_new0 (StartupApplet);
@@ -242,31 +271,7 @@ mb_panel_applet_create (const char    *id,
         g_object_weak_ref (G_OBJECT(applet->image),
                            (GWeakNotify) startup_applet_free, applet);
 
-        xdisplay = GDK_DISPLAY_XDISPLAY
-                                (gtk_widget_get_display
-                                        (GTK_WIDGET (applet->image)));
-
-        applet->sn_display = sn_display_new (xdisplay, NULL, NULL);
-
-        applet->sn_context = sn_monitor_context_new (applet->sn_display,
-                                                     DefaultScreen(xdisplay),
-                                                     monitor_event_func,
-                                                     (void *) applet,
-                                                     NULL);
-
-        /* We have to select for property events on at least one
-         * root window (but not all as INITIATE messages go to
-         * all root windows)
-         */
-        XSelectInput (xdisplay,
-                      DefaultRootWindow(xdisplay), PropertyChangeMask);
-
-        applet->root_window =
-                gdk_window_lookup_for_display
-                        (gdk_x11_lookup_xdisplay (xdisplay), 0);
-
-        gdk_window_add_filter (applet->root_window,
-                               (GdkFilterFunc) filter_func, applet);
+        g_signal_connect (applet->image, "realize", G_CALLBACK (on_realize), applet);
 
         return GTK_WIDGET (applet->image);
 }
Signature · 1 line
2.8.1
#4 lore raw

PATCH 4/25 startup-notify: port to GTK+ 3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/startup-notify/startup.c | 65 +++++++++++++++++++++++++++-------------
 1 file changed, 44 insertions(+), 21 deletions(-)
applets/startup-notify/startup.c +44 -21
index a65817a..a4686ef 100644
@@ -302,37 +302,60 @@ init_notify (StartupApplet *applet)
   return TRUE;
 }
 
+static void
+screen_changed_cb (GtkWidget     *widget,
+                   GdkScreen     *old_screen,
+                   StartupApplet *applet)
+{
+  GdkScreen *screen;
+  GdkDisplay *display;
+  Display *xdisplay;
+
+  if (applet->root_window) {
+    gdk_window_remove_filter (applet->root_window,
+                              (GdkFilterFunc) filter_func,
+                              applet);
+  }
+
+  screen = gtk_widget_get_screen (widget);
+  display = gdk_screen_get_display (screen);
+
+  xdisplay = GDK_DISPLAY_XDISPLAY (display);
+
+  applet->sn_display = sn_display_new (xdisplay, NULL, NULL);
+
+  applet->sn_context = sn_monitor_context_new (applet->sn_display,
+                                               gdk_screen_get_number (screen),
+                                               monitor_event_func,
+                                               applet, NULL);
+
+  /* We have to select for property events on at least one root window (but not
+   * all as INITIATE messages go to all root windows)
+   */
+  XSelectInput (xdisplay, DefaultRootWindow (xdisplay), PropertyChangeMask);
+
+  applet->root_window = gdk_x11_window_lookup_for_display
+    (display, DefaultRootWindow (xdisplay));
+
+  gdk_window_add_filter (applet->root_window, (GdkFilterFunc)filter_func, applet);
+}
+
 G_MODULE_EXPORT GtkWidget *
 mb_panel_applet_create (const char *id, GtkOrientation orientation)
 {
   StartupApplet *applet;
   GtkWidget *widget;
-  Display *xdisplay;
-  
+
   applet = g_slice_new0 (StartupApplet);
 
-  widget = gtk_hbox_new (0, FALSE); /* grr */
+  widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   g_object_weak_ref (G_OBJECT (widget), (GWeakNotify)startup_applet_free, applet);
 
   if (init_notify (applet)) {
-    xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget));
-    
-    applet->sn_display = sn_display_new (xdisplay, NULL, NULL);
-    
-    applet->sn_context = sn_monitor_context_new (applet->sn_display,
-                                                 DefaultScreen (xdisplay),
-                                                 monitor_event_func,
-                                                 applet, NULL);
-
-    /* We have to select for property events on at least one root window (but not
-     * all as INITIATE messages go to all root windows)
-     */
-    XSelectInput (xdisplay, DefaultRootWindow (xdisplay), PropertyChangeMask);
-    
-    applet->root_window = gdk_window_lookup_for_display
-      (gdk_x11_lookup_xdisplay (xdisplay), 0);
-    
-    gdk_window_add_filter (applet->root_window, (GdkFilterFunc)filter_func, applet);
+          g_signal_connect (widget,
+                            "screen-changed",
+                            G_CALLBACK (screen_changed_cb),
+                            applet);
   }
 
   /* TODO: need to fix the panel to support invisible widgets */
Signature · 1 line
2.8.1
#5 lore raw

PATCH 5/25 showdesktop: port to GTK+ 3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/showdesktop/showdesktop.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
applets/showdesktop/showdesktop.c +6 -10
index 33c13e1..e40ebc3 100644
@@ -1,4 +1,4 @@
-/* 
+/*
  * (C) 2006 OpenedHand Ltd.
  *
  * Author: Jorn Baayen <[email protected]>
@@ -20,7 +20,7 @@ typedef struct {
         gboolean active;
 
         Atom atom;
-        
+
         GdkWindow *root_window;
 } ShowDesktopApplet;
 
@@ -50,7 +50,7 @@ set_active (ShowDesktopApplet *applet, gboolean active)
         applet->active = active;
 
         /* TODO: remove this function and instead use a toggle button? */
-        
+
         icon = "panel-user-desktop";
 
         mb_panel_scaling_image_set_icon (applet->image, icon);
@@ -71,8 +71,7 @@ sync_applet (ShowDesktopApplet *applet)
 
         gdk_error_trap_push ();
         result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
-                                     GDK_WINDOW_XWINDOW
-                                            (applet->root_window),
+                                     GDK_WINDOW_XID (applet->root_window),
                                      applet->atom,
                                      0,
                                      G_MAXLONG,
@@ -160,13 +159,13 @@ button_clicked_cb (GtkButton         *button,
 
         widget = GTK_WIDGET (button);
         screen = GDK_SCREEN_XSCREEN (gtk_widget_get_screen (widget));
-  
+
         xev.xclient.type = ClientMessage;
         xev.xclient.serial = 0;
         xev.xclient.send_event = True;
         xev.xclient.display = DisplayOfScreen (screen);
         xev.xclient.window = RootWindowOfScreen (screen);
-        xev.xclient.message_type = applet->atom; 
+        xev.xclient.message_type = applet->atom;
         xev.xclient.format = 32;
         xev.xclient.data.l[0] = !applet->active;
         xev.xclient.data.l[1] = 0;
@@ -194,12 +193,10 @@ mb_panel_applet_create (const char    *id,
         ShowDesktopApplet *applet;
         GtkWidget *button, *image;
 
-        /* Create applet data structure */
         applet = g_slice_new0 (ShowDesktopApplet);
 
         applet->root_window = NULL;
 
-        /* Create button */
         button = gtk_button_new ();
         applet->button = GTK_BUTTON (button);
 
@@ -231,7 +228,6 @@ mb_panel_applet_create (const char    *id,
                            (GWeakNotify) show_desktop_applet_free,
                            applet);
 
-        /* Show! */
         gtk_widget_show_all (button);
 
         return button;
Signature · 1 line
2.8.1
#6 lore raw

PATCH 6/25 launcher: port to GTK+ 3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/launcher/launcher.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
applets/launcher/launcher.c +7 -5
index 7e12814..0ec8a43 100644
@@ -143,6 +143,7 @@ button_release_event_cb (GtkWidget      *event_box,
 {
         int x, y;
         pid_t child_pid = 0;
+        GtkAllocation allocation;
 #ifdef USE_LIBSN
         SnLauncherContext *context;
 #endif
@@ -154,16 +155,17 @@ button_release_event_cb (GtkWidget      *event_box,
 
         /* Only process if the button was released inside the button */
         gtk_widget_translate_coordinates (event_box,
-                                          event_box->parent,
+                                          gtk_widget_get_parent (event_box),
                                           event->x,
                                           event->y,
                                           &x,
                                           &y);
 
-        if (x < event_box->allocation.x ||
-            x > event_box->allocation.x + event_box->allocation.width ||
-            y < event_box->allocation.y ||
-            y > event_box->allocation.y + event_box->allocation.height)
+        gtk_widget_get_allocation (event_box, &allocation);
+        if (x < allocation.x ||
+            x > allocation.x + allocation.width ||
+            y < allocation.y ||
+            y > allocation.y + allocation.height)
                 return TRUE;
 
 #ifdef USE_LIBSN
Signature · 1 line
2.8.1
#7 lore raw

PATCH 7/25 mb-panel: port to GTK+3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

Whilst porting to GTK+ 3 the layout model was simplified: panels are always full-width and you just pick an edge and size. The panel is also multi-screen and multi-monitor aware now.

---
 matchbox-panel/mb-panel.c | 368 +++++++++++++++++++++++-----------------------
 1 file changed, 187 insertions(+), 181 deletions(-)
matchbox-panel/mb-panel.c +187 -181
index 828a36d..1d6832f 100644
@@ -1,9 +1,10 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 
 /*
- * (C) 2006 OpenedHand Ltd.
+ * (C) 2006-2013 Intel Corp
  *
- * Author: Jorn Baayen <[email protected]>
+ * Authors: Ross Burton <[email protected]>
+ *          Jorn Baayen <[email protected]>
  *
  * Licensed under the GPL v2 or greater.
  */
@@ -23,17 +24,16 @@
 
 static GList *open_modules = NULL; /* List of open modules */
 
-/* Extra width and height to reserve for panel struts (see --reserve-extra) */
-static gint extra_width  = 0;
-static gint extra_height = 0;
+enum {
+        ATOM_WM_STRUT_PARTIAL,
+        ATOM_MB_STATE,
+        ATOM_STATE_DOCT_TITLEBAR,
+        ATOM_DOCK_TITLEBAR_DESKTOP,
+        /* Counter */
+        ATOM_LAST
+};
 
-static gboolean snap_right = FALSE;
-static gboolean snap_bottom = FALSE;
-
-static gboolean center_vertical   = FALSE;
-static gboolean center_horizontal = FALSE;
-
-static gboolean fullscreen = FALSE;
+static Atom atoms[ATOM_LAST];
 
 /* Load applet @name with ID @id */
 static GtkWidget *
@@ -132,63 +132,70 @@ load_applets (const char    *applets_desc,
         g_strfreev (applets);
 }
 
-/* Set struts based on the window size and position */
 static void
-set_struts (GtkWidget *window, gint x, gint y, gint w, gint h)
+set_struts (GtkWidget *window, GtkPositionType edge, int size)
 {
-        static Atom net_wm_strut_partial = None;
-
-        guint32    struts [12];
-        gint       screen_width, screen_height;
-        GdkScreen *screen;
-
-        screen = gdk_screen_get_default ();
-
-        screen_width  = gdk_screen_get_width (screen);
-        screen_height = gdk_screen_get_height (screen);
-
-        /* left */
-        struts[0] = x == 0 ? w + extra_width : 0;
-        struts[4] = struts[0] ? y : 0;
-        struts[5] = struts[0] ? y + h : 0;
+        Display *xdisplay;
+        int x, y, w, h;
+        struct {
+                long left;
+                long right;
+                long top;
+                long bottom;
+                long left_start_y;
+                long left_end_y;
+                long right_start_y;
+                long right_end_y;
+                long top_start_x;
+                long top_end_x;
+                long bottom_start_x;
+                long bottom_end_x;
+        } struts = { 0, };
+
+        xdisplay = GDK_SCREEN_XDISPLAY (gtk_widget_get_screen (window));
+        g_assert (xdisplay);
 
-        /* right */
-        struts[1] = x + w == screen_width ? w + extra_width: 0;
-        struts[6] = struts[1] ? y : 0;
-        struts[7] = struts[1] ? y + h : 0;
-
-        /* top */
-        struts[2] = y == 0 ? h + extra_height: 0;
-        struts[8] = struts[2] ? x : 0;
-        struts[9] = struts[2] ? x + w : 0;
+        gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+        gtk_window_get_size (GTK_WINDOW (window), &w, &h);
 
-        /* bottom */
-        struts[3] = y + h == screen_height ? h + extra_height : 0;
-        struts[10] = struts[3] ? x : 0;
-        struts[11] = struts[3] ? x + w : 0;
+        switch (edge) {
+        case GTK_POS_LEFT:
+                struts.left = size;
+                struts.left_start_y = y;
+                struts.left_end_y = y + h;
+                break;
+        case GTK_POS_RIGHT:
+                struts.right = size;
+                struts.right_start_y = y;
+                struts.right_end_y = y + h;
+                break;
+        case GTK_POS_TOP:
+                struts.top = size;
+                struts.top_start_x = x;
+                struts.top_end_x = x + w;
+                break;
+        case GTK_POS_BOTTOM:
+                struts.bottom = size;
+                struts.bottom_start_x = x;
+                struts.bottom_end_x = x + w;
+                break;
+        }
 
         gdk_error_trap_push ();
-
-        if (!net_wm_strut_partial)
-                net_wm_strut_partial = XInternAtom (GDK_DISPLAY () ,
-                                                    "_NET_WM_STRUT_PARTIAL",
-                                                    False);
-
-        XChangeProperty (GDK_DISPLAY (),
-                         GDK_WINDOW_XID (window->window),
-                         net_wm_strut_partial, XA_CARDINAL, 32,
+        XChangeProperty (xdisplay,
+                         GDK_WINDOW_XID (gtk_widget_get_window (window)),
+                         atoms[ATOM_WM_STRUT_PARTIAL], XA_CARDINAL, 32,
                          PropModeReplace,
                          (guchar *) &struts, 12);
-
-        gdk_error_trap_pop ();
+        gdk_error_trap_pop_ignored ();
 }
 
+#if 0
 static void
 screen_size_changed_cb (GdkScreen *screen, GtkWidget *window)
 {
         gint       x, y, w, h;
         gint       screen_width, screen_height;
-
         gtk_window_get_position (GTK_WINDOW (window), &x, &y);
         gtk_window_get_size (GTK_WINDOW (window), &w, &h);
 
@@ -232,6 +239,20 @@ screen_size_changed_cb (GdkScreen *screen, GtkWidget *window)
 
         set_struts (window, x, y, w, h);
 }
+#endif
+
+static void
+get_atoms (Display *xdisplay)
+{
+        static const char *names[] = {
+                "_NET_WM_STRUT_PARTIAL",
+                "_MB_WM_STATE",
+                "_MB_WM_STATE_DOCK_TITLEBAR",
+                "_MB_DOCK_TITLEBAR_SHOW_ON_DESKTOP"
+        };
+
+        XInternAtoms (xdisplay, (char**)names, G_N_ELEMENTS (names), False, atoms);
+}
 
 int
 main (int argc, char **argv)
@@ -239,54 +260,44 @@ main (int argc, char **argv)
         GOptionContext *option_context;
         GOptionGroup *option_group;
         GError *error;
-        char *geometry = NULL, *start_applets = NULL, *end_applets = NULL;
+        char *start_applets = NULL, *end_applets = NULL;
+        char *edge_string = NULL;
+        int size = DEFAULT_HEIGHT;
+        int screen_num = -1;
+        int monitor_num = -1;
+        GtkPositionType edge = GTK_POS_TOP;
         GtkWidget *window, *box, *frame;
+        GdkDisplay *display;
         GdkScreen *screen;
-        int panel_width, panel_height;
-        GtkOrientation orientation;
-        gboolean want_titlebar = FALSE;
+        GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
+        gboolean in_titlebar = FALSE;
+        GdkRectangle screen_geom;
 
+        /* TODO: add these as groups (applets / position) */
         GOptionEntry option_entries[] = {
-                { "geometry", 0, 0, G_OPTION_ARG_STRING, &geometry,
-                  N_("Panel geometry"), N_("[WIDTH][xHEIGHT][{+-}X[{+-}Y]]") },
                 { "start-applets", 0, 0, G_OPTION_ARG_STRING, &start_applets,
                   N_("Applets to pack at the start"), N_("APPLET[:APPLET_ID] ...") },
                 { "end-applets", 0, 0, G_OPTION_ARG_STRING, &end_applets,
                   N_("Applets to pack at the end"), N_("APPLET[:APPLET_ID] ...") },
-                { "titlebar", 0, 0, G_OPTION_ARG_NONE, &want_titlebar,
-                  N_("Display in window titlebar (If Matchbox theme supports)"),
-                  NULL },
-                { "reserve-extra-width", 0, 0, G_OPTION_ARG_INT, &extra_width,
-                  N_("Extra width to reserve in panel strut in addittion to "
-                     "the window width"),
-                  N_("pixels")},
-                { "reserve-extra-height", 0, 0, G_OPTION_ARG_INT, &extra_height,
-                  N_("Extra height to reserve in panel strut in addition to "
-                     "the window height"),
-                  N_("pixels")},
-                { "center-horizontally", 0, 0, G_OPTION_ARG_NONE,
-                  &center_horizontal,
-                  N_("Center panel horizontally"),
-                  NULL },
-                { "center-vertically", 0, 0, G_OPTION_ARG_NONE,
-                  &center_vertical,
-                  N_("Center panel vertically"),
-                  NULL },
-                { "fullscreen", 0, 0, G_OPTION_ARG_NONE,
-                  &fullscreen,
-                  N_("Stretch panel to fullscreen in dominant direction "
-                     "(if used together with the --geometry options "
-                     "while the offset in the dominant direction will be "
-                     "ignored, it must not be specified with the + prefix, "
-                     "e.g., --geometry=200x32+0-0"),
-                  NULL },
+
+                { "screen", 'n', 0, G_OPTION_ARG_INT, &screen_num,
+                  N_("Screen number"), N_("SCREEN") },
+                { "monitor", 'm', 0, G_OPTION_ARG_INT, &monitor_num,
+                  N_("Monitor number"), N_("MONITOR") },
+
+                { "titlebar", 't', 0, G_OPTION_ARG_NONE, &in_titlebar,
+                  N_("Display in window titlebar (with Matchbox theme support)"), NULL },
+                { "edge", 'e', 0, G_OPTION_ARG_STRING, &edge_string,
+                  N_("Panel edge"), N_("TOP|BOTTON|LEFT|RIGHT") },
+                { "size", 's', 0, G_OPTION_ARG_INT, &size,
+                  N_("Panel size"), N_("PIXELS")},
+
                 { NULL }
         };
 
         /* Make sure that GModule is supported */
         if (!g_module_supported ()) {
-                g_warning (_("gmodule support not found. gmodule support is "
-                             "required for matchbox-panel to work"));
+                g_warning (_("GModule support not found, this is required for matchbox-panel to work"));
                 return -1;
         }
 
@@ -316,44 +327,100 @@ main (int argc, char **argv)
 
         g_option_context_free (option_context);
 
+        /* Can't be in the titlebar *and* on an edge, so check for this and exit */
+        if (in_titlebar && edge_string) {
+                g_printerr ("Cannot specify both --edge and --titlebar\n");
+                return 1;
+        }
+
+        if (edge_string) {
+                if (g_ascii_strcasecmp (edge_string, "top") == 0) {
+                        edge = GTK_POS_TOP;
+                } else if (g_ascii_strcasecmp (edge_string, "bottom") == 0) {
+                        edge = GTK_POS_BOTTOM;
+                } else if (g_ascii_strcasecmp (edge_string, "left") == 0) {
+                        edge = GTK_POS_LEFT;
+                } else if (g_ascii_strcasecmp (edge_string, "right") == 0) {
+                        edge = GTK_POS_RIGHT;
+                } else {
+                        g_printerr ("Unparsable edge '%s', expecting top/bottom/left/right\n", edge_string);
+                        return 1;
+                }
+                g_free (edge_string);
+        }
+
         /* Set app name */
         g_set_application_name (_("Matchbox Panel"));
 
+        display = gdk_display_get_default ();
+
+        get_atoms (GDK_DISPLAY_XDISPLAY (display));
+
+        if (screen_num != -1) {
+                screen = gdk_display_get_screen (display, screen_num);
+        } else {
+                screen = gdk_display_get_default_screen (display);
+        }
+
+        if (monitor_num == -1) {
+                monitor_num = gdk_screen_get_primary_monitor (screen);
+        }
+
+        /* Note that this is bare monitor geometry and not the work area, so
+           panels will overlap. */
+        gdk_screen_get_monitor_geometry (screen, monitor_num, &screen_geom);
+
         /* Create window */
         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
         gtk_widget_set_name (window, "MatchboxPanel");
-
-        gtk_window_set_type_hint (GTK_WINDOW (window),
-                                  GDK_WINDOW_TYPE_HINT_DOCK);
+        gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK);
+        gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
 
         /* No key focus please */
         gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
 
-        /* Set default panel height */
-        screen = gtk_window_get_screen (GTK_WINDOW (window));
-        gtk_window_set_default_size (GTK_WINDOW (window),
-                                     gdk_screen_get_width (screen),
-                                     DEFAULT_HEIGHT);
-
-        /* Parse geometry string */
-        if (geometry) {
-                if (!gtk_window_parse_geometry (GTK_WINDOW (window),
-                                                geometry)) {
-                        g_warning ("Failed to parse geometry string");
-
-                        gtk_widget_destroy (window);
+        gtk_widget_realize (window);
 
-                        return 1;
+        /* Set size */
+        if (!in_titlebar) {
+                /* TODO: hook this up to GdkScreen:size-changed */
+
+                /* Orientation and size */
+                switch (edge) {
+                case GTK_POS_TOP:
+                case GTK_POS_BOTTOM:
+                        orientation = GTK_ORIENTATION_HORIZONTAL;
+                        gtk_widget_set_size_request (window,
+                                           screen_geom.width, size);
+                        break;
+                case GTK_POS_LEFT:
+                case GTK_POS_RIGHT:
+                        orientation = GTK_ORIENTATION_VERTICAL;
+                        gtk_widget_set_size_request (window,
+                                           size, screen_geom.height);
+                        break;
                 }
-        }
 
-        /* Determine window size */
-        gtk_window_get_size (GTK_WINDOW (window), &panel_width, &panel_height);
+                /* Position */
+                switch (edge) {
+                case GTK_POS_TOP:
+                case GTK_POS_LEFT:
+                        gtk_window_move (GTK_WINDOW (window),
+                                         screen_geom.x, screen_geom.y);
+                        break;
+                case GTK_POS_RIGHT:
+                        gtk_window_move (GTK_WINDOW (window),
+                                         screen_geom.x + screen_geom.width - size,
+                                         screen_geom.y);
+                        break;
+                case GTK_POS_BOTTOM:
+                        gtk_window_move (GTK_WINDOW (window),
+                                         screen_geom.x,
+                                         screen_geom.y + screen_geom.height - size);
+                }
 
-        /* Force size */
-        gtk_widget_set_size_request (window, panel_width, panel_height);
-        gtk_window_resize (GTK_WINDOW (window), panel_width, panel_height);
+                set_struts (window, edge, size);
+        }
 
         /* Add frame */
         frame = gtk_frame_new (NULL);
@@ -362,91 +429,30 @@ main (int argc, char **argv)
         gtk_widget_show (frame);
 
         /* Is this a horizontal or a vertical layout? */
-        if (panel_width >= panel_height) {
-                orientation = GTK_ORIENTATION_HORIZONTAL;
-
+        if (orientation == GTK_ORIENTATION_HORIZONTAL) {
                 gtk_widget_set_name (frame, "MatchboxPanelFrameHorizontal");
-
-                box = gtk_hbox_new (FALSE, 0);
         } else {
-                orientation = GTK_ORIENTATION_VERTICAL;
-
                 gtk_widget_set_name (frame, "MatchboxPanelFrameVertical");
-
-                box = gtk_vbox_new (FALSE, 0);
         }
+        box = gtk_box_new (orientation, 0);
 
         gtk_container_add (GTK_CONTAINER (frame), box);
         gtk_widget_show (box);
 
-        gtk_widget_realize (window);
-
+#if 0
         /* Do we want to display the panel in the Matchbox titlebar? */
-        if (want_titlebar) {
-                const char *names[] = {
-                        /* Set the Matchbox-specific window state */
-                        "_MB_WM_STATE",
-                        /* To the list of these atoms */
-                        "_MB_WM_STATE_DOCK_TITLEBAR",
-                        "_MB_DOCK_TITLEBAR_SHOW_ON_DESKTOP"
-                };
-                Atom atoms[G_N_ELEMENTS (names)];
-
-                XInternAtoms (GDK_DISPLAY (), (char**)names,
-                              G_N_ELEMENTS (names), False, atoms);
-
-                XChangeProperty (GDK_DISPLAY (),
-                                 GDK_WINDOW_XID (window->window),
+        if (in_titlebar) {
+                XChangeProperty (GDK_SCREEN_XDISPLAY (screen),
+                                 GDK_WINDOW_XID (gtk_widget_get_window (window)),
                                  atoms[0], XA_ATOM, 32,
                                  PropModeReplace,
                                  (unsigned char *) &atoms[1], 2);
         } else {
-                /* If we're not in a title bar, set the struts */
-                gint screen_width  = gdk_screen_get_width (screen);
-                gint screen_height = gdk_screen_get_height (screen);
-                gint x, y, w, h;
-
-                gtk_window_get_position (GTK_WINDOW (window), &x, &y);
-                gtk_window_get_size (GTK_WINDOW (window), &w, &h);
-
-                if (fullscreen)
-                        {
-                                if (w > h)
-                                        {
-                                                w = screen_width;
-                                                x = 0;
-                                        }
-                                else
-                                        {
-                                                h = screen_height;
-                                                y = 0;
-                                        }
-
-                                gtk_widget_set_size_request (window, w, h);
-                                gtk_window_resize (GTK_WINDOW (window), w, h);
-                        }
-
-                if (center_horizontal)
-                        x = (screen_width - w) / 2;
-
-                if (center_vertical)
-                        y = (screen_height - h)/ 2;
-
-                if (center_horizontal || center_vertical || fullscreen)
-                        gtk_window_move (GTK_WINDOW (window), x, y);
-
-
-                if (x + w == screen_width)
-                        snap_right = TRUE;
-
-                if (y + h == screen_height)
-                        snap_bottom = TRUE;
-
-                set_struts (window, x, y, w, h);
                 g_signal_connect (screen, "size-changed",
                                   G_CALLBACK (screen_size_changed_cb),
                                   window);
         }
+#endif
 
         /* Load applets */
         load_applets (start_applets,
Signature · 1 line
2.8.1
#8 lore raw

PATCH 8/25 notify: port to GTK+ 3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/notify/applet.c          | 19 ++++++++++++-------
 applets/notify/mb-notification.c | 38 +++++++++++++++++++++-----------------
 2 files changed, 33 insertions(+), 24 deletions(-)
applets/notify/applet.c +12 -7
index 2920b12..2d896e8 100644
@@ -1,4 +1,4 @@
-/* 
+/*
  * (C) 2008 OpenedHand Ltd.
  *
  * Author: Ross Burton <[email protected]>
@@ -20,9 +20,13 @@ reposition (GtkWindow *window)
 
   screen = gtk_window_get_screen (window);
 
-  gtk_widget_size_request ((GtkWidget*)window, &req);
+  gtk_widget_get_preferred_size (GTK_WIDGET (window), &req, NULL);
+
   if (req.height) {
     gtk_window_resize (window, req.width, req.height);
+    /* TODO: get the primary monitor and then use
+       gdk_screen_get_monitor_geometry() to get the geometry of the primary
+       display, not the overall screen. */
     gtk_window_move (window,
                      gdk_screen_get_width (screen) - req.width,
                      gdk_screen_get_height (screen) - req.height);
@@ -45,7 +49,7 @@ find_widget (GtkContainer *container, guint32 id)
 {
   GList *children, *l;
   GtkWidget *w;
-  
+
   children = gtk_container_get_children (container);
   l = g_list_find_custom (children, GINT_TO_POINTER (id), id_compare);
   w = l ? l->data : NULL;
@@ -86,7 +90,7 @@ on_notification_closed (MbNotifyStore *store, guint id, guint reason, GtkWindow
   w = find_widget ((GtkContainer*)box, id);
   if (w)
     gtk_container_remove (GTK_CONTAINER (box), w);
-  
+
   reposition (window);
 }
 
@@ -95,14 +99,15 @@ mb_panel_applet_create (const char *id, GtkOrientation orientation)
 {
   GtkWidget *window, *box;
   MbNotifyStore *notify;
-  
+
   window = gtk_window_new (GTK_WINDOW_POPUP);
   gtk_widget_set_name (window, "MbNotificationBox");
-  
+  gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_SOUTH_EAST);
+
   box = gtk_vbox_new (TRUE, 0);
   gtk_container_add (GTK_CONTAINER (window), box);
   gtk_widget_show_all (window);
-  
+
   notify = mb_notify_store_new ();
   g_signal_connect (notify, "notification-added", G_CALLBACK (on_notification_added), window);
   g_signal_connect (notify, "notification-closed", G_CALLBACK (on_notification_closed), window);
applets/notify/mb-notification.c +21 -17
index 0d0e97c..e440ec9 100644
@@ -9,7 +9,7 @@ enum {
 };
 
 static guint signals[N_SIGNALS];
-  
+
 #define GET_PRIVATE(o) \
   (G_TYPE_INSTANCE_GET_PRIVATE ((o), MB_TYPE_NOTIFICATION, MbNotificationPrivate))
 
@@ -31,17 +31,21 @@ on_button_release (MbNotification *notification, GdkEventButton *event)
   }
 }
 
-static gint
-expose (GtkWidget *widget, GdkEventExpose *event)
+static gboolean
+on_draw (GtkWidget *widget, cairo_t *cr)
 {
-  if (gtk_widget_is_drawable (widget)) {
-    gtk_paint_box (widget->style, widget->window,
-                   widget->state, GTK_SHADOW_OUT,
-                   &event->area, widget, "notification",
-                   0, 0, -1, -1);
-    
-    (*GTK_WIDGET_CLASS (mb_notification_parent_class)->expose_event) (widget, event);
-  }
+  GtkStyleContext *style;
+  int width, height;
+
+  style = gtk_widget_get_style_context (widget);
+
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
+
+  gtk_render_frame (style, cr, 0, 0, width, height);
+
+  (*GTK_WIDGET_CLASS (mb_notification_parent_class)->draw) (widget, cr);
+
   return FALSE;
 }
 
@@ -52,8 +56,8 @@ mb_notification_class_init (MbNotificationClass *klass)
 
   g_type_class_add_private (klass, sizeof (MbNotificationPrivate));
 
-  widget_class->expose_event = expose;
-  
+  widget_class->draw = on_draw;
+
   signals[CLOSED] = g_signal_new ("closed",
                                   G_OBJECT_CLASS_TYPE (klass),
                                   G_SIGNAL_RUN_FIRST,
@@ -73,13 +77,13 @@ mb_notification_init (MbNotification *self)
   gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), FALSE);
   gtk_widget_add_events (GTK_WIDGET (self), GDK_BUTTON_RELEASE_MASK);
   g_signal_connect (self, "button-release-event", G_CALLBACK (on_button_release), NULL);
-  
-  box = gtk_hbox_new (FALSE, 8);
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
   gtk_container_add (GTK_CONTAINER (self), box);
 
   priv->image = gtk_image_new ();
   gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, FALSE, 0);
-  
+
   priv->label = gtk_label_new (NULL);
   gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
   gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
@@ -106,7 +110,7 @@ mb_notification_update (MbNotification *notification, Notification *n)
     /* TODO: should this default to no image, or "info" */
     gtk_image_clear (GTK_IMAGE (priv->image));
   }
-  
+
   s = g_strdup_printf ("<big><b>%s</b></big>\n"
                        "\n%s", n->summary, n->body ?: NULL);
   gtk_label_set_markup (GTK_LABEL (priv->label), s);
Signature · 1 line
2.8.1
#9 lore raw

PATCH 9/25 systray: port to GTK+ 3

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

In the process refresh the bulk of the code from it's upstream in gnome-panel.

---
 applets/systray/Makefile.am       |  20 +-
 applets/systray/fixedtip.c        | 276 ++++++++++++
 applets/systray/fixedtip.h        |  68 +++
 applets/systray/na-marshal.list   |   3 -
 applets/systray/na-tray-child.c   | 526 +++++++++++++++++++++++
 applets/systray/na-tray-child.h   |  71 ++++
 applets/systray/na-tray-manager.c | 570 ++++++++++++++-----------
 applets/systray/na-tray-manager.h |  32 +-
 applets/systray/na-tray.c         | 863 ++++++++++++++++++++++++++++++++++++++
 applets/systray/na-tray.h         |  76 ++++
 applets/systray/systray.c         |  91 +---
 11 files changed, 2253 insertions(+), 343 deletions(-)
 create mode 100644 applets/systray/fixedtip.c
 create mode 100644 applets/systray/fixedtip.h
 delete mode 100644 applets/systray/na-marshal.list
 create mode 100644 applets/systray/na-tray-child.c
 create mode 100644 applets/systray/na-tray-child.h
 create mode 100644 applets/systray/na-tray.c
 create mode 100644 applets/systray/na-tray.h
applets/systray/Makefile.am +8 -12
index e01fe0c..1788581 100644
@@ -1,21 +1,17 @@
 include ../Makefile.applets
 
-%.c: %.list
-	$(AM_V_GEN) (echo "#include \"na-marshal.h\""; \
-	  $(GLIB_GENMARSHAL) --internal --prefix=_na_marshal $^ --body) > $@
-%.h: %.list
-	$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_na_marshal $^ --header > $@
-
 applet_LTLIBRARIES = libsystray.la
-libsystray_la_SOURCES = $(BUILT_SOURCES) \
+libsystray_la_SOURCES = systray.c \
+                        na-tray.c \
+			na-tray.h \
                         na-tray-manager.c \
 			na-tray-manager.h \
-			systray.c
-libsystray_la_LDFLAGS = -avoid-version -module
+                        na-tray-child.c \
+			na-tray-child.h \
+			fixedtip.c \
+			fixedtip.h
 
-EXTRA_DIST = na-marshal.list
-
-BUILT_SOURCES = na-marshal.c na-marshal.h
+libsystray_la_LDFLAGS = -avoid-version -module
 
 test_linkage_LDADD += libsystray.la
 
applets/systray/fixedtip.c new file +276 -0

276 lines not on this page · raw message

applets/systray/fixedtip.h new file +68 -0

68 lines not on this page · raw message

applets/systray/na-marshal.list deleted +0 -3
deleted file mode 100644
index e3fc399..0000000
@@ -1,3 +0,0 @@
-VOID:OBJECT,OBJECT
-VOID:OBJECT,STRING,LONG,LONG
-VOID:OBJECT,LONG
applets/systray/na-tray-child.c new file +526 -0

526 lines not on this page · raw message

applets/systray/na-tray-child.h new file +71 -0

71 lines not on this page · raw message

applets/systray/na-tray-manager.c +324 -246

830 lines not on this page · raw message

applets/systray/na-tray-manager.h +24 -8
index a1781a7..0408959 100644
@@ -24,10 +24,12 @@
 #ifndef __NA_TRAY_MANAGER_H__
 #define __NA_TRAY_MANAGER_H__
 
-#include <gtk/gtk.h>
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
 #endif
+#include <gtk/gtk.h>
+
+#include "na-tray-child.h"
 
 G_BEGIN_DECLS
 
@@ -40,7 +42,6 @@ G_BEGIN_DECLS
 	
 typedef struct _NaTrayManager	    NaTrayManager;
 typedef struct _NaTrayManagerClass  NaTrayManagerClass;
-typedef struct _NaTrayManagerChild  NaTrayManagerChild;
 
 struct _NaTrayManager
 {
@@ -49,11 +50,18 @@ struct _NaTrayManager
 #ifdef GDK_WINDOWING_X11
   GdkAtom selection_atom;
   Atom    opcode_atom;
+  Atom    message_data_atom;
 #endif
   
   GtkWidget *invisible;
   GdkScreen *screen;
   GtkOrientation orientation;
+  gint padding;
+  gint icon_size;
+  GdkColor fg;
+  GdkColor error;
+  GdkColor warning;
+  GdkColor success;
 
   GList *messages;
   GHashTable *socket_table;
@@ -64,18 +72,18 @@ struct _NaTrayManagerClass
   GObjectClass parent_class;
 
   void (* tray_icon_added)   (NaTrayManager      *manager,
-			      NaTrayManagerChild *child);
+			      NaTrayChild        *child);
   void (* tray_icon_removed) (NaTrayManager      *manager,
-			      NaTrayManagerChild *child);
+			      NaTrayChild        *child);
 
   void (* message_sent)      (NaTrayManager      *manager,
-			      NaTrayManagerChild *child,
+			      NaTrayChild        *child,
 			      const gchar        *message,
 			      glong               id,
 			      glong               timeout);
   
   void (* message_cancelled) (NaTrayManager      *manager,
-			      NaTrayManagerChild *child,
+			      NaTrayChild        *child,
 			      glong               id);
 
   void (* lost_selection)    (NaTrayManager      *manager);
@@ -87,11 +95,19 @@ gboolean        na_tray_manager_check_running   (GdkScreen          *screen);
 NaTrayManager  *na_tray_manager_new             (void);
 gboolean        na_tray_manager_manage_screen   (NaTrayManager      *manager,
 						 GdkScreen          *screen);
-char           *na_tray_manager_get_child_title (NaTrayManager      *manager,
-						 NaTrayManagerChild *child);
 void            na_tray_manager_set_orientation (NaTrayManager      *manager,
 						 GtkOrientation      orientation);
 GtkOrientation  na_tray_manager_get_orientation (NaTrayManager      *manager);
+void            na_tray_manager_set_padding     (NaTrayManager      *manager,
+						 gint                padding);
+void            na_tray_manager_set_icon_size   (NaTrayManager      *manager,
+						 gint                padding);
+void            na_tray_manager_set_colors      (NaTrayManager      *manager,
+						 GdkColor           *fg,
+						 GdkColor           *error,
+						 GdkColor           *warning,
+						 GdkColor           *success);
+
 
 G_END_DECLS
 
applets/systray/na-tray.c new file +863 -0

863 lines not on this page · raw message

applets/systray/na-tray.h new file +76 -0

76 lines not on this page · raw message

applets/systray/systray.c +17 -74

122 lines not on this page · raw message

Signature · 1 line
2.8.1
#10 lore raw

PATCH 10/25 data: ship our own icons here instead of in sato-icon-theme

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 Makefile.am                        |   2 +-
 configure.ac                       |   1 +
 data/16x16/panel-task-switcher.png | Bin 0 -> 432 bytes
 data/16x16/panel-user-desktop.png  | Bin 0 -> 393 bytes
 data/22x22/panel-task-switcher.png | Bin 0 -> 636 bytes
 data/22x22/panel-user-desktop.png  | Bin 0 -> 517 bytes
 data/32x32/panel-task-switcher.png | Bin 0 -> 965 bytes
 data/32x32/panel-user-desktop.png  | Bin 0 -> 734 bytes
 data/48x48/panel-task-switcher.png | Bin 0 -> 1588 bytes
 data/48x48/panel-user-desktop.png  | Bin 0 -> 1115 bytes
 data/64x64/panel-task-switcher.png | Bin 0 -> 2328 bytes
 data/64x64/panel-user-desktop.png  | Bin 0 -> 1491 bytes
 data/Makefile.am                   |  18 ++++++++++++++++++
 13 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 data/16x16/panel-task-switcher.png
 create mode 100644 data/16x16/panel-user-desktop.png
 create mode 100644 data/22x22/panel-task-switcher.png
 create mode 100644 data/22x22/panel-user-desktop.png
 create mode 100644 data/32x32/panel-task-switcher.png
 create mode 100644 data/32x32/panel-user-desktop.png
 create mode 100644 data/48x48/panel-task-switcher.png
 create mode 100644 data/48x48/panel-user-desktop.png
 create mode 100644 data/64x64/panel-task-switcher.png
 create mode 100644 data/64x64/panel-user-desktop.png
 create mode 100644 data/Makefile.am
Makefile.am +1 -1
index 68f2e0a..87db93c 100644
@@ -1,4 +1,4 @@
-SUBDIRS = matchbox-panel applets po
+SUBDIRS = matchbox-panel applets data po
 
 pcdatadir = $(libdir)/pkgconfig
 dist_pcdata_DATA= matchbox-panel.pc
configure.ac +1 -0
index 4f38032..101df2d 100644
@@ -105,6 +105,7 @@ applets/startup/Makefile
 applets/startup/data/Makefile
 applets/systray/Makefile
 applets/windowselector/Makefile
+data/Makefile
 po/Makefile.in
 po/Makefile
 ])
data/16x16/panel-task-switcher.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1bc5a70aa1ad13423f552594f5aff1c6b0de924e
GIT binary patch
data/16x16/panel-user-desktop.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..69c09ddbd369815b569668214a53fd3bc793c771
GIT binary patch
data/22x22/panel-task-switcher.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..d19020e71ecbe2653219e8def1af8c7cb76574d4
GIT binary patch
data/22x22/panel-user-desktop.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e2b03669785bdc34ab756f48babd902eb550cd0d
GIT binary patch
data/32x32/panel-task-switcher.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..c06fc3ffd6c61c5ffc2d539148993c266c823b89
GIT binary patch
data/32x32/panel-user-desktop.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..dfc3df3ea91782627e6eafac9d8af57ab1384913
GIT binary patch
data/48x48/panel-task-switcher.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..dfe84ae98a6191be722a1b605baa00a075866d04
GIT binary patch
data/48x48/panel-user-desktop.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..12c4b5c94af993c5f27cfa0670749b686940bd89
GIT binary patch
data/64x64/panel-task-switcher.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..a6b33959e80aca8a371b4deb7c001c11b322f2ff
GIT binary patch
data/64x64/panel-user-desktop.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..7da52c69dcfdd433cdacfe9565a28e491d6587b6
GIT binary patch
data/Makefile.am new file +18 -0
new file mode 100644
index 0000000..ed7ebeb
@@ -0,0 +1,18 @@
+icondir = $(datadir)/icons/hicolor
+
+icon16dir = $(icondir)/16x16/apps
+dist_icon16_DATA = $(wildcard $(srcdir)/16x16/*.png)
+
+icon22dir = $(icondir)/22x22/apps
+dist_icon22_DATA = $(wildcard $(srcdir)/22x22/*.png)
+
+icon32dir = $(icondir)/32x32/apps
+dist_icon32_DATA = $(wildcard $(srcdir)/32x32/*.png)
+
+icon48dir = $(icondir)/48x48/apps
+dist_icon48_DATA = $(wildcard $(srcdir)/48x48/*.png)
+
+icon64dir = $(icondir)/64x64/apps
+dist_icon64_DATA = $(wildcard $(srcdir)/64x64/*.png)
+
+-include $(top_srcdir)/git.mk
Signature · 1 line
2.8.1
#11 lore raw

PATCH 11/25 po: update POTFILES.in

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 po/POTFILES.in | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
po/POTFILES.in +17 -7
index b98a590..3ffdd38 100644
@@ -1,12 +1,22 @@
-matchbox-panel/mb-panel-scaling-image.c
-matchbox-panel/mb-panel.c
-applets/launcher/launcher.c
-applets/startup/startup.c
+applets/exit/exit.c
 applets/windowselector/windowselector.c
+applets/startup/startup.c
+applets/battery/battery-apm.c
 applets/battery/battery.c
+applets/battery/battery-acpi.c
+applets/launcher/launcher.c
 applets/showdesktop/showdesktop.c
-applets/clock/clock.c
+applets/startup-notify/marshal.c
+applets/startup-notify/startup.c
 applets/systray/systray.c
-applets/systray/na-marshal.c
 applets/systray/na-tray-manager.c
-
+applets/systray/na-tray-child.c
+applets/systray/fixedtip.c
+applets/systray/na-tray.c
+applets/clock/clock.c
+applets/notify/mb-notification.c
+applets/notify/marshal.c
+applets/notify/notify-store.c
+applets/notify/applet.c
+applets/brightness/brightness.c
+applets/common/test_main.c
Signature · 1 line
2.8.1
#12 lore raw

PATCH 12/25 build: bump version to 2.9

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index 101df2d..c03c62e 100644
@@ -1,5 +1,5 @@
 AC_PREREQ(2.53)
-AC_INIT(matchbox-panel, 2.0, http://www.openedhand.com/)
+AC_INIT(matchbox-panel, 2.9, http://www.openedhand.com/)
 AM_INIT_AUTOMAKE([-Wno-portability])
 AC_CONFIG_SRCDIR(matchbox-panel/mb-panel.c)
 AM_CONFIG_HEADER(config.h)
Signature · 1 line
2.8.1
#13 lore raw

PATCH 13/25 scaling-image: fix whitespace

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 matchbox-panel/mb-panel-scaling-image.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
matchbox-panel/mb-panel-scaling-image.c +11 -10
index 25aa041..dc76b06 100644
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 /*
  * (C) 2006, 2007 OpenedHand Ltd.
  *
@@ -158,7 +159,7 @@ clear_cache (MBPanelScalingImage *image)
 {
         if (!image->priv->caching)
                 return;
-        
+
         g_hash_table_foreach_remove (image->priv->cache,
                                      return_true,
                                      NULL);
@@ -208,18 +209,18 @@ find_icon (GtkIconTheme *icon_theme,
 
         prefixed = g_strconcat ("panel-", stripped, NULL);
 
-        info = gtk_icon_theme_lookup_icon (icon_theme, 
+        info = gtk_icon_theme_lookup_icon (icon_theme,
                                            prefixed,
                                            size,
                                            0);
 
         if (info == NULL) {
-          info = gtk_icon_theme_lookup_icon (icon_theme, 
+          info = gtk_icon_theme_lookup_icon (icon_theme,
                                              stripped,
                                              size,
                                              0);
         }
-        
+
         g_free (stripped);
         g_free (prefixed);
 
@@ -318,7 +319,7 @@ mb_panel_scaling_image_size_allocate (GtkWidget *widget,
 
         widget_class = GTK_WIDGET_CLASS (mb_panel_scaling_image_parent_class);
         widget_class->size_allocate (widget, allocation);
-        
+
         reload_icon (image, FALSE);
 }
 
@@ -328,7 +329,7 @@ mb_panel_scaling_image_realize (GtkWidget *widget)
         GtkWidgetClass *widget_class;
 
         reload_icon (MB_PANEL_SCALING_IMAGE (widget), TRUE);
-        
+
         widget_class = GTK_WIDGET_CLASS (mb_panel_scaling_image_parent_class);
         widget_class->realize (widget);
 }
@@ -382,7 +383,7 @@ mb_panel_scaling_image_screen_changed (GtkWidget *widget,
 
                 reload_icon (MB_PANEL_SCALING_IMAGE (widget), TRUE);
         }
-        
+
         widget_class = GTK_WIDGET_CLASS (mb_panel_scaling_image_parent_class);
         widget_class->screen_changed (widget, old_screen);
 }
@@ -513,7 +514,7 @@ const char *
 mb_panel_scaling_image_get_icon (MBPanelScalingImage *image)
 {
         g_return_val_if_fail (MB_PANEL_IS_SCALING_IMAGE (image), NULL);
-        
+
         return image->priv->icon;
 }
 
@@ -522,7 +523,7 @@ mb_panel_scaling_image_get_icon (MBPanelScalingImage *image)
  * @image: A #MBPanelScalingImage
  * @caching: TRUE if image caching is desired
  *
- * Sets the caching mode to @caching. If @caching is TRUE, 
+ * Sets the caching mode to @caching. If @caching is TRUE,
  * #GdkPixbuf objects previously loaded by @image will be kept around.
  * Use this if you want to quickly alternate between a fixed set of images.
  *
@@ -562,6 +563,6 @@ gboolean
 mb_panel_scaling_image_get_caching (MBPanelScalingImage *image)
 {
         g_return_val_if_fail (MB_PANEL_IS_SCALING_IMAGE (image), FALSE);
-        
+
         return image->priv->caching;
 }
Signature · 1 line
2.8.1
#14 lore raw

PATCH 14/25 scaling-image: port to GTK+ 3 API

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 matchbox-panel/mb-panel-scaling-image.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
matchbox-panel/mb-panel-scaling-image.c +10 -6
index dc76b06..56d2d78 100644
@@ -240,16 +240,16 @@ find_icon (GtkIconTheme *icon_theme,
 static void
 reload_icon (MBPanelScalingImage *image, gboolean force)
 {
+        GtkAllocation alloc;
         int size;
         char *file;
         GdkPixbuf *pixbuf;
         GError *error;
 
         /* Determine the required icon size */
-        if (image->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-                size = GTK_WIDGET (image)->allocation.height;
-        else
-                size = GTK_WIDGET (image)->allocation.width;
+        gtk_widget_get_allocation (GTK_WIDGET (image), &alloc);
+        size = image->priv->orientation == GTK_ORIENTATION_HORIZONTAL
+                ? alloc.height : alloc.width;
 
         if (!force && size == image->priv->size) {
                 return;
@@ -302,7 +302,9 @@ static void
 icon_theme_changed_cb (GtkIconTheme   *icon_theme,
                        MBPanelScalingImage *image)
 {
-        if (!gtk_widget_get_realized (GTK_WIDGET (image)))
+        GtkWidget *widget = GTK_WIDGET (image);
+
+        if (!gtk_widget_get_realized (widget))
                 return;
 
         clear_cache (image);
@@ -320,7 +322,9 @@ mb_panel_scaling_image_size_allocate (GtkWidget *widget,
         widget_class = GTK_WIDGET_CLASS (mb_panel_scaling_image_parent_class);
         widget_class->size_allocate (widget, allocation);
 
-        reload_icon (image, FALSE);
+        if (gtk_widget_get_realized (widget)) {
+                reload_icon (image, FALSE);
+        }
 }
 
 static void
Signature · 1 line
2.8.1
#15 lore raw

PATCH 15/25 mb-panel: allow resizing, but hide the grip

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 matchbox-panel/mb-panel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
matchbox-panel/mb-panel.c +1 -1
index 1d6832f..ea1bb19 100644
@@ -374,7 +374,7 @@ main (int argc, char **argv)
         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
         gtk_widget_set_name (window, "MatchboxPanel");
         gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK);
-        gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
+        gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
 
         /* No key focus please */
         gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
Signature · 1 line
2.8.1
#16 lore raw

PATCH 16/25 mb-panel: replace --titlebar with --mode

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

--mode supports:

"dock" (usual panel behaviour)
"titlebar" (embed into Matchbox titlebar, not funtional at present) "window" (normal window, for testing)

---
 matchbox-panel/mb-panel.c | 61 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 15 deletions(-)
matchbox-panel/mb-panel.c +46 -15
index ea1bb19..3f7e3b4 100644
@@ -261,7 +261,8 @@ main (int argc, char **argv)
         GOptionGroup *option_group;
         GError *error;
         char *start_applets = NULL, *end_applets = NULL;
-        char *edge_string = NULL;
+        char *edge_string = NULL, *mode_string = NULL;
+        enum { MODE_DOCK, MODE_TITLEBAR, MODE_WINDOW } mode = MODE_DOCK;
         int size = DEFAULT_HEIGHT;
         int screen_num = -1;
         int monitor_num = -1;
@@ -270,7 +271,6 @@ main (int argc, char **argv)
         GdkDisplay *display;
         GdkScreen *screen;
         GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
-        gboolean in_titlebar = FALSE;
         GdkRectangle screen_geom;
 
         /* TODO: add these as groups (applets / position) */
@@ -285,13 +285,12 @@ main (int argc, char **argv)
                 { "monitor", 'm', 0, G_OPTION_ARG_INT, &monitor_num,
                   N_("Monitor number"), N_("MONITOR") },
 
-                { "titlebar", 't', 0, G_OPTION_ARG_NONE, &in_titlebar,
-                  N_("Display in window titlebar (with Matchbox theme support)"), NULL },
                 { "edge", 'e', 0, G_OPTION_ARG_STRING, &edge_string,
                   N_("Panel edge"), N_("TOP|BOTTON|LEFT|RIGHT") },
                 { "size", 's', 0, G_OPTION_ARG_INT, &size,
                   N_("Panel size"), N_("PIXELS")},
-
+                { "mode", 'm', 0, G_OPTION_ARG_STRING, &mode_string,
+                  N_("Panel mode"), N_("DOCK|TITLEBAR|WINDOW") },
                 { NULL }
         };
 
@@ -327,12 +326,6 @@ main (int argc, char **argv)
 
         g_option_context_free (option_context);
 
-        /* Can't be in the titlebar *and* on an edge, so check for this and exit */
-        if (in_titlebar && edge_string) {
-                g_printerr ("Cannot specify both --edge and --titlebar\n");
-                return 1;
-        }
-
         if (edge_string) {
                 if (g_ascii_strcasecmp (edge_string, "top") == 0) {
                         edge = GTK_POS_TOP;
@@ -349,6 +342,20 @@ main (int argc, char **argv)
                 g_free (edge_string);
         }
 
+        if (mode_string) {
+                if (g_ascii_strcasecmp (mode_string, "dock") == 0) {
+                        mode = MODE_DOCK;
+                } else if (g_ascii_strcasecmp (mode_string, "titlebar") == 0) {
+                        mode = MODE_TITLEBAR;
+                } else if (g_ascii_strcasecmp (mode_string, "window") == 0) {
+                        mode = MODE_WINDOW;
+                } else {
+                        g_printerr ("Unparsable mode '%s', expecting dock/titlebar/window\n", mode_string);
+                        return 1;
+                }
+                g_free (mode_string);
+        }
+
         /* Set app name */
         g_set_application_name (_("Matchbox Panel"));
 
@@ -373,16 +380,18 @@ main (int argc, char **argv)
         /* Create window */
         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
         gtk_widget_set_name (window, "MatchboxPanel");
-        gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK);
         gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
 
-        /* No key focus please */
-        gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
+        if (mode != MODE_WINDOW) {
+                gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK);
+                gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
+        }
 
         gtk_widget_realize (window);
 
         /* Set size */
-        if (!in_titlebar) {
+        switch (mode) {
+        case MODE_DOCK:
                 /* TODO: hook this up to GdkScreen:size-changed */
 
                 /* Orientation and size */
@@ -420,6 +429,28 @@ main (int argc, char **argv)
                 }
 
                 set_struts (window, edge, size);
+                break;
+        case MODE_TITLEBAR:
+                /* TODO */
+                break;
+        case MODE_WINDOW:
+                /* Set the size based on half the screen dimensions, and
+                   requested size */
+                switch (edge) {
+                case GTK_POS_TOP:
+                case GTK_POS_BOTTOM:
+                        orientation = GTK_ORIENTATION_HORIZONTAL;
+                        gtk_widget_set_size_request (window,
+                                           screen_geom.width / 2, size);
+                        break;
+                case GTK_POS_LEFT:
+                case GTK_POS_RIGHT:
+                        orientation = GTK_ORIENTATION_VERTICAL;
+                        gtk_widget_set_size_request (window,
+                                           size, screen_geom.height / 2);
+                        break;
+                }
+                break;
         }
 
         /* Add frame */
Signature · 1 line
2.8.1
#17 lore raw

PATCH 17/25 scaling-image2: revised and slimmer scaling image implementation

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

No caching, but it's lighter and doesn't misbehave (i.e. size-allocate loop).

---
 matchbox-panel/Makefile.am               |   4 +-
 matchbox-panel/mb-panel-scaling-image2.c | 449 +++++++++++++++++++++++++++++++
 matchbox-panel/mb-panel-scaling-image2.h |  64 +++++
 3 files changed, 515 insertions(+), 2 deletions(-)
 create mode 100644 matchbox-panel/mb-panel-scaling-image2.c
 create mode 100644 matchbox-panel/mb-panel-scaling-image2.h
matchbox-panel/Makefile.am +2 -2
index 67e0756..a102402 100644
@@ -7,11 +7,11 @@ AM_CFLAGS = $(WARN_CFLAGS)
 
 matchbox_panelincdir = $(pkgincludedir)
 
-matchbox_panelinc_HEADERS = mb-panel.h mb-panel-scaling-image.h
+matchbox_panelinc_HEADERS = mb-panel.h mb-panel-scaling-image.h mb-panel-scaling-image2.h
 
 bin_PROGRAMS = matchbox-panel
 
-matchbox_panel_SOURCES = mb-panel.c mb-panel-scaling-image.c
+matchbox_panel_SOURCES = mb-panel.c mb-panel-scaling-image.c mb-panel-scaling-image2.c
 
 matchbox_panel_LDADD = $(MATCHBOX_PANEL_LIBS)
 
matchbox-panel/mb-panel-scaling-image2.c new file +449 -0

449 lines not on this page · raw message

matchbox-panel/mb-panel-scaling-image2.h new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
2.8.1
#18 lore raw

PATCH 18/25 applets: add scaling-image2 to the test harness

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/Makefile.applets | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
applets/Makefile.applets +2 -1
index 9538818..1fff4ff 100644
@@ -9,5 +9,6 @@ appletdir = $(pkglibdir)
 # Binary to check that the applet actually links against everything it needs.
 noinst_PROGRAMS = test-linkage
 test_linkage_SOURCES = $(srcdir)/../common/test_main.c \
-                       $(top_srcdir)/matchbox-panel/mb-panel-scaling-image.c
+                       $(top_srcdir)/matchbox-panel/mb-panel-scaling-image.c \
+                       $(top_srcdir)/matchbox-panel/mb-panel-scaling-image2.c
 test_linkage_LDADD = $(MATCHBOX_PANEL_LIBS)
Signature · 1 line
2.8.1
#19 lore raw

PATCH 19/25 showdesktop: port to use scaling-image2

In reply to Jussi Kukkonen

From: Ross Burton <[email protected]>

---
 applets/showdesktop/showdesktop.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
applets/showdesktop/showdesktop.c +5 -9
index e40ebc3..14f9d96 100644
@@ -11,11 +11,11 @@
 #include <gdk/gdkx.h>
 #include <X11/Xatom.h>
 #include <matchbox-panel/mb-panel.h>
-#include <matchbox-panel/mb-panel-scaling-image.h>
+#include <matchbox-panel/mb-panel-scaling-image2.h>
 
 typedef struct {
         GtkButton *button;
-        MBPanelScalingImage *image;
+        MBPanelScalingImage2 *image;
 
         gboolean active;
 
@@ -45,15 +45,11 @@ show_desktop_applet_free (ShowDesktopApplet *applet)
 static void
 set_active (ShowDesktopApplet *applet, gboolean active)
 {
-        const char *icon;
-
         applet->active = active;
 
         /* TODO: remove this function and instead use a toggle button? */
 
-        icon = "panel-user-desktop";
-
-        mb_panel_scaling_image_set_icon (applet->image, icon);
+        mb_panel_scaling_image2_set_icon (applet->image, "panel-user-desktop");
 }
 
 /* Sync @applet with the _NET_SHOWING_DESKTOP root window property */
@@ -206,8 +202,8 @@ mb_panel_applet_create (const char    *id,
 
         gtk_widget_set_name (button, "MatchboxPanelShowDesktop");
 
-        image = mb_panel_scaling_image_new (orientation, NULL);
-        applet->image = MB_PANEL_SCALING_IMAGE (image);
+        image = mb_panel_scaling_image2_new (orientation, NULL);
+        applet->image = MB_PANEL_SCALING_IMAGE2 (image);
 
         gtk_container_add (GTK_CONTAINER (button), image);
 
Signature · 1 line
2.8.1
#20 lore raw

PATCH 20/25 Fix a crash on startup

In reply to Jussi Kukkonen
---
 matchbox-panel/mb-panel-scaling-image2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
matchbox-panel/mb-panel-scaling-image2.c +4 -2
index 5692ce1..8cdc3a1 100644
@@ -327,8 +327,10 @@ mb_panel_scaling_image2_draw (GtkWidget *widget, cairo_t *cr)
 {
         MBPanelScalingImage2 *image = MB_PANEL_SCALING_IMAGE2 (widget);
 
-        gdk_cairo_set_source_pixbuf (cr, image->priv->pixbuf, 0.0, 0.0);
-        cairo_paint (cr);
+        if (image->priv->pixbuf) {
+                gdk_cairo_set_source_pixbuf (cr, image->priv->pixbuf, 0.0, 0.0);
+                cairo_paint (cr);
+        }
         return TRUE;
 }
 
Signature · 1 line
2.8.1
#21 lore raw

PATCH 21/25 Don't use deprecated GtkMisc

In reply to Jussi Kukkonen

These changes should not affect fucntionality

---
 applets/notify/mb-notification.c | 2 +-
 applets/systray/fixedtip.c       | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
applets/notify/mb-notification.c +1 -1
index e440ec9..c73b21f 100644
@@ -85,7 +85,7 @@ mb_notification_init (MbNotification *self)
   gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, FALSE, 0);
 
   priv->label = gtk_label_new (NULL);
-  gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
+  gtk_label_set_xalign (GTK_LABEL (priv->label), 0.0);
   gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
 }
 
applets/systray/fixedtip.c +0 -1
index 861e4ab..ce19067 100644
@@ -116,7 +116,6 @@ na_fixed_tip_init (NaFixedTip *fixedtip)
 
   label = gtk_label_new (NULL);
   gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-  gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
   gtk_widget_show (label);
   gtk_container_add (GTK_CONTAINER (fixedtip), label);
   fixedtip->priv->label = label;
Signature · 1 line
2.8.1
#22 lore raw

PATCH 22/25 Update .pc-file to require Gtk+-3.0

In reply to Jussi Kukkonen
---
 matchbox-panel.pc.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
matchbox-panel.pc.in +1 -1
index dc0a75c..90374b7 100644
@@ -8,4 +8,4 @@ Name: matchbox-panel
 Description: Simple GTK+ based panel
 Version: @VERSION@
 Cflags: -I${includedir}
-Requires: glib-2.0 gtk+-2.0
+Requires: glib-2.0 gtk+-3.0
Signature · 1 line
2.8.1
#23 lore raw

PATCH 23/25 Draw systray icons in their actual locations

In reply to Jussi Kukkonen

Cairo context is now in widget-relative coordinates instead of
window-relative: undo that transform so the icon draw code actually draws inside the window.

---
 applets/systray/na-tray.c | 2 ++
 1 file changed, 2 insertions(+)
applets/systray/na-tray.c +2 -0
index 7da908f..714bd90 100644
@@ -538,6 +538,8 @@ static void
 na_tray_draw_box (GtkWidget *box,
 		  cairo_t   *cr)
 {
+  /* Transform to window-relative coordinates */
+  gtk_cairo_transform_to_window (cr, box, gtk_widget_get_window (box));
   gtk_container_foreach (GTK_CONTAINER (box), na_tray_draw_icon, cr);
 }
 
Signature · 1 line
2.8.1
#24 lore raw

PATCH 24/25 mb-panel: size request needs to be set before realize

In reply to Jussi Kukkonen

GtkWindow will default to 200 height on realize unless we request otherwise before that. On the other hand, struts can only be set after the window has been realized.

---
 matchbox-panel/mb-panel.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
matchbox-panel/mb-panel.c +4 -4
index 3f7e3b4..4f5fb74 100644
@@ -387,8 +387,6 @@ main (int argc, char **argv)
                 gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
         }
 
-        gtk_widget_realize (window);
-
         /* Set size */
         switch (mode) {
         case MODE_DOCK:
@@ -427,8 +425,6 @@ main (int argc, char **argv)
                                          screen_geom.x,
                                          screen_geom.y + screen_geom.height - size);
                 }
-
-                set_struts (window, edge, size);
                 break;
         case MODE_TITLEBAR:
                 /* TODO */
@@ -453,6 +449,10 @@ main (int argc, char **argv)
                 break;
         }
 
+        gtk_widget_realize (window);
+        if (mode == MODE_DOCK)
+		set_struts (window, edge, size);
+
         /* Add frame */
         frame = gtk_frame_new (NULL);
         gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
Signature · 1 line
2.8.1
#25 lore raw

PATCH 25/25 windowselector: Port to ScalingImage2

In reply to Jussi Kukkonen
---
 applets/windowselector/windowselector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
applets/windowselector/windowselector.c +2 -2
index 9c1dadf..d269355 100644
@@ -15,7 +15,7 @@
 #include <gdk/gdkx.h>
 
 #include <matchbox-panel/mb-panel.h>
-#include <matchbox-panel/mb-panel-scaling-image.h>
+#include <matchbox-panel/mb-panel-scaling-image2.h>
 
 #define DEFAULT_WINDOW_ICON_NAME "application-x-executable"
 
@@ -792,7 +792,7 @@ mb_panel_applet_create (const char    *id,
 
         switch (applet->mode) {
         case MODE_STATIC_ICON:
-                applet->image = mb_panel_scaling_image_new (orientation,
+                applet->image = mb_panel_scaling_image2_new (orientation,
                         "panel-task-switcher");
                 gtk_container_add (GTK_CONTAINER (applet->button),
                                 applet->image);
Signature · 1 line
2.8.1