Commit 4d24bdbf authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Some code review:

2004-02-18  Michael Natterer  <mitch@gimp.org>

	Some code review:

	* app/config/gimpconfig-deserialize.c
	* app/config/gimpconfig-serialize.c: removed obsolete code which
	made sure serialize_property()/deserialize_property() are only
	called for properties of the correct class. We do it the right way
	for quite a while now and clear the inherited function pointers in
	gimp_config_iface_base_init().

	* app/config/gimprc.c (gimp_rc_dispose): don't forget to chain up.

	* app/base/gimplut.c
	* app/base/lut-funcs.c
	* app/config/gimpconfig-deserialize.c
	* app/config/gimpconfig-serialize.c
	* app/config/gimpconfig-types.c
	* app/config/gimprc.c
	* app/core/gimp-modules.c
	* app/core/gimpbrush.c
	* app/core/gimpcontainer.c
	* app/core/gimpdocumentlist.c
	* app/core/gimpitem.c
	* app/gui/about-dialog.c
	* app/gui/color-notebook.c
	* app/gui/gui.c
	* app/gui/tips-dialog.c
	* app/paint/gimppaintcore.c
	* app/paint-funcs/paint-funcs.c
	* app/widgets/gimpcolorpanel.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainermenuimpl.c
	* app/widgets/gimpselectioneditor.c: removed I/O includes from
	files which don't use lowlevel APIs any more. Also removes
	a whole bunch of G_OS_WIN32 special casing. Removed trailing
	whitespace. Misc tiny cleanups.
parent 361369bc
2004-02-18 Michael Natterer <mitch@gimp.org>
Some code review:
* app/config/gimpconfig-deserialize.c
* app/config/gimpconfig-serialize.c: removed obsolete code which
made sure serialize_property()/deserialize_property() are only
called for properties of the correct class. We do it the right way
for quite a while now and clear the inherited function pointers in
gimp_config_iface_base_init().
* app/config/gimprc.c (gimp_rc_dispose): don't forget to chain up.
* app/base/gimplut.c
* app/base/lut-funcs.c
* app/config/gimpconfig-deserialize.c
* app/config/gimpconfig-serialize.c
* app/config/gimpconfig-types.c
* app/config/gimprc.c
* app/core/gimp-modules.c
* app/core/gimpbrush.c
* app/core/gimpcontainer.c
* app/core/gimpdocumentlist.c
* app/core/gimpitem.c
* app/gui/about-dialog.c
* app/gui/color-notebook.c
* app/gui/gui.c
* app/gui/tips-dialog.c
* app/paint/gimppaintcore.c
* app/paint-funcs/paint-funcs.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainermenuimpl.c
* app/widgets/gimpselectioneditor.c: removed I/O includes from
files which don't use lowlevel APIs any more. Also removes
a whole bunch of G_OS_WIN32 special casing. Removed trailing
whitespace. Misc tiny cleanups.
2004-02-18 Michael Natterer <mitch@gimp.org>
 
