mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-11 13:10:07 +00:00
removed gtk_signal_init() compat define.
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org> * gtk/gtksignal.h: removed gtk_signal_init() compat define. * gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument GTypeDebugFlags debug_flags and pass it on to g_type_init (); deprecated this function. * gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as argument. Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org> * gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS. Sun Feb 4 07:59:57 2001 Tim Janik <timj@gtk.org> * gdk-pixbuf.h: DOH! don't include glib/gobject.h but glib-object.h, we finally need the gobject->gruntime rename. * *.c: scratched calls to g_type_init(), there's simply no point in doing that, use gtk_init().
This commit is contained in:
parent
f2ceb1c46a
commit
89a0a894bc
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,18 @@
|
||||
Sun Feb 4 07:55:17 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtksignal.h: removed gtk_signal_init() compat define.
|
||||
|
||||
* gtk/gtktypeutils.[hc]: gtk_tpye_init() take an additional argument
|
||||
GTypeDebugFlags debug_flags and pass it on to g_type_init ();
|
||||
deprecated this function.
|
||||
|
||||
* gdk/gdk.c (gdk_init_check): call g_type_init () with 0 as
|
||||
argument.
|
||||
|
||||
Sun Feb 4 07:45:45 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkdebug.h: nuke GTK_DEBUG_OBJECTS and GTK_DEBUG_SIGNALS.
|
||||
|
||||
2001-02-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Fix bug reported by
|
||||
|
@ -1,3 +1,11 @@
|
||||
Sun Feb 4 07:59:57 2001 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gdk-pixbuf.h: DOH! don't include glib/gobject.h but glib-object.h,
|
||||
we finally need the gobject->gruntime rename.
|
||||
|
||||
* *.c: scratched calls to g_type_init(), there's simply no point in
|
||||
doing that, use gtk_init().
|
||||
|
||||
2001-02-01 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gdk-pixbuf-loader.c, gdk-pixbuf-loader.h: rename "private" field
|
||||
|
@ -50,8 +50,6 @@ gdk_pixbuf_animation_get_type (void)
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) NULL,
|
||||
};
|
||||
|
||||
g_type_init ();
|
||||
|
||||
object_type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GdkPixbufAnimation",
|
||||
@ -458,13 +456,9 @@ gdk_pixbuf_frame_get_type (void)
|
||||
static GType our_type = 0;
|
||||
|
||||
if (our_type == 0)
|
||||
{
|
||||
g_type_init ();
|
||||
|
||||
our_type = g_boxed_type_register_static ("GdkPixbufFrame",
|
||||
gdk_pixbuf_frame_copy,
|
||||
gdk_pixbuf_frame_free);
|
||||
}
|
||||
our_type = g_boxed_type_register_static ("GdkPixbufFrame",
|
||||
gdk_pixbuf_frame_copy,
|
||||
gdk_pixbuf_frame_free);
|
||||
|
||||
return our_type;
|
||||
}
|
||||
|
@ -93,8 +93,6 @@ gdk_pixbuf_loader_get_type (void)
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gdk_pixbuf_loader_init
|
||||
};
|
||||
|
||||
g_type_init ();
|
||||
|
||||
loader_type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GdkPixbufLoader",
|
||||
|
@ -53,8 +53,6 @@ gdk_pixbuf_get_type (void)
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) NULL,
|
||||
};
|
||||
|
||||
g_type_init ();
|
||||
|
||||
object_type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GdkPixbuf",
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf-features.h>
|
||||
#include <gobject/gobject.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -323,7 +323,7 @@ gdk_init_check (int *argc,
|
||||
|
||||
GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
|
||||
|
||||
g_type_init ();
|
||||
g_type_init (0);
|
||||
|
||||
result = _gdk_windowing_init_check (argc_orig, argv_orig);
|
||||
|
||||
|
@ -140,6 +140,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
|
||||
gtkradiomenuitem.h \
|
||||
gtkrange.h \
|
||||
gtkrc.h \
|
||||
gtkrcdata.h \
|
||||
gtkruler.h \
|
||||
gtkscale.h \
|
||||
gtkscrollbar.h \
|
||||
@ -298,6 +299,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
|
||||
gtkrange.c \
|
||||
gtkrbtree.c \
|
||||
gtkrc.c \
|
||||
gtkrcdata.c \
|
||||
gtkruler.c \
|
||||
gtkscale.c \
|
||||
gtkscrollbar.c \
|
||||
|
@ -116,6 +116,7 @@
|
||||
#include <gtk/gtkradiomenuitem.h>
|
||||
#include <gtk/gtkrange.h>
|
||||
#include <gtk/gtkrc.h>
|
||||
#include <gtk/gtkrcdata.h>
|
||||
#include <gtk/gtkruler.h>
|
||||
#include <gtk/gtkscale.h>
|
||||
#include <gtk/gtkscrollbar.h>
|
||||
|
@ -32,14 +32,12 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef enum {
|
||||
GTK_DEBUG_OBJECTS = 1 << 0,
|
||||
GTK_DEBUG_MISC = 1 << 1,
|
||||
GTK_DEBUG_SIGNALS = 1 << 2,
|
||||
GTK_DEBUG_DND = 1 << 3,
|
||||
GTK_DEBUG_PLUGSOCKET = 1 << 4,
|
||||
GTK_DEBUG_TEXT = 1 << 5,
|
||||
GTK_DEBUG_TREE = 1 << 6,
|
||||
GTK_DEBUG_UPDATES = 1 << 7
|
||||
GTK_DEBUG_MISC = 1 << 0,
|
||||
GTK_DEBUG_DND = 1 << 1,
|
||||
GTK_DEBUG_PLUGSOCKET = 1 << 2,
|
||||
GTK_DEBUG_TEXT = 1 << 3,
|
||||
GTK_DEBUG_TREE = 1 << 4,
|
||||
GTK_DEBUG_UPDATES = 1 << 5
|
||||
} GtkDebugFlag;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
112
gtk/gtkrc.c
112
gtk/gtkrc.c
@ -57,6 +57,7 @@
|
||||
#include "gtkthemes.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkiconfactory.h"
|
||||
#include "gtkrcdata.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
@ -101,6 +102,8 @@ static void gtk_rc_parse_any (const gchar *input_nam
|
||||
const gchar *input_string);
|
||||
static guint gtk_rc_parse_statement (GScanner *scanner);
|
||||
static guint gtk_rc_parse_style (GScanner *scanner);
|
||||
static guint gtk_rc_parse_assignment (GScanner *scanner,
|
||||
const gchar *var_name);
|
||||
static guint gtk_rc_parse_bg (GScanner *scanner,
|
||||
GtkRcStyle *style);
|
||||
static guint gtk_rc_parse_fg (GScanner *scanner,
|
||||
@ -566,9 +569,9 @@ gtk_rc_init (void)
|
||||
|
||||
gint i, j;
|
||||
|
||||
static gboolean initted = FALSE;
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initted)
|
||||
if (!initialized)
|
||||
{
|
||||
gint length;
|
||||
gchar *locale;
|
||||
@ -579,8 +582,7 @@ gtk_rc_init (void)
|
||||
#else
|
||||
locale = setlocale (LC_CTYPE, NULL);
|
||||
#endif
|
||||
|
||||
initted = TRUE;
|
||||
initialized = TRUE;
|
||||
|
||||
pixmap_path[0] = NULL;
|
||||
module_path[0] = NULL;
|
||||
@ -628,8 +630,14 @@ gtk_rc_init (void)
|
||||
|
||||
g_free (normalized_locale);
|
||||
}
|
||||
|
||||
/* setup global rc-file variables */
|
||||
gtk_rc_data_install_property (g_param_spec_int ("mouse-timeout", NULL, NULL,
|
||||
0, 1000, 0,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
}
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (gtk_rc_data_get_global ()));
|
||||
i = 0;
|
||||
while (gtk_rc_default_files[i] != NULL)
|
||||
{
|
||||
@ -649,6 +657,11 @@ gtk_rc_init (void)
|
||||
gtk_rc_parse (gtk_rc_default_files[i]);
|
||||
i++;
|
||||
}
|
||||
/* setup global rc-file variables after the fact */
|
||||
gtk_rc_data_install_property (g_param_spec_float ("foo-number", NULL, NULL,
|
||||
-10000, 10000, 0,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
g_object_thaw_notify (G_OBJECT (gtk_rc_data_get_global ()));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1535,54 +1548,119 @@ gtk_rc_parse_statement (GScanner *scanner)
|
||||
guint token;
|
||||
|
||||
token = g_scanner_peek_next_token (scanner);
|
||||
|
||||
|
||||
switch (token)
|
||||
{
|
||||
gboolean is_varname;
|
||||
gchar *p;
|
||||
case GTK_RC_TOKEN_INCLUDE:
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != GTK_RC_TOKEN_INCLUDE)
|
||||
return GTK_RC_TOKEN_INCLUDE;
|
||||
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_STRING)
|
||||
return G_TOKEN_STRING;
|
||||
|
||||
|
||||
gtk_rc_parse_file (scanner->value.v_string, FALSE);
|
||||
return G_TOKEN_NONE;
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_STYLE:
|
||||
return gtk_rc_parse_style (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_BINDING:
|
||||
return gtk_binding_parse_binding (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_PIXMAP_PATH:
|
||||
return gtk_rc_parse_pixmap_path (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_WIDGET:
|
||||
return gtk_rc_parse_path_pattern (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_WIDGET_CLASS:
|
||||
return gtk_rc_parse_path_pattern (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_CLASS:
|
||||
return gtk_rc_parse_path_pattern (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_MODULE_PATH:
|
||||
return gtk_rc_parse_module_path (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_IM_MODULE_PATH:
|
||||
return gtk_rc_parse_im_module_path (scanner);
|
||||
|
||||
|
||||
case GTK_RC_TOKEN_IM_MODULE_FILE:
|
||||
return gtk_rc_parse_im_module_file (scanner);
|
||||
|
||||
|
||||
case G_TOKEN_IDENTIFIER:
|
||||
is_varname = strchr (G_CSET_a_2_z "_", scanner->next_value.v_identifier[0]) != NULL;
|
||||
for (p = scanner->next_value.v_identifier + 1; *p && is_varname; p++)
|
||||
is_varname &= strchr (G_CSET_a_2_z G_CSET_DIGITS "_-", *p) != NULL;
|
||||
if (is_varname)
|
||||
{
|
||||
gchar *name;
|
||||
|
||||
g_scanner_get_next_token (scanner); /* eat identifier */
|
||||
name = g_strdup (scanner->value.v_identifier);
|
||||
|
||||
token = gtk_rc_parse_assignment (scanner, name);
|
||||
g_free (name);
|
||||
|
||||
return token;
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
g_scanner_get_next_token (scanner);
|
||||
return /* G_TOKEN_SYMBOL */ GTK_RC_TOKEN_STYLE;
|
||||
}
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_rc_parse_assignment (GScanner *scanner,
|
||||
const gchar *var_name)
|
||||
{
|
||||
guint token;
|
||||
gboolean negate = FALSE;
|
||||
gchar *location;
|
||||
|
||||
if (g_scanner_get_next_token (scanner) != '=')
|
||||
return '=';
|
||||
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token == '-')
|
||||
{
|
||||
negate = TRUE;
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
if (token != G_TOKEN_FLOAT &&
|
||||
token != G_TOKEN_INT)
|
||||
return G_TOKEN_INT;
|
||||
}
|
||||
location = g_strdup_printf ("%s:%u", scanner->input_name, scanner->line);
|
||||
switch (token)
|
||||
{
|
||||
case G_TOKEN_INT:
|
||||
gtk_rc_data_set_long_property (var_name,
|
||||
negate ? -scanner->value.v_int : scanner->value.v_int,
|
||||
location);
|
||||
break;
|
||||
case G_TOKEN_FLOAT:
|
||||
gtk_rc_data_set_double_property (var_name,
|
||||
negate ? -scanner->value.v_float : scanner->value.v_float,
|
||||
location);
|
||||
break;
|
||||
case G_TOKEN_STRING:
|
||||
gtk_rc_data_set_string_property (var_name,
|
||||
scanner->value.v_string,
|
||||
location);
|
||||
break;
|
||||
default:
|
||||
return G_TOKEN_INT;
|
||||
}
|
||||
g_free (location);
|
||||
|
||||
return G_TOKEN_NONE;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_rc_parse_style (GScanner *scanner)
|
||||
{
|
||||
|
10
gtk/gtkrc.h
10
gtk/gtkrc.h
@ -91,22 +91,24 @@ struct _GtkRcStyleClass
|
||||
* g_object_new (G_OBJECT_TYPE (style), NULL);
|
||||
* should work in most cases.
|
||||
*/
|
||||
GtkRcStyle *(*clone) (GtkRcStyle *rc_style);
|
||||
GtkRcStyle * (*clone) (GtkRcStyle *rc_style);
|
||||
|
||||
/* Fill in engine specific parts of GtkRcStyle by parsing contents
|
||||
* of brackets. Returns G_TOKEN_NONE if succesful, otherwise returns
|
||||
* the token it expected but didn't get.
|
||||
*/
|
||||
guint (*parse) (GtkRcStyle *rc_style, GScanner *scanner);
|
||||
guint (*parse) (GtkRcStyle *rc_style,
|
||||
GScanner *scanner);
|
||||
|
||||
/* Combine RC style data from src into dest. If overriden, this
|
||||
* function should chain to the parent.
|
||||
*/
|
||||
void (*merge) (GtkRcStyle *dest, GtkRcStyle *src);
|
||||
void (*merge) (GtkRcStyle *dest,
|
||||
GtkRcStyle *src);
|
||||
|
||||
/* Create an empty style suitable to this RC style
|
||||
*/
|
||||
GtkStyle *(*create_style) (GtkRcStyle *rc_style);
|
||||
GtkStyle * (*create_style) (GtkRcStyle *rc_style);
|
||||
};
|
||||
|
||||
void gtk_rc_init (void);
|
||||
|
325
gtk/gtkrcdata.c
Normal file
325
gtk/gtkrcdata.c
Normal file
@ -0,0 +1,325 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "gtkrcdata.h"
|
||||
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static void gtk_rc_data_init (GtkRCData *data);
|
||||
static void gtk_rc_data_class_init (GtkRCDataClass *class);
|
||||
static GObject* gtk_rc_data_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_properties);
|
||||
static void gtk_rc_data_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer);
|
||||
static void gtk_rc_data_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer);
|
||||
static void gtk_rc_data_notify (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
/* --- variables --- */
|
||||
static gpointer parent_class = NULL;
|
||||
static GtkRCData *the_singleton = NULL;
|
||||
|
||||
|
||||
/* --- functions --- */
|
||||
GType
|
||||
gtk_rc_data_get_type (void)
|
||||
{
|
||||
static GType rc_data_type = 0;
|
||||
|
||||
if (!rc_data_type)
|
||||
{
|
||||
static const GTypeInfo rc_data_info =
|
||||
{
|
||||
sizeof (GtkRCDataClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gtk_rc_data_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkRCData),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gtk_rc_data_init,
|
||||
};
|
||||
|
||||
rc_data_type = g_type_register_static (G_TYPE_OBJECT, "GtkRCData", &rc_data_info, 0);
|
||||
}
|
||||
|
||||
return rc_data_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_rc_data_init (GtkRCData *data)
|
||||
{
|
||||
g_datalist_init (&data->qvalues);
|
||||
data->pvalues = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_rc_data_class_init (GtkRCDataClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->constructor = gtk_rc_data_constructor;
|
||||
gobject_class->get_property = gtk_rc_data_get_property;
|
||||
gobject_class->set_property = gtk_rc_data_set_property;
|
||||
gobject_class->notify = gtk_rc_data_notify;
|
||||
}
|
||||
|
||||
static GObject*
|
||||
gtk_rc_data_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_properties)
|
||||
{
|
||||
GObject *object;
|
||||
|
||||
if (!the_singleton)
|
||||
{
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type,
|
||||
n_construct_properties,
|
||||
construct_properties);
|
||||
the_singleton = GTK_RC_DATA (g_object_ref (object));
|
||||
}
|
||||
else
|
||||
object = g_object_ref (G_OBJECT (the_singleton));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
GtkRCData*
|
||||
gtk_rc_data_get_global (void)
|
||||
{
|
||||
if (!the_singleton)
|
||||
g_object_new (GTK_TYPE_RC_DATA, NULL);
|
||||
|
||||
return the_singleton; /* we don't add a reference count here, we'd be rc_data_ref_global() if we did */
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GtkRCData *data,
|
||||
GParamSpec *pspec,
|
||||
GtkRCDataValue *dvalue)
|
||||
{
|
||||
if (g_value_types_exchangable (G_VALUE_TYPE (&dvalue->rc_value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
|
||||
{
|
||||
GValue tmp_value = { 0, };
|
||||
|
||||
g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_value_convert (&dvalue->rc_value, &tmp_value);
|
||||
g_param_value_validate (pspec, &tmp_value);
|
||||
g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value);
|
||||
g_value_unset (&tmp_value);
|
||||
}
|
||||
else
|
||||
g_message ("%s: unable to convert rc-value of type `%s' for rc-property \"%s\" of type `%s'",
|
||||
dvalue->location,
|
||||
G_VALUE_TYPE_NAME (&dvalue->rc_value),
|
||||
pspec->name,
|
||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_rc_data_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer)
|
||||
{
|
||||
GtkRCData *data = GTK_RC_DATA (object);
|
||||
|
||||
g_value_copy (value, data->pvalues + property_id - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_rc_data_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer)
|
||||
{
|
||||
GtkRCData *data = GTK_RC_DATA (object);
|
||||
|
||||
g_value_copy (data->pvalues + property_id - 1, value);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_rc_data_notify (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GValue tmp_value = { 0, };
|
||||
|
||||
g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_object_get_property (object, pspec->name, &tmp_value);
|
||||
g_print ("rc-file property \"%s\" set to %p\n",
|
||||
pspec->name,
|
||||
tmp_value.data[0].v_pointer);
|
||||
g_value_unset (&tmp_value);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_rc_data_install_property (GParamSpec *pspec)
|
||||
{
|
||||
GtkRCData *data = gtk_rc_data_get_global ();
|
||||
|
||||
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
||||
|
||||
switch (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)))
|
||||
{
|
||||
case G_TYPE_BOOLEAN:
|
||||
case G_TYPE_UCHAR:
|
||||
case G_TYPE_CHAR:
|
||||
case G_TYPE_UINT:
|
||||
case G_TYPE_INT:
|
||||
case G_TYPE_ULONG:
|
||||
case G_TYPE_LONG:
|
||||
case G_TYPE_FLOAT:
|
||||
case G_TYPE_DOUBLE:
|
||||
case G_TYPE_STRING:
|
||||
break;
|
||||
default:
|
||||
g_warning (G_STRLOC ": property type `%s' is not supported for rc-data property \"%s\"",
|
||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), pspec->name);
|
||||
return;
|
||||
}
|
||||
g_object_freeze_notify (G_OBJECT (data));
|
||||
if (!g_object_class_find_property (G_OBJECT_GET_CLASS (data), pspec->name))
|
||||
{
|
||||
static guint n_properties = 0;
|
||||
GtkRCDataValue *dvalue;
|
||||
|
||||
g_object_class_install_property (G_OBJECT_GET_CLASS (data), ++n_properties, pspec);
|
||||
data->pvalues = g_renew (GValue, data->pvalues, n_properties);
|
||||
data->pvalues[n_properties - 1].g_type = 0;
|
||||
g_value_init (data->pvalues + n_properties - 1, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
g_param_value_set_default (pspec, data->pvalues + n_properties - 1);
|
||||
g_object_notify (G_OBJECT (data), pspec->name);
|
||||
|
||||
dvalue = g_datalist_get_data (&data->qvalues, pspec->name);
|
||||
if (dvalue)
|
||||
set_property (data, pspec, dvalue);
|
||||
}
|
||||
else
|
||||
g_warning (G_STRLOC ": an rc-data property \"%s\" already exists",
|
||||
pspec->name);
|
||||
g_object_thaw_notify (G_OBJECT (data));
|
||||
}
|
||||
|
||||
static void
|
||||
free_value (gpointer data)
|
||||
{
|
||||
GtkRCDataValue *dvalue = data;
|
||||
|
||||
g_value_unset (&dvalue->rc_value);
|
||||
g_free (dvalue->location);
|
||||
g_free (dvalue);
|
||||
}
|
||||
|
||||
static void
|
||||
set_value (GtkRCData *data,
|
||||
const gchar *vname,
|
||||
GValue *value,
|
||||
const gchar *location)
|
||||
{
|
||||
GtkRCDataValue *dvalue;
|
||||
GParamSpec *pspec;
|
||||
gchar *name = g_strdup (vname);
|
||||
|
||||
g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
||||
|
||||
dvalue = g_datalist_get_data (&data->qvalues, name);
|
||||
if (!dvalue)
|
||||
{
|
||||
dvalue = g_new0 (GtkRCDataValue, 1);
|
||||
g_datalist_set_data_full (&data->qvalues, name, dvalue, free_value);
|
||||
}
|
||||
else
|
||||
g_value_unset (&dvalue->rc_value);
|
||||
g_free (dvalue->location);
|
||||
dvalue->location = g_strdup (location);
|
||||
g_value_init (&dvalue->rc_value, G_VALUE_TYPE (value));
|
||||
g_value_copy (value, &dvalue->rc_value);
|
||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (data), name);
|
||||
if (pspec)
|
||||
set_property (data, pspec, dvalue);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_rc_data_set_string_property (const gchar *name,
|
||||
const gchar *v_string,
|
||||
const gchar *location)
|
||||
{
|
||||
GtkRCData *data = gtk_rc_data_get_global ();
|
||||
GValue value = { 0, };
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
g_return_if_fail (v_string != NULL);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (data));
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&value, v_string);
|
||||
set_value (data, name, &value, location);
|
||||
g_value_unset (&value);
|
||||
g_object_thaw_notify (G_OBJECT (data));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_rc_data_set_long_property (const gchar *name,
|
||||
glong v_long,
|
||||
const gchar *location)
|
||||
{
|
||||
GtkRCData *data = gtk_rc_data_get_global ();
|
||||
GValue value = { 0, };
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (data));
|
||||
g_value_init (&value, G_TYPE_LONG);
|
||||
g_value_set_long (&value, v_long);
|
||||
set_value (data, name, &value, location);
|
||||
g_value_unset (&value);
|
||||
g_object_thaw_notify (G_OBJECT (data));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_rc_data_set_double_property (const gchar *name,
|
||||
gdouble v_double,
|
||||
const gchar *location)
|
||||
{
|
||||
GtkRCData *data = gtk_rc_data_get_global ();
|
||||
GValue value = { 0, };
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (data));
|
||||
g_value_init (&value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (&value, v_double);
|
||||
set_value (data, name, &value, location);
|
||||
g_value_unset (&value);
|
||||
g_object_thaw_notify (G_OBJECT (data));
|
||||
}
|
84
gtk/gtkrcdata.h
Normal file
84
gtk/gtkrcdata.h
Normal file
@ -0,0 +1,84 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __GTK_RC_DATA_H__
|
||||
#define __GTK_RC_DATA_H__
|
||||
|
||||
#include <gtk/gtkrc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* -- type macros --- */
|
||||
#define GTK_TYPE_RC_DATA (gtk_rc_data_get_type ())
|
||||
#define GTK_RC_DATA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_RC_DATA, GtkRCData))
|
||||
#define GTK_RC_DATA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_RC_DATA, GtkRCDataClass))
|
||||
#define GTK_IS_RC_DATA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_RC_DATA))
|
||||
#define GTK_IS_RC_DATA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RC_DATA))
|
||||
#define GTK_RC_DATA_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_RC_DATA, GtkRCDataClass))
|
||||
|
||||
|
||||
/* --- typedefs --- */
|
||||
typedef struct _GtkRCData GtkRCData;
|
||||
typedef struct _GtkRCDataClass GtkRCDataClass;
|
||||
typedef struct _GtkRCDataValue GtkRCDataValue;
|
||||
|
||||
|
||||
/* --- structures --- */
|
||||
struct _GtkRCData
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GData *qvalues;
|
||||
GValue *pvalues;
|
||||
};
|
||||
struct _GtkRCDataClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
};
|
||||
struct _GtkRCDataValue
|
||||
{
|
||||
gchar *location; /* rc-file location */
|
||||
GValue rc_value; /* rc-file value */
|
||||
};
|
||||
|
||||
|
||||
/* --- functions --- */
|
||||
GType gtk_rc_data_get_type (void);
|
||||
GtkRCData* gtk_rc_data_get_global (void); /* singleton */
|
||||
void gtk_rc_data_install_property (GParamSpec *pspec);
|
||||
|
||||
/*< private >*/
|
||||
void gtk_rc_data_set_string_property (const gchar *name,
|
||||
const gchar *v_string,
|
||||
const gchar *location);
|
||||
void gtk_rc_data_set_long_property (const gchar *name,
|
||||
glong v_long,
|
||||
const gchar *location);
|
||||
void gtk_rc_data_set_double_property (const gchar *name,
|
||||
gdouble v_double,
|
||||
const gchar *location);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GTK_RC_DATA_H__ */
|
@ -44,7 +44,6 @@ extern "C" {
|
||||
|
||||
/* --- compat defines --- */
|
||||
#define GTK_SIGNAL_OFFSET GTK_STRUCT_OFFSET
|
||||
#define gtk_signal_init() g_type_init()
|
||||
#define gtk_signal_lookup g_signal_lookup
|
||||
#define gtk_signal_name g_signal_name
|
||||
#define gtk_signal_emit_stop(i,s) g_signal_stop_emission ((i), (s), 0)
|
||||
|
@ -123,7 +123,7 @@ extern IMPORT gboolean glib_debug_objects;
|
||||
#include <gdk.h> /* gtktypebuiltins_ids.c */
|
||||
|
||||
void
|
||||
gtk_type_init (void)
|
||||
gtk_type_init (GTypeDebugFlags debug_flags)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
@ -156,7 +156,7 @@ gtk_type_init (void)
|
||||
|
||||
/* initialize GLib type system
|
||||
*/
|
||||
g_type_init ();
|
||||
g_type_init (debug_flags);
|
||||
|
||||
/* GTK_TYPE_OBJECT
|
||||
*/
|
||||
|
@ -224,8 +224,8 @@ gpointer gtk_type_class (GtkType type) G_GNUC_CONST;
|
||||
gpointer gtk_type_new (GtkType type);
|
||||
|
||||
|
||||
/* --- initialize the type system --- */
|
||||
void gtk_type_init (void);
|
||||
/* deprecated, use g_type_init() instead */
|
||||
void gtk_type_init (GTypeDebugFlags debug_flags);
|
||||
|
||||
|
||||
/* --- compatibility defines --- */
|
||||
|
@ -9349,6 +9349,8 @@ main (int argc, char *argv[])
|
||||
{
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
g_mem_set_vtable (glib_mem_profiler_table);
|
||||
|
||||
srand (time (NULL));
|
||||
|
||||
test_init ();
|
||||
@ -9374,16 +9376,17 @@ main (int argc, char *argv[])
|
||||
create_main_window ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
if (0)
|
||||
|
||||
if (1)
|
||||
{
|
||||
sleep (1);
|
||||
while (g_main_pending ())
|
||||
g_main_iteration (FALSE);
|
||||
sleep (1);
|
||||
while (g_main_pending ())
|
||||
g_main_iteration (FALSE);
|
||||
}
|
||||
g_blow_chunks ();
|
||||
g_mem_profile ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ include "testgtkrc2"
|
||||
# On Windows, if you have installed gtk-engines, try this for instance:
|
||||
#include "\\windows\\gtk\\themes\\Pixmap\\gtk\\gtkrc"
|
||||
|
||||
foo_number = 5
|
||||
mouse_timeout = -7
|
||||
|
||||
pixmap_path "."
|
||||
|
||||
style "defaultfont"
|
||||
|
@ -9349,6 +9349,8 @@ main (int argc, char *argv[])
|
||||
{
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
g_mem_set_vtable (glib_mem_profiler_table);
|
||||
|
||||
srand (time (NULL));
|
||||
|
||||
test_init ();
|
||||
@ -9374,16 +9376,17 @@ main (int argc, char *argv[])
|
||||
create_main_window ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
if (0)
|
||||
|
||||
if (1)
|
||||
{
|
||||
sleep (1);
|
||||
while (g_main_pending ())
|
||||
g_main_iteration (FALSE);
|
||||
sleep (1);
|
||||
while (g_main_pending ())
|
||||
g_main_iteration (FALSE);
|
||||
}
|
||||
g_blow_chunks ();
|
||||
g_mem_profile ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ include "testgtkrc2"
|
||||
# On Windows, if you have installed gtk-engines, try this for instance:
|
||||
#include "\\windows\\gtk\\themes\\Pixmap\\gtk\\gtkrc"
|
||||
|
||||
foo_number = 5
|
||||
mouse_timeout = -7
|
||||
|
||||
pixmap_path "."
|
||||
|
||||
style "defaultfont"
|
||||
|
Loading…
Reference in New Issue
Block a user