[gnome-panel/wip/3.0-freeze-break] panel: Change pack-end (boolean) key to pack (enum) in object schema



commit 8f23cf4be1b19285724b3ac83953ba786e7793a9
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Mar 25 23:24:39 2011 +0100

    panel: Change pack-end (boolean) key to pack (enum) in object schema
    
    This will make it easier to add a way to center objects later on.

 data/org.gnome.gnome-panel.object.gschema.xml |    6 +++---
 data/panel-default-layout.layout              |    6 +++---
 gnome-panel/applet.c                          |   16 +++++++++-------
 gnome-panel/panel-enums-gsettings.h           |    5 ++++-
 gnome-panel/panel-layout.c                    |    8 ++++----
 gnome-panel/panel-object-loader.c             |    6 ++++--
 gnome-panel/panel-schemas.h                   |    2 +-
 7 files changed, 28 insertions(+), 21 deletions(-)
---
diff --git a/data/org.gnome.gnome-panel.object.gschema.xml b/data/org.gnome.gnome-panel.object.gschema.xml
index a4d4613..15fb32f 100644
--- a/data/org.gnome.gnome-panel.object.gschema.xml
+++ b/data/org.gnome.gnome-panel.object.gschema.xml
@@ -15,10 +15,10 @@
       <summary>Object's position on the panel</summary>
       <description>The position of this panel object. The position is specified by the number of pixels from the left (or top if vertical) panel edge.</description>
     </key>
-    <key name="pack-end" type="b">
-      <default>false</default>
+    <key name="pack" enum="org.gnome.gnome-panel.PanelObjectPack">
+      <default>'start'</default>
       <summary>Interpret position relative to bottom/right edge</summary>
-      <description>If true, the position of the object is interpreted relative to the right (or bottom if vertical) edge of the panel.</description>
+      <description>If set to 'end', the position of the object is interpreted relative to the right (or bottom if vertical) edge of the panel.</description>
     </key>
   </schema>
 </schemalist>
diff --git a/data/panel-default-layout.layout b/data/panel-default-layout.layout
index db3d28f..73b0978 100644
--- a/data/panel-default-layout.layout
+++ b/data/panel-default-layout.layout
@@ -18,13 +18,13 @@ position=0
 object-iid=ClockAppletFactory::ClockApplet
 toplevel-id=top-panel
 position=0
-pack-end=true
+pack=end
 
 [Object notification-area]
 object-iid=NotificationAreaAppletFactory::NotificationArea
 toplevel-id=top-panel
 position=1
-pack-end=true
+pack=end
 
 [Object window-list]
 object-iid=WnckletFactory::WindowListApplet
@@ -35,4 +35,4 @@ position=0
 object-iid=WnckletFactory::WorkspaceSwitcherApplet
 toplevel-id=bottom-panel
 position=0
-pack-end=true
+pack=end
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index ab5e34b..2ecd806 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -865,9 +865,9 @@ panel_applet_save_position (AppletInfo *applet_info,
 	g_settings_set_string (applet_info->settings,
 			       PANEL_OBJECT_TOPLEVEL_ID_KEY,
 			       toplevel_id);
-	g_settings_set_boolean (applet_info->settings,
-				PANEL_OBJECT_PACK_END_KEY,
-				right_stick);
+	g_settings_set_enum (applet_info->settings,
+			     PANEL_OBJECT_PACK_KEY,
+			     right_stick ? PANEL_OBJECT_PACK_END : PANEL_OBJECT_PACK_START);
 	g_settings_set_int (applet_info->settings,
 			    PANEL_OBJECT_POSITION_KEY,
 			    position);
@@ -950,8 +950,9 @@ panel_applet_register (GtkWidget       *applet,
 		       gpointer         data,
 		       GDestroyNotify   data_destroy)
 {
-	AppletInfo *info;
-	int         pos;
+	AppletInfo      *info;
+	int              pos;
+	PanelObjectPack  pack;
 	
 	g_return_val_if_fail (applet != NULL && panel != NULL, NULL);
 
@@ -978,7 +979,8 @@ panel_applet_register (GtkWidget       *applet,
 
 	/* Find where to insert the applet */
         pos = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY);
-        if (g_settings_get_boolean (info->settings, PANEL_OBJECT_PACK_END_KEY)) {
+        pack = g_settings_get_enum (info->settings, PANEL_OBJECT_PACK_KEY);
+        if (pack == PANEL_OBJECT_PACK_END) {
                 if (!panel->packed)
                         pos = panel->size - pos;
                 else
@@ -1069,5 +1071,5 @@ panel_applet_can_freely_move (AppletInfo *applet)
 	        g_settings_is_writable (applet->settings,
 					PANEL_OBJECT_POSITION_KEY) &&
 	        g_settings_is_writable (applet->settings,
-					PANEL_OBJECT_PACK_END_KEY));
+					PANEL_OBJECT_PACK_KEY));
 }
