本文整理汇总了C++中G_ACTION_GROUP函数的典型用法代码示例。如果您正苦于以下问题:C++ G_ACTION_GROUP函数的具体用法?C++ G_ACTION_GROUP怎么用?C++ G_ACTION_GROUP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_ACTION_GROUP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ide_editor_view_actions_init
void
ide_editor_view_actions_init (IdeEditorView *self)
{
g_autoptr(GSimpleActionGroup) group = NULL;
group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorViewActions,
G_N_ELEMENTS (IdeEditorViewActions), self);
gtk_widget_insert_action_group (GTK_WIDGET (self), "view", G_ACTION_GROUP (group));
gtk_widget_insert_action_group (GTK_WIDGET (self->tweak_widget), "view", G_ACTION_GROUP (group));
#define WATCH_PROPERTY(name) \
G_STMT_START { \
g_signal_connect (self->frame1->source_view, \
"notify::"name, \
G_CALLBACK (ide_editor_view_actions_source_view_notify), \
group); \
g_object_notify (G_OBJECT (self->frame1->source_view), name); \
} G_STMT_END
WATCH_PROPERTY ("auto-indent");
WATCH_PROPERTY ("highlight-current-line");
WATCH_PROPERTY ("insert-spaces-instead-of-tabs");
WATCH_PROPERTY ("show-line-numbers");
WATCH_PROPERTY ("show-right-margin");
WATCH_PROPERTY ("smart-backspace");
WATCH_PROPERTY ("tab-width");
#undef WATCH_PROPERTY
}
示例2: gb_project_tree_actions_init
void
gb_project_tree_actions_init (GbProjectTree *self)
{
g_autoptr(GSettings) settings = NULL;
g_autoptr(GSettings) tree_settings = NULL;
g_autoptr(GSimpleActionGroup) actions = NULL;
g_autoptr(GAction) action = NULL;
g_autoptr(GVariant) show_icons = NULL;
actions = g_simple_action_group_new ();
settings = g_settings_new ("org.gtk.Settings.FileChooser");
action = g_settings_create_action (settings, "sort-directories-first");
g_action_map_add_action (G_ACTION_MAP (actions), action);
g_action_map_add_action_entries (G_ACTION_MAP (actions),
GbProjectTreeActions,
G_N_ELEMENTS (GbProjectTreeActions),
self);
gtk_widget_insert_action_group (GTK_WIDGET (self),
"project-tree",
G_ACTION_GROUP (actions));
tree_settings = g_settings_new ("org.gnome.builder.project-tree");
show_icons = g_settings_get_value (tree_settings, "show-icons");
action_set (G_ACTION_GROUP (actions), "show-icons",
"state", show_icons,
NULL);
gb_project_tree_actions_update (self);
}
示例3: main
int
main (int argc, char **argv)
{
GApplication *app;
int status;
app = g_application_new ("org.gtk.TestApplication", 0);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_application_set_inactivity_timeout (app, 10000);
add_actions (app);
if (argc > 1 && strcmp (argv[1], "--simple-action") == 0)
{
g_application_register (app, NULL, NULL);
g_action_group_activate_action (G_ACTION_GROUP (app), "simple-action", NULL);
exit (0);
}
else if (argc > 1 && strcmp (argv[1], "--toggle-action") == 0)
{
g_application_register (app, NULL, NULL);
g_action_group_activate_action (G_ACTION_GROUP (app), "toggle-action", NULL);
exit (0);
}
status = g_application_run (app, argc, argv);
g_object_unref (app);
return status;
}
示例4: gtk_application_window_real_realize
static void
gtk_application_window_real_realize (GtkWidget *widget)
{
GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
GtkApplication *application;
GtkSettings *settings;
application = gtk_window_get_application (GTK_WINDOW (window));
settings = gtk_widget_get_settings (widget);
g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);
if (!window->priv->muxer_initialised)
{
g_action_muxer_insert (G_ACTION_MUXER (window->priv->muxer), "app", G_ACTION_GROUP (application));
g_action_muxer_insert (G_ACTION_MUXER (window->priv->muxer), "win", G_ACTION_GROUP (window));
window->priv->muxer_initialised = TRUE;
}
gtk_application_window_update_shell_shows_app_menu (window, settings);
gtk_application_window_update_shell_shows_menubar (window, settings);
gtk_application_window_update_menubar (window);
gtk_application_window_update_accels (window);
GTK_WIDGET_CLASS (gtk_application_window_parent_class)
->realize (widget);
#ifdef GDK_WINDOWING_X11
{
GdkWindow *gdkwindow;
gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
if (GDK_IS_X11_WINDOW (gdkwindow) && window->priv->session)
{
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_ID",
g_application_get_application_id (G_APPLICATION (application)));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_UNIQUE_BUS_NAME",
g_dbus_connection_get_unique_name (window->priv->session));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APPLICATION_OBJECT_PATH",
g_application_get_dbus_object_path (G_APPLICATION (application)));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_WINDOW_OBJECT_PATH",
window->priv->object_path);
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APP_MENU_OBJECT_PATH",
gtk_application_get_app_menu_object_path (application));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_MENUBAR_OBJECT_PATH",
gtk_application_get_menubar_object_path (application));
}
}
#endif
}
示例5: activate_action
static void
activate_action (GtkWidget *widget,
const gchar *prefix,
const gchar *action_name,
GVariant *parameter)
{
GApplication *app;
GtkWidget *toplevel;
GActionGroup *group = NULL;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (prefix);
g_return_if_fail (action_name);
g_print ("activate!\n");
app = g_application_get_default ();
toplevel = gtk_widget_get_toplevel (widget);
while ((group == NULL) && (widget != NULL))
{
group = gtk_widget_get_action_group (widget, prefix);
widget = gtk_widget_get_parent (widget);
}
if (!group && g_str_equal (prefix, "win") && G_IS_ACTION_GROUP (toplevel))
group = G_ACTION_GROUP (toplevel);
if (!group && g_str_equal (prefix, "app") && G_IS_ACTION_GROUP (app))
group = G_ACTION_GROUP (app);
if (group)
{
if (g_action_group_has_action (group, action_name))
{
g_print ("Activating %s.%s\n", prefix, action_name);
g_action_group_activate_action (group, action_name, parameter);
return;
}
}
if (parameter && g_variant_is_floating (parameter))
{
parameter = g_variant_ref_sink (parameter);
g_variant_unref (parameter);
}
g_warning ("Failed to resolve action %s.%s", prefix, action_name);
}
示例6: action_enter_location_callback
static void
action_enter_location_callback (GtkAction *action,
gpointer user_data)
{
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"enter-location", NULL);
}
示例7: bus_acquired
static void
bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
IndicatorTestService *indicator = user_data;
GError *error = NULL;
indicator->actions_export_id = g_dbus_connection_export_action_group (connection,
"/com/canonical/indicator/test",
G_ACTION_GROUP (indicator->actions),
&error);
if (indicator->actions_export_id == 0)
{
g_warning ("cannot export action group: %s", error->message);
g_error_free (error);
return;
}
indicator->menu_export_id = g_dbus_connection_export_menu_model (connection,
"/com/canonical/indicator/test/desktop",
G_MENU_MODEL (indicator->menu),
&error);
if (indicator->menu_export_id == 0)
{
g_warning ("cannot export menu: %s", error->message);
g_error_free (error);
return;
}
}
示例8: gtk_application_window_init
static void
gtk_application_window_init (GtkApplicationWindow *window)
{
window->priv = gtk_application_window_get_instance_private (window);
window->priv->actions = gtk_application_window_actions_new (window);
window->priv->app_menu_section = g_menu_new ();
window->priv->menubar_section = g_menu_new ();
window->priv->accels = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), window->priv->accels);
gtk_widget_insert_action_group (GTK_WIDGET (window), "win", G_ACTION_GROUP (window->priv->actions));
/* window->priv->actions is the one and only ref on the group, so when
* we dispose, the action group will die, disconnecting all signals.
*/
g_signal_connect_swapped (window->priv->actions, "action-added",
G_CALLBACK (g_action_group_action_added), window);
g_signal_connect_swapped (window->priv->actions, "action-enabled-changed",
G_CALLBACK (g_action_group_action_enabled_changed), window);
g_signal_connect_swapped (window->priv->actions, "action-state-changed",
G_CALLBACK (g_action_group_action_state_changed), window);
g_signal_connect_swapped (window->priv->actions, "action-removed",
G_CALLBACK (g_action_group_action_removed), window);
}
示例9: action_about_nautilus_callback
static void
action_about_nautilus_callback (GtkAction *action,
gpointer user_data)
{
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"about", NULL);
}
示例10: g_dbus_action_group_describe_all_done
static void
g_dbus_action_group_describe_all_done (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GDBusActionGroup *group= user_data;
GVariant *reply;
g_assert (group->actions == NULL);
group->actions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, action_info_free);
g_assert (group->connection == (gpointer) source);
reply = g_dbus_connection_call_finish (group->connection, result, NULL);
if (reply != NULL)
{
GVariantIter *iter;
ActionInfo *action;
g_variant_get (reply, "(a{s(bgav)})", &iter);
while ((action = action_info_new_from_iter (iter)))
{
g_hash_table_insert (group->actions, action->name, action);
if (group->strict)
g_action_group_action_added (G_ACTION_GROUP (group), action->name);
}
g_variant_iter_free (iter);
g_variant_unref (reply);
}
g_object_unref (group);
}
示例11: action_bookmarks_callback
static void
action_bookmarks_callback (GtkAction *action,
gpointer user_data)
{
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"bookmarks", NULL);
}
示例12: action_connect_to_server_callback
static void
action_connect_to_server_callback (GtkAction *action,
gpointer user_data)
{
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"connect-to-server", NULL);
}
示例13: gpm_applet_cb
/**
* gpm_applet_cb:
* @_applet: GpmInhibitApplet instance created by the applet factory
* @iid: Applet id
*
* the function called by libpanel-applet factory after creation
**/
static gboolean
gpm_applet_cb (PanelApplet *_applet, const gchar *iid, gpointer data)
{
GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(_applet);
GSimpleActionGroup *action_group;
gchar *ui_path;
static const GActionEntry menu_actions [] = {
{ "about", gpm_applet_dialog_about_cb, NULL, NULL, NULL },
};
if (strcmp (iid, GPM_INHIBIT_APPLET_ID) != 0) {
return FALSE;
}
action_group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (action_group),
menu_actions,
G_N_ELEMENTS (menu_actions),
applet);
ui_path = g_build_filename (INHIBIT_MENU_UI_DIR, "inhibit-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (applet), ui_path, action_group, GETTEXT_PACKAGE);
g_free (ui_path);
gtk_widget_insert_action_group (GTK_WIDGET (applet), "inhibit",
G_ACTION_GROUP (action_group));
g_object_unref (action_group);
return TRUE;
}
示例14: action_new_window_callback
static void
action_new_window_callback (GtkAction *action,
gpointer user_data)
{
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"new-window", NULL);
}
示例15: action_close_all_windows_callback
static void
action_close_all_windows_callback (GtkAction *action,
gpointer user_data)
{
g_action_group_activate_action (G_ACTION_GROUP (g_application_get_default ()),
"quit", NULL);
}