int main (int argc, char *argv[]) { GOptionContext* context; GError *error = NULL; ihm_trick_t *ihm_setup; mtrace(); ihm_setup=malloc(sizeof(ihm_trick_t)); memset(ihm_setup,0,sizeof(ihm_trick_t)); context = g_option_context_new ( _("Gbridge GTK game") ); if(context) { //g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, entries, "gbridge"); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); g_free(context); create_config(); verifie_config(); create_ihm(ihm_setup); //gtk_init (&argc, &argv); if (ihm_setup->Fenetre != NULL ) { gtk_widget_show_all(ihm_setup->Fenetre); gtk_main (); } } return (0); }
static void parse_args (int *argc, char ***argv) { GError *error; GOptionContext *context; cinnamon_settings_profile_start (NULL); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_get_option_group (FALSE)); error = NULL; if (!g_option_context_parse (context, argc, argv, &error)) { if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); } else { g_warning ("Unable to initialize GTK+"); } exit (EXIT_FAILURE); } g_option_context_free (context); cinnamon_settings_profile_end (NULL); if (debug) g_setenv ("G_MESSAGES_DEBUG", "all", FALSE); }
static gboolean parse_options (App* app, gint* argc, gchar*** argv) { GError* error = NULL; GOptionContext* context; context = g_option_context_new ("- YouTube Viewer"); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, argc, argv, &error)) { g_print ("option parsing failed: %s\n", error->message); return FALSE; } if (horizontal == TRUE) { app->orientation = YTV_ORIENTATION_HORIZONTAL; } else if (vertical == TRUE) { app->orientation = YTV_ORIENTATION_VERTICAL; } g_option_context_free (context); return TRUE; }
static void _parse_cmd_args (int *argc, char ***argv) { ol_log_func (); GError *error = NULL; GOptionContext *context; context = g_option_context_new ("- Display your lyrics"); g_option_context_add_main_entries (context, cmdargs, PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, argc, argv, &error)) { ol_errorf ("option parsing failed: %s\n", error->message); } if (debug_level != NULL) { if (strcmp (debug_level, "none") == 0) ol_log_set_level (OL_LOG_NONE); else if (strcmp (debug_level, "error") == 0) ol_log_set_level (OL_ERROR); else if (strcmp (debug_level, "debug") == 0) ol_log_set_level (OL_DEBUG); else if (strcmp (debug_level, "info") == 0) ol_log_set_level (OL_INFO); g_free (debug_level); } }
static GOptionContext * gth_application_create_option_context (void) { GOptionContext *context; static gsize initialized = FALSE; context = g_option_context_new (N_("— Image browser and viewer")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_set_ignore_unknown_options (context, TRUE); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); if (g_once_init_enter (&initialized)) { g_option_context_add_group (context, gtk_get_option_group (TRUE)); #ifdef HAVE_CLUTTER g_option_context_add_group (context, clutter_get_option_group_without_init ()); g_option_context_add_group (context, gtk_clutter_get_option_group ()); #endif #ifdef HAVE_GSTREAMER g_option_context_add_group (context, gst_init_get_option_group ()); #endif g_once_init_leave (&initialized, TRUE); } return context; }
/** * ppg_runtime_init: * @argc: (inout): A pointer to the programs argc. * @argv: (inout): A pointer to the programs argv. * * Initialize the runtime system for the profiler gui. * * Returns: %TRUE if successful; otherwise %FALSE and the program should exit. * Side effects: Everything. */ gboolean ppg_runtime_init (gint *argc, gchar ***argv) { GOptionContext *context; GError *error = NULL; context = g_option_context_new(_("- " PRODUCT_NAME)); g_option_context_add_main_entries(context, option_entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_add_group(context, ppg_prefs_get_option_group()); if (!g_option_context_parse(context, argc, argv, &error)) { g_printerr("%s\n", error->message); g_error_free(error); return FALSE; } ppg_log_init(use_stdount, log_filename); ppg_monitor_init(); ppg_paths_init(); ppg_prefs_init(); ppg_color_init(); gtk_window_set_default_icon(LOAD_INLINE_PIXBUF(perfkit_pixbuf)); gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), ppg_paths_get_icon_dir()); ppg_instruments_init(); ppg_actions_init(); return TRUE; }
int main(int argc, char **argv) { gchar *backend = NULL; gchar *backend_opt = NULL; gchar *majacd_app = NULL; GOptionEntry entries[] = { {"backend", 'b', 0, G_OPTION_ARG_STRING, &backend_opt, "Path to majacd application", "<path>"}, {NULL} }; GError *err = NULL; GOptionContext *context; GtkWidget *err_dialog; context = g_option_context_new("- system tray icon to " "control the majacd application"); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_add_main_entries(context, entries, NULL); g_option_context_parse(context, &argc, &argv, &err); g_option_context_free(context); if (backend_opt) { backend = g_strdup(backend_opt); } else { backend = g_strdup(MAJACD_APP); } gtk_init(&argc, &argv); if (!(majacd_app = g_find_program_in_path(backend))) { err_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not locate the majacd application"); gtk_window_set_title(GTK_WINDOW(err_dialog), "Error"); gtk_dialog_run(GTK_DIALOG(err_dialog)); gtk_widget_destroy(err_dialog); g_error("Could not locate the majacd application\n"); /* NOT REACHED */ return EXIT_FAILURE; } if (backend_ctl_command(CMD_INIT, (gpointer) majacd_app) < 0) { g_error("Error starting %s", majacd_app); } main_window_create(); main_window_hide(); tray_icon_create(); gtk_main(); g_free(backend); g_free(majacd_app); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; context = g_option_context_new("- spice-vdagent " VERSION); g_option_context_add_main_entries(context, options, NULL); g_option_context_add_group(context, gtk_get_option_group (TRUE)); if (!g_option_context_parse(context, &argc, &argv, &error)) { g_print("option parsing failed: %s\n", error->message); exit(1); } gsyslog_install("spice-vdagent"); { struct sigaction act = { .sa_flags = SA_RESTART, .sa_handler = quit_handler }; sigaction(SIGINT, &act, NULL); sigaction(SIGTERM, &act, NULL); sigaction(SIGQUIT, &act, NULL); } while (!quit) { if (version_mismatch) { g_warning("Version mismatch, restarting"); sleep(1); execvp(argv[0], argv); } run_agent(); } return 0; }
void gui_libs_init (GOptionContext *context) { g_return_if_fail (context != NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); }
int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; ENTER; gtk_set_locale(); context = g_option_context_new("- X11 keyboard switcher"); g_option_context_add_main_entries(context, entries, NULL); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_set_description(context, desription); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("%s\n", error->message); exit(1); } gtk_init(&argc, &argv); if (argc > 1) { g_print("Unknown option %s.\nRun '%s --help' for description\n", argv[1], g_get_prgname()); exit(1); } if (display_version) { printf("%s %s\n", g_get_prgname(), VERSION); exit(0); } init(); create_all(); gtk_main(); RET(0); }
int main(int argc, char *argv[]) { setlocale(LC_ALL, ""); MarmiteConfig *cfg = marmite_config(argc, argv, gtk_get_option_group(TRUE)); if (!cfg) return 64; GtkWindow *window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); gtk_window_set_title(window, cfg->title); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); MarmiteHooks hooks = { .data = window, .set_title = (void*)gtk_window_set_title, .all_done = (void*)gtk_window_close, }; GObject *vte = marmite_vte(cfg, &hooks); if (!vte) return 70; gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(vte)); gtk_widget_show_all(GTK_WIDGET(window)); gtk_main(); return 0; }
static gboolean parse_arguments (int *argc, char ***argv) { GOptionContext *context; GOptionGroup *gtk_group; GError *error; context = g_option_context_new (NULL); gtk_group = gtk_get_option_group (FALSE); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_group); error = NULL; if (g_option_context_parse (context, argc, argv, &error) == FALSE) { g_warning ("Failed to parse command line arguments: %s", error->message); g_error_free (error); return FALSE; } if (debug) g_setenv ("G_MESSAGES_DEBUG", "all", FALSE); return TRUE; }
inline bool parse_cmdline_args(CmdArgs& args, int& argc, char**& argv) { static const GOptionEntry arg_entries[] = { { "no-locale", 'l', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &(args.arg_locale), "Disable locale", NULL }, { "version", 'V', 0, G_OPTION_ARG_NONE, &(args.arg_version), "Display version information", NULL }, { "no-scan", '\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &(args.arg_scan), "Don't scan devices on startup", NULL }, { "no-hide-tabs", '\0', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &(args.arg_hide_tabs), "Don't hide non-identity tabs when SMART is disabled. Useful for debugging.", NULL }, { "add-virtual", '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &(args.arg_add_virtual), "Load smartctl data from file, creating a virtual drive", NULL }, { "add-device", '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &(args.arg_add_device), "Add this device to device list. Useful with --no-scan to list certain drives only.", NULL }, { NULL } }; GError* error = 0; GOptionContext* context = g_option_context_new("- A GTK+ GUI for smartmontools"); g_option_context_add_main_entries(context, arg_entries, NULL); g_option_context_add_group(context, gtk_get_option_group(false)); // gtk options // libdebug options; this will also automatically apply them g_option_context_add_group(context, debug_get_option_group()); g_option_context_parse(context, &argc, &argv, &error); g_option_context_free(context); return true; }
static int get_options(int argc, char **argv) { GOptionContext *option_context; GError *error = NULL; gboolean display_version = FALSE; GOptionEntry option_entries[] = { { _("version"), 'v', 0, G_OPTION_ARG_NONE, &display_version, _("Display version and exit"), NULL }, { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &remaining, NULL, _("[FILE…]") }, { NULL }, }; option_context = g_option_context_new(_("- Edit text files")); g_option_context_add_main_entries(option_context, option_entries, NULL); //FIXME: translation domain? GETTEXT_PACKAGE g_option_context_add_group(option_context, gtk_get_option_group(TRUE)); if(g_option_context_parse(option_context, &argc, &argv, &error) == FALSE) { g_fprintf(stderr, "Error: can not parse command line arguments: %s\n", error->message); g_error_free(error); return -1; } g_option_context_free(option_context); if(display_version == TRUE) { g_fprintf(stdout, _("Lightpad: a simple text editor, based on a keyboard-based workflow. Version %s.\n"), LIGHTPAD_VERSION); return 1; } return 0; }
int main (int argc, char **argv) { GOptionContext *option_context; GError *error = NULL; gchar *plugin_dir; PeasEngine *engine; option_context = g_option_context_new (_("- libpeas demo application")); g_option_context_add_main_entries (option_context, demo_args, GETTEXT_PACKAGE); g_option_context_add_group (option_context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (option_context, &argc, &argv, &error)) { g_warning ("Error while parsing arguments: %s", error->message); g_error_free (error); return -1; } g_option_context_free (option_context); /* Ensure we pick the uninstalled plugin loaders if we're running from build dir */ if (run_from_build_dir) { g_debug ("Running from build dir."); g_irepository_prepend_search_path ("../libpeas"); g_irepository_prepend_search_path ("../libpeas-gtk"); g_setenv ("PEAS_PLUGIN_LOADERS_DIR", "../loaders", TRUE); } engine = peas_engine_get_default (); plugin_dir = g_build_filename (g_get_user_config_dir (), "peas-demo/plugins", NULL); peas_engine_add_search_path (engine, plugin_dir, plugin_dir); g_free (plugin_dir); peas_engine_enable_loader (engine, "gjs"); peas_engine_enable_loader (engine, "python3"); peas_engine_enable_loader (engine, "seed"); if (run_from_build_dir) peas_engine_add_search_path (engine, "./plugins", NULL); else peas_engine_add_search_path (engine, PEAS_LIBDIR "/peas-demo/plugins/", PEAS_PREFIX "/share/peas-demo/plugins"); n_windows = 0; main_window = create_main_window (); gtk_widget_show_all (main_window); gtk_main (); gtk_widget_destroy (main_window); g_object_unref (engine); return 0; }
int main(int argc, char *argv[]) { bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_set_application_name (_("Gtranscoder")); GtranscoderOptions *options = g_new0(GtranscoderOptions, 1);; GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &options->verbose, N_("Print debug info"), NULL }, { "version", 'V', 0, G_OPTION_ARG_NONE, &options->show_version, N_("Show version number and exit"), NULL }, { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 } }; GError *error = NULL; GOptionContext *context; context = g_option_context_new(N_("- Movie transcoding program")); g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { gchar *help_text = g_option_context_get_help (context, TRUE, NULL); g_print ("%s\n\n%s", error->message, help_text); g_free (help_text); g_error_free (error); g_option_context_free (context); g_free(options); return 1; } if (options->show_version) { g_print("Gtranscoder " VERSION " \n"); return 0; } g_option_context_free (context); gtk_init(&argc, &argv); gboolean has_ffmpeg = check_for_ffmpeg(); if (! has_ffmpeg) { gchar *error_mess = N_("Gtranscoder could not find the ffmpeg executable. Aborting."); g_critical("%s", error_mess); gtranscoder_show_error_dialog_without_main_loop(error_mess); g_error("%s", N_("ffmpeg is required.")); return 1; } else { g_debug("%s", N_("Found ffmpeg")); run_main_window(options); gtk_main(); } g_free(options); return 0; }
/** * main: **/ int main (int argc, char *argv[]) { gboolean ret; gint status = 1; GOptionContext *context; GtkApplication *application = NULL; const GOptionEntry options[] = { { "filter", 'f', 0, G_OPTION_ARG_STRING, &filter, /* TRANSLATORS: preset the GtktextBox with this filter text */ N_("Set the filter to this value"), NULL }, { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid, /* TRANSLATORS: we can make this modal (stay on top of) another window */ _("Set the parent window to make this modal"), NULL }, { NULL} }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init (&argc, &argv); context = g_option_context_new (NULL); g_option_context_set_summary (context, _("Software Log Viewer")); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gpk_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); /* are we running privileged */ ret = gpk_check_privileged_user (_("Log viewer"), TRUE); if (!ret) goto out; /* add application specific icons to search path */ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), GPK_DATA G_DIR_SEPARATOR_S "icons"); /* are we already activated? */ application = gtk_application_new ("org.freedesktop.PackageKit.LogViewer", 0); g_signal_connect (application, "startup", G_CALLBACK (gpk_log_startup_cb), NULL); g_signal_connect (application, "activate", G_CALLBACK (gpk_log_activate_cb), NULL); /* run */ status = g_application_run (G_APPLICATION (application), argc, argv); out: if (builder != NULL) g_object_unref (builder); if (application != NULL) g_object_unref (application); return status; }
void parse_options(int *argc, char **argv[]) { GOptionContext *oc = g_option_context_new(NULL); g_option_context_add_main_entries(oc, option_entries, NULL); g_option_context_add_group(oc, gtk_get_option_group(TRUE)); g_option_context_parse(oc, argc, argv, NULL); g_option_context_free(oc); }
gint main (gint argc, gchar **argv) { GOptionContext *context; GtkWidget *window; GError *error = NULL; static gchar **remaining_args = NULL; gchar *initial_key = NULL; const GOptionEntry entries[] = { { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, N_("[KEY]") }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new (N_("- Directly edit your entire configuration database")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); exit (1); } g_option_context_free (context); /* Register our stock icons */ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), ICONDIR); mateconf_stock_icons_register (); load_accel_map (); gtk_window_set_default_icon_name ("mateconf-editor"); window = mateconf_editor_application_create_editor_window (MATECONF_EDITOR_WINDOW_TYPE_NORMAL); gtk_widget_show_now (window); /* get the key specified on the command line if any. Ignore the rest */ initial_key = remaining_args != NULL ? remaining_args[0] : NULL; if (initial_key != NULL) mateconf_editor_window_go_to (MATECONF_EDITOR_WINDOW (window),initial_key); gtk_main (); save_accel_map (); g_strfreev (remaining_args); return 0; }
int main(int argc, gchar* argv[]) { gtk_init(&argc, &argv); GError *error = NULL; GOptionContext *context; context = g_option_context_new("URL"); g_option_context_add_main_entries(context, entries, NULL); g_option_context_add_group(context, gtk_get_option_group(TRUE)); if (!g_option_context_parse(context, &argc, &argv, &error)) { errx(1, "option parsing failed: %s", error->message); } if (argc < 2) { printf("Usage: %s [OPTION...] URL\n", argv[0]); printf("Try '%s --help' for more information.\n", argv[0]); return 1; } todo = (mhtml_file != NULL) + (html_file != NULL) + (png_file != NULL) + (title_file != NULL); if (!todo) { printf("Specify at least one of: --mhtml, --html, --png, --title\n"); printf("Try '%s --help' for more information.\n", argv[0]); return 1; } const gchar *url = argv[1]; if (g_uri_parse_scheme(url) == NULL) { errx(1, "invalid URI: %s", url); } WebKitWebView *web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_signal_connect(web_view, "load-changed", G_CALLBACK(load_changed), NULL); g_signal_connect(web_view, "load-failed", G_CALLBACK(load_failed), NULL); WebKitSettings *settings = webkit_settings_new_with_settings( "user-agent", USER_AGENT, "enable-javascript", enable_js, "enable-java", FALSE, "enable-plugins", FALSE, "enable-private-browsing", TRUE, "enable-offline-web-application-cache", FALSE, "enable-page-cache", FALSE, NULL ); webkit_web_view_set_settings(web_view, settings); GtkWidget *window = gtk_offscreen_window_new(); gtk_window_set_default_size(GTK_WINDOW(window), 1280, 1024); gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(web_view)); gtk_widget_show_all(window); webkit_web_view_load_uri(web_view, url); gtk_main(); return 0; }
int main (int argc, char *argv[]) { GcmPickerPrivate *priv; GOptionContext *context; GtkApplication *application; guint xid = 0; int status = 0; const GOptionEntry options[] = { { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid, /* TRANSLATORS: we can make this modal (stay on top of) another window */ _("Set the parent window to make this modal"), NULL }, { NULL} }; /* setup translations */ setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* setup LCMS */ cmsSetLogErrorHandler (gcm_picker_error_cb); context = g_option_context_new (NULL); /* TRANSLATORS: tool that is used to pick colors */ g_option_context_set_summary (context, _("GNOME Color Manager Color Picker")); g_option_context_add_group (context, gcm_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); /* create private */ priv = g_new0 (GcmPickerPrivate, 1); priv->last_ambient = -1.0f; priv->xid = xid; /* ensure single instance */ application = gtk_application_new ("org.gnome.ColorManager.Picker", 0); g_signal_connect (application, "startup", G_CALLBACK (gcm_picker_startup_cb), priv); g_signal_connect (application, "activate", G_CALLBACK (gcm_picker_activate_cb), priv); status = g_application_run (G_APPLICATION (application), argc, argv); g_object_unref (application); if (priv->client != NULL) g_object_unref (priv->client); if (priv->builder != NULL) g_object_unref (priv->builder); g_free (priv); return status; }
int main(int argc, char **argv) { GtkWidget *window, *revealer, *grid, *widget; GtkCssProvider *cssprovider; GError *error = NULL; guint x, y; GOptionContext *context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, NULL); frame_stats_add_options (g_option_context_get_main_group (context)); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s\n", error->message); return 1; } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); frame_stats_ensure (GTK_WINDOW (window)); revealer = gtk_revealer_new (); gtk_widget_set_valign (revealer, GTK_ALIGN_START); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), reveal_time * 1000); gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE); g_signal_connect_after (revealer, "map", G_CALLBACK (toggle_reveal), NULL); g_signal_connect_after (revealer, "notify::child-revealed", G_CALLBACK (toggle_reveal), NULL); gtk_container_add (GTK_CONTAINER (window), revealer); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (revealer), grid); cssprovider = gtk_css_provider_new (); gtk_css_provider_load_from_data (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }", -1, NULL); for (x = 0; x < 10; x++) { for (y = 0; y < 20; y++) { widget = gtk_label_new ("Hello World"); gtk_style_context_add_provider (gtk_widget_get_style_context (widget), GTK_STYLE_PROVIDER (cssprovider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); gtk_grid_attach (GTK_GRID (grid), widget, x, y, 1, 1); } } gtk_widget_show_all (window); gtk_main (); return 0; }
int main (int argc, char **argv) { GtkWidget *window; GtkWidget *scrolled_window; GtkWidget *viewport; GtkWidget *grid; GError *error = NULL; int i; GOptionContext *context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, NULL); frame_stats_add_options (g_option_context_get_main_group (context)); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s\n", error->message); return 1; } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); frame_stats_ensure (GTK_WINDOW (window)); gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (window), scrolled_window); viewport = gtk_viewport_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), viewport); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (viewport), grid); for (i = 0; i < 4; i++) { GtkWidget *content = create_widget_factory_content (); gtk_grid_attach (GTK_GRID (grid), content, i % 2, i / 2, 1, 1); g_object_unref (content); } gtk_widget_add_tick_callback (viewport, scroll_viewport, NULL, NULL); gtk_widget_show_all (window); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_main (); return 0; }
static void set_option_group (CutModuleFactory *factory, GOptionContext *context) { GOptionGroup *group; if (CUT_MODULE_FACTORY_CLASS(parent_class)->set_option_group) CUT_MODULE_FACTORY_CLASS(parent_class)->set_option_group(factory, context); group = gtk_get_option_group(TRUE); g_option_context_add_group(context, group); }
static gboolean init_ui (gint *argc, gchar **argv[]) { GtkWidget *main_window; gint window_width, window_height; gchar *ui_path = NULL; GError *error = NULL; GOptionContext *context; context = g_option_context_new ("- graphical SSDP debug tool"); g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, argc, argv, &error)) { g_print ("Failed to parse options: %s\n", error->message); g_error_free (error); return FALSE; } /* Try to fetch the ui file from the CWD first */ ui_path = UI_FILE; if (!g_file_test (ui_path, G_FILE_TEST_EXISTS)) { /* Then Try to fetch it from the system path */ ui_path = UI_DIR "/" UI_FILE; if (!g_file_test (ui_path, G_FILE_TEST_EXISTS)) ui_path = NULL; } if (ui_path == NULL) { g_critical ("Unable to load the GUI file %s", UI_FILE); return FALSE; } builder = gtk_builder_new(); if (gtk_builder_add_from_file(builder, ui_path, NULL) == 0) return FALSE; main_window = GTK_WIDGET(gtk_builder_get_object (builder, "main-window")); g_assert (main_window != NULL); /* 80% of the screen but don't get bigger than 1000x800 */ window_width = CLAMP ((gdk_screen_width () * 80 / 100), 10, 1000); window_height = CLAMP ((gdk_screen_height () * 80 / 100), 10, 800); gtk_window_set_default_size (GTK_WINDOW (main_window), window_width, window_height); gtk_builder_connect_signals (builder, NULL); setup_treeviews (); gtk_widget_show_all (main_window); return TRUE; }
int main(int argc, char **argv) { GError *error = NULL; GdkMonitor *monitor; GdkRectangle monitor_bounds; GOptionContext *context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, NULL); frame_stats_add_options (g_option_context_get_main_group (context)); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s\n", error->message); return 1; } g_print ("# Load factor: %g\n", load_factor); g_print ("# Resizing?: %s\n", cb_no_resize ? "no" : "yes"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); frame_stats_ensure (GTK_WINDOW (window)); gtk_window_set_keep_above (GTK_WINDOW (window), TRUE); gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER); gtk_widget_set_app_paintable (window, TRUE); g_signal_connect (window, "draw", G_CALLBACK (on_window_draw), NULL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (window, "map-event", G_CALLBACK (on_map_event), NULL); on_frame (0.); monitor = gdk_display_get_primary_monitor (gtk_widget_get_display (window)); gdk_monitor_get_geometry (monitor, &monitor_bounds); gtk_window_move (GTK_WINDOW (window), monitor_bounds.x + (monitor_bounds.width - window_width) / 2, monitor_bounds.y + (monitor_bounds.height - window_height) / 2); gtk_widget_show (window); gtk_main (); return 0; }
/** * Program entry point. Initializes gtk+, calls the widget creating * functions and starts the main loop. Also connects 'popup-menu', * 'activate' and 'button-release-event' to the tray_icon. * * @param argc count of arguments * @param argv string array of arguments * @return 0 for success, otherwise error code */ int main (int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif DEBUG_PRINT("[Debugging Mode Build]\n"); setlocale(LC_ALL, ""); context = g_option_context_new (_("- A mixer for the system tray.")); g_option_context_add_main_entries (context, args, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); gtk_init (&argc, &argv); g_option_context_free(context); if (version) { printf(_("%s version: %s\n"),PACKAGE,VERSION); exit(0); } popup_window = NULL; status_icons[0] = status_icons[1] = status_icons[2] = status_icons[3] = NULL; add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); add_pixmap_directory ("./pixmaps"); ensure_prefs_dir(); load_prefs(); cards = NULL; // so we don't try and free on first run alsa_init(); init_libnotify(); create_popups(); add_filter(); tray_icon = create_tray_icon(); apply_prefs(0); g_signal_connect(G_OBJECT(tray_icon), "popup-menu",G_CALLBACK(popup_callback), popup_menu); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL); g_signal_connect(G_OBJECT(tray_icon), "button-release-event", G_CALLBACK(tray_icon_button), NULL); gtk_main (); uninit_libnotify(); alsa_close(); return 0; }
int main (int argc, char **argv) { ArvViewer *viewer; int status; GOptionContext *context; GError *error = NULL; bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); arv_g_thread_init (NULL); gtk_init (&argc, &argv); gst_init (&argc, &argv); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_viewer_option_entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_group (context, gst_init_get_option_group ()); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_viewer_option_debug_domains); viewer = arv_viewer_new (); if (!ARV_IS_VIEWER (viewer)) return EXIT_FAILURE; arv_viewer_set_options (viewer, arv_viewer_option_auto_socket_buffer, !arv_viewer_option_no_packet_resend, arv_viewer_option_packet_timeout, arv_viewer_option_frame_retention); notify_init ("Aravis Viewer"); status = g_application_run (G_APPLICATION (viewer), argc, argv); g_object_unref (viewer); notify_uninit (); return status; }
static gboolean local_cmdline (GApplication *app, gchar ***arguments, gint *exit_status) { gint i; gchar **argv; gint argc = 0; gboolean retval = FALSE; GError *error = NULL; GOptionContext *optcontext; GOptionEntry options[] = { { "hidden", 'h', 0, G_OPTION_ARG_NONE, &hidden, N_("Don't display any dialogs; do any work (eg, importing) and exit"), NULL }, { "if-needed", 'n', 0, G_OPTION_ARG_NONE, &only_if_needed, N_("Don't display any dialogs unless there are only \"People Nearby\" accounts"), NULL }, { "select-account", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &selected_account_name, N_("Initially select given account (eg, " "gabble/jabber/foo_40example_2eorg0)"), N_("<account-id>") }, { NULL } }; optcontext = g_option_context_new (N_("- Empathy Accounts")); g_option_context_add_group (optcontext, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE); argv = *arguments; for (i = 0; argv[i] != NULL; i++) argc++; if (!g_option_context_parse (optcontext, &argc, &argv, &error)) { g_print ("%s\nRun '%s --help' to see a full list of available command line options.\n", error->message, argv[0]); g_warning ("Error in empathy init: %s", error->message); *exit_status = EXIT_FAILURE; retval = TRUE; } g_option_context_free (optcontext); return retval; }
int main(int argc, char* argv[]) { #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain("eiciel", DATADIR "/locale"); textdomain("eiciel"); // We want translations in UTF-8 bind_textdomain_codeset ("eiciel", "UTF-8"); #endif #ifdef USING_GNOME2 GnomeProgram *my_app; my_app = gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE, argc, argv, GNOME_PARAM_HUMAN_READABLE_NAME, "Eiciel", GNOME_PARAM_APP_DATADIR, DATADIR, NULL); #else bool version_called = false; Glib::OptionEntry version_entry; version_entry.set_long_name("version"); version_entry.set_short_name('v'); version_entry.set_description(_("Print version information")); Glib::OptionGroup main_group("Eiciel", _("Access control list editor")); main_group.add_entry(version_entry, version_called); Glib::OptionGroup gtk_group(gtk_get_option_group(TRUE)); Glib::OptionContext oc("[FILE]"); oc.set_main_group(main_group); oc.add_group(gtk_group); oc.parse(argc, argv); if (version_called) { std::cerr << "GNOME " PACKAGE " " VERSION << std::endl; return 0; } #endif Gtk::Main kit(argc, argv); EicielContainer w; if (argc > 1) { w.open_file(argv[1]); } kit.run(w); return 0; }