mirror of https://github.com/GNOME/gimp.git
libgimpwidgets/gimpcolorprofilestore-private.h
2007-09-13 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpcolorprofilestore-private.h * libgimpwidgets/gimpcolorprofilestore.c * libgimpwidgets/gimpcolorprofilecombobox.c: only keep the eight most recently used profiles in the history. svn path=/trunk/; revision=23529
This commit is contained in:
parent
0691f94df6
commit
574a6f7524
|
@ -1,3 +1,10 @@
|
|||
2007-09-13 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpcolorprofilestore-private.h
|
||||
* libgimpwidgets/gimpcolorprofilestore.c
|
||||
* libgimpwidgets/gimpcolorprofilecombobox.c: only keep the eight
|
||||
most recently used profiles in the history.
|
||||
|
||||
2007-09-13 Nils Philippsen <nphilipp@redhat.com>
|
||||
|
||||
* app/file/file-save.[ch] (file_save)
|
||||
|
@ -8,7 +15,7 @@
|
|||
|
||||
2007-09-13 Nils Philippsen <nphilipp@redhat.com>
|
||||
|
||||
drop own recently used files code in favour of GtkRecentManager:
|
||||
Drop own recently used files code in favour of GtkRecentManager:
|
||||
|
||||
* app/core/gimp-gui.[ch] (gimp_recent_list_add_uri)
|
||||
* app/gui/gui-vtable.c (gui_recent_list_add_uri): add
|
||||
|
|
|
@ -253,7 +253,8 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
|
|||
|
||||
priv->last_path = gtk_tree_model_get_path (model, &iter);
|
||||
|
||||
/* FIXME: update order of history */
|
||||
_gimp_color_profile_store_history_reorder (GIMP_COLOR_PROFILE_STORE (model),
|
||||
&iter);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#ifndef __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__
|
||||
#define __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -42,10 +41,13 @@ typedef enum
|
|||
} GimpColorProfileStoreColumns;
|
||||
|
||||
|
||||
G_GNUC_INTERNAL gboolean _gimp_color_profile_store_history_add (GimpColorProfileStore *store,
|
||||
const gchar *filename,
|
||||
const gchar *label,
|
||||
GtkTreeIter *iter);
|
||||
G_GNUC_INTERNAL gboolean _gimp_color_profile_store_history_add (GimpColorProfileStore *store,
|
||||
const gchar *filename,
|
||||
const gchar *label,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
G_GNUC_INTERNAL void _gimp_color_profile_store_history_reorder (GimpColorProfileStore *store,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__ */
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "libgimp/libgimp-intl.h"
|
||||
|
||||
|
||||
#define HISTORY_SIZE 8
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -375,6 +377,65 @@ _gimp_color_profile_store_history_add (GimpColorProfileStore *store,
|
|||
return iter_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_color_profile_store_history_reorder
|
||||
* @store: a #GimpColorProfileStore
|
||||
* @iter: a #GtkTreeIter
|
||||
*
|
||||
* Moves the entry pointed to by @iter to the front of the MRU list.
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
**/
|
||||
void
|
||||
_gimp_color_profile_store_history_reorder (GimpColorProfileStore *store,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
gint index;
|
||||
gboolean iter_valid;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_PROFILE_STORE (store));
|
||||
g_return_if_fail (iter != NULL);
|
||||
|
||||
model = GTK_TREE_MODEL (store);
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
GIMP_COLOR_PROFILE_STORE_INDEX, &index,
|
||||
-1);
|
||||
|
||||
if (index == 0)
|
||||
return; /* already at the top */
|
||||
|
||||
for (iter_valid = gtk_tree_model_get_iter_first (model, iter);
|
||||
iter_valid;
|
||||
iter_valid = gtk_tree_model_iter_next (model, iter))
|
||||
{
|
||||
gint type;
|
||||
gint this_index;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type,
|
||||
GIMP_COLOR_PROFILE_STORE_INDEX, &this_index,
|
||||
-1);
|
||||
|
||||
if (type == GIMP_COLOR_PROFILE_STORE_ITEM_FILE && this_index > -1)
|
||||
{
|
||||
if (this_index < index)
|
||||
{
|
||||
this_index++;
|
||||
}
|
||||
else if (this_index == index)
|
||||
{
|
||||
this_index = 0;
|
||||
}
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (store), iter,
|
||||
GIMP_COLOR_PROFILE_STORE_INDEX, this_index,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_color_profile_store_history_insert (GimpColorProfileStore *store,
|
||||
GtkTreeIter *iter,
|
||||
|
@ -436,8 +497,8 @@ gimp_color_profile_store_history_insert (GimpColorProfileStore *store,
|
|||
GIMP_COLOR_PROFILE_STORE_ITEM_TYPE,
|
||||
GIMP_COLOR_PROFILE_STORE_ITEM_FILE,
|
||||
GIMP_COLOR_PROFILE_STORE_FILENAME, filename,
|
||||
GIMP_COLOR_PROFILE_STORE_LABEL, label,
|
||||
GIMP_COLOR_PROFILE_STORE_INDEX, index,
|
||||
GIMP_COLOR_PROFILE_STORE_LABEL, label,
|
||||
GIMP_COLOR_PROFILE_STORE_INDEX, index,
|
||||
-1);
|
||||
|
||||
return iter_valid;
|
||||
|
@ -604,9 +665,12 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
|
|||
GError **error)
|
||||
{
|
||||
GimpConfigWriter *writer;
|
||||
GtkTreeModel *model = GTK_TREE_MODEL (store);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gchar *labels[HISTORY_SIZE] = { NULL, };
|
||||
gchar *filenames[HISTORY_SIZE] = { NULL, };
|
||||
gboolean iter_valid;
|
||||
gint i;
|
||||
|
||||
writer = gimp_config_writer_new_file (filename,
|
||||
TRUE,
|
||||
|
@ -615,48 +679,58 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
|
|||
if (! writer)
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: store the history in MRU order */
|
||||
model = GTK_TREE_MODEL (store);
|
||||
|
||||
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
iter_valid;
|
||||
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
||||
{
|
||||
gint type;
|
||||
gint index;
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type,
|
||||
GIMP_COLOR_PROFILE_STORE_INDEX, &index,
|
||||
-1);
|
||||
|
||||
if (type == GIMP_COLOR_PROFILE_STORE_ITEM_FILE)
|
||||
if (type == GIMP_COLOR_PROFILE_STORE_ITEM_FILE &&
|
||||
index >= 0 &&
|
||||
index < HISTORY_SIZE)
|
||||
{
|
||||
gchar *label;
|
||||
gchar *filename;
|
||||
if (labels[index] || filenames[index])
|
||||
g_warning ("%s: double index %d", G_STRFUNC, index);
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
GIMP_COLOR_PROFILE_STORE_LABEL, &label,
|
||||
GIMP_COLOR_PROFILE_STORE_FILENAME, &filename,
|
||||
GIMP_COLOR_PROFILE_STORE_LABEL,
|
||||
&labels[index],
|
||||
GIMP_COLOR_PROFILE_STORE_FILENAME,
|
||||
&filenames[index],
|
||||
-1);
|
||||
|
||||
if (filename && label)
|
||||
{
|
||||
gchar *uri = g_filename_to_uri (filename, NULL, NULL);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
gimp_config_writer_open (writer, "color-profile");
|
||||
gimp_config_writer_string (writer, label);
|
||||
gimp_config_writer_string (writer, uri);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
g_free (label);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < HISTORY_SIZE; i++)
|
||||
{
|
||||
if (filenames[i] && labels[i])
|
||||
{
|
||||
gchar *uri = g_filename_to_uri (filenames[i], NULL, NULL);
|
||||
|
||||
if (uri)
|
||||
{
|
||||
gimp_config_writer_open (writer, "color-profile");
|
||||
gimp_config_writer_string (writer, labels[i]);
|
||||
gimp_config_writer_string (writer, uri);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (filenames[i]);
|
||||
g_free (labels[i]);
|
||||
}
|
||||
|
||||
return gimp_config_writer_finish (writer,
|
||||
"end of color profile history", error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue