本文整理匯總了C++中GTK_APPLICATION函數的典型用法代碼示例。如果您正苦於以下問題:C++ GTK_APPLICATION函數的具體用法?C++ GTK_APPLICATION怎麽用?C++ GTK_APPLICATION使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GTK_APPLICATION函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: initialize_app_menubar
void
initialize_app_menubar (GApplication *application)
{
GtkBuilder *builder;
GSettings *settings;
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_menu_entries,
G_N_ELEMENTS (app_menu_entries),
application);
builder = _gtk_builder_new_from_resource ("app-menubar.ui");
gtk_application_set_menubar (GTK_APPLICATION (application),
G_MENU_MODEL (gtk_builder_get_object (builder, "app-menubar")));
g_object_unref (builder);
settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI);
g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR),
g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR)));
settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING);
g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE),
g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE,
g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick));
g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI),
"changed::" PREF_UI_VIEW_SIDEBAR,
G_CALLBACK (pref_view_sidebar_changed),
application);
g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING),
"changed::" PREF_LISTING_LIST_MODE,
G_CALLBACK (pref_list_mode_changed),
application);
}
示例2: gw_application_set_win_menubar
void
gw_application_set_win_menubar (GwApplication *application, GMenuModel *menumodel)
{
//Sanity checks
g_return_if_fail (application != NULL);
g_return_if_fail (menumodel != NULL);
if (g_menu_model_get_n_items (menumodel) == 0) return;
//Declarations
GMenuModel *menubar;
gint length;
//Initializations
menubar = gtk_application_get_menubar (GTK_APPLICATION (application));
g_return_if_fail (menubar != NULL);
length = g_menu_model_get_n_items (menubar);
//Clear the menubar
while (length-- > 0) g_menu_remove (G_MENU (menubar), 0);
//Add the menuitem linking the menus
{
GMenuItem *menuitem = g_menu_item_new_section (NULL, menumodel);
if (menuitem != NULL)
{
g_menu_append_item (G_MENU (menubar), menuitem);
g_object_unref (menuitem); menuitem = NULL;
}
gw_application_add_accelerators (application, menubar);
}
}
示例3: gw_application_load_menubar
static void
gw_application_load_menubar (GwApplication *application)
{
GMenuModel *menumodel;
menumodel = G_MENU_MODEL (g_menu_new ());
gtk_application_set_menubar (GTK_APPLICATION (application), menumodel);
}
示例4: trg_gtk_app_command_line
static int
trg_gtk_app_command_line(GApplication * application,
GApplicationCommandLine * cmdline)
{
GList *windows =
gtk_application_get_windows(GTK_APPLICATION(application));
TrgMainWindow *window;
gchar **argv;
if (!windows || !windows->data)
return 1;
window = TRG_MAIN_WINDOW(windows->data);
argv = g_application_command_line_get_arguments(cmdline, NULL);
if (g_application_command_line_get_is_remote(cmdline)) {
if (!argv[0]) {
gtk_window_present(GTK_WINDOW(window));
g_strfreev(argv);
} else {
return trg_add_from_filename(window, argv);
}
} else {
trg_main_window_set_start_args(window, argv);
auto_connect_if_required(TRG_MAIN_WINDOW(windows->data));
}
return 0;
}
示例5: get_network_available
static void
get_network_available (GNetworkMonitor *monitor,
gboolean available,
GeditApp *app)
{
gboolean enable;
GList *windows, *w;
enable = g_network_monitor_get_network_available (monitor);
windows = gtk_application_get_windows (GTK_APPLICATION (app));
for (w = windows; w != NULL; w = w->next)
{
GeditWindow *window = GEDIT_WINDOW (w->data);
if (GEDIT_IS_WINDOW (window))
{
GList *tabs, *t;
tabs = _gedit_window_get_all_tabs (window);
for (t = tabs; t != NULL; t = t->next)
{
_gedit_tab_set_network_available (GEDIT_TAB (t->data),
enable);
}
g_list_free (tabs);
}
}
}
示例6: openoffice_missing_unoconv
static void
openoffice_missing_unoconv (NemoPreviewPdfLoader *self)
{
GApplication *app = g_application_get_default ();
GtkWidget *widget = GTK_WIDGET (gtk_application_get_active_window (GTK_APPLICATION (app)));
GDBusConnection *connection = g_application_get_dbus_connection (app);
guint xid = 0;
GdkWindow *gdk_window;
const gchar *unoconv_path[2];
gdk_window = gtk_widget_get_window (widget);
if (gdk_window != NULL)
xid = GDK_WINDOW_XID (gdk_window);
unoconv_path[0] = "/usr/bin/unoconv";
unoconv_path[1] = NULL;
g_dbus_connection_call (connection,
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit.Modify",
"InstallProvideFiles",
g_variant_new ("(u^ass)",
xid,
unoconv_path,
"hide-confirm-deps"),
NULL, G_DBUS_CALL_FLAGS_NONE,
G_MAXINT, NULL,
openoffice_missing_unoconv_ready_cb,
self);
}
示例7: activate_wizard
static void
activate_wizard(GApplication *app,
gpointer user_data)
{
create_assistant(GTK_APPLICATION(app), *(int *)user_data);
update_gui_state_from_problem_data(UPDATE_SELECTED_EVENT);
}
示例8: maybe_open_with_existing_workspace
static gboolean
maybe_open_with_existing_workspace (IdeApplication *self,
GFile *file,
const gchar *hint,
GCancellable *cancellable)
{
GList *windows;
GList *iter;
g_assert (IDE_IS_APPLICATION (self));
g_assert (G_IS_FILE (file));
windows = gtk_application_get_windows (GTK_APPLICATION (self));
for (iter = windows; iter != NULL; iter = iter->next)
{
GtkWindow *window = iter->data;
if (IDE_IS_WORKBENCH (window) &&
workbench_manages_file (IDE_WORKBENCH (window), file))
{
ide_workbench_open_files_async (IDE_WORKBENCH (window),
&file,
1,
hint,
0,
cancellable,
NULL,
NULL);
return TRUE;
}
}
return FALSE;
}
示例9: startup
/* Startup function for the menu we are creating in this sample */
static void
startup (GApplication *app,
gpointer user_data)
{
GMenu *menu;
GSimpleAction *quit_action;
/* Initialize the GMenu, and add a menu item with label "About" and action
* "win.about". Also add another menu item with label "Quit" and action
* "app.quit"
*/
menu = g_menu_new ();
g_menu_append (menu, "About", "win.about");
g_menu_append (menu, "Quit", "app.quit");
/* Create a new simple action for the application. (In this case it is the
* "quit" action.
*/
quit_action = g_simple_action_new ("quit", NULL);
/* Ensure that the menu we have just created is set for the overall application */
gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (menu));
g_signal_connect (quit_action,
"activate",
G_CALLBACK (quit_cb),
app);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (quit_action));
}
示例10: XPLAYER_SCREENSAVER_PLUGIN
static void
impl_deactivate (PeasActivatable *plugin)
{
XplayerScreensaverPlugin *pi = XPLAYER_SCREENSAVER_PLUGIN (plugin);
g_object_unref (pi->priv->settings);
if (pi->priv->handler_id_playing != 0) {
XplayerObject *xplayer;
xplayer = g_object_get_data (G_OBJECT (plugin), "object");
g_signal_handler_disconnect (G_OBJECT (xplayer), pi->priv->handler_id_playing);
pi->priv->handler_id_playing = 0;
}
if (pi->priv->handler_id_metadata != 0) {
g_signal_handler_disconnect (G_OBJECT (pi->priv->bvw), pi->priv->handler_id_metadata);
pi->priv->handler_id_metadata = 0;
}
if (pi->priv->inhibit_cookie != 0) {
gtk_application_uninhibit (GTK_APPLICATION (pi->priv->xplayer), pi->priv->inhibit_cookie);
pi->priv->inhibit_cookie = 0;
}
g_object_unref (pi->priv->xplayer);
g_object_unref (pi->priv->bvw);
}
示例11: gw_window_constructed
static void
gw_window_constructed (GObject *object)
{
GwWindow *window;
GwWindowPrivate *priv;
gboolean os_shows_app_menu;
GtkSettings *settings;
//Chain the parent class
{
G_OBJECT_CLASS (gw_window_parent_class)->constructed (object);
}
window = GW_WINDOW (object);
priv = window->priv;
settings = gtk_settings_get_default ();
g_object_get (settings, "gtk-shell-shows-app-menu", &os_shows_app_menu, NULL);
gtk_widget_add_events (GTK_WIDGET (window), GDK_FOCUS_CHANGE_MASK);
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);
priv->accelgroup = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), priv->accelgroup);
gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (priv->application));
priv->builder = gtk_builder_new ();
gw_window_load_ui_xml (window, priv->ui_xml);
priv->toplevel = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "toplevel"));
g_signal_connect (G_OBJECT (window), "configure-event", G_CALLBACK (gw_window_configure_event_cb), NULL);
g_signal_connect (window, "focus-in-event", G_CALLBACK (gw_window_focus_in_event_cb), NULL);
}
示例12: refimpl_app_startup
static void refimpl_app_startup(GApplication* application) {
RefImplApp* app = REFIMPL_APP(application);
G_APPLICATION_CLASS(refimpl_app_parent_class)->startup(application);
g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app);
if (refimpl_app_has_app_menu(app)) {
GtkBuilder* builder;
GError* error = NULL;
builder = gtk_builder_new();
if (!gtk_builder_add_from_resource(builder,
"/com/bobtacoindustries/N3888_RefImpl/refimpl_menu.ui",
&error)) {
g_warning("Loading menu builder file failed. Message: %s", error->message);
g_error_free(error);
}
else {
GMenuModel* appMenu;
appMenu = G_MENU_MODEL(gtk_builder_get_object(builder, "app_menu"));
gtk_application_set_app_menu(GTK_APPLICATION(application), appMenu);
}
g_object_unref(builder);
}
//setup_accelerators(app);
}
示例13: shell_action_new_window_cb
static void
shell_action_new_window_cb (GSimpleAction *action,
GVariant *parameter,
EShell *shell)
{
GtkApplication *application;
GList *list;
const gchar *view_name;
application = GTK_APPLICATION (shell);
list = gtk_application_get_windows (application);
view_name = g_variant_get_string (parameter, NULL);
/* Present the first EShellWindow showing 'view_name'. */
while (list != NULL) {
GtkWindow *window = GTK_WINDOW (list->data);
if (E_IS_SHELL_WINDOW (window)) {
const gchar *active_view;
active_view = e_shell_window_get_active_view (
E_SHELL_WINDOW (window));
if (g_strcmp0 (active_view, view_name) == 0) {
gtk_window_present (window);
return;
}
}
list = g_list_next (list);
}
/* No suitable EShellWindow found, so create one. */
e_shell_create_shell_window (shell, view_name);
}
示例14: bmd_activate
/************************************************************ APP Main Window */
static void
bmd_activate (GtkApplication *app, gpointer data)
{
bmd_widgets *a = (bmd_widgets *) data;
/* create a window with title, default size, icon and a box container */
a->window = gtk_application_window_new (app);
gtk_window_set_application (GTK_WINDOW (a->window), GTK_APPLICATION (app));
gtk_window_set_position (GTK_WINDOW (a->window), GTK_WIN_POS_CENTER);
gtk_window_set_title (GTK_WINDOW (a->window), "Book Management Demo");
gtk_window_set_default_size (GTK_WINDOW (a->window), XSIZE, YSIZE);
gtk_window_set_default_icon_from_file ("bmd_icon.png", NULL);
a->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (a->window), a->box);
/* moved the creation of the menu to a dedicated function */
bmd_construct_menu (app, (gpointer) a);
a->paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (a->box), a->paned, TRUE, TRUE, 0);
bmd_construct_editablecells (app, (gpointer) a);
bmd_construct_imagedemo (app, (gpointer) a);
gtk_widget_show_all (GTK_WIDGET (a->window));
}
示例15: terminal_app_startup
static void
terminal_app_startup (GApplication *application)
{
const GActionEntry app_menu_actions[] = {
{ "preferences", app_menu_preferences_cb, NULL, NULL, NULL },
{ "help", app_menu_help_cb, NULL, NULL, NULL },
{ "about", app_menu_about_cb, NULL, NULL, NULL },
{ "quit", app_menu_quit_cb, NULL, NULL, NULL }
};
gs_unref_object GtkBuilder *builder;
GError *error = NULL;
G_APPLICATION_CLASS (terminal_app_parent_class)->startup (application);
/* Need to set the WM class (bug #685742) */
gdk_set_program_class("Gnome-terminal");
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_menu_actions, G_N_ELEMENTS (app_menu_actions),
application);
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder,
TERMINAL_RESOURCES_PATH_PREFIX "ui/terminal-appmenu.ui",
&error);
g_assert_no_error (error);
gtk_application_set_app_menu (GTK_APPLICATION (application),
G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")));
_terminal_debug_print (TERMINAL_DEBUG_SERVER, "Startup complete\n");
}