mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 20:12:30 +00:00
app/widgets/Makefile.am app/widgets/widgets-types.h skeleton of a widget
2008-06-22 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpsettingseditor.[ch]: skeleton of a widget to manage the list of saved settings for the image map tools. Does absolutely nothing yet apart from displaying the list of settings. * app/widgets/gimpsettingsbox.[ch]: add "Manage Settings" menu item and show a dialog containing the new widget. svn path=/trunk/; revision=25977
This commit is contained in:
parent
e068c051f1
commit
ba7d6020da
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2008-06-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpsettingseditor.[ch]: skeleton of a widget to
|
||||
manage the list of saved settings for the image map tools. Does
|
||||
absolutely nothing yet apart from displaying the list of settings.
|
||||
|
||||
* app/widgets/gimpsettingsbox.[ch]: add "Manage Settings" menu item
|
||||
and show a dialog containing the new widget.
|
||||
|
||||
2008-06-21 Martin Nordholts <martinn@svn.gnome.org>
|
||||
|
||||
* app/tools/gimpfreeselecttool.c
|
||||
|
|
|
@ -257,6 +257,8 @@ libappwidgets_a_sources = \
|
|||
gimpsessioninfo-dockable.h \
|
||||
gimpsettingsbox.c \
|
||||
gimpsettingsbox.h \
|
||||
gimpsettingseditor.c \
|
||||
gimpsettingseditor.h \
|
||||
gimpsizebox.c \
|
||||
gimpsizebox.h \
|
||||
gimpstringaction.c \
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "gimpcontainercombobox.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpsettingsbox.h"
|
||||
#include "gimpsettingseditor.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
@ -94,10 +95,17 @@ 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_manage_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box);
|
||||
|
||||
static void gimp_settings_box_favorite_callback (GtkWidget *query_box,
|
||||
const gchar *string,
|
||||
gpointer data);
|
||||
static void gimp_settings_box_toplevel_unmap (GtkWidget *widget,
|
||||
GimpSettingsBox *box);
|
||||
static void gimp_settings_box_manage_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
GimpSettingsBox *box);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpSettingsBox, gimp_settings_box, GTK_TYPE_HBOX)
|
||||
|
@ -244,6 +252,11 @@ gimp_settings_box_constructor (GType type,
|
|||
_("_Export Settings to File..."),
|
||||
G_CALLBACK (gimp_settings_box_export_activate));
|
||||
|
||||
gimp_settings_box_menu_item_add (box,
|
||||
GTK_STOCK_EDIT,
|
||||
_("_Manage Settings..."),
|
||||
G_CALLBACK (gimp_settings_box_manage_activate));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -270,6 +283,18 @@ gimp_settings_box_finalize (GObject *object)
|
|||
box->filename = NULL;
|
||||
}
|
||||
|
||||
if (box->editor_dialog)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box));
|
||||
|
||||
if (toplevel)
|
||||
g_signal_handlers_disconnect_by_func (toplevel,
|
||||
gimp_settings_box_toplevel_unmap,
|
||||
box);
|
||||
|
||||
gtk_widget_destroy (box->editor_dialog);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -518,6 +543,50 @@ gimp_settings_box_export_activate (GtkWidget *widget,
|
|||
g_signal_emit (box, settings_box_signals[EXPORT], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_manage_activate (GtkWidget *widget,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
GtkWidget *editor;
|
||||
|
||||
if (box->editor_dialog)
|
||||
{
|
||||
gtk_window_present (GTK_WINDOW (box->editor_dialog));
|
||||
return;
|
||||
}
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box));
|
||||
|
||||
box->editor_dialog = gimp_dialog_new (_("Manage Saved Settings"),
|
||||
"gimp-settings-editor-dialog",
|
||||
toplevel, 0,
|
||||
NULL, NULL,
|
||||
GTK_STOCK_CLOSE,
|
||||
GTK_RESPONSE_CLOSE,
|
||||
NULL);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (box->editor_dialog),
|
||||
(gpointer) &box->editor_dialog);
|
||||
g_signal_connect (toplevel, "unmap",
|
||||
G_CALLBACK (gimp_settings_box_toplevel_unmap),
|
||||
box);
|
||||
|
||||
g_signal_connect (box->editor_dialog, "response",
|
||||
G_CALLBACK (gimp_settings_box_manage_response),
|
||||
box);
|
||||
|
||||
editor = gimp_settings_editor_new (box->gimp,
|
||||
box->config,
|
||||
box->container);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (box->editor_dialog)->vbox),
|
||||
editor);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
gtk_widget_show (box->editor_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_favorite_callback (GtkWidget *query_box,
|
||||
const gchar *string,
|
||||
|
@ -534,6 +603,29 @@ gimp_settings_box_favorite_callback (GtkWidget *query_box,
|
|||
gimp_settings_box_serialize (box);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_toplevel_unmap (GtkWidget *widget,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
gtk_dialog_response (GTK_DIALOG (box->editor_dialog),
|
||||
GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_manage_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
GimpSettingsBox *box)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box));
|
||||
|
||||
if (toplevel)
|
||||
g_signal_handlers_disconnect_by_func (toplevel,
|
||||
gimp_settings_box_toplevel_unmap,
|
||||
box);
|
||||
|
||||
gtk_widget_destroy (widget);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ struct _GimpSettingsBox
|
|||
GtkWidget *menu;
|
||||
GtkWidget *import_item;
|
||||
GtkWidget *export_item;
|
||||
GtkWidget *editor_dialog;
|
||||
|
||||
Gimp *gimp;
|
||||
GObject *config;
|
||||
|
|
229
app/widgets/gimpsettingseditor.c
Normal file
229
app/widgets/gimpsettingseditor.c
Normal file
|
@ -0,0 +1,229 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsettingseditor.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 "gimpcontainertreeview.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpsettingseditor.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GIMP,
|
||||
PROP_CONFIG,
|
||||
PROP_CONTAINER,
|
||||
PROP_FILENAME
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_settings_editor_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_settings_editor_finalize (GObject *object);
|
||||
static void gimp_settings_editor_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_settings_editor_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpSettingsEditor, gimp_settings_editor, GTK_TYPE_VBOX)
|
||||
|
||||
#define parent_class gimp_settings_editor_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_settings_editor_class_init (GimpSettingsEditorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_settings_editor_constructor;
|
||||
object_class->finalize = gimp_settings_editor_finalize;
|
||||
object_class->set_property = gimp_settings_editor_set_property;
|
||||
object_class->get_property = gimp_settings_editor_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));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_editor_init (GimpSettingsEditor *editor)
|
||||
{
|
||||
gtk_box_set_spacing (GTK_BOX (editor), 6);
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_settings_editor_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpSettingsEditor *editor;
|
||||
GtkWidget *view;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
editor = GIMP_SETTINGS_EDITOR (object);
|
||||
|
||||
g_assert (GIMP_IS_GIMP (editor->gimp));
|
||||
g_assert (GIMP_IS_CONFIG (editor->config));
|
||||
g_assert (GIMP_IS_CONTAINER (editor->container));
|
||||
|
||||
view = gimp_container_tree_view_new (editor->container,
|
||||
gimp_get_user_context (editor->gimp),
|
||||
16, 0);
|
||||
gtk_container_add (GTK_CONTAINER (editor), view);
|
||||
gtk_widget_show (view);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_editor_finalize (GObject *object)
|
||||
{
|
||||
GimpSettingsEditor *editor = GIMP_SETTINGS_EDITOR (object);
|
||||
|
||||
if (editor->config)
|
||||
{
|
||||
g_object_unref (editor->config);
|
||||
editor->config = NULL;
|
||||
}
|
||||
|
||||
if (editor->container)
|
||||
{
|
||||
g_object_unref (editor->container);
|
||||
editor->container = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_editor_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpSettingsEditor *editor = GIMP_SETTINGS_EDITOR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
editor->gimp = g_value_get_object (value); /* don't dup */
|
||||
break;
|
||||
|
||||
case PROP_CONFIG:
|
||||
editor->config = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_CONTAINER:
|
||||
editor->container = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_editor_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpSettingsEditor *editor = GIMP_SETTINGS_EDITOR (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
g_value_set_object (value, editor->gimp);
|
||||
break;
|
||||
|
||||
case PROP_CONFIG:
|
||||
g_value_set_object (value, editor->config);
|
||||
break;
|
||||
|
||||
case PROP_CONTAINER:
|
||||
g_value_set_object (value, editor->container);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_settings_editor_new (Gimp *gimp,
|
||||
GObject *config,
|
||||
GimpContainer *container)
|
||||
{
|
||||
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);
|
||||
|
||||
return g_object_new (GIMP_TYPE_SETTINGS_EDITOR,
|
||||
"gimp", gimp,
|
||||
"config", config,
|
||||
"container", container,
|
||||
NULL);
|
||||
}
|
58
app/widgets/gimpsettingseditor.h
Normal file
58
app/widgets/gimpsettingseditor.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsettingseditor.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_EDITOR_H__
|
||||
#define __GIMP_SETTINGS_EDITOR_H__
|
||||
|
||||
|
||||
#define GIMP_TYPE_SETTINGS_EDITOR (gimp_settings_editor_get_type ())
|
||||
#define GIMP_SETTINGS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SETTINGS_EDITOR, GimpSettingsEditor))
|
||||
#define GIMP_SETTINGS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SETTINGS_EDITOR, GimpSettingsEditorClass))
|
||||
#define GIMP_IS_SETTINGS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SETTINGS_EDITOR))
|
||||
#define GIMP_IS_SETTINGS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SETTINGS_EDITOR))
|
||||
#define GIMP_SETTINGS_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SETTINGS_EDITOR, GimpSettingsEditorClass))
|
||||
|
||||
|
||||
typedef struct _GimpSettingsEditorClass GimpSettingsEditorClass;
|
||||
|
||||
struct _GimpSettingsEditor
|
||||
{
|
||||
GtkVBox parent_instance;
|
||||
|
||||
Gimp *gimp;
|
||||
GObject *config;
|
||||
GimpContainer *container;
|
||||
};
|
||||
|
||||
struct _GimpSettingsEditorClass
|
||||
{
|
||||
GtkVBoxClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_settings_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_settings_editor_new (Gimp *gimp,
|
||||
GObject *config,
|
||||
GimpContainer *container);
|
||||
|
||||
|
||||
#endif /* __GIMP_SETTINGS_EDITOR_H__ */
|
|
@ -176,6 +176,7 @@ typedef struct _GimpMessageBox GimpMessageBox;
|
|||
typedef struct _GimpProgressBox GimpProgressBox;
|
||||
typedef struct _GimpScaleButton GimpScaleButton;
|
||||
typedef struct _GimpSettingsBox GimpSettingsBox;
|
||||
typedef struct _GimpSettingsEditor GimpSettingsEditor;
|
||||
typedef struct _GimpSizeBox GimpSizeBox;
|
||||
typedef struct _GimpStrokeEditor GimpStrokeEditor;
|
||||
typedef struct _GimpTemplateEditor GimpTemplateEditor;
|
||||
|
|
Loading…
Reference in a new issue