2
* Copyright (C) 2009-2010 Nick Schermer <nick@xfce.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundatoin; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundatoin, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31
#include <xfconf/xfconf.h>
32
#include <libxfce4util/libxfce4util.h>
33
#include <migrate/migrate-46.h>
34
#include <libxfce4panel/xfce-panel-macros.h>
38
#define LAUNCHER_FOLDER "launcher"
56
SNAP_POSITION_NONE, /* snapping */
59
SNAP_POSITION_E, /* right */
60
SNAP_POSITION_NE, /* top right */
61
SNAP_POSITION_EC, /* right center */
62
SNAP_POSITION_SE, /* bottom right */
65
SNAP_POSITION_W, /* left */
66
SNAP_POSITION_NW, /* top left */
67
SNAP_POSITION_WC, /* left center */
68
SNAP_POSITION_SW, /* bottom left */
71
SNAP_POSITION_NC, /* top center */
72
SNAP_POSITION_SC, /* bottom center */
73
SNAP_POSITION_N, /* top */
74
SNAP_POSITION_S, /* bottom */
81
guint plugin_id_counter;
82
guint panel_id_counter;
83
XfconfChannel *channel;
85
GPtrArray *panel_plugin_ids;
88
XfceScreenPosition panel_screen_position;
89
guint panel_transparency;
90
gboolean panel_activetrans;
97
migrate_46_panel_screen_position (XfceScreenPosition screen_position,
98
SnapPosition *snap_position,
103
*snap_position = SNAP_POSITION_NONE;
105
switch (screen_position)
108
case XFCE_SCREEN_POSITION_NW_H:
110
*snap_position = SNAP_POSITION_NW;
113
case XFCE_SCREEN_POSITION_N:
115
*snap_position = SNAP_POSITION_NC;
118
case XFCE_SCREEN_POSITION_NE_H:
120
*snap_position = SNAP_POSITION_NE;
124
case XFCE_SCREEN_POSITION_NW_V:
125
*snap_position = SNAP_POSITION_NW;
128
case XFCE_SCREEN_POSITION_W:
129
*snap_position = SNAP_POSITION_WC;
132
case XFCE_SCREEN_POSITION_SW_V:
133
*snap_position = SNAP_POSITION_SW;
137
case XFCE_SCREEN_POSITION_NE_V:
138
*snap_position = SNAP_POSITION_NE;
141
case XFCE_SCREEN_POSITION_E:
142
*snap_position = SNAP_POSITION_EC;
145
case XFCE_SCREEN_POSITION_SE_V:
146
*snap_position = SNAP_POSITION_SE;
150
case XFCE_SCREEN_POSITION_SW_H:
152
*snap_position = SNAP_POSITION_SW;
155
case XFCE_SCREEN_POSITION_S:
157
*snap_position = SNAP_POSITION_SC;
160
case XFCE_SCREEN_POSITION_SE_H:
162
*snap_position = SNAP_POSITION_SE;
166
case XFCE_SCREEN_POSITION_FLOATING_H:
178
migrate_46_panel_set_property (ConfigParser *parser,
179
const gchar *property_name,
188
if (strcmp (property_name, "size") == 0)
190
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/size", parser->panel_id_counter);
191
xfconf_channel_set_uint (parser->channel, prop, CLAMP (atoi (value), 16, 128));
193
else if (strcmp (property_name, "fullwidth") == 0)
195
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/length", parser->panel_id_counter);
196
xfconf_channel_set_uint (parser->channel, prop, (atoi (value) != 0) ? 100 : 0);
198
else if (strcmp (property_name, "screen-position") == 0)
200
parser->panel_screen_position = CLAMP (atoi (value),
201
XFCE_SCREEN_POSITION_NONE,
202
XFCE_SCREEN_POSITION_FLOATING_V);
204
else if (strcmp (property_name, "xoffset") == 0)
206
parser->panel_xoffset = MAX (0, atoi (value));
208
else if (strcmp (property_name, "yoffset") == 0)
210
parser->panel_yoffset = MAX (0, atoi (value));
212
else if (strcmp (property_name, "monitor") == 0)
214
/* in 4.4 and 4.6 we only use monitor and make no difference between monitors
215
* and screen's, so check the setup of the user to properly convert this */
216
num = MAX (0, atoi (value));
217
if (G_LIKELY (num > 0))
219
display = gdk_display_get_default ();
220
if (display != NULL && gdk_display_get_n_screens (display) > 1)
221
name = g_strdup_printf ("screen-%d", num);
223
name = g_strdup_printf ("monitor-%d", num);
225
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/output", parser->panel_id_counter);
226
xfconf_channel_set_string (parser->channel, prop, name);
230
else if (strcmp (property_name, "handlestyle") == 0)
232
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/locked", parser->panel_id_counter);
233
xfconf_channel_set_bool (parser->channel, prop, atoi (value) == 0);
235
else if (strcmp (property_name, "autohide") == 0)
237
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/autohide", parser->panel_id_counter);
238
xfconf_channel_set_bool (parser->channel, prop, (atoi (value) == 1));
240
else if (strcmp (property_name, "transparency") == 0)
242
parser->panel_transparency = CLAMP (atoi (value), 0, 100);
244
else if (strcmp (property_name, "activetrans") == 0)
246
parser->panel_activetrans = (atoi (value) == 1);
250
g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, G_MARKUP_ERROR,
251
"Unknown property \"%s\" in #%d \"panel\" element",
252
property_name, parser->panel_id_counter);
258
#define migrate_46_plugin_string(old_name, new_name, fallback) \
259
if (xfce_rc_has_entry (rc, old_name)) \
260
xfconf_channel_set_string (channel, "/" new_name, \
261
xfce_rc_read_entry (rc, old_name, fallback))
263
#define migrate_46_plugin_bool(old_name, new_name, fallback) \
264
if (xfce_rc_has_entry (rc, old_name)) \
265
xfconf_channel_set_bool (channel, "/" new_name, \
266
xfce_rc_read_bool_entry (rc, old_name, fallback))
268
#define migrate_46_plugin_uint(old_name, new_name, fallback) \
269
if (xfce_rc_has_entry (rc, old_name)) \
270
xfconf_channel_set_uint (channel, "/" new_name, \
271
xfce_rc_read_int_entry (rc, old_name, fallback))
276
migrate_46_plugin_actions (XfconfChannel *channel,
281
if (!xfce_rc_has_entry (rc, "type"))
284
type = xfce_rc_read_int_entry (rc, "types", 0);
287
case 0: /* ACTION_QUIT */
288
xfconf_channel_set_uint (channel, "/first-action", 0);
291
case 1: /* ACTION_LOCK */
292
xfconf_channel_set_uint (channel, "/first-action", 2);
295
default: /* ACTION_QUIT_LOCK */
296
xfconf_channel_set_uint (channel, "/first-action", 0);
297
xfconf_channel_set_uint (channel, "/second-action", 2);
305
migrate_46_plugin_clock (XfconfChannel *channel,
310
if (xfce_rc_has_entry (rc, "ClockType"))
312
type = xfce_rc_read_int_entry (rc, "ClockType", 0);
313
if (type == 4) /* XFCE_CLOCK_LCD */
314
type++; /* Skip CLOCK_PLUGIN_MODE_FUZZY */
315
xfconf_channel_set_uint (channel, "/mode", type);
318
migrate_46_plugin_string ("DigitalFormat", "digital-format", "%R");
319
migrate_46_plugin_string ("TooltipFormat", "tooltip-format", "%A %d %B %Y");
321
migrate_46_plugin_bool ("ShowFrame", "show-frame", TRUE);
322
migrate_46_plugin_bool ("ShowSeconds", "show-seconds", FALSE);
323
migrate_46_plugin_bool ("ShowMilitary", "show-military", FALSE);
324
migrate_46_plugin_bool ("ShowMeridiem", "show-meridiem", TRUE);
325
migrate_46_plugin_bool ("FlashSeparators", "flash-separators", FALSE);
326
migrate_46_plugin_bool ("TrueBinary", "true-binary", FALSE);
332
migrate_46_plugin_iconbox (XfconfChannel *channel,
335
/* tasklist in iconbox mode */
336
xfconf_channel_set_uint (channel, "/show-labels", FALSE);
338
migrate_46_plugin_bool ("only_hidden", "show-only-minimized", FALSE);
339
migrate_46_plugin_bool ("all_workspaces", "include-all-workspaces", TRUE);
342
* xfce_rc_write_int_entry (rc, "expand", iconbox->expand); */
348
migrate_46_plugin_launcher (XfconfChannel *channel,
362
if (xfce_rc_has_group (rc, "Global"))
364
xfce_rc_set_group (rc, "Global");
366
migrate_46_plugin_bool ("MoveFirst", "move-first", FALSE);
367
migrate_46_plugin_bool ("ArrowPosition", "arrow-position", 0);
370
g_get_current_time (&timeval);
371
array = g_ptr_array_new ();
373
for (i = 0; i < 100 /* arbitrary */; i++)
375
g_snprintf (buf, sizeof (buf), "Entry %d", i);
376
if (!xfce_rc_has_group (rc, buf))
379
xfce_rc_set_group (rc, buf);
381
g_snprintf (buf, sizeof (buf), "xfce4" G_DIR_SEPARATOR_S "panel"
382
G_DIR_SEPARATOR_S LAUNCHER_FOLDER "-%d" G_DIR_SEPARATOR_S "%ld%d.desktop",
383
plugin_id, timeval.tv_sec, i);
384
path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, buf, TRUE);
385
if (G_UNLIKELY (path == NULL))
387
g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
388
"Failed to create new launcher desktop file in \"%s\"", buf);
391
else if (g_file_test (path, G_FILE_TEST_EXISTS))
393
g_set_error (error, G_FILE_ERROR_EXIST, G_FILE_ERROR,
394
"Deasktop item \"%s\" already exists", path);
399
new_desktop = xfce_rc_simple_open (path, FALSE);
400
if (G_UNLIKELY (new_desktop == NULL))
402
g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
403
"Failed to create new desktop file \"%s\"", path);
409
xfce_rc_set_group (new_desktop, G_KEY_FILE_DESKTOP_GROUP);
411
xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TYPE,
412
G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
413
xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_NAME,
414
xfce_rc_read_entry (rc, "Name", ""));
415
xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_COMMENT,
416
xfce_rc_read_entry (rc, "Comment", ""));
417
xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_ICON,
418
xfce_rc_read_entry (rc, "Icon", ""));
419
xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_EXEC,
420
xfce_rc_read_entry (rc, "Exec", ""));
421
xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_PATH,
422
xfce_rc_read_entry (rc, "Path", ""));
423
xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TERMINAL,
424
xfce_rc_read_bool_entry (rc, "Terminal", FALSE));
425
xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY,
426
xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE));
428
xfce_rc_flush (new_desktop);
429
if (xfce_rc_is_dirty (new_desktop))
431
g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
432
"Failed to flush desktop file \"%s\"", path);
434
xfce_rc_close (new_desktop);
439
xfce_rc_close (new_desktop);
441
value = g_new0 (GValue, 1);
442
g_value_init (value, G_TYPE_STRING);
443
filename = g_strdup_printf ("%ld%d.desktop", timeval.tv_sec, i);
444
g_value_take_string (value, filename);
445
g_ptr_array_add (array, value);
448
xfconf_channel_set_arrayv (channel, "/items", array);
449
xfconf_array_free (array);
455
migrate_46_plugin_pager (XfconfChannel *channel,
458
migrate_46_plugin_uint ("rows", "rows", 1);
459
migrate_46_plugin_bool ("show-names", "show-names", FALSE);
460
migrate_46_plugin_bool ("scrolling", "workspace-scrolling", TRUE);
466
migrate_46_plugin_separator (XfconfChannel *channel,
472
if (!xfce_rc_has_entry (rc, "separator-type"))
475
type = xfce_rc_read_int_entry (rc, "separator-type", 0);
478
case 0: /* SEP_SPACE */
479
style = 0; /* SEPARATOR_PLUGIN_STYLE_TRANSPARENT */
482
case 1: /* SEP_EXPAND */
483
style = 0; /* SEPARATOR_PLUGIN_STYLE_TRANSPARENT */
484
xfconf_channel_set_bool (channel, "/expand", TRUE);
487
case 2: /* SEP_LINE */
488
style = 1; /* SEPARATOR_PLUGIN_STYLE_SEPARATOR */
491
case 3: /* SEP_HANDLE */
492
style = 2; /* SEPARATOR_PLUGIN_STYLE_HANDLE */
495
default: /* SEP_DOTS */
496
style = 3; /* SEPARATOR_PLUGIN_STYLE_DOTS */
500
xfconf_channel_set_uint (channel, "/style", style);
506
migrate_46_plugin_showdesktop (XfconfChannel *channel,
515
migrate_46_plugin_systray (XfconfChannel *channel,
518
if (xfce_rc_has_group (rc, "Global"))
520
xfce_rc_set_group (rc, "Global");
522
migrate_46_plugin_bool ("ShowFrame", "show-frame", TRUE);
523
migrate_46_plugin_uint ("Rows", "rows", 1);
526
if (xfce_rc_has_group (rc, "Applications"))
528
xfce_rc_set_group (rc, "Applications");
531
/* xfce_rc_read_bool_entry (rc, appname, hidden); */
538
migrate_46_plugin_tasklist (XfconfChannel *channel,
541
migrate_46_plugin_uint ("grouping", "grouping", 0);
542
migrate_46_plugin_bool ("all_workspaces", "include-all-workspaces", TRUE);
543
migrate_46_plugin_bool ("flat_buttons", "flat-buttons", FALSE);
544
migrate_46_plugin_bool ("show_handles", "show-handle", TRUE);
547
* xfce_rc_write_int_entry (rc, "width", tasklist->width);
548
* xfce_rc_write_bool_entry (rc, "fixed_width", tasklist->fixed_width);
549
* xfce_rc_write_bool_entry (rc, "expand", tasklist->expand); */
555
migrate_46_plugin_windowlist (XfconfChannel *channel,
558
if (xfce_rc_has_entry (rc, "urgency_notify"))
559
xfconf_channel_set_bool (channel, "/urgentcy-notification",
560
xfce_rc_read_int_entry (rc, "button_layout", 0) > 0);
562
migrate_46_plugin_uint ("button_layout", "style", 0);
563
migrate_46_plugin_bool ("show_all_workspaces", "all-workspaces", TRUE);
564
migrate_46_plugin_bool ("show_workspace_actions", "workspace-actions", FALSE);
567
* xfce_rc_read_bool_entry (rc, "show_window_icons", TRUE); */
573
migrate_46_plugin_xfce4_menu (XfconfChannel *channel,
576
migrate_46_plugin_bool ("show_menu_icons", "show-menu-icons", TRUE);
577
migrate_46_plugin_bool ("show_button_title", "show-button-title", TRUE);
578
migrate_46_plugin_string ("menu_file", "custom-menu-file", "");
579
migrate_46_plugin_string ("icon_file", "button-icon", "xfce4-panel-menu");
580
migrate_46_plugin_string ("button_title", "button-title", "");
582
if (xfce_rc_has_entry (rc, "use_default_menu"))
583
xfconf_channel_set_bool (channel, "/custom-menu",
584
!xfce_rc_read_bool_entry (rc, "use_default_menu", TRUE));
590
migrate_46_panel_add_plugin (ConfigParser *parser,
595
XfconfChannel *channel;
598
const gchar *plugin_name = name;
600
g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel));
602
/* open the old rc file of the plugin */
603
g_snprintf (base, sizeof (base), "xfce4" G_DIR_SEPARATOR_S
604
"panel" G_DIR_SEPARATOR_S "%s-%s.rc", name, id);
605
rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, base, TRUE);
607
/* open a panel with the propert base for the plugin */
608
g_snprintf (base, sizeof (base), "/plugins/plugin-%d", parser->plugin_id_counter);
609
channel = xfconf_channel_new_with_property_base (XFCE_PANEL_CHANNEL_NAME, base);
611
if (strcmp (name, "actions") == 0)
613
if (G_LIKELY (rc != NULL))
614
migrate_46_plugin_actions (channel, rc);
616
else if (strcmp (name, "clock") == 0)
618
if (G_LIKELY (rc != NULL))
619
migrate_46_plugin_clock (channel, rc);
621
else if (strcmp (name, "iconbox") == 0)
623
plugin_name = "tasklist";
624
if (G_LIKELY (rc != NULL))
625
migrate_46_plugin_iconbox (channel, rc);
627
else if (strcmp (name, "launcher") == 0)
629
if (G_LIKELY (rc != NULL))
630
migrate_46_plugin_launcher (channel, rc, parser->plugin_id_counter, error);
632
else if (strcmp (name, "pager") == 0)
634
if (G_LIKELY (rc != NULL))
635
migrate_46_plugin_pager (channel, rc);
637
else if (strcmp (name, "separator") == 0)
639
if (G_LIKELY (rc != NULL))
640
migrate_46_plugin_separator (channel, rc);
642
else if (strcmp (name, "showdesktop") == 0)
644
if (G_LIKELY (rc != NULL))
645
migrate_46_plugin_showdesktop (channel, rc);
647
else if (strcmp (name, "systray") == 0)
649
if (G_LIKELY (rc != NULL))
650
migrate_46_plugin_systray (channel, rc);
652
else if (strcmp (name, "tasklist") == 0)
654
if (G_LIKELY (rc != NULL))
655
migrate_46_plugin_tasklist (channel, rc);
657
else if (strcmp (name, "windowlist") == 0)
659
plugin_name = "windowmenu";
660
if (G_LIKELY (rc != NULL))
661
migrate_46_plugin_windowlist (channel, rc);
663
else if (strcmp (name, "xfce4-menu") == 0)
665
plugin_name = "applicationsmenu";
666
if (G_LIKELY (rc != NULL))
667
migrate_46_plugin_xfce4_menu (channel, rc);
671
/* handle other "external" plugins */
674
/* close plugin configs */
675
g_object_unref (G_OBJECT (channel));
676
if (G_LIKELY (rc != NULL))
679
/* store the (new) plugin name */
680
xfconf_channel_set_string (parser->channel, base, plugin_name);
686
migrate_46_start_element_handler (GMarkupParseContext *context,
687
const gchar *element_name,
688
const gchar **attribute_names,
689
const gchar **attribute_values,
693
ConfigParser *parser = user_data;
695
const gchar *name, *id, *value;
698
g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel));
700
switch (parser->state)
703
if (strcmp (element_name, "panels") == 0)
704
parser->state = PANELS;
708
if (strcmp (element_name, "panel") == 0)
710
parser->state = PANEL;
712
/* intialize new ids array */
713
parser->panel_plugin_ids = g_ptr_array_new ();
716
parser->panel_screen_position = XFCE_SCREEN_POSITION_NONE;
717
parser->panel_xoffset = 100;
718
parser->panel_yoffset = 100;
719
parser->panel_transparency = 100;
720
parser->panel_activetrans = FALSE;
725
if (strcmp (element_name, "properties") == 0)
726
parser->state = PROPERTIES;
727
else if (strcmp (element_name, "items") == 0)
728
parser->state = ITEMS;
732
if (strcmp (element_name, "property") == 0)
737
for (i = 0; attribute_names[i] != NULL; i++)
739
if (strcmp (attribute_names[i], "name") == 0)
740
name = attribute_values[i];
741
else if (strcmp (attribute_names[i], "value") == 0)
742
value = attribute_values[i];
745
if (G_LIKELY (name != NULL && value != NULL))
747
migrate_46_panel_set_property (parser, name, value, error);
751
g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, G_MARKUP_ERROR,
752
"Unknown property name (%s) or value (%s) in element",
759
if (strcmp (element_name, "item") == 0)
763
for (i = 0; attribute_names[i] != NULL; i++)
765
if (strcmp (attribute_names[i], "name") == 0)
766
name = attribute_values[i];
767
else if (strcmp (attribute_names[i], "id") == 0)
768
id = attribute_values[i];
771
if (G_LIKELY (name != NULL && id != NULL))
773
parser->plugin_id_counter++;
774
migrate_46_panel_add_plugin (parser, name, id, error);
776
id_value = g_new0 (GValue, 1);
777
g_value_init (id_value, G_TYPE_INT);
778
g_value_set_int (id_value, parser->plugin_id_counter);
779
g_ptr_array_add (parser->panel_plugin_ids, id_value);
783
g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, G_MARKUP_ERROR,
784
"Unknown item name (%s) or id (%s) in element",
791
g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR,
792
"Unknown start element \"%s\"", element_name);
800
migrate_46_end_element_handler (GMarkupParseContext *context,
801
const gchar *element_name,
805
ConfigParser *parser = user_data;
806
SnapPosition snap_position;
811
g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel));
813
switch (parser->state)
816
g_set_error (error, G_MARKUP_ERROR_PARSE, G_MARKUP_ERROR,
817
"Unexpected end element \"%s\"", element_name);
821
if (strcmp ("panel", element_name) == 0)
823
parser->state = PANELS;
825
/* store ids array */
826
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/plugin-ids", parser->panel_id_counter);
827
xfconf_channel_set_arrayv (parser->channel, prop, parser->panel_plugin_ids);
828
xfconf_array_free (parser->panel_plugin_ids);
830
/* translate the old screen position to a snap position and orientation */
831
migrate_46_panel_screen_position (parser->panel_screen_position,
832
&snap_position, &horizontal);
834
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/horizontal", parser->panel_id_counter);
835
xfconf_channel_set_bool (parser->channel, prop, horizontal);
837
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/position", parser->panel_id_counter);
838
position = g_strdup_printf ("p=%d;x=%d;y=%d",
840
parser->panel_xoffset,
841
parser->panel_yoffset);
842
xfconf_channel_set_string (parser->channel, prop, position);
845
/* set transparency */
846
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/leave-opacity", parser->panel_id_counter);
847
xfconf_channel_set_uint (parser->channel, prop, parser->panel_transparency);
849
g_snprintf (prop, sizeof (prop), "/panels/panel-%u/enter-opacity", parser->panel_id_counter);
850
xfconf_channel_set_uint (parser->channel, prop, parser->panel_activetrans ?
851
parser->panel_transparency : 100);
853
/* prepare for the next panel */
854
parser->panel_id_counter++;
859
if (strcmp ("panels", element_name) == 0)
861
parser->state = START;
862
xfconf_channel_set_uint (parser->channel, "/panels", parser->panel_id_counter);
867
if (strcmp ("properties", element_name) == 0)
868
parser->state = PANEL;
872
if (strcmp ("items", element_name) == 0)
873
parser->state = PANEL;
877
g_set_error (error, G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR,
878
"Unknown end element \"%s\"", element_name);
885
static GMarkupParser markup_parser =
887
migrate_46_start_element_handler,
888
migrate_46_end_element_handler,
897
migrate_46 (const gchar *filename,
902
GMarkupParseContext *context;
903
ConfigParser *parser;
904
gboolean succeed = FALSE;
906
g_return_val_if_fail (filename != NULL, FALSE);
907
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
909
if (!g_file_get_contents (filename, &contents, &length, error))
912
parser = g_slice_new0 (ConfigParser);
913
parser->state = START;
914
parser->plugin_id_counter = 0;
915
parser->panel_id_counter = 0;
916
parser->channel = xfconf_channel_new (XFCE_PANEL_CHANNEL_NAME);
918
context = g_markup_parse_context_new (&markup_parser, 0, parser, NULL);
920
if (g_markup_parse_context_parse (context, contents, length, error))
922
/* check if the entire file is parsed */
923
if (g_markup_parse_context_end_parse (context, error))
927
/* if parsing failed somehow, empty the channel so no broken config is left */
929
xfconf_channel_reset_property (parser->channel, "/", TRUE);
932
g_markup_parse_context_free (context);
933
g_object_unref (G_OBJECT (parser->channel));
934
g_slice_free (ConfigParser, parser);