Commit 57f97f73 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

libgimpwidgets/Makefile.am libgimpwidgets/gimpwidgets.h

2005-06-25  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgets.h
	* libgimpwidgets/gimpwidgetstypes.h
	* libgimpwidgets/gimpenumlabel.[ch]: added new widget GimpEnumLabel.

	* libgimpwidgets/gimppropwidgets.[ch]: added
	gimp_prop_enum_label_new().

	* libgimpwidgets/gimpwidgets.def: updated.

	* modules/cdisplay_lcms.c (cdisplay_lcms_configure): started to
	add a view on the current color managment configuration.
parent dfad53ef
2005-06-25 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgets.h
* libgimpwidgets/gimpwidgetstypes.h
* libgimpwidgets/gimpenumlabel.[ch]: added new widget GimpEnumLabel.
* libgimpwidgets/gimppropwidgets.[ch]: added
gimp_prop_enum_label_new().
* libgimpwidgets/gimpwidgets.def: updated.
* modules/cdisplay_lcms.c (cdisplay_lcms_configure): started to
add a view on the current color managment configuration.
2005-06-24 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/Makefile.am: build all libraries with no-undefined.
......
......@@ -106,6 +106,8 @@ libgimpwidgets_2_0_la_sources = \
gimpenumstore.h \
gimpenumcombobox.c \
gimpenumcombobox.h \
gimpenumlabel.c \
gimpenumlabel.h \
gimpfileentry.c \
gimpfileentry.h \
gimpframe.c \
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpenumlabel.c
* Copyright (C) 2005 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 "libgimpbase/gimpbase.h"
#include "gimpwidgetstypes.h"
#include "gimpenumlabel.h"
static void gimp_enum_label_class_init (GimpEnumLabelClass *klass);
static void gimp_enum_label_finalize (GObject *object);
static GtkLabelClass *parent_class = NULL;
GType
gimp_enum_label_get_type (void)
{
static GType enum_label_type = 0;
if (!enum_label_type)
{
static const GTypeInfo enum_label_info =
{
sizeof (GimpEnumLabelClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_enum_label_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpEnumLabel),
0, /* n_preallocs */
NULL /* instance_init */
};
enum_label_type = g_type_register_static (GTK_TYPE_LABEL,
"GimpEnumLabel",
&enum_label_info, 0);
}
return enum_label_type;
}
static void
gimp_enum_label_class_init (GimpEnumLabelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_enum_label_finalize;
}
static void
gimp_enum_label_finalize (GObject *object)
{
GimpEnumLabel *enum_label = GIMP_ENUM_LABEL (object);
if (enum_label->enum_class)
g_type_class_unref (enum_label->enum_class);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* gimp_enum_label_new:
* @enum_type: the #GType of an enum.
* @value:
*
* Return value: a new #GimpEnumLabel.
*
* Since: GIMP 2.4
**/
GtkWidget *
gimp_enum_label_new (GType enum_type,
gint value)
{
GimpEnumLabel *label;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
label = g_object_new (GIMP_TYPE_ENUM_LABEL, NULL);
label->enum_class = g_type_class_ref (enum_type);
gimp_enum_label_set_value (label, value);
return GTK_WIDGET (label);
}
/**
* gimp_enum_label_set_value
* @label: a #GimpEnumLabel
* @value:
*
* Since: GIMP 2.4
**/
void
gimp_enum_label_set_value (GimpEnumLabel *label,
gint value)
{
const gchar *desc;
g_return_if_fail (GIMP_IS_ENUM_LABEL (label));
if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (label->enum_class), value,
NULL, NULL, &desc, NULL))
{
g_warning ("%s: %d is not valid for enum of type '%s'",
G_STRLOC, value,
g_type_name (G_TYPE_FROM_CLASS (label->enum_class)));
return;
}
gtk_label_set_text (GTK_LABEL (label), desc);
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpenumlabel.h
* Copyright (C) 2005 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_ENUM__LABEL_H__
#define __GIMP_ENUM__LABEL_H__
#include <gtk/gtklabel.h>
#define GIMP_TYPE_ENUM_LABEL (gimp_enum_label_get_type ())
#define GIMP_ENUM_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ENUM_LABEL, GimpEnumLabel))
#define GIMP_ENUM_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ENUM_LABEL, GimpEnumLabelClass))
#define GIMP_IS_ENUM_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ENUM_LABEL))
#define GIMP_IS_ENUM_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ENUM_LABEL))
#define GIMP_ENUM_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ENUM_LABEL, GimpEnumLabelClass))
typedef struct _GimpEnumLabelClass GimpEnumLabelClass;
struct _GimpEnumLabel
{
GtkLabel parent_instance;
/*< private >*/
GEnumClass *enum_class;
};
struct _GimpEnumLabelClass
{
GtkLabelClass parent_instance;
};
GType gimp_enum_label_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_enum_label_new (GType enum_type,
gint value);
void gimp_enum_label_set_value (GimpEnumLabel *label,
gint value);
#endif /* __GIMP_ENUM_LABEL_H__ */
......@@ -31,6 +31,7 @@
#include "libgimp/libgimp-intl.h"
/* utility function prototypes */
static void set_param_spec (GObject *object,
......@@ -789,10 +790,74 @@ gimp_prop_enum_radio_box_new (GObject *config,
return vbox;
}
/***********/
/* label */
/***********/
static void gimp_prop_enum_label_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *label);
/**
* gimp_prop_enum_label_new:
* @config: Object to which property is attached.
* @property_name: Name of enum property to be displayed.
*
* Return value: The newly created #GimpEnumLabel widget.
*
* Since GIMP 2.4
*/
GtkWidget *
gimp_prop_enum_label_new (GObject *config,
const gchar *property_name)
{
GParamSpec *param_spec;
GtkWidget *label;
gint value;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
param_spec = check_param_spec (config, property_name,
G_TYPE_PARAM_ENUM, G_STRFUNC);
if (! param_spec)
return NULL;
g_object_get (config,
property_name, &value,
NULL);
label = gimp_enum_label_new (param_spec->value_type, value);
set_param_spec (G_OBJECT (label), NULL, param_spec);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_enum_label_notify),
label);
return label;
}
static void
gimp_prop_enum_label_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *label)
{
gint value;
g_object_get (config,
param_spec->name, &value,
NULL);
gimp_enum_label_set_value (GIMP_ENUM_LABEL (label), value);
}
/**
* gimp_prop_boolean_radio_frame_new:
* @config: Object to which property is attached.
* @property_name: Name of Enum property controlled by the radio buttons.
* @property_name: Name of boolean property controlled by the radio buttons.
* @title: Label for the frame.
* @true_text: Label for the button corresponding to #TRUE.
* @false_text: Label for the button corresponding to #FALSE.
......
......@@ -79,6 +79,9 @@ GtkWidget * gimp_prop_enum_stock_box_new (GObject *config,
gint minimum,
gint maximum);
GtkWidget * gimp_prop_enum_label_new (GObject *config,
const gchar *property_name);
/* GParamInt, GParamUInt, GParamLong, GParamULong, GParamDouble */
......
......@@ -104,6 +104,9 @@ EXPORTS
gimp_enum_combo_box_get_type
gimp_enum_combo_box_new
gimp_enum_combo_box_set_stock_prefix
gimp_enum_label_get_type
gimp_enum_label_new
gimp_enum_label_set_value
gimp_enum_radio_box_new
gimp_enum_radio_box_new_with_range
gimp_enum_radio_frame_new
......@@ -206,6 +209,7 @@ EXPORTS
gimp_prop_entry_new
gimp_prop_enum_check_button_new
gimp_prop_enum_combo_box_new
gimp_prop_enum_label_new
gimp_prop_enum_radio_box_new
gimp_prop_enum_radio_frame_new
gimp_prop_enum_stock_box_new
......
......@@ -44,6 +44,7 @@
#include <libgimpwidgets/gimpcolorselection.h>
#include <libgimpwidgets/gimpdialog.h>
#include <libgimpwidgets/gimpenumcombobox.h>
#include <libgimpwidgets/gimpenumlabel.h>
#include <libgimpwidgets/gimpenumstore.h>
#include <libgimpwidgets/gimpenumwidgets.h>
#include <libgimpwidgets/gimpfileentry.h>
......
......@@ -51,6 +51,7 @@ typedef struct _GimpController GimpController;
typedef struct _GimpDialog GimpDialog;
typedef struct _GimpEnumStore GimpEnumStore;
typedef struct _GimpEnumComboBox GimpEnumComboBox;
typedef struct _GimpEnumLabel GimpEnumLabel;
typedef struct _GimpFileEntry GimpFileEntry;
typedef struct _GimpFrame GimpFrame;
typedef struct _GimpIntComboBox GimpIntComboBox;
......
......@@ -231,16 +231,53 @@ cdisplay_lcms_set_property (GObject *object,
static GtkWidget *
cdisplay_lcms_configure (GimpColorDisplay *display)
{
return g_object_new (GTK_TYPE_LABEL,
"label", _("This module takes its configuration "
"from the <i>Color Management</i> "
"section in the Preferences dialog."),
"use-markup", TRUE,
"justify", GTK_JUSTIFY_LEFT,
"wrap", TRUE,
"xalign", 0.5,
"yalign", 0.5,
NULL);
CdisplayLcms *lcms = CDISPLAY_LCMS (display);
GObject *config = G_OBJECT (lcms->config);
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *image;
GtkWidget *table;
gint row = 0;
vbox = gtk_vbox_new (FALSE, 12);
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", _("This module takes its configuration "
"from the <i>Color Management</i> "
"section in the Preferences dialog."),
"use-markup", TRUE,
"wrap", TRUE,
"justify", GTK_JUSTIFY_LEFT,
"xalign", 0.0,
"yalign", 0.5,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
table = gtk_table_new (1, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
label = gimp_prop_enum_label_new (config, "mode");
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Mode of operation:"),
0.0, 0.5, label, 1, TRUE);
/* more to come here */
return vbox;
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment