summaryrefslogtreecommitdiff
path: root/src/dlg-open-with.c
diff options
context:
space:
mode:
authorraveit <[email protected]>2012-11-05 17:14:51 +0100
committerraveit <[email protected]>2012-11-05 17:14:51 +0100
commite06e9b088a12dd098e11110f7d0d77ab8032e4eb (patch)
tree40a96b1b0e2ccd44771f5000e374e1920764ae59 /src/dlg-open-with.c
parent8f8784ba4ebcd8eb099c4e119a9a8d5a349efd61 (diff)
downloadengrampa-e06e9b088a12dd098e11110f7d0d77ab8032e4eb.tar.bz2
engrampa-e06e9b088a12dd098e11110f7d0d77ab8032e4eb.tar.xz
Port to gsettings
Diffstat (limited to 'src/dlg-open-with.c')
-rw-r--r--src/dlg-open-with.c83
1 files changed, 38 insertions, 45 deletions
diff --git a/src/dlg-open-with.c b/src/dlg-open-with.c
index 303a08c..3d04889 100644
--- a/src/dlg-open-with.c
+++ b/src/dlg-open-with.c
@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
#include "file-utils.h"
-#include "mateconf-utils.h"
#include "glib-utils.h"
#include "gtk-utils.h"
#include "main.h"
@@ -38,7 +37,8 @@ enum { ICON_COLUMN, TEXT_COLUMN, DATA_COLUMN, N_COLUMNS };
typedef struct {
FrWindow *window;
- GtkBuilder *builder;
+ GSettings *settings;
+ GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *o_app_tree_view;
@@ -62,14 +62,13 @@ static void
open_with__destroy_cb (GtkWidget *widget,
DialogData *data)
{
- g_object_unref (G_OBJECT (data->builder));
-
if (data->app_list != NULL)
g_list_free (data->app_list);
if (data->file_list != NULL)
path_list_free (data->file_list);
-
+ g_object_unref (data->builder);
+ g_object_unref (data->settings);
g_free (data);
}
@@ -83,7 +82,8 @@ open_cb (GtkWidget *widget,
gboolean present = FALSE;
char *command = NULL;
GList *scan;
- GSList *sscan, *editors;
+ char **editors;
+ int i;
application = gtk_entry_get_text (GTK_ENTRY (data->o_app_entry));
@@ -98,23 +98,25 @@ open_cb (GtkWidget *widget,
/* add the command to the editors list if not already present. */
- editors = eel_mateconf_get_string_list (PREF_EDIT_EDITORS);
- for (sscan = editors; sscan && ! present; sscan = sscan->next) {
- char *recent_command = sscan->data;
- if (strcmp (recent_command, application) == 0) {
- command = g_strdup (recent_command);
+ editors = g_settings_get_strv (data->settings, PREF_GENERAL_EDITORS);
+ for (i = 0; ! present && editors[i] != NULL; i++) {
+ if (strcmp (editors[i], application) == 0) {
+ command = g_strdup (editors[i]);
present = TRUE;
}
}
if (! present) {
- editors = g_slist_prepend (editors, g_strdup (application));
+ char **new_editors;
+
+ new_editors = _g_strv_prepend (editors, g_strdup (application));
command = g_strdup (application);
- eel_mateconf_set_string_list (PREF_EDIT_EDITORS, editors);
+ g_settings_set_strv (data->settings, PREF_GENERAL_EDITORS, (const gchar * const *) new_editors);
+
+ g_strfreev (new_editors);
}
- g_slist_foreach (editors, (GFunc) g_free, NULL);
- g_slist_free (editors);
+ g_strfreev (editors);
/* exec the application */
@@ -242,8 +244,8 @@ delete_recent_cb (GtkWidget *widget,
if (data->last_clicked_list == data->o_recent_tree_view) {
- char *editor;
- GSList *editors, *link;
+ char *editor;
+ char **editors;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_recent_tree_view));
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
@@ -256,17 +258,10 @@ delete_recent_cb (GtkWidget *widget,
/**/
- editors = eel_mateconf_get_string_list (PREF_EDIT_EDITORS);
- link = g_slist_find_custom (editors, editor, (GCompareFunc) strcmp);
- if (link != NULL) {
- editors = g_slist_remove_link (editors, link);
- eel_mateconf_set_string_list (PREF_EDIT_EDITORS, editors);
- g_free (link->data);
- g_slist_free (link);
- }
- g_slist_foreach (editors, (GFunc) g_free, NULL);
- g_slist_free (editors);
-
+ editors = g_settings_get_strv (data->settings, PREF_GENERAL_EDITORS);
+ if (_g_strv_remove (editors, editor))
+ g_settings_set_strv (data->settings, PREF_GENERAL_EDITORS, (const gchar * const *) editors);
+ g_strfreev (editors);
g_free (editor);
}
else if (data->last_clicked_list == data->o_app_tree_view) {
@@ -296,22 +291,23 @@ void
dlg_open_with (FrWindow *window,
GList *file_list)
{
- DialogData *data;
- GAppInfo *app;
- GList *scan, *app_names = NULL;
- GSList *sscan, *editors;
- GtkWidget *cancel_button;
- GtkTreeIter iter;
- GtkCellRenderer *renderer;
+ DialogData *data;
+ GAppInfo *app;
+ GList *scan, *app_names = NULL;
+ char **editors;
+ int i;
+ GtkWidget *cancel_button;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
- GtkIconTheme *theme;
- int icon_size;
+ GtkIconTheme *theme;
+ int icon_size;
if (file_list == NULL)
return;
data = g_new0 (DialogData, 1);
-
+ data->settings = g_settings_new (ENGRAMPA_SCHEMA_GENERAL);
data->builder = _gtk_builder_new_from_file ("open-with.ui");
if (data->builder == NULL) {
g_free (data);
@@ -472,17 +468,14 @@ dlg_open_with (FrWindow *window,
data->recent_model);
g_object_unref (G_OBJECT (data->recent_model));
- editors = eel_mateconf_get_string_list (PREF_EDIT_EDITORS);
- for (sscan = editors; sscan; sscan = sscan->next) {
- char *editor = sscan->data;
-
+ editors = g_settings_get_strv (data->settings, PREF_GENERAL_EDITORS);
+ for (i = 0; editors[i] != NULL; i++) {
gtk_list_store_append (GTK_LIST_STORE (data->recent_model), &iter);
gtk_list_store_set (GTK_LIST_STORE (data->recent_model), &iter,
- 0, editor,
+ 0, editors[i],
-1);
}
- g_slist_foreach (editors, (GFunc) g_free, NULL);
- g_slist_free (editors);
+ g_strfreev (editors);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (NULL,