libgimpwidgets/gimpcolorbutton.c libgimpwidgets/gimpcolornotebook.c

2004-07-13  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpcolorbutton.c
	* libgimpwidgets/gimpcolornotebook.c
	* libgimpwidgets/gimpcolorscale.c
	* libgimpwidgets/gimpcolorscales.c
	* libgimpwidgets/gimpcolorselect.c
	* libgimpwidgets/gimpcolorselection.c
	* libgimpwidgets/gimpframe.c
	* libgimpwidgets/gimppickbutton.c
	* libgimpwidgets/gimpunitmenu.c: some code review and cosmetics.
This commit is contained in:
Sven Neumann 2004-07-13 14:55:16 +00:00 committed by Sven Neumann
parent 6d3d212973
commit 45a7f5e459
10 changed files with 55 additions and 135 deletions

View File

@ -1,3 +1,15 @@
2004-07-13 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcolorbutton.c
* libgimpwidgets/gimpcolornotebook.c
* libgimpwidgets/gimpcolorscale.c
* libgimpwidgets/gimpcolorscales.c
* libgimpwidgets/gimpcolorselect.c
* libgimpwidgets/gimpcolorselection.c
* libgimpwidgets/gimpframe.c
* libgimpwidgets/gimppickbutton.c
* libgimpwidgets/gimpunitmenu.c: some code review and cosmetics.
2004-07-13 Shlomi Fish <shlomif@iglu.org.il>
* plug-ins/gimpressionist/*.[ch]: normalized some of brush.c's

View File

@ -137,13 +137,9 @@ gimp_color_button_get_type (void)
static void
gimp_color_button_class_init (GimpColorButtonClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkButtonClass *button_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
button_class = GTK_BUTTON_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -196,9 +192,7 @@ gimp_color_button_init (GimpColorButton *button)
static void
gimp_color_button_destroy (GtkObject *object)
{
GimpColorButton *button;
button = GIMP_COLOR_BUTTON (object);
GimpColorButton *button = GIMP_COLOR_BUTTON (object);
if (button->title)
{
@ -225,12 +219,10 @@ static gboolean
gimp_color_button_button_press (GtkWidget *widget,
GdkEventButton *bevent)
{
GimpColorButton *button;
GimpColorButton *button = GIMP_COLOR_BUTTON (widget);
gint x;
gint y;
button = GIMP_COLOR_BUTTON (widget);
if (bevent->button == 3)
{
gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);

View File

@ -112,13 +112,9 @@ gimp_color_notebook_get_type (void)
static void
gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GimpColorSelectorClass *selector_class;
object_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);

View File

@ -83,14 +83,11 @@ gimp_color_scale_get_type (void)
static void
gimp_color_scale_class_init (GimpColorScaleClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
object_class->destroy = gimp_color_scale_destroy;
widget_class->size_allocate = gimp_color_scale_size_allocate;
@ -119,9 +116,7 @@ gimp_color_scale_init (GimpColorScale *scale)
static void
gimp_color_scale_destroy (GtkObject *object)
{
GimpColorScale *scale;
scale = GIMP_COLOR_SCALE (object);
GimpColorScale *scale = GIMP_COLOR_SCALE (object);
if (scale->buf)
{
@ -139,15 +134,12 @@ static void
gimp_color_scale_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GimpColorScale *scale;
GtkRange *range;
GimpColorScale *scale = GIMP_COLOR_SCALE (widget);
GtkRange *range = GTK_RANGE (widget);
gint focus = 0;
gint scale_width;
gint scale_height;
scale = GIMP_COLOR_SCALE (widget);
range = GTK_RANGE (widget);
if (GTK_WIDGET_CAN_FOCUS (widget))
{
gint focus_padding = 0;
@ -199,7 +191,7 @@ static gboolean
gimp_color_scale_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GimpColorScale *scale;
GimpColorScale *scale = GIMP_COLOR_SCALE (widget);
GtkRange *range;
GdkRectangle expose_area; /* Relative to widget->allocation */
GdkRectangle area;
@ -208,8 +200,6 @@ gimp_color_scale_expose (GtkWidget *widget,
gint x, y;
gint w, h;
scale = GIMP_COLOR_SCALE (widget);
if (! scale->buf || ! GTK_WIDGET_DRAWABLE (widget))
return FALSE;
@ -462,7 +452,7 @@ should_invert (GtkRange *range)
static void
gimp_color_scale_render (GimpColorScale *scale)
{
GtkRange *range;
GtkRange *range = GTK_RANGE (scale);
GimpRGB rgb;
GimpHSV hsv;
guint x, y;
@ -508,7 +498,6 @@ gimp_color_scale_render (GimpColorScale *scale)
break;
}
range = GTK_RANGE (scale);
invert = should_invert (range);
switch (range->orientation)
@ -568,7 +557,7 @@ gimp_color_scale_render (GimpColorScale *scale)
static void
gimp_color_scale_render_alpha (GimpColorScale *scale)
{
GtkRange *range;
GtkRange *range = GTK_RANGE (scale);
GimpRGB rgb;
gboolean invert;
gdouble a;
@ -576,7 +565,6 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
guchar *buf;
guchar *d, *l;
range = GTK_RANGE (scale);
invert = should_invert (range);
buf = scale->buf;

View File

@ -69,8 +69,6 @@ struct _GimpColorScalesClass
static void gimp_color_scales_class_init (GimpColorScalesClass *klass);
static void gimp_color_scales_init (GimpColorScales *scales);
static void gimp_color_scales_finalize (GObject *object);
static void gimp_color_scales_togg_sensitive (GimpColorSelector *selector,
gboolean sensitive);
static void gimp_color_scales_togg_visible (GimpColorSelector *selector,
@ -129,16 +127,10 @@ gimp_color_scales_get_type (void)
static void
gimp_color_scales_class_init (GimpColorScalesClass *klass)
{
GObjectClass *object_class;
GimpColorSelectorClass *selector_class;
object_class = G_OBJECT_CLASS (klass);
selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_color_scales_finalize;
selector_class->name = _("Scales");
selector_class->help_id = "gimp-colorselector-scales";
selector_class->stock_id = GIMP_STOCK_TOOL_OPTIONS;
@ -152,7 +144,7 @@ gimp_color_scales_class_init (GimpColorScalesClass *klass)
static void
gimp_color_scales_init (GimpColorScales *scales)
{
GimpColorSelector *selector;
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
GtkWidget *table;
GtkWidget *hbox;
GtkWidget *label;
@ -183,8 +175,6 @@ gimp_color_scales_init (GimpColorScales *scales)
static gdouble slider_max_vals[] = { 360, 100, 100, 255, 255, 255, 100 };
static gdouble slider_incs[] = { 30, 10, 10, 16, 16, 16, 10 };
selector = GIMP_COLOR_SELECTOR (scales);
/* don't needs the toggles for our own operation */
selector->toggles_visible = FALSE;
@ -271,25 +261,13 @@ gimp_color_scales_init (GimpColorScales *scales)
gtk_widget_show (label);
}
static void
gimp_color_scales_finalize (GObject *object)
{
GimpColorScales *scales;
scales = GIMP_COLOR_SCALES (object);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_color_scales_togg_sensitive (GimpColorSelector *selector,
gboolean sensitive)
{
GimpColorScales *scales;
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
gint i;
scales = GIMP_COLOR_SCALES (selector);
for (i = 0; i < 6; i++)
gtk_widget_set_sensitive (scales->toggles[i], sensitive);
}
@ -298,11 +276,9 @@ static void
gimp_color_scales_togg_visible (GimpColorSelector *selector,
gboolean visible)
{
GimpColorScales *scales;
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
gint i;
scales = GIMP_COLOR_SCALES (selector);
for (i = 0; i < 6; i++)
{
if (visible)
@ -316,13 +292,11 @@ static void
gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
gboolean show_alpha)
{
GimpColorScales *scales;
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
GtkWidget *label;
GtkWidget *scale;
GtkWidget *spin;
scales = GIMP_COLOR_SCALES (selector);
label = GIMP_SCALE_ENTRY_LABEL (scales->slider_data[6]);
scale = GIMP_SCALE_ENTRY_SCALE (scales->slider_data[6]);
spin = GIMP_SCALE_ENTRY_SPINBUTTON (scales->slider_data[6]);
@ -346,9 +320,7 @@ gimp_color_scales_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv)
{
GimpColorScales *scales;
scales = GIMP_COLOR_SCALES (selector);
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
gimp_color_scales_update_scales (scales, -1);
}
@ -357,9 +329,7 @@ static void
gimp_color_scales_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel)
{
GimpColorScales *scales;
scales = GIMP_COLOR_SCALES (selector);
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
if (channel >= 0 && channel <= 7)
{
@ -380,13 +350,11 @@ static void
gimp_color_scales_update_scales (GimpColorScales *scales,
gint skip)
{
GimpColorSelector *selector;
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
gint values[7];
gchar buffer[8];
gint i;
selector = GIMP_COLOR_SELECTOR (scales);
values[GIMP_COLOR_SELECTOR_HUE] = ROUND (selector->hsv.h * 360.0);
values[GIMP_COLOR_SELECTOR_SATURATION] = ROUND (selector->hsv.s * 100.0);
values[GIMP_COLOR_SELECTOR_VALUE] = ROUND (selector->hsv.v * 100.0);
@ -427,9 +395,7 @@ static void
gimp_color_scales_toggle_update (GtkWidget *widget,
GimpColorScales *scales)
{
GimpColorSelector *selector;
selector = GIMP_COLOR_SELECTOR (scales);
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
if (GTK_TOGGLE_BUTTON (widget)->active)
{
@ -450,11 +416,9 @@ static void
gimp_color_scales_scale_update (GtkAdjustment *adjustment,
GimpColorScales *scales)
{
GimpColorSelector *selector;
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
gint i;
selector = GIMP_COLOR_SELECTOR (scales);
for (i = 0; i < 7; i++)
if (scales->slider_data[i] == GTK_OBJECT (adjustment))
break;
@ -510,14 +474,12 @@ gimp_color_scales_hex_events (GtkWidget *widget,
GdkEvent *event,
GimpColorScales *scales)
{
GimpColorSelector *selector;
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
const gchar *hex_color;
gchar buffer[8];
guint hex_rgb;
guchar r, g, b;
selector = GIMP_COLOR_SELECTOR (scales);
switch (event->type)
{
case GDK_KEY_PRESS:

View File

@ -251,11 +251,8 @@ gimp_color_select_get_type (void)
static void
gimp_color_select_class_init (GimpColorSelectClass *klass)
{
GObjectClass *object_class;
GimpColorSelectorClass *selector_class;
object_class = G_OBJECT_CLASS (klass);
selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -395,9 +392,7 @@ gimp_color_select_init (GimpColorSelect *select)
static void
gimp_color_select_finalize (GObject *object)
{
GimpColorSelect *select;
select = GIMP_COLOR_SELECT (object);
GimpColorSelect *select = GIMP_COLOR_SELECT (object);
if (select->gc)
{
@ -412,9 +407,7 @@ static void
gimp_color_select_togg_visible (GimpColorSelector *selector,
gboolean visible)
{
GimpColorSelect *select;
select = GIMP_COLOR_SELECT (selector);
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
if (visible)
gtk_widget_show (select->toggle_box);
@ -426,9 +419,7 @@ static void
gimp_color_select_togg_sensitive (GimpColorSelector *selector,
gboolean sensitive)
{
GimpColorSelect *select;
select = GIMP_COLOR_SELECT (selector);
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
gtk_widget_set_sensitive (select->toggle_box, sensitive);
}
@ -438,9 +429,7 @@ gimp_color_select_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv)
{
GimpColorSelect *select;
select = GIMP_COLOR_SELECT (selector);
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
gimp_color_select_update (select,
UPDATE_POS | UPDATE_XY_COLOR | UPDATE_Z_COLOR);
@ -450,9 +439,7 @@ static void
gimp_color_select_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel)
{
GimpColorSelect *select;
select = GIMP_COLOR_SELECT (selector);
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
switch ((ColorSelectFillType) channel)
{
@ -500,11 +487,9 @@ gimp_color_select_channel_toggled (GtkWidget *widget,
{
if (GTK_TOGGLE_BUTTON (widget)->active)
{
GimpColorSelector *selector;
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
GimpColorSelectorChannel channel;
selector = GIMP_COLOR_SELECTOR (select);
channel = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"channel"));

View File

@ -271,11 +271,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
GtkWidget *
gimp_color_selection_new (void)
{
GimpColorSelection *selection;
selection = g_object_new (GIMP_TYPE_COLOR_SELECTION, NULL);
return GTK_WIDGET (selection);
return g_object_new (GIMP_TYPE_COLOR_SELECTION, NULL);
}
/**
@ -443,11 +439,9 @@ gimp_color_selection_switch_page (GtkWidget *widget,
guint page_num,
GimpColorSelection *selection)
{
GimpColorNotebook *notebook;
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selection->notebook);
gboolean sensitive;
notebook = GIMP_COLOR_NOTEBOOK (selection->notebook);
sensitive =
(GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->set_channel != NULL);

View File

@ -90,14 +90,11 @@ gimp_frame_get_type (void)
static void
gimp_frame_class_init (GimpFrameClass *klass)
{
GtkWidgetClass *widget_class;
GtkFrameClass *frame_class;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkFrameClass *frame_class = GTK_FRAME_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
widget_class = GTK_WIDGET_CLASS (klass);
frame_class = GTK_FRAME_CLASS (klass);
widget_class->size_request = gimp_frame_size_request;
widget_class->size_allocate = gimp_frame_size_allocate;
widget_class->style_set = gimp_frame_style_set;

View File

@ -102,11 +102,8 @@ gimp_pick_button_get_type (void)
static void
gimp_pick_button_class_init (GimpPickButtonClass* klass)
{
GtkObjectClass *object_class;
GtkButtonClass *button_class;
object_class = GTK_OBJECT_CLASS (klass);
button_class = GTK_BUTTON_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);

View File

@ -98,9 +98,7 @@ gimp_unit_menu_get_type (void)
static void
gimp_unit_menu_class_init (GimpUnitMenuClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -712,10 +710,9 @@ static void
gimp_unit_menu_callback (GtkWidget *widget,
gpointer data)
{
GimpUnitMenu *menu;
GimpUnitMenu *menu = data;
GimpUnit new_unit;
menu = data;
new_unit = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
"gimp_unit_menu"));