action stuff: stop abusing GLib's namespace

Rename our internal GActionMuxer, GActionObserver and GActionObservable
classes and interfaces to have names in our own namespace.

These classes were originally intended for GIO but turned out to be too
special-purpose to be useful there, so we never made them public API but
have just been copying them around (without bothering to properly rename
them).  Now that other people will be copying them out of Gtk, it's even
more important to prevent this namespace abuse from spreading further.
This commit is contained in:
Ryan Lortie 2013-05-09 14:15:51 -04:00 committed by Jasper St. Pierre
parent 58481ffabf
commit 6c49cd0ea6
13 changed files with 510 additions and 509 deletions

View File

@ -21,9 +21,9 @@ CFILE_GLOB=$(top_srcdir)/gtk/*.c
# Header files to ignore when scanning
IGNORE_HFILES= \
fnmatch.h \
gactionmuxer.h \
gactionobserver.h \
gactionobservable.h \
gtkactionmuxer.h \
gtkactionobserver.h \
gtkactionobservable.h \
gtk9slice.h \
gtkanimationdescription.h \
gtkdebug.h \

View File

@ -402,9 +402,9 @@ gtk_private_type_h_sources = \
# GTK+ header files that don't get installed
gtk_private_h_sources = \
gactionmuxer.h \
gactionobserver.h \
gactionobservable.h \
gtkactionmuxer.h \
gtkactionobserver.h \
gtkactionobservable.h \
gtkapplicationprivate.h \
gtkaccelgroupprivate.h \
gtkaccelmapprivate.h \
@ -584,9 +584,9 @@ deprecated_c_sources = \
gtk_base_c_sources = \
$(deprecated_c_sources) \
gactionmuxer.c \
gactionobserver.c \
gactionobservable.c \
gtkactionmuxer.c \
gtkactionobserver.c \
gtkactionobservable.c \
gtkactionable.c \
gtkquery.c \
gtksearchentry.c \

View File

@ -1,62 +0,0 @@
/*
* Copyright © 2011 Canonical Limited
*
* 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
* licence 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __G_ACTION_OBSERVABLE_H__
#define __G_ACTION_OBSERVABLE_H__
#include <gtk/gactionobserver.h>
G_BEGIN_DECLS
#define G_TYPE_ACTION_OBSERVABLE (g_action_observable_get_type ())
#define G_ACTION_OBSERVABLE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
G_TYPE_ACTION_OBSERVABLE, GActionObservable))
#define G_IS_ACTION_OBSERVABLE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
G_TYPE_ACTION_OBSERVABLE))
#define G_ACTION_OBSERVABLE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
G_TYPE_ACTION_OBSERVABLE, GActionObservableInterface))
typedef struct _GActionObservableInterface GActionObservableInterface;
struct _GActionObservableInterface
{
GTypeInterface g_iface;
void (* register_observer) (GActionObservable *observable,
const gchar *action_name,
GActionObserver *observer);
void (* unregister_observer) (GActionObservable *observable,
const gchar *action_name,
GActionObserver *observer);
};
G_GNUC_INTERNAL
GType g_action_observable_get_type (void);
G_GNUC_INTERNAL
void g_action_observable_register_observer (GActionObservable *observable,
const gchar *action_name,
GActionObserver *observer);
G_GNUC_INTERNAL
void g_action_observable_unregister_observer (GActionObservable *observable,
const gchar *action_name,
GActionObserver *observer);
G_END_DECLS
#endif /* __G_ACTION_OBSERVABLE_H__ */

View File

@ -1,88 +0,0 @@
/*
* Copyright © 2011 Canonical Limited
*
* 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
* licence 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __G_ACTION_OBSERVER_H__
#define __G_ACTION_OBSERVER_H__
#include <gio/gio.h>
G_BEGIN_DECLS
#define G_TYPE_ACTION_OBSERVER (g_action_observer_get_type ())
#define G_ACTION_OBSERVER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
G_TYPE_ACTION_OBSERVER, GActionObserver))
#define G_IS_ACTION_OBSERVER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
G_TYPE_ACTION_OBSERVER))
#define G_ACTION_OBSERVER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
G_TYPE_ACTION_OBSERVER, GActionObserverInterface))
typedef struct _GActionObserverInterface GActionObserverInterface;
typedef struct _GActionObservable GActionObservable;
typedef struct _GActionObserver GActionObserver;
struct _GActionObserverInterface
{
GTypeInterface g_iface;
void (* action_added) (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state);
void (* action_enabled_changed) (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
gboolean enabled);
void (* action_state_changed) (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
GVariant *state);
void (* action_removed) (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name);
};
G_GNUC_INTERNAL
GType g_action_observer_get_type (void);
G_GNUC_INTERNAL
void g_action_observer_action_added (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state);
G_GNUC_INTERNAL
void g_action_observer_action_enabled_changed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
gboolean enabled);
G_GNUC_INTERNAL
void g_action_observer_action_state_changed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
GVariant *state);
G_GNUC_INTERNAL
void g_action_observer_action_removed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name);
G_END_DECLS
#endif /* __G_ACTION_OBSERVER_H__ */

View File

