[gnome-applets/wip/segeiger/windowpicker: 3/7] windowpicker: extract get_applet_orientation



commit 162aec9403e29dac9a35299d634c462b62ad248d
Author: Sebastian Geiger <sbastig gmx net>
Date:   Tue Oct 8 22:34:24 2019 +0200

    windowpicker: extract get_applet_orientation

 windowpicker/src/task-list.c | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 37d6256d4..68cfbb753 100644
--- a/windowpicker/src/task-list.c
+++ b/windowpicker/src/task-list.c
@@ -36,6 +36,32 @@ G_DEFINE_TYPE (TaskList, task_list, GTK_TYPE_BOX)
 
 static GSList *task_lists;
 
+static GtkOrientation
+get_applet_orientation (WpApplet *applet)
+{
+  PanelAppletOrient panel_orientation;
+  GtkOrientation orientation;
+
+  panel_orientation = panel_applet_get_orient(PANEL_APPLET(applet));
+
+  switch(panel_orientation)
+  {
+    case PANEL_APPLET_ORIENT_UP:
+    case PANEL_APPLET_ORIENT_DOWN:
+      orientation = GTK_ORIENTATION_HORIZONTAL;
+      break;
+    case PANEL_APPLET_ORIENT_LEFT:
+    case PANEL_APPLET_ORIENT_RIGHT:
+      orientation = GTK_ORIENTATION_VERTICAL;
+      break;
+    default:
+      orientation = GTK_ORIENTATION_HORIZONTAL;
+      break;
+  }
+
+  return orientation;
+}
+
 static TaskList *
 get_task_list_for_monitor (TaskList   *task_list,
                            GdkMonitor *monitor)
@@ -326,20 +352,10 @@ static void task_list_init (TaskList *list) {
 }
 
 GtkWidget *task_list_new (WpApplet *windowPickerApplet) {
-    PanelAppletOrient panel_orientation = panel_applet_get_orient(PANEL_APPLET(windowPickerApplet));
+
     GtkOrientation orientation;
-    switch(panel_orientation) {
-        case PANEL_APPLET_ORIENT_UP:
-        case PANEL_APPLET_ORIENT_DOWN:
-            orientation = GTK_ORIENTATION_HORIZONTAL;
-            break;
-        case PANEL_APPLET_ORIENT_LEFT:
-        case PANEL_APPLET_ORIENT_RIGHT:
-            orientation = GTK_ORIENTATION_VERTICAL;
-            break;
-        default:
-            orientation = GTK_ORIENTATION_HORIZONTAL;
-    }
+
+    orientation = get_applet_orientation (windowPickerApplet);
 
     TaskList* taskList = g_object_new (TASK_TYPE_LIST,
                                        "orientation", orientation,


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