* app/display/gimpdisplayshell-handlers.c
......@@ -20,8 +20,6 @@
#include "config.h"
#include <stdio.h>
#include <glib-object.h>
#include "base-types.h"
......
......@@ -18,8 +18,6 @@
#include "config.h"
#include <stdio.h>
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"
......@@ -331,7 +329,7 @@ posterize_lut_setup (GimpLut *lut,
g_return_if_fail (lut != NULL);
gimp_lut_setup_exact (lut, (GimpLutFunc) posterize_lut_func,
(gpointer) &levels , n_channels);
(gpointer) &levels, n_channels);
}
/* --------------- equalize ------------- */
......
......@@ -21,14 +21,6 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -253,7 +245,6 @@ gimp_config_deserialize_property (GimpConfig *config,
{
GTypeClass *owner_class;
GimpConfigInterface *config_iface;
GimpConfigInterface *parent_iface;
GParamSpec *prop_spec;
GTokenType token = G_TOKEN_RIGHT_PAREN;
GValue value = { 0, };
......@@ -269,28 +260,7 @@ gimp_config_deserialize_property (GimpConfig *config,
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
/* We must call deserialize_property() *only* if the *exact* class
* which implements it is param_spec->owner_type's class.
*
* Therefore, we ask param_spec->owner_type's immediate parent class
* for it's GimpConfigInterface and check if we get a different pointer.
*
* (if the pointers are the same, param_spec->owner_type's
* GimpConfigInterface is inherited from one of it's parent classes
* and thus not able to handle param_spec->owner_type's properties).
*/
if (config_iface)
{
GTypeClass *owner_parent_class;
owner_parent_class = g_type_class_peek_parent (owner_class),
parent_iface = g_type_interface_peek (owner_parent_class,
GIMP_TYPE_CONFIG);
}
if (config_iface &&
config_iface != parent_iface && /* see comment above */
config_iface->deserialize_property &&
config_iface->deserialize_property (config,
prop_spec->param_id,
......
......@@ -21,18 +21,10 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
......@@ -205,7 +197,6 @@ gimp_config_serialize_property (GimpConfig *config,
{
GTypeClass *owner_class;
GimpConfigInterface *config_iface;
GimpConfigInterface *parent_iface = NULL;
GValue value = { 0, };
gboolean success = FALSE;
......@@ -229,28 +220,7 @@ gimp_config_serialize_property (GimpConfig *config,
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
/* We must call serialize_property() *only* if the *exact* class
* which implements it is param_spec->owner_type's class.
*
* Therefore, we ask param_spec->owner_type's immediate parent class
* for it's GimpConfigInterface and check if we get a different pointer.
*
* (if the pointers are the same, param_spec->owner_type's
* GimpConfigInterface is inherited from one of it's parent classes
* and thus not able to handle param_spec->owner_type's properties).
*/
if (config_iface)
{
GTypeClass *owner_parent_class;
owner_parent_class = g_type_class_peek_parent (owner_class),
parent_iface = g_type_interface_peek (owner_parent_class,
GIMP_TYPE_CONFIG);
}
if (config_iface &&
config_iface != parent_iface && /* see comment above */
config_iface->serialize_property &&
config_iface->serialize_property (config,
param_spec->param_id,
......
......@@ -21,10 +21,8 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <string.h>
#include <glib-object.h>
......
......@@ -23,16 +23,8 @@
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "libgimpbase/gimpbase.h"
#include "config-types.h"
......@@ -173,12 +165,14 @@ gimp_rc_dispose (GObject *object)
if (rc->save_idle_id)
gimp_rc_idle_save (rc);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_rc_finalize (GObject *object)
{
GimpRc *rc = (GimpRc *) object;
GimpRc *rc = GIMP_RC (object);
if (rc->system_gimprc)
{
......
......@@ -21,14 +21,6 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <time.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -157,7 +149,7 @@ gimp_modules_load (Gimp *gimp)
}
static void
add_to_inhibit_string (gpointer data,
add_to_inhibit_string (gpointer data,
gpointer user_data)
{
GimpModule *module = data;
......
......@@ -40,8 +40,6 @@
#define _O_BINARY 0
#endif
#include <stdio.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
......
......@@ -40,8 +40,6 @@
#define _O_BINARY 0
#endif
#include <stdio.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
......
......@@ -22,16 +22,9 @@
#include "config.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "core-types.h"
#include "gimp.h"
......@@ -270,9 +263,7 @@ gimp_container_config_iface_init (GimpConfigInterface *config_iface)
static void
gimp_container_dispose (GObject *object)
{
GimpContainer *container;
container = GIMP_CONTAINER (object);
GimpContainer *container = GIMP_CONTAINER (object);
while (container->handlers)
gimp_container_remove_handler (container,
......@@ -294,9 +285,7 @@ gimp_container_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpContainer *container;
container = GIMP_CONTAINER (object);
GimpContainer *container = GIMP_CONTAINER (object);
switch (property_id)
{
......@@ -319,9 +308,7 @@ gimp_container_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpContainer *container;
container = GIMP_CONTAINER (object);
GimpContainer *container = GIMP_CONTAINER (object);
switch (property_id)
{
......@@ -341,11 +328,9 @@ static gint64
gimp_container_get_memsize (GimpObject *object,
gint64 *gui_size)
{
GimpContainer *container;
GimpContainer *container = GIMP_CONTAINER (object);
gint64 memsize = 0;
GList *list;
gint64 memsize = 0;
container = GIMP_CONTAINER (object);
for (list = container->handlers; list; list = g_list_next (list))
{
......
......@@ -18,17 +18,8 @@
#include "config.h"
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "core-types.h"
#include "config/gimpconfig.h"
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <glib-object.h>
......
......@@ -18,8 +18,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
......@@ -179,7 +177,7 @@ about_dialog_create (void)
g_signal_connect (widget, "key_press_event",
G_CALLBACK (about_dialog_key),
NULL);
gtk_widget_set_events (widget, GDK_BUTTON_PRESS_MASK);
if (! about_dialog_load_logo (widget))
......@@ -244,7 +242,7 @@ about_dialog_create (void)
0, 0);
about_info.layout = gtk_widget_create_pango_layout (about_info.logo_area,
NULL);
g_object_weak_ref (G_OBJECT (about_info.logo_area),
g_object_weak_ref (G_OBJECT (about_info.logo_area),
(GWeakNotify) g_object_unref, about_info.layout);
font_desc = pango_font_description_from_string ("Sans, 11");
......@@ -347,7 +345,7 @@ about_dialog_logo_expose (GtkWidget *widget,
/* weird magic to determine the way the logo should be shown */
mask &= ~GDK_BUTTON3_MASK;
pp = (mask &= (GDK_SHIFT_MASK | GDK_CONTROL_MASK) &
pp = (mask &= (GDK_SHIFT_MASK | GDK_CONTROL_MASK) &
(GDK_CONTROL_MASK | GDK_MOD1_MASK) &
(GDK_MOD1_MASK | ~GDK_SHIFT_MASK),
height = mask ? (about_info.pixmaparea.height > 0) &&
......@@ -380,7 +378,7 @@ about_dialog_logo_expose (GtkWidget *widget,
widget->style->black_gc,
TRUE,
0, 0, about_info.pixmaparea.width, 158);
}
if (about_info.visible == TRUE)
......@@ -393,7 +391,7 @@ about_dialog_logo_expose (GtkWidget *widget,
(about_info.textarea.width - width) / 2;
layout_y = about_info.textarea.y +
(about_info.textarea.height - height) / 2;
if (about_info.textrange[1] > 0)
{
GdkRegion *covered_region = NULL;
......@@ -451,7 +449,7 @@ about_dialog_key (GtkWidget *widget,
default:
break;
}
return FALSE;
}
......@@ -497,7 +495,7 @@ mix_gradient (PangoColor *gradient, guint ncolors,
target->blue = gradient[ncolors-1].blue;
return;
}
index = (int) floor (pos * (ncolors-1));
pos = pos * (ncolors - 1) - index;
......@@ -528,17 +526,17 @@ reshuffle_array (void)
GRand *gr = g_rand_new ();
gint i;
for (i = 0; i < nscroll_texts; i++)
for (i = 0; i < nscroll_texts; i++)
{
shuffle_array[i] = i;
}
for (i = 0; i < nscroll_texts; i++)
for (i = 0; i < nscroll_texts; i++)
{
gint j;
j = g_rand_int_range (gr, 0, nscroll_texts);
if (i != j)
if (i != j)
{
gint t;
......@@ -729,7 +727,7 @@ decorate_text (PangoLayout *layout, gint anim_type, gdouble time)
g_printerr ("Unknown animation type %d\n", anim_type);
}
pango_layout_set_attributes (layout, attrlist);
pango_attr_list_unref (attrlist);
......@@ -797,7 +795,7 @@ about_dialog_timer (gpointer data)
if (about_info.index >= G_N_ELEMENTS (founders))
{
about_info.index = 0;
/* skip the translators section when the translator
* did not provide a translation with his name
*/
......@@ -853,7 +851,7 @@ about_dialog_timer (gpointer data)
about_info.index++;
}
}
if (about_info.state == 4)
{
if (about_info.index >= G_N_ELEMENTS (contri_intro))
......@@ -871,11 +869,11 @@ about_dialog_timer (gpointer data)
if (about_info.state == 5)
{
about_info.index += 1;
if (about_info.index == nscroll_texts)
about_info.index = 0;
text = insert_spacers (scroll_text[shuffle_array[about_info.index]]);
}
......@@ -998,7 +996,7 @@ about_dialog_load_logo (GtkWidget *window)
pango_layout_set_font_description (layout, desc);
pango_layout_set_justify (layout, PANGO_ALIGN_CENTER);
pango_layout_set_text (layout, GIMP_VERSION, -1);
gc = gdk_gc_new (about_info.logo_pixmap);
/* draw a defined content to the Pixmap */
......@@ -1007,7 +1005,7 @@ about_dialog_load_logo (GtkWidget *window)
0, 0,
about_info.pixmaparea.width,
about_info.pixmaparea.height * 2);
gdk_draw_pixbuf (GDK_DRAWABLE (about_info.logo_pixmap),
gc, pixbuf,
0, 0, 0, 0,
......@@ -1162,7 +1160,7 @@ about_dialog_load_logo (GtkWidget *window)
{
gdk_draw_pixbuf (GDK_DRAWABLE (about_info.logo_pixmap),
gc, white (noise), 0, 0,
(about_info.pixmaparea.width -
(about_info.pixmaparea.width -
level (white (noise))) / 2,
about_info.pixmaparea.height +
(about_info.pixmaparea.height -
......
......@@ -20,12 +20,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
......
......@@ -18,11 +18,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
......
......@@ -18,8 +18,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
......@@ -179,7 +177,7 @@ about_dialog_create (void)
g_signal_connect (widget, "key_press_event",
G_CALLBACK (about_dialog_key),
NULL);
gtk_widget_set_events (widget, GDK_BUTTON_PRESS_MASK);
if (! about_dialog_load_logo (widget))
......@@ -244,7 +242,7 @@ about_dialog_create (void)
0, 0);
about_info.layout = gtk_widget_create_pango_layout (about_info.logo_area,
NULL);
g_object_weak_ref (G_OBJECT (about_info.logo_area),
g_object_weak_ref (G_OBJECT (about_info.logo_area),
(GWeakNotify) g_object_unref, about_info.layout);
font_desc = pango_font_description_from_string ("Sans, 11");
......@@ -347,7 +345,7 @@ about_dialog_logo_expose (GtkWidget *widget,
/* weird magic to determine the way the logo should be shown */
mask &= ~GDK_BUTTON3_MASK;
pp = (mask &= (GDK_SHIFT_MASK | GDK_CONTROL_MASK) &
pp = (mask &= (GDK_SHIFT_MASK | GDK_CONTROL_MASK) &
(GDK_CONTROL_MASK | GDK_MOD1_MASK) &
(GDK_MOD1_MASK | ~GDK_SHIFT_MASK),
height = mask ? (about_info.pixmaparea.height > 0) &&
......@@ -380,7 +378,7 @@ about_dialog_logo_expose (GtkWidget *widget,
widget->style->black_gc,
TRUE,
0, 0, about_info.pixmaparea.width, 158);
}
if (about_info.visible == TRUE)
......@@ -393,7 +391,7 @@ about_dialog_logo_expose (GtkWidget *widget,
(about_info.textarea.width - width) / 2;
layout_y = about_info.textarea.y +
(about_info.textarea.height - height) / 2;
if (about_info.textrange[1] > 0)
{
GdkRegion *covered_region = NULL;
......@@ -451,7 +449,7 @@ about_dialog_key (GtkWidget *widget,
default:
break;
}
return FALSE;
}
......@@ -497,7 +495,7 @@ mix_gradient (PangoColor *gradient, guint ncolors,
target->blue = gradient[ncolors-1].blue;
return;
}
index = (int) floor (pos * (ncolors-1));
pos = pos * (ncolors - 1) - index;
......@@ -528,17 +526,17 @@ reshuffle_array (void)
GRand *gr = g_rand_new ();
gint i;
for (i = 0; i < nscroll_texts; i++)
for (i = 0; i < nscroll_texts; i++)
{
shuffle_array[i] = i;
}
for (i = 0; i < nscroll_texts; i++)
for (i = 0; i < nscroll_texts; i++)
{
gint j;
j = g_rand_int_range (gr, 0, nscroll_texts);
if (i != j)
if (i != j)
{
gint t;
......@@ -729,7 +727,7 @@ decorate_text (PangoLayout *layout, gint anim_type, gdouble time)
g_printerr ("Unknown animation type %d\n", anim_type);
}