@ -18,7 +18,7 @@
*/
#include "gtkactionhelper.h"
#include "gactionobservable.h"
#include "gtkactionobservable.h"
#include "gtkwidget.h"
#include "gtkwidgetprivate.h"
@ -57,7 +57,7 @@ struct _GtkActionHelper
GtkActionHelperGroup *group;
GActionMuxer *action_context;
GtkActionMuxer *action_context;
gchar *action_name;
GVariant *target;
@ -81,10 +81,10 @@ enum
static GParamSpec *gtk_action_helper_pspecs[N_PROPS];
static void gtk_action_helper_observer_iface_init (GActionObserverInterface *iface);
static void gtk_action_helper_observer_iface_init (GtkActionObserverInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkActionHelper, gtk_action_helper, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_OBSERVER, gtk_action_helper_observer_iface_init))
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTION_OBSERVER, gtk_action_helper_observer_iface_init))
static void
gtk_action_helper_report_change (GtkActionHelper *helper,
@ -288,38 +288,38 @@ gtk_action_helper_finalize (GObject *object)
}
static void
gtk_action_helper_observer_action_added (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state)
gtk_action_helper_observer_action_added (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state)
{
gtk_action_helper_action_added (GTK_ACTION_HELPER (observer), enabled, parameter_type, state, TRUE);
}
static void
gtk_action_helper_observer_action_enabled_changed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
gboolean enabled)
gtk_action_helper_observer_action_enabled_changed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
gboolean enabled)
{
gtk_action_helper_action_enabled_changed (GTK_ACTION_HELPER (observer), enabled);
}
static void
gtk_action_helper_observer_action_state_changed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
GVariant *state)
gtk_action_helper_observer_action_state_changed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
GVariant *state)
{
gtk_action_helper_action_state_changed (GTK_ACTION_HELPER (observer), state);
}
static void
gtk_action_helper_observer_action_removed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name)
gtk_action_helper_observer_action_removed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name)
{
gtk_action_helper_action_removed (GTK_ACTION_HELPER (observer));
}
@ -345,7 +345,7 @@ gtk_action_helper_class_init (GtkActionHelperClass *class)
}
static void
gtk_action_helper_observer_iface_init (GActionObserverInterface *iface)
gtk_action_helper_observer_iface_init (GtkActionObserverInterface *iface)
{
iface->action_added = gtk_action_helper_observer_action_added;
iface->action_enabled_changed = gtk_action_helper_observer_action_enabled_changed;
@ -401,7 +401,7 @@ gtk_action_helper_active_window_changed (GObject *object,
gpointer user_data)
{
GtkActionHelper *helper = user_data;
GActionMuxer *parent;
GtkActionMuxer *parent;
if (helper->widget)
g_object_unref (helper->widget);
@ -415,11 +415,11 @@ gtk_action_helper_active_window_changed (GObject *object,
}
else
{
parent = g_action_muxer_new ();
g_action_muxer_insert (parent, "app", G_ACTION_GROUP (helper->application));
parent = gtk_action_muxer_new ();
gtk_action_muxer_insert (parent, "app", G_ACTION_GROUP (helper->application));
}
g_action_muxer_set_parent (helper->action_context, parent);
gtk_action_muxer_set_parent (helper->action_context, parent);
g_object_unref (parent);
}
@ -433,7 +433,7 @@ gtk_action_helper_new_with_application (GtkApplication *application)
helper = g_object_new (GTK_TYPE_ACTION_HELPER, NULL);
helper->application = g_object_ref (application);
helper->action_context = g_action_muxer_new ();
helper->action_context = gtk_action_muxer_new ();
g_signal_connect (application, "notify::active-window", G_CALLBACK (gtk_action_helper_active_window_changed), helper);
gtk_action_helper_active_window_changed (NULL, NULL, helper);
@ -455,17 +455,17 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
if (helper->action_name)
{
g_action_observable_unregister_observer (G_ACTION_OBSERVABLE (helper->action_context),
helper->action_name,
G_ACTION_OBSERVER (helper));
gtk_action_observable_unregister_observer (GTK_ACTION_OBSERVABLE (helper->action_context),
helper->action_name,
GTK_ACTION_OBSERVER (helper));
g_free (helper->action_name);
}
helper->action_name = g_strdup (action_name);
g_action_observable_register_observer (G_ACTION_OBSERVABLE (helper->action_context),
helper->action_name,
G_ACTION_OBSERVER (helper));
gtk_action_observable_register_observer (GTK_ACTION_OBSERVABLE (helper->action_context),
helper->action_name,
GTK_ACTION_OBSERVER (helper));
/* Start by recording the current state of our properties so we know
* what notify signals we will need to send.

View File

@ -19,18 +19,18 @@
#include "config.h"
#include "gactionmuxer.h"
#include "gtkactionmuxer.h"
#include "gactionobservable.h"
#include "gactionobserver.h"
#include "gtkactionobservable.h"
#include "gtkactionobserver.h"
#include <string.h>
/*
* SECTION:gactionmuxer
* SECTION:gtkactionmuxer
* @short_description: Aggregate and monitor several action groups
*
* #GActionMuxer is a #GActionGroup and #GActionObservable that is
* #GtkActionMuxer is a #GActionGroup and #GtkActionObservable that is
* capable of containing other #GActionGroup instances.
*
* The typical use is aggregating all of the actions applicable to a
@ -42,11 +42,11 @@
* application (such as 'fullscreen').
*
* In this case, each of these action groups could be added to a
* #GActionMuxer with the prefixes "app" and "win", respectively. This
* #GtkActionMuxer with the prefixes "app" and "win", respectively. This
* would expose the actions as "app.quit" and "win.fullscreen" on the
* #GActionGroup interface presented by the #GActionMuxer.
* #GActionGroup interface presented by the #GtkActionMuxer.
*
* Activations and state change requests on the #GActionMuxer are wired
* Activations and state change requests on the #GtkActionMuxer are wired
* through to the underlying action group in the expected way.
*
* This class is typically only used at the site of "consumption" of
@ -54,23 +54,23 @@
* different objects).
*/
static void g_action_muxer_group_iface_init (GActionGroupInterface *iface);
static void g_action_muxer_observable_iface_init (GActionObservableInterface *iface);
static void gtk_action_muxer_group_iface_init (GActionGroupInterface *iface);
static void gtk_action_muxer_observable_iface_init (GtkActionObservableInterface *iface);
typedef GObjectClass GActionMuxerClass;
typedef GObjectClass GtkActionMuxerClass;
struct _GActionMuxer
struct _GtkActionMuxer
{
GObject parent_instance;
GHashTable *observed_actions;
GHashTable *groups;
GActionMuxer *parent;
GtkActionMuxer *parent;
};
G_DEFINE_TYPE_WITH_CODE (GActionMuxer, g_action_muxer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_action_muxer_group_iface_init)
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_OBSERVABLE, g_action_muxer_observable_iface_init))
G_DEFINE_TYPE_WITH_CODE (GtkActionMuxer, gtk_action_muxer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, gtk_action_muxer_group_iface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTION_OBSERVABLE, gtk_action_muxer_observable_iface_init))
enum
{
@ -83,23 +83,23 @@ static GParamSpec *properties[NUM_PROPERTIES];
typedef struct
{
GActionMuxer *muxer;
GtkActionMuxer *muxer;
GSList *watchers;
gchar *fullname;
} Action;
typedef struct
{
GActionMuxer *muxer;
GtkActionMuxer *muxer;
GActionGroup *group;
gchar *prefix;
gulong handler_ids[4];
} Group;
static void
g_action_muxer_append_group_actions (gpointer key,
gpointer value,
gpointer user_data)
gtk_action_muxer_append_group_actions (gpointer key,
gpointer value,
gpointer user_data)
{
const gchar *prefix = key;
Group *group = value;
@ -120,9 +120,9 @@ g_action_muxer_append_group_actions (gpointer key,
}
static gchar **
g_action_muxer_list_actions (GActionGroup *action_group)
gtk_action_muxer_list_actions (GActionGroup *action_group)
{
GActionMuxer *muxer = G_ACTION_MUXER (action_group);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (action_group);
GArray *actions;
actions = g_array_new (TRUE, FALSE, sizeof (gchar *));
@ -130,7 +130,7 @@ g_action_muxer_list_actions (GActionGroup *action_group)
for ( ; muxer != NULL; muxer = muxer->parent)
{
g_hash_table_foreach (muxer->groups,
g_action_muxer_append_group_actions,
gtk_action_muxer_append_group_actions,
actions);
}
@ -138,9 +138,9 @@ g_action_muxer_list_actions (GActionGroup *action_group)
}
static Group *
g_action_muxer_find_group (GActionMuxer *muxer,
const gchar *full_name,
const gchar **action_name)
gtk_action_muxer_find_group (GtkActionMuxer *muxer,
const gchar *full_name,
const gchar **action_name)
{
const gchar *dot;
gchar *prefix;
@ -162,90 +162,90 @@ g_action_muxer_find_group (GActionMuxer *muxer,
}
static void
g_action_muxer_action_enabled_changed (GActionMuxer *muxer,
const gchar *action_name,
gboolean enabled)
gtk_action_muxer_action_enabled_changed (GtkActionMuxer *muxer,
const gchar *action_name,
gboolean enabled)
{
Action *action;
GSList *node;
action = g_hash_table_lookup (muxer->observed_actions, action_name);
for (node = action ? action->watchers : NULL; node; node = node->next)
g_action_observer_action_enabled_changed (node->data, G_ACTION_OBSERVABLE (muxer), action_name, enabled);
gtk_action_observer_action_enabled_changed (node->data, GTK_ACTION_OBSERVABLE (muxer), action_name, enabled);
g_action_group_action_enabled_changed (G_ACTION_GROUP (muxer), action_name, enabled);
}
static void
g_action_muxer_group_action_enabled_changed (GActionGroup *action_group,
gtk_action_muxer_group_action_enabled_changed (GActionGroup *action_group,
const gchar *action_name,
gboolean enabled,
gpointer user_data)
{
Group *group = user_data;
gchar *fullname;
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
gtk_action_muxer_action_enabled_changed (group->muxer, fullname, enabled);
g_free (fullname);
}
static void
gtk_action_muxer_parent_action_enabled_changed (GActionGroup *action_group,
const gchar *action_name,
gboolean enabled,
gpointer user_data)
{
GtkActionMuxer *muxer = user_data;
gtk_action_muxer_action_enabled_changed (muxer, action_name, enabled);
}
static void
gtk_action_muxer_action_state_changed (GtkActionMuxer *muxer,
const gchar *action_name,
GVariant *state)
{
Action *action;
GSList *node;
action = g_hash_table_lookup (muxer->observed_actions, action_name);
for (node = action ? action->watchers : NULL; node; node = node->next)
gtk_action_observer_action_state_changed (node->data, GTK_ACTION_OBSERVABLE (muxer), action_name, state);
g_action_group_action_state_changed (G_ACTION_GROUP (muxer), action_name, state);
}
static void
gtk_action_muxer_group_action_state_changed (GActionGroup *action_group,
const gchar *action_name,
gboolean enabled,
GVariant *state,
gpointer user_data)
{
Group *group = user_data;
gchar *fullname;
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
g_action_muxer_action_enabled_changed (group->muxer, fullname, enabled);
gtk_action_muxer_action_state_changed (group->muxer, fullname, state);
g_free (fullname);
}
static void
g_action_muxer_parent_action_enabled_changed (GActionGroup *action_group,
gtk_action_muxer_parent_action_state_changed (GActionGroup *action_group,
const gchar *action_name,
gboolean enabled,
GVariant *state,
gpointer user_data)
{
GActionMuxer *muxer = user_data;
GtkActionMuxer *muxer = user_data;
g_action_muxer_action_enabled_changed (muxer, action_name, enabled);
gtk_action_muxer_action_state_changed (muxer, action_name, state);
}
static void
g_action_muxer_action_state_changed (GActionMuxer *muxer,
const gchar *action_name,
GVariant *state)
{
Action *action;
GSList *node;
action = g_hash_table_lookup (muxer->observed_actions, action_name);
for (node = action ? action->watchers : NULL; node; node = node->next)
g_action_observer_action_state_changed (node->data, G_ACTION_OBSERVABLE (muxer), action_name, state);
g_action_group_action_state_changed (G_ACTION_GROUP (muxer), action_name, state);
}
static void
g_action_muxer_group_action_state_changed (GActionGroup *action_group,
const gchar *action_name,
GVariant *state,
gpointer user_data)
{
Group *group = user_data;
gchar *fullname;
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
g_action_muxer_action_state_changed (group->muxer, fullname, state);
g_free (fullname);
}
static void
g_action_muxer_parent_action_state_changed (GActionGroup *action_group,
const gchar *action_name,
GVariant *state,
gpointer user_data)
{
GActionMuxer *muxer = user_data;
g_action_muxer_action_state_changed (muxer, action_name, state);
}
static void
g_action_muxer_action_added (GActionMuxer *muxer,
const gchar *action_name,
GActionGroup *original_group,
const gchar *orignal_action_name)
gtk_action_muxer_action_added (GtkActionMuxer *muxer,
const gchar *action_name,
GActionGroup *original_group,
const gchar *orignal_action_name)
{
const GVariantType *parameter_type;
gboolean enabled;
@ -261,8 +261,8 @@ g_action_muxer_action_added (GActionMuxer *muxer,
GSList *node;
for (node = action->watchers; node; node = node->next)
g_action_observer_action_added (node->data,
G_ACTION_OBSERVABLE (muxer),
gtk_action_observer_action_added (node->data,
GTK_ACTION_OBSERVABLE (muxer),
action_name, parameter_type, enabled, state);
if (state)
@ -273,80 +273,80 @@ g_action_muxer_action_added (GActionMuxer *muxer,
}
static void
g_action_muxer_action_added_to_group (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
gtk_action_muxer_action_added_to_group (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
{
Group *group = user_data;
gchar *fullname;
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
g_action_muxer_action_added (group->muxer, fullname, action_group, action_name);
gtk_action_muxer_action_added (group->muxer, fullname, action_group, action_name);
g_free (fullname);
}
static void
g_action_muxer_action_added_to_parent (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
gtk_action_muxer_action_added_to_parent (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
{
GActionMuxer *muxer = user_data;
GtkActionMuxer *muxer = user_data;
g_action_muxer_action_added (muxer, action_name, action_group, action_name);
gtk_action_muxer_action_added (muxer, action_name, action_group, action_name);
}
static void
g_action_muxer_action_removed (GActionMuxer *muxer,
const gchar *action_name)
gtk_action_muxer_action_removed (GtkActionMuxer *muxer,
const gchar *action_name)
{
Action *action;
GSList *node;
action = g_hash_table_lookup (muxer->observed_actions, action_name);
for (node = action ? action->watchers : NULL; node; node = node->next)
g_action_observer_action_removed (node->data, G_ACTION_OBSERVABLE (muxer), action_name);
gtk_action_observer_action_removed (node->data, GTK_ACTION_OBSERVABLE (muxer), action_name);
g_action_group_action_removed (G_ACTION_GROUP (muxer), action_name);
}
static void
g_action_muxer_action_removed_from_group (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
gtk_action_muxer_action_removed_from_group (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
{
Group *group = user_data;
gchar *fullname;
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
g_action_muxer_action_removed (group->muxer, fullname);
gtk_action_muxer_action_removed (group->muxer, fullname);
g_free (fullname);
}
static void
g_action_muxer_action_removed_from_parent (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
gtk_action_muxer_action_removed_from_parent (GActionGroup *action_group,
const gchar *action_name,
gpointer user_data)
{
GActionMuxer *muxer = user_data;
GtkActionMuxer *muxer = user_data;
g_action_muxer_action_removed (muxer, action_name);
gtk_action_muxer_action_removed (muxer, action_name);
}
static gboolean
g_action_muxer_query_action (GActionGroup *action_group,
const gchar *action_name,
gboolean *enabled,
const GVariantType **parameter_type,
const GVariantType **state_type,
GVariant **state_hint,
GVariant **state)
gtk_action_muxer_query_action (GActionGroup *action_group,
const gchar *action_name,
gboolean *enabled,
const GVariantType **parameter_type,
const GVariantType **state_type,
GVariant **state_hint,
GVariant **state)
{
GActionMuxer *muxer = G_ACTION_MUXER (action_group);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (action_group);
Group *group;
const gchar *unprefixed_name;
group = g_action_muxer_find_group (muxer, action_name, &unprefixed_name);
group = gtk_action_muxer_find_group (muxer, action_name, &unprefixed_name);
if (group)
return g_action_group_query_action (group->group, unprefixed_name, enabled,
@ -361,15 +361,15 @@ g_action_muxer_query_action (GActionGroup *action_group,
}
static void
g_action_muxer_activate_action (GActionGroup *action_group,
const gchar *action_name,
GVariant *parameter)
gtk_action_muxer_activate_action (GActionGroup *action_group,
const gchar *action_name,
GVariant *parameter)
{
GActionMuxer *muxer = G_ACTION_MUXER (action_group);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (action_group);
Group *group;
const gchar *unprefixed_name;
group = g_action_muxer_find_group (muxer, action_name, &unprefixed_name);
group = gtk_action_muxer_find_group (muxer, action_name, &unprefixed_name);
if (group)
g_action_group_activate_action (group->group, unprefixed_name, parameter);
@ -378,15 +378,15 @@ g_action_muxer_activate_action (GActionGroup *action_group,
}
static void
g_action_muxer_change_action_state (GActionGroup *action_group,
const gchar *action_name,
GVariant *state)
gtk_action_muxer_change_action_state (GActionGroup *action_group,
const gchar *action_name,
GVariant *state)
{
GActionMuxer *muxer = G_ACTION_MUXER (action_group);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (action_group);
Group *group;
const gchar *unprefixed_name;
group = g_action_muxer_find_group (muxer, action_name, &unprefixed_name);
group = gtk_action_muxer_find_group (muxer, action_name, &unprefixed_name);
if (group)
g_action_group_change_action_state (group->group, unprefixed_name, state);
@ -395,10 +395,10 @@ g_action_muxer_change_action_state (GActionGroup *action_group,
}
static void
g_action_muxer_unregister_internal (Action *action,
gpointer observer)
gtk_action_muxer_unregister_internal (Action *action,
gpointer observer)
{
GActionMuxer *muxer = action->muxer;
GtkActionMuxer *muxer = action->muxer;
GSList **ptr;
for (ptr = &action->watchers; *ptr; ptr = &(*ptr)->next)
@ -414,20 +414,20 @@ g_action_muxer_unregister_internal (Action *action,
}
static void
g_action_muxer_weak_notify (gpointer data,
GObject *where_the_object_was)
gtk_action_muxer_weak_notify (gpointer data,
GObject *where_the_object_was)
{
Action *action = data;
g_action_muxer_unregister_internal (action, where_the_object_was);
gtk_action_muxer_unregister_internal (action, where_the_object_was);
}
static void
g_action_muxer_register_observer (GActionObservable *observable,
const gchar *name,
GActionObserver *observer)
gtk_action_muxer_register_observer (GtkActionObservable *observable,
const gchar *name,
GtkActionObserver *observer)
{
GActionMuxer *muxer = G_ACTION_MUXER (observable);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (observable);
Action *action;
action = g_hash_table_lookup (muxer->observed_actions, name);
@ -443,24 +443,24 @@ g_action_muxer_register_observer (GActionObservable *observable,
}
action->watchers = g_slist_prepend (action->watchers, observer);
g_object_weak_ref (G_OBJECT (observer), g_action_muxer_weak_notify, action);
g_object_weak_ref (G_OBJECT (observer), gtk_action_muxer_weak_notify, action);
}
static void
g_action_muxer_unregister_observer (GActionObservable *observable,
const gchar *name,
GActionObserver *observer)
gtk_action_muxer_unregister_observer (GtkActionObservable *observable,
const gchar *name,
GtkActionObserver *observer)
{
GActionMuxer *muxer = G_ACTION_MUXER (observable);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (observable);
Action *action;
action = g_hash_table_lookup (muxer->observed_actions, name);
g_object_weak_unref (G_OBJECT (observer), g_action_muxer_weak_notify, action);
g_action_muxer_unregister_internal (action, observer);
g_object_weak_unref (G_OBJECT (observer), gtk_action_muxer_weak_notify, action);
gtk_action_muxer_unregister_internal (action, observer);
}
static void
g_action_muxer_free_group (gpointer data)
gtk_action_muxer_free_group (gpointer data)
{
Group *group = data;
gint i;
@ -476,13 +476,13 @@ g_action_muxer_free_group (gpointer data)
}
static void
g_action_muxer_free_action (gpointer data)
gtk_action_muxer_free_action (gpointer data)
{
Action *action = data;
GSList *it;
for (it = action->watchers; it; it = it->next)
g_object_weak_unref (G_OBJECT (it->data), g_action_muxer_weak_notify, action);
g_object_weak_unref (G_OBJECT (it->data), gtk_action_muxer_weak_notify, action);
g_slist_free (action->watchers);
g_free (action->fullname);
@ -491,51 +491,51 @@ g_action_muxer_free_action (gpointer data)
}
static void
g_action_muxer_finalize (GObject *object)
gtk_action_muxer_finalize (GObject *object)
{
GActionMuxer *muxer = G_ACTION_MUXER (object);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (object);
g_assert_cmpint (g_hash_table_size (muxer->observed_actions), ==, 0);
g_hash_table_unref (muxer->observed_actions);
g_hash_table_unref (muxer->groups);
G_OBJECT_CLASS (g_action_muxer_parent_class)
G_OBJECT_CLASS (gtk_action_muxer_parent_class)
->finalize (object);
}
static void
g_action_muxer_dispose (GObject *object)
gtk_action_muxer_dispose (GObject *object)
{
GActionMuxer *muxer = G_ACTION_MUXER (object);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (object);
if (muxer->parent)
{
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_action_added_to_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_action_removed_from_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_parent_action_enabled_changed, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_parent_action_state_changed, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_action_added_to_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_action_removed_from_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_parent_action_enabled_changed, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_parent_action_state_changed, muxer);
g_clear_object (&muxer->parent);
}
g_hash_table_remove_all (muxer->observed_actions);
G_OBJECT_CLASS (g_action_muxer_parent_class)
G_OBJECT_CLASS (gtk_action_muxer_parent_class)
->dispose (object);
}
static void
g_action_muxer_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
gtk_action_muxer_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GActionMuxer *muxer = G_ACTION_MUXER (object);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (object);
switch (property_id)
{
case PROP_PARENT:
g_value_set_object (value, g_action_muxer_get_parent (muxer));
g_value_set_object (value, gtk_action_muxer_get_parent (muxer));
break;
default:
@ -544,17 +544,17 @@ g_action_muxer_get_property (GObject *object,
}
static void
g_action_muxer_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
gtk_action_muxer_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GActionMuxer *muxer = G_ACTION_MUXER (object);
GtkActionMuxer *muxer = GTK_ACTION_MUXER (object);
switch (property_id)
{
case PROP_PARENT:
g_action_muxer_set_parent (muxer, g_value_get_object (value));
gtk_action_muxer_set_parent (muxer, g_value_get_object (value));
break;
default:
@ -563,39 +563,39 @@ g_action_muxer_set_property (GObject *object,
}
static void
g_action_muxer_init (GActionMuxer *muxer)
gtk_action_muxer_init (GtkActionMuxer *muxer)
{
muxer->observed_actions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_action_muxer_free_action);
muxer->groups = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_action_muxer_free_group);
muxer->observed_actions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gtk_action_muxer_free_action);
muxer->groups = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gtk_action_muxer_free_group);
}
static void
g_action_muxer_observable_iface_init (GActionObservableInterface *iface)
gtk_action_muxer_observable_iface_init (GtkActionObservableInterface *iface)
{
iface->register_observer = g_action_muxer_register_observer;
iface->unregister_observer = g_action_muxer_unregister_observer;
iface->register_observer = gtk_action_muxer_register_observer;
iface->unregister_observer = gtk_action_muxer_unregister_observer;
}
static void
g_action_muxer_group_iface_init (GActionGroupInterface *iface)
gtk_action_muxer_group_iface_init (GActionGroupInterface *iface)
{
iface->list_actions = g_action_muxer_list_actions;
iface->query_action = g_action_muxer_query_action;
iface->activate_action = g_action_muxer_activate_action;
iface->change_action_state = g_action_muxer_change_action_state;
iface->list_actions = gtk_action_muxer_list_actions;
iface->query_action = gtk_action_muxer_query_action;
iface->activate_action = gtk_action_muxer_activate_action;
iface->change_action_state = gtk_action_muxer_change_action_state;
}
static void
g_action_muxer_class_init (GObjectClass *class)
gtk_action_muxer_class_init (GObjectClass *class)
{
class->get_property = g_action_muxer_get_property;
class->set_property = g_action_muxer_set_property;
class->finalize = g_action_muxer_finalize;
class->dispose = g_action_muxer_dispose;
class->get_property = gtk_action_muxer_get_property;
class->set_property = gtk_action_muxer_set_property;
class->finalize = gtk_action_muxer_finalize;
class->dispose = gtk_action_muxer_dispose;
properties[PROP_PARENT] = g_param_spec_object ("parent", "Parent",
"The parent muxer",
G_TYPE_ACTION_MUXER,
GTK_TYPE_ACTION_MUXER,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
@ -603,8 +603,8 @@ g_action_muxer_class_init (GObjectClass *class)
}
/*
* g_action_muxer_insert:
* @muxer: a #GActionMuxer
* gtk_action_muxer_insert:
* @muxer: a #GtkActionMuxer
* @prefix: the prefix string for the action group
* @action_group: a #GActionGroup
*
@ -617,22 +617,22 @@ g_action_muxer_class_init (GObjectClass *class)
* contains an action called "<literal>quit</literal>", then @muxer will
* now contain an action called "<literal>app.quit</literal>".
*
* If any #GActionObservers are registered for actions in the group,
* If any #GtkActionObservers are registered for actions in the group,
* "action_added" notifications will be emitted, as appropriate.
*
* @prefix must not contain a dot ('.').
*/
void
g_action_muxer_insert (GActionMuxer *muxer,
const gchar *prefix,
GActionGroup *action_group)
gtk_action_muxer_insert (GtkActionMuxer *muxer,
const gchar *prefix,
GActionGroup *action_group)
{
gchar **actions;
Group *group;
gint i;
/* TODO: diff instead of ripout and replace */
g_action_muxer_remove (muxer, prefix);
gtk_action_muxer_remove (muxer, prefix);
group = g_slice_new (Group);
group->muxer = muxer;
@ -643,32 +643,32 @@ g_action_muxer_insert (GActionMuxer *muxer,
actions = g_action_group_list_actions (group->group);
for (i = 0; actions[i]; i++)
g_action_muxer_action_added_to_group (group->group, actions[i], group);
gtk_action_muxer_action_added_to_group (group->group, actions[i], group);
g_strfreev (actions);
group->handler_ids[0] = g_signal_connect (group->group, "action-added",
G_CALLBACK (g_action_muxer_action_added_to_group), group);
G_CALLBACK (gtk_action_muxer_action_added_to_group), group);
group->handler_ids[1] = g_signal_connect (group->group, "action-removed",
G_CALLBACK (g_action_muxer_action_removed_from_group), group);
G_CALLBACK (gtk_action_muxer_action_removed_from_group), group);
group->handler_ids[2] = g_signal_connect (group->group, "action-enabled-changed",
G_CALLBACK (g_action_muxer_group_action_enabled_changed), group);
G_CALLBACK (gtk_action_muxer_group_action_enabled_changed), group);
group->handler_ids[3] = g_signal_connect (group->group, "action-state-changed",
G_CALLBACK (g_action_muxer_group_action_state_changed), group);
G_CALLBACK (gtk_action_muxer_group_action_state_changed), group);
}
/*
* g_action_muxer_remove:
* @muxer: a #GActionMuxer
* gtk_action_muxer_remove:
* @muxer: a #GtkActionMuxer
* @prefix: the prefix of the action group to remove
*
* Removes a #GActionGroup from the #GActionMuxer.
* Removes a #GActionGroup from the #GtkActionMuxer.
*
* If any #GActionObservers are registered for actions in the group,
* If any #GtkActionObservers are registered for actions in the group,
* "action_removed" notifications will be emitted, as appropriate.
*/
void
g_action_muxer_remove (GActionMuxer *muxer,
const gchar *prefix)
gtk_action_muxer_remove (GtkActionMuxer *muxer,
const gchar *prefix)
{
Group *group;
@ -683,49 +683,49 @@ g_action_muxer_remove (GActionMuxer *muxer,
actions = g_action_group_list_actions (group->group);
for (i = 0; actions[i]; i++)
g_action_muxer_action_removed_from_group (group->group, actions[i], group);
gtk_action_muxer_action_removed_from_group (group->group, actions[i], group);
g_strfreev (actions);
g_action_muxer_free_group (group);
gtk_action_muxer_free_group (group);
}
}
/*
* g_action_muxer_new:
* gtk_action_muxer_new:
*
* Creates a new #GActionMuxer.
* Creates a new #GtkActionMuxer.
*/
GActionMuxer *
g_action_muxer_new (void)
GtkActionMuxer *
gtk_action_muxer_new (void)
{
return g_object_new (G_TYPE_ACTION_MUXER, NULL);
return g_object_new (GTK_TYPE_ACTION_MUXER, NULL);
}
/* g_action_muxer_get_parent:
* @muxer: a #GActionMuxer
/* gtk_action_muxer_get_parent:
* @muxer: a #GtkActionMuxer
*
* Returns: (transfer-none): the parent of @muxer, or NULL.
*/
GActionMuxer *
g_action_muxer_get_parent (GActionMuxer *muxer)
GtkActionMuxer *
gtk_action_muxer_get_parent (GtkActionMuxer *muxer)
{
g_return_val_if_fail (G_IS_ACTION_MUXER (muxer), NULL);
g_return_val_if_fail (GTK_IS_ACTION_MUXER (muxer), NULL);
return muxer->parent;
}
/* g_action_muxer_set_parent:
* @muxer: a #GActionMuxer
* @parent: (allow-none): the new parent #GActionMuxer
/* gtk_action_muxer_set_parent:
* @muxer: a #GtkActionMuxer
* @parent: (allow-none): the new parent #GtkActionMuxer
*
* Sets the parent of @muxer to @parent.
*/
void
g_action_muxer_set_parent (GActionMuxer *muxer,
GActionMuxer *parent)
gtk_action_muxer_set_parent (GtkActionMuxer *muxer,
GtkActionMuxer *parent)
{
g_return_if_fail (G_IS_ACTION_MUXER (muxer));
g_return_if_fail (parent == NULL || G_IS_ACTION_MUXER (parent));
g_return_if_fail (GTK_IS_ACTION_MUXER (muxer));
g_return_if_fail (parent == NULL || GTK_IS_ACTION_MUXER (parent));
if (muxer->parent == parent)
return;
@ -737,13 +737,13 @@ g_action_muxer_set_parent (GActionMuxer *muxer,
actions = g_action_group_list_actions (G_ACTION_GROUP (muxer->parent));
for (it = actions; *it; it++)
g_action_muxer_action_removed (muxer, *it);
gtk_action_muxer_action_removed (muxer, *it);
g_strfreev (actions);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_action_added_to_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_action_removed_from_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_parent_action_enabled_changed, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, g_action_muxer_parent_action_state_changed, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_action_added_to_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_action_removed_from_parent, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_parent_action_enabled_changed, muxer);
g_signal_handlers_disconnect_by_func (muxer->parent, gtk_action_muxer_parent_action_state_changed, muxer);
g_object_unref (muxer->parent);
}
@ -759,17 +759,17 @@ g_action_muxer_set_parent (GActionMuxer *muxer,
actions = g_action_group_list_actions (G_ACTION_GROUP (muxer->parent));
for (it = actions; *it; it++)
g_action_muxer_action_added (muxer, *it, G_ACTION_GROUP (muxer->parent), *it);
gtk_action_muxer_action_added (muxer, *it, G_ACTION_GROUP (muxer->parent), *it);
g_strfreev (actions);
g_signal_connect (muxer->parent, "action-added",
G_CALLBACK (g_action_muxer_action_added_to_parent), muxer);
G_CALLBACK (gtk_action_muxer_action_added_to_parent), muxer);
g_signal_connect (muxer->parent, "action-removed",
G_CALLBACK (g_action_muxer_action_removed_from_parent), muxer);
G_CALLBACK (gtk_action_muxer_action_removed_from_parent), muxer);
g_signal_connect (muxer->parent, "action-enabled-changed",
G_CALLBACK (g_action_muxer_parent_action_enabled_changed), muxer);
G_CALLBACK (gtk_action_muxer_parent_action_enabled_changed), muxer);
g_signal_connect (muxer->parent, "action-state-changed",
G_CALLBACK (g_action_muxer_parent_action_state_changed), muxer);
G_CALLBACK (gtk_action_muxer_parent_action_state_changed), muxer);
}
g_object_notify_by_pspec (G_OBJECT (muxer), properties[PROP_PARENT]);

View File

@ -17,42 +17,42 @@
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __G_ACTION_MUXER_H__
#define __G_ACTION_MUXER_H__
#ifndef __GTK_ACTION_MUXER_H__
#define __GTK_ACTION_MUXER_H__
#include <gio/gio.h>
G_BEGIN_DECLS
#define G_TYPE_ACTION_MUXER (g_action_muxer_get_type ())
#define G_ACTION_MUXER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
G_TYPE_ACTION_MUXER, GActionMuxer))
#define G_IS_ACTION_MUXER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
G_TYPE_ACTION_MUXER))
#define GTK_TYPE_ACTION_MUXER (gtk_action_muxer_get_type ())
#define GTK_ACTION_MUXER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
GTK_TYPE_ACTION_MUXER, GtkActionMuxer))
#define GTK_IS_ACTION_MUXER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
GTK_TYPE_ACTION_MUXER))
typedef struct _GActionMuxer GActionMuxer;
typedef struct _GtkActionMuxer GtkActionMuxer;
G_GNUC_INTERNAL
GType g_action_muxer_get_type (void);
GType gtk_action_muxer_get_type (void);
G_GNUC_INTERNAL
GActionMuxer * g_action_muxer_new (void);
GtkActionMuxer * gtk_action_muxer_new (void);
G_GNUC_INTERNAL
void g_action_muxer_insert (GActionMuxer *muxer,
const gchar *prefix,
GActionGroup *group);
void gtk_action_muxer_insert (GtkActionMuxer *muxer,
const gchar *prefix,
GActionGroup *group);
G_GNUC_INTERNAL
void g_action_muxer_remove (GActionMuxer *muxer,
const gchar *prefix);
void gtk_action_muxer_remove (GtkActionMuxer *muxer,
const gchar *prefix);
G_GNUC_INTERNAL
GActionMuxer * g_action_muxer_get_parent (GActionMuxer *muxer);
GtkActionMuxer * gtk_action_muxer_get_parent (GtkActionMuxer *muxer);
G_GNUC_INTERNAL
void g_action_muxer_set_parent (GActionMuxer *muxer,
GActionMuxer *parent);
void gtk_action_muxer_set_parent (GtkActionMuxer *muxer,
GtkActionMuxer *parent);
G_END_DECLS
#endif /* __G_ACTION_MUXER_H__ */
#endif /* __GTK_ACTION_MUXER_H__ */

View File

@ -19,46 +19,46 @@
#include "config.h"
#include "gactionobservable.h"
#include "gtkactionobservable.h"
G_DEFINE_INTERFACE (GActionObservable, g_action_observable, G_TYPE_OBJECT)
G_DEFINE_INTERFACE (GtkActionObservable, gtk_action_observable, G_TYPE_OBJECT)
/*
* SECTION:gactionobserable
* SECTION:gtkactionobserable
* @short_description: an interface implemented by objects that report
* changes to actions
*/
void
g_action_observable_default_init (GActionObservableInterface *iface)
gtk_action_observable_default_init (GtkActionObservableInterface *iface)
{
}
/*
* g_action_observable_register_observer:
* @observable: a #GActionObservable
* gtk_action_observable_register_observer:
* @observable: a #GtkActionObservable
* @action_name: the name of the action
* @observer: the #GActionObserver to which the events will be reported
* @observer: the #GtkActionObserver to which the events will be reported
*
* Registers @observer as being interested in changes to @action_name on
* @observable.
*/
void
g_action_observable_register_observer (GActionObservable *observable,
const gchar *action_name,
GActionObserver *observer)
gtk_action_observable_register_observer (GtkActionObservable *observable,
const gchar *action_name,
GtkActionObserver *observer)
{
g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
g_return_if_fail (GTK_IS_ACTION_OBSERVABLE (observable));
G_ACTION_OBSERVABLE_GET_IFACE (observable)
GTK_ACTION_OBSERVABLE_GET_IFACE (observable)
->register_observer (observable, action_name, observer);
}
/*
* g_action_observable_unregister_observer:
* @observable: a #GActionObservable
* gtk_action_observable_unregister_observer:
* @observable: a #GtkActionObservable
* @action_name: the name of the action
* @observer: the #GActionObserver to which the events will be reported
* @observer: the #GtkActionObserver to which the events will be reported
*
* Removes the registration of @observer as being interested in changes
* to @action_name on @observable.
@ -67,12 +67,12 @@ g_action_observable_register_observer (GActionObservable *observable,
* unregistered an equal number of times.
*/
void
g_action_observable_unregister_observer (GActionObservable *observable,
const gchar *action_name,
GActionObserver *observer)
gtk_action_observable_unregister_observer (GtkActionObservable *observable,
const gchar *action_name,
GtkActionObserver *observer)
{
g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
g_return_if_fail (GTK_IS_ACTION_OBSERVABLE (observable));
G_ACTION_OBSERVABLE_GET_IFACE (observable)
GTK_ACTION_OBSERVABLE_GET_IFACE (observable)
->unregister_observer (observable, action_name, observer);
}

63
gtk/gtkactionobservable.h Normal file
View File

@ -0,0 +1,63 @@
/*
* Copyright © 2011 Canonical Limited
*
* 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
* licence 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __GTK_ACTION_OBSERVABLE_H__
#define __GTK_ACTION_OBSERVABLE_H__
#include <gtk/gtkactionobserver.h>
G_BEGIN_DECLS
#define GTK_TYPE_ACTION_OBSERVABLE (gtk_action_observable_get_type ())
#define GTK_ACTION_OBSERVABLE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
GTK_TYPE_ACTION_OBSERVABLE, GtkActionObservable))
#define GTK_IS_ACTION_OBSERVABLE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
GTK_TYPE_ACTION_OBSERVABLE))
#define GTK_ACTION_OBSERVABLE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
GTK_TYPE_ACTION_OBSERVABLE, \
GtkActionObservableInterface))
typedef struct _GtkActionObservableInterface GtkActionObservableInterface;
struct _GtkActionObservableInterface
{
GTypeInterface g_iface;
void (* register_observer) (GtkActionObservable *observable,
const gchar *action_name,
GtkActionObserver *observer);
void (* unregister_observer) (GtkActionObservable *observable,
const gchar *action_name,
GtkActionObserver *observer);
};
G_GNUC_INTERNAL
GType gtk_action_observable_get_type (void);
G_GNUC_INTERNAL
void gtk_action_observable_register_observer (GtkActionObservable *observable,
const gchar *action_name,
GtkActionObserver *observer);
G_GNUC_INTERNAL
void gtk_action_observable_unregister_observer (GtkActionObservable *observable,
const gchar *action_name,
GtkActionObserver *observer);
G_END_DECLS
#endif /* __GTK_ACTION_OBSERVABLE_H__ */

View File

@ -19,16 +19,16 @@
#include "config.h"
#include "gactionobserver.h"
#include "gtkactionobserver.h"
G_DEFINE_INTERFACE (GActionObserver, g_action_observer, G_TYPE_OBJECT)
G_DEFINE_INTERFACE (GtkActionObserver, gtk_action_observer, G_TYPE_OBJECT)
/**
* SECTION:gactionobserver
* SECTION:gtkactionobserver
* @short_description: an interface implemented by objects that are
* interested in monitoring actions for changes
*
* GActionObserver is a simple interface allowing objects that wish to
* GtkActionObserver is a simple interface allowing objects that wish to
* be notified of changes to actions to be notified of those changes.
*
* It is also possible to monitor changes to action groups using
@ -50,13 +50,13 @@ G_DEFINE_INTERFACE (GActionObserver, g_action_observer, G_TYPE_OBJECT)
*/
void
g_action_observer_default_init (GActionObserverInterface *class)
gtk_action_observer_default_init (GtkActionObserverInterface *class)
{
}
/*
* g_action_observer_action_added:
* @observer: a #GActionObserver
* gtk_action_observer_action_added:
* @observer: a #GtkActionObserver
* @observable: the source of the event
* @action_name: the name of the action
* @enabled: %TRUE if the action is now enabled
@ -72,22 +72,22 @@ g_action_observer_default_init (GActionObserverInterface *class)
* observer has explicitly registered itself to receive events.
*/
void
g_action_observer_action_added (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state)
gtk_action_observer_action_added (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state)
{
g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
g_return_if_fail (GTK_IS_ACTION_OBSERVER (observer));
G_ACTION_OBSERVER_GET_IFACE (observer)
GTK_ACTION_OBSERVER_GET_IFACE (observer)
->action_added (observer, observable, action_name, parameter_type, enabled, state);
}
/*
* g_action_observer_action_enabled_changed:
* @observer: a #GActionObserver
* gtk_action_observer_action_enabled_changed:
* @observer: a #GtkActionObserver
* @observable: the source of the event
* @action_name: the name of the action
* @enabled: %TRUE if the action is now enabled
@ -99,20 +99,20 @@ g_action_observer_action_added (GActionObserver *observer,
* observer has explicitly registered itself to receive events.
*/
void
g_action_observer_action_enabled_changed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
gboolean enabled)
gtk_action_observer_action_enabled_changed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
gboolean enabled)
{
g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
g_return_if_fail (GTK_IS_ACTION_OBSERVER (observer));
G_ACTION_OBSERVER_GET_IFACE (observer)
GTK_ACTION_OBSERVER_GET_IFACE (observer)
->action_enabled_changed (observer, observable, action_name, enabled);
}
/*
* g_action_observer_action_state_changed:
* @observer: a #GActionObserver
* gtk_action_observer_action_state_changed:
* @observer: a #GtkActionObserver
* @observable: the source of the event
* @action_name: the name of the action
* @state: the new state of the action
@ -124,20 +124,20 @@ g_action_observer_action_enabled_changed (GActionObserver *observer,
* observer has explicitly registered itself to receive events.
*/
void
g_action_observer_action_state_changed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name,
GVariant *state)
gtk_action_observer_action_state_changed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
GVariant *state)
{
g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
g_return_if_fail (GTK_IS_ACTION_OBSERVER (observer));
G_ACTION_OBSERVER_GET_IFACE (observer)
GTK_ACTION_OBSERVER_GET_IFACE (observer)
->action_state_changed (observer, observable, action_name, state);
}
/*
* g_action_observer_action_removed:
* @observer: a #GActionObserver
* gtk_action_observer_action_removed:
* @observer: a #GtkActionObserver
* @observable: the source of the event
* @action_name: the name of the action
*
@ -148,12 +148,12 @@ g_action_observer_action_state_changed (GActionObserver *observer,
* observer has explicitly registered itself to receive events.
*/
void
g_action_observer_action_removed (GActionObserver *observer,
GActionObservable *observable,
const gchar *action_name)
gtk_action_observer_action_removed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name)
{
g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
g_return_if_fail (GTK_IS_ACTION_OBSERVER (observer));
G_ACTION_OBSERVER_GET_IFACE (observer)
GTK_ACTION_OBSERVER_GET_IFACE (observer)
->action_removed (observer, observable, action_name);
}

