本文整理汇总了C++中G_ACTION函数的典型用法代码示例。如果您正苦于以下问题:C++ G_ACTION函数的具体用法?C++ G_ACTION怎么用?C++ G_ACTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_ACTION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gstyle_color_panel_actions_toggle_page
static void
gstyle_color_panel_actions_toggle_page (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
GstyleColorPanel *self = (GstyleColorPanel *)user_data;
g_autoptr (GVariant) value = NULL;
g_autofree gchar *page_name = NULL;
const gchar *name;
gboolean state;
g_assert (GSTYLE_IS_COLOR_PANEL (self));
value = g_action_get_state (G_ACTION (action));
state = g_variant_get_boolean (value);
name = g_action_get_name(G_ACTION (action));
if (!g_str_has_prefix (name, "toggle-"))
return;
page_name = g_strdup (&name [7]);
g_simple_action_set_state (action, g_variant_new_boolean (!state));
if (!state)
{
_gstyle_color_panel_update_prefs_page (self, page_name);
gtk_stack_set_visible_child_name (self->prefs_stack, page_name);
}
gstyle_slidein_reveal_slide (GSTYLE_SLIDEIN (self->prefs_slidein),
!gstyle_slidein_get_revealed (GSTYLE_SLIDEIN (self->prefs_slidein)));
}
示例2: _brio_application_set_app_menu
static void
_brio_application_set_app_menu (GApplication *app)
{
GMenu *app_menu = g_menu_new ();
GSimpleAction *about;
GSimpleAction *quit;
about = g_simple_action_new ("about", NULL);
g_signal_connect (about,
"activate",
G_CALLBACK (_brio_application_show_about),
app);
g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about));
g_menu_append (app_menu, _("About"), "app.about");
quit = g_simple_action_new ("quit", NULL);
g_signal_connect (quit,
"activate",
G_CALLBACK (_brio_application_quit),
app);
g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit));
g_menu_append (app_menu, _("Quit"), "app.quit");
gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu));
}
示例3: create_action_group
static GSimpleActionGroup *
create_action_group(ReaderWindowPrivate *priv)
{
GSimpleActionGroup *actions = g_simple_action_group_new();
gboolean side_pane = cainteoir_settings_get_boolean(priv->settings, "index", "visible", TRUE);
priv->index_pane_action = g_simple_action_new_stateful("side-pane", nullptr, g_variant_new_boolean(side_pane));
g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->index_pane_action));
g_signal_connect(priv->index_pane_action, "activate", G_CALLBACK(on_index_pane_toggle_action), priv);
priv->open_action = g_simple_action_new("open", nullptr);
g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->open_action));
g_signal_connect(priv->open_action, "activate", G_CALLBACK(on_open_file_action), priv);
priv->play_stop_action = g_simple_action_new("play-stop", nullptr);
g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->play_stop_action));
g_signal_connect(priv->play_stop_action, "activate", G_CALLBACK(on_play_stop_action), priv);
priv->record_action = g_simple_action_new("record", nullptr);
g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->record_action));
g_signal_connect(priv->record_action, "activate", G_CALLBACK(on_record_action), priv);
return actions;
}
示例4: shell_add_actions
static void
shell_add_actions (GApplication *application)
{
GActionMap *action_map;
GSimpleAction *action;
action_map = G_ACTION_MAP (application);
/* Add actions that remote instances can invoke. */
action = g_simple_action_new ("new-window", G_VARIANT_TYPE_STRING);
g_signal_connect (
action, "activate",
G_CALLBACK (shell_action_new_window_cb), application);
g_action_map_add_action (action_map, G_ACTION (action));
g_object_unref (action);
action = g_simple_action_new (
"handle-uris", G_VARIANT_TYPE_STRING_ARRAY);
g_signal_connect (
action, "activate",
G_CALLBACK (shell_action_handle_uris_cb), application);
g_action_map_add_action (action_map, G_ACTION (action));
g_object_unref (action);
action = g_simple_action_new ("quit", NULL);
g_signal_connect (
action, "activate",
G_CALLBACK (shell_action_quit_cb), application);
g_action_map_add_action (action_map, G_ACTION (action));
g_object_unref (action);
}
示例5: impl_activate
static void
impl_activate (PeasActivatable *plugin)
{
TotemDiscRecorderPlugin *pi = TOTEM_DISC_RECORDER_PLUGIN (plugin);
TotemDiscRecorderPluginPrivate *priv = pi->priv;
GMenu *menu;
char *path;
/* make sure brasero is in the path */
path = g_find_program_in_path ("brasero");
if (!path)
return;
g_free (path);
priv->totem = g_object_get_data (G_OBJECT (plugin), "object");
g_signal_connect (priv->totem,
"file-opened",
G_CALLBACK (totem_disc_recorder_file_opened),
plugin);
g_signal_connect (priv->totem,
"file-closed",
G_CALLBACK (totem_disc_recorder_file_closed),
plugin);
/* Create the actions */
priv->dvd_action = g_simple_action_new ("media-optical-video-new", NULL);
g_signal_connect (G_OBJECT (priv->dvd_action), "activate",
G_CALLBACK (totem_disc_recorder_plugin_burn), plugin);
g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->dvd_action));
priv->copy_action = g_simple_action_new ("media-optical-copy", NULL);
g_signal_connect (G_OBJECT (priv->copy_action), "activate",
G_CALLBACK (totem_disc_recorder_plugin_copy), plugin);
g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->copy_action));
priv->copy_vcd_action = g_simple_action_new ("media-optical-copy-vcd", NULL);
g_signal_connect (G_OBJECT (priv->copy_vcd_action), "activate",
G_CALLBACK (totem_disc_recorder_plugin_copy), plugin);
g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->copy_vcd_action));
/* Install the menu */
menu = totem_object_get_menu_section (priv->totem, "burn-placeholder");
menu_append_hidden (G_MENU (menu), _("_Create Video Disc…"), "app.media-optical-video-new");
menu_append_hidden (G_MENU (menu), _("Copy Vide_o DVD…"), "app.media-optical-copy");
menu_append_hidden (G_MENU (menu), _("Copy (S)VCD…"), "app.media-optical-copy-vcd");
if (!totem_object_is_paused (priv->totem) && !totem_object_is_playing (priv->totem)) {
set_menu_items_state (pi, FALSE, FALSE, FALSE);
} else {
char *mrl;
mrl = totem_object_get_current_mrl (priv->totem);
totem_disc_recorder_file_opened (priv->totem, mrl, pi);
g_free (mrl);
}
}
示例6: cc_application_startup
static void
cc_application_startup (GApplication *application)
{
CcApplication *self = CC_APPLICATION (application);
GMenu *menu;
GMenu *section;
GSimpleAction *action;
G_APPLICATION_CLASS (cc_application_parent_class)->startup (application);
#ifdef HAVE_CHEESE
if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
{
g_critical ("Unable to initialize Clutter");
return;
}
#endif /* HAVE_CHEESE */
/* register a symbolic icon size for use in sidebar lists */
gtk_icon_size_register ("cc-sidebar-list", 24, 24);
action = g_simple_action_new ("help", NULL);
g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
g_signal_connect (action, "activate", G_CALLBACK (help_activated), self);
g_object_unref (action);
action = g_simple_action_new ("quit", NULL);
g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
g_signal_connect (action, "activate", G_CALLBACK (cc_application_quit), self);
g_object_unref (action);
/* Launch panel by id. The parameter is a (panel_id, array_of_panel_parameters)
* tuple. The GVariant-containing array usually is just the same array of
* strings that would be generated by passing panel-specific arguments on
* the command line. */
action = g_simple_action_new ("launch-panel", G_VARIANT_TYPE ("(sav)"));
g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
g_signal_connect (action, "activate", G_CALLBACK (launch_panel_activated), self);
g_object_unref (action);
menu = g_menu_new ();
section = g_menu_new ();
g_menu_append (section, _("Help"), "app.help");
g_menu_append (section, _("Quit"), "app.quit");
g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
gtk_application_set_app_menu (GTK_APPLICATION (application),
G_MENU_MODEL (menu));
gtk_application_add_accelerator (GTK_APPLICATION (application),
"F1", "app.help", NULL);
self->priv->window = cc_window_new (GTK_APPLICATION (application));
}
示例7: activate_action
static void
activate_action (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
GAction *win_action = get_corresponding_window_action (GTK_APPLICATION (data),
G_ACTION (action));
g_action_activate (win_action, parameter);
if (parameter)
g_action_change_state (G_ACTION (action), parameter);
}
示例8: toggle_speed
static void
toggle_speed (GtkToggleButton *button, gpointer data)
{
GMenuModel *model;
GActionGroup *group;
GSimpleAction *action;
gboolean adding;
GMenuModel *m;
GMenu *submenu;
GtkTreeView *tv = data;
GtkTreeModel *store;
model = g_object_get_data (G_OBJECT (button), "model");
group = g_object_get_data (G_OBJECT (button), "group");
store = gtk_tree_view_get_model (tv);
adding = gtk_toggle_button_get_active (button);
m = g_menu_model_get_item_link (model, 1, G_MENU_LINK_SECTION);
if (adding)
{
action = g_simple_action_new ("faster", NULL);
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
g_signal_connect (action, "activate", G_CALLBACK (activate_action), NULL);
g_object_unref (action);
action = g_simple_action_new ("slower", NULL);
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
g_signal_connect (action, "activate", G_CALLBACK (activate_action), NULL);
g_object_unref (action);
action_list_add (store, "faster");
action_list_add (store, "slower");
submenu = g_menu_new ();
g_menu_append (submenu, "Faster", "faster");
g_menu_append (submenu, "Slower", "slower");
g_menu_append_submenu (G_MENU (m), "Speed", G_MENU_MODEL (submenu));
}
else
{
g_action_map_remove_action (G_ACTION_MAP (group), "faster");
g_action_map_remove_action (G_ACTION_MAP (group), "slower");
action_list_remove (store, "faster");
action_list_remove (store, "slower");
g_menu_remove (G_MENU (m), g_menu_model_get_n_items (m) - 1);
}
}
示例9: gcal_application_set_app_menu
static void
gcal_application_set_app_menu (GApplication *app)
{
GcalApplicationPrivate *priv;
GMenu *app_menu;
GMenu *view_as;
GSimpleAction *about;
GSimpleAction *quit;
g_return_if_fail (GCAL_IS_APPLICATION (app));
priv = GCAL_APPLICATION (app)->priv;
app_menu = g_menu_new ();
priv->view = g_simple_action_new_stateful (
"view",
G_VARIANT_TYPE_STRING,
g_settings_get_value (priv->settings, "active-view"));
g_signal_connect (priv->view,
"activate",
G_CALLBACK (gcal_application_change_view),
app);
g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (priv->view));
view_as = g_menu_new ();
g_menu_append (view_as, _("Weeks"), "app.view::week");
g_menu_append (view_as, _("Months"), "app.view::month");
g_menu_append_section (app_menu, _("View as"), G_MENU_MODEL (view_as));
about = g_simple_action_new ("about", NULL);
g_signal_connect (about,
"activate",
G_CALLBACK (gcal_application_show_about),
app);
g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about));
g_menu_append (app_menu, _("About"), "app.about");
quit = g_simple_action_new ("quit", NULL);
g_signal_connect (quit,
"activate",
G_CALLBACK (gcal_application_quit),
app);
g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit));
g_menu_append (app_menu, _("Quit"), "app.quit");
gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu));
}
示例10: photos_application_action_toggle
static void
photos_application_action_toggle (GSimpleAction *simple, GVariant *parameter, gpointer user_data)
{
GVariant *state;
GVariant *new_state;
state = g_action_get_state (G_ACTION (simple));
if (state == NULL)
return;
new_state = g_variant_new ("b", !g_variant_get_boolean (state));
g_action_change_state (G_ACTION (simple), new_state);
g_variant_unref (state);
}
示例11: action_toggle_state
static void
action_toggle_state (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GVariant *state;
gboolean new_state;
state = g_action_get_state (G_ACTION (action));
new_state = !g_variant_get_boolean (state);
g_action_change_state (G_ACTION (action),
g_variant_new_boolean (new_state));
g_variant_unref (state);
}
示例12: startup
static void
startup (GApplication *app,
gpointer user_data)
{
GSimpleAction *new_action;
GSimpleAction *quit_action;
new_action = g_simple_action_new ("new", NULL);
g_signal_connect (new_action, "activate", G_CALLBACK (new_callback), app);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (new_action));
quit_action = g_simple_action_new ("quit", NULL);
g_signal_connect (quit_action, "activate", G_CALLBACK (quit_callback), app);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (quit_action));
}
示例13: activate_toggle_action
static void
activate_toggle_action (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
GVariant *state = g_action_get_state (G_ACTION (action));
gboolean value = g_variant_get_boolean (state);
GAction *win_action;
win_action = get_corresponding_window_action (GTK_APPLICATION (data),
G_ACTION (action));
g_action_change_state (win_action, g_variant_new_boolean (!value));
g_action_change_state (G_ACTION (action), g_variant_new_boolean (!value));
g_variant_unref (state);
}
示例14: gb_preferences_switch_update_settings
static void
gb_preferences_switch_update_settings (GbPreferencesSwitch *self)
{
g_assert (GB_IS_PREFERENCES_SWITCH (self));
if ((self->settings != NULL) && (self->settings_schema_key != NULL))
{
GSimpleActionGroup *group;
GAction *action;
gchar *name;
action = g_settings_create_action (self->settings, self->settings_schema_key);
group = g_simple_action_group_new ();
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
gtk_widget_insert_action_group (GTK_WIDGET (self), "settings", G_ACTION_GROUP (group));
g_object_unref (action);
name = g_strdup_printf ("settings.%s", self->settings_schema_key);
if (self->is_radio)
{
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_radio), name);
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_switch), NULL);
}
else
{
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_radio), NULL);
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_switch), name);
}
g_free (name);
}
}
示例15: xfdashboard_application_init
/* Object initialization
* Create private structure and set up default values
*/
static void xfdashboard_application_init(XfdashboardApplication *self)
{
XfdashboardApplicationPrivate *priv;
GSimpleAction *action;
priv=self->priv=XFDASHBOARD_APPLICATION_GET_PRIVATE(self);
/* Set default values */
priv->isDaemon=FALSE;
priv->isSuspended=FALSE;
priv->themeName=NULL;
priv->inited=FALSE;
priv->xfconfChannel=NULL;
priv->viewManager=NULL;
priv->searchManager=NULL;
priv->focusManager=NULL;
priv->theme=NULL;
priv->xfconfThemeChangedSignalID=0L;
priv->isQuitting=FALSE;
priv->sessionManagementClient=NULL;
/* Add callable DBUS actions for this application */
action=g_simple_action_new("Quit", NULL);
g_signal_connect(action, "activate", G_CALLBACK(xfdashboard_application_quit_forced), NULL);
g_action_map_add_action(G_ACTION_MAP(self), G_ACTION(action));
g_object_unref(action);
}