diff options
author | Brent Hull <[email protected]> | 2012-11-15 14:23:32 -0500 |
---|---|---|
committer | Brent Hull <[email protected]> | 2012-11-15 14:23:32 -0500 |
commit | 1aa6079a48aacd1b495f6944848e3d432a4b115d (patch) | |
tree | c185cf295dfd1d80ffd4792088e179d001ae39a2 /logview | |
parent | 381d345351f1d3a0fb34bb125f1411af61ce67ad (diff) | |
download | mate-utils-1aa6079a48aacd1b495f6944848e3d432a4b115d.tar.bz2 mate-utils-1aa6079a48aacd1b495f6944848e3d432a4b115d.tar.xz |
Port logview to Gsettings (based on GNOME patches)
Diffstat (limited to 'logview')
-rw-r--r-- | logview/Makefile.am | 13 | ||||
-rw-r--r-- | logview/data/Makefile.am | 22 | ||||
-rw-r--r-- | logview/data/mate-system-log.schemas.in | 80 | ||||
-rw-r--r-- | logview/data/org.mate.system-log.gschema.xml.in | 34 | ||||
-rw-r--r-- | logview/logview-app.c | 13 | ||||
-rw-r--r-- | logview/logview-manager.c | 10 | ||||
-rw-r--r-- | logview/logview-manager.h | 3 | ||||
-rw-r--r-- | logview/logview-prefs.c | 286 | ||||
-rw-r--r-- | logview/logview-prefs.h | 2 |
9 files changed, 169 insertions, 294 deletions
diff --git a/logview/Makefile.am b/logview/Makefile.am index b12cf217..ab9fa458 100644 --- a/logview/Makefile.am +++ b/logview/Makefile.am @@ -1,8 +1,6 @@ SUBDIRS = data help tests INCLUDES = \ - $(MATE_UTILS_CFLAGS) \ - $(GTHREAD_CFLAGS) \ -DG_LOG_DOMAIN=\"mate-system-log\" \ -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DDATADIR=\""$(datadir)"\" \ @@ -42,9 +40,18 @@ mate_system_log_SOURCES = \ logview-filter-manager.c \ $(BUILT_SOURCES) +mate_system_log_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GTHREAD_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GTK_CFLAGS) \ + $(NULL) + mate_system_log_LDADD = \ - $(MATE_UTILS_LIBS) \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ $(GTHREAD_LIBS) \ + $(GTK_LIBS) \ $(Z_LIBS) \ -lm diff --git a/logview/data/Makefile.am b/logview/data/Makefile.am index 04efb96a..eb96fcbb 100644 --- a/logview/data/Makefile.am +++ b/logview/data/Makefile.am @@ -10,27 +10,21 @@ $(desktop_in_files): $(desktop_in_files:.desktop.in=.desktop.in.in) man_MANS = mate-system-log.1 -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = mate-system-log.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) -@INTLTOOL_SCHEMAS_RULE@ +gsettingsschema_in_files = org.mate.system-log.gschema.xml.in +gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml) +.PRECIOUS: $(gsettings_SCHEMAS) -install-data-local: $(schemas_DATA) -if MATECONF_SCHEMAS_INSTALL - if test -z "$(DESTDIR)" ; then \ - for p in $^ ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $$p 2>&1 > /dev/null; \ - done \ - fi -endif +@INTLTOOL_XML_NOMERGE_RULE@ + +@GSETTINGS_RULES@ EXTRA_DIST = \ mate-system-log.desktop.in.in \ $(xml_DATA) \ $(man_MANS) \ - $(schemas_in_files) + $(gsettingsschema_in_files) DISTCLEANFILES = \ $(desktop_DATA) \ $(desktop_in_files) \ - $(schemas_DATA) + $(gsettings_SCHEMAS) diff --git a/logview/data/mate-system-log.schemas.in b/logview/data/mate-system-log.schemas.in deleted file mode 100644 index 7961605f..00000000 --- a/logview/data/mate-system-log.schemas.in +++ /dev/null @@ -1,80 +0,0 @@ -<mateconfschemafile> - - <schemalist> - <schema> - <key>/schemas/apps/mate-system-log/logfile</key> - <applyto>/apps/mate-system-log/logfile</applyto> - <owner>logview</owner> - <type>string</type> - <default>/var/log/messages</default> - <locale name="C"> - <short>Log file to open up on startup</short> - <long>Specifies the log file displayed at startup. - The default is either /var/adm/messages or - /var/log/messages, depending on your - operating system. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/mate-system-log/fontsize</key> - <applyto>/apps/mate-system-log/fontsize</applyto> - <owner>logview</owner> - <type>int</type> - <default>10</default> - <locale name="C"> - <short>Size of the font used to display the log</short> - <long>Specifies the size of the fixed-width font used - to display the log in the main tree view. - The default is taken from the default terminal - font size. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/mate-system-log/height</key> - <applyto>/apps/mate-system-log/height</applyto> - <owner>logview</owner> - <type>int</type> - <default>400</default> - <locale name="C"> - <short>Height of the main window in pixels</short> - <long>Specifies the height of the log viewer main window - in pixels. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/mate-system-log/width</key> - <applyto>/apps/mate-system-log/width</applyto> - <owner>logview</owner> - <type>int</type> - <default>600</default> - <locale name="C"> - <short>Width of the main window in pixels</short> - <long>Specifies the width of the log viewer main window - in pixels. - </long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/mate-system-log/logfiles</key> - <applyto>/apps/mate-system-log/logfiles</applyto> - <owner>logview</owner> - <type>list</type> - <list_type>string</list_type> - <locale name="C"> - <short>Log files to open up on startup</short> - <long>Specifies a list of log files to open up at startup. - A default list is created by reading /etc/syslog.conf. - </long> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/logview/data/org.mate.system-log.gschema.xml.in b/logview/data/org.mate.system-log.gschema.xml.in new file mode 100644 index 00000000..0f00134e --- /dev/null +++ b/logview/data/org.mate.system-log.gschema.xml.in @@ -0,0 +1,34 @@ +<schemalist gettext-domain="mate-utils-2.0"> + <schema id="org.mate.system-log" path="/org/mate/system-log/"> + <key name="logfile" type="s"> + <default>'/var/log/messages'</default> + <_summary>Log file to open up on startup</_summary> + <_description>Specifies the log file displayed at startup. The default is either /var/adm/messages or /var/log/messages, depending on your operating system.</_description> + </key> + <key name="fontsize" type="i"> + <default>10</default> + <_summary>Size of the font used to display the log</_summary> + <_description>Specifies the size of the fixed-width font used to display the log in the main tree view. The default is taken from the default terminal font size.</_description> + </key> + <key name="height" type="i"> + <default>400</default> + <_summary>Height of the main window in pixels</_summary> + <_description>Specifies the height of the log viewer main window in pixels.</_description> + </key> + <key name="width" type="i"> + <default>600</default> + <_summary>Width of the main window in pixels</_summary> + <_description>Specifies the width of the log viewer main window in pixels.</_description> + </key> + <key name="logfiles" type="as"> + <default>[]</default> + <_summary>Log files to open up on startup</_summary> + <_description>Specifies a list of log files to open up at startup. A default list is created by reading /etc/syslog.conf.</_description> + </key> + <key name="filters" type="as"> + <default>[]</default> + <_summary>List of saved filters</_summary> + <_description>List of saved regexp filters</_description> + </key> + </schema> +</schemalist> diff --git a/logview/logview-app.c b/logview/logview-app.c index a13f29d4..b45f4ac5 100644 --- a/logview/logview-app.c +++ b/logview/logview-app.c @@ -338,23 +338,22 @@ logview_app_initialize (LogviewApp *app, char **log_files) if (log_files == NULL) { char *active_log; - GSList *logs; + gchar **logs; active_log = logview_prefs_get_active_logfile (priv->prefs); logs = logview_prefs_get_stored_logfiles (priv->prefs); - if (!logs) { + if (!logs || !logs[0]) { logview_app_first_time_initialize (app); } else { - logview_manager_add_logs_from_name_list (priv->manager, - logs, active_log); + logview_manager_add_logs_from_names (priv->manager, + logs, active_log); g_free (active_log); - g_slist_foreach (logs, (GFunc) g_free, NULL); - g_slist_free (logs); + g_strfreev (logs); } } else { - logview_manager_add_logs_from_names (priv->manager, log_files); + logview_manager_add_logs_from_names (priv->manager, log_files, NULL); } gtk_widget_show (GTK_WIDGET (priv->window)); diff --git a/logview/logview-manager.c b/logview/logview-manager.c index c9f460e7..4b365e77 100644 --- a/logview/logview-manager.c +++ b/logview/logview-manager.c @@ -337,17 +337,21 @@ logview_manager_add_logs_from_name_list (LogviewManager *manager, void logview_manager_add_logs_from_names (LogviewManager *manager, - char ** names) + char ** names, + const gchar *active) { int i; + gboolean set_active; g_assert (LOGVIEW_IS_MANAGER (manager)); g_assert (op == NULL); - op = multiple_creation_op_new (G_N_ELEMENTS (names)); + op = multiple_creation_op_new (g_strv_length (names)); for (i = 0; names[i]; i++) { - logview_manager_add_log_from_name (manager, names[i], FALSE, TRUE); + set_active = (active != NULL) && (!g_ascii_strcasecmp (active, names[i])); + logview_manager_add_log_from_name (manager, names[i], set_active, + TRUE); } } diff --git a/logview/logview-manager.h b/logview/logview-manager.h index 9a5fe630..b9444323 100644 --- a/logview/logview-manager.h +++ b/logview/logview-manager.h @@ -73,7 +73,8 @@ void logview_manager_add_log_from_gfile (LogviewManager *manager, GFile *file, gboolean set_active); void logview_manager_add_logs_from_names (LogviewManager *manager, - char ** names); + char ** names, + const gchar *active); void logview_manager_set_active_log (LogviewManager *manager, LogviewLog *log); LogviewLog * logview_manager_get_active_log (LogviewManager *manager); diff --git a/logview/logview-prefs.c b/logview/logview-prefs.c index 2ce0aa81..44c3d669 100644 --- a/logview/logview-prefs.c +++ b/logview/logview-prefs.c @@ -28,7 +28,6 @@ #include <sys/stat.h> #include <string.h> #include <gtk/gtk.h> -#include <mateconf/mateconf-client.h> #include "logview-prefs.h" @@ -36,17 +35,17 @@ #define LOGVIEW_DEFAULT_WIDTH 600 /* logview settings */ -#define MATECONF_DIR "/apps/mate-system-log" -#define MATECONF_WIDTH_KEY MATECONF_DIR "/width" -#define MATECONF_HEIGHT_KEY MATECONF_DIR "/height" -#define MATECONF_LOGFILE MATECONF_DIR "/logfile" -#define MATECONF_LOGFILES MATECONF_DIR "/logfiles" -#define MATECONF_FONTSIZE_KEY MATECONF_DIR "/fontsize" -#define MATECONF_FILTERS MATECONF_DIR "/filters" +#define LOGVIEW_SCHEMA "org.mate.system-log" +#define PREF_WIDTH "width" +#define PREF_HEIGHT "height" +#define PREF_LOGFILE "logfile" +#define PREF_LOGFILES "logfiles" +#define PREF_FONTSIZE "fontsize" +#define PREF_FILTERS "filters" /* desktop-wide settings */ -#define MATECONF_MONOSPACE_FONT_NAME "/desktop/mate/interface/monospace_font_name" -#define MATECONF_MENUS_HAVE_TEAROFF "/desktop/mate/interface/menus_have_tearoff" +#define MATE_MONOSPACE_FONT_NAME "monospace-font-name" +#define MATE_MENUS_HAVE_TEAROFF "menus-have-tearoff" static LogviewPrefs *singleton = NULL; @@ -71,18 +70,12 @@ static guint signals[LAST_SIGNAL] = { 0 }; (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOGVIEW_TYPE_PREFS, LogviewPrefsPrivate)) struct _LogviewPrefsPrivate { - MateConfClient *client; - - guint size_store_timeout; + GSettings *logview_prefs; + GSettings *interface_prefs; GHashTable *filters; }; -typedef struct { - int width; - int height; -} WindowSize; - G_DEFINE_TYPE (LogviewPrefs, logview_prefs, G_TYPE_OBJECT); static void @@ -92,7 +85,8 @@ do_finalize (GObject *obj) g_hash_table_destroy (prefs->priv->filters); - g_object_unref (prefs->priv->client); + g_object_unref (prefs->priv->logview_prefs); + g_object_unref (prefs->priv->interface_prefs); G_OBJECT_CLASS (logview_prefs_parent_class)->finalize (obj); } @@ -125,63 +119,29 @@ logview_prefs_class_init (LogviewPrefsClass *klass) } static void -have_tearoff_changed_cb (MateConfClient *client, - guint id, - MateConfEntry *entry, +have_tearoff_changed_cb (GSettings *settings, + gchar *key, gpointer data) { LogviewPrefs *prefs = data; + gboolean add_tearoffs; - if (entry->value && (entry->value->type == MATECONF_VALUE_BOOL)) { - gboolean add_tearoffs; - - add_tearoffs = mateconf_value_get_bool (entry->value); - g_signal_emit (prefs, signals[HAVE_TEAROFF_CHANGED], 0, add_tearoffs, NULL); - } + add_tearoffs = g_settings_get_boolean (settings, key); + g_signal_emit (prefs, signals[HAVE_TEAROFF_CHANGED], 0, add_tearoffs, NULL); } static void -monospace_font_changed_cb (MateConfClient *client, - guint id, - MateConfEntry *entry, +monospace_font_changed_cb (GSettings *settings, + gchar *key, gpointer data) { LogviewPrefs *prefs = data; + gchar *monospace_font_name; - if (entry->value && (entry->value->type == MATECONF_VALUE_STRING)) { - const gchar *monospace_font_name; - - monospace_font_name = mateconf_value_get_string (entry->value); - g_signal_emit (prefs, signals[SYSTEM_FONT_CHANGED], 0, monospace_font_name, NULL); - } -} - -static gboolean -size_store_timeout_cb (gpointer data) -{ - WindowSize *size = data; - LogviewPrefs *prefs = logview_prefs_get (); - - if (size->width > 0 && size->height > 0) { - if (mateconf_client_key_is_writable (prefs->priv->client, MATECONF_WIDTH_KEY, NULL)) - mateconf_client_set_int (prefs->priv->client, - MATECONF_WIDTH_KEY, - size->width, - NULL); - - if (mateconf_client_key_is_writable (prefs->priv->client, MATECONF_HEIGHT_KEY, NULL)) - mateconf_client_set_int (prefs->priv->client, - MATECONF_HEIGHT_KEY, - size->height, - NULL); - } - - /* reset the source id */ - prefs->priv->size_store_timeout = 0; - - g_free (size); + monospace_font_name = g_settings_get_string (settings, key); + g_signal_emit (prefs, signals[SYSTEM_FONT_CHANGED], 0, monospace_font_name, NULL); - return FALSE; + g_free (monospace_font_name); } #define DELIMITER ":" @@ -189,24 +149,24 @@ size_store_timeout_cb (gpointer data) static void load_filters (LogviewPrefs *prefs) { - GSList *node; - GSList *filters; + gchar **filters; gchar **tokens; + const gchar *str; LogviewFilter *filter; GtkTextTag *tag; GdkColor color; + gint idx; - filters = mateconf_client_get_list (prefs->priv->client, - MATECONF_FILTERS, - MATECONF_VALUE_STRING, - NULL); + filters = g_settings_get_strv (prefs->priv->logview_prefs, + PREF_FILTERS); prefs->priv->filters = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); - for (node = filters; node != NULL; node = g_slist_next (node)) { - tokens = g_strsplit (node->data, DELIMITER, MAX_TOKENS); + for (idx = 0; filters[idx] != NULL; idx++) { + str = filters[idx]; + tokens = g_strsplit (str, DELIMITER, MAX_TOKENS); filter = logview_filter_new (tokens[FILTER_NAME], tokens[FILTER_REGEX]); tag = gtk_text_tag_new (tokens[FILTER_NAME]); @@ -235,14 +195,13 @@ load_filters (LogviewPrefs *prefs) g_strfreev (tokens); } - g_slist_foreach (filters, (GFunc) g_free, NULL); - g_slist_free (filters); + g_strfreev (filters); } static void save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data) { - GSList **filters; + GPtrArray *filters; const gchar *name; LogviewFilter *filter; GdkColor *foreground; @@ -307,26 +266,27 @@ save_filter_foreach_func (gpointer key, gpointer value, gpointer user_data) g_free (regex); g_object_unref (tag); - *filters = g_slist_prepend (*filters, g_string_free (prefs_string, FALSE)); -} + g_ptr_array_add (filters, g_string_free (prefs_string, FALSE)); +} static void save_filters (LogviewPrefs *prefs) { - GSList *filters; - - filters = NULL; + GPtrArray *filters; + gchar **filters_strv; + filters = g_ptr_array_new (); g_hash_table_foreach (prefs->priv->filters, save_filter_foreach_func, - &filters); - mateconf_client_set_list (prefs->priv->client, - MATECONF_FILTERS, - MATECONF_VALUE_STRING, - filters, NULL); + filters); + g_ptr_array_add (filters, NULL); + + filters_strv = (gchar **) g_ptr_array_free (filters, FALSE); + g_settings_set_strv (prefs->priv->logview_prefs, + PREF_FILTERS, + (const gchar **) filters_strv); - g_slist_foreach (filters, (GFunc) g_free, NULL); - g_slist_free (filters); + g_strfreev (filters_strv); } static void @@ -344,17 +304,13 @@ logview_prefs_init (LogviewPrefs *self) priv = self->priv = GET_PRIVATE (self); - priv->client = mateconf_client_get_default (); - priv->size_store_timeout = 0; + priv->logview_prefs = g_settings_new (LOGVIEW_SCHEMA); + priv->interface_prefs = g_settings_new ("org.mate.interface"); - mateconf_client_notify_add (priv->client, - MATECONF_MONOSPACE_FONT_NAME, - (MateConfClientNotifyFunc) monospace_font_changed_cb, - self, NULL, NULL); - mateconf_client_notify_add (priv->client, - MATECONF_MENUS_HAVE_TEAROFF, - (MateConfClientNotifyFunc) have_tearoff_changed_cb, - self, NULL, NULL); + g_signal_connect (priv->interface_prefs, "changed::" MATE_MONOSPACE_FONT_NAME, + G_CALLBACK (monospace_font_changed_cb), self); + g_signal_connect (priv->interface_prefs, "changed::" MATE_MENUS_HAVE_TEAROFF, + G_CALLBACK (have_tearoff_changed_cb), self); load_filters (self); } @@ -374,26 +330,12 @@ void logview_prefs_store_window_size (LogviewPrefs *prefs, int width, int height) { - /* we want to be smart here: since we will get a lot of configure events - * while resizing, we schedule the real MateConf storage in a timeout. - */ - WindowSize *size; - g_assert (LOGVIEW_IS_PREFS (prefs)); - size = g_new0 (WindowSize, 1); - size->width = width; - size->height = height; - - if (prefs->priv->size_store_timeout != 0) { - /* reschedule the timeout */ - g_source_remove (prefs->priv->size_store_timeout); - prefs->priv->size_store_timeout = 0; - } - - prefs->priv->size_store_timeout = g_timeout_add (200, - size_store_timeout_cb, - size); + g_settings_set_int (prefs->priv->logview_prefs, + PREF_WIDTH, width); + g_settings_set_int (prefs->priv->logview_prefs, + PREF_HEIGHT, height); } void @@ -402,13 +344,10 @@ logview_prefs_get_stored_window_size (LogviewPrefs *prefs, { g_assert (LOGVIEW_IS_PREFS (prefs)); - *width = mateconf_client_get_int (prefs->priv->client, - MATECONF_WIDTH_KEY, - NULL); - - *height = mateconf_client_get_int (prefs->priv->client, - MATECONF_HEIGHT_KEY, - NULL); + *width = g_settings_get_int (prefs->priv->logview_prefs, + PREF_WIDTH); + *height = g_settings_get_int (prefs->priv->logview_prefs, + PREF_HEIGHT); if ((*width == 0) ^ (*height == 0)) { /* if one of the two failed, return default for both */ @@ -422,7 +361,7 @@ logview_prefs_get_monospace_font_name (LogviewPrefs *prefs) { g_assert (LOGVIEW_IS_PREFS (prefs)); - return (mateconf_client_get_string (prefs->priv->client, MATECONF_MONOSPACE_FONT_NAME, NULL)); + return (g_settings_get_string (prefs->priv->interface_prefs, MATE_MONOSPACE_FONT_NAME)); } gboolean @@ -430,39 +369,35 @@ logview_prefs_get_have_tearoff (LogviewPrefs *prefs) { g_assert (LOGVIEW_IS_PREFS (prefs)); - return (mateconf_client_get_bool (prefs->priv->client, MATECONF_MENUS_HAVE_TEAROFF, NULL)); + return (g_settings_get_boolean (prefs->priv->interface_prefs, MATE_MENUS_HAVE_TEAROFF)); } /* the elements should be freed with g_free () */ -GSList * +gchar ** logview_prefs_get_stored_logfiles (LogviewPrefs *prefs) { - GSList *retval; - g_assert (LOGVIEW_IS_PREFS (prefs)); - retval = mateconf_client_get_list (prefs->priv->client, - MATECONF_LOGFILES, - MATECONF_VALUE_STRING, - NULL); - return retval; + return g_settings_get_strv (prefs->priv->logview_prefs, + PREF_LOGFILES); } void logview_prefs_store_log (LogviewPrefs *prefs, GFile *file) { - GSList *stored_logs, *l; + gchar **stored_logs; GFile *stored; gboolean found = FALSE; + gint idx, old_size; g_assert (LOGVIEW_IS_PREFS (prefs)); g_assert (G_IS_FILE (file)); stored_logs = logview_prefs_get_stored_logfiles (prefs); - for (l = stored_logs; l; l = l->next) { - stored = g_file_parse_name (l->data); + for (idx = 0; stored_logs[idx] != NULL; idx++) { + stored = g_file_parse_name (stored_logs[idx]); if (g_file_equal (file, stored)) { found = TRUE; } @@ -475,60 +410,52 @@ logview_prefs_store_log (LogviewPrefs *prefs, GFile *file) } if (!found) { - stored_logs = g_slist_prepend (stored_logs, g_file_get_parse_name (file)); - mateconf_client_set_list (prefs->priv->client, - MATECONF_LOGFILES, - MATECONF_VALUE_STRING, - stored_logs, - NULL); + old_size = g_strv_length (stored_logs); + stored_logs = g_realloc (stored_logs, (old_size + 2) * sizeof (gchar *)); + stored_logs[old_size] = g_file_get_parse_name (file); + stored_logs[old_size + 1] = NULL; + + g_settings_set_strv (prefs->priv->logview_prefs, + PREF_LOGFILES, + (const gchar **) stored_logs); } - /* the string list is copied */ - g_slist_foreach (stored_logs, (GFunc) g_free, NULL); - g_slist_free (stored_logs); + g_strfreev (stored_logs); } void logview_prefs_remove_stored_log (LogviewPrefs *prefs, GFile *target) { - GSList *stored_logs, *l, *removed = NULL; + gchar **stored_logs; GFile *stored; + GPtrArray *new_value; + gint idx; + gboolean removed = FALSE; g_assert (LOGVIEW_IS_PREFS (prefs)); g_assert (G_IS_FILE (target)); stored_logs = logview_prefs_get_stored_logfiles (prefs); + new_value = g_ptr_array_new (); - for (l = stored_logs; l; l = l->next) { - stored = g_file_parse_name (l->data); - if (g_file_equal (stored, target)) { - removed = l; - stored_logs = g_slist_remove_link (stored_logs, l); + for (idx = 0; stored_logs[idx] != NULL; idx++) { + stored = g_file_parse_name (stored_logs[idx]); + if (!g_file_equal (stored, target)) { + g_ptr_array_add (new_value, g_strdup (stored_logs[idx])); } g_object_unref (stored); - - if (removed) { - break; - } } - if (removed) { - mateconf_client_set_list (prefs->priv->client, - MATECONF_LOGFILES, - MATECONF_VALUE_STRING, - stored_logs, - NULL); - } + g_ptr_array_add (new_value, NULL); + g_strfreev (stored_logs); + stored_logs = (gchar **) g_ptr_array_free (new_value, FALSE); - /* the string list is copied */ - g_slist_foreach (stored_logs, (GFunc) g_free, NULL); - g_slist_free (stored_logs); + g_settings_set_strv (prefs->priv->logview_prefs, + PREF_LOGFILES, + (const gchar **) stored_logs); - if (removed) { - g_free (removed->data); - g_slist_free (removed); - } + g_strfreev (stored_logs); } void @@ -537,11 +464,7 @@ logview_prefs_store_fontsize (LogviewPrefs *prefs, int fontsize) g_assert (LOGVIEW_IS_PREFS (prefs)); g_assert (fontsize > 0); - if (mateconf_client_key_is_writable (prefs->priv->client, MATECONF_FONTSIZE_KEY, NULL)) { - mateconf_client_set_int (prefs->priv->client, - MATECONF_FONTSIZE_KEY, - fontsize, NULL); - } + g_settings_set_int (prefs->priv->logview_prefs, PREF_FONTSIZE, fontsize); } int @@ -549,7 +472,7 @@ logview_prefs_get_stored_fontsize (LogviewPrefs *prefs) { g_assert (LOGVIEW_IS_PREFS (prefs)); - return mateconf_client_get_int (prefs->priv->client, MATECONF_FONTSIZE_KEY, NULL); + return g_settings_get_int (prefs->priv->logview_prefs, PREF_FONTSIZE); } void @@ -558,24 +481,17 @@ logview_prefs_store_active_logfile (LogviewPrefs *prefs, { g_assert (LOGVIEW_IS_PREFS (prefs)); - if (mateconf_client_key_is_writable (prefs->priv->client, MATECONF_LOGFILE, NULL)) { - mateconf_client_set_string (prefs->priv->client, - MATECONF_LOGFILE, - filename, - NULL); - } + g_settings_set_string (prefs->priv->logview_prefs, + PREF_LOGFILE, filename); } char * logview_prefs_get_active_logfile (LogviewPrefs *prefs) { - char *filename; - g_assert (LOGVIEW_IS_PREFS (prefs)); - filename = mateconf_client_get_string (prefs->priv->client, MATECONF_LOGFILE, NULL); - - return filename; + return g_settings_get_string (prefs->priv->logview_prefs, + PREF_LOGFILE); } GList * diff --git a/logview/logview-prefs.h b/logview/logview-prefs.h index 2d2e9e27..a56bfe7e 100644 --- a/logview/logview-prefs.h +++ b/logview/logview-prefs.h @@ -70,7 +70,7 @@ void logview_prefs_store_log (LogviewPrefs *prefs, GFile *file); void logview_prefs_remove_stored_log (LogviewPrefs *prefs, GFile *target); -GSList * logview_prefs_get_stored_logfiles (LogviewPrefs *prefs); +gchar ** logview_prefs_get_stored_logfiles (LogviewPrefs *prefs); void logview_prefs_store_fontsize (LogviewPrefs *prefs, int fontsize); int logview_prefs_get_stored_fontsize (LogviewPrefs *prefs); |