int main(int argc, char *argv[]) { char *host, *port, *path, *tmp_url; lo_server osc_server; gint osc_server_socket_tag; Y_DEBUG_INIT("WhySynth_gtk"); #ifdef Y_DEBUG GDB_MESSAGE(GDB_MAIN, " starting (pid %d)...\n", getpid()); #else fprintf(stderr, "WhySynth_gtk starting (pid %d)...\n", getpid()); #endif /* { int i; fprintf(stderr, "args:\n"); for(i=0; i<argc; i++) printf("%d: %s\n", i, argv[i]); } // debug */ gtk_init(&argc, &argv); if (argc > 1 && !strcmp(argv[1], "-test")) { gui_test_mode = 1; test_argv[0] = argv[0]; test_argv[1] = "osc.udp://localhost:9/test/mode"; if (argc >= 5) test_argv[4] = argv[4]; argc = 5; argv = test_argv; } else if (argc != 5) { fprintf(stderr, "usage: %s <osc url> <plugin dllname> <plugin label> <user-friendly id>\n" " or: %s -test\n", argv[0], argv[0]); exit(1); } /* set up OSC support */ osc_host_url = argv[1]; host = lo_url_get_hostname(osc_host_url); port = lo_url_get_port(osc_host_url); path = lo_url_get_path(osc_host_url); osc_host_address = lo_address_new(host, port); osc_configure_path = osc_build_path(path, "/configure"); osc_control_path = osc_build_path(path, "/control"); osc_exiting_path = osc_build_path(path, "/exiting"); osc_hide_path = osc_build_path(path, "/hide"); osc_midi_path = osc_build_path(path, "/midi"); osc_program_path = osc_build_path(path, "/program"); osc_quit_path = osc_build_path(path, "/quit"); osc_rate_path = osc_build_path(path, "/sample-rate"); osc_show_path = osc_build_path(path, "/show"); osc_update_path = osc_build_path(path, "/update"); osc_server = lo_server_new(NULL, osc_error); lo_server_add_method(osc_server, osc_configure_path, "ss", osc_configure_handler, NULL); lo_server_add_method(osc_server, osc_control_path, "if", osc_control_handler, NULL); lo_server_add_method(osc_server, osc_hide_path, "", osc_action_handler, "hide"); lo_server_add_method(osc_server, osc_program_path, "ii", osc_program_handler, NULL); lo_server_add_method(osc_server, osc_quit_path, "", osc_action_handler, "quit"); lo_server_add_method(osc_server, osc_rate_path, "i", osc_action_handler, "sample-rate"); lo_server_add_method(osc_server, osc_show_path, "", osc_action_handler, "show"); lo_server_add_method(osc_server, NULL, NULL, osc_debug_handler, NULL); tmp_url = lo_server_get_url(osc_server); osc_self_url = osc_build_path(tmp_url, (strlen(path) > 1 ? path + 1 : path)); free(tmp_url); GDB_MESSAGE(GDB_OSC, ": listening at %s\n", osc_self_url); /* set up GTK+ */ update_port_wavetable_counts(); create_windows(argv[4]); /* add OSC server socket to GTK+'s watched I/O */ if (lo_server_get_socket_fd(osc_server) < 0) { fprintf(stderr, "WhySynth_gtk fatal: OSC transport does not support exposing socket fd\n"); exit(1); } osc_server_socket_tag = gdk_input_add(lo_server_get_socket_fd(osc_server), GDK_INPUT_READ, osc_data_on_socket_callback, osc_server); /* default patches, temporary patchfile support */ gui_data_friendly_patches(); rebuild_patches_list(); patches_dirty = 0; last_configure_load_was_from_tmp = 0; create_patches_tmp_filename(path); /* schedule our update request */ update_request_timeout_tag = g_timeout_add(50, update_request_timeout_callback, NULL); /* let GTK+ take it from here */ gtk_main(); /* clean up and exit */ GDB_MESSAGE(GDB_MAIN, ": yep, we got to the cleanup!\n"); /* release test note, if playing */ release_test_note(); /* GTK+ cleanup */ if (update_request_timeout_tag != 0) gtk_timeout_remove(update_request_timeout_tag); gdk_input_remove(osc_server_socket_tag); /* say bye-bye */ if (!host_requested_quit) { lo_send(osc_host_address, osc_exiting_path, ""); } /* clean up patches */ if (patches) free(patches); if (project_directory) free(project_directory); /* clean up OSC support */ lo_server_free(osc_server); free(host); free(port); free(path); free(osc_configure_path); free(osc_control_path); free(osc_exiting_path); free(osc_hide_path); free(osc_midi_path); free(osc_program_path); free(osc_quit_path); free(osc_rate_path); free(osc_show_path); free(osc_update_path); free(osc_self_url); return 0; }
void gui_kit_run(unsigned (*timer_callback)()) { g_timeout_add(250, (GSourceFunc)timer_callback, NULL); gtk_main(); }
int main(int argc, char *argv[]) { //The gtk_init() function initializes GTK+ and parses some standard command line options. //This function must be called before using any other GTK+ functions gtk_init(&argc, &argv); WidgetData *DataSet = g_slice_new(WidgetData); GtkWidget *window; DataSet->combo = gtk_combo_box_new_text(); DataSet->combo2 = gtk_combo_box_new_text(); DataSet->mainCombo = gtk_combo_box_new_text(); DataSet->container = gtk_fixed_new(); DataSet->entry1 = gtk_entry_new(); DataSet->entry2 = gtk_entry_new(); //gtk_window_new creates new gtk window //GTK_WINDOW_TOPLEVEL is the window type. //toplevel windows have a titlebar and border window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Unit Converter"); //sets window size gtk_window_set_default_size(GTK_WINDOW(window), 280, 80); //sets starting position gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); //adding options to combo box gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo), "Pounds (lbs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo), "Kilograms (kgs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo2), "Pounds (lbs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo2), "Kilograms (kgs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->mainCombo), "Mass"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->mainCombo), "Temperature"); //setting the default settings gtk_combo_box_set_active(GTK_COMBO_BOX(DataSet->mainCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(DataSet->combo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(DataSet->combo2),1); gtk_entry_set_text(GTK_ENTRY(DataSet->entry1), "2.25"); gtk_entry_set_text(GTK_ENTRY(DataSet->entry2), "1.00"); //setting containter border and then adding widgets to containers gtk_container_set_border_width(GTK_CONTAINER(window), 5); gtk_container_add(GTK_CONTAINER(window), DataSet->container); //adding the widgets to container and setting coordinates //set_size_request is setting minimum size the widget will be gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->mainCombo, 70, 0); gtk_widget_set_size_request(DataSet->mainCombo, 130, 30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->combo, 0, 40); gtk_widget_set_size_request(DataSet->combo, 130, 30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->combo2, 140,40); gtk_widget_set_size_request(DataSet->combo2,130,30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->entry1,0,80); gtk_widget_set_size_request(DataSet->entry1, 130, 30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->entry2,140,80); gtk_widget_set_size_request(DataSet->entry2, 130, 30); //g_signal_connect(GtkWidget, signal, G_CALLBACK(method it will call), parameters for the method) g_signal_connect(window, "destroy",G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(DataSet->entry1, "changed", G_CALLBACK(convert), DataSet); g_signal_connect(DataSet->entry2, "changed", G_CALLBACK(convert2), DataSet); g_signal_connect(DataSet->mainCombo, "changed", G_CALLBACK(changeType), DataSet); //flags all widget to be shown gtk_widget_show_all(window); gtk_main(); return 0; }
int main(int argc, char *argv[]) { signal_user_data_t *ud; GError *error = NULL; GOptionContext *context; hb_global_init(); #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif context = g_option_context_new(_("- Transcode media formats")); g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); #if defined(_ENABLE_GST) g_option_context_add_group(context, gst_init_get_option_group()); #endif g_option_context_parse(context, &argc, &argv, &error); if (error != NULL) { g_warning("%s: %s", G_STRFUNC, error->message); g_clear_error(&error); } g_option_context_free(context); #if defined(_WIN32) if (win32_console) { // Enable console logging if(AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()){ close(STDOUT_FILENO); freopen("CONOUT$", "w", stdout); close(STDERR_FILENO); freopen("CONOUT$", "w", stderr); } } else { // Non-console windows apps do not have a stderr->_file // assigned properly stderr->_file = STDERR_FILENO; stdout->_file = STDOUT_FILENO; } #endif if (argc > 1 && dvd_device == NULL && argv[1][0] != '-') { dvd_device = argv[1]; } gtk_init(&argc, &argv); GtkCssProvider *css = gtk_css_provider_new(); error = NULL; gtk_css_provider_load_from_data(css, MyCSS, -1, &error); if (error == NULL) { GdkScreen *ss = gdk_screen_get_default(); gtk_style_context_add_provider_for_screen(ss, GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } else { g_warning("%s: %s", G_STRFUNC, error->message); g_clear_error(&error); } #if !defined(_WIN32) notify_init("HandBrake"); #endif ghb_resource_init(); ghb_load_icons(); #if !defined(_WIN32) dbus_g_thread_init(); #endif ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); ud->debug = ghb_debug; g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud); g_log_set_handler("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud); //g_log_set_handler("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud); ud->globals = ghb_dict_new(); ud->prefs = ghb_dict_new(); ud->settings_array = ghb_array_new(); ud->settings = ghb_dict_new(); ghb_array_append(ud->settings_array, ud->settings); ud->builder = create_builder_or_die(BUILDER_NAME); // Enable events that alert us to media change events watch_volumes(ud); //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom"); //gtk_entry_set_inner_border(widget, 2); // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; #if defined(_NO_UPDATE_CHECK) widget = GHB_WIDGET(ud->builder, "check_updates_box"); gtk_widget_hide(widget); #endif // Must set the names of the widgets that I want to modify // style for. gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_hud"), "preview_hud"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_frame"), "preview_frame"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_preview_play"), "live_preview_play"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_preview_progress"), "live_preview_progress"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_encode_progress"), "live_encode_progress"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "live_duration"), "live_duration"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_show_crop"), "preview_show_crop"); gtk_widget_set_name(GHB_WIDGET(ud->builder, "preview_fullscreen"), "preview_fullscreen"); widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); gtk_widget_set_name(widget, "preview_window"); // Set up the "hud" control overlay for the preview window GtkWidget *preview_box, *draw, *hud, *blender; preview_box = GHB_WIDGET(ud->builder, "preview_window_box"); draw = GHB_WIDGET(ud->builder, "preview_image"); hud = GHB_WIDGET(ud->builder, "preview_hud"); #if 0 // GTK_CHECK_VERSION(3, 0, 0) // This uses the new GtkOverlay widget. // // Unfortunately, GtkOverlay is broken in a couple of ways. // // First, it doesn't respect gtk_widget_shape_combine_region() // on it's child overlays. It appears to just ignore the clip // mask of the child. // // Second, it doesn't respect window opacity. // // So for now, I'll just continue using my home-grown overlay // widget (GhbCompositor). blender = gtk_overlay_new(); gtk_container_add(GTK_CONTAINER(preview_box), blender); gtk_container_add(GTK_CONTAINER(blender), draw); gtk_widget_set_valign (hud, GTK_ALIGN_END); gtk_widget_set_halign (hud, GTK_ALIGN_CENTER); gtk_overlay_add_overlay(GTK_OVERLAY(blender), hud); g_signal_connect(G_OBJECT(blender), "get-child-position", G_CALLBACK(position_overlay_cb), ud); gtk_widget_show(blender); #else // Set up compositing for hud blender = ghb_compositor_new(); gtk_container_add(GTK_CONTAINER(preview_box), blender); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85); gtk_widget_show(blender); #endif // Redirect stderr to the activity window ghb_preview_init(ud); IoRedirect(ud); ghb_log( "%s - %s - %s", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); // Need to connect x264_options textview buffer to the changed signal // since it can't be done automatically GtkTextView *textview; GtkTextBuffer *buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "x264Option")); buffer = gtk_text_view_get_buffer(textview); g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "VideoOptionExtra")); buffer = gtk_text_view_get_buffer(textview); g_signal_connect(buffer, "changed", (GCallback)video_option_changed_cb, ud); textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "MetaLongDescription")); buffer = gtk_text_view_get_buffer(textview); g_signal_connect(buffer, "changed", (GCallback)plot_changed_cb, ud); ghb_combo_init(ud); g_debug("ud %p\n", ud); g_debug("ud->builder %p\n", ud->builder); bind_audio_tree_model(ud); bind_subtitle_tree_model(ud); bind_presets_tree_model(ud); bind_queue_tree_model(ud); bind_chapter_tree_model(ud); // Connect up the signals to their callbacks // I wrote my own connector so that I could pass user data // to the callbacks. Builder's standard autoconnect doesn't all this. gtk_builder_connect_signals_full(ud->builder, MyConnect, ud); ghb_init_audio_defaults_ui(ud); ghb_init_subtitle_defaults_ui(ud); // Parsing x264 options "" initializes x264 widgets to proper defaults ghb_x264_init(ud); // Load prefs before presets. Some preset defaults may depend // on preference settings. // First load default values ghb_settings_init(ud->prefs, "Preferences"); ghb_settings_init(ud->globals, "Globals"); ghb_settings_init(ud->settings, "Initialization"); ghb_settings_init(ud->settings, "OneTimeInitialization"); // Load user preferences file ghb_prefs_load(ud); // Store user preferences into ud->prefs ghb_prefs_to_settings(ud->prefs); int logLevel = ghb_dict_get_int(ud->prefs, "LoggingLevel"); ghb_backend_init(logLevel); // Load the presets files ghb_presets_load(ud); // Note that ghb_preset_to_settings(ud->settings) is called when // the default preset is selected. ghb_settings_to_ui(ud, ud->globals); ghb_settings_to_ui(ud, ud->prefs); // Note that ghb_settings_to_ui(ud->settings) happens when initial // empty title is initialized. if (ghb_dict_get_bool(ud->prefs, "hbfd")) { ghb_hbfd(ud, TRUE); } const gchar *source = ghb_dict_get_string(ud->prefs, "default_source"); ghb_dvd_set_current(source, ud); // Populate the presets tree view ghb_presets_list_init(ud, NULL); // Get the first preset name if (arg_preset != NULL) { ghb_select_preset(ud->builder, arg_preset); } else { ghb_select_default_preset(ud->builder); } // Grey out widgets that are dependent on a disabled feature ghb_check_all_depencencies(ud); if (dvd_device != NULL) { // Source overridden from command line option ghb_dict_set_string(ud->globals, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } else { GhbValue *gval = ghb_dict_get_value(ud->prefs, "default_source"); ghb_dict_set(ud->globals, "scan_source", ghb_value_dup(gval)); } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); // Start timer for monitoring libhb status, 500ms g_timeout_add(200, ghb_timer_cb, (gpointer)ud); // Add dvd devices to File menu ghb_volname_cache_init(); GHB_THREAD_NEW("Cache Volume Names", (GThreadFunc)ghb_cache_volnames, ud); GtkWidget *ghb_window = GHB_WIDGET(ud->builder, "hb_window"); gint window_width, window_height; GdkGeometry geo = { -1, -1, 1920, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST }; GdkWindowHints geo_mask; geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE; gtk_window_set_geometry_hints(GTK_WINDOW(ghb_window), ghb_window, &geo, geo_mask); window_width = ghb_dict_get_int(ud->prefs, "window_width"); window_height = ghb_dict_get_int(ud->prefs, "window_height"); /* * Filter objects in GtkBuilder xml * Unfortunately, GtkFilter is poorly supported by GtkBuilder, * so a lot of the setup must happen in code. SourceFilterAll SourceFilterVideo SourceFilterTS SourceFilterMPG SourceFilterEVO SourceFilterVOB SourceFilterMKV SourceFilterMP4 SourceFilterAVI SourceFilterMOV SourceFilterOGG SourceFilterFLV SourceFilterWMV */ // Add filters to source chooser GtkFileFilter *filter; GtkFileChooser *chooser; chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog")); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_filter_set_name(filter, _("All")); gtk_file_filter_add_pattern(filter, "*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo")); gtk_file_filter_set_name(filter, _("Video")); gtk_file_filter_add_mime_type(filter, "video/*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS")); gtk_file_filter_set_name(filter, "TS"); gtk_file_filter_add_pattern(filter, "*.ts"); gtk_file_filter_add_pattern(filter, "*.TS"); gtk_file_filter_add_pattern(filter, "*.m2ts"); gtk_file_filter_add_pattern(filter, "*.M2TS"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG")); gtk_file_filter_set_name(filter, "MPG"); gtk_file_filter_add_pattern(filter, "*.mpg"); gtk_file_filter_add_pattern(filter, "*.MPG"); gtk_file_filter_add_pattern(filter, "*.mepg"); gtk_file_filter_add_pattern(filter, "*.MEPG"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO")); gtk_file_filter_set_name(filter, "EVO"); gtk_file_filter_add_pattern(filter, "*.evo"); gtk_file_filter_add_pattern(filter, "*.EVO"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB")); gtk_file_filter_set_name(filter, "VOB"); gtk_file_filter_add_pattern(filter, "*.vob"); gtk_file_filter_add_pattern(filter, "*.VOB"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMKV")); gtk_file_filter_set_name(filter, "MKV"); gtk_file_filter_add_pattern(filter, "*.mkv"); gtk_file_filter_add_pattern(filter, "*.MKV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMP4")); gtk_file_filter_set_name(filter, "MP4"); gtk_file_filter_add_pattern(filter, "*.mp4"); gtk_file_filter_add_pattern(filter, "*.MP4"); gtk_file_filter_add_pattern(filter, "*.m4v"); gtk_file_filter_add_pattern(filter, "*.M4V"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMOV")); gtk_file_filter_set_name(filter, "MOV"); gtk_file_filter_add_pattern(filter, "*.mov"); gtk_file_filter_add_pattern(filter, "*.MOV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAVI")); gtk_file_filter_set_name(filter, "AVI"); gtk_file_filter_add_pattern(filter, "*.avi"); gtk_file_filter_add_pattern(filter, "*.AVI"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterOGG")); gtk_file_filter_set_name(filter, "OGG"); gtk_file_filter_add_pattern(filter, "*.ogg"); gtk_file_filter_add_pattern(filter, "*.OGG"); gtk_file_filter_add_pattern(filter, "*.ogv"); gtk_file_filter_add_pattern(filter, "*.OGV"); gtk_file_filter_add_pattern(filter, "*.ogm"); gtk_file_filter_add_pattern(filter, "*.OGM"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterFLV")); gtk_file_filter_set_name(filter, "FLV"); gtk_file_filter_add_pattern(filter, "*.flv"); gtk_file_filter_add_pattern(filter, "*.FLV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterWMV")); gtk_file_filter_set_name(filter, "WMV"); gtk_file_filter_add_pattern(filter, "*.wmv"); gtk_file_filter_add_pattern(filter, "*.WMV"); gtk_file_chooser_add_filter(chooser, filter); // Gtk has a really stupid bug. If the file chooser is showing // hidden files AND there is no filter set, it will not select // the filename when gtk_file_chooser_set_filename is called. // So add a completely unnessary filter to prevent this behavior. filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_chooser_set_filter(chooser, filter); PangoFontDescription *font_desc; font_desc = pango_font_description_from_string("monospace 10"); textview = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "activity_view")); gtk_widget_override_font(GTK_WIDGET(textview), font_desc); pango_font_description_free(font_desc); // Grrrr! Gtk developers !!!hard coded!!! the width of the // radio buttons in GtkStackSwitcher to 100!!! // // Thankfully, GtkStackSwitcher is a regular container object // and we can access the buttons to change their width. GList *stack_switcher_children, *link; GtkContainer * stack_switcher = GTK_CONTAINER( GHB_WIDGET(ud->builder, "SettingsStackSwitcher")); link = stack_switcher_children = gtk_container_get_children(stack_switcher); while (link != NULL) { GtkWidget *widget = link->data; gtk_widget_set_size_request(widget, -1, -1); gtk_widget_set_hexpand(widget, TRUE); gtk_widget_set_halign(widget, GTK_ALIGN_FILL); link = link->next; } g_list_free(stack_switcher_children); gtk_window_resize(GTK_WINDOW(ghb_window), window_width, window_height); gtk_widget_show(ghb_window); // Everything should be go-to-go. Lets rock! gtk_main(); ghb_backend_close(); ghb_value_free(&ud->queue); ghb_value_free(&ud->settings_array); ghb_value_free(&ud->prefs); ghb_value_free(&ud->globals); ghb_value_free(&ud->x264_priv); g_io_channel_unref(ud->activity_log); ghb_settings_close(); ghb_resource_free(); #if !defined(_WIN32) notify_uninit(); #endif g_object_unref(ud->builder); g_free(ud->current_dvd_device); g_free(ud); return 0; }
/* Instanciates the GUI Reads the config file Sets widget states according to the config file Connect callbacks to signals */ int main( int argc, char **argv ) { GtkBuilder *builder; GError *error = NULL; FILE *in; char *pB, *p; int len, val; char t[256]; #ifdef ENABLE_NLS setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif gtk_init( &argc, &argv ); builder = gtk_builder_new(); // Load the glade file if ( !gtk_builder_add_from_file( builder, DATADIR "peopsxgl.ui", &error ) ) { g_warning( "%s", error->message ); g_free( error ); return( 1 ); } // Display the About dialog when the emulator ask for it if ( argv[1] && strcmp( argv[1], "ABOUT" ) == 0 ) { GtkWidget *widget; const char *authors[]= {"Adapted from P.E.Op.S OpenGL GPU by Pete Bernert", NULL}; widget = gtk_about_dialog_new(); gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(widget), "OpenGL GPU Driver"); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "1.18"); gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors); gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), "http://pcsxr.codeplex.com/"); gtk_dialog_run(GTK_DIALOG(widget)); gtk_widget_destroy(widget); return 0; } // Get widgets from the glade file window = GTK_WIDGET( gtk_builder_get_object( builder, "MainDialog" ) ); btnCancel = GTK_WIDGET( gtk_builder_get_object( builder, "btnCancel" ) ); btnSave = GTK_WIDGET( gtk_builder_get_object( builder, "btnSave" ) ); spinXSize = GTK_WIDGET( gtk_builder_get_object( builder, "spinXSize" ) ); spinYSize = GTK_WIDGET( gtk_builder_get_object( builder, "spinYSize" ) ); chkKeepRatio = GTK_WIDGET( gtk_builder_get_object( builder, "chkKeepRatio" ) ); chkDithering = GTK_WIDGET( gtk_builder_get_object( builder, "chkDithering" ) ); chkFullScreen = GTK_WIDGET( gtk_builder_get_object( builder, "chkFullScreen" ) ); cbxTexQuality = GTK_WIDGET( gtk_builder_get_object( builder, "cbxTexQuality" ) ); cbxTexFiltering = GTK_WIDGET( gtk_builder_get_object( builder, "cbxTexFiltering" ) ); cbxHiResTex = GTK_WIDGET( gtk_builder_get_object( builder, "cbxHiResTex" ) ); spinVRam = GTK_WIDGET( gtk_builder_get_object( builder, "spinVRam" ) ); chkShowFPS = GTK_WIDGET( gtk_builder_get_object( builder, "chkShowFPS" ) ); chkUseFPSLimit = GTK_WIDGET( gtk_builder_get_object( builder, "chkUseFPSLimit" ) ); vboxFPSLimit = GTK_WIDGET( gtk_builder_get_object( builder, "vboxFPSLimit" ) ); radFPSLimitAuto = GTK_WIDGET( gtk_builder_get_object( builder, "radFPSLimitAuto" ) ); radFPSLimitManual = GTK_WIDGET( gtk_builder_get_object( builder, "radFPSLimitManual" ) ); spinFPSLimit = GTK_WIDGET( gtk_builder_get_object( builder, "spinFPSLimit" ) ); chkUseFrameSkipping = GTK_WIDGET( gtk_builder_get_object( builder, "chkUseFrameSkipping" ) ); cbxOffscreen = GTK_WIDGET( gtk_builder_get_object( builder, "cbxOffscreen" ) ); cbxFBTex = GTK_WIDGET( gtk_builder_get_object( builder, "cbxFBTex" ) ); cbxFBAccess = GTK_WIDGET( gtk_builder_get_object( builder, "cbxFBAccess" ) ); chkMaskDetect = GTK_WIDGET( gtk_builder_get_object( builder, "chkMaskDetect" ) ); chkOpaquePass = GTK_WIDGET( gtk_builder_get_object( builder, "chkOpaquePass" ) ); chkAdvancedBlend = GTK_WIDGET( gtk_builder_get_object( builder, "chkAdvancedBlend" ) ); chkScanLines = GTK_WIDGET( gtk_builder_get_object( builder, "chkScanLines" ) ); spinScanLinesBlend = GTK_WIDGET( gtk_builder_get_object( builder, "spinScanLinesBlend" ) ); chkFastMdec = GTK_WIDGET( gtk_builder_get_object( builder, "chkFastMdec" ) ); chk15bitMdec = GTK_WIDGET( gtk_builder_get_object( builder, "chk15bitMdec" ) ); chkLineMode = GTK_WIDGET( gtk_builder_get_object( builder, "chkLineMode" ) ); chkAntiAlias = GTK_WIDGET( gtk_builder_get_object( builder, "chkAntiAlias" ) ); chkOGLExtensions = GTK_WIDGET( gtk_builder_get_object( builder, "chkOGLExtensions" ) ); chkScreenSmoothing = GTK_WIDGET( gtk_builder_get_object( builder, "chkScreenSmoothing" ) ); chkGteAccuracy = GTK_WIDGET( gtk_builder_get_object( builder, "chkGteAccuracy" ) ); chkUseGameFixes = GTK_WIDGET( gtk_builder_get_object( builder, "chkUseGameFixes" ) ); tblGameFixes = GTK_WIDGET( gtk_builder_get_object( builder, "tblGameFixes" ) ); chkCfgFix1 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix1" ) ); chkCfgFix2 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix2" ) ); chkCfgFix4 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix4" ) ); chkCfgFix8 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix8" ) ); chkCfgFix16 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix16" ) ); chkCfgFix32 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix32" ) ); chkCfgFix64 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix64" ) ); chkCfgFix128 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix128" ) ); chkCfgFix256 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix256" ) ); chkCfgFix512 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix512" ) ); chkCfgFix1024 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix1024" ) ); chkCfgFix2048 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix2048" ) ); chkCfgFix4096 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix4096" ) ); chkCfgFix8192 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix8192" ) ); chkCfgFix16384 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix16384" ) ); chkCfgFix32768 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix32768" ) ); chkCfgFix65536 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix65536" ) ); chkCfgFix131072 = GTK_WIDGET( gtk_builder_get_object( builder, "chkCfgFix131072" ) ); btnFast = GTK_WIDGET( gtk_builder_get_object( builder, "btnFast" ) ); btnBeautiful = GTK_WIDGET( gtk_builder_get_object( builder, "btnBeautiful" ) ); // Read the config file in = fopen( "gpuPeopsMesaGL.cfg", "rb" ); if ( in ) { pB = (char *) malloc( 32767 ); memset( pB, 0, 32767 ); len = fread( pB, 1, 32767, in ); fclose(in); } else pB = 0; val = 640; if ( pB ) { strcpy( t, "\nResX" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_spin_button_set_value( GTK_SPIN_BUTTON( spinXSize ), val ); val = 480; if ( pB ) { strcpy( t, "\nResY" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_spin_button_set_value( GTK_SPIN_BUTTON( spinYSize ), val ); val = 0; if ( pB ) { strcpy( t, "\nKeepRatio" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkKeepRatio ), val ); val = 0; if ( pB ) { strcpy( t, "\nDithering" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkDithering ), val ); val = 0; if ( pB ) { strcpy( t, "\nFullScreen" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkFullScreen ), val ); val = 0; if ( pB ) { strcpy( t, "\nTexQuality" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_combo_box_set_active( GTK_COMBO_BOX( cbxTexQuality ), val ); val = 0; if ( pB ) { strcpy( t, "\nTexFilter" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_combo_box_set_active( GTK_COMBO_BOX( cbxTexFiltering ), val ); val = 0; if ( pB ) { strcpy( t, "\nHiResTextures" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_combo_box_set_active( GTK_COMBO_BOX( cbxHiResTex ), val ); val = 0; if ( pB ) { strcpy(t,"\nVRamSize"); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_spin_button_set_value( GTK_SPIN_BUTTON( spinVRam ), val ); val = 0; if ( pB ) { strcpy( t, "\nShowFPS" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkShowFPS ), val ); val = 1; if ( pB ) { strcpy( t, "\nUseFrameLimit" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkUseFPSLimit ), val ); val = 1; if ( pB ) { strcpy( t, "\nFPSDetection" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( radFPSLimitAuto ), val ); val = 200; if ( pB ) { strcpy(t,"\nFrameRate"); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_spin_button_set_value( GTK_SPIN_BUTTON( spinFPSLimit ), val ); val = 0; if ( pB ) { strcpy( t, "\nUseFrameSkip" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkUseFrameSkipping ), val ); val = 2; if ( pB ) { strcpy( t, "\nOffscreenDrawing" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_combo_box_set_active( GTK_COMBO_BOX( cbxOffscreen ), val ); val = 1; if ( pB ) { strcpy( t, "\nFrameTextures" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_combo_box_set_active( GTK_COMBO_BOX( cbxFBTex ), val ); val = 0; if ( pB ) { strcpy( t, "\nFrameAccess" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_combo_box_set_active( GTK_COMBO_BOX( cbxFBAccess ), val ); val = 0; if ( pB ) { strcpy( t, "\nMaskDetect" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkMaskDetect ), val ); val = 1; if ( pB ) { strcpy( t, "\nOpaquePass" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkOpaquePass ), val ); val = 0; if ( pB ) { strcpy( t, "\nAdvancedBlend" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkAdvancedBlend ), val ); val = 0; if ( pB ) { strcpy( t, "\nScanLines" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkScanLines ), val ); val = 0; if ( pB ) { strcpy(t,"\nScanLinesBlend"); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_spin_button_set_value( GTK_SPIN_BUTTON( spinScanLinesBlend ), val ); val = 1; if ( pB ) { strcpy( t, "\nFastMdec" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkFastMdec ), val ); val = 0; if ( pB ) { strcpy( t, "\n15bitMdec" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chk15bitMdec ), val ); val = 0; if ( pB ) { strcpy( t, "\nLineMode" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkLineMode ), val ); val = 0; if ( pB ) { strcpy( t, "\nAntiAlias" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkAntiAlias ), val ); val = 0; if ( pB ) { strcpy( t, "\nOGLExtensions" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkOGLExtensions ), val ); val = 0; if ( pB ) { strcpy( t, "\nScreenSmoothing" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkScreenSmoothing ), val ); val = 0; if ( pB ) { strcpy( t, "\nGteAccuracy" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkGteAccuracy ), val ); val = 0; if ( pB ) { strcpy( t, "\nUseFixes" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkUseGameFixes ), val ); val = 0; if ( pB ) { strcpy( t, "\nCfgFixes" ); p = strstr( pB, t ); if ( p ) { p = strstr( p, "=" ); len = 1; val = atoi( p + len ); } } if ( val & (1 << 17) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix131072 ), TRUE ); } if ( val & (1 << 16) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix65536 ), TRUE ); } if ( val & (1 << 15) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix32768 ), TRUE ); } if ( val & (1 << 14) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix16384 ), TRUE ); } if ( val & (1 << 13) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix8192 ), TRUE ); } if ( val & (1 << 12) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix4096 ), TRUE ); } if ( val & (1 << 11) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix2048 ), TRUE ); } if ( val & (1 << 10) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix1024 ), TRUE ); } if ( val & (1 << 9) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix512 ), TRUE ); } if ( val & (1 << 8) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix256 ), TRUE ); } if ( val & (1 << 7) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix128 ), TRUE ); } if ( val & (1 << 6) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix64 ), TRUE ); } if ( val & (1 << 5) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix32 ), TRUE ); } if ( val & (1 << 4) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix16 ), TRUE ); } if ( val & (1 << 3) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix8 ), TRUE ); } if ( val & (1 << 2) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix4 ), TRUE ); } if ( val & (1 << 1) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix2 ), TRUE ); } if ( val & (1 << 0) ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( chkCfgFix1 ), TRUE ); } gtk_builder_connect_signals( builder, NULL ); g_object_unref( G_OBJECT( builder ) ); // Connect callbacks to signals g_signal_connect(G_OBJECT( window ), "destroy", G_CALLBACK( gtk_main_quit ), NULL ); g_signal_connect(G_OBJECT( btnCancel ), "clicked", G_CALLBACK( gtk_main_quit ), NULL ); g_signal_connect(G_OBJECT( btnSave ), "clicked", G_CALLBACK( on_btnSave_clicked ), NULL ); g_signal_connect(G_OBJECT( chkUseGameFixes ), "toggled", G_CALLBACK( on_chkUseGameFixes_toggled ), NULL ); g_signal_connect(G_OBJECT( chkUseFPSLimit ), "toggled", G_CALLBACK( on_chkUseFPSLimit_toggled ), NULL ); g_signal_connect(G_OBJECT( radFPSLimitManual ), "toggled", G_CALLBACK( on_radFPSLimitManual_toggled ), NULL ); g_signal_connect(G_OBJECT( chkScanLines ), "toggled", G_CALLBACK( on_chkScanLines_toggled ), NULL ); g_signal_connect(G_OBJECT( btnFast ), "clicked", G_CALLBACK( on_btnFast_clicked ), NULL ); g_signal_connect(G_OBJECT( btnBeautiful ), "clicked", G_CALLBACK( on_btnBeautiful_clicked ), NULL ); // Call some callbacks to ensure widget state consistency on_chkUseGameFixes_toggled( G_OBJECT( chkUseGameFixes ), NULL ); on_chkUseFPSLimit_toggled( G_OBJECT( chkUseFPSLimit ), NULL ); on_radFPSLimitManual_toggled( G_OBJECT( radFPSLimitManual ), NULL ); on_chkScanLines_toggled( G_OBJECT( chkScanLines ), NULL ); gtk_widget_show( window ); gtk_main(); return 0; }
void * mainThread(void * nothingUseful) { gtk_main(); }
int main (int argc, char *argv[]) { int ret; char *uri; GdkPixbuf *pixbuf; GFile *file; GError *error; GnomeGdkPixbufAsyncHandle *handle; uri = NULL; error = NULL; async_ok = FALSE; ret = 1; gtk_init (&argc, &argv); if (argc != 2) { g_warning ("usage: %s <uri_to_imagefile>", argv[0]); goto out; } /* this is a cheap trick to get file:/// properly appended */ file = g_file_new_for_commandline_arg (argv[1]); uri = g_file_get_uri (file); g_object_unref (file); /* first, test the sync version */ g_message ("Using gnome_gdk_pixbuf_new_from_uri() to load file with uri '%s'", uri); pixbuf = gnome_gdk_pixbuf_new_from_uri (uri); if (pixbuf == NULL) { g_warning ("gnome_gdk_pixbuf_new_from_uri() failed"); goto out; } if (!gdk_pixbuf_save (pixbuf, "pixbuf-sync.png", "png", &error, NULL)) { g_warning ("Error saving file pixbuf-sync.png: %s", error->message); goto out; } g_object_unref (pixbuf); g_message ("Saved pixbuf to pixbuf-sync.png"); /* now, the async version */ g_message ("Using gnome_gdk_pixbuf_new_from_uri_async() to load file with uri '%s'", uri); handle = gnome_gdk_pixbuf_new_from_uri_async (uri, pixbuf_loaded, pixbuf_done, NULL); gtk_main (); if (!async_ok) { g_warning ("Error saving file pixbuf-async.png"); goto out; } g_message ("Saved pixbuf to pixbuf-async.png"); ret = 0; out: g_free (uri); return ret; }
/* ----------------------------------------------------------------------------*/ int main(int argc,char* argv[]) { gboolean retry; GtkWidget* dialog; gint result; int i; gtk_init(&argc,&argv); fprintf(stderr,"gHermes Version %s\n",VERSION); strcpy(propertyPath,"gHermes.properties"); // strcpy(soundCardName,"HPSDR"); ozy_set_interface("eth0"); processCommands(argc,argv); loadProperties(propertyPath); #ifdef ALEX_TEST alex_rx_test_load("alex_rx_test.csv"); alex_tx_test_load("alex_tx_test.csv"); #endif //init_cw(); // initialize DttSP Setup_SDR(); Release_Update(); SetTRX(0,FALSE); // thread 0 is for receive SetTRX(1,TRUE); // thread 1 is for transmit SetThreadProcessingMode(0,2); // set thread 0 to RUN SetThreadProcessingMode(1,2); // set thread 1 to RUN SetSubRXSt(0,0,TRUE); reset_for_buflen(0,buffer_size); reset_for_buflen(1,buffer_size); // initialize ozy (default 48K) //ozyRestoreState(); do { switch(ozy_init()) { case -1: // cannot find ozy dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, "Cannot locate Ozy!\n\nIs it powered on and plugged in?"); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Retry?"); gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR"); result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_YES: retry=TRUE; break; default: exit(1); break; } gtk_widget_destroy (dialog); break; case -2: // found but needs initializing result=fork(); if(result==0) { // child process - exec initozy fprintf(stderr,"exec initozy\n"); result=execl("initozy",NULL,NULL); fprintf(stderr,"exec returned %d\n",result); exit(result); } else if(result>0) { // wait for the forked process to terminate dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, "Initializing Ozy"); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Please Wait ..."); gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR"); gtk_widget_show_all (dialog); while (gtk_events_pending ()) gtk_main_iteration (); wait(&result); fprintf(stderr,"wait status=%d\n",result); retry=TRUE; } gtk_widget_destroy (dialog); break; case -3: // did not find metis dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, "Cannot locate Metis on interface %s!", ozy_get_interface()); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Retry?"); gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR"); result = gtk_dialog_run (GTK_DIALOG (dialog)); switch (result) { case GTK_RESPONSE_YES: retry=TRUE; break; default: exit(1); break; } gtk_widget_destroy (dialog); break; default: retry=FALSE; break; } } while(retry); mainRootX=0; mainRootY=0; cwPitch =600; restoreInitialState(); //SetKeyerResetSize(4096); //NewKeyer(600.0f,TRUE,0.0f,3.0f,25.0f,48000.0f); //SetKeyerPerf(FALSE); //StartKeyer(); initColors(); //gtk_key_snooper_install((GtkKeySnoopFunc)keyboardSnooper,NULL); //bandscopeRestoreState(); //bandscopeWindow=buildBandscopeUI(); //bandscope_controlRestoreState(); //bandscope_controlWindow=buildBandscope_controlUI(); meterRestoreState(); meterWindow=buildMeterUI(); vfoRestoreState(); vfoWindow=buildVfoUI(); bandRestoreState(); bandWindow=buildBandUI(); modeRestoreState(); modeWindow=buildModeUI(); filterRestoreState(); filterWindow=buildFilterUI(); displayRestoreState(); displayWindow=buildDisplayUI(); audioRestoreState(); audioWindow=buildAudioUI(); agcRestoreState(); agcWindow=buildAgcUI(); preampWindow=buildPreampUI(); zoomWindow=buildZoomUI(); receiverRestoreState(); receiverWindow=buildReceiverUI(); volumeRestoreState(); volumeWindow=buildVolumeUI(); keyerRestoreState(); keyerWindow=buildKeyerUI(); cwPitch =(int)cw_sidetone_frequency; transmitRestoreState(); transmitWindow=buildTransmitUI(); mic_meterWindow=buildMic_MeterUI(); subrxRestoreState(); subrxWindow=buildSubRxUI(); restoreState(); // build the Main UI buildMainUI(); //setSoundcard(getSoundcardId(soundCardName)); audio_stream_init(); hamlibserv_init(); gtk_main(); return 0; }
int main(int argc, char **argv) { GError *error = NULL; GtkBuilder *builder; #if defined(_WIN32) && defined(GFT_USE_MANIFEST) { INITCOMMONCONTROLSEX tim; memset(&tim, 0, sizeof tim); tim.dwSize = sizeof tim; tim.dwICC = ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_DATE_CLASSES | ICC_HOTKEY_CLASS | ICC_INTERNET_CLASSES | ICC_LISTVIEW_CLASSES | ICC_NATIVEFNTCTL_CLASS | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES | ICC_STANDARD_CLASSES; if(InitCommonControlsEx(&tim) == FALSE) fputs("warning: InitCommomControlsEx() failed\n", stderr); } #endif #ifndef _WIN32 if(signal(SIGCHLD, SIG_IGN) == SIG_ERR) perror("signal(SIGCHLD)"); #endif ft_zero(&ft); ft_async(&ft) = 1; gtk_init(&argc, &argv); /* bail here if !$DISPLAY */ #ifdef _WIN32 { int debug = 0; if(argc == 2){ if(!strcmp(argv[1], "-d")){ debug = 1; fprintf(stderr, "%s: debug on\n", *argv); }else{ usage: fprintf(stderr, "Usage: %s [-d]\n", *argv); return 1; } }else if(argc != 1) goto usage; if(!debug){ fputs("gft: debug off\n", stderr); FreeConsole(); } } #else if(argc != 1){ fprintf(stderr, "Usage: %s\n", *argv); return 1; } #endif builder = gtk_builder_new(); if(gladegen_init()) return 1; if(!gtk_builder_add_from_file(builder, GLADE_XML_FILE, &error)){ g_warning("%s", error->message); /*g_free(error);*/ return 1; } gladegen_term(); if(getobjects(builder)) return 1; gtk_builder_connect_signals(builder, NULL); glist_init(&listTransfers, treeTransfers); /* don't need it anymore */ g_object_unref(G_OBJECT(builder)); /* signal setup */ g_signal_connect(G_OBJECT(winMain), "delete-event" , G_CALLBACK(on_winMain_delete_event), NULL); g_signal_connect(G_OBJECT(winMain), "destroy", G_CALLBACK(on_winMain_destroy), NULL); cfg_read(cboHost); tray_init(winMain, *argv); transfers_init(&listDone, treeDone); gtk_widget_set_sensitive(btnSend, FALSE); drag_init(); cmds(); gtk_widget_show_all(winMain); gtk_main(); tray_term(); return 0; }
int main(int argc, char **argv) { gboolean init_ret; gboolean verbose = FALSE; GError *error = NULL; int i; GOptionEntry options[] = { { "interval", 'i', 0, G_OPTION_ARG_INT, &dz.interval, "Refresh interval (milliseconds)", NULL }, { "block", 'b', 0, G_OPTION_ARG_INT, &dz.block_size, "Use block bytes as the unit for displaying zone LBA, length and write pointer position", NULL }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Set libzbc verbose mode", NULL }, { NULL } }; /* Init */ memset(&dz, 0, sizeof(dz)); init_ret = gtk_init_with_args(&argc, &argv, "ZBC device zone state GUI", options, NULL, &error); if ( (init_ret == FALSE) || (error != NULL) ) { printf("Failed to parse command line arguments: %s\n", error->message); g_error_free(error); return( 1 ); } if ( dz.interval < 0 ) { fprintf(stderr, "Invalid update interval\n"); return( 1 ); } if ( dz.block_size < 0 ) { fprintf(stderr, "Invalid block size\n"); return( 1 ); } if ( verbose ) { zbc_set_log_level("debug"); } dz_set_signal_handlers(); /* Create GUI */ dz_if_create(); /* Add devices listed on command line */ for(i = 1; i < argc; i++ ) { dz_if_add_device(argv[i]); } /* Main event loop */ gtk_main(); /* Cleanup GUI */ dz_if_destroy(); return( 0 ); }
int ras_kl_menu(int kn_fokus,const char *kod_kl,const char *fio,int denrog,int pol,class iceb_u_str *zap_vv,int metka_blok,double *saldo,double *saldo_po_kas) { class iceb_gdite_data gdite; iceb_gdite(&gdite,1,NULL); //открываем окно ждите iceb_refresh(); double ost_na_saldo=0.; *saldo_po_kas=0.; *saldo=ras_sal_kl(kod_kl,&ost_na_saldo,saldo_po_kas,NULL); class iceb_u_str zagolovok; zagolovok.plus(gettext("Клиент")); zagolovok.plus(":"); zagolovok.plus(kod_kl); zagolovok.plus(" "); zagolovok.plus(fio); zagolovok.ps_plus(gettext("Общее сальдо")); zagolovok.plus(":"); zagolovok.plus(*saldo); zagolovok.ps_plus(gettext("Наличное сальдо")); zagolovok.plus(":"); zagolovok.plus(*saldo_po_kas); zagolovok.ps_plus(gettext("Безналичное сальдо")); zagolovok.plus(":"); zagolovok.plus(*saldo-*saldo_po_kas); zagolovok.ps_plus(gettext("Пол")); zagolovok.plus(":"); if(pol == 0) zagolovok.plus(gettext("Мужчина")); else zagolovok.plus(gettext("Женщина")); if(denrog == 1) { zagolovok.ps_plus(gettext("У клиента сегодня день рождения")); } if(metka_blok == 1) zagolovok.ps_plus(gettext("Внимание !!! Карточка заблокирована !!!")); iceb_refresh(); gdite.close(); //закрываем окно ждите class ras_kl_data data; char bros[300]; data.window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER); sprintf(bros,"%s %s",NAME_SYSTEM,gettext("Расчёт клиентов")); gtk_window_set_title(GTK_WINDOW(data.window),iceb_u_toutf(bros)); //Установка ширины окантовки внутренней области gtk_container_set_border_width(GTK_CONTAINER(data.window),1); //gtk_widget_show(data.window); //Отрисовываем, чтобы можно было взять цвет gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(ras_kl_destroy),&data.knopka); gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL); gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(iceb_vihod),&data.knopka); GtkWidget *vbox=gtk_vbox_new(FALSE,1); gtk_container_add(GTK_CONTAINER(data.window),vbox); GtkWidget *label=gtk_label_new(zagolovok.ravno_toutf()); gtk_box_pack_start((GtkBox*)vbox,label,FALSE,FALSE,1); if(zap_vv->getdlinna() > 1) { GdkColor color; label=gtk_label_new(zap_vv->ravno_toutf()); gdk_color_parse("red",&color); gtk_widget_modify_fg(label,GTK_STATE_NORMAL,&color); gtk_box_pack_start((GtkBox*)vbox,label,FALSE,FALSE,1); } GtkWidget *knopka[KOLKNOP]; knopka[VOZVRAT_KAR]=gtk_button_new_with_label(gettext("Возврат карточки клиентом")); gtk_box_pack_start((GtkBox*)vbox,knopka[VOZVRAT_KAR],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[VOZVRAT_KAR]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[VOZVRAT_KAR]),(gpointer)VOZVRAT_KAR); knopka[VOZVRAT_SUM]=gtk_button_new_with_label(gettext("Возвратить деньги из кассы")); gtk_box_pack_start((GtkBox*)vbox,knopka[VOZVRAT_SUM],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[VOZVRAT_SUM]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[VOZVRAT_SUM]),(gpointer)VOZVRAT_SUM); knopka[OPLATA]=gtk_button_new_with_label(gettext("Оплата")); gtk_box_pack_start((GtkBox*)vbox,knopka[OPLATA],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[OPLATA]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[OPLATA]),(gpointer)OPLATA); knopka[VID_KART]=gtk_button_new_with_label(gettext("Выдача карточки клиенту")); gtk_box_pack_start((GtkBox*)vbox,knopka[VID_KART],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[VID_KART]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[VID_KART]),(gpointer)VID_KART); knopka[PROS_SHETS]=gtk_button_new_with_label(gettext("Просмотр счетов по клиенту")); gtk_box_pack_start((GtkBox*)vbox,knopka[PROS_SHETS],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[PROS_SHETS]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[PROS_SHETS]),(gpointer)PROS_SHETS); knopka[PROV_VV]=gtk_button_new_with_label(gettext("Проверка возможности входа/выхода в подразделение")); gtk_box_pack_start((GtkBox*)vbox,knopka[PROV_VV],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[PROV_VV]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[PROV_VV]),(gpointer)PROV_VV); knopka[PROS_VV]=gtk_button_new_with_label(gettext("Просмотр движения по карточке")); gtk_box_pack_start((GtkBox*)vbox,knopka[PROS_VV],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[PROS_VV]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[PROS_VV]),(gpointer)PROS_VV); knopka[VIHOD]=gtk_button_new_with_label(gettext("Выход")); gtk_box_pack_start((GtkBox*)vbox,knopka[VIHOD],TRUE,TRUE,1); gtk_signal_connect(GTK_OBJECT(knopka[VIHOD]),"clicked",GTK_SIGNAL_FUNC(ras_kl_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(knopka[VIHOD]),(gpointer)VIHOD); gtk_widget_grab_focus(knopka[kn_fokus]); gtk_widget_show_all( data.window ); gtk_main(); return(data.knopka); }
int vmat_medp(iceb_u_str *innom,short *dn,short *mn,short *gn,iceb_u_str *regnom,GtkWidget *wpredok) { vmat_medp_data data; char strsql[512]; data.window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(data.window),TRUE); sprintf(strsql,"%s %s",name_system,gettext("Ввод карточки мед. препората")); gtk_window_set_title (GTK_WINDOW (data.window),strsql); gtk_container_set_border_width (GTK_CONTAINER (data.window), 5); gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL); gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL); gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(vmat_medp_v_key_press),&data); if(wpredok != NULL) { gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE)); //Удерживать окно над породившем его окном всегда gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok)); //Закрыть окно если окно предок удалено gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE); } GtkWidget *label=gtk_label_new(gettext("Ввод карточки мед. препората")); GtkWidget *vbox = gtk_vbox_new (FALSE, 0); GtkWidget *hbox[KOLENTER]; for(int i=0; i < KOLENTER; i++) hbox[i] = gtk_hbox_new (FALSE, 0); GtkWidget *hboxknop = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (data.window), vbox); gtk_container_add (GTK_CONTAINER (vbox), label); for(int i=0; i < KOLENTER; i++) gtk_container_add (GTK_CONTAINER (vbox), hbox[i]); gtk_container_add (GTK_CONTAINER (vbox), hboxknop); sprintf(strsql,"%s",gettext("Дата регистрации медицинского препарата")); label=gtk_label_new(iceb_u_toutf(strsql)); data.entry[E_DATAR] = gtk_entry_new_with_max_length (10); gtk_box_pack_start (GTK_BOX (hbox[E_DATAR]), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox[E_DATAR]), data.entry[E_DATAR], TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT (data.entry[E_DATAR]), "activate",GTK_SIGNAL_FUNC(vmat_medp_v_vvod),&data); gtk_entry_set_text(GTK_ENTRY(data.entry[E_DATAR]),data.datar.ravno()); gtk_object_set_user_data(GTK_OBJECT(data.entry[E_DATAR]),(gpointer)E_DATAR); sprintf(strsql,"%s",gettext("Серия медицинского препарата")); label=gtk_label_new(iceb_u_toutf(strsql)); data.entry[E_SERIQ] = gtk_entry_new_with_max_length (20); gtk_box_pack_start (GTK_BOX (hbox[E_SERIQ]), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox[E_SERIQ]), data.entry[E_SERIQ], TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT (data.entry[E_SERIQ]), "activate",GTK_SIGNAL_FUNC(vmat_medp_v_vvod),&data); gtk_entry_set_text(GTK_ENTRY(data.entry[E_SERIQ]),data.seriq.ravno()); gtk_object_set_user_data(GTK_OBJECT(data.entry[E_SERIQ]),(gpointer)E_SERIQ); sprintf(strsql,"%s",gettext("Регистрационный номер документа мед.прерарата")); label=gtk_label_new(iceb_u_toutf(strsql)); data.entry[E_REGNOM] = gtk_entry_new_with_max_length (20); gtk_box_pack_start (GTK_BOX (hbox[E_REGNOM]), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox[E_REGNOM]), data.entry[E_REGNOM], TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT (data.entry[E_REGNOM]), "activate",GTK_SIGNAL_FUNC(vmat_medp_v_vvod),&data); gtk_entry_set_text(GTK_ENTRY(data.entry[E_REGNOM]),data.regnom.ravno()); gtk_object_set_user_data(GTK_OBJECT(data.entry[E_REGNOM]),(gpointer)E_REGNOM); GtkTooltips *tooltips[KOL_F_KL]; sprintf(strsql,"F2 %s",gettext("Записать")); data.knopka[FK2]=gtk_button_new_with_label(strsql); tooltips[FK2]=gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Записать введенную в меню информацию."),NULL); gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]),"clicked",GTK_SIGNAL_FUNC(vmat_medp_v_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2); gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK2], TRUE, TRUE, 0); /******************* sprintf(strsql,"F3 %s",gettext("Реквизиты")); data.knopka[FK3]=gtk_button_new_with_label(strsql); tooltips[FK3]=gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips[FK3],data.knopka[FK3],gettext("Просмотр нужных реквизитов."),NULL); gtk_signal_connect(GTK_OBJECT(data.knopka[FK3]),"clicked",GTK_SIGNAL_FUNC(vmat_medp_v_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK3]),(gpointer)FK3); gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK3], TRUE, TRUE, 0); ******************/ sprintf(strsql,"F4 %s",gettext("Очистить")); data.knopka[FK4]=gtk_button_new_with_label(strsql); tooltips[FK4]=gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Очистить меню от введенной информации."),NULL); gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]),"clicked",GTK_SIGNAL_FUNC(vmat_medp_v_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4); gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK4], TRUE, TRUE, 0); sprintf(strsql,"F10 %s",gettext("Выход")); data.knopka[FK10]=gtk_button_new_with_label(strsql); tooltips[FK10]=gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Завершение работы в этом окне."),NULL); gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]),"clicked",GTK_SIGNAL_FUNC(vmat_medp_v_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10); gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK10], TRUE, TRUE, 0); gtk_widget_grab_focus(data.entry[0]); gtk_widget_show_all (data.window); gtk_main(); if(data.voz == 0) { innom->new_plus(data.seriq.ravno()); regnom->new_plus(data.regnom.ravno()); iceb_u_rsdat(dn,mn,gn,data.datar.ravno(),1); } if(wpredok != NULL) gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR)); return(data.voz); }
int main (int argc, char *argv[]) { GtkWidget *scrolled_win; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *close; GtkWidget *insert; GtkWidget *find; GtkWidget *retrieve; /* * Here, we use a heap'ed struct to logically group two widgets that * interact closely and - in our example - don't make much sense on their * own. We even prefer this grouping as a function parameter! * Of course this is also a perfect candidate for cb data */ Widgets *w = g_slice_new (Widgets); gtk_init (&argc, &argv); /* * Setting up the main window, + some style. */ w->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW(w->window), "Text Iterators Example"); gtk_container_set_border_width (GTK_CONTAINER(w->window), 10); gtk_widget_set_size_request (w->window, -1, 200); // clever, -1 means "I don't care." w->textview = gtk_text_view_new(); w->entry = gtk_entry_new(); close = gtk_button_new_from_stock (GTK_STOCK_CLOSE); insert = gtk_button_new_with_label ("Insert Text"); find = gtk_button_new_with_label ("Find Text"); retrieve = gtk_button_new_with_label ("Retrieve Text"); /* * Connecting signals for our buttons and main window. */ g_signal_connect_swapped (G_OBJECT(close), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT(w->window)); g_signal_connect (G_OBJECT(insert), "clicked", G_CALLBACK (on_insert_clicked), (gpointer) w); g_signal_connect (G_OBJECT(find), "clicked", G_CALLBACK (on_find_clicked), (gpointer) w); g_signal_connect (G_OBJECT(retrieve), "clicked", G_CALLBACK (on_retrieve_clicked), (gpointer) w); g_signal_connect (G_OBJECT(w->window), "destroy", G_CALLBACK (gtk_main_quit), NULL); /* * We create a scrolled window without supplying h/v adjustments and pack * our textview into it. */ scrolled_win = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER(scrolled_win), w->textview); hbox = gtk_hbox_new (FALSE, 5); gtk_box_pack_start_defaults (GTK_BOX(hbox), close); gtk_box_pack_start_defaults (GTK_BOX(hbox), w->entry); gtk_box_pack_start_defaults (GTK_BOX(hbox), insert); gtk_box_pack_start_defaults (GTK_BOX(hbox), find); gtk_box_pack_start_defaults (GTK_BOX(hbox), retrieve); vbox = gtk_vbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX(vbox), scrolled_win, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_container_add (GTK_CONTAINER(w->window), vbox); gtk_widget_show_all (w->window); gtk_main(); return 0; }
int main (int argc, char **argv) { GtkWidget *window, *label, *entry, *button, *grid, *notebook; GtkWidget *vbox, *hbox, *grid_hbox, *spin, *spin2, *toggle, *combo, *image, *ebox; PangoFontDescription *font; GtkAdjustment *adjustment; int i, j; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (window), notebook); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, gtk_label_new ("hboxes")); for (j = 0; j < 2; j++) { hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 5); char *aligns_names[] = { "FILL", "BASELINE" }; GtkAlign aligns[] = { GTK_ALIGN_FILL, GTK_ALIGN_BASELINE}; label = gtk_label_new (aligns_names[j]); gtk_container_add (GTK_CONTAINER (hbox), label); for (i = 0; i < 3; i++) { label = gtk_label_new ("│XYyj,Ö..."); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (label, font); gtk_widget_set_valign (label, aligns[j]); gtk_container_add (GTK_CONTAINER (hbox), label); } for (i = 0; i < 3; i++) { entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "│XYyj,Ö..."); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (entry, font); gtk_widget_set_valign (entry, aligns[j]); gtk_container_add (GTK_CONTAINER (hbox), entry); } spin = gtk_spin_button_new (NULL, 0, 1); gtk_orientable_set_orientation (GTK_ORIENTABLE (spin), GTK_ORIENTATION_VERTICAL); gtk_widget_set_valign (spin, aligns[j]); gtk_container_add (GTK_CONTAINER (hbox), spin); } grid_hbox = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[0]); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[1]); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[2]); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1); gtk_container_add (GTK_CONTAINER (hbox), combo); for (j = 0; j < 2; j++) { hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (baseline_position_changed), hbox); if (j == 0) label = gtk_label_new ("Baseline:"); else label = gtk_label_new ("Normal:"); gtk_container_add (GTK_CONTAINER (hbox), label); for (i = 0; i < 3; i++) { button = gtk_button_new_with_label ("│Xyj,Ö"); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (button, font); if (j == 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); } for (i = 0; i < 3; i++) { button = gtk_button_new_with_label ("│Xyj,Ö"); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON)); gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (button, font); if (j == 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); } ebox = gtk_event_box_new (); if (j == 0) gtk_widget_set_valign (ebox, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), ebox); image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON); gtk_image_set_pixel_size (GTK_IMAGE (image), 34); if (j == 0) gtk_widget_set_valign (image, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (ebox), image); button = gtk_toggle_button_new_with_label ("│Xyj,Ö"); if (j == 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); button = gtk_toggle_button_new_with_label ("│Xyj,Ö"); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), TRUE); if (j == 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); button = gtk_check_button_new_with_label ("│Xyj,Ö"); if (j == 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); button = gtk_radio_button_new_with_label (NULL, "│Xyj,Ö"); if (j == 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); } vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, gtk_label_new ("grid")); grid_hbox = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); label = gtk_label_new ("Align me:"); gtk_widget_set_valign (label, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), label); grid = gtk_grid_new (); gtk_widget_set_valign (grid, GTK_ALIGN_BASELINE); gtk_grid_set_column_spacing (GTK_GRID (grid), 8); gtk_grid_set_row_spacing (GTK_GRID (grid), 8); for (j = 0; j < 4; j++) { char *labels[] = { "Normal:", "Baseline (top):", "Baseline (center):", "Baseline (bottom):"}; label = gtk_label_new (labels[j]); gtk_grid_attach (GTK_GRID (grid), label, 0, j, 1, 1); gtk_widget_set_vexpand (label, TRUE); if (j != 0) gtk_grid_set_row_baseline_position (GTK_GRID (grid), j, (GtkBaselinePosition)(j-1)); for (i = 0; i < 3; i++) { label = gtk_label_new ("Xyjg,Ö."); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (label, font); if (j != 0) gtk_widget_set_valign (label, GTK_ALIGN_BASELINE); gtk_grid_attach (GTK_GRID (grid), label, i+1, j, 1, 1); } for (i = 0; i < 3; i++) { button = gtk_button_new_with_label ("│Xyj,Ö"); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON)); gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (button, font); if (j != 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_grid_attach (GTK_GRID (grid), button, i+4, j, 1, 1); } } gtk_container_add (GTK_CONTAINER (hbox), grid); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 5); adjustment = gtk_adjustment_new (0.0, -1.0, 5.0, 1.0, 1.0, 0.0); spin = gtk_spin_button_new (adjustment, 1.0, 0); g_signal_connect (spin, "value-changed", (GCallback)baseline_row_value_changed, grid); gtk_container_add (GTK_CONTAINER (hbox), spin); toggle = gtk_toggle_button_new_with_label ("Homogeneous"); g_signal_connect (toggle, "toggled", (GCallback)homogeneous_changed, grid); gtk_container_add (GTK_CONTAINER (hbox), toggle); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[0]); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[1]); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), baseline_pos_str[2]); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 1); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (baseline_position_changed), grid_hbox); gtk_container_add (GTK_CONTAINER (hbox), combo); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, gtk_label_new ("button box")); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 5); adjustment = gtk_adjustment_new (34.0, 1.0, 64.0, 1.0, 1.0, 0.0); spin = gtk_spin_button_new (adjustment, 1.0, 0); gtk_container_add (GTK_CONTAINER (hbox), spin); adjustment = gtk_adjustment_new (16.0, 1.0, 64.0, 1.0, 1.0, 0.0); spin2 = gtk_spin_button_new (adjustment, 1.0, 0); gtk_container_add (GTK_CONTAINER (hbox), spin2); for (j = 0; j < 3; j++) { hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5); gtk_box_set_baseline_position (GTK_BOX (hbox), j); label = gtk_label_new (baseline_pos_str[j]); gtk_container_add (GTK_CONTAINER (hbox), label); gtk_widget_set_vexpand (label, TRUE); image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON); gtk_image_set_pixel_size (GTK_IMAGE (image), 34); gtk_container_add (GTK_CONTAINER (hbox), image); g_signal_connect (spin, "value-changed", (GCallback)image_size_value_changed, image); for (i = 0; i < 3; i++) { button = gtk_button_new_with_label ("│Xyj,Ö"); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (button, font); if (i != 0) gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); } for (i = 0; i < 3; i++) { button = gtk_button_new_with_label ("│Xyj,Ö"); image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); gtk_button_set_image (GTK_BUTTON (button), image); if (i == 0) g_signal_connect (spin2, "value-changed", (GCallback)image_size_value_changed, image); gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE); font = pango_font_description_new (); pango_font_description_set_size (font, 5*(i+1)* 1024); gtk_widget_override_font (button, font); gtk_widget_set_valign (button, GTK_ALIGN_BASELINE); gtk_container_add (GTK_CONTAINER (hbox), button); } } gtk_widget_show_all (window); gtk_main (); return 0; }
void gaiBerriaSartu() { GtkWidget *hBox, *vBox; GtkWidget *labela; GtkWidget *botoia; GtkWidget *frame; /* Lehioa sortu eta konfiguratu */ frmGaiBerriaSartu = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position (GTK_WINDOW (frmGaiBerriaSartu), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_modal (GTK_WINDOW (frmGaiBerriaSartu), TRUE); gtk_window_set_decorated (GTK_WINDOW (frmGaiBerriaSartu), FALSE); gtk_window_set_type_hint (GTK_WINDOW (frmGaiBerriaSartu), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_transient_for (GTK_WINDOW(frmGaiBerriaSartu), GTK_WINDOW(frmBodegatikElkartera)); frame = gtk_frame_new("Gai berria sartu"); gtk_container_add(GTK_CONTAINER(frmGaiBerriaSartu), frame); /* Sortutako frameGaiBerria bete */ vBox = gtk_vbox_new(TRUE, 5); gtk_container_add(GTK_CONTAINER(frame), vBox); /* Titulua */ labela = gtk_label_new("GAI BERRIAREN DATUAK"); gtk_box_pack_start(GTK_BOX(vBox), labela, TRUE, TRUE, 0); /* Gaiaren izena */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Gaiaren izena:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); txtIzena = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hBox), txtIzena, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Materiala */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Materiala:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); checkMateriala = gtk_check_button_new(); gtk_box_pack_start(GTK_BOX(hBox), checkMateriala, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Elkarteko prezioa */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Elkarteko prezioa:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); txtElkartekoPrezioa = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hBox), txtElkartekoPrezioa, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Dagokion aukera */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Dagokion aukera:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); cmbAukerak = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(hBox), cmbAukerak, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Erosketaren kopurua */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Erosketa kopurua:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); txtErosketaKop = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hBox), txtErosketaKop, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Eroskea prezioa unitateko */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Erosketa prezioa unitateko:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); txtErosketaPrezioaUnitateko = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hBox), txtErosketaPrezioaUnitateko, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Hornitzailea */ hBox = gtk_hbox_new(TRUE, 3); labela = gtk_label_new("Hornitzailea:"); gtk_box_pack_start(GTK_BOX(hBox), labela, FALSE, FALSE, 0); cmbHornitzaileak = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(hBox), cmbHornitzaileak, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Hornitzaile berria botoia */ botoia = gtk_button_new_with_label("Hornitzaile berria sartu"); g_signal_connect(G_OBJECT(botoia), "clicked", G_CALLBACK(btmHornitzaileBerria), NULL); gtk_box_pack_start(GTK_BOX(vBox), botoia, FALSE, FALSE, 0); /* Utzi eta Ados botoiak */ hBox = gtk_hbox_new(TRUE, 20); botoia = gtk_button_new_with_label("Utzi"); g_signal_connect(G_OBJECT(botoia), "clicked", G_CALLBACK(btmGaiBerriaUtzi), NULL); gtk_box_pack_start(GTK_BOX(hBox), botoia, TRUE, TRUE, 10); botoia = gtk_button_new_with_label("Ados"); g_signal_connect(G_OBJECT(botoia), "clicked", G_CALLBACK(btmGaiBerriaAdos), NULL); gtk_box_pack_start(GTK_BOX(hBox), botoia, TRUE, TRUE, 10); gtk_box_pack_start(GTK_BOX(vBox), hBox, FALSE, FALSE, 0); /* Dena bistaratu eta martxan jarri */ gtk_widget_show_all(frmGaiBerriaSartu); datuakKargatu(); gtk_main(); }
int main(int argc, char*argv[]) { extern char* optarg; extern int optind; extern int optopt; extern int opterr; int c; int i; int oindex; opterr = 0; recent_file_options_t options; recents_main_action_t action = RMA_NONE; char bad_option[2]="\0\0"; initialize_options(&options); gtk_init(&argc, &argv); /* Initialize GTK+ */ struct option cli_options[] = { {"quiet", 0, NULL, 'q'}, {"force", 0, NULL, 'f'}, {"add", 0, NULL, 'a'}, {"touch", 0, NULL, 't'}, {"clear", 0, NULL, 'c'}, {"help", 0, NULL, 'h'}, {NULL, 0, NULL, 0} }; while ((c = getopt_long (argc, argv, "qfatch", cli_options, &oindex)) != -1) { switch (c) { case 0: fatal (g_strconcat("Option ", optarg, " not recognized", NULL), 1); break; /* Not neccessary */ case '?': bad_option[0]=optopt; fatal (g_strconcat("Option -", bad_option, " not recognized", NULL), 1); break; /* Not neccesary */ case 'q': options.quiet = 1; break; case 'f': options.force = 1; break; case 'a': if (action != RMA_NONE) fatal ("Only one action can be performed", 1); action = RMA_INCLUDE; break; case 't': options.touchFile = 1; break; case 'c': if (action != RMA_NONE) fatal ("Only one action can be performed", 1); action = RMA_CLEAR; break; case 'h': action = RMA_HELP; /* Help will be shown without error */ break; default: fatal("Bad usage. Please read help below", 1); } } if (options.quiet) fprintf (stdout, "recents - basic recent files management from terminal\n" "by Gaspar Fernandez (2016) http://gaspar.totaki.com/\n\n"); /* This will exit on error */ check_config (&options, action, optind, argc); if (action == RMA_HELP) { help(); return 0; } else if (action == RMA_INCLUDE) { for (i=optind; i<argc; ++i) { options.fileNames = g_slist_append(options.fileNames, argv[i]); } g_idle_add(main_include_task, &options); } else if (action == RMA_CLEAR) { if (confirm_delete(&options)) g_idle_add(main_clear_task, &options); else return 2; } else exit(2); gtk_main(); return options.result; }
int main(int argc, char ** argv) { getopt_t *gopt = getopt_create(); getopt_add_bool (gopt, 'h', "help", 0, "Show help"); getopt_add_bool (gopt, '\0', "no-gtk", 0, "Don't show gtk window, only advertise remote connection"); getopt_add_string (gopt, '\0', "pnm", "", "Path for pnm file to render as texture (.e.g BlockM.pnm)"); getopt_add_bool (gopt, '\0', "stay-open", 0, "Stay open after gtk exits to continue handling remote connections"); // parse and print help if (!getopt_parse(gopt, argc, argv, 1) || getopt_get_bool(gopt,"help")) { printf ("Usage: %s [options]\n\n", argv[0]); getopt_do_usage (gopt); exit (1); } vx_global_init(); // Call this to initialize the vx-wide lock. Required to start the GL thread or to use the program library state_t * state = state_create(); // Load a pnm from file, and repack the data so that it's understandable by vx if (strcmp(getopt_get_string(gopt,"pnm"),"")) { state->img = image_u32_create_from_pnm(getopt_get_string(gopt, "pnm")); printf("Loaded image %d x %d from %s\n", state->img->width, state->img->height, getopt_get_string(gopt, "pnm")); } draw(state, state->world); vx_remote_display_source_attr_t remote_attr; vx_remote_display_source_attr_init(&remote_attr); remote_attr.advertise_name = "Vx Demo"; vx_remote_display_source_t * cxn = vx_remote_display_source_create_attr(&state->app, &remote_attr); pthread_create(&state->animate_thread, NULL, render_loop, state); if (!getopt_get_bool(gopt,"no-gtk")) { gdk_threads_init (); gdk_threads_enter (); gtk_init (&argc, &argv); vx_gtk_display_source_t * appwrap = vx_gtk_display_source_create(&state->app); GtkWidget * window = gtk_window_new (GTK_WINDOW_TOPLEVEL); GtkWidget * canvas = vx_gtk_display_source_get_widget(appwrap); gtk_window_set_default_size (GTK_WINDOW (window), 400, 400); gtk_container_add(GTK_CONTAINER(window), canvas); gtk_widget_show (window); gtk_widget_show (canvas); // XXX Show all causes errors! g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_main (); // Blocks as long as GTK window is open gdk_threads_leave (); vx_gtk_display_source_destroy(appwrap); // quit when gtk closes? Or wait for remote displays/Ctrl-C if (!getopt_get_bool(gopt, "stay-open")) state->running = 0; } pthread_join(state->animate_thread, NULL); vx_remote_display_source_destroy(cxn); state_destroy(state); vx_global_destroy(); getopt_destroy(gopt); }
gint main(gint argc, gchar **argv) { Conf *conf; gchar *stdin_data = NULL; bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); pub = g_malloc(sizeof(PublicData)); pub->fi = g_malloc(sizeof(FileInfo)); pub->fi->filename = NULL; pub->fi->charset = NULL; pub->fi->charset_flag = FALSE; pub->fi->lineend = LF; parse_args(argc, argv, pub->fi); #if !ENABLE_XINPUT2 gdk_disable_multidevice(); #endif gtk_init(&argc, &argv); g_set_application_name(PACKAGE_NAME); selection_primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY); pub->mw = create_main_window(); conf = g_malloc(sizeof(Conf)); conf->width = 600; conf->height = 400; conf->fontname = g_strdup("Monospace 12"); conf->wordwrap = FALSE; conf->linenumbers = FALSE; conf->autoindent = FALSE; load_config_file(conf); gtk_window_set_default_size( GTK_WINDOW(pub->mw->window), conf->width, conf->height); set_text_font_by_name(pub->mw->view, conf->fontname); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(pub->mw->menubar, "/M/Options/WordWrap")), conf->wordwrap); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(pub->mw->menubar, "/M/Options/LineNumbers")), conf->linenumbers); indent_refresh_tab_width(pub->mw->view); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( gtk_item_factory_get_widget(pub->mw->menubar, "/M/Options/AutoIndent")), conf->autoindent); gtk_widget_show_all(pub->mw->window); g_free(conf->fontname); g_free(conf); #if ENABLE_EMACS check_emacs_key_theme(GTK_WINDOW(pub->mw->window), pub->mw->menubar); #endif hlight_init(pub->mw->buffer); undo_init(pub->mw->view, gtk_item_factory_get_widget(pub->mw->menubar, "/M/Edit/Undo"), gtk_item_factory_get_widget(pub->mw->menubar, "/M/Edit/Redo")); // hlight_init(pub->mw->buffer); dnd_init(pub->mw->view); if (pub->fi->filename) file_open_real(pub->mw->view, pub->fi); #ifdef G_OS_UNIX else stdin_data = gedit_utils_get_stdin(); #endif if (stdin_data) { gchar *str; GtkTextIter iter; str = g_convert(stdin_data, -1, "UTF-8", get_default_charset(), NULL, NULL, NULL); g_free(stdin_data); // gtk_text_buffer_set_text(buffer, "", 0); gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter); gtk_text_buffer_insert(pub->mw->buffer, &iter, str, strlen(str)); gtk_text_buffer_get_start_iter(pub->mw->buffer, &iter); gtk_text_buffer_place_cursor(pub->mw->buffer, &iter); gtk_text_buffer_set_modified(pub->mw->buffer, FALSE); gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(pub->mw->view), &iter, 0, FALSE, 0, 0); g_free(str); } if (jump_linenum) { GtkTextIter iter; gtk_text_buffer_get_iter_at_line(pub->mw->buffer, &iter, jump_linenum - 1); gtk_text_buffer_place_cursor(pub->mw->buffer, &iter); // gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(textview), &iter, 0.1, FALSE, 0.5, 0.5); scroll_to_cursor(pub->mw->buffer, 0.25); } set_main_window_title(); indent_refresh_tab_width(pub->mw->view); // hlight_apply_all(pub->mw->buffer); gtk_main(); return 0; }
int main (int argc, char **argv) { UpgradeNotifier *un; GError *error = NULL; // init if(!gtk_init_with_args (&argc, &argv, _("- inform about updates"), entries, "update-notifier", &error) ) { fprintf(stderr, _("Failed to init the UI: %s\n"), error ? error->message : _("unknown error")); exit(1); } notify_init("update-notifier"); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); if (HOOK_DEBUG || UPDATE_DEBUG || INOTIFY_DEBUG || UEVENT_DEBUG || RELEASE_DEBUG || MISC_DEBUG) g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); // setup a custom debug log handler g_log_set_handler ("inotify", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("hooks", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("update", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("uevent", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("release", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_set_application_name (_("update-notifier")); gtk_window_set_default_icon_name ("update-notifier"); //g_print("starting update-notifier\n"); /* Create the UpgradeNotifier object */ un = g_new0 (UpgradeNotifier, 1); un->settings = g_settings_new(SETTINGS_SCHEMA); // do not run as system user (e.g. guest user) if (system_user(un) && !FORCE_START) { g_warning("not starting for system user"); exit(0); } // do not run as system user (e.g. guest user) if (FORCE_RELEASE_CHECK) g_settings_reset(un->settings, SETTINGS_KEY_LAST_RELEASE_CHECK); // check if it is running already if (!up_get_clipboard ()) { g_warning ("already running?"); return 1; } // check for update-notifier dir and create if needed gchar *dirname = g_strdup_printf("%s/update-notifier", g_get_user_config_dir()); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) g_mkdir(dirname, 0700); g_free(dirname); // delay icon creation for 30s so that the desktop // login is not slowed down by update-notifier g_timeout_add_seconds(STARTUP_DELAY, (GSourceFunc)(tray_icons_init), un); // initial check for avahi avahi_disabled_check(); /* setup inserted-cdroms checker */ if(!cdroms_init(un)) { g_warning("initializing cdroms failed"); } // init release checker release_checker_init(un); // init uevent monitoring (missing firmware, etc.) uevent_init(); // init gio file monitoring monitor_init (un); /* Start the main gtk loop */ g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, sigint_cb, NULL, NULL); gtk_main (); return 0; }
int main(int argc, char** argv) { //gtk wdiget init start... GtkWidget *window, *icon_view, *notebook; GtkWidget *current_user_name, *current_time, *network_speed; GtkWidget *home_button, *access_token_entry, *access_token_ok_button; GtkWidget *access_token_cancel_button; GtkWidget *get_access_token_button, *post_blog_title_entry; GtkWidget *post_blog_content_text_view, *post_blog_content_text_buffer; GtkWidget *post_blog_ok_button, *post_blog_cancel_button; GtkWidget *blog_access_permission, *blog_password; GList *post_blog_page = NULL; GtkBuilder *builder; GError *error = NULL; //widget init gtk_init(&argc, &argv); builder = gtk_builder_new(); if(!gtk_builder_add_from_file(builder, "./sources/glade.glade", &error)) { g_print("Error occured while loading UI files\n"); g_print("Message: %s\n", error->message); g_free(error); return 1; } //widget get from builder(glade files) window = GTK_WIDGET(gtk_builder_get_object(builder, "window")); notebook = GTK_WIDGET(gtk_builder_get_object(builder, "notebook1")); icon_view = GTK_WIDGET(gtk_builder_get_object(builder, "iconview1")); current_user_name = GTK_WIDGET(gtk_builder_get_object(builder,"label4")); current_time = GTK_WIDGET(gtk_builder_get_object(builder, "label5")); network_speed = GTK_WIDGET(gtk_builder_get_object(builder, "label6")); access_token_ok_button = GTK_WIDGET(gtk_builder_get_object(builder, "button3")); access_token_cancel_button = GTK_WIDGET(gtk_builder_get_object(builder, "button6")); get_access_token_button = GTK_WIDGET(gtk_builder_get_object(builder, "button2")); home_button = GTK_WIDGET(gtk_builder_get_object(builder, "button1")); access_token_entry = GTK_WIDGET(gtk_builder_get_object(builder, "entry1")); post_blog_content_text_view= GTK_WIDGET(gtk_builder_get_object(builder, "textview1")); post_blog_ok_button = GTK_WIDGET(gtk_builder_get_object(builder, "button4")); post_blog_title_entry = GTK_WIDGET(gtk_builder_get_object(builder, "entry2")); blog_access_permission = GTK_WIDGET(gtk_builder_get_object(builder, "comboboxtext1")); blog_password = GTK_WIDGET(gtk_builder_get_object(builder, "entry4")); //set object attributes gtk_window_set_title(GTK_WINDOW(window), "Xiao nei Gtk App"); gtk_window_set_default_size(GTK_WINDOW(window), 800, 400); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_icon_view_set_model(GTK_ICON_VIEW(icon_view), create_model()); gtk_icon_view_set_text_column(GTK_ICON_VIEW(icon_view), COL_DISPLAY_NAME); gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(icon_view), COL_PIXBUF); gtk_icon_view_set_columns(GTK_ICON_VIEW(icon_view), 4); gtk_label_set_text(GTK_LABEL(current_user_name), "Current user:fengtianba"); g_timeout_add_seconds(1, (GSourceFunc)set_label_time, current_time); gtk_label_set_text(GTK_LABEL(network_speed), "Network Speed:100M"); gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE); int n = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), icon_view); //gtk_combo_box_set_model(GTK_COMBO_BOX(blog_access_permission), create_combo_box_tree_model()); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "private", "PRIVATE"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "public", "PUBLIC"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "password", "PASSWORD"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(blog_access_permission), "friend", "FRIEND"); printf("n is %d\n", n); struct tm *time_ptr; time_t the_time; char *time_malloc; (void)time(&the_time); time_ptr = localtime(&the_time); time_malloc = malloc(sizeof(struct tm)); memset(time_malloc, 0, sizeof(struct tm)); sprintf(time_malloc, "%d/%d/%d/%d:%d:%d", 1900 + time_ptr->tm_year, time_ptr->tm_mon, time_ptr->tm_mday, time_ptr->tm_hour, time_ptr->tm_min, time_ptr->tm_sec); gtk_label_set_text(GTK_LABEL(current_time), time_malloc); post_blog_page = g_list_append(post_blog_page, post_blog_title_entry); post_blog_page = g_list_append(post_blog_page, post_blog_content_text_view); post_blog_page = g_list_append(post_blog_page, blog_access_permission); post_blog_page = g_list_append(post_blog_page, blog_password); //signal to connect to widget g_signal_connect(window, "delete-event", gtk_main_quit, NULL); g_signal_connect(GTK_BUTTON(get_access_token_button), "clicked", G_CALLBACK(get_access_token_button_clicked), NULL); g_signal_connect(GTK_ICON_VIEW(icon_view), "item-activated", G_CALLBACK(icon_view_item_select), notebook); g_signal_connect(GTK_BUTTON(home_button), "clicked", G_CALLBACK(home_button_clicked), notebook); g_signal_connect(GTK_BUTTON(access_token_ok_button), "clicked", G_CALLBACK(access_token_ok_button_clicked), access_token_entry); g_signal_connect(GTK_BUTTON(post_blog_ok_button), "clicked", G_CALLBACK(post_blog_ok_button_clicked), post_blog_page); //object unref g_object_unref(G_OBJECT(builder)); //show widget gtk_widget_show_all(window); gtk_main(); int i = 100; char *decode_string; /*CURL *curl; curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); decode_string = curl_easy_unescape(curl, ACCESS_TOKEN, 0, &i); printf("origin url: %s\n", ACCESS_TOKEN); printf("new url: %s\n", decode_string); curl_easy_cleanup(curl);*/ //puts("enter access token\n"); //scanf("%s", accesstoken); //调用自己写的SDK xiaonei_gtk_get_blog_list(accesstoken); xiaonei_gtk_get_one_blog(accesstoken); return (EXIT_SUCCESS); }
int main (int argc, char *argv[]) { GstElement *bin; GstElement *src, *spectrum, *audioconvert, *sink; GstBus *bus; GtkWidget *appwindow, *vbox, *widget; gst_init (&argc, &argv); gtk_init (&argc, &argv); bin = gst_pipeline_new ("bin"); src = gst_element_factory_make ("audiotestsrc", "src"); g_object_set (G_OBJECT (src), "wave", 0, NULL); spectrum = gst_element_factory_make ("spectrum", "spectrum"); g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80, "message", TRUE, NULL); audioconvert = gst_element_factory_make ("audioconvert", "audioconvert"); sink = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink"); gst_bin_add_many (GST_BIN (bin), src, spectrum, audioconvert, sink, NULL); if (!gst_element_link_many (src, spectrum, audioconvert, sink, NULL)) { fprintf (stderr, "can't link elements\n"); exit (1); } bus = gst_element_get_bus (bin); gst_bus_add_watch (bus, message_handler, NULL); gst_object_unref (bus); sync_clock = gst_pipeline_get_clock (GST_PIPELINE (bin)); appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (appwindow), "destroy", G_CALLBACK (on_window_destroy), NULL); vbox = gtk_vbox_new (FALSE, 6); widget = gtk_hscale_new_with_range (50.0, 20000.0, 10); gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE); gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP); gtk_range_set_value (GTK_RANGE (widget), 440.0); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_frequency_changed), (gpointer) src); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0); drawingarea = gtk_drawing_area_new (); gtk_widget_set_size_request (drawingarea, spect_bands, spect_height); g_signal_connect (G_OBJECT (drawingarea), "configure-event", G_CALLBACK (on_configure_event), (gpointer) spectrum); gtk_box_pack_start (GTK_BOX (vbox), drawingarea, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (appwindow), vbox); gtk_widget_show_all (appwindow); gst_element_set_state (bin, GST_STATE_PLAYING); gtk_main (); gst_element_set_state (bin, GST_STATE_NULL); gst_object_unref (sync_clock); gst_object_unref (bin); return 0; }
int main( int argc, char *argv[] ) { GtkWidget *mainbox, *hbox, *hbox2, *label,*pixmap_w; /* GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style;*/ init_pipes(); /* set all pipe data to 0 */ command_line_options(argc, argv); /* g_thread_init(NULL); no ide why I had to remove it */ gtk_init(&argc, &argv); gdk_rgb_init (); /* capturing_init = FALSE; playing = FALSE;*/ signal(SIGSEGV, signal_handler); signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); signal(SIGPIPE, signal_handler); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (destroy), NULL); gtk_window_set_title (GTK_WINDOW (window), "Linux Video Studio"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); mainbox = gtk_vbox_new(FALSE,0); gtk_container_add (GTK_CONTAINER (window), mainbox); gtk_widget_show (mainbox); make_menus(mainbox); notebook = gtk_notebook_new (); /* style = gtk_widget_get_style(window);*/ gtk_widget_realize(window); hbox = create_lavrec_layout(window); if (hbox != NULL) { hbox2 = gtk_hbox_new(FALSE, 10); /* pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], cam_xpm); pixmap_w = gtk_pixmap_new(pixmap, mask);*/ pixmap_w = gtk_widget_from_xpm_data(cam_xpm); gtk_widget_show(pixmap_w); gtk_box_pack_start(GTK_BOX(hbox2), pixmap_w, FALSE, FALSE, 0); label = gtk_label_new("Capture Video"); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hbox, hbox2); gtk_widget_show(hbox); gtk_widget_show(hbox2); } hbox = create_lavedit_layout(window); hbox2 = gtk_hbox_new(FALSE, 10); /* pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], editing_xpm); pixmap_w = gtk_pixmap_new(pixmap, mask);*/ pixmap_w = gtk_widget_from_xpm_data(editing_xpm); gtk_widget_show(pixmap_w); gtk_box_pack_start(GTK_BOX(hbox2), pixmap_w, FALSE, FALSE, 0); label = gtk_label_new("Edit Video"); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hbox, hbox2); gtk_widget_show(hbox); gtk_widget_show(hbox2); hbox = create_lavplay_layout(); if (hbox != NULL) { hbox2 = gtk_hbox_new(FALSE, 10); /* pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], tv_xpm); pixmap_w = gtk_pixmap_new(pixmap, mask);*/ pixmap_w = gtk_widget_from_xpm_data(tv_xpm); gtk_widget_show(pixmap_w); gtk_box_pack_start(GTK_BOX(hbox2), pixmap_w, FALSE, FALSE, 0); label = gtk_label_new("Playback Video"); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hbox, hbox2); gtk_widget_show(hbox); gtk_widget_show(hbox2); } /* New notebook entry for encoding */ hbox = create_lavencode_layout(); hbox2 = gtk_hbox_new(FALSE, 10); /* pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], arrows_xpm); pixmap_w = gtk_pixmap_new(pixmap, mask);*/ pixmap_w = gtk_widget_from_xpm_data(arrows_xpm); gtk_widget_show(pixmap_w); gtk_box_pack_start(GTK_BOX(hbox2), pixmap_w, FALSE, FALSE, 0); label = gtk_label_new("Encode Video"); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hbox, hbox2); gtk_widget_show(hbox); gtk_widget_show(hbox2); hbox = gtk_hbox_new(FALSE,5); gtk_box_pack_start(GTK_BOX(hbox), notebook, FALSE, FALSE, 5); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); gtk_widget_show(notebook); gtk_box_pack_start(GTK_BOX(mainbox), hbox, FALSE, FALSE, 5); gtk_widget_show(hbox); gtk_signal_connect(GTK_OBJECT(notebook), "switch_page", GTK_SIGNAL_FUNC(notebook_page_switched),NULL); gtk_widget_show(window); if (verbose) g_print("Linux Video Studio initialized correctly\n"); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); return 0; }
int main( int argc, char *argv[] ) { GtkWidget *window = NULL; GtkWidget *box1; GtkWidget *box2; GtkWidget *button; GtkWidget *separator; GSList *group; gtk_init(&argc,&argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC(close_application), NULL); gtk_window_set_title (GTK_WINDOW (window), "radio buttons"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); box1 = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); gtk_widget_show (box1); box2 = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); gtk_widget_show (box2); button = gtk_radio_button_new_with_label (NULL, "button1"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); group = gtk_radio_button_group (GTK_RADIO_BUTTON (button)); button = gtk_radio_button_new_with_label(group, "button2"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); button = gtk_radio_button_new_with_label( gtk_radio_button_group (GTK_RADIO_BUTTON (button)), "button3"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); separator = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); gtk_widget_show (separator); box2 = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); gtk_widget_show (box2); button = gtk_button_new_with_label ("close"); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(close_application), GTK_OBJECT (window)); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_widget_grab_default (button); gtk_widget_show (button); gtk_widget_show (window); gtk_main(); return(0); }
int main (int argc, char **argv) { state_t * self = (state_t*) calloc (1, sizeof (state_t)); self->use_gui = 1; char *optstring = "hc:p:"; int c; struct option long_opts[] = { { "help", no_argument, 0, 'h' }, { "chain", required_argument, 0, 'c' }, { "plugin-path", required_argument, 0, 'p' }, { "no-gui", no_argument, 0, 'u' }, { 0, 0, 0, 0 } }; while ((c = getopt_long (argc, argv, optstring, long_opts, 0)) >= 0) { switch (c) { case 'c': self->xml_fname = strdup (optarg); break; case 'u': self->use_gui = 0; break; case 'p': self->extra_plugin_path = strdup (optarg); break; case 'h': default: usage (); break; }; } if (!self->use_gui && !self->xml_fname) usage(); if (self->use_gui) { gtk_init (&argc, &argv); } else { g_type_init (); } if (!g_thread_supported()) { g_thread_init (NULL); } if (0 != state_setup (self)) { state_cleanup(self); return 1; } if (self->use_gui) { camview_gtk_quit_on_interrupt (); gtk_main (); state_cleanup (self); } else { // did everything start up correctly? CamUnit *faulty = cam_unit_chain_all_units_stream_init(self->chain); if (faulty) { int faulty_index = 0; for(GList *uiter = cam_unit_chain_get_units(self->chain); uiter && uiter->data != faulty; uiter = uiter->next) faulty_index ++; fprintf(stderr, "Unit %d [%s] is not streaming, aborting...\n", faulty_index, cam_unit_get_name (faulty)); return -1; } GMainLoop *mainloop = g_main_loop_new (NULL, FALSE); camview_g_quit_on_interrupt (mainloop); g_main_loop_run (mainloop); g_main_loop_unref (mainloop); state_cleanup (self); } return 0; }
int main( int argc, char *argv[]) #endif { // command_line_path = argv[0]; // g_debug ("argc = %d", argc); // print_array ("argv", argv); // i18n support. We need to support i18n under console, too. setlocale(LC_ALL, ""); bindtextdomain (BINARY, LOCALEDIR); bind_textdomain_codeset (BINARY, "UTF-8"); textdomain (BINARY); const gchar *user_config_dir = g_get_user_config_dir(); #if ! defined(SAFEMODE) && defined(DEVELOP) g_message("Running %s without SAFE MODE!", PACKAGE); #endif #ifdef OUT_OF_MEMORY # undef g_strdup_printf #endif if (user_config_dir) profile_dir = g_strdup_printf("%s/%s", user_config_dir, BINARY); #ifdef OUT_OF_MEMORY #define g_strdup_printf(...) NULL #endif proc_exist = check_if_default_proc_dir_exist(NULL); // g_debug ("Get proc_exist = %d, proc_file_system_path = %s", proc_exist, proc_file_system_path); shell = g_getenv("SHELL"); if (shell==NULL) shell = ""; gboolean pwd_need_be_free = FALSE; pwd = (gchar *)g_getenv("PWD"); if (pwd==NULL) { pwd_need_be_free = TRUE; pwd = g_get_current_dir(); } if (pwd==NULL) { pwd_need_be_free = FALSE; pwd = ""; } // g_debug("Got $PWD = %s", pwd); home = g_getenv("HOME"); if (home==NULL) home = ""; // g_debug("Get $HOME = %s", home); // deal the command line options command_option(argc, argv); if (wmclass_name==NULL) wmclass_name = g_getenv("RESOURCE_NAME"); if (wmclass_name==NULL) wmclass_name = ""; if (wmclass_class==NULL) wmclass_class = ""; // g_debug("Got wmclass_name = %s, wmclass_class = %s", wmclass_name, wmclass_class); // init the gtk+2 engine // GTK3: get gtk_test_widget_click() working... // gdk_disable_multidevice(); #ifndef UNIT_TEST gtk_init(&argc, &argv); #endif // FIXME: we should get the single_process from profile. Current is command-line option only. if (single_process) { // init socket data if (init_socket_data()) { // trying to connect to an existing LilyTerm if (query_socket()) { // success, sent the argc/argv to socket then quit // g_debug("A LilyTerm socket server is exist already. exiting..."); if (send_socket(argc, argv, TRUE)) { g_free(profile_dir); exit (0); } } // no LilyTerm exist. create a socket server // g_debug("Creating a LilyTerm socket server..."); init_socket_server(); g_atexit((GVoidFunc)shutdown_socket_server); } } // start LilyTerm // empty_environ = g_strsplit("", " ", -1); extern gchar **environ; // print_array("main(): environ", environ); gchar *environ_str = convert_array_to_string(environ, '\t'); window_list = NULL; // g_debug("Got environ_str (in main.c) = %s", environ_str); selection_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); selection_primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY); system_locale_list = get_locale_list(); // g_debug("Got system_locale_list = %s", system_locale_list); init_LC_CTYPE = g_strdup(get_default_lc_data(LC_CTYPE)); // g_debug("Got init_LC_CTYPE = %s", init_LC_CTYPE); init_LANGUAGE = g_strdup(get_default_lc_data(LANGUAGE)); // g_debug("Got init_LANGUAGE = %s", init_LANGUAGE); init_LC_MESSAGES = g_strdup(get_default_lc_data(LC_MESSAGES)); // g_debug("init_LC_MESSAGES = %s", init_LC_MESSAGES); init_encoding = (gchar *)get_encoding_from_locale(NULL); if (! compare_strings(init_encoding, "ANSI_X3.4-1968", TRUE)) { g_free(init_encoding); init_encoding = g_strdup("UTF-8"); } // g_debug("init_encoding = %s", init_encoding); SYSTEM_VTE_CJK_WIDTH_STR = g_getenv("VTE_CJK_WIDTH"); // g_debug ("Got SYSTEM_VTE_CJK_WIDTH_STR = %s", SYSTEM_VTE_CJK_WIDTH_STR); // FIXME: signal(SIGCHLD, SIG_IGN); // The first window of LilyTerm // Convert the GdkColor to GdkRGBA convert_system_color_to_rgba(); // g_debug("Got original encoding = %s", get_encoding_from_locale(NULL)); //GtkNotebook *new_window(int argc, // char *argv[], // gchar *shell, // gchar *environment, // gchar *locale_list, // gchar *PWD, // gchar *HOME, // gchar *VTE_CJK_WIDTH_STR, // gboolean VTE_CJK_WIDTH_STR_overwrite_profile, // gchar *wmclass_name, // gchar *wmclass_class, // gchar *user_environ, // gchar *encoding, // gboolean encoding_overwrite_profile, // gchar *lc_messages, // struct Window *win_data_orig, // struct Page *page_data_orig) if ((new_window(argc, argv, (gchar *) shell, environ_str, system_locale_list, (gchar *) pwd, (gchar *) home, SYSTEM_VTE_CJK_WIDTH_STR, FALSE, wmclass_name, wmclass_class, NULL, init_encoding, FALSE, init_LC_MESSAGES, NULL, NULL)) || window_list) { // The argv of "main" LilyTerm can't be free. // Set it to NULL here to avoid double_free(). argv=NULL; #ifdef ENABLE_X_STARTUP_NOTIFICATION_ID gdk_notify_startup_complete_with_id(PACKAGE); #endif // g_debug("gtk_main_level = %d", gtk_main_level()); if (! gtk_main_level()) gtk_main(); } #ifdef DETAIL else { // g_debug("Got window_list = %p", window_list); // GList *win_list = window_list; // gint i=0; // // while (win_list) // { // g_debug("Got %d win_data = %p", ++i, win_list->data); // win_list = win_list->next; // } g_debug("??? The creation of first window is FAIL!!!"); } #endif extern struct KeyValue system_keys[KEYS]; gint i; // g_debug("Clear function key data!!"); for (i=KEY_SWITCH_TO_TAB_1; i<=KEY_SWITCH_TO_TAB_12; i++) { g_free(system_keys[i].name); g_free(system_keys[i].topic); g_free(system_keys[i].comment); g_free(system_keys[i].translation); #ifdef UNIT_TEST system_keys[i].name = NULL; system_keys[i].topic = NULL; system_keys[i].comment = NULL; system_keys[i].translation = NULL; #endif } // g_free(pwd); // g_strfreev(empty_environ); g_free(environ_str); g_free(init_encoding); g_free(system_locale_list); g_free(profile_dir); if (pwd_need_be_free) g_free(pwd); g_free(restricted_locale_message); g_list_free(window_list); g_free(init_LC_CTYPE); g_free(init_LC_MESSAGES); #ifdef UNIT_TEST // empty_environ = NULL; environ_str = NULL; init_encoding = NULL; system_locale_list = NULL; profile_dir = NULL; restricted_locale_message = NULL; window_list = NULL; init_LC_CTYPE = NULL; init_LC_MESSAGES = NULL; #endif return 0; }
int main (int argc, char *argv[]) { GstElement *bin; GstElement *src, *capsfilter, *equalizer, *spectrum, *audioconvert, *sink; GstCaps *caps; GstBus *bus; GtkWidget *appwindow, *vbox, *hbox, *widget; int i; gst_init (&argc, &argv); gtk_init (&argc, &argv); bin = gst_pipeline_new ("bin"); /* White noise */ src = gst_element_factory_make ("audiotestsrc", "src"); g_object_set (G_OBJECT (src), "wave", 5, "volume", 0.8, NULL); /* Force float32 samples */ capsfilter = gst_element_factory_make ("capsfilter", "capsfilter"); caps = gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 32, NULL); g_object_set (capsfilter, "caps", caps, NULL); equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer"); g_object_set (G_OBJECT (equalizer), "num-bands", NBANDS, NULL); spectrum = gst_element_factory_make ("spectrum", "spectrum"); g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80, "message", TRUE, "interval", 500 * GST_MSECOND, NULL); audioconvert = gst_element_factory_make ("audioconvert", "audioconvert"); sink = gst_element_factory_make ("autoaudiosink", "sink"); gst_bin_add_many (GST_BIN (bin), src, capsfilter, equalizer, spectrum, audioconvert, sink, NULL); if (!gst_element_link_many (src, capsfilter, equalizer, spectrum, audioconvert, sink, NULL)) { fprintf (stderr, "can't link elements\n"); exit (1); } bus = gst_element_get_bus (bin); gst_bus_add_watch (bus, message_handler, NULL); gst_object_unref (bus); appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (appwindow), "destroy", G_CALLBACK (on_window_destroy), NULL); vbox = gtk_vbox_new (FALSE, 6); drawingarea = gtk_drawing_area_new (); gtk_widget_set_size_request (drawingarea, spect_bands, spect_height); g_signal_connect (G_OBJECT (drawingarea), "configure-event", G_CALLBACK (on_configure_event), (gpointer) spectrum); gtk_box_pack_start (GTK_BOX (vbox), drawingarea, TRUE, TRUE, 0); hbox = gtk_hbox_new (FALSE, 20); for (i = 0; i < NBANDS; i++) { GstObject *band; gdouble freq; gdouble bw; gdouble gain; gchar *label; GtkWidget *frame, *scales_hbox; band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); g_assert (band != NULL); g_object_get (G_OBJECT (band), "freq", &freq, NULL); g_object_get (G_OBJECT (band), "bandwidth", &bw, NULL); g_object_get (G_OBJECT (band), "gain", &gain, NULL); label = g_strdup_printf ("%d Hz", (int) (freq + 0.5)); frame = gtk_frame_new (label); g_free (label); scales_hbox = gtk_hbox_new (FALSE, 6); widget = gtk_vscale_new_with_range (-24.0, 12.0, 0.5); gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE); gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP); gtk_range_set_value (GTK_RANGE (widget), gain); gtk_widget_set_size_request (widget, 25, 150); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_gain_changed), (gpointer) band); gtk_box_pack_start (GTK_BOX (scales_hbox), widget, FALSE, FALSE, 0); widget = gtk_vscale_new_with_range (0.0, 20000.0, 5.0); gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE); gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP); gtk_range_set_value (GTK_RANGE (widget), bw); gtk_widget_set_size_request (widget, 25, 150); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_bandwidth_changed), (gpointer) band); gtk_box_pack_start (GTK_BOX (scales_hbox), widget, TRUE, TRUE, 0); widget = gtk_vscale_new_with_range (20.0, 20000.0, 5.0); gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE); gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP); gtk_range_set_value (GTK_RANGE (widget), freq); gtk_widget_set_size_request (widget, 25, 150); g_signal_connect (G_OBJECT (widget), "value-changed", G_CALLBACK (on_freq_changed), (gpointer) band); gtk_box_pack_start (GTK_BOX (scales_hbox), widget, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (frame), scales_hbox); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); } gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (appwindow), vbox); gtk_widget_show_all (appwindow); gst_element_set_state (bin, GST_STATE_PLAYING); gtk_main (); gst_element_set_state (bin, GST_STATE_NULL); gst_object_unref (bin); return 0; }
int main(int argc, char** argv) { GtkWidget *edit; GtkWidget *label; GtkWidget *window; GtkWidget *frame; GtkWidget *plus; GtkWidget *minus; GtkWidget *image; GtkWidget *grid; GtkWidget *inner_grid; unsigned x, y; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(window), 500, 500); gtk_window_set_title(GTK_WINDOW(window), "+-"); frame = gtk_fixed_new(); /* gtk_container_add(GTK_CONTAINER(window), frame); */ grid = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(window), grid); plus = gtk_button_new_with_label("+"); gtk_widget_set_size_request(plus, 80, 35); gtk_grid_attach(GTK_GRID(grid), plus, 0, 0, 1, 1); minus = gtk_button_new_with_label("-"); gtk_widget_set_size_request(minus, 80, 35); gtk_grid_attach(GTK_GRID(grid), minus, 1, 0, 1, 1); label = gtk_label_new("0"); gtk_grid_attach(GTK_GRID(grid), label, 2, 1, 1, 1); edit = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(edit), "0"); gtk_grid_attach(GTK_GRID(grid), edit, 2, 0, 1, 1); image = gtk_image_new_from_file ("red_dot.png"); gtk_grid_attach(GTK_GRID(grid), image, 3, 0, 1, 1); inner_grid = gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), inner_grid, 3, 3, 10, 10); gtk_grid_set_column_spacing(GTK_GRID(inner_grid), 5); for (x = 0; x < 5; ++x) { image = gtk_image_new_from_file ("red_dot.png"); gtk_grid_attach(GTK_GRID(inner_grid), image, x, 0, 1, 1); } gtk_widget_show_all(window); g_signal_connect(window, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect(plus, "clicked", G_CALLBACK(increase), label); g_signal_connect(plus, "clicked", G_CALLBACK(increase_edit), edit); g_signal_connect(minus, "clicked", G_CALLBACK(decrease), label); g_signal_connect(minus, "clicked", G_CALLBACK(decrease_edit), edit); g_signal_connect(label, "move-cursor", G_CALLBACK(increase), label); gtk_main(); return 0; }
int l_vmat(int *kodv,//выбранный код int kodgr, //Код группы для которой ищем записи int metkarr, //0-работа со списком товаров 1-списком услуг GtkWidget *wpredok) { vmat_data data; char strsql[300]; //GdkColor color; SQLCURSOR cur; SQL_str row; printf("l_vmat %d\n",kodgr); data.kodgr=kodgr; data.metkarr=metkarr; if(metkarr == 0) sprintf(strsql,"select naik from Grup where kod=%d",kodgr); if(metkarr == 1) sprintf(strsql,"select naik from Uslgrup where kod=%d",kodgr); if(sql_readkey(&bd,strsql,&row,&cur) == 1) data.naigr.new_plus(row[0]); data.window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(data.window),TRUE); gtk_window_set_default_size (GTK_WINDOW (data.window),600,600); //gdk_color_parse("black",&color); //gtk_widget_modify_bg(data.window,GTK_STATE_NORMAL,&color); if(metkarr == 0) sprintf(strsql,"%s %s",name_system,gettext("Список товаров")); if(metkarr == 1) sprintf(strsql,"%s %s",name_system,gettext("Список услуг")); gtk_window_set_title (GTK_WINDOW (data.window),strsql); gtk_container_set_border_width (GTK_CONTAINER (data.window), 5); gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL); gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL); if(wpredok != NULL) { //Удерживать окно над породившем его окном всегда gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok)); //Закрыть окно если окно предок удалено gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE); } gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(vmat_key_press),&data); gtk_signal_connect_after(GTK_OBJECT(data.window),"key_release_event",GTK_SIGNAL_FUNC(iceb_key_release),&data.kl_shift); GtkWidget *hbox = gtk_hbox_new (FALSE, 1); gtk_container_add (GTK_CONTAINER (data.window), hbox); GtkWidget *vbox1 = gtk_vbox_new (FALSE, 1); GtkWidget *vbox2 = gtk_vbox_new (FALSE, 1); gtk_box_pack_start (GTK_BOX (hbox), vbox1, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); gtk_widget_show(hbox); data.label_kolstr=gtk_label_new (gettext("Выберите нужную запись")); //gdk_color_parse("green",&color); //gtk_widget_modify_fg(data.label_kolstr,GTK_STATE_NORMAL,&color); gtk_box_pack_start (GTK_BOX (vbox2),data.label_kolstr,FALSE, FALSE, 0); gtk_widget_show(vbox1); gtk_widget_show(vbox2); data.sw = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_usize(GTK_WIDGET(data.sw),400,300); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (data.sw),GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (data.sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); //gtk_box_pack_start (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0); //Кнопки GtkTooltips *tooltips[KOL_F_KL]; sprintf(strsql,"F2 %s",gettext("Выбор")); data.knopka[FK2]=gtk_button_new_with_label(strsql); gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK2], TRUE, TRUE, 0); gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]), "clicked",GTK_SIGNAL_FUNC(vmat_knopka),&data); tooltips[FK2]=gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Выбор отмеченной записи"),NULL); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2); gtk_widget_show(data.knopka[FK2]); GtkWidget *arrow=gtk_arrow_new(GTK_ARROW_UP,GTK_SHADOW_OUT); //sprintf(strsql,"%s",gettext("Вверх")); //data.knopka[FK_VVERH]=gtk_button_new_with_label(strsql); data.knopka[FK_VVERH]=gtk_button_new(); gtk_container_add(GTK_CONTAINER(data.knopka[FK_VVERH]),arrow); gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK_VVERH], TRUE, TRUE, 0); //gtk_signal_connect(GTK_OBJECT(data.knopka[FK_VVERH]), "clicked",GTK_SIGNAL_FUNC(vmat_knopka),&data); gtk_signal_connect(GTK_OBJECT(data.knopka[FK_VVERH]), "pressed",GTK_SIGNAL_FUNC(l_vmat_knopka_vverh_press),&data); gtk_signal_connect(GTK_OBJECT(data.knopka[FK_VVERH]), "released",GTK_SIGNAL_FUNC(l_vmat_knopka_released),&data); //tooltips[FK_VVERH]=gtk_tooltips_new(); //gtk_tooltips_set_tip(tooltips[FK_VVERH],data.knopka[FK_VVERH],gettext("Выбор отмеченной записи"),NULL); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK_VVERH]),(gpointer)FK_VVERH); gtk_widget_show(data.knopka[FK_VVERH]); gtk_widget_show(arrow); arrow=gtk_arrow_new(GTK_ARROW_DOWN,GTK_SHADOW_OUT); //sprintf(strsql,"%s",gettext("Вниз")); //data.knopka[FK_VNIZ]=gtk_button_new_with_label(strsql); data.knopka[FK_VNIZ]=gtk_button_new(); gtk_container_add(GTK_CONTAINER(data.knopka[FK_VNIZ]),arrow); gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK_VNIZ], TRUE, TRUE, 0); //gtk_signal_connect(GTK_OBJECT(data.knopka[FK_VNIZ]), "clicked",GTK_SIGNAL_FUNC(vmat_knopka),&data); gtk_signal_connect(GTK_OBJECT(data.knopka[FK_VNIZ]), "pressed",GTK_SIGNAL_FUNC(l_vmat_knopka_vniz_press),&data); gtk_signal_connect(GTK_OBJECT(data.knopka[FK_VNIZ]), "released",GTK_SIGNAL_FUNC(l_vmat_knopka_released),&data); //tooltips[FK_VNIZ]=gtk_tooltips_new(); //gtk_tooltips_set_tip(tooltips[FK_VNIZ],data.knopka[FK_VNIZ],gettext("Выбор отмеченной записи"),NULL); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK_VNIZ]),(gpointer)FK_VNIZ); gtk_widget_show(data.knopka[FK_VNIZ]); gtk_widget_show(arrow); sprintf(strsql,"F10 %s",gettext("Выход")); data.knopka[FK10]=gtk_button_new_with_label(strsql); gtk_box_pack_start(GTK_BOX(vbox1),data.knopka[FK10],TRUE,TRUE, 0); tooltips[FK10]=gtk_tooltips_new(); gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Завершение работы в этом окне"),NULL); gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]), "clicked",GTK_SIGNAL_FUNC(vmat_knopka),&data); gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10); gtk_widget_show(data.knopka[FK10]); gtk_widget_realize(data.window); gdk_window_set_cursor(data.window->window,gdk_cursor_new(ICEB_CURSOR)); gtk_widget_grab_focus(data.knopka[FK10]); vmat_create_list (&data); //gtk_window_maximize(GTK_WINDOW(data.window)); //gtk_window_fullscreen(GTK_WINDOW(data.window)); gtk_widget_show(data.window); gtk_main(); printf("l_vmat end\n"); *kodv=atoi(data.kod.ravno()); return(data.voz); }
gint main (gint argc, gchar ** argv) { GtkWidget *window, *revealer, *box, *widget, *entry; gtk_init (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window, 300, 300); box = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), box); widget = gtk_label_new ("Some filler text to avoid\nresizing of the window"); gtk_widget_set_margin_top (widget, 10); gtk_widget_set_margin_bottom (widget, 10); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_grid_attach (GTK_GRID (box), widget, 1, 1, 1, 1); widget = gtk_label_new ("Some filler text to avoid\nresizing of the window"); gtk_widget_set_margin_top (widget, 10); gtk_widget_set_margin_bottom (widget, 10); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_grid_attach (GTK_GRID (box), widget, 3, 3, 1, 1); widget = gtk_toggle_button_new_with_label ("None"); gtk_grid_attach (GTK_GRID (box), widget, 0, 0, 1, 1); revealer = gtk_revealer_new (); gtk_widget_set_halign (revealer, GTK_ALIGN_START); gtk_widget_set_valign (revealer, GTK_ALIGN_START); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "00000"); gtk_container_add (GTK_CONTAINER (revealer), entry); g_object_bind_property (widget, "active", revealer, "reveal-child", 0); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_NONE); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 2000); gtk_grid_attach (GTK_GRID (box), revealer, 1, 0, 1, 1); widget = gtk_toggle_button_new_with_label ("Fade"); gtk_grid_attach (GTK_GRID (box), widget, 4, 4, 1, 1); revealer = gtk_revealer_new (); gtk_widget_set_halign (revealer, GTK_ALIGN_END); gtk_widget_set_valign (revealer, GTK_ALIGN_END); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "00000"); gtk_container_add (GTK_CONTAINER (revealer), entry); g_object_bind_property (widget, "active", revealer, "reveal-child", 0); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 2000); gtk_grid_attach (GTK_GRID (box), revealer, 3, 4, 1, 1); widget = gtk_toggle_button_new_with_label ("Right"); gtk_grid_attach (GTK_GRID (box), widget, 0, 2, 1, 1); revealer = gtk_revealer_new (); gtk_widget_set_hexpand (revealer, TRUE); gtk_widget_set_halign (revealer, GTK_ALIGN_START); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "12345"); gtk_container_add (GTK_CONTAINER (revealer), entry); g_object_bind_property (widget, "active", revealer, "reveal-child", 0); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 2000); gtk_grid_attach (GTK_GRID (box), revealer, 1, 2, 1, 1); widget = gtk_toggle_button_new_with_label ("Down"); gtk_grid_attach (GTK_GRID (box), widget, 2, 0, 1, 1); revealer = gtk_revealer_new (); gtk_widget_set_vexpand (revealer, TRUE); gtk_widget_set_valign (revealer, GTK_ALIGN_START); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "23456"); gtk_container_add (GTK_CONTAINER (revealer), entry); g_object_bind_property (widget, "active", revealer, "reveal-child", 0); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 2000); gtk_grid_attach (GTK_GRID (box), revealer, 2, 1, 1, 1); widget = gtk_toggle_button_new_with_label ("Left"); gtk_grid_attach (GTK_GRID (box), widget, 4, 2, 1, 1); revealer = gtk_revealer_new (); gtk_widget_set_hexpand (revealer, TRUE); gtk_widget_set_halign (revealer, GTK_ALIGN_END); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "34567"); gtk_container_add (GTK_CONTAINER (revealer), entry); g_object_bind_property (widget, "active", revealer, "reveal-child", 0); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 2000); gtk_grid_attach (GTK_GRID (box), revealer, 3, 2, 1, 1); widget = gtk_toggle_button_new_with_label ("Up"); gtk_grid_attach (GTK_GRID (box), widget, 2, 4, 1, 1); revealer = gtk_revealer_new (); gtk_widget_set_vexpand (revealer, TRUE); gtk_widget_set_valign (revealer, GTK_ALIGN_END); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), "45678"); gtk_container_add (GTK_CONTAINER (revealer), entry); g_object_bind_property (widget, "active", revealer, "reveal-child", 0); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP); gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 2000); gtk_grid_attach (GTK_GRID (box), revealer, 2, 3, 1, 1); gtk_widget_show (window); gtk_main (); gtk_widget_destroy (window); return 0; }
int main ( int argc, char** argv) { int s = sizeof(local_uav); gtk_init(&argc, &argv); if (argc < 3) { printf("Use: ivy2serial ac_id serial_device\n"); printf("or\n"); printf("Use: ivy2serial ac_id serial_device xbee_power_level [0-4] to configure the xbee as broadcast, no retries\n"); return -1; } if (argc == 4) { printf("Programming XBee Modem\n"); power_level = (int) (argv[3][0]) - (int) '0'; if (power_level < 0) power_level = 0; else if (power_level > 4) power_level = 4; printf("Set Power Level To: '%d'\n", power_level); } else { power_level = -1; } local_uav.ac_id = atoi(argv[1]); sprintf(status_str, "Listening to AC=%d, Serial Data Size = %d",local_uav.ac_id, s); sprintf(status_ivy_str, "---"); sprintf(status_serial_str, "---"); printf("%s\n",status_str); // Open Serial or Die port = argv[2]; open_port(port); // Init UAV remote_uav.ac_id = 6; remote_uav.phi = 1000; remote_uav.theta = 200; remote_uav.psi = -3140; // Start IVY IvyInit ("IVY <-> Serial", "IVY <-> Serial READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_Desired, NULL, "^%d DESIRED (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); IvyBindMsg(on_Estimator, NULL, "^%d ESTIMATOR (\\S*) (\\S*)",local_uav.ac_id); IvyBindMsg(on_Navigation, NULL, "^%d NAVIGATION (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); IvyBindMsg(on_Attitude, NULL, "^%d ATTITUDE (\\S*) (\\S*) (\\S*)", local_uav.ac_id); IvyBindMsg(on_Gps, NULL, "^%d GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); IvyStart("127.255.255.255"); // Add Timer gtk_timeout_add(delay / 4, timeout_callback, NULL); // GTK Window GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "IVY_Serial_Bridge"); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); GtkWidget *box = gtk_vbox_new(TRUE, 1); gtk_container_add (GTK_CONTAINER (window), box); GtkWidget *hbox = gtk_hbox_new(FALSE, 1); gtk_container_add (GTK_CONTAINER (box), hbox); status = gtk_label_new( "Status:" ); gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT ); status = gtk_label_new( status_str ); gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT ); hbox = gtk_hbox_new(FALSE, 1); gtk_container_add (GTK_CONTAINER (box), hbox); status_ivy = gtk_label_new( "IVY->SERIAL:" ); gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT ); status_ivy = gtk_label_new( status_ivy_str ); gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT ); hbox = gtk_hbox_new(FALSE, 1); gtk_container_add (GTK_CONTAINER (box), hbox); status_serial = gtk_label_new( "SERIAL->IVY:" ); gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status_serial, GTK_JUSTIFY_LEFT ); status_serial = gtk_label_new( status_serial_str ); gtk_label_set_justify( GTK_LABEL(status_serial), GTK_JUSTIFY_LEFT ); gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1); gtk_widget_show_all(window); gtk_main(); // Clean up fprintf(stderr,"Stopping\n"); return 0; }