libgimpwidgets/Makefile.am libgimpwidgets/gimpwidgets.h added simple

2006-09-05  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgets.h
	* libgimpwidgets/gimphintbox.[ch]: added simple widget to
display
	a user hint. Having this as a widget will allow us to change the
	look, perhaps even using style properties.

	* libgimpwidgets/gimpwidgets.def: added the new symbols.

	* app/dialogs/keyboard-shortcuts-dialog.c
	* plug-ins/common/colormap-remap.c
	* plug-ins/common/redeye.c: use the new widget instead of
	duplicating the code.
This commit is contained in:
Sven Neumann 2006-09-05 21:43:07 +00:00 committed by Sven Neumann
parent 42e9548379
commit dea33cb255
9 changed files with 302 additions and 97 deletions

View File

@ -1,3 +1,18 @@
2006-09-05 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgets.h
* libgimpwidgets/gimphintbox.[ch]: added simple widget to display
a user hint. Having this as a widget will allow us to change the
look, perhaps even using style properties.
* libgimpwidgets/gimpwidgets.def: added the new symbols.
* app/dialogs/keyboard-shortcuts-dialog.c
* plug-ins/common/colormap-remap.c
* plug-ins/common/redeye.c: use the new widget instead of
duplicating the code.
2006-09-05 Michael Natterer <mitch@gimp.org>
* app/actions/debug-actions.c

View File

@ -40,11 +40,9 @@ keyboard_shortcuts_dialog_new (Gimp *gimp)
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *scrolled_window;
GtkWidget *view;
GtkWidget *image;
GtkWidget *label;
GtkWidget *box;
GtkWidget *button;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
@ -80,30 +78,12 @@ keyboard_shortcuts_dialog_new (Gimp *gimp)
gtk_container_add (GTK_CONTAINER (scrolled_window), view);
gtk_widget_show (view);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
image = gtk_image_new_from_stock (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = g_object_new (GTK_TYPE_LABEL,
"label", _("To edit a shortcut key, click on the "
box = gimp_hint_box_new (_("To edit a shortcut key, click on the "
"corresponding row and type a new "
"accelerator, or press backspace to "
"clear."),
"wrap", TRUE,
"justify", GTK_JUSTIFY_LEFT,
"xalign", 0.0,
"yalign", 0.5,
NULL);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
"clear."));
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, FALSE, 0);
gtk_widget_show (box);
button = gimp_prop_check_button_new (G_OBJECT (gimp->config), "save-accels",
_("_Save keyboard shortcuts on exit"));

View File

@ -114,6 +114,8 @@ libgimpwidgets_2_0_la_sources = \
gimpframe.h \
gimphelpui.c \
gimphelpui.h \
gimphintbox.c \
gimphintbox.h \
gimpintcombobox.c \
gimpintcombobox.h \
gimpintstore.c \
@ -196,6 +198,7 @@ libgimpwidgetsinclude_HEADERS = \
gimpfileentry.h \
gimpframe.h \
gimphelpui.h \
gimphintbox.h \
gimpintcombobox.h \
gimpintstore.h \
gimpmemsizeentry.h \

View File

