Speed up action muxer setup more
Don't emit signals for group insertion/removal if nobody is listening.
This commit is contained in:
@@ -94,6 +94,9 @@ static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
guint accel_signal;
|
||||
|
||||
static guint action_added_signal;
|
||||
static guint action_removed_signal;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkActionMuxer *muxer;
|
||||
@@ -359,13 +362,8 @@ static void
|
||||
emit_action_added (GtkActionMuxer *muxer,
|
||||
GtkActionMuxer *parent)
|
||||
{
|
||||
static guint signal_id = 0;
|
||||
|
||||
if (signal_id == 0)
|
||||
signal_id = g_signal_lookup ("action-added", G_OBJECT_TYPE (muxer));
|
||||
|
||||
if (g_signal_has_handler_pending (muxer, signal_id, 0, FALSE))
|
||||
{
|
||||
if (g_signal_has_handler_pending (muxer, action_added_signal, 0, FALSE))
|
||||
{
|
||||
gchar **actions;
|
||||
gchar **it;
|
||||
|
||||
@@ -387,13 +385,10 @@ notify_observers_removed (GtkActionMuxer *muxer,
|
||||
Action *action;
|
||||
|
||||
g_hash_table_iter_init (&iter, muxer->observed_actions);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&action_name, (gpointer *)&action))
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&action_name, (gpointer *)&action))
|
||||
{
|
||||
GSList *node;
|
||||
|
||||
if (!action->watchers)
|
||||
continue;
|
||||
|
||||
for (node = action->watchers; node; node = node->next)
|
||||
gtk_action_observer_action_removed (node->data,
|
||||
GTK_ACTION_OBSERVABLE (muxer),
|
||||
@@ -405,13 +400,8 @@ static void
|
||||
emit_action_removed (GtkActionMuxer *muxer,
|
||||
GtkActionMuxer *parent)
|
||||
{
|
||||
static guint signal_id = 0;
|
||||
|
||||
if (signal_id == 0)
|
||||
signal_id = g_signal_lookup ("action-removed", G_OBJECT_TYPE (muxer));
|
||||
|
||||
if (g_signal_has_handler_pending (muxer, signal_id, 0, FALSE))
|
||||
{
|
||||
if (g_signal_has_handler_pending (muxer, action_removed_signal, 0, FALSE))
|
||||
{
|
||||
gchar **actions;
|
||||
gchar **it;
|
||||
|
||||
@@ -461,12 +451,14 @@ gtk_action_muxer_action_added_to_group (GActionGroup *action_group,
|
||||
gpointer user_data)
|
||||
{
|
||||
Group *group = user_data;
|
||||
gchar *fullname;
|
||||
|
||||
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
|
||||
gtk_action_muxer_action_added (group->muxer, fullname, action_group, action_name);
|
||||
|
||||
g_free (fullname);
|
||||
if (g_hash_table_size (group->muxer->observed_actions) > 0 ||
|
||||
g_signal_has_handler_pending (group->muxer, action_added_signal, 0, FALSE))
|
||||
{
|
||||
char *fullname = g_strconcat (group->prefix, ".", action_name, NULL);
|
||||
gtk_action_muxer_action_added (group->muxer, fullname, action_group, action_name);
|
||||
g_free (fullname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -498,12 +490,14 @@ gtk_action_muxer_action_removed_from_group (GActionGroup *action_group,
|
||||
gpointer user_data)
|
||||
{
|
||||
Group *group = user_data;
|
||||
gchar *fullname;
|
||||
|
||||
fullname = g_strconcat (group->prefix, ".", action_name, NULL);
|
||||
gtk_action_muxer_action_removed (group->muxer, fullname);
|
||||
|
||||
g_free (fullname);
|
||||
if (g_hash_table_size (group->muxer->observed_actions) > 0 ||
|
||||
g_signal_has_handler_pending (group->muxer, action_removed_signal, 0, FALSE))
|
||||
{
|
||||
char *fullname = g_strconcat (group->prefix, ".", action_name, NULL);
|
||||
gtk_action_muxer_action_removed (group->muxer, fullname);
|
||||
g_free (fullname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1045,6 +1039,9 @@ gtk_action_muxer_class_init (GObjectClass *class)
|
||||
class->finalize = gtk_action_muxer_finalize;
|
||||
class->dispose = gtk_action_muxer_dispose;
|
||||
|
||||
action_added_signal = g_signal_lookup ("action-added", GTK_TYPE_ACTION_MUXER);
|
||||
action_removed_signal = g_signal_lookup ("action-removed", GTK_TYPE_ACTION_MUXER);
|
||||
|
||||
accel_signal = g_signal_new (I_("primary-accel-changed"),
|
||||
GTK_TYPE_ACTION_MUXER,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
|
||||
Reference in New Issue
Block a user