summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mate-panel/drawer.c17
-rw-r--r--mate-panel/launcher.c10
-rw-r--r--mate-panel/panel-action-button.c7
-rw-r--r--mate-panel/panel-applet-frame.c7
-rw-r--r--mate-panel/panel-menu-bar.c7
-rw-r--r--mate-panel/panel-menu-button.c7
-rw-r--r--mate-panel/panel-separator.c7
-rw-r--r--mate-panel/panel-widget.c53
-rw-r--r--mate-panel/panel-widget.h7
9 files changed, 114 insertions, 8 deletions
diff --git a/mate-panel/drawer.c b/mate-panel/drawer.c
index 677d0734..edca5096 100644
--- a/mate-panel/drawer.c
+++ b/mate-panel/drawer.c
@@ -623,9 +623,14 @@ panel_drawer_create (PanelToplevel *toplevel,
const char *tooltip)
{
char *id;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
id = panel_profile_prepare_object (PANEL_OBJECT_DRAWER, toplevel, position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
panel_drawer_prepare (id, custom_icon, use_custom_icon, tooltip, NULL);
@@ -643,9 +648,17 @@ panel_drawer_create_with_id (const char *toplevel_id,
{
char *id;
char *attached_toplevel_id = NULL;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+ PanelToplevel *toplevel;
+
+ toplevel = panel_profile_get_toplevel_by_id (toplevel_id);
+ if (toplevel)
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
id = panel_profile_prepare_object_with_id (PANEL_OBJECT_DRAWER, toplevel_id, position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
panel_drawer_prepare (id, custom_icon, use_custom_icon, tooltip, &attached_toplevel_id);
diff --git a/mate-panel/launcher.c b/mate-panel/launcher.c
index 54a824ac..2732aa85 100644
--- a/mate-panel/launcher.c
+++ b/mate-panel/launcher.c
@@ -1094,13 +1094,21 @@ panel_launcher_create_with_id (const char *toplevel_id,
char *id;
char *no_uri;
char *new_location;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+ PanelToplevel *toplevel;
g_return_if_fail (location != NULL);
+ toplevel = panel_profile_get_toplevel_by_id (toplevel_id);
+ if (toplevel)
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
+
id = panel_profile_prepare_object_with_id (PANEL_OBJECT_LAUNCHER,
toplevel_id,
position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH, id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff --git a/mate-panel/panel-action-button.c b/mate-panel/panel-action-button.c
index 8135132b..ba598ea7 100644
--- a/mate-panel/panel-action-button.c
+++ b/mate-panel/panel-action-button.c
@@ -944,9 +944,14 @@ panel_action_button_create (PanelToplevel *toplevel,
GSettings *settings;
char *id;
char *path;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
id = panel_profile_prepare_object (PANEL_OBJECT_ACTION, toplevel, position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff --git a/mate-panel/panel-applet-frame.c b/mate-panel/panel-applet-frame.c
index c1f20c3e..b175f787 100644
--- a/mate-panel/panel-applet-frame.c
+++ b/mate-panel/panel-applet-frame.c
@@ -1093,11 +1093,16 @@ mate_panel_applet_frame_create (PanelToplevel *toplevel,
GSettings *settings;
gchar *path;
char *id;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
g_return_if_fail (iid != NULL);
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
+
id = panel_profile_prepare_object (PANEL_OBJECT_APPLET, toplevel, position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c
index 1d9b6979..28ef9084 100644
--- a/mate-panel/panel-menu-bar.c
+++ b/mate-panel/panel-menu-bar.c
@@ -385,9 +385,14 @@ void panel_menu_bar_load_from_gsettings (PanelWidget* panel, gboolean locked, in
void panel_menu_bar_create(PanelToplevel* toplevel, int position)
{
char* id;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+
+ panel_widget_get_insert_at_pos(panel_toplevel_get_panel_widget(toplevel),
+ &pack_type, &pack_index, position);
id = panel_profile_prepare_object(PANEL_OBJECT_MENU_BAR, toplevel, position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
panel_profile_add_to_list(PANEL_GSETTINGS_OBJECTS, id);
g_free(id);
}
diff --git a/mate-panel/panel-menu-button.c b/mate-panel/panel-menu-button.c
index c7e2fd31..52dad972 100644
--- a/mate-panel/panel-menu-button.c
+++ b/mate-panel/panel-menu-button.c
@@ -974,9 +974,14 @@ panel_menu_button_create (PanelToplevel *toplevel,
gchar *path;
const char *scheme;
char *id;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
id = panel_profile_prepare_object (PANEL_OBJECT_MENU, toplevel, position,
- PANEL_OBJECT_PACK_START, 0);
+ pack_type, pack_index);
path = g_strdup_printf (PANEL_OBJECT_PATH "%s/", id);
settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA, path);
diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c
index a9544726..5893ac32 100644
--- a/mate-panel/panel-separator.c
+++ b/mate-panel/panel-separator.c
@@ -263,10 +263,15 @@ panel_separator_create (PanelToplevel *toplevel,
int position)
{
char *id;
+ PanelObjectPackType pack_type = PANEL_OBJECT_PACK_START;
+ int pack_index = 0;
+
+ panel_widget_get_insert_at_pos (panel_toplevel_get_panel_widget (toplevel),
+ &pack_type, &pack_index, position);
id = panel_profile_prepare_object (PANEL_OBJECT_SEPARATOR,
toplevel,
- position, PANEL_OBJECT_PACK_START, 0);
+ position, pack_type, pack_index);
panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id);
g_free (id);
}
diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c
index 540dadc6..0e8cf7e0 100644
--- a/mate-panel/panel-widget.c
+++ b/mate-panel/panel-widget.c
@@ -1246,6 +1246,59 @@ get_applet_list_pack (PanelWidget *panel,
return ret;
}
+/* get pack type & index for insertion at a given position in panel */
+void
+panel_widget_get_insert_at_pos (PanelWidget *panel,
+ PanelObjectPackType *pack_type,
+ int *pack_index,
+ int pos)
+{
+ GList *l;
+ AppletData *ad;
+
+ g_return_if_fail (PANEL_IS_WIDGET (panel));
+
+ /* check if pos is in an object; in this case, return the pack type
+ * of the object */
+ for (l = panel->applet_list; l; l = l->next) {
+ ad = l->data;
+
+ if (ad->constrained <= pos) {
+ if (ad->constrained + ad->cells > pos) {
+ *pack_type = ad->pack_type;
+ *pack_index = ad->pack_index;
+ return;
+ }
+ } else
+ break;
+ }
+
+ if (pos <= panel->size / 2)
+ *pack_type = PANEL_OBJECT_PACK_START;
+ else
+ *pack_type = PANEL_OBJECT_PACK_END;
+
+ *pack_index = panel_widget_get_new_pack_index (panel, *pack_type);
+}
+
+/* get index for insertion with pack type */
+int
+panel_widget_get_new_pack_index (PanelWidget *panel,
+ PanelObjectPackType pack_type)
+{
+ GList *l;
+ AppletData *ad;
+ int max_pack_index = -1;
+
+ for (l = panel->applet_list; l; l = l->next) {
+ ad = l->data;
+ if (ad->pack_type == pack_type)
+ max_pack_index = MAX (max_pack_index, ad->pack_index);
+ }
+
+ return max_pack_index + 1;
+}
+
/* Note: this can only be called at the beginning of size_allocate, which means
* that ad->constrained doesn't matter yet (it will be set to the correct
* value in size_allocate). */
diff --git a/mate-panel/panel-widget.h b/mate-panel/panel-widget.h
index ed39b1f9..a9c42bfe 100644
--- a/mate-panel/panel-widget.h
+++ b/mate-panel/panel-widget.h
@@ -210,6 +210,13 @@ void panel_widget_focus (PanelWidget *panel);
PanelOrientation panel_widget_get_applet_orientation (PanelWidget *panel);
+void panel_widget_get_insert_at_pos (PanelWidget *panel,
+ PanelObjectPackType *pack_type,
+ int *pack_index,
+ int pos);
+int panel_widget_get_new_pack_index (PanelWidget *panel,
+ PanelObjectPackType pack_type);
+
void panel_widget_emit_background_changed (PanelWidget *panel);
void panel_widget_set_applet_size_constrained (PanelWidget *panel,