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:

committed by
Sven Neumann

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>
|
2007-09-13 Nils Philippsen <nphilipp@redhat.com>
|
||||||
|
|
||||||
* app/file/file-save.[ch] (file_save)
|
* app/file/file-save.[ch] (file_save)
|
||||||
@ -8,7 +15,7 @@
|
|||||||
|
|
||||||
2007-09-13 Nils Philippsen <nphilipp@redhat.com>
|
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/core/gimp-gui.[ch] (gimp_recent_list_add_uri)
|
||||||
* app/gui/gui-vtable.c (gui_recent_list_add_uri): add
|
* 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);
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#ifndef __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__
|
#ifndef __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__
|
||||||
#define __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__
|
#define __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -47,5 +46,8 @@ G_GNUC_INTERNAL gboolean _gimp_color_profile_store_history_add (GimpColorProfil
|
|||||||
const gchar *label,
|
const gchar *label,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL void _gimp_color_profile_store_history_reorder (GimpColorProfileStore *store,
|
||||||
|
GtkTreeIter *iter);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__ */
|
#endif /* __GIMP_COLOR_PROFILE_STORE_PRIVATE_H__ */
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
#include "libgimp/libgimp-intl.h"
|
#include "libgimp/libgimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define HISTORY_SIZE 8
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -375,6 +377,65 @@ _gimp_color_profile_store_history_add (GimpColorProfileStore *store,
|
|||||||
return iter_valid;
|
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
|
static gboolean
|
||||||
gimp_color_profile_store_history_insert (GimpColorProfileStore *store,
|
gimp_color_profile_store_history_insert (GimpColorProfileStore *store,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
@ -604,9 +665,12 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpConfigWriter *writer;
|
GimpConfigWriter *writer;
|
||||||
GtkTreeModel *model = GTK_TREE_MODEL (store);
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gchar *labels[HISTORY_SIZE] = { NULL, };
|
||||||
|
gchar *filenames[HISTORY_SIZE] = { NULL, };
|
||||||
gboolean iter_valid;
|
gboolean iter_valid;
|
||||||
|
gint i;
|
||||||
|
|
||||||
writer = gimp_config_writer_new_file (filename,
|
writer = gimp_config_writer_new_file (filename,
|
||||||
TRUE,
|
TRUE,
|
||||||
@ -615,36 +679,47 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
|
|||||||
if (! writer)
|
if (! writer)
|
||||||
return FALSE;
|
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);
|
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||||
iter_valid;
|
iter_valid;
|
||||||
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
iter_valid = gtk_tree_model_iter_next (model, &iter))
|
||||||
{
|
{
|
||||||
gint type;
|
gint type;
|
||||||
|
gint index;
|
||||||
|
|
||||||
gtk_tree_model_get (model, &iter,
|
gtk_tree_model_get (model, &iter,
|
||||||
GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type,
|
GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type,
|
||||||
|
GIMP_COLOR_PROFILE_STORE_INDEX, &index,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (type == GIMP_COLOR_PROFILE_STORE_ITEM_FILE)
|
if (type == GIMP_COLOR_PROFILE_STORE_ITEM_FILE &&
|
||||||
|
index >= 0 &&
|
||||||
|
index < HISTORY_SIZE)
|
||||||
{
|
{
|
||||||
gchar *label;
|
if (labels[index] || filenames[index])
|
||||||
gchar *filename;
|
g_warning ("%s: double index %d", G_STRFUNC, index);
|
||||||
|
|
||||||
gtk_tree_model_get (model, &iter,
|
gtk_tree_model_get (model, &iter,
|
||||||
GIMP_COLOR_PROFILE_STORE_LABEL, &label,
|
GIMP_COLOR_PROFILE_STORE_LABEL,
|
||||||
GIMP_COLOR_PROFILE_STORE_FILENAME, &filename,
|
&labels[index],
|
||||||
|
GIMP_COLOR_PROFILE_STORE_FILENAME,
|
||||||
|
&filenames[index],
|
||||||
-1);
|
-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (filename && label)
|
|
||||||
|
for (i = 0; i < HISTORY_SIZE; i++)
|
||||||
{
|
{
|
||||||
gchar *uri = g_filename_to_uri (filename, NULL, NULL);
|
if (filenames[i] && labels[i])
|
||||||
|
{
|
||||||
|
gchar *uri = g_filename_to_uri (filenames[i], NULL, NULL);
|
||||||
|
|
||||||
if (uri)
|
if (uri)
|
||||||
{
|
{
|
||||||
gimp_config_writer_open (writer, "color-profile");
|
gimp_config_writer_open (writer, "color-profile");
|
||||||
gimp_config_writer_string (writer, label);
|
gimp_config_writer_string (writer, labels[i]);
|
||||||
gimp_config_writer_string (writer, uri);
|
gimp_config_writer_string (writer, uri);
|
||||||
gimp_config_writer_close (writer);
|
gimp_config_writer_close (writer);
|
||||||
|
|
||||||
@ -652,9 +727,8 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (filename);
|
g_free (filenames[i]);
|
||||||
g_free (label);
|
g_free (labels[i]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gimp_config_writer_finish (writer,
|
return gimp_config_writer_finish (writer,
|
||||||
|
Reference in New Issue
Block a user