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

app/widgets/Makefile.am app/widgets/widgets-types.h made an object out of

2004-06-16  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpcontrollerinfo.[ch]: made an object out of
	the GimpControllerInfo struct.

	* app/widgets/gimpcontrollers.c: changed accordingly.
parent 02e41c06
2004-06-16 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpcontrollerinfo.[ch]: made an object out of
the GimpControllerInfo struct.
* app/widgets/gimpcontrollers.c: changed accordingly.
2004-06-16 Jakub Steiner <jimmac@ximian.com>
* etc/controllerrc: fix typo
......
......@@ -71,6 +71,8 @@ libappwidgets_a_sources = \
gimpcontainerview.h \
gimpcontainerview-utils.c \
gimpcontainerview-utils.h \
gimpcontrollerinfo.c \
gimpcontrollerinfo.h \
gimpcontrollers.c \
gimpcontrollers.h \
gimpcontrollerwheel.c \
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcontrollerinfo.c
* Copyright (C) 2004 Michael Natterer <mitch@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 "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "gimpcontrollerinfo.h"
#include "gimp-intl.h"
static void gimp_controller_info_class_init (GimpControllerInfoClass *klass);
static void gimp_controller_info_init (GimpControllerInfo *info);
static void gimp_controller_info_finalize (GObject *object);
static void gimp_controller_info_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_controller_info_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpObjectClass *parent_class = NULL;
GType
gimp_controller_info_get_type (void)
{
static GType controller_type = 0;
if (! controller_type)
{
static const GTypeInfo controller_info =
{
sizeof (GimpControllerInfoClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_controller_info_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpControllerInfo),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_controller_info_init,
};
controller_type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpControllerInfo",
&controller_info, 0);
}
return controller_type;
}
static void
gimp_controller_info_class_init (GimpControllerInfoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_controller_info_finalize;
object_class->set_property = gimp_controller_info_set_property;
object_class->get_property = gimp_controller_info_get_property;
}
static void
gimp_controller_info_init (GimpControllerInfo *info)
{
info->controller = NULL;
info->mapping = g_hash_table_new_full (g_int_hash,
g_int_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
}
static void
gimp_controller_info_finalize (GObject *object)
{
GimpControllerInfo *info = GIMP_CONTROLLER_INFO (object);
if (info->controller)
g_object_unref (info->controller);
if (info->mapping)
g_hash_table_destroy (info->mapping);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_controller_info_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpControllerInfo *info = GIMP_CONTROLLER_INFO (object);
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_controller_info_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpControllerInfo *info = GIMP_CONTROLLER_INFO (object);
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcontrollerinfo.h
* Copyright (C) 2004 Michael Natterer <mitch@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_CONTROLLER_WHELL_H__
#define __GIMP_CONTROLLER_INFO_H__
#include "core/gimpobject.h"
#define GIMP_TYPE_CONTROLLER_INFO (gimp_controller_info_get_type ())
#define GIMP_CONTROLLER_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTROLLER_INFO, GimpControllerInfo))
#define GIMP_CONTROLLER_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTROLLER_INFO, GimpControllerInfoClass))
#define GIMP_IS_CONTROLLER_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTROLLER_INFO))
#define GIMP_IS_CONTROLLER_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTROLLER_INFO))
#define GIMP_CONTROLLER_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONTROLLER_INFO, GimpControllerInfoClass))
typedef struct _GimpControllerInfoClass GimpControllerInfoClass;
struct _GimpControllerInfo
{
GimpObject parent_instance;
GimpController *controller;
GHashTable *mapping;
};
struct _GimpControllerInfoClass
{
GimpObjectClass parent_class;
};
GType gimp_controller_info_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_CONTROLLER_INFO_H__ */
......@@ -33,6 +33,7 @@
#include "core/gimp.h"
#include "gimpcontrollerinfo.h"
#include "gimpcontrollers.h"
#include "gimpcontrollerwheel.h"
#include "gimpuimanager.h"
......@@ -44,7 +45,6 @@
typedef struct _GimpControllerManager GimpControllerManager;
typedef struct _GimpControllerInfo GimpControllerInfo;
struct _GimpControllerManager
{
......@@ -53,19 +53,12 @@ struct _GimpControllerManager
GimpUIManager *ui_manager;
};
struct _GimpControllerInfo
{
GimpController *controller;
GHashTable *mapping;
};
/* local function prototypes */
static GimpControllerManager * gimp_controller_manager_get (Gimp *gimp);
static void gimp_controller_manager_free (GimpControllerManager *manager);
static void gimp_controller_info_free (GimpControllerInfo *info);
static gboolean gimp_controller_info_event (GimpController *controller,
const GimpControllerEvent *event,
GimpControllerInfo *info);
......@@ -260,7 +253,7 @@ gimp_controller_manager_get (Gimp *gimp)
static void
gimp_controller_manager_free (GimpControllerManager *manager)
{
g_list_foreach (manager->controllers, (GFunc) gimp_controller_info_free, NULL);
g_list_foreach (manager->controllers, (GFunc) g_object_unref, NULL);
g_list_free (manager->controllers);
g_object_unref (manager->ui_manager);
......@@ -268,18 +261,6 @@ gimp_controller_manager_free (GimpControllerManager *manager)
g_free (manager);
}
static void
gimp_controller_info_free (GimpControllerInfo *info)
{
if (info->controller)
g_object_unref (info->controller);
if (info->mapping)
g_hash_table_destroy (info->mapping);
g_free (info);
}
static GTokenType
gimp_controller_deserialize (GimpControllerManager *manager,
GScanner *scanner)
......@@ -300,13 +281,9 @@ gimp_controller_deserialize (GimpControllerManager *manager,
if (! g_type_is_a (controller_type, GIMP_TYPE_CONTROLLER))
goto error;
info = g_new0 (GimpControllerInfo, 1);
info = g_object_new (GIMP_TYPE_CONTROLLER_INFO, NULL);
info->controller = gimp_controller_new (controller_type);
info->mapping = g_hash_table_new_full (g_int_hash,
g_int_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
/* EEEEEK */
{
......@@ -439,7 +416,7 @@ gimp_controller_deserialize (GimpControllerManager *manager,
{
error:
if (info)
gimp_controller_info_free (info);
g_object_unref (info);
}
return token;
......
......@@ -56,6 +56,7 @@ typedef struct _GimpPreviewRendererImage GimpPreviewRendererImage;
typedef struct _GimpPreviewRendererImagefile GimpPreviewRendererImagefile;
typedef struct _GimpPreviewRendererVectors GimpPreviewRendererVectors;
typedef struct _GimpControllerInfo GimpControllerInfo;
typedef struct _GimpControllerWheel GimpControllerWheel;
......
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