Commit 73ef3804 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

panel-applet-frame: add support for initial settings

parent 2b3a16ba
......@@ -14,6 +14,7 @@ gsettings_SCHEMAS = \
org.gnome.gnome-panel.applet.window-list.gschema.xml \
org.gnome.gnome-panel.applet.workspace-switcher.gschema.xml \
org.gnome.gnome-panel.applet.clock.gschema.xml \
org.gnome.gnome-panel.applet.initial-settings.gschema.xml \
org.gnome.gnome-panel.gschema.xml \
org.gnome.gnome-panel.launcher.gschema.xml \
org.gnome.gnome-panel.menu-button.gschema.xml \
......
<schemalist>
<schema id="org.gnome.gnome-panel.applet.initial-settings">
<key name="settings" type="a{sv}">
<default>{}</default>
</key>
</schema>
</schemalist>
......@@ -1188,7 +1188,7 @@ panel_launcher_create_with_id (const char *toplevel_id,
id = panel_layout_object_create_start (PANEL_OBJECT_LAUNCHER,
NULL,
toplevel_id, pack_type, pack_index,
&settings);
NULL, &settings);
no_uri = NULL;
/* if we have an URI, it might contain escaped characters (? : etc)
......
......@@ -34,6 +34,37 @@ struct _GpAppletManager
G_DEFINE_TYPE (GpAppletManager, gp_applet_manager, PANEL_TYPE_APPLETS_MANAGER)
static GVariant *
get_initial_settings (PanelAppletFrameActivating *frame_act)
{
gchar *path;
GSettings *settings;
GVariant *initial_settings;
path = panel_applet_frame_activating_get_initial_settings_path (frame_act);
settings = g_settings_new_with_path ("org.gnome.gnome-panel.applet.initial-settings", path);
g_free (path);
initial_settings = g_settings_get_user_value (settings, "settings");
g_object_unref (settings);
return initial_settings;
}
static void
remove_initial_settings (PanelAppletFrameActivating *frame_act)
{
gchar *path;
GSettings *settings;
path = panel_applet_frame_activating_get_initial_settings_path (frame_act);
settings = g_settings_new_with_path ("org.gnome.gnome-panel.applet.initial-settings", path);
g_free (path);
g_settings_reset (settings, "settings");
g_object_unref (settings);
}
static void
get_applet_infos (GpAppletManager *manager,
const gchar *id,
......@@ -239,7 +270,7 @@ gp_applet_manager_load_applet (PanelAppletsManager *manager,
break;
}
initial_settings = NULL;
initial_settings = get_initial_settings (frame_act);
error = NULL;
applet = gp_module_applet_new (module, applet_id, settings_path,
......@@ -256,6 +287,8 @@ gp_applet_manager_load_applet (PanelAppletsManager *manager,
return FALSE;
}
remove_initial_settings (frame_act);
gp_applet_set_locked_down (applet, locked_down);
gp_applet_set_orientation (applet, orientation);
gp_applet_set_position (applet, position);
......
......@@ -732,7 +732,8 @@ panel_action_button_create (PanelToplevel *toplevel,
panel_layout_object_create (PANEL_OBJECT_ACTION,
panel_enum_to_string (type),
panel_toplevel_get_id (toplevel),
pack_type, pack_index);
pack_type, pack_index,
NULL);
}
void
......
......@@ -682,7 +682,8 @@ panel_addto_add_item (PanelAddtoDialog *dialog,
panel_applet_frame_create (dialog->panel_widget->toplevel,
dialog->insert_pack_type,
pack_index,
item_info->iid);
item_info->iid,
NULL);
break;
case PANEL_ADDTO_ACTION:
panel_action_button_create (dialog->panel_widget->toplevel,
......
......@@ -716,6 +716,19 @@ panel_applet_frame_activating_get_settings_path (PanelAppletFrameActivating *fra
return path_instance;
}
gchar *
panel_applet_frame_activating_get_initial_settings_path (PanelAppletFrameActivating *frame_act)
{
char *path;
char *path_instance;
g_object_get (frame_act->settings, "path", &path, NULL);
path_instance = g_strdup_printf ("%sinitial-settings/", path);
g_free (path);
return path_instance;
}
static void
panel_applet_frame_loading_failed_response (GtkWidget *dialog,
guint response,
......@@ -865,14 +878,16 @@ void
panel_applet_frame_create (PanelToplevel *toplevel,
PanelObjectPackType pack_type,
int pack_index,
const char *iid)
const char *iid,
GVariant *initial_settings)
{
g_return_if_fail (iid != NULL);
panel_layout_object_create (PANEL_OBJECT_APPLET,
iid,
panel_toplevel_get_id (toplevel),
pack_type, pack_index);
pack_type, pack_index,
initial_settings);
}
gboolean
......
......@@ -79,7 +79,8 @@ GType panel_applet_frame_get_type (void) G_GNUC_CONST;
void panel_applet_frame_create (PanelToplevel *toplevel,
PanelObjectPackType pack_type,
int pack_index,
const char *iid);
const char *iid,
GVariant *initial_settings);
void panel_applet_frame_load (PanelWidget *panel_widget,
const char *id,
......@@ -99,6 +100,7 @@ typedef struct _PanelAppletFrameActivating PanelAppletFrameActivating;
PanelOrientation panel_applet_frame_activating_get_orientation (PanelAppletFrameActivating *frame_act);
gboolean panel_applet_frame_activating_get_locked_down (PanelAppletFrameActivating *frame_act);
gchar *panel_applet_frame_activating_get_settings_path (PanelAppletFrameActivating *frame_act);
gchar *panel_applet_frame_activating_get_initial_settings_path (PanelAppletFrameActivating *frame_act);
void _panel_applet_frame_set_iid (PanelAppletFrame *frame,
const gchar *iid);
......
......@@ -646,13 +646,14 @@ panel_layout_object_create (PanelObjectType type,
const char *type_detail,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index)
int pack_index,
GVariant *initial_settings)
{
char *id;
id = panel_layout_object_create_start (type, type_detail,
toplevel_id, pack_type, pack_index,
NULL);
initial_settings, NULL);
if (!id)
return;
......@@ -719,6 +720,7 @@ panel_layout_object_create_start (PanelObjectType type,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index,
GVariant *initial_settings,
GSettings **settings)
{
char *unique_id;
......@@ -757,6 +759,17 @@ panel_layout_object_create_start (PanelObjectType type,
PANEL_OBJECT_PACK_INDEX_KEY,
pack_index);
if (initial_settings != NULL) {
GSettings *tmp;
path = g_strdup_printf ("%s%s/initial-settings/", PANEL_LAYOUT_OBJECT_PATH, unique_id);
tmp = g_settings_new_with_path ("org.gnome.gnome-panel.applet.initial-settings", path);
g_free (path);
g_settings_set_value (tmp, "settings", initial_settings);
g_object_unref (tmp);
}
g_free (try_id);
g_free (iid);
......
......@@ -41,7 +41,8 @@ void panel_layout_object_create (PanelObjectType type,
const char *type_detail,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index);
int pack_index,
GVariant *initial_settings);
char *panel_layout_object_get_gconf_path (const char *object_id);
GSettings *panel_layout_get_instance_settings (GSettings *settings_object,
......@@ -52,6 +53,7 @@ char *panel_layout_object_create_start (PanelObjectType type,
const char *toplevel_id,
PanelObjectPackType pack_type,
int pack_index,
GVariant *initial_settings,
GSettings **settings);
void panel_layout_object_create_finish (const char *object_id);
......
......@@ -794,7 +794,7 @@ panel_menu_button_create (PanelToplevel *toplevel,
id = panel_layout_object_create_start (PANEL_OBJECT_MENU, NULL,
panel_toplevel_get_id (toplevel),
pack_type, pack_index,
&settings);
NULL, &settings);
settings_instance = panel_layout_get_instance_settings (settings,
PANEL_MENU_BUTTON_SCHEMA);
......
......@@ -512,7 +512,7 @@ drop_nautilus_desktop_uri (PanelWidget *panel,
if (strncmp (basename, "trash", strlen ("trash")) == 0)
panel_applet_frame_create (panel->toplevel, pack_type, pack_index,
"OAFIID:GNOME_Panel_TrashApplet");
"OAFIID:GNOME_Panel_TrashApplet", NULL);
else if (strncmp (basename, "home", strlen ("home")) == 0) {
char *name;
char *uri_tmp;
......@@ -1081,7 +1081,7 @@ panel_receive_dnd_data (PanelWidget *panel,
if (panel_layout_is_writable ()) {
panel_applet_frame_create (panel->toplevel,
pack_type, pack_index,
(char *) data);
(char *) data, NULL);
success = TRUE;
} else {
success = FALSE;
......
# List of source files that should *not* be translated.
# Please keep this file sorted alphabetically.
data/org.gnome.gnome-panel.applet.initial-settings.gschema.xml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment