Commit cad7543c authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added enum GimpPageSelectorTarget which can be one of { LAYERS, IMAGES }

2005-06-28  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimpwidgetsenums.[ch]: added enum
	GimpPageSelectorTarget which can be one of { LAYERS, IMAGES }
	(suggestions for a better name welcome).

	* libgimpwidgets/gimppageselector.[ch]: added "target" property
	and a combo box to select a target. Removed GimpFrame around inner
	widgets again. Set a minimum width on the items so the "Page xxx"
	text doesn't wrap for pages smaller than 1000.
parent 053f6684
2005-06-28 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpwidgetsenums.[ch]: added enum
GimpPageSelectorTarget which can be one of { LAYERS, IMAGES }
(suggestions for a better name welcome).
* libgimpwidgets/gimppageselector.[ch]: added "target" property
and a combo box to select a target. Removed GimpFrame around inner
widgets again. Set a minimum width on the items so the "Page xxx"
text doesn't wrap for pages smaller than 1000.
2005-06-27 Michael Schumacher <schumaml@cvs.gnome.org>
* libgimpwidgets/gimppageselector.c: fixed a typo:
......
......@@ -29,8 +29,8 @@
#include "gimpwidgetstypes.h"
#include "gimpframe.h"
#include "gimppageselector.h"
#include "gimppropwidgets.h"
#include "libgimp/libgimp-intl.h"
......@@ -44,7 +44,8 @@ enum
enum
{
PROP_0,
PROP_N_PAGES
PROP_N_PAGES,
PROP_TARGET
};
enum
......@@ -67,6 +68,8 @@ static void gimp_page_selector_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_page_selector_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_page_selector_selection_changed (GtkIconView *icon_view,
GimpPageSelector *selector);
......@@ -115,10 +118,19 @@ gimp_page_selector_get_type (void)
static void
gimp_page_selector_class_init (GimpPageSelectorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_page_selector_finalize;
object_class->get_property = gimp_page_selector_get_property;
object_class->set_property = gimp_page_selector_set_property;
widget_class->style_set = gimp_page_selector_style_set;
klass->selection_changed = NULL;
selector_signals[SELECTION_CHANGED] =
g_signal_new ("selection-changed",
G_TYPE_FROM_CLASS (klass),
......@@ -128,12 +140,6 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_page_selector_finalize;
object_class->get_property = gimp_page_selector_get_property;
object_class->set_property = gimp_page_selector_set_property;
klass->selection_changed = NULL;
/**
* GimpPageSelector:n_pages:
*
......@@ -144,34 +150,42 @@ gimp_page_selector_class_init (GimpPageSelectorClass *klass)
g_object_class_install_property (object_class, PROP_N_PAGES,
g_param_spec_int ("n-pages", NULL, NULL,
0, G_MAXINT, 0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
G_PARAM_READWRITE));
/**
* GimpPageSelector:target:
*
* The target to open the document to.
*
* Since: GIMP 2.4
*/
g_object_class_install_property (object_class, PROP_TARGET,
g_param_spec_enum ("target", NULL, NULL,
GIMP_TYPE_PAGE_SELECTOR_TARGET,
GIMP_PAGE_SELECTOR_TARGET_LAYERS,
G_PARAM_READWRITE));
}
static void
gimp_page_selector_init (GimpPageSelector *selector)
{
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *sw;
GtkWidget *hbox;
GtkWidget *hbbox;
GtkWidget *button;
GtkWidget *label;
GtkWidget *combo;
/* Pages */
selector->n_pages = 0;
selector->target = GIMP_PAGE_SELECTOR_TARGET_LAYERS;
frame = gimp_frame_new (_("Select Pages"));
gtk_box_pack_start (GTK_BOX (selector), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gtk_box_set_spacing (GTK_BOX (selector), 6);
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
/* Pages */
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (selector), sw, TRUE, TRUE, 0);
gtk_widget_show (sw);
selector->store = gtk_list_store_new (3,
......@@ -195,9 +209,11 @@ gimp_page_selector_init (GimpPageSelector *selector)
selector);
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* Select buttons */
hbbox = gtk_hbutton_box_new ();
gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
gtk_widget_show (hbbox);
......@@ -230,15 +246,31 @@ gimp_page_selector_init (GimpPageSelector *selector)
G_CALLBACK (gimp_page_selector_range_activate),
selector);
label = gtk_label_new_with_mnemonic (_("Select _Range:"));
label = gtk_label_new_with_mnemonic (_("Select _range:"));
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), selector->range_entry);
/* Target combo */
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (selector), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("Open _pages as"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
combo = gimp_prop_enum_combo_box_new (G_OBJECT (selector), "target", -1, -1);
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
selector->thumbnail = gtk_widget_render_icon (GTK_WIDGET (selector),
GTK_STOCK_FILE,
GTK_ICON_SIZE_BUTTON,
GTK_ICON_SIZE_DND,
NULL);
}
......@@ -266,6 +298,9 @@ gimp_page_selector_get_property (GObject *object,
case PROP_N_PAGES:
g_value_set_int (value, selector->n_pages);
break;
case PROP_TARGET:
g_value_set_enum (value, selector->target);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -285,12 +320,47 @@ gimp_page_selector_set_property (GObject *object,
case PROP_N_PAGES:
gimp_page_selector_set_n_pages (selector, g_value_get_int (value));
break;
case PROP_TARGET:
selector->target = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_page_selector_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GimpPageSelector *selector = GIMP_PAGE_SELECTOR (widget);
PangoLayout *layout;
PangoRectangle ink_rect;
PangoRectangle logical_rect;
gint focus_line_width;
gint focus_padding;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
layout = gtk_widget_create_pango_layout (widget, _("Page 000"));
pango_layout_get_extents (layout, &ink_rect, &logical_rect);
g_object_unref (layout);
gtk_widget_style_get (widget,
"focus-line-width", &focus_line_width,
"focus-padding", &focus_padding,
NULL);
#define ICON_TEXT_PADDING 3 /* EEK */
gtk_icon_view_set_item_width (GTK_ICON_VIEW (selector->view),
PANGO_PIXELS (MAX (ink_rect.width,
logical_rect.width)) +
2 * (focus_line_width + focus_padding +
ICON_TEXT_PADDING));
}
/* public functions */
......@@ -378,6 +448,31 @@ gimp_page_selector_get_n_pages (GimpPageSelector *selector)
return selector->n_pages;
}
void
gimp_page_selector_set_target (GimpPageSelector *selector,
GimpPageSelectorTarget target)
{
g_return_if_fail (GIMP_IS_PAGE_SELECTOR (selector));
g_return_if_fail (target >= GIMP_PAGE_SELECTOR_TARGET_LAYERS &&
target <= GIMP_PAGE_SELECTOR_TARGET_IMAGES);
if (target != selector->target)
{
selector->target = target;
g_object_notify (G_OBJECT (selector), "target");
}
}
GimpPageSelectorTarget
gimp_page_selector_get_target (GimpPageSelector *selector)
{
g_return_val_if_fail (GIMP_IS_PAGE_SELECTOR (selector),
GIMP_PAGE_SELECTOR_TARGET_LAYERS);
return selector->target;
}
/**
* gimp_page_selector_set_page_thumbnail:
* @selector: Pointer to a #GimpPageSelector.
......
......@@ -27,12 +27,6 @@
G_BEGIN_DECLS
typedef enum
{
GIMP_PAGE_SELECTOR_OPEN_LAYERS,
GIMP_PAGE_SELECTOR_OPEN_IMAGES
} GimpPageSelectorOpenMode;
#define GIMP_TYPE_PAGE_SELECTOR (gimp_page_selector_get_type ())
#define GIMP_PAGE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAGE_SELECTOR, GimpPageSelector))
#define GIMP_PAGE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAGE_SELECTOR, GimpPageSelectorClass))
......@@ -45,16 +39,17 @@ typedef struct _GimpPageSelectorClass GimpPageSelectorClass;
struct _GimpPageSelector
{
GtkVBox parent_instance;
GtkVBox parent_instance;
gint n_pages;
gint n_pages;
GimpPageSelectorTarget target;
GtkListStore *store;
GtkWidget *view;
GtkListStore *store;
GtkWidget *view;
GtkWidget *range_entry;
GtkWidget *range_entry;
GdkPixbuf *thumbnail;
GdkPixbuf *thumbnail;
};
struct _GimpPageSelectorClass
......@@ -79,6 +74,11 @@ void gimp_page_selector_set_n_pages (GimpPageSelector *selector,
gint n_pages);
gint gimp_page_selector_get_n_pages (GimpPageSelector *selector);
void gimp_page_selector_set_target (GimpPageSelector *selector,
GimpPageSelectorTarget target);
GimpPageSelectorTarget
gimp_page_selector_get_target (GimpPageSelector *selector);
void gimp_page_selector_set_page_thumbnail (GimpPageSelector *selector,
gint page_no,
GdkPixbuf *thumbnail);
......@@ -100,7 +100,6 @@ void gimp_page_selector_select_range (GimpPageSelector *selector,
const gchar *range);
gchar * gimp_page_selector_get_selected_range (GimpPageSelector *selector);
G_END_DECLS
#endif /* __GIMP_PAGE_SELECTOR_H__ */
......@@ -111,6 +111,35 @@ gimp_color_selector_channel_get_type (void)
return type;
}
GType
gimp_page_selector_target_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_PAGE_SELECTOR_TARGET_LAYERS, "GIMP_PAGE_SELECTOR_TARGET_LAYERS", "layers" },
{ GIMP_PAGE_SELECTOR_TARGET_IMAGES, "GIMP_PAGE_SELECTOR_TARGET_IMAGES", "images" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_PAGE_SELECTOR_TARGET_LAYERS, N_("Layers"), NULL },
{ GIMP_PAGE_SELECTOR_TARGET_IMAGES, N_("Images"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpPageSelectorTarget", values);
gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_size_entry_update_policy_get_type (void)
{
......
......@@ -67,6 +67,17 @@ typedef enum
} GimpColorSelectorChannel;
#define GIMP_TYPE_PAGE_SELECTOR_TARGET (gimp_page_selector_target_get_type ())
GType gimp_page_selector_target_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_PAGE_SELECTOR_TARGET_LAYERS, /*< desc="Layers" >*/
GIMP_PAGE_SELECTOR_TARGET_IMAGES /*< desc="Images" >*/
} GimpPageSelectorTarget;
#define GIMP_TYPE_SIZE_ENTRY_UPDATE_POLICY (gimp_size_entry_update_policy_get_type ())
GType gimp_size_entry_update_policy_get_type (void) G_GNUC_CONST;
......
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