本文整理汇总了C++中G_ACTION_MAP函数的典型用法代码示例。如果您正苦于以下问题:C++ G_ACTION_MAP函数的具体用法?C++ G_ACTION_MAP怎么用?C++ G_ACTION_MAP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_ACTION_MAP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: photos_main_window_constructed
static void
photos_main_window_constructed (GObject *object)
{
PhotosMainWindow *self = PHOTOS_MAIN_WINDOW (object);
GApplication *app;
G_OBJECT_CLASS (photos_main_window_parent_class)->constructed (object);
/* HACK: Since GtkWindow:application is a non-construct property it
* will be set after constructed has finished. We explicitly add
* the window to the application here before creating the rest of
* the widget hierarchy. This ensures that we can use
* photos_application_get_scale_factor while constructing the
* widgets.
*/
app = g_application_get_default ();
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (self));
self->edit_cancel = g_action_map_lookup_action (G_ACTION_MAP (app), "edit-cancel");
self->import_cancel = g_action_map_lookup_action (G_ACTION_MAP (app), "import-cancel");
self->load_next = g_action_map_lookup_action (G_ACTION_MAP (app), "load-next");
self->load_previous = g_action_map_lookup_action (G_ACTION_MAP (app), "load-previous");
gtk_widget_init_template (GTK_WIDGET (self));
}
示例2: main
int
main (int argc, char *argv[])
{
GtkApplication *app;
GSettings *settings;
GAction *action;
gtk_init (NULL, NULL);
app = gtk_application_new ("org.gtk.Demo2", 0);
settings = g_settings_new ("org.gtk.Demo");
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
action = g_settings_create_action (settings, "color");
g_action_map_add_action (G_ACTION_MAP (app), action);
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_application_run (G_APPLICATION (app), 0, NULL);
return 0;
}
示例3: _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));
}
示例4: 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;
}
示例5: 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);
}
示例6: eog_application_init_app_menu
static void
eog_application_init_app_menu (EogApplication *application)
{
EogApplicationPrivate *priv = application->priv;
GtkBuilder *builder;
GError *error = NULL;
GAction *action;
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_entries, G_N_ELEMENTS (app_entries),
application);
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, EOG_DATA_DIR"/eog-app-menu.xml", &error);
if (error == NULL) {
gtk_application_set_app_menu (GTK_APPLICATION (application),
G_MENU_MODEL (gtk_builder_get_object (builder,
"app-menu")));
} else {
g_critical ("Unable to add the application menu: %s\n", error->message);
g_error_free (error);
}
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"view-gallery");
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_IMAGE_GALLERY, action,
"state", G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
_settings_map_set_variant,
NULL, NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"toolbar");
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_TOOLBAR, action, "state",
G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
_settings_map_set_variant,
NULL, NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"view-sidebar");
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_SIDEBAR, action, "state",
G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
_settings_map_set_variant,
NULL, NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (application),
"view-statusbar");
g_settings_bind_with_mapping (priv->ui_settings,
EOG_CONF_UI_STATUSBAR, action, "state",
G_SETTINGS_BIND_DEFAULT,
_settings_map_get_bool_variant,
_settings_map_set_variant,
NULL, NULL);
g_object_unref (builder);
}
示例7: toggle_italic
static void
toggle_italic (GtkToggleButton *button, gpointer data)
{
GMenuModel *model;
GActionGroup *group;
GSimpleAction *action;
gboolean adding;
GMenuModel *m;
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, g_menu_model_get_n_items (model) - 1, G_MENU_LINK_SECTION);
if (adding)
{
action = g_simple_action_new_stateful ("italic", NULL, g_variant_new_boolean (FALSE));
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
g_signal_connect (action, "activate", G_CALLBACK (activate_toggle), NULL);
g_object_unref (action);
action_list_add (store, "italic");
g_menu_insert (G_MENU (m), 1, "Italic", "italic");
}
else
{
g_action_map_remove_action (G_ACTION_MAP (group), "italic");
action_list_remove (store, "italic");
g_menu_remove (G_MENU (m), 1);
}
}
示例8: change_interval
static gboolean
change_interval (gpointer user_data)
{
g_message ("change interval");
IndicatorTestService *indicator = user_data;
GAction* action_switch = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.switch");
actual_switch(G_SIMPLE_ACTION(action_switch));
GAction* action_checkbox = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.checkbox");
actual_switch(G_SIMPLE_ACTION(action_checkbox));
GAction* action_accessPoint = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.accessPoint");
actual_switch(G_SIMPLE_ACTION(action_accessPoint));
GAction* action_slider = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.slider");
static double old_value = 0.25;
double new_value = old_value == 0.25 ? 0.75 : 0.25;
old_value = new_value;
Action* slide_action = malloc(sizeof(Action));
slide_action->action = G_SIMPLE_ACTION(action_slider);
slide_action->value = g_variant_new_double(new_value);
actual_slide(slide_action);
return TRUE;
}
示例9: photos_preview_nav_buttons_init
static void
photos_preview_nav_buttons_init (PhotosPreviewNavButtons *self)
{
GAction *action;
GApplication *app;
PhotosSearchContextState *state;
app = g_application_get_default ();
state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
self->load_next = g_action_map_lookup_action (G_ACTION_MAP (app), "load-next");
g_signal_connect_object (self->load_next,
"activate",
G_CALLBACK (photos_preview_nav_buttons_next),
self,
G_CONNECT_SWAPPED);
self->load_previous = g_action_map_lookup_action (G_ACTION_MAP (app), "load-previous");
g_signal_connect_object (self->load_previous,
"activate",
G_CALLBACK (photos_preview_nav_buttons_previous),
self,
G_CONNECT_SWAPPED);
self->item_mngr = g_object_ref (state->item_mngr);
self->mode_cntrlr = g_object_ref (state->mode_cntrlr);
action = g_action_map_lookup_action (G_ACTION_MAP (app), "delete");
g_signal_connect_object (action,
"activate",
G_CALLBACK (photos_preview_nav_buttons_delete),
self,
G_CONNECT_SWAPPED);
}
示例10: on_menu_changed
void on_menu_changed(gpointer instance, GVariant *parameters, gpointer user_data)
{
WorkraveApplet *applet = WORKRAVE_APPLET(user_data);
GVariantIter *iter;
g_variant_get (parameters, "(a(sii))", &iter);
char *text;
int id;
int flags;
gboolean visible[sizeof(menu_data)/sizeof(struct Menuitems)];
for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++)
{
visible[i] = menu_data[i].visible_when_not_running;
}
while (g_variant_iter_loop(iter, "(sii)", &text, &id, &flags))
{
int index = lookup_menu_index_by_id((enum MenuCommand)id);
if (index == -1)
{
continue;
}
GAction *action = g_action_map_lookup_action(G_ACTION_MAP(applet->priv->action_group), menu_data[index].action);
if (flags & MENU_ITEM_FLAG_SUBMENU_END ||
flags & MENU_ITEM_FLAG_SUBMENU_BEGIN)
{
continue;
}
visible[index] = TRUE;
if (g_action_get_state_type(G_ACTION(action)) != NULL)
{
if (menu_data[index].state == NULL)
{
g_simple_action_set_state(G_SIMPLE_ACTION(action), g_variant_new_boolean(flags & MENU_ITEM_FLAG_ACTIVE));
}
else
{
if (flags & MENU_ITEM_FLAG_ACTIVE)
{
g_simple_action_set_state(G_SIMPLE_ACTION(action), g_variant_new_string(menu_data[index].state));
}
}
}
}
g_variant_iter_free (iter);
for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++)
{
GAction *action = g_action_map_lookup_action(G_ACTION_MAP(applet->priv->action_group), menu_data[i].action);
g_simple_action_set_enabled(G_SIMPLE_ACTION(action), visible[i]);
}
}
示例11: update_ui
static void
update_ui (GeditSpellPlugin *plugin)
{
GeditSpellPluginPrivate *priv;
GeditView *view;
GAction *check_spell_action;
GAction *config_spell_action;
GAction *auto_spell_action;
gedit_debug (DEBUG_PLUGINS);
priv = plugin->priv;
view = gedit_window_get_active_view (priv->window);
check_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
"check-spell");
g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
(view != NULL) &&
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
config_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
"config-spell");
g_simple_action_set_enabled (G_SIMPLE_ACTION (config_spell_action),
(view != NULL) &&
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
auto_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window),
"auto-spell");
g_simple_action_set_enabled (G_SIMPLE_ACTION (auto_spell_action),
(view != NULL) &&
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
if (view != NULL)
{
GeditDocument *doc;
GeditTab *tab;
GeditTabState state;
gboolean autospell;
doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
tab = gedit_window_get_active_tab (priv->window);
state = gedit_tab_get_state (tab);
autospell = (doc != NULL &&
gedit_automatic_spell_checker_get_from_document (doc) != NULL);
/* If the document is loading we can't get the metadata so we
endup with an useless speller */
if (state == GEDIT_TAB_STATE_NORMAL)
{
g_action_change_state (auto_spell_action, g_variant_new_boolean (autospell));
}
g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action),
gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc)) > 0);
}
}
示例12: 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);
}
}
示例13: 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));
}
示例14: gt_win_init
static void
gt_win_init(GtWin* self)
{
GtWinPrivate* priv = gt_win_get_instance_private(self);
GPropertyAction* action;
GT_TYPE_PLAYER; // Hack to load GtPlayer into the symbols table
GT_TYPE_PLAYER_HEADER_BAR;
GT_TYPE_BROWSE_HEADER_BAR;
GT_TYPE_CHANNELS_VIEW;
GT_TYPE_GAMES_VIEW;
GT_TYPE_FOLLOWS_VIEW;
GT_TYPE_CHAT;
gtk_window_set_application(GTK_WINDOW(self), GTK_APPLICATION(main_app));
gtk_widget_init_template(GTK_WIDGET(self));
gtk_widget_realize(priv->player_header_bar);
priv->cur_info_data = NULL;
priv->info_queue = g_queue_new();
gtk_window_set_default_size(GTK_WINDOW(self),
g_settings_get_int(main_app->settings, "window-width"),
g_settings_get_int(main_app->settings, "window-height"));
gtk_window_set_default_icon_name("gnome-twitch");
g_object_bind_property(priv->browse_stack, "visible-child",
self, "visible-view",
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
GdkScreen* screen = gdk_screen_get_default();
GtkCssProvider* css = gtk_css_provider_new();
gtk_css_provider_load_from_resource(css, "/com/vinszent/GnomeTwitch/com.vinszent.GnomeTwitch.style.css");
gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_signal_connect_after(self, "key-press-event", G_CALLBACK(key_press_cb), self);
g_signal_connect(self, "delete-event", G_CALLBACK(delete_cb), self);
g_signal_connect_after(priv->info_bar, "response", G_CALLBACK(close_info_bar_cb), self);
g_action_map_add_action_entries(G_ACTION_MAP(self),
win_actions,
G_N_ELEMENTS(win_actions),
self);
action = g_property_action_new("toggle_fullscreen", self, "fullscreen");
g_action_map_add_action(G_ACTION_MAP(self),
G_ACTION(action));
g_object_unref(action);
GtkWindowGroup* window_group = gtk_window_group_new();
gtk_window_group_add_window(window_group, GTK_WINDOW(self));
g_object_unref(window_group);
}
示例15: irc_context_get_action_group
/**
* irc_context_get_action_group:
*
* Returns: (transfer full): Valid actions for this context
*/
GActionGroup *
irc_context_get_action_group (void)
{
GSimpleActionGroup *group = g_simple_action_group_new ();
GAction *close_action = irc_context_action_new ("close", irc_context_close);
GAction *focus_action = irc_context_action_new ("focus", irc_context_focus);
g_action_map_add_action (G_ACTION_MAP (group), close_action);
g_action_map_add_action (G_ACTION_MAP (group), focus_action);
return G_ACTION_GROUP (group);
}