@ -0,0 +1,225 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimphintbox.c
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; 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 "gimpwidgets.h"
typedef GtkHBoxClass GimpHintBoxClass;
typedef struct
{
GtkHBox parent_instance;
gchar *stock_id;
gchar *hint;
} GimpHintBox;
#define GIMP_HINT_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HINT_BOX, GimpHintBox))
enum
{
PROP_0,
PROP_STOCK_ID,
PROP_HINT
};
static GObject * gimp_hint_box_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_hint_box_finalize (GObject *object);
static void gimp_hint_box_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_hint_box_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpHintBox, gimp_hint_box, GTK_TYPE_HBOX)
#define parent_class gimp_hint_box_parent_class
static void
gimp_hint_box_class_init (GimpHintBoxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = gimp_hint_box_constructor;
object_class->finalize = gimp_hint_box_finalize;
object_class->set_property = gimp_hint_box_set_property;
object_class->get_property = gimp_hint_box_get_property;
g_object_class_install_property (object_class, PROP_STOCK_ID,
g_param_spec_string ("stock-id", NULL, NULL,
GIMP_STOCK_INFO,
G_PARAM_CONSTRUCT_ONLY |
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HINT,
g_param_spec_string ("hint", NULL, NULL,
NULL,
G_PARAM_CONSTRUCT_ONLY |
GIMP_PARAM_READWRITE));
}
static void
gimp_hint_box_init (GimpHintBox *box)
{
box->stock_id = NULL;
box->hint = NULL;
}
static GObject *
gimp_hint_box_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpHintBox *box;
GtkWidget *label;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
box = GIMP_HINT_BOX (object);
gtk_box_set_spacing (GTK_BOX (box), 12);
if (box->stock_id)
{
GtkWidget *image = gtk_image_new_from_stock (box->stock_id,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
gtk_widget_show (image);
}
label = g_object_new (GTK_TYPE_LABEL,
"label", box->hint,
"wrap", TRUE,
"justify", GTK_JUSTIFY_LEFT,
"xalign", 0.0,
"yalign", 0.5,
NULL);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
gtk_widget_show (label);
return object;
}
static void
gimp_hint_box_finalize (GObject *object)
{
GimpHintBox *box = GIMP_HINT_BOX (object);
if (box->stock_id)
{
g_free (box->stock_id);
box->stock_id = NULL;
}
if (box->hint)
{
g_free (box->hint);
box->hint = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_hint_box_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpHintBox *box = GIMP_HINT_BOX (object);
switch (property_id)
{
case PROP_STOCK_ID:
box->stock_id = g_value_dup_string (value);
break;
case PROP_HINT:
box->hint = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_hint_box_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpHintBox *box = GIMP_HINT_BOX (object);
switch (property_id)
{
case PROP_STOCK_ID:
g_value_set_string (value, box->stock_id);
break;
case PROP_HINT:
g_value_set_string (value, box->hint);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/**
* gimp_hint_box_new:
* @hint: text to display as a user hint
*
* Creates a new widget that shows a text label showing @hint,
* decorated with a GIMP_STOCK_INFO wilber icon.
*
* Return value: a new widget
*
* Since GIMP 2.4
**/
GtkWidget *
gimp_hint_box_new (const gchar *hint)
{
g_return_val_if_fail (hint != NULL, NULL);
return g_object_new (GIMP_TYPE_HINT_BOX,
"hint", hint,
NULL);
}

View File

@ -0,0 +1,40 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimphintbox.h
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_HINT_BOX_H__
#define __GIMP_HINT_BOX_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#define GIMP_TYPE_HINT_BOX (gimp_hint_box_get_type ())
GType gimp_hint_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_hint_box_new (const gchar *hint);
G_END_DECLS
#endif /* __GIMP_HINT_BOX_H__ */

View File

@ -135,6 +135,8 @@ EXPORTS
gimp_help_enable_tooltips
gimp_help_id_quark
gimp_help_set_help_data
gimp_hint_box_get_type
gimp_hint_box_new
gimp_int_adjustment_update
gimp_int_combo_box_append
gimp_int_combo_box_connect

View File

@ -50,6 +50,7 @@
#include <libgimpwidgets/gimpfileentry.h>
#include <libgimpwidgets/gimpframe.h>
#include <libgimpwidgets/gimphelpui.h>
#include <libgimpwidgets/gimphintbox.h>
#include <libgimpwidgets/gimpintcombobox.h>
#include <libgimpwidgets/gimpintstore.h>
#include <libgimpwidgets/gimpmemsizeentry.h>

View File

@ -532,39 +532,6 @@ remap_ui_manager_new (GtkWidget *window,
return ui_manager;
}
static GtkWidget *
remap_hints_new (void)
{
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
hbox = gtk_hbox_new (FALSE, 12);
image = gtk_image_new_from_stock (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = g_object_new (GTK_TYPE_LABEL,
"label",
_("Drag and drop colors to rearrange the colormap. "
"The numbers shown are the original indices. "
"Right-click for a menu with sort options."),
"wrap", TRUE,
"justify", GTK_JUSTIFY_LEFT,
"xalign", 0.0,
"yalign", 0.5,
NULL);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
return hbox;
}
static gboolean
remap_popup_menu (GtkWidget *widget,
GdkEventButton *event)
@ -617,7 +584,7 @@ remap_dialog (gint32 image_ID,
{
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *box;
GtkWidget *iconview;
GtkListStore *store;
GtkCellRenderer *renderer;
@ -731,9 +698,12 @@ remap_dialog (gint32 image_ID,
G_CALLBACK (remap_button_press),
NULL);
hbox = remap_hints_new ();
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
box = gimp_hint_box_new (_("Drag and drop colors to rearrange the colormap. "
"The numbers shown are the original indices. "
"Right-click for a menu with sort options."));
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, FALSE, 0);
gtk_widget_show (box);
g_signal_connect (dialog, "response",
G_CALLBACK (remap_response),

View File

@ -125,38 +125,6 @@ query (void)
}
static GtkWidget *
redeye_hints_new (void)
{
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *label;
hbox = gtk_hbox_new (FALSE, 12);
image = gtk_image_new_from_stock (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
label = g_object_new (GTK_TYPE_LABEL,
"label",
_("Manually selecting the eyes may "
"improve the results."),
"wrap", TRUE,
"justify", GTK_JUSTIFY_LEFT,
"xalign", 0.0,
"yalign", 0.5,
NULL);
gimp_label_set_attributes (GTK_LABEL (label),
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
-1);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
return hbox;
}
/*
* Create dialog for red eye removal
*/
@ -213,7 +181,8 @@ dialog (gint32 image_id,
if (gimp_selection_is_empty (gimp_drawable_get_image (drawable->drawable_id)))
{
GtkWidget *hints = redeye_hints_new ();
GtkWidget *hints = gimp_hint_box_new (_("Manually selecting the eyes may "
"improve the results."));
gtk_box_pack_end (GTK_BOX (main_vbox), hints, FALSE, FALSE, 0);
gtk_widget_show (hints);