gint main (gint argc, gchar *argv[]) { GError * error = NULL; GOptionContext * ctx = g_option_context_new (NULL); g_option_context_add_group (ctx, g_irepository_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &error)) { g_print ("sample: %s\n", error->message); g_option_context_free (ctx); if (error) { g_error_free (error); } return 1; } MesonSample * i = meson_sample_new ("Hello, meson/c!"); meson_sample_print_message (i); g_object_unref (i); g_option_context_free (ctx); return 0; }
static void parse_options (int *argc, char ***argv) { GOptionContext *ctx; GError *error = NULL; ctx = g_option_context_new (NULL); g_option_context_add_group (ctx, g_irepository_get_option_group ()); if (!g_option_context_parse (ctx, argc, argv, &error)) { g_print ("sushi: %s\n", error->message); exit(1); } g_option_context_free (ctx); }
static void gedit_app_init (GeditApp *app) { GeditAppPrivate *priv; priv = gedit_app_get_instance_private (app); g_set_application_name ("gedit"); gtk_window_set_default_icon_name ("accessories-text-editor"); priv->monitor = g_network_monitor_get_default (); g_signal_connect (priv->monitor, "network-changed", G_CALLBACK (get_network_available), app); g_application_add_main_option_entries (G_APPLICATION (app), options); #ifdef ENABLE_INTROSPECTION g_application_add_option_group (G_APPLICATION (app), g_irepository_get_option_group ()); #endif }
if (g_str_equal (prgname, "ide")) { g_assert_cmpstr (entries [0].long_name, ==, "list-commands"); entries [0].flags = 0; shortdesc = _("COMMAND"); } context = g_option_context_new (shortdesc); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); group = gtk_get_option_group (TRUE); g_option_context_add_group (context, group); group = g_irepository_get_option_group (); g_option_context_add_group (context, group); ide_application_discover_plugins (self); /* * If we are the "ide" program, then we want to setup ourselves for * verb style commands and add a commands group for help. */ if (g_str_equal (prgname, "ide")) { gchar *command_help; self->mode = IDE_APPLICATION_MODE_TOOL; g_option_context_set_strict_posix (context, TRUE);
int main (int argc, char *argv[]) { GtkApplication *app; GError *error = NULL; GOptionContext *context; GOptionGroup *debug; gulong debug_flags = 0; LifereaDBus *dbus = NULL; gchar *feedUri = NULL; gint status; GOptionEntry entries[] = { { "mainwindow-state", 'w', 0, G_OPTION_ARG_STRING, &initialStateOption, N_("Start Liferea with its main window in STATE. STATE may be `shown', `iconified', or `hidden'"), N_("STATE") }, { "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version, N_("Show version information and exit"), NULL }, { "add-feed", 'a', 0, G_OPTION_ARG_STRING, &feedUri, N_("Add a new subscription"), N_("uri") }, { NULL, 0, 0, 0, NULL, NULL, NULL } }; GOptionEntry debug_entries[] = { { "debug-all", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all types"), NULL }, { "debug-cache", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages for the cache handling"), NULL }, { "debug-conf", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages for the configuration handling"), NULL }, { "debug-db", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the database handling"), NULL }, { "debug-gui", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all GUI functions"), NULL }, { "debug-html", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Enables HTML rendering debugging. Each time Liferea renders HTML output it will also dump the generated HTML into ~/.cache/liferea/output.xhtml"), NULL }, { "debug-net", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all network activity"), NULL }, { "debug-parsing", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all parsing functions"), NULL }, { "debug-performance", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages when a function takes too long to process"), NULL }, { "debug-trace", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages when entering/leaving functions"), NULL }, { "debug-update", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the feed update processing"), NULL }, { "debug-vfolder", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the search folder matching"), NULL }, { "debug-verbose", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print verbose debugging messages"), NULL }, { NULL, 0, 0, 0, NULL, NULL, NULL } }; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif debug = g_option_group_new ("debug", _("Print debugging messages for the given topic"), _("Print debugging messages for the given topic"), &debug_flags, NULL); g_option_group_set_translation_domain(debug, GETTEXT_PACKAGE); g_option_group_add_entries (debug, debug_entries); context = g_option_context_new (NULL); g_option_context_set_summary (context, N_("Liferea, the Linux Feed Reader")); g_option_context_set_description (context, N_("For more information, please visit http://lzone.de/liferea/")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_group (context, debug); g_option_context_add_group (context, gtk_get_option_group (FALSE)); g_option_context_add_group (context, g_irepository_get_option_group ()); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error) { g_print ("Error parsing options: %s\n", error->message); } set_debug_level (debug_flags); /* Configuration necessary for network options, so it has to be initialized before update_init() */ conf_init (); /* We need to do the network initialization here to allow network-manager to be setup before gtk_init() */ update_init (); gtk_init (&argc, &argv); /* Single instance checks, also note that we pass or only RPC (add-feed) as activate signal payload as it is simply an URI string. */ app = gtk_application_new ("net.sourceforge.liferea", G_APPLICATION_HANDLES_OPEN); g_signal_connect (app, "activate", G_CALLBACK (on_app_activate), feedUri); g_signal_connect (app, "open", G_CALLBACK (on_feed_add), NULL); g_set_prgname ("liferea"); g_set_application_name (_("Liferea")); gtk_window_set_default_icon_name ("liferea"); /* GTK theme support */ debug_start_measurement (DEBUG_DB); /* order is important! */ db_init (); /* initialize sqlite */ xml_init (); /* initialize libxml2 */ #ifdef HAVE_LIBNOTIFY notification_plugin_register (&libnotify_plugin); #endif social_init (); /* initialize social bookmarking */ dbus = liferea_dbus_new (); signal (SIGTERM, signal_handler); signal (SIGINT, signal_handler); signal (SIGHUP, signal_handler); /* Note: we explicitely do not use the gdk_thread_* locking in Liferea because it freezes the program when running Flash applets */ runState = STATE_STARTING; debug_end_measurement (DEBUG_DB, "startup"); status = g_application_run (G_APPLICATION (app), 0, NULL); /* Trigger RPCs if we are not primary instance (currently only feed-add) */ if (feedUri && g_application_get_is_remote (G_APPLICATION (app))) { GFile *uris[2]; uris[0] = g_file_new_for_uri (feedUri); uris[1] = NULL; g_application_open (G_APPLICATION (app), uris, 1, "feed-add"); g_object_unref (uris[0]); } g_object_unref (G_OBJECT (dbus)); g_object_unref (app); return status; }
int main (int argc, char **argv) { GOptionContext *ctx; GError *error = NULL; int ecode; TpDebugSender *sender; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); session_mode = (char *) g_getenv ("GNOME_SHELL_SESSION_MODE"); ctx = meta_get_option_context (); g_option_context_add_main_entries (ctx, gnome_shell_options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, g_irepository_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &error)) { g_printerr ("%s: %s\n", argv[0], error->message); exit (1); } g_option_context_free (ctx); meta_plugin_manager_set_plugin_type (gnome_shell_plugin_get_type ()); meta_set_wm_name (WM_NAME); meta_set_gnome_wm_keybindings (GNOME_WM_KEYBINDINGS); meta_init (); /* FIXME: Add gjs API to set this stuff and don't depend on the * environment. These propagate to child processes. */ g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE); g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE); shell_init_debug (g_getenv ("SHELL_DEBUG")); shell_dbus_init (meta_get_replace_current_wm ()); shell_a11y_init (); shell_perf_log_init (); shell_introspection_init (); shell_fonts_init (); /* Turn on telepathy-glib debugging but filter it out in * default_log_handler. This handler also exposes all the logs over D-Bus * using TpDebugSender. */ tp_debug_set_flags ("all"); sender = tp_debug_sender_dup (); g_log_set_default_handler (default_log_handler, sender); /* Initialize the global object */ if (session_mode == NULL) session_mode = is_gdm_mode ? "gdm" : "user"; _shell_global_init ("session-mode", session_mode, NULL); shell_prefs_init (); ecode = meta_run (); if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP")) { g_printerr ("Doing final cleanup...\n"); g_object_unref (shell_global_get ()); } g_object_unref (sender); return ecode; }
int main (int argc, char *argv[]) { GOptionContext *context; PlumaPluginsEngine *engine; PlumaWindow *window; PlumaApp *app; gboolean restored = FALSE; GError *error = NULL; gchar *dir; gchar *icon_dir; /* Setup debugging */ pluma_debug_init (); pluma_debug_message (DEBUG_APP, "Startup"); setlocale (LC_ALL, ""); dir = pluma_dirs_get_pluma_locale_dir (); bindtextdomain (GETTEXT_PACKAGE, dir); g_free (dir); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); startup_timestamp = get_startup_timestamp(); /* Setup command line options */ context = g_option_context_new (_("- Edit text files")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_group (context, egg_sm_client_get_option_group ()); #ifdef HAVE_INTROSPECTION g_option_context_add_group (context, g_irepository_get_option_group ()); #endif if (!g_option_context_parse (context, &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_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); pluma_debug_message (DEBUG_APP, "Create bacon connection"); connection = bacon_message_connection_new ("pluma"); if (connection != NULL) { if (!bacon_message_connection_get_is_server (connection)) { pluma_debug_message (DEBUG_APP, "I'm a client"); pluma_get_command_line_data (); send_bacon_message (); free_command_line_data (); /* we never popup a window... tell startup-notification * that we are done. */ gdk_notify_startup_complete (); bacon_message_connection_free (connection); exit (0); } else { pluma_debug_message (DEBUG_APP, "I'm a server"); bacon_message_connection_set_callback (connection, on_message_received, NULL); } } else { g_warning ("Cannot create the 'pluma' connection."); } pluma_debug_message (DEBUG_APP, "Set icon"); dir = pluma_dirs_get_pluma_data_dir (); icon_dir = g_build_filename (dir, "icons", NULL); g_free (dir); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_dir); g_free (icon_dir); /* Set the associated .desktop file */ egg_set_desktop_file (DATADIR "/applications/pluma.desktop"); /* Load user preferences */ pluma_debug_message (DEBUG_APP, "Init prefs manager"); pluma_prefs_manager_app_init (); /* Init plugins engine */ pluma_debug_message (DEBUG_APP, "Init plugins"); engine = pluma_plugins_engine_get_default (); /* Initialize session management */ pluma_debug_message (DEBUG_APP, "Init session manager"); pluma_session_init (); if (pluma_session_is_restored ()) restored = pluma_session_load (); if (!restored) { pluma_debug_message (DEBUG_APP, "Analyze command line data"); pluma_get_command_line_data (); pluma_debug_message (DEBUG_APP, "Get default app"); app = pluma_app_get_default (); pluma_debug_message (DEBUG_APP, "Create main window"); window = pluma_app_create_window (app, NULL); if (file_list != NULL) { const PlumaEncoding *encoding = NULL; if (encoding_charset) encoding = pluma_encoding_get_from_charset (encoding_charset); pluma_debug_message (DEBUG_APP, "Load files"); _pluma_cmd_load_files_from_prompt (window, file_list, encoding, line_position); } else { pluma_debug_message (DEBUG_APP, "Create tab"); pluma_window_create_tab (window, TRUE); } pluma_debug_message (DEBUG_APP, "Show window"); gtk_widget_show (GTK_WIDGET (window)); free_command_line_data (); } pluma_debug_message (DEBUG_APP, "Start gtk-main"); gtk_main(); bacon_message_connection_free (connection); /* We kept the original engine reference here. So let's unref it to * finalize it properly. */ g_object_unref (engine); pluma_prefs_manager_app_shutdown (); #ifndef ENABLE_GVFS_METADATA pluma_metadata_manager_shutdown (); #endif return 0; }
int main (int argc, char *argv[]) { g_type_init(); #ifdef GOIS GOptionContext *ctx; GError *error = NULL; ctx = g_option_context_new (NULL); g_option_context_add_group (ctx, g_irepository_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &error)) { g_print ("swimmer: %s\n", error->message); // exit(1); } #endif /* * Prior to any use of the type system, g_type_init() has to be called * to initialize the type system and assorted other code portions * (such as the various fundamental type implementations or the signal * system). */ /* Create our object */ NatureAnimal *an = nature_animal_new("Animal", 12); //SwimmerSw *sw = g_object_new(SWIMMER_TYPE, NULL); an->age += 1; g_print("incremented animal->age: %d\n", an->age); /* Call object method */ nature_animal_eat(an, "helowrld"); nature_animal_cry(an, "test"); my_int num = 110183; nature_animal_myint(an, num); nature_animal_uint(an, num*2); nature_animal_get_data(an); g_object_unref(an); // nature_animal_do_action(sw); printf("\n\n"); NatureAnimal *m = nature_monkey_new("Monkey", 10); nature_animal_eat(m, "eat_monkey"); nature_animal_cry(m, "cry monkey"); nature_animal_get_data(m); m->age += 3; nature_animal_get_data(m); // nature_animal_do_action(m); nature_monkey_print_private(m); nature_monkey_set_private(m, "gorilla", "afrika"); nature_monkey_print_private(m); g_object_unref(m); printf("\n"); NatureAnimal *h = mankind_human_new("Jack", 30); nature_animal_eat(h, "eat_human"); nature_animal_cry(h, "cry human"); nature_animal_get_data(h); int r =9; int *arr; nature_animal_pint(h, &r, &arr); printf("r = %d\n", r); printf("arr[0] = %d\n", arr[0]); printf("arr[1] = %d\n", arr[1]); mankind_human_print_private(h); /* printf("\n"); DigitalComp *dc = digital_comp_new("Jack", 30); digital_comp_compute(dc, "comp compute"); digital_comp_reboot(dc, "comp reboot"); digital_comp_halt(dc); */ (void) argc; (void) argv; return 0; }