本文整理汇总了C++中G_ACTION_MAP函数的典型用法代码示例。如果您正苦于以下问题:C++ G_ACTION_MAP函数的具体用法?C++ G_ACTION_MAP怎么用?C++ G_ACTION_MAP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_ACTION_MAP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:GNOME,项目名称:gnome-photos,代码行数:25,代码来源:photos-main-window.c
示例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;
}
开发者ID:Therzok,项目名称:gtk,代码行数:27,代码来源:application.c
示例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));
}
开发者ID:bpepple,项目名称:brio,代码行数:25,代码来源:brio-application.c
示例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;
}
开发者ID:happytcj,项目名称:cainteoir-gtk,代码行数:25,代码来源:reader_window.cpp
示例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);
}
开发者ID:Dagal,项目名称:gnome-builder,代码行数:31,代码来源:gb-project-tree-actions.c
示例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);
}
开发者ID:DOICHE,项目名称:eog,代码行数:60,代码来源:eog-application.c
示例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);
}
}
开发者ID:3v1n0,项目名称:gtk,代码行数:35,代码来源:testgmenu.c
示例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;
}
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:27,代码来源:mock-indicator-service.c
示例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);
}
开发者ID:kleopatra999,项目名称:gnome-photos,代码行数:34,代码来源:photos-preview-nav-buttons.c
示例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]);
}
}
开发者ID:183amir,项目名称:workrave,代码行数:59,代码来源:WorkraveApplet.c
示例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);
}
}
开发者ID:AqibAhmedJ,项目名称:gedit,代码行数:57,代码来源:gedit-spell-plugin.c
示例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);
}
}
开发者ID:Avinashkumarsharma,项目名称:totem,代码行数:57,代码来源:totem-disc-recorder.c
示例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));
}
开发者ID:ChrisCummins,项目名称:gnome-control-center,代码行数:56,代码来源:cc-application.c
示例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);
}
开发者ID:AlejandroC90,项目名称:gnome-twitch,代码行数:56,代码来源:gt-win.c
示例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);
}
开发者ID:TingPing,项目名称:irc-client,代码行数:15,代码来源:irc-context.c
示例16: activate
static void
activate (GApplication *app,
gpointer user_data)
{
GtkWidget *win;
GtkWidget *button;
GSimpleActionGroup *doc_actions;
GtkBuilder *builder;
GMenuModel *doc_menu;
GMenuModel *win_menu;
GMenu *button_menu;
GMenuItem *section;
if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL)
return;
win = gtk_application_window_new (GTK_APPLICATION (app));
doc_actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win);
g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries,
G_N_ELEMENTS (win_entries), win);
builder = gtk_builder_new ();
gtk_builder_add_from_string (builder, menu_ui, -1, NULL);
doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu"));
win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu"));
button_menu = g_menu_new ();
section = g_menu_item_new_section (NULL, doc_menu);
g_menu_item_set_attribute (section, "action-namespace", "s", "doc");
g_menu_append_item (button_menu, section);
g_object_unref (section);
section = g_menu_item_new_section (NULL, win_menu);
g_menu_item_set_attribute (section, "action-namespace", "s", "win");
g_menu_append_item (button_menu, section);
g_object_unref (section);
button = gtk_menu_button_new ();
gtk_button_set_label (GTK_BUTTON (button), "Menu");
gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions));
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu));
gtk_container_add (GTK_CONTAINER (win), button);
gtk_container_set_border_width (GTK_CONTAINER (win), 12);
gtk_widget_show_all (win);
g_object_unref (button_menu);
g_object_unref (doc_actions);
g_object_unref (builder);
}
开发者ID:Davletvm,项目名称:gtk,代码行数:55,代码来源:action-namespace.c
示例17: enable_win_actions
static void
enable_win_actions (PtWindow *win,
gboolean state)
{
GAction *action;
action = g_action_map_lookup_action (G_ACTION_MAP (win), "copy");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);
action = g_action_map_lookup_action (G_ACTION_MAP (win), "goto");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);
}
开发者ID:gkarsay,项目名称:parlatype,代码行数:12,代码来源:pt-window.c
示例18: example_app_window_init
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
GtkBuilder *builder;
GMenuModel *menu;
GAction *action;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("com.lonelycactus.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "show-words",
priv->sidebar, "reveal-child",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property (priv->search, "active",
priv->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
g_signal_connect (priv->connect, "toggled",
G_CALLBACK (toggle_server), win);
g_signal_connect (priv->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
builder = gtk_builder_new_from_resource ("/com/lonelycactus/exampleapp/gears-menu.ui");
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
g_object_unref (builder);
action = g_settings_create_action (priv->settings, "show-words");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
g_object_bind_property (priv->lines, "visible",
priv->lines_label, "visible",
G_BINDING_DEFAULT);
service_init();
service_start_accepting_new_connections();
g_object_set (gtk_settings_get_default (), "gtk-shell-shows-app-menu", FALSE, NULL);
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (win), TRUE);
}
开发者ID:spk121,项目名称:jozabad,代码行数:53,代码来源:exampleappwin.c
示例19: impl_activate
static void
impl_activate (EogWindowActivatable *activatable)
{
const gchar * const accel_keys[] = { "W", NULL };
EogFitToWidthPlugin *plugin = EOG_FIT_TO_WIDTH_PLUGIN (activatable);
GMenu *model, *menu;
GMenuItem *item;
GSimpleAction *action;
GAction *ref_action;
model= eog_window_get_gear_menu_section (plugin->window,
"plugins-section");
g_return_if_fail (G_IS_MENU (model));
/* Setup and inject action */
action = g_simple_action_new (EOG_FIT_TO_WIDTH_PLUGIN_ACTION, NULL);
g_signal_connect(action, "activate",
G_CALLBACK (fit_to_width_cb), plugin->window);
g_action_map_add_action (G_ACTION_MAP (plugin->window),
G_ACTION (action));
/* Bind to the zoom-normal action's enabled property to only enable
* fit-to-width zooming if zooming is generally enabled */
ref_action = g_action_map_lookup_action (G_ACTION_MAP (plugin->window),
"zoom-normal");
if (ref_action)
g_object_bind_property (ref_action, "enabled",
action, "enabled",
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_unref (action);
/* Append entry to the window's gear menu */
menu = g_menu_new ();
g_menu_append (menu, _("Fit to width"),
"win." EOG_FIT_TO_WIDTH_PLUGIN_ACTION);
item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
g_menu_item_set_attribute (item, "id",
"s", EOG_FIT_TO_WIDTH_PLUGIN_MENU_ID);
g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
"s", "zoom-fit-best-symbolic");
g_menu_append_item (model, item);
g_object_unref (item);
g_object_unref (menu);
/* Define accelerator keys */
gtk_application_set_accels_for_action (GTK_APPLICATION (EOG_APP),
"win." EOG_FIT_TO_WIDTH_PLUGIN_ACTION,
accel_keys);
}
开发者ID:GNOME,项目名称:eog-plugins,代码行数:52,代码来源:eog-fit-to-width-plugin.c
示例20: 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);
}
}
开发者ID:3v1n0,项目名称:gtk,代码行数:51,代码来源:testgmenu.c
注:本文中的G_ACTION_MAP函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论