[gnome-applets/wip/segeiger/window-picker-in-process: 1/2] windowpicker/applet.c: Replace grid with box
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/segeiger/window-picker-in-process: 1/2] windowpicker/applet.c: Replace grid with box
- Date: Wed, 10 Jun 2015 22:53:29 +0000 (UTC)
commit 392f078e7d3c0399bbd22d9b9d8876e1e19c86f6
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 | 19 ++++++++++++++-----
2 files changed, 35 insertions(+), 11 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 ae9b565..b2579c5 100644
--- a/windowpicker/src/task-item.c
+++ b/windowpicker/src/task-item.c
@@ -353,12 +353,21 @@ static gboolean task_item_draw (
static void on_size_allocate (
GtkWidget *widget,
GtkAllocation *allocation,
- TaskItem *item)
+ WindowPickerApplet *applet)
{
- g_return_if_fail (TASK_IS_ITEM (item));
+ g_return_if_fail (TASK_IS_ITEM (widget));
+ TaskItem *item = TASK_ITEM (widget);
TaskItemPrivate *priv;
- if (allocation->width != allocation->height + 6)
- gtk_widget_set_size_request (widget, allocation->height + 6, -1);
+ PanelAppletOrient orientation = panel_applet_get_orient (PANEL_APPLET (applet));
+
+ if (orientation == PANEL_APPLET_ORIENT_RIGHT || orientation == PANEL_APPLET_ORIENT_LEFT) {
+ if (allocation->height != allocation->width + 6)
+ gtk_widget_set_size_request (widget, -1, allocation->width + 6);
+ } else {
+ if (allocation->width != allocation->height + 6)
+ gtk_widget_set_size_request (widget, allocation->height + 6, -1);
+ }
+
priv = item->priv;
priv->area.x = allocation->x;
priv->area.y = allocation->y;
@@ -858,7 +867,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]