88
gtk/gtkactionobserver.h Normal file
View File

@ -0,0 +1,88 @@
/*
* Copyright © 2011 Canonical Limited
*
* 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
* licence 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Ryan Lortie <desrt@desrt.ca>
*/
#ifndef __GTK_ACTION_OBSERVER_H__
#define __GTK_ACTION_OBSERVER_H__
#include <gio/gio.h>
G_BEGIN_DECLS
#define GTK_TYPE_ACTION_OBSERVER (gtk_action_observer_get_type ())
#define GTK_ACTION_OBSERVER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
GTK_TYPE_ACTION_OBSERVER, GtkActionObserver))
#define GTK_IS_ACTION_OBSERVER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
GTK_TYPE_ACTION_OBSERVER))
#define GTK_ACTION_OBSERVER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
GTK_TYPE_ACTION_OBSERVER, GtkActionObserverInterface))
typedef struct _GtkActionObserverInterface GtkActionObserverInterface;
typedef struct _GtkActionObservable GtkActionObservable;
typedef struct _GtkActionObserver GtkActionObserver;
struct _GtkActionObserverInterface
{
GTypeInterface g_iface;
void (* action_added) (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state);
void (* action_enabled_changed) (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
gboolean enabled);
void (* action_state_changed) (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
GVariant *state);
void (* action_removed) (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name);
};
G_GNUC_INTERNAL
GType gtk_action_observer_get_type (void);
G_GNUC_INTERNAL
void gtk_action_observer_action_added (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
const GVariantType *parameter_type,
gboolean enabled,
GVariant *state);
G_GNUC_INTERNAL
void gtk_action_observer_action_enabled_changed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
gboolean enabled);
G_GNUC_INTERNAL
void gtk_action_observer_action_state_changed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name,
GVariant *state);
G_GNUC_INTERNAL
void gtk_action_observer_action_removed (GtkActionObserver *observer,
GtkActionObservable *observable,
const gchar *action_name);
G_END_DECLS
#endif /* __GTK_ACTION_OBSERVER_H__ */

