From 80db8ac5799071e4c79ed5582f8464ccf77c14b2 Mon Sep 17 00:00:00 2001 From: Tony Houghton Date: Sat, 22 Sep 2007 23:14:51 +0100 Subject: [PATCH] Use new panels config file to decide which panels to create with -S. --- ROX-Filer/Options.xml | 4 ++-- ROX-Filer/src/choices.c | 2 +- ROX-Filer/src/main.c | 44 +++++++++++++++++++++++++++++++++++++------- ROX-Filer/src/panel.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/ROX-Filer/Options.xml b/ROX-Filer/Options.xml index b36497e1..c44b74b6 100644 --- a/ROX-Filer/Options.xml +++ b/ROX-Filer/Options.xml @@ -228,8 +228,8 @@ indicator'>If this is on then files which have one or more extended attributes s Both a panel and a pinboard are shown. - - Enter the name of the panel to show here. + + Enter the name of the panel to show here. This option is deprecated. diff --git a/ROX-Filer/src/choices.c b/ROX-Filer/src/choices.c index 7f0a16e6..7026b3fb 100644 --- a/ROX-Filer/src/choices.c +++ b/ROX-Filer/src/choices.c @@ -295,7 +295,7 @@ gchar *choices_find_xdg_path_save(const char *leaf, const char *dir, } if(site) - { + { path = g_build_filename(xdg_dir_list[0], site, NULL); if (create && !exists(path)) { diff --git a/ROX-Filer/src/main.c b/ROX-Filer/src/main.c index c504a1e9..0522fee0 100644 --- a/ROX-Filer/src/main.c +++ b/ROX-Filer/src/main.c @@ -175,7 +175,7 @@ enum { SESSION_BOTH, }; Option o_session_panel_or_pin; -Option o_session_panel_name; +Option o_session_panel_name; /* Now a comma-separated list */ Option o_session_pinboard_name; /* Always start a new filer, even if one seems to be already running */ @@ -828,7 +828,7 @@ static void xrandr_size_change(GdkScreen *screen, gpointer user_data) static void add_default_panel_and_pinboard(xmlNodePtr body) { - char *name; + const char *name; if (o_session_panel_or_pin.int_value != SESSION_PANEL_ONLY) { @@ -840,11 +840,41 @@ static void add_default_panel_and_pinboard(xmlNodePtr body) if (o_session_panel_or_pin.int_value != SESSION_PINBOARD_ONLY) { - name = o_session_panel_name.value; - if (!name[0]) - name="Default"; - - soap_add(body, "Panel", "Name", name, NULL, NULL); + gboolean use_old_option = TRUE; + GIOChannel *fp = NULL; + GError *err = NULL; + char *line = NULL; + gsize term; + char *filename = choices_find_xdg_path_load("panels", + "ROX-Filer", "rox.sourceforge.net"); + + if (filename) + fp = g_io_channel_new_file(filename, "r", &err); + while (fp && g_io_channel_read_line(fp, &line, NULL, &term, &err) == + G_IO_STATUS_NORMAL) + { + if (line && (line[term] = 0, line[0])) + { + soap_add(body, "Panel", "Name", line, NULL, NULL); + use_old_option = FALSE; + } + } + if (err) + { + g_critical(_("Unable to read '%s': %s"), + filename, err->message); + g_error_free(err); + } + if (fp) + g_io_channel_shutdown(fp, FALSE, NULL); + if (use_old_option) + { + name = o_session_panel_name.value; + if (!name[0]) + name="Default"; + soap_add(body, "Panel", "Name", name, NULL, NULL); + } + g_free(filename); } } diff --git a/ROX-Filer/src/panel.c b/ROX-Filer/src/panel.c index 3b23e082..e9f5b3ce 100644 --- a/ROX-Filer/src/panel.c +++ b/ROX-Filer/src/panel.c @@ -298,6 +298,30 @@ static void panel_load_options_from_xml(Panel *panel, xmlDocPtr doc) get_int_prop(options, "monitor", &panel->monitor); } +static void save_panels(void) +{ + char *filename = choices_find_xdg_path_save("panels", + "ROX-Filer", "rox.sourceforge.net", TRUE); + FILE *fp = fopen(filename, "w"); + + if (fp) + { + PanelSide n; + + for (n = 0; n < PANEL_NUMBER_OF_SIDES; ++n) + { + if (current_panel[n]) + fprintf(fp, "%s\n", current_panel[n]->name); + } + fclose(fp); + } + else + { + g_critical(_("Unable to save '%s'"), filename); + } + g_free(filename); +} + /* 'name' may be NULL or "" to remove the panel */ Panel *panel_new(const gchar *name, PanelSide side) { @@ -366,7 +390,10 @@ Panel *panel_new(const gchar *name, PanelSide side) } if (name == NULL || *name == '\0') + { + save_panels(); return NULL; + } panel = g_new(Panel, 1); panel->name = g_strdup(name); @@ -535,6 +562,8 @@ Panel *panel_new(const gchar *name, PanelSide side) window_put_just_above(panel->window->window, pinboard); } + save_panels(); + return panel; } -- 2.11.4.GIT