Commit 30f77136 authored by Paolo Bacchilega's avatar Paolo Bacchilega

add to catalog: select the last used catalog by default

parent 931268b9
......@@ -2,6 +2,7 @@ schemas_dir = join_paths(datadir, 'glib-2.0', 'schemas')
gschema_files = files(
'org.gnome.gthumb.gschema.xml',
'org.gnome.gthumb.catalogs.gschema.xml',
'org.gnome.gthumb.change-date.gschema.xml',
'org.gnome.gthumb.comments.gschema.xml',
'org.gnome.gthumb.contact-sheet.gschema.xml',
......
<!--
gThumb
Copyright © 2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<schemalist>
<schema id="org.gnome.gthumb.catalogs" path="/org/gnome/gthumb/catalogs/" gettext-domain="gthumb">
<key name="last-catalog" type="s">
<default>''</default>
</key>
</schema>
</schemalist>
......@@ -24,6 +24,7 @@
#include "dlg-add-to-catalog.h"
#include "gth-catalog.h"
#include "gth-file-source-catalogs.h"
#include "preferences.h"
#define GET_WIDGET(name) _gtk_builder_get_widget (data->builder, (name))
......@@ -91,6 +92,7 @@ typedef struct {
GthFileData *new_library;
gulong file_selection_changed_event;
guint update_selection_event;
GSettings *settings;
} DialogData;
......@@ -112,6 +114,7 @@ destroy_cb (GtkWidget *widget,
_g_object_unref (data->catalog_source);
_g_object_unref (data->new_catalog);
_g_object_unref (data->new_library);
_g_object_unref (data->settings);
g_object_unref (data->builder);
g_free (data);
}
......@@ -223,6 +226,7 @@ static void
add_selection_to_catalog (DialogData *data,
gboolean close_after_adding)
{
char *last_catalog;
GList *items;
GList *file_list;
......@@ -231,6 +235,10 @@ add_selection_to_catalog (DialogData *data,
if (data->add_data->catalog_file == NULL)
return;
last_catalog = g_file_get_uri (data->add_data->catalog_file);
g_settings_set_string (data->settings, PREF_CATALOGS_LAST_CATALOG, last_catalog);
g_free (last_catalog);
_g_object_list_unref (data->add_data->files);
data->add_data->files = NULL;
......@@ -654,6 +662,7 @@ dlg_add_to_catalog (GthBrowser *browser)
{
DialogData *data;
GtkTreeSelection *selection;
char *last_catalog;
if (gth_browser_get_dialog (browser, ADD_TO_CATALOG_DIALOG_NAME)) {
gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, ADD_TO_CATALOG_DIALOG_NAME)));
......@@ -664,6 +673,7 @@ dlg_add_to_catalog (GthBrowser *browser)
data->browser = browser;
data->builder = _gtk_builder_new_from_file ("add-to-catalog.ui", "catalogs");
data->dialog = _gtk_builder_get_widget (data->builder, "add_to_catalog_dialog");
data->settings = g_settings_new (GTHUMB_CATALOGS_SCHEMA);
gth_browser_set_dialog (browser, ADD_TO_CATALOG_DIALOG_NAME, data->dialog);
......@@ -672,13 +682,16 @@ dlg_add_to_catalog (GthBrowser *browser)
data->add_data->parent_window = data->add_data->dialog = data->dialog;
add_data_ref (data->add_data);
data->source_tree = gth_vfs_tree_new ("catalog:///");
last_catalog = g_settings_get_string (data->settings, PREF_CATALOGS_LAST_CATALOG);
data->source_tree = gth_vfs_tree_new ("catalog:///", last_catalog);
gtk_widget_show (data->source_tree);
gtk_container_add (GTK_CONTAINER (GET_WIDGET ("catalog_list_scrolled_window")), data->source_tree);
gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("catalogs_label")), data->source_tree);
update_sensitivity (data);
g_free (last_catalog);
/* Set the signals handlers. */
g_signal_connect (G_OBJECT (data->dialog),
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2019 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CATALOGS_PREFERENCES_H
#define CATALOGS_PREFERENCES_H
/* schema */
#define GTHUMB_CATALOGS_SCHEMA GTHUMB_SCHEMA ".catalogs"
/* keys */
#define PREF_CATALOGS_LAST_CATALOG "last-catalog"
#endif /* CATALOGS_PREFERENCES_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment