app/widgets/Makefile.am app/widgets/widgets-types.h new widget containing
2008-06-13 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpsettingsbox.[ch]: new widget containing the combo and menu button for the image map tool settings plus most of their logic. Has "import" and "export" signals that might go away if I figure a way to nicely abstract that. Contains some minor bugfixes and cosmetic improvements compared to the old code. * app/tools/gimpimagemaptool.[ch] * app/tools/gimpimagemaptool-settings.[ch]: changed accordingly, mostly removal of lots of code that is now in the widget. svn path=/trunk/; revision=25943
This commit is contained in:

committed by
Michael Natterer

parent
13ff88e176
commit
8912b68290
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2008-06-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpsettingsbox.[ch]: new widget containing the
|
||||
combo and menu button for the image map tool settings plus most of
|
||||
their logic. Has "import" and "export" signals that might go away
|
||||
if I figure a way to nicely abstract that. Contains some minor
|
||||
bugfixes and cosmetic improvements compared to the old code.
|
||||
|
||||
* app/tools/gimpimagemaptool.[ch]
|
||||
* app/tools/gimpimagemaptool-settings.[ch]: changed accordingly,
|
||||
mostly removal of lots of code that is now in the widget.
|
||||
|
||||
2008-06-13 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* configure.in
|
||||
|
@ -38,9 +38,7 @@
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpcontainercombobox.h"
|
||||
#include "widgets/gimpcontainerview.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
#include "widgets/gimpsettingsbox.h"
|
||||
|
||||
#include "gimpimagemapoptions.h"
|
||||
#include "gimpimagemaptool.h"
|
||||
@ -51,67 +49,23 @@
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_image_map_tool_recent_deserialize (GimpImageMapTool *im_tool);
|
||||
static void gimp_image_map_tool_recent_serialize (GimpImageMapTool *im_tool);
|
||||
static void gimp_image_map_tool_import_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool);
|
||||
static void gimp_image_map_tool_export_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool);
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_tool_row_separator_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data);
|
||||
static void gimp_image_map_tool_recent_selected (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data,
|
||||
GimpImageMapTool *tool);
|
||||
static void gimp_image_map_tool_settings_dialog (GimpImageMapTool *im_tool,
|
||||
const gchar *title,
|
||||
gboolean save);
|
||||
|
||||
static gboolean gimp_image_map_tool_menu_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpImageMapTool *tool);
|
||||
static void gimp_image_map_tool_favorite_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool);
|
||||
static void gimp_image_map_tool_import_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool);
|
||||
static void gimp_image_map_tool_export_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool);
|
||||
|
||||
static void gimp_image_map_tool_settings_dialog (GimpImageMapTool *im_tool,
|
||||
const gchar *title,
|
||||
gboolean save);
|
||||
|
||||
static void gimp_image_map_tool_favorite_callback (GtkWidget *query_box,
|
||||
const gchar *string,
|
||||
gpointer data);
|
||||
static gboolean gimp_image_map_tool_settings_import(GimpImageMapTool *tool,
|
||||
const gchar *filename);
|
||||
static gboolean gimp_image_map_tool_settings_export(GimpImageMapTool *tool,
|
||||
const gchar *filename);
|
||||
static gboolean gimp_image_map_tool_settings_import (GimpImageMapTool *tool,
|
||||
const gchar *filename);
|
||||
static gboolean gimp_image_map_tool_settings_export (GimpImageMapTool *tool,
|
||||
const gchar *filename);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
static GtkWidget *
|
||||
gimp_image_map_tool_menu_item_add (GimpImageMapTool *image_map_tool,
|
||||
const gchar *stock_id,
|
||||
const gchar *label,
|
||||
GCallback callback)
|
||||
{
|
||||
GtkWidget *item;
|
||||
GtkWidget *image;
|
||||
|
||||
item = gtk_image_menu_item_new_with_mnemonic (label);
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (image_map_tool->favorites_menu),
|
||||
item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
g_signal_connect (item, "activate",
|
||||
callback,
|
||||
image_map_tool);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
@ -119,17 +73,12 @@ gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *button;
|
||||
GtkWidget *arrow;
|
||||
gchar *filename;
|
||||
|
||||
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
|
||||
|
||||
tool_info = GIMP_TOOL (image_map_tool)->tool_info;
|
||||
|
||||
if (gimp_container_num_children (klass->recent_settings) == 0)
|
||||
gimp_image_map_tool_recent_deserialize (image_map_tool);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
|
||||
FALSE, FALSE, 0);
|
||||
@ -143,108 +92,36 @@ gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
|
||||
gtk_size_group_add_widget (image_map_tool->label_group, label);
|
||||
g_object_unref (image_map_tool->label_group);
|
||||
|
||||
combo = gimp_container_combo_box_new (klass->recent_settings,
|
||||
GIMP_CONTEXT (tool_info->tool_options),
|
||||
16, 0);
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
|
||||
gimp_image_map_tool_row_separator_func,
|
||||
NULL, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
|
||||
gtk_widget_show (combo);
|
||||
filename = gimp_tool_info_build_options_filename (tool_info, ".settings");
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||
image_map_tool->settings_box = gimp_settings_box_new (tool_info->gimp,
|
||||
image_map_tool->config,
|
||||
klass->recent_settings,
|
||||
filename);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image_map_tool->settings_box,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (image_map_tool->settings_box);
|
||||
|
||||
gimp_help_set_help_data (combo, _("Pick a setting from the list"),
|
||||
NULL);
|
||||
g_free (filename);
|
||||
|
||||
g_signal_connect_after (combo, "select-item",
|
||||
G_CALLBACK (gimp_image_map_tool_recent_selected),
|
||||
image_map_tool);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label),
|
||||
GIMP_SETTINGS_BOX (image_map_tool->settings_box)->combo);
|
||||
|
||||
button = gtk_button_new ();
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
arrow = gtk_image_new_from_stock (GIMP_STOCK_MENU_LEFT, GTK_ICON_SIZE_MENU);
|
||||
gtk_container_add (GTK_CONTAINER (button), arrow);
|
||||
gtk_widget_show (arrow);
|
||||
|
||||
g_signal_connect (button, "button-press-event",
|
||||
G_CALLBACK (gimp_image_map_tool_menu_press),
|
||||
g_signal_connect (image_map_tool->settings_box, "import",
|
||||
G_CALLBACK (gimp_image_map_tool_import_activate),
|
||||
image_map_tool);
|
||||
|
||||
/* Favorites menu */
|
||||
|
||||
image_map_tool->favorites_menu = gtk_menu_new ();
|
||||
gtk_menu_attach_to_widget (GTK_MENU (image_map_tool->favorites_menu),
|
||||
button, NULL);
|
||||
|
||||
gimp_image_map_tool_menu_item_add (image_map_tool,
|
||||
GTK_STOCK_ADD,
|
||||
_("Add Settings to _Favorites"),
|
||||
G_CALLBACK (gimp_image_map_tool_favorite_activate));
|
||||
|
||||
image_map_tool->import_item =
|
||||
gimp_image_map_tool_menu_item_add (image_map_tool,
|
||||
GTK_STOCK_OPEN,
|
||||
_("_Import Settings from File"),
|
||||
G_CALLBACK (gimp_image_map_tool_import_activate));
|
||||
|
||||
image_map_tool->export_item =
|
||||
gimp_image_map_tool_menu_item_add (image_map_tool,
|
||||
GTK_STOCK_SAVE,
|
||||
_("_Export Settings to File"),
|
||||
G_CALLBACK (gimp_image_map_tool_export_activate));
|
||||
g_signal_connect (image_map_tool->settings_box, "export",
|
||||
G_CALLBACK (gimp_image_map_tool_export_activate),
|
||||
image_map_tool);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_tool_add_recent_settings (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
GimpContainer *recent;
|
||||
GimpConfig *current;
|
||||
GimpConfig *config = NULL;
|
||||
GList *list;
|
||||
|
||||
recent = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool)->recent_settings;
|
||||
current = GIMP_CONFIG (image_map_tool->config);
|
||||
|
||||
for (list = GIMP_LIST (recent)->list; list; list = g_list_next (list))
|
||||
{
|
||||
config = list->data;
|
||||
|
||||
if (GIMP_IMAGE_MAP_CONFIG (config)->time > 0 &&
|
||||
gimp_config_is_equal_to (config, current))
|
||||
{
|
||||
g_object_set (current,
|
||||
"time", (guint) time (NULL),
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! list)
|
||||
{
|
||||
config = gimp_config_duplicate (current);
|
||||
g_object_set (config,
|
||||
"time", (guint) time (NULL),
|
||||
NULL);
|
||||
|
||||
gimp_container_insert (recent, GIMP_OBJECT (config), 0);
|
||||
g_object_unref (config);
|
||||
}
|
||||
|
||||
|
||||
gimp_image_map_tool_recent_serialize (image_map_tool);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success;
|
||||
|
||||
@ -259,9 +136,9 @@ gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
|
||||
gchar *header;
|
||||
@ -288,165 +165,6 @@ gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_separator_add (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_new (GIMP_TYPE_IMAGE_MAP_CONFIG, NULL);
|
||||
|
||||
gimp_container_add (container, sep);
|
||||
g_object_unref (sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", sep);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_separator_remove (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_get_data (G_OBJECT (container), "separator");
|
||||
|
||||
gimp_container_remove (container, sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_recent_deserialize (GimpImageMapTool *im_tool)
|
||||
{
|
||||
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
|
||||
GimpToolInfo *tool_info = GIMP_TOOL (im_tool)->tool_info;
|
||||
gchar *filename;
|
||||
GError *error = NULL;
|
||||
|
||||
filename = gimp_tool_info_build_options_filename (tool_info,
|
||||
".settings");
|
||||
|
||||
if (tool_info->gimp->be_verbose)
|
||||
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
||||
|
||||
if (! gimp_config_deserialize_file (GIMP_CONFIG (klass->recent_settings),
|
||||
filename,
|
||||
NULL, &error))
|
||||
{
|
||||
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
||||
gimp_message (tool_info->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"%s", error->message);
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
|
||||
gimp_image_map_tool_separator_add (klass->recent_settings);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_recent_serialize (GimpImageMapTool *im_tool)
|
||||
{
|
||||
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
|
||||
GimpToolInfo *tool_info = GIMP_TOOL (im_tool)->tool_info;
|
||||
gchar *filename;
|
||||
GError *error = NULL;
|
||||
|
||||
gimp_image_map_tool_separator_remove (klass->recent_settings);
|
||||
|
||||
filename = gimp_tool_info_build_options_filename (tool_info,
|
||||
".settings");
|
||||
|
||||
if (tool_info->gimp->be_verbose)
|
||||
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
||||
|
||||
if (! gimp_config_serialize_to_file (GIMP_CONFIG (klass->recent_settings),
|
||||
filename,
|
||||
"tool settings",
|
||||
"end of tool settings",
|
||||
NULL, &error))
|
||||
{
|
||||
gimp_message (tool_info->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
|
||||
gimp_image_map_tool_separator_add (klass->recent_settings);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_tool_row_separator_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *name = NULL;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: dont use magic model column
|
||||
#endif
|
||||
gtk_tree_model_get (model, iter,
|
||||
1, &name,
|
||||
-1);
|
||||
|
||||
g_free (name);
|
||||
|
||||
return name == NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_recent_selected (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data,
|
||||
GimpImageMapTool *tool)
|
||||
{
|
||||
if (object)
|
||||
{
|
||||
gimp_config_copy (GIMP_CONFIG (object),
|
||||
GIMP_CONFIG (tool->config), 0);
|
||||
|
||||
gimp_container_view_select_item (view, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_menu_position (GtkMenu *menu,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gboolean *push_in,
|
||||
gpointer user_data)
|
||||
{
|
||||
gimp_button_menu_position (user_data, menu, GTK_POS_LEFT, x, y);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_tool_menu_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpImageMapTool *tool)
|
||||
{
|
||||
if (bevent->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
gtk_menu_popup (GTK_MENU (tool->favorites_menu),
|
||||
NULL, NULL,
|
||||
gimp_image_map_tool_menu_position, widget,
|
||||
bevent->button, bevent->time);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_favorite_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gimp_query_string_box (_("Add Settings to Favorites"),
|
||||
tool->shell,
|
||||
gimp_standard_help_func, NULL,
|
||||
_("Enter a name for the settings"),
|
||||
_("Saved Settings"),
|
||||
G_OBJECT (tool->shell), "hide",
|
||||
gimp_image_map_tool_favorite_callback, tool);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_import_activate (GtkWidget *widget,
|
||||
GimpImageMapTool *tool)
|
||||
@ -489,9 +207,9 @@ settings_dialog_response (GtkWidget *dialog,
|
||||
}
|
||||
|
||||
if (save)
|
||||
gtk_widget_set_sensitive (tool->import_item, TRUE);
|
||||
gtk_widget_set_sensitive (GIMP_SETTINGS_BOX (tool->settings_box)->import_item, TRUE);
|
||||
else
|
||||
gtk_widget_set_sensitive (tool->export_item, TRUE);
|
||||
gtk_widget_set_sensitive (GIMP_SETTINGS_BOX (tool->settings_box)->export_item, TRUE);
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
@ -517,9 +235,9 @@ gimp_image_map_tool_settings_dialog (GimpImageMapTool *tool,
|
||||
}
|
||||
|
||||
if (save)
|
||||
gtk_widget_set_sensitive (tool->import_item, FALSE);
|
||||
gtk_widget_set_sensitive (GIMP_SETTINGS_BOX (tool->settings_box)->import_item, FALSE);
|
||||
else
|
||||
gtk_widget_set_sensitive (tool->export_item, FALSE);
|
||||
gtk_widget_set_sensitive (GIMP_SETTINGS_BOX (tool->settings_box)->export_item, FALSE);
|
||||
|
||||
tool->settings_dialog =
|
||||
gtk_file_chooser_dialog_new (title, GTK_WINDOW (tool->shell),
|
||||
@ -582,23 +300,6 @@ gimp_image_map_tool_settings_dialog (GimpImageMapTool *tool,
|
||||
gtk_widget_show (tool->settings_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_favorite_callback (GtkWidget *query_box,
|
||||
const gchar *string,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImageMapTool *tool = GIMP_IMAGE_MAP_TOOL (data);
|
||||
GimpConfig *config;
|
||||
|
||||
config = gimp_config_duplicate (GIMP_CONFIG (tool->config));
|
||||
gimp_object_set_name (GIMP_OBJECT (config), string);
|
||||
gimp_container_add (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->recent_settings,
|
||||
GIMP_OBJECT (config));
|
||||
g_object_unref (config);
|
||||
|
||||
gimp_image_map_tool_recent_serialize (tool);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_tool_settings_import (GimpImageMapTool *tool,
|
||||
const gchar *filename)
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
gboolean gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool);
|
||||
|
||||
void gimp_image_map_tool_add_recent_settings (GimpImageMapTool *image_map_tool);
|
||||
|
||||
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpsettingsbox.h"
|
||||
#include "widgets/gimptooldialog.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
@ -171,7 +172,7 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
||||
static void
|
||||
gimp_image_map_tool_base_init (GimpImageMapToolClass *klass)
|
||||
{
|
||||
klass->recent_settings = gimp_list_new (GIMP_TYPE_VIEWABLE, TRUE);
|
||||
klass->recent_settings = gimp_list_new (GIMP_TYPE_IMAGE_MAP_CONFIG, TRUE);
|
||||
gimp_list_set_sort_func (GIMP_LIST (klass->recent_settings),
|
||||
(GCompareFunc) gimp_image_map_config_compare);
|
||||
}
|
||||
@ -196,9 +197,8 @@ gimp_image_map_tool_init (GimpImageMapTool *image_map_tool)
|
||||
|
||||
image_map_tool->shell = NULL;
|
||||
image_map_tool->main_vbox = NULL;
|
||||
image_map_tool->favorites_menu = NULL;
|
||||
image_map_tool->import_item = NULL;
|
||||
image_map_tool->export_item = NULL;
|
||||
image_map_tool->settings_box = NULL;
|
||||
image_map_tool->label_group = NULL;
|
||||
image_map_tool->settings_dialog = NULL;
|
||||
}
|
||||
|
||||
@ -243,11 +243,10 @@ gimp_image_map_tool_finalize (GObject *object)
|
||||
if (image_map_tool->shell)
|
||||
{
|
||||
gtk_widget_destroy (image_map_tool->shell);
|
||||
image_map_tool->shell = NULL;
|
||||
image_map_tool->main_vbox = NULL;
|
||||
image_map_tool->favorites_menu = NULL;
|
||||
image_map_tool->import_item = NULL;
|
||||
image_map_tool->export_item = NULL;
|
||||
image_map_tool->shell = NULL;
|
||||
image_map_tool->main_vbox = NULL;
|
||||
image_map_tool->settings_box = NULL;
|
||||
image_map_tool->label_group = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
@ -549,7 +548,7 @@ gimp_image_map_tool_response (GtkWidget *widget,
|
||||
gimp_image_flush (tool->display->image);
|
||||
|
||||
if (image_map_tool->config)
|
||||
gimp_image_map_tool_add_recent_settings (image_map_tool);
|
||||
gimp_settings_box_add_current (GIMP_SETTINGS_BOX (image_map_tool->settings_box));
|
||||
}
|
||||
|
||||
tool->display = NULL;
|
||||
|
@ -51,9 +51,7 @@ struct _GimpImageMapTool
|
||||
/* dialog */
|
||||
GtkWidget *shell;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *favorites_menu;
|
||||
GtkWidget *import_item;
|
||||
GtkWidget *export_item;
|
||||
GtkWidget *settings_box;
|
||||
GtkSizeGroup *label_group;
|
||||
|
||||
/* settings file dialog */
|
||||
|
@ -255,6 +255,8 @@ libappwidgets_a_sources = \
|
||||
gimpsessioninfo-dock.h \
|
||||
gimpsessioninfo-dockable.c \
|
||||
gimpsessioninfo-dockable.h \
|
||||
gimpsettingsbox.c \
|
||||
gimpsettingsbox.h \
|
||||
gimpsizebox.c \
|
||||
gimpsizebox.h \
|
||||
gimpstringaction.c \
|
||||
|
598
app/widgets/gimpsettingsbox.c
Normal file
598
app/widgets/gimpsettingsbox.c
Normal file
@ -0,0 +1,598 @@
|
||||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsettingsbox.c
|
||||
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "gimpcontainercombobox.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpsettingsbox.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
IMPORT,
|
||||
EXPORT,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GIMP,
|
||||
PROP_CONFIG,
|
||||
PROP_CONTAINER,
|
||||
PROP_FILENAME
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_settings_box_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_settings_box_finalize (GObject *object);
|
||||
static void gimp_settings_box_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_settings_box_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_settings_box_deserialize (GimpSettingsBox *box);
|
||||
static void gimp_settings_box_serialize (GimpSettingsBox *box);
|
||||
static GtkWidget *
|
||||
gimp_settings_box_menu_item_add (GimpSettingsBox *box,
|
||||
const gchar *stock_id,
|
||||
const gchar *label,
|
||||
GCallback callback);
|
||||
static gboolean
|
||||
gimp_settings_box_row_separator_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data);
|
||||
static void gimp_settings_box_setting_selected (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data,
|
||||
GimpSettingsBox *box);
|
||||
static gboolean gimp_settings_box_menu_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpSettingsBox *box);
|
||||
static void gimp_settings_box_favorite_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box);
|
||||
static void gimp_settings_box_import_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box);
|
||||
static void gimp_settings_box_export_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box);
|
||||
|
||||
static void gimp_settings_box_favorite_callback (GtkWidget *query_box,
|
||||
const gchar *string,
|
||||
gpointer data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpSettingsBox, gimp_settings_box, GTK_TYPE_HBOX)
|
||||
|
||||
#define parent_class gimp_settings_box_parent_class
|
||||
|
||||
static guint settings_box_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
||||
static void
|
||||
gimp_settings_box_class_init (GimpSettingsBoxClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
settings_box_signals[IMPORT] =
|
||||
g_signal_new ("import",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpSettingsBoxClass, import),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
settings_box_signals[EXPORT] =
|
||||
g_signal_new ("export",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpSettingsBoxClass, export),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->constructor = gimp_settings_box_constructor;
|
||||
object_class->finalize = gimp_settings_box_finalize;
|
||||
object_class->set_property = gimp_settings_box_set_property;
|
||||
object_class->get_property = gimp_settings_box_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_GIMP,
|
||||
g_param_spec_object ("gimp",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_GIMP,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CONFIG,
|
||||
g_param_spec_object ("config",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_CONFIG,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CONTAINER,
|
||||
g_param_spec_object ("container",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_CONTAINER,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILENAME,
|
||||
g_param_spec_string ("filename",
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_init (GimpSettingsBox *box)
|
||||
{
|
||||
gtk_box_set_spacing (GTK_BOX (box), 6);
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_settings_box_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpSettingsBox *box;
|
||||
GtkWidget *button;
|
||||
GtkWidget *arrow;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
box = GIMP_SETTINGS_BOX (object);
|
||||
|
||||
g_assert (GIMP_IS_GIMP (box->gimp));
|
||||
g_assert (GIMP_IS_CONFIG (box->config));
|
||||
g_assert (GIMP_IS_CONTAINER (box->container));
|
||||
g_assert (box->filename != NULL);
|
||||
|
||||
if (gimp_container_num_children (box->container) == 0)
|
||||
gimp_settings_box_deserialize (box);
|
||||
|
||||
box->combo = gimp_container_combo_box_new (box->container,
|
||||
gimp_get_user_context (box->gimp),
|
||||
16, 0);
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (box->combo),
|
||||
gimp_settings_box_row_separator_func,
|
||||
NULL, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (box), box->combo, TRUE, TRUE, 0);
|
||||
gtk_widget_show (box->combo);
|
||||
|
||||
gimp_help_set_help_data (box->combo, _("Pick a setting from the list"),
|
||||
NULL);
|
||||
|
||||
g_signal_connect_after (box->combo, "select-item",
|
||||
G_CALLBACK (gimp_settings_box_setting_selected),
|
||||
box);
|
||||
|
||||
button = gtk_button_new ();
|
||||
GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
arrow = gtk_image_new_from_stock (GIMP_STOCK_MENU_LEFT, GTK_ICON_SIZE_MENU);
|
||||
gtk_container_add (GTK_CONTAINER (button), arrow);
|
||||
gtk_widget_show (arrow);
|
||||
|
||||
g_signal_connect (button, "button-press-event",
|
||||
G_CALLBACK (gimp_settings_box_menu_press),
|
||||
box);
|
||||
|
||||
/* Favorites menu */
|
||||
|
||||
box->menu = gtk_menu_new ();
|
||||
gtk_menu_attach_to_widget (GTK_MENU (box->menu), button, NULL);
|
||||
|
||||
gimp_settings_box_menu_item_add (box,
|
||||
GTK_STOCK_ADD,
|
||||
_("Add Settings to _Favorites..."),
|
||||
G_CALLBACK (gimp_settings_box_favorite_activate));
|
||||
|
||||
box->import_item =
|
||||
gimp_settings_box_menu_item_add (box,
|
||||
GTK_STOCK_OPEN,
|
||||
_("_Import Settings from File..."),
|
||||
G_CALLBACK (gimp_settings_box_import_activate));
|
||||
|
||||
box->export_item =
|
||||
gimp_settings_box_menu_item_add (box,
|
||||
GTK_STOCK_SAVE,
|
||||
_("_Export Settings to File..."),
|
||||
G_CALLBACK (gimp_settings_box_export_activate));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_finalize (GObject *object)
|
||||
{
|
||||
GimpSettingsBox *box = GIMP_SETTINGS_BOX (object);
|
||||
|
||||
if (box->config)
|
||||
{
|
||||
g_object_unref (box->config);
|
||||
box->config = NULL;
|
||||
}
|
||||
|
||||
if (box->container)
|
||||
{
|
||||
g_object_unref (box->container);
|
||||
box->container = NULL;
|
||||
}
|
||||
|
||||
if (box->filename)
|
||||
{
|
||||
g_free (box->filename);
|
||||
box->filename = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpSettingsBox *box = GIMP_SETTINGS_BOX (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
box->gimp = g_value_get_object (value); /* don't dup */
|
||||
break;
|
||||
|
||||
case PROP_CONFIG:
|
||||
box->config = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_CONTAINER:
|
||||
box->container = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_FILENAME:
|
||||
box->filename = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpSettingsBox *box = GIMP_SETTINGS_BOX (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
g_value_set_object (value, box->gimp);
|
||||
break;
|
||||
|
||||
case PROP_CONFIG:
|
||||
g_value_set_object (value, box->config);
|
||||
break;
|
||||
|
||||
case PROP_CONTAINER:
|
||||
g_value_set_object (value, box->container);
|
||||
break;
|
||||
|
||||
case PROP_FILENAME:
|
||||
g_value_set_string (value, box->filename);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_separator_add (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_new (container->children_type, NULL);
|
||||
|
||||
gimp_container_add (container, sep);
|
||||
g_object_unref (sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", sep);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_separator_remove (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_get_data (G_OBJECT (container), "separator");
|
||||
|
||||
gimp_container_remove (container, sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_deserialize (GimpSettingsBox *box)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (box->gimp->be_verbose)
|
||||
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (box->filename));
|
||||
|
||||
if (! gimp_config_deserialize_file (GIMP_CONFIG (box->container),
|
||||
box->filename,
|
||||
NULL, &error))
|
||||
{
|
||||
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
||||
gimp_message (box->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"%s", error->message);
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
gimp_settings_box_separator_add (box->container);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_serialize (GimpSettingsBox *box)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gimp_settings_box_separator_remove (box->container);
|
||||
|
||||
if (box->gimp->be_verbose)
|
||||
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (box->filename));
|
||||
|
||||
if (! gimp_config_serialize_to_file (GIMP_CONFIG (box->container),
|
||||
box->filename,
|
||||
"settings",
|
||||
"end of settings",
|
||||
NULL, &error))
|
||||
{
|
||||
gimp_message (box->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
gimp_settings_box_separator_add (box->container);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_settings_box_menu_item_add (GimpSettingsBox *box,
|
||||
const gchar *stock_id,
|
||||
const gchar *label,
|
||||
GCallback callback)
|
||||
{
|
||||
GtkWidget *item;
|
||||
GtkWidget *image;
|
||||
|
||||
item = gtk_image_menu_item_new_with_mnemonic (label);
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (box->menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
g_signal_connect (item, "activate",
|
||||
callback,
|
||||
box);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_settings_box_row_separator_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *name = NULL;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: dont use magic model column
|
||||
#endif
|
||||
gtk_tree_model_get (model, iter,
|
||||
1, &name,
|
||||
-1);
|
||||
|
||||
g_free (name);
|
||||
|
||||
return name == NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_setting_selected (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
if (object)
|
||||
{
|
||||
gimp_config_copy (GIMP_CONFIG (object),
|
||||
GIMP_CONFIG (box->config), 0);
|
||||
|
||||
gimp_container_view_select_item (view, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_menu_position (GtkMenu *menu,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gboolean *push_in,
|
||||
gpointer user_data)
|
||||
{
|
||||
gimp_button_menu_position (user_data, menu, GTK_POS_LEFT, x, y);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_settings_box_menu_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
if (bevent->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
gtk_menu_popup (GTK_MENU (box->menu),
|
||||
NULL, NULL,
|
||||
gimp_settings_box_menu_position, widget,
|
||||
bevent->button, bevent->time);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_favorite_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gimp_query_string_box (_("Add Settings to Favorites"),
|
||||
toplevel,
|
||||
gimp_standard_help_func, NULL,
|
||||
_("Enter a name for the settings"),
|
||||
_("Saved Settings"),
|
||||
G_OBJECT (toplevel), "hide",
|
||||
gimp_settings_box_favorite_callback, box);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_import_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
g_signal_emit (box, settings_box_signals[IMPORT], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_export_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
g_signal_emit (box, settings_box_signals[EXPORT], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_favorite_callback (GtkWidget *query_box,
|
||||
const gchar *string,
|
||||
gpointer data)
|
||||
{
|
||||
GimpSettingsBox *box = GIMP_SETTINGS_BOX (data);
|
||||
GimpConfig *config;
|
||||
|
||||
config = gimp_config_duplicate (GIMP_CONFIG (box->config));
|
||||
gimp_object_set_name (GIMP_OBJECT (config), string);
|
||||
gimp_container_add (box->container, GIMP_OBJECT (config));
|
||||
g_object_unref (config);
|
||||
|
||||
gimp_settings_box_serialize (box);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_settings_box_new (Gimp *gimp,
|
||||
GObject *config,
|
||||
GimpContainer *container,
|
||||
const gchar *filename)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_SETTINGS_BOX,
|
||||
"gimp", gimp,
|
||||
"config", config,
|
||||
"container", container,
|
||||
"filename", filename,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_settings_box_add_current (GimpSettingsBox *box)
|
||||
{
|
||||
GimpConfig *config = NULL;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_SETTINGS_BOX (box));
|
||||
|
||||
for (list = GIMP_LIST (box->container)->list; list; list = g_list_next (list))
|
||||
{
|
||||
guint t;
|
||||
|
||||
config = list->data;
|
||||
|
||||
g_object_get (config,
|
||||
"time", &t,
|
||||
NULL);
|
||||
|
||||
if (t > 0 && gimp_config_is_equal_to (config, GIMP_CONFIG (box->config)))
|
||||
{
|
||||
g_object_set (config,
|
||||
"time", (guint) time (NULL),
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! list)
|
||||
{
|
||||
config = gimp_config_duplicate (GIMP_CONFIG (box->config));
|
||||
g_object_set (config,
|
||||
"time", (guint) time (NULL),
|
||||
NULL);
|
||||
|
||||
gimp_container_insert (box->container, GIMP_OBJECT (config), 0);
|
||||
g_object_unref (config);
|
||||
}
|
||||
|
||||
gimp_settings_box_serialize (box);
|
||||
}
|
70
app/widgets/gimpsettingsbox.h
Normal file
70
app/widgets/gimpsettingsbox.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsettingsbox.h
|
||||
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SETTINGS_BOX_H__
|
||||
#define __GIMP_SETTINGS_BOX_H__
|
||||
|
||||
|
||||
#define GIMP_TYPE_SETTINGS_BOX (gimp_settings_box_get_type ())
|
||||
#define GIMP_SETTINGS_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SETTINGS_BOX, GimpSettingsBox))
|
||||
#define GIMP_SETTINGS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SETTINGS_BOX, GimpSettingsBoxClass))
|
||||
#define GIMP_IS_SETTINGS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SETTINGS_BOX))
|
||||
#define GIMP_IS_SETTINGS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SETTINGS_BOX))
|
||||
#define GIMP_SETTINGS_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SETTINGS_BOX, GimpSettingsBoxClass))
|
||||
|
||||
|
||||
typedef struct _GimpSettingsBoxClass GimpSettingsBoxClass;
|
||||
|
||||
struct _GimpSettingsBox
|
||||
{
|
||||
GtkHBox parent_instance;
|
||||
|
||||
GtkWidget *combo;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *import_item;
|
||||
GtkWidget *export_item;
|
||||
|
||||
Gimp *gimp;
|
||||
GObject *config;
|
||||
GimpContainer *container;
|
||||
gchar *filename;
|
||||
};
|
||||
|
||||
struct _GimpSettingsBoxClass
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
void (* import) (GimpSettingsBox *box);
|
||||
void (* export) (GimpSettingsBox *box);
|
||||
};
|
||||
|
||||
|
||||
GType gimp_settings_box_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_settings_box_new (Gimp *gimp,
|
||||
GObject *config,
|
||||
GimpContainer *container,
|
||||
const gchar *filename);
|
||||
|
||||
void gimp_settings_box_add_current (GimpSettingsBox *box);
|
||||
|
||||
|
||||
#endif /* __GIMP_SETTINGS_BOX_H__ */
|
@ -175,6 +175,7 @@ typedef struct _GimpLanguageEntry GimpLanguageEntry;
|
||||
typedef struct _GimpMessageBox GimpMessageBox;
|
||||
typedef struct _GimpProgressBox GimpProgressBox;
|
||||
typedef struct _GimpScaleButton GimpScaleButton;
|
||||
typedef struct _GimpSettingsBox GimpSettingsBox;
|
||||
typedef struct _GimpSizeBox GimpSizeBox;
|
||||
typedef struct _GimpStrokeEditor GimpStrokeEditor;
|
||||
typedef struct _GimpTemplateEditor GimpTemplateEditor;
|
||||
|
Reference in New Issue
Block a user