diff --git a/gnome-panel/panel-enums-gsettings.h b/gnome-panel/panel-enums-gsettings.h
index 4f2f8a0..6ac6c1c 100644
--- a/gnome-panel/panel-enums-gsettings.h
+++ b/gnome-panel/panel-enums-gsettings.h
@@ -29,6 +29,10 @@
 
 G_BEGIN_DECLS
 
+typedef enum {
+	PANEL_OBJECT_PACK_START = 0,
+	PANEL_OBJECT_PACK_END   = 1
+} PanelObjectPack;
 
 typedef enum {
 	PANEL_ORIENTATION_TOP    = 1 << 0,
@@ -37,7 +41,6 @@ typedef enum {
 	PANEL_ORIENTATION_LEFT   = 1 << 3
 } PanelOrientation;
 
-
 typedef enum {
 	PANEL_ANIMATION_SLOW   = 0,
 	PANEL_ANIMATION_MEDIUM = 1,
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index ea9ce89..95fbc44 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -110,7 +110,7 @@ static PanelLayoutKeyDefinition panel_layout_object_keys[] = {
         { PANEL_OBJECT_IID_KEY,         G_TYPE_STRING   },
         { PANEL_OBJECT_TOPLEVEL_ID_KEY, G_TYPE_STRING   },
         { PANEL_OBJECT_POSITION_KEY,    G_TYPE_INT      },
-        { PANEL_OBJECT_PACK_END_KEY,    G_TYPE_BOOLEAN  }
+        { PANEL_OBJECT_PACK_KEY,        G_TYPE_STRING   }
 };
 
 static gboolean
@@ -674,9 +674,9 @@ panel_layout_object_create_start (PanelObjectType   type,
         g_settings_set_int (settings_object,
                             PANEL_OBJECT_POSITION_KEY,
                             position);
-        g_settings_set_boolean (settings_object,
-                                PANEL_OBJECT_PACK_END_KEY,
-                                pack_end);
+        g_settings_set_enum (settings_object,
+                             PANEL_OBJECT_PACK_KEY,
+                             pack_end ? PANEL_OBJECT_PACK_END : PANEL_OBJECT_PACK_START);
 
         g_free (iid);
 
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index 1610bd3..cafa7d5 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -244,6 +244,7 @@ panel_object_loader_queue (const char *id,
         PanelObjectToLoad *object;
         GSettings         *settings;
         char              *toplevel_id;
+        PanelObjectPack    pack;
 
         if (panel_object_loader_is_queued (id))
                 return;
@@ -260,6 +261,8 @@ panel_object_loader_queue (const char *id,
                 return;
         }
 
+        pack = g_settings_get_enum (settings, PANEL_OBJECT_PACK_KEY);
+
         object = g_new0 (PanelObjectToLoad, 1);
 
         object->id            = g_strdup (id);
@@ -268,8 +271,7 @@ panel_object_loader_queue (const char *id,
         object->toplevel_id   = toplevel_id;
         object->position      = g_settings_get_int (settings,
                                                     PANEL_OBJECT_POSITION_KEY);
-        object->right_stick   = g_settings_get_boolean (settings,
-                                                        PANEL_OBJECT_PACK_END_KEY);
+        object->right_stick   = (pack == PANEL_OBJECT_PACK_END);
 
         panel_objects_to_load = g_slist_prepend (panel_objects_to_load, object);
 
diff --git a/gnome-panel/panel-schemas.h b/gnome-panel/panel-schemas.h
index 380c8fd..aa41eb0 100644
--- a/gnome-panel/panel-schemas.h
+++ b/gnome-panel/panel-schemas.h
@@ -64,7 +64,7 @@
 #define PANEL_OBJECT_IID_KEY            "object-iid"
 #define PANEL_OBJECT_TOPLEVEL_ID_KEY    "toplevel-id"
 #define PANEL_OBJECT_POSITION_KEY       "position"
-#define PANEL_OBJECT_PACK_END_KEY       "pack-end"
+#define PANEL_OBJECT_PACK_KEY           "pack"
 
 #define PANEL_LAUNCHER_SCHEMA      "org.gnome.gnome-panel.launcher"
 #define PANEL_LOCATION_KEY         "location"



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