Add change notification for GtkAccelMap, by on-demand instantiating a

Sat Feb  7 00:06:44 2004  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkaccelmap.[hc]: Add change notification for GtkAccelMap,
	by on-demand instantiating a singleton object with a "changed"
	signal.

	* gtk/gtkmarshalers.list (VOID:STRING,UINT,FLAGS): Add marshaller
	for GtkAccelMap::changed.
This commit is contained in:
Matthias Clasen 2004-02-06 23:37:00 +00:00 committed by Matthias Clasen
parent 55468e90bd
commit c03700734e
11 changed files with 179 additions and 3 deletions

View File

@ -1,3 +1,12 @@
Sat Feb 7 00:06:44 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkaccelmap.[hc]: Add change notification for GtkAccelMap,
by on-demand instantiating a singleton object with a "changed"
signal.
* gtk/gtkmarshalers.list (VOID:STRING,UINT,FLAGS): Add marshaller
for GtkAccelMap::changed.
Fri Feb 6 23:08:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextbtree.c (_gtk_text_btree_check):

View File

@ -1,3 +1,12 @@
Sat Feb 7 00:06:44 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkaccelmap.[hc]: Add change notification for GtkAccelMap,
by on-demand instantiating a singleton object with a "changed"
signal.
* gtk/gtkmarshalers.list (VOID:STRING,UINT,FLAGS): Add marshaller
for GtkAccelMap::changed.
Fri Feb 6 23:08:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextbtree.c (_gtk_text_btree_check):

View File

@ -1,3 +1,12 @@
Sat Feb 7 00:06:44 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkaccelmap.[hc]: Add change notification for GtkAccelMap,
by on-demand instantiating a singleton object with a "changed"
signal.
* gtk/gtkmarshalers.list (VOID:STRING,UINT,FLAGS): Add marshaller
for GtkAccelMap::changed.
Fri Feb 6 23:08:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextbtree.c (_gtk_text_btree_check):

View File

@ -1,3 +1,12 @@
Sat Feb 7 00:06:44 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkaccelmap.[hc]: Add change notification for GtkAccelMap,
by on-demand instantiating a singleton object with a "changed"
signal.
* gtk/gtkmarshalers.list (VOID:STRING,UINT,FLAGS): Add marshaller
for GtkAccelMap::changed.
Fri Feb 6 23:08:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextbtree.c (_gtk_text_btree_check):

View File

@ -1,3 +1,12 @@
Sat Feb 7 00:06:44 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkaccelmap.[hc]: Add change notification for GtkAccelMap,
by on-demand instantiating a singleton object with a "changed"
signal.
* gtk/gtkmarshalers.list (VOID:STRING,UINT,FLAGS): Add marshaller
for GtkAccelMap::changed.
Fri Feb 6 23:08:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextbtree.c (_gtk_text_btree_check):

View File

@ -1,3 +1,12 @@
Sat Feb 7 00:38:23 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtk-sections.txt: Add GtkAccelMap, gtk_accel_map_get,
and a bunch of standard and private accel map symbols.
Sat Feb 7 00:38:03 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtk.types: Add gtk_accel_map_get_type.
Sun Feb 1 00:37:44 2004 Matthias Clasen <maclas@gmx.de>
* gtk/tmpl/gtkobject.sgml: Remove misleading documentation for

View File

@ -45,6 +45,7 @@ GTK_ACCEL_GROUP_GET_CLASS
<SECTION>
<FILE>gtkaccelmap</FILE>
<TITLE>Accelerator Maps</TITLE>
GtkAccelMap
GtkAccelMapForeach
gtk_accel_map_add_entry
gtk_accel_map_lookup_entry
@ -57,6 +58,16 @@ gtk_accel_map_save_fd
gtk_accel_map_load_scanner
gtk_accel_map_add_filter
gtk_accel_map_foreach_unfiltered
gtk_accel_map_get
<SUBSECTION Standard>
GTK_TYPE_ACCEL_MAP
GTK_IS_ACCEL_MAP
GTK_ACCEL_MAP_CLASS
GTK_IS_ACCEL_MAP_CLASS
GTK_ACCEL_MAP_GET_CLASS
GtkAccelMapClass
<SUBSECTION Private>
gtk_accel_map_get_type
</SECTION>
<SECTION>

View File

@ -1,6 +1,7 @@
#include <gtk/gtk.h>
gtk_accel_group_get_type
gtk_accel_map_get_type
gtk_accel_label_get_type
gtk_accessible_get_type
gtk_action_get_type

View File