View File

@ -505,7 +505,7 @@ struct _GtkWidgetPrivate
SizeRequestCache requests;
/* actions attached to this or any parent widget */
GActionMuxer *muxer;
GtkActionMuxer *muxer;
/* The widget's window or its parent window if it does
* not have a window. (Which will be indicated by the
@ -15351,7 +15351,7 @@ void
_gtk_widget_update_parent_muxer (GtkWidget *widget)
{
GtkWidget *parent;
GActionMuxer *parent_muxer;
GtkActionMuxer *parent_muxer;
if (widget->priv->muxer == NULL)
return;
@ -15363,15 +15363,15 @@ _gtk_widget_update_parent_muxer (GtkWidget *widget)
parent_muxer = parent ? _gtk_widget_get_action_muxer (parent) : NULL;
g_action_muxer_set_parent (widget->priv->muxer, parent_muxer);
gtk_action_muxer_set_parent (widget->priv->muxer, parent_muxer);
}
GActionMuxer *
GtkActionMuxer *
_gtk_widget_get_action_muxer (GtkWidget *widget)
{
if (widget->priv->muxer == NULL)
{
widget->priv->muxer = g_action_muxer_new ();
widget->priv->muxer = gtk_action_muxer_new ();
_gtk_widget_update_parent_muxer (widget);
}
@ -15396,7 +15396,7 @@ gtk_widget_insert_action_group (GtkWidget *widget,
const gchar *name,
GActionGroup *group)
{
GActionMuxer *muxer;
GtkActionMuxer *muxer;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (name != NULL);
@ -15404,9 +15404,9 @@ gtk_widget_insert_action_group (GtkWidget *widget,
muxer = _gtk_widget_get_action_muxer (widget);
if (group)
g_action_muxer_insert (muxer, name, group);
gtk_action_muxer_insert (muxer, name, group);
else
g_action_muxer_remove (muxer, name);
gtk_action_muxer_remove (muxer, name);
}
/****************************************************************

View File

@ -27,7 +27,7 @@
#include "gtkcsstypesprivate.h"
#include "gtkwidget.h"
#include "gactionmuxer.h"
#include "gtkactionmuxer.h"
G_BEGIN_DECLS
@ -145,7 +145,7 @@ void _gtk_widget_invalidate_style_context (GtkWidget *widget
void _gtk_widget_style_context_invalidated (GtkWidget *widget);
void _gtk_widget_update_parent_muxer (GtkWidget *widget);
GActionMuxer * _gtk_widget_get_action_muxer (GtkWidget *widget);
GtkActionMuxer * _gtk_widget_get_action_muxer (GtkWidget *widget);
G_END_DECLS