Use ~/.config to save and load preferences
This commit is contained in:
parent
a263c7615f
commit
8efa57d525
30
src/panel.c
30
src/panel.c
|
@ -137,8 +137,6 @@ static void _panel_reset(Panel * panel, GdkRectangle * rect);
|
|||
/* helpers */
|
||||
#include "helper.c"
|
||||
|
||||
static String * _config_get_filename(void);
|
||||
|
||||
|
||||
/* public */
|
||||
/* panel_new */
|
||||
|
@ -207,7 +205,6 @@ static int _new_config(Panel * panel)
|
|||
size_t i;
|
||||
gint width;
|
||||
gint height;
|
||||
String * filename;
|
||||
|
||||
for(i = 0; i < sizeof(_panel_sizes) / sizeof(*_panel_sizes); i++)
|
||||
{
|
||||
|
@ -221,12 +218,10 @@ static int _new_config(Panel * panel)
|
|||
}
|
||||
if((panel->config = config_new()) == NULL)
|
||||
return -1;
|
||||
if((filename = _config_get_filename()) == NULL)
|
||||
return -1;
|
||||
if(config_load(panel->config, filename) != 0)
|
||||
if(config_load_preferences(panel->config, PANEL_CONFIG_VENDOR,
|
||||
PACKAGE, PANEL_CONFIG_FILE) != 0)
|
||||
/* we can ignore this error */
|
||||
panel_error(NULL, _("Could not load configuration"), 1);
|
||||
string_delete(filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -651,14 +646,8 @@ static void _reset_on_idle_load(Panel * panel, PanelPosition position)
|
|||
/* panel_save */
|
||||
int panel_save(Panel * panel)
|
||||
{
|
||||
int ret;
|
||||
String * filename;
|
||||
|
||||
if((filename = _config_get_filename()) == NULL)
|
||||
return -1;
|
||||
ret = config_save(panel->config, filename);
|
||||
string_delete(filename);
|
||||
return ret;
|
||||
return config_save_preferences_user(panel->config, PANEL_CONFIG_VENDOR,
|
||||
PACKAGE, PANEL_CONFIG_FILE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1399,17 +1388,6 @@ static void _preferences_on_panel_up(gpointer data)
|
|||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* config_get_filename */
|
||||
static String * _config_get_filename(void)
|
||||
{
|
||||
char const * homedir;
|
||||
|
||||
if((homedir = getenv("HOME")) == NULL)
|
||||
homedir = g_get_home_dir();
|
||||
return string_new_format("%s/%s", homedir, PANEL_CONFIG_FILE);
|
||||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* panel_can_shutdown */
|
||||
static gboolean _panel_can_shutdown(void)
|
||||
|
|
17
src/panel.h
17
src/panel.h
|
@ -18,15 +18,17 @@
|
|||
#ifndef PANEL_PANEL_H
|
||||
# define PANEL_PANEL_H
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
# include <System/string.h>
|
||||
# include <Desktop.h>
|
||||
# include "../include/Panel/panel.h"
|
||||
# include "../config.h"
|
||||
|
||||
|
||||
/* Panel */
|
||||
/* types */
|
||||
typedef struct _PanelPrefs
|
||||
{
|
||||
char const * iconsize;
|
||||
String const * iconsize;
|
||||
int monitor;
|
||||
} PanelPrefs;
|
||||
|
||||
|
@ -34,7 +36,8 @@ typedef struct _PanelPrefs
|
|||
/* constants */
|
||||
# define PANEL_BORDER_WIDTH 4
|
||||
|
||||
# define PANEL_CONFIG_FILE ".panel"
|
||||
# define PANEL_CONFIG_FILE "Panel.conf"
|
||||
# define PANEL_CONFIG_VENDOR "DeforaOS/" VENDOR
|
||||
|
||||
# define PANEL_ICON_SIZE_DEFAULT "panel-large"
|
||||
# define PANEL_ICON_SIZE_UNSET NULL
|
||||
|
@ -48,12 +51,12 @@ Panel * panel_new(PanelPrefs const * prefs);
|
|||
void panel_delete(Panel * panel);
|
||||
|
||||
/* accessors */
|
||||
char const * panel_get_config(Panel * panel, char const * section,
|
||||
char const * variable);
|
||||
String const * panel_get_config(Panel * panel, String const * section,
|
||||
String const * variable);
|
||||
|
||||
/* useful */
|
||||
int panel_error(Panel * panel, char const * message, int ret);
|
||||
int panel_load(Panel * panel, PanelPosition position, char const * applet);
|
||||
int panel_error(Panel * panel, String const * message, int ret);
|
||||
int panel_load(Panel * panel, PanelPosition position, String const * applet);
|
||||
int panel_reset(Panel * panel);
|
||||
int panel_save(Panel * panel);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user