[gnome-applets/wip/segeiger/window-picker-in-process: 3/4] windowpicker/applet.c: Replace grid with box



commit a243c12e0130ca7159ef7700c9c91a7a7229cda4
Author: Sebastian Geiger <sbastig gmx net>
Date:   Mon Jun 8 21:10:27 2015 +0200

    windowpicker/applet.c: Replace grid with box
    
    This fixes a problem on vertically aligned panels, that
    caused the task list to remain horizontal.
    
    This registers a callback to handle orientation changes of the panel.
    
    We also consider the orientation of the panel in the size allocation
    of the TaskItems.

 windowpicker/src/applet.c    |   27 +++++++++++++++++++++------
 windowpicker/src/task-item.c |    2 +-
 2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/windowpicker/src/applet.c b/windowpicker/src/applet.c
index bf1f3f0..17a3016 100644
--- a/windowpicker/src/applet.c
+++ b/windowpicker/src/applet.c
@@ -44,6 +44,7 @@
 #define KEY_EXPAND_TASK_LIST       "expand-task-list"
 
 struct _WindowPickerAppletPrivate {
+    GtkWidget *outer_box;
     GtkWidget *tasks;
     GtkWidget *title; /* a pointer to the window title widget */
     GSettings *settings;
@@ -132,6 +133,18 @@ setupPanelContextMenu (WindowPickerApplet *windowPickerApplet)
     g_object_unref (action_group);
 }
 
+static void
+on_applet_orientation_changed (PanelApplet *applet,
+                               guint orient,
+                               gpointer user_data)
+{
+    WindowPickerApplet *windowPickerApplet = WINDOW_PICKER_APPLET (applet);
+    WindowPickerAppletPrivate *priv = windowPickerApplet->priv;
+
+    gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->outer_box), panel_applet_get_gtk_orientation 
(applet));
+    gtk_widget_queue_resize (GTK_WIDGET (applet));
+}
+
 static gboolean
 load_window_picker (PanelApplet *applet) {
     WindowPickerApplet *windowPickerApplet = WINDOW_PICKER_APPLET(applet);
@@ -139,19 +152,18 @@ load_window_picker (PanelApplet *applet) {
     GSettings *settings = windowPickerApplet->priv->settings
                         = panel_applet_settings_new(applet, SETTINGS_SCHEMA);
 
-    GtkWidget *grid = gtk_grid_new ();
-    gtk_grid_set_row_spacing (GTK_GRID(grid), 10);
-    gtk_container_add (GTK_CONTAINER (applet), grid);
+    GtkWidget *outer_box = priv->outer_box = gtk_box_new (panel_applet_get_gtk_orientation (applet), 0);
+    gtk_container_add (GTK_CONTAINER (applet), outer_box);
     gtk_container_set_border_width (GTK_CONTAINER (applet), 0);
-    gtk_container_set_border_width (GTK_CONTAINER (grid), 0);
+    gtk_container_set_border_width (GTK_CONTAINER (outer_box), 0);
 
     priv->tasks = task_list_new (windowPickerApplet);
     gtk_widget_set_vexpand (priv->tasks, TRUE);
-    gtk_grid_attach (GTK_GRID(grid), priv->tasks, 0, 0, 1, 1);
+    gtk_box_pack_start (GTK_BOX (outer_box), priv->tasks, TRUE, TRUE, 0);
 
     priv->title = task_title_new (windowPickerApplet);
     gtk_widget_set_hexpand (priv->title, TRUE);
-    gtk_grid_attach (GTK_GRID(grid), priv->title, 1, 0, 1, 1);
+    gtk_box_pack_start (GTK_BOX (outer_box), priv->title, TRUE, TRUE, 0);
 
     priv->show_all_windows = g_settings_get_boolean (settings, KEY_SHOW_ALL_WINDOWS);
     g_settings_bind (settings, KEY_SHOW_ALL_WINDOWS,
@@ -183,6 +195,9 @@ load_window_picker (PanelApplet *applet) {
 
     panel_applet_set_flags(applet, flags);
 
+    g_signal_connect(applet, "change-orient",
+                     G_CALLBACK(on_applet_orientation_changed), NULL);
+
     gtk_widget_show_all(GTK_WIDGET (applet));
 
     return TRUE;
diff --git a/windowpicker/src/task-item.c b/windowpicker/src/task-item.c
index 0cf4f09..888a0cb 100644
--- a/windowpicker/src/task-item.c
+++ b/windowpicker/src/task-item.c
@@ -942,7 +942,7 @@ GtkWidget *task_item_new (WindowPickerApplet* windowPickerApplet, WnckWindow *wi
     g_signal_connect (item, "button-press-event",
         G_CALLBACK (on_button_pressed), item);
     g_signal_connect (item, "size-allocate",
-        G_CALLBACK (on_size_allocate), item);
+        G_CALLBACK (on_size_allocate), windowPickerApplet);
     g_signal_connect (item, "query-tooltip",
         G_CALLBACK (on_query_tooltip), item);
     g_signal_connect (item, "enter-notify-event",


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