@ -21,6 +21,7 @@
#include "gtkaccelmap.h"
#include "gtkmarshalers.h"
#include "gtkwindow.h" /* in lack of GtkAcceleratable */
#include <string.h>
@ -36,6 +37,16 @@
/* --- structures --- */
struct _GtkAccelMap
{
GObject parent_instance;
};
struct _GtkAccelMapClass
{
GObjectClass parent_class;
};
typedef struct {
const gchar *accel_path;
guint accel_key;
@ -47,11 +58,21 @@ typedef struct {
GSList *groups;
} AccelEntry;
/* --- signals --- */
enum {
CHANGED,
LAST_SIGNAL
};
/* --- variables --- */
static GHashTable *accel_entry_ht = NULL; /* accel_path -> AccelEntry */
static GSList *accel_filters = NULL;
static GHookList *change_hooks = NULL;
static gulong accel_map_signals[LAST_SIGNAL] = { 0, };
static GtkAccelMap *accel_map;
/* --- prototypes --- */
static void do_accel_map_changed (AccelEntry *entry);
/* --- functions --- */
static guint
@ -163,6 +184,8 @@ gtk_accel_map_add_entry (const gchar *accel_path,
entry->changed = FALSE;
entry->lock_count = 0;
g_hash_table_insert (accel_entry_ht, entry, entry);
do_accel_map_changed (entry);
}
}
@ -242,6 +265,8 @@ internal_change_entry (const gchar *accel_path,
entry->accel_key = accel_key;
entry->accel_mods = accel_mods;
entry->changed = TRUE;
do_accel_map_changed (entry);
}
return TRUE;
}
@ -268,6 +293,8 @@ internal_change_entry (const gchar *accel_path,
entry->accel_key = accel_key;
entry->accel_mods = accel_mods;
entry->changed = TRUE;
do_accel_map_changed (entry);
}
return TRUE;
}
@ -379,6 +406,8 @@ internal_change_entry (const gchar *accel_path,
/* unref accel groups */
for (slist = group_list; slist; slist = slist->next)
g_object_unref (slist->data);
do_accel_map_changed (entry);
}
g_slist_free (replace_list);
g_slist_free (group_list);
@ -900,3 +929,69 @@ gtk_accel_map_unlock_path (const gchar *accel_path)
entry->lock_count -= 1;
}
G_DEFINE_TYPE (GtkAccelMap, gtk_accel_map, G_TYPE_OBJECT);
static void
gtk_accel_map_class_init (GtkAccelMapClass *accel_map_class)
{
/**
* GtkAccelMap::changed:
* @object: the global accel map object
* @accel_path: the path of the accelerator that changed
* @accel_key: the key value for the new accelerator
* @accel_mods: the modifier mask for the new accelerator
*
* Notifies of a change in the global accelerator map.
* The path is also used as the detail for the signal,
* so it is possible to connect to
* changed::<replaceable>accel_path</replaceable>.
*
* Since: 2.4
*/
accel_map_signals[CHANGED] = g_signal_new ("changed",
G_TYPE_FROM_CLASS (accel_map_class),
G_SIGNAL_DETAILED|G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
_gtk_marshal_VOID__STRING_UINT_FLAGS,
G_TYPE_NONE, 3,
G_TYPE_STRING, G_TYPE_UINT, GDK_TYPE_MODIFIER_TYPE);
}
static void
gtk_accel_map_init (GtkAccelMap *accel_map)
{
}
/**
* gtk_accel_map_get:
*
* Gets the singleton global #GtkAccelMap object. This object
* is useful only for notification of changes to the accelerator
* map via the ::changed signal; it isn't a parameter to the
* other accelerator map functions.
*
* Return value: the global #GtkAccelMap object
*
* Since: 2.4
**/
GtkAccelMap *
gtk_accel_map_get (void)
{
if (!accel_map)
accel_map = g_object_new (GTK_TYPE_ACCEL_MAP, NULL);
return accel_map;
}
static void
do_accel_map_changed (AccelEntry *entry)
{
if (accel_map)
g_signal_emit (accel_map,
accel_map_signals[CHANGED],
g_quark_from_string (entry->accel_path),
entry->accel_path,
entry->accel_key,
entry->accel_mods);
}

View File

@ -24,6 +24,16 @@
G_BEGIN_DECLS
/* --- global GtkAccelMap object --- */
#define GTK_TYPE_ACCEL_MAP (gtk_accel_map_get_type ())
#define GTK_ACCEL_MAP(accel_map) (G_TYPE_CHECK_INSTANCE_CAST ((accel_map), GTK_TYPE_ACCEL_MAP, GtkAccelMap))
#define GTK_ACCEL_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_MAP, GtkAccelMapClass))
#define GTK_IS_ACCEL_MAP(accel_map) (G_TYPE_CHECK_INSTANCE_TYPE ((accel_map), GTK_TYPE_ACCEL_MAP))
#define GTK_IS_ACCEL_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_MAP))
#define GTK_ACCEL_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_MAP, GtkAccelMapClass))
typedef struct _GtkAccelMap GtkAccelMap;
typedef struct _GtkAccelMapClass GtkAccelMapClass;
/* --- notifier --- */
typedef void (*GtkAccelMapForeach) (gpointer data,
@ -59,6 +69,10 @@ void gtk_accel_map_add_filter (const gchar *filter_pattern);
void gtk_accel_map_foreach_unfiltered (gpointer data,
GtkAccelMapForeach foreach_func);
/* --- notification --- */
GType gtk_accel_map_get_type (void);
GtkAccelMap *gtk_accel_map_get (void);
/* --- internal API --- */
void _gtk_accel_map_init (void);

View File

@ -87,6 +87,7 @@ VOID:POINTER,UINT
VOID:STRING
VOID:STRING,STRING
VOID:STRING,INT,POINTER
VOID:STRING,UINT,FLAGS
VOID:UINT,FLAGS,BOXED
VOID:UINT,UINT
VOID:UINT,STRING