[gnome-panel/wip/packed-objects: 2/17] panel: Pass the pack style of objects when adding applet to PanelWidget
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/packed-objects: 2/17] panel: Pass the pack style of objects when adding applet to PanelWidget
- Date: Thu, 31 Mar 2011 06:59:33 +0000 (UTC)
commit 772495f631796b127ff69308497c58e02db97daa
Author: Vincent Untz <vuntz gnome org>
Date: Mon Mar 28 18:02:59 2011 +0530
panel: Pass the pack style of objects when adding applet to PanelWidget
PanelWidget will soon learn how to use this.
gnome-panel/applet.c | 13 ++++---------
gnome-panel/panel-object-loader.c | 22 ++++++++++------------
gnome-panel/panel-widget.c | 19 ++++++++++++++-----
gnome-panel/panel-widget.h | 9 +++++----
4 files changed, 33 insertions(+), 30 deletions(-)
---
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index ceecb79..85a740c 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -980,22 +980,17 @@ panel_applet_register (GtkWidget *applet,
/* Find where to insert the applet */
pos = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_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
- pos = -1;
- }
/* Insert it */
- if (panel_widget_add (panel, applet, pos, TRUE) == -1 &&
- panel_widget_add (panel, applet, 0, FALSE) == -1) {
+ if (panel_widget_add (panel, applet, pos, pack, TRUE) == -1 &&
+ panel_widget_add (panel, applet, 0, PANEL_OBJECT_PACK_START, FALSE) == -1) {
GSList *l;
for (l = panels; l; l = l->next) {
panel = PANEL_WIDGET (l->data);
- if (panel_widget_add (panel, applet, 0, FALSE) != -1)
+ if (panel_widget_add (panel, applet,
+ 0, PANEL_OBJECT_PACK_START, FALSE) != -1)
break;
}
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index cafa7d5..0f0c1f6 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -48,12 +48,12 @@
#include "panel-object-loader.h"
typedef struct {
- char *id;
- char *settings_path;
- GSettings *settings;
- char *toplevel_id;
- int position;
- guint right_stick : 1;
+ char *id;
+ char *settings_path;
+ GSettings *settings;
+ char *toplevel_id;
+ int position;
+ PanelObjectPack pack;
} PanelObjectToLoad;
/* Each time those lists get both empty,
@@ -244,7 +244,6 @@ panel_object_loader_queue (const char *id,
PanelObjectToLoad *object;
GSettings *settings;
char *toplevel_id;
- PanelObjectPack pack;
if (panel_object_loader_is_queued (id))
return;
@@ -261,8 +260,6 @@ 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);
@@ -271,7 +268,8 @@ 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 = (pack == PANEL_OBJECT_PACK_END);
+ object->pack = g_settings_get_enum (settings,
+ PANEL_OBJECT_PACK_KEY);
panel_objects_to_load = g_slist_prepend (panel_objects_to_load, object);
@@ -286,8 +284,8 @@ panel_object_compare (const PanelObjectToLoad *a,
if ((c = g_strcmp0 (a->toplevel_id, b->toplevel_id)))
return c;
- else if (a->right_stick != b->right_stick)
- return b->right_stick ? -1 : 1;
+ else if (a->pack != b->pack)
+ return a->pack - b->pack; /* start < center < end */
else
return a->position - b->position;
}
diff --git a/gnome-panel/panel-widget.c b/gnome-panel/panel-widget.c
index b9fbe6a..1e60549 100644
--- a/gnome-panel/panel-widget.c
+++ b/gnome-panel/panel-widget.c
@@ -474,7 +474,8 @@ panel_widget_cadd (GtkContainer *container,
g_return_if_fail (PANEL_IS_WIDGET (container));
g_return_if_fail (GTK_IS_WIDGET (widget));
- panel_widget_add (PANEL_WIDGET (container), widget, 0, FALSE);
+ panel_widget_add (PANEL_WIDGET (container), widget,
+ 0, PANEL_OBJECT_PACK_START, FALSE);
}
static void
@@ -2227,16 +2228,24 @@ panel_widget_find_empty_pos(PanelWidget *panel, int pos)
}
int
-panel_widget_add (PanelWidget *panel,
- GtkWidget *applet,
- int pos,
- gboolean insert_at_pos)
+panel_widget_add (PanelWidget *panel,
+ GtkWidget *applet,
+ int pos,
+ PanelObjectPack pack,
+ gboolean insert_at_pos)
{
AppletData *ad = NULL;
g_return_val_if_fail (PANEL_IS_WIDGET (panel), -1);
g_return_val_if_fail (GTK_IS_WIDGET (applet), -1);
+ if (pack == PANEL_OBJECT_PACK_END) {
+ if (!panel->packed)
+ pos = panel->size - pos;
+ else
+ pos = -1;
+ }
+
ad = g_object_get_data (G_OBJECT (applet), PANEL_APPLET_DATA);
if (ad != NULL)
diff --git a/gnome-panel/panel-widget.h b/gnome-panel/panel-widget.h
index 0b13166..1890522 100644
--- a/gnome-panel/panel-widget.h
+++ b/gnome-panel/panel-widget.h
@@ -145,10 +145,11 @@ GtkWidget * panel_widget_new (PanelToplevel *toplevel,
int sz);
/*add an applet to the panel, preferably at position pos, if insert_at_pos
is on, we REALLY want to insert at the pos given by pos*/
-int panel_widget_add (PanelWidget *panel,
- GtkWidget *applet,
- int pos,
- gboolean insert_at_pos);
+int panel_widget_add (PanelWidget *panel,
+ GtkWidget *applet,
+ int pos,
+ PanelObjectPack pack,
+ gboolean insert_at_pos);
/*move applet to a different panel*/
int panel_widget_reparent (PanelWidget *old_panel,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]