static void connect_dialog_init (ConnectDialog *dialog) { gchar *path = locate_data_file ("connect-dialog.glade"); g_assert(path != NULL); GtkBuilder *xml = gtk_builder_new (); g_assert (gtk_builder_add_from_file ( xml, path, NULL) != 0); g_free (path); #define GW(name) ((dialog->name) = GTK_WIDGET (gtk_builder_get_object (xml, #name))) GW(toplevel); GW(server_list); #undef GW g_object_unref (xml); dialog->server_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->server_list), GTK_TREE_MODEL (dialog->server_store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes ("name", renderer, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->server_list), column); GtkWidget *button = gtk_button_new_with_mnemonic (_("C_onnect")); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK); gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); GtkWidget *content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_widget_reparent (dialog->toplevel, content_area); g_signal_connect (G_OBJECT (dialog->server_list), "row-activated", G_CALLBACK (row_activated), dialog); g_signal_connect ( G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->server_list))), "changed", G_CALLBACK (selection_changed), dialog); for (GSList *netlist = network_list; netlist; netlist = g_slist_next (netlist)) { GtkTreeIter iter; ircnet *net = netlist->data; gtk_list_store_append (dialog->server_store, &iter); gtk_list_store_set (dialog->server_store, &iter, 0, net->name, 1, net, -1); } gtk_window_set_default_size (GTK_WINDOW (dialog), 320, 240); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_window_set_title (GTK_WINDOW (dialog), _("Connect")); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (dialog_response), NULL); g_signal_connect (G_OBJECT (dialog), "key-press-event", G_CALLBACK (dialog_escape_key_handler_destroy), NULL); }
//****************************************** // Compute the value that will not change // (duration) // and init the entries for current bitrate //****************************************** void prepare( void ) { #if 0 float duration=0; aviInfo info; char string[200]; uint16_t mm,hh,ss,ms; AVDMGenericAudioStream *stream; if(frameStart<frameEnd) numberOfVideoFrames=frameEnd-frameStart; else numberOfVideoFrames=frameStart-frameEnd; duration=(float)video_body->getTime (numberOfVideoFrames); duration=duration/1000.; if(duration<0) duration=-duration; video_body->getVideoInfo(&info); videoDuration=(uint32_t)ceil(duration); frame2time(numberOfVideoFrames,info.fps1000, &hh, &mm, &ss, &ms); // now we can set it sprintf(string,"%02d:%02d:%02d",hh,mm,ss); gtk_label_set_text(GTK_LABEL(GW(labelDuration),string); printf("Video duration :%lu\n",videoDuration); // Now get audio info track1=0; if(audioProcessMode() && currentaudiostream) { // stream=buildAudioFilter(currentaudiostream,0); if(stream) { track1=(stream->getInfo()->byterate*8)/1000; } // deleteAudioFilter(stream); }else { if(currentaudiostream) track1=(currentaudiostream->getInfo()->byterate*8)/1000; } track2=0; gtk_spin_button_set_value(GTK_SPIN_BUTTON(GW(spinbuttonTrack1)), track1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(GW(spinbuttonTrack2)), track2); printf("Track1 bitrate :%lu\n",track1); printf("Track2 bitrate :%lu\n",track2); #endif }
int cb_mod(GtkWidget * object, gpointer user_data) { int r; int sens=0; r=gtk_combo_box_get_active(GTK_COMBO_BOX(GW(comboboxMedium))); if(r==5) { sens=1; } gtk_widget_set_sensitive(GW(spinbuttonCustom),sens); update(); return 0; }
/* Main function */ int main (int argc, char **argv) { Data *data; char *path; GtkBuilder *builder; GError *error = NULL; /* Initialize translation machinery */ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Initialize GTK+ */ gtk_init (&argc, &argv); #ifdef ENABLE_DEBUG g_print ("Running application in debug mode\n"); #endif /* Allocate shared data memory */ data = g_slice_new0 (Data); /* Create UI */ builder = gtk_builder_new (); path = g_build_filename (PKGUIDIR, "snrmga.glade", NULL); if (!gtk_builder_add_from_file (builder, path, &error)) { g_critical ("%s", error->message); return 1; } g_free (path); #define GW(name) \ (data->name = GTK_WIDGET (gtk_builder_get_object (builder, (#name)))) GW (main_window); GW (image); #undef GW gtk_builder_connect_signals (builder, data); g_object_unref (builder); gtk_widget_show (data->main_window); gtk_main(); return 0; }
/* Gets the widgets from the XML file and returns if they are all available. */ static gboolean get_widgets (GoToDialog *dlg) { #define GW(name) glade_xml_get_widget (dlg->xml, name) dlg->dialog = GW ("goto-dialog"); dlg->month = GW ("month"); dlg->year = GW ("year"); dlg->vbox = GW ("vbox"); #undef GW return (dlg->dialog && dlg->month && dlg->year && dlg->vbox); }
//************************************ void DIA_Calculator(uint32_t *sizeInMeg, uint32_t *avgBitrate ) { if(!avifileinfo) return ; glade.init(); if (!glade.loadFile("calculator.gtkBuilder")) { GUI_Error_HIG(QT_TR_NOOP("Cannot load dialog"), QT_TR_NOOP("File \"calculator.gtkBuilder\" could not be loaded.")); return; } GtkWidget *dialog = GW(dialogCalculator); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL, GTK_RESPONSE_APPLY, -1); gtk_register_dialog(dialog); g_signal_connect(GW(comboboxFormat), "changed", G_CALLBACK(cb_mod), (void *) 0); g_signal_connect(GW(comboboxMedium), "changed", G_CALLBACK(cb_mod2), (void *) 0); prepare(); update(); gtk_widget_set_sensitive(GW(spinbuttonCustom),0); while(1) { if(GTK_RESPONSE_APPLY==gtk_dialog_run(GTK_DIALOG(dialog))) { update(); videoCodecSetFinalSize(videoSize); } else { break; } } gtk_unregister_dialog(dialog); gtk_widget_destroy(dialog); *sizeInMeg=videoSize; *avgBitrate=videoBitrate; }
int init_gtk(int argc, char *argv[]){ GtkBuilder *builder; GtkWidget *label; Interface *data; GError *error = NULL; gtk_init (&argc, &argv); builder = gtk_builder_new(); if(!gtk_builder_add_from_file( builder, UI_FILE, &error )){ g_warning("%s", error->message); g_free(error); return(1); } data = g_slice_new(Interface); /* Get objects from UI */ #define GW(name) CH_GET_WIDGET(builder, name, data) GW( mainwindow ); GW( menubar ); GW( filequit ); GW( statusbar ); GW( sidearea ); GW( drawwindow ); #undef GW gtk_builder_connect_signals(builder, data); g_object_unref(G_OBJECT(builder)); g_signal_connect(data->mainwindow, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(data->filequit, "activate", G_CALLBACK(callbackhandler), (void*)"Test"); gtk_window_set_title (GTK_WINDOW(data->mainwindow), "Testing GTK iterface for C/C++ v0.0.1"); gtk_window_set_position(GTK_WINDOW(data->mainwindow), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(data->mainwindow), false); gtk_widget_show(data->mainwindow); gtk_main(); g_slice_free(Interface, data); return 0; }
KW(PRINTF), KW(RIGHT), KW(TRUNCATE), KW(WIDTH), }; #undef KW static const KeywordTable SelectKeywords = SORTED_TOKENER_TABLE(SelectKeywordItems); enum { gw_AS=1, gw_ASCENDING, gw_DECENDING, }; #define GW(a) { #a, gw_##a, 0 } static const Keyword GroupKeywordItems[] = { GW(AS), GW(ASCENDING), GW(DECENDING), }; #undef KW static const KeywordTable GroupKeywords = SORTED_TOKENER_TABLE(GroupKeywordItems); static void unexpected_token(std::string & message, const char * tag, SimpleInputStream & stream, tokener & toke) { std::string tok; toke.copy_token(tok); formatstr_cat(message, "%s was unexpected at line %d offset %d in %s\n", tok.c_str(), stream.count_of_lines_read(), (int)toke.offset(), tag); } static void expected_token(std::string & message, const char * reason, const char * tag, SimpleInputStream & stream, tokener & toke) {
//************************************* void update( void ) { uint32_t audioSize; uint32_t totalSize; char string[200]; aviInfo info; video_body->getVideoInfo(&info); track1=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(GW(spinbuttonTrack1))); track2=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(GW(spinbuttonTrack2))); gtk_spin_button_set_value(GTK_SPIN_BUTTON(GW(spinbuttonTrack1)), track1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(GW(spinbuttonTrack2)), track1); // kb->Byte audioSize=(track1+track2)*1000; audioSize/=8; audioSize*=videoDuration; audioSize>>=20; sprintf(string,"%"PRIu32,audioSize); gtk_label_set_text(GTK_LABEL(GW(labelAudio)),string); // Compute total size (for Avi) uint32_t s74,s80,dvd; // For avi/ogm int f = gtk_combo_box_get_active(GTK_COMBO_BOX(GW(comboboxFormat))); if(f==2) { // Mpeg s74=730; s80=790; dvd=4300; } else {//AVI or OGM s74=650; s80=700; dvd=4300; } int j=gtk_combo_box_get_active(GTK_COMBO_BOX(GW(comboboxMedium))); switch(j) { case 2: totalSize=1*s74;break; case 3: totalSize=2*s74;break; case 0: totalSize=1*s80;break; case 1: totalSize=2*s80;break; case 4: totalSize=dvd;break; case 5: totalSize=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(GW(spinbuttonCustom))); if(totalSize<1) totalSize=1; break; default: ADM_assert(0); } sprintf(string,"%"PRIu32,totalSize); gtk_label_set_text(GTK_LABEL(GW(labelTotal)),string); // Compute muxing overhead size uint32_t muxingOverheadSize; int numberOfAudioTracks = 0; int numberOfChunks; switch (f) { case 0: // AVI /* Muxing overhead is 8 + 32 = 40 bytes per chunk. More or less: numberOfChunks = (x + 1) * numberOfVideoFrames, where x - the number of audio tracks */ if (track1 != 0) { numberOfAudioTracks++; } if (track2 != 0) { numberOfAudioTracks++; } numberOfChunks = (numberOfAudioTracks + 1) * numberOfVideoFrames; muxingOverheadSize = (uint32_t) ceil((numberOfChunks * 40) / 1048576.0);; break; case 1: // OGM // Muxing overhead is 1.1% to 1.2% of (videoSize + audioSize) muxingOverheadSize = (uint32_t) ceil(totalSize - totalSize / 1.012); break; case 2: // MPEG // Muxing overhead is 1% to 2% of (videoSize + audioSize) muxingOverheadSize = (uint32_t) ceil(totalSize - totalSize / 1.02); break; default: ADM_assert(0); } //sprintf(string,"%lu",muxingOverheadSize); //gtk_label_set_text(GTK_LABEL(GW(labelMux)),string); // and compute // //uint32_t videoSize; if(audioSize>=totalSize) sprintf(string,"** NO ROOM LEFT**"); else { uint32_t picSize; videoSize=totalSize-audioSize - muxingOverheadSize; // Compute average bps float avg; float bpp; avg=videoSize; avg*=1024.*1024.; avg/=videoDuration; // now we have byte /sec // convert to kb per sec avg=(avg*8)/1000; videoBitrate=(uint32_t)avg; sprintf(string,"%"PRIu32,(uint32_t)videoBitrate); gtk_label_set_text(GTK_LABEL(GW(labelBitrate)),string); // sprintf(string,"%"PRIu32,videoSize); gtk_label_set_text(GTK_LABEL(GW(labelVideo)),string); // Bpp bpp=videoBitrate; bpp=bpp*1000000.; // kbit->bit + compensate for fps1000 // Fetch info from filter if(videoProcessMode()) picSize=getPicSize(); else picSize=info.width*info.height; bpp/=picSize; //printf("w:%d h:%d\n",info.width,info.height); bpp/=info.fps1000; sprintf(string,"%1.3f",bpp); gtk_label_set_text(GTK_LABEL(GW(labelBPP)),string); } }
static gboolean get_widgets (GnomePilotCapplet *gpcap) { GnomePilotCappletPrivate *priv; GtkWidget *w; priv = gpcap->priv; #define GW(name) GTK_WIDGET (gtk_builder_get_object (priv->ui, name)) gtk_window_set_title (GTK_WINDOW (gpcap), _("gnome-pilot Settings")); gtk_dialog_add_button (GTK_DIALOG (gpcap), GTK_STOCK_HELP, GTK_RESPONSE_HELP); gtk_dialog_add_button (GTK_DIALOG (gpcap), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); priv->notebook = GW ("CappletMain"); if (priv->notebook) gtk_container_add (GTK_CONTAINER ( gtk_dialog_get_content_area (GTK_DIALOG (gpcap))), priv->notebook); w = GW ("pilots_treeview"); priv->pilots_treeview = g_object_get_data (G_OBJECT (w), "treeview"); priv->pilots_model = g_object_get_data (G_OBJECT (w), "model"); priv->pilots_add = GW ("pilots_add_button"); priv->pilots_edit = GW ("pilots_edit_button"); priv->pilots_delete = GW ("pilots_delete_button"); w = GW ("devices_treeview"); priv->devices_treeview = g_object_get_data (G_OBJECT (w), "treeview"); priv->devices_model = g_object_get_data (G_OBJECT (w), "model"); priv->devices_add = GW ("devices_add_button"); priv->devices_edit = GW ("devices_edit_button"); priv->devices_delete = GW ("devices_delete_button"); priv->pilots_combo = GW ("pilots_combo"); priv->pilots_username = GW ("username_label"); w = GW ("conduit_treeview"); priv->conduit_treeview = g_object_get_data (G_OBJECT (w), "treeview"); priv->conduit_model = g_object_get_data (G_OBJECT (w), "model"); priv->conduit_enable = GW ("conduit_enable_button"); priv->conduit_disable = GW ("conduit_disable_button"); priv->conduit_settings = GW ("conduit_settings_button"); priv->conduit_description = GW ("description_label"); #undef GW return (priv->notebook && priv->pilots_treeview && priv->pilots_add && priv->pilots_edit && priv->pilots_delete && priv->devices_treeview && priv->devices_add && priv->devices_edit && priv->devices_delete && priv->pilots_combo && priv->conduit_treeview && priv->conduit_enable && priv->conduit_disable && priv->conduit_settings && priv->conduit_description); }
static void preferences_dialog_init (PreferencesDialog *p) { GtkCellRenderer *icon_renderer, *text_renderer; GtkTreeViewColumn *column; GtkTreeSelection *select; p->gconf = NULL; p->dialog = NULL; gchar *path = locate_data_file ("preferences-dialog.glade"); g_assert (path != NULL); GtkBuilder *xml = gtk_builder_new (); g_assert (gtk_builder_add_from_file ( xml, path, NULL) != 0); g_free (path); #define GW(name) ((p->name) = GTK_WIDGET (gtk_builder_get_object (xml, #name))) GW(dialog); GW(settings_page_list); GW(settings_notebook); #undef GW p->gconf = gconf_client_get_default (); g_assert (p->dialog); g_signal_connect (p->dialog, "response", G_CALLBACK (preferences_response), p); g_signal_connect (p->dialog, "key-press-event", G_CALLBACK (dialog_escape_key_handler_hide), NULL); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (p->settings_notebook), FALSE); p->page_store = gtk_list_store_new (4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER); gtk_tree_view_set_model (GTK_TREE_VIEW (p->settings_page_list), GTK_TREE_MODEL (p->page_store)); column = gtk_tree_view_column_new (); icon_renderer = gtk_cell_renderer_pixbuf_new (); text_renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, icon_renderer, FALSE); gtk_tree_view_column_set_attributes (column, icon_renderer, "pixbuf", 0, NULL); gtk_tree_view_column_pack_start (column, text_renderer, FALSE); gtk_tree_view_column_set_attributes (column, text_renderer, "text", 1, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (p->settings_page_list), column); select = gtk_tree_view_get_selection (GTK_TREE_VIEW (p->settings_page_list)); gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); g_signal_connect (G_OBJECT (select), "changed", G_CALLBACK (page_selection_changed), p); p->irc_page = preferences_page_irc_new (p, xml); p->spellcheck_page= preferences_page_spellcheck_new (p,xml); p->colors_page = preferences_page_colors_new (p, xml); p->effects_page = preferences_page_effects_new (p, xml); p->dcc_page = preferences_page_dcc_new (p, xml); p->networks_page = preferences_page_networks_new (p, xml); #ifdef USE_PLUGIN p->plugins_page = preferences_page_plugins_new (p, xml); g_signal_connect (p->plugins_page, "new-plugin-page", G_CALLBACK (new_plugin_page), p); g_signal_connect (p->plugins_page, "remove-plugin-page", G_CALLBACK (remove_plugin_page), p); preferences_page_plugins_check_plugins (p->plugins_page); #endif g_object_unref (xml); }
int main(int argc, char *argv[]) { GtkBuilder *builder; GString *txt = g_string_new_len("", 20); char filepad[100]; unsigned short i, mask=0; GdkScreen* screen = NULL; int xx, yy, screen_width, screen_height; InitAudio(); pad = get_real_path(); // get the path of the executable sprintf(filepad, "%s/.lock", pad); setlock(filepad, 10, TRUE); // disable multiple instances for at least 10 seconds g_thread_init (NULL); display = XOpenDisplay(0); if (display == NULL) exit(1); gtk_set_locale(); gtk_init(&argc, &argv); builder = gtk_builder_new (); sprintf(filepad, "%s/%s.glade", pad, SKIN); gtk_builder_add_from_file(builder, filepad, NULL); gtk_builder_connect_signals (builder, NULL); // set widgets to be handled by the event handlers window = GW ("window"); preferences = GW ("preferences"); lookup = GW ("lookup"); fontbutton = GW ("fontbutton1"); drag = GW ("dragbar"); debug = GW ("debug"); papier = GW ("drawingarea1"); colorbutton1 = GW ("colorbutton1"); colorbutton2 = GW ("colorbutton2"); checkbutton1 = GW ("checkbutton1"); entry1 = GW ("entry1"); entry2 = GW ("entry2"); gtktable1 = GW ("table1"); checkbutton8 = GW ("checkbutton8"); checkbutton9 = GW ("checkbutton9"); textview1 = GW ("textview1"); entry16 = GW ("entry16"); combobox1 = GW ("combobox1"); scrolled = GW ("scrolledwindow2"); opacity = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "adjustment1")); speed = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "adjustment2")); textbuffer1 = GTK_TEXT_BUFFER(gtk_builder_get_object (builder, "textbuffer1")); for (i=0; i<sizeof(unsigned short); i++) { // set each bit of mask mask <<= 8; mask |= 0xFF; } // fill the struct that keeps the 7 recognize buttons & checkboxes (in preferences) for (i=0; i<7; i++) { g_string_sprintf(txt, "checkbutton%d", i+2); modebits[i].check = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); g_string_sprintf(txt, "button%d", i+3); modebits[i].button = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); switch (i) { case 0: modebits[i].bit = (GB1|GB2); modebits[i].mask = ((GB1|GB2) ^ mask); break; case 1: modebits[i].bit = BIG5; modebits[i].mask = (BIG5 ^ mask); break; case 2: modebits[i].bit = DIGITS; modebits[i].mask = (DIGITS ^ mask); break; case 3: modebits[i].bit = LOWERCASE; modebits[i].mask = (LOWERCASE ^ mask); break; case 4: modebits[i].bit = UPPERCASE; modebits[i].mask = (UPPERCASE ^ mask); break; case 5: modebits[i].bit = PUNC; modebits[i].mask = (PUNC ^ mask); break; case 6: modebits[i].bit = DEFAULT; modebits[i].mask = (DEFAULT ^ mask); break; } } // fill the structure that keeps the 13 labels for the keys (preferences) for (i=0; i<13; i++) { g_string_sprintf(txt, "button%d", i+10); conf.defkey[i].button = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); g_string_sprintf(txt, "entry%d", i+3); conf.defkey[i].entry = GTK_WIDGET(gtk_builder_get_object (builder, txt->str)); conf.defkey[i].key = 0; } // place a simple combobox for the input selection (preferences) combo = gtk_combo_box_new_text(); gtk_table_attach_defaults(GTK_TABLE(gtktable1), combo, 1, 2, 2, 3); gtk_widget_show (combo); // get events and labels for the 9 candidates for (int i=0; i< 9; i++) { g_string_sprintf(txt, "knop%d", i+1); knop[i] = GTK_WIDGET (gtk_builder_get_object (builder, txt->str)); g_string_sprintf(txt, "event%d", i+1); event[i] = GTK_WIDGET (gtk_builder_get_object (builder, txt->str)); } // set events for paste and backspace entries (preferences) g_signal_connect(entry1, "key_press_event", G_CALLBACK(on_key_press), NULL); g_signal_connect(entry1, "key_release_event", G_CALLBACK(on_key_release), NULL); g_signal_connect(entry2, "key_press_event", G_CALLBACK(on_key_press), NULL); g_signal_connect(entry2, "key_release_event", G_CALLBACK(on_key_release), NULL); if (!create_wtpen_window()) exit(1); wtpen_init(); g_object_unref (G_OBJECT (builder)); gtk_widget_show_all(GTK_WIDGET(window)); for (i=0; i<NUMKEYS; i++) hotkey[i] = 0; // reset all hotkeys // load cedict from file sprintf(filepad, "%s/data", pad); import_cedict(filepad); // load settings from file sprintf(filepad, "%s/xpen.cfg", pad); load_preferences(filepad); // set background and shape sprintf(filepad, "%s/%s.png", pad, SKIN); set_window_shape(filepad); // some styles to be used in the cedict browser (lookup window)δΈ€ gtk_text_buffer_create_tag(textbuffer1, "mark", "background", "yellow", "foreground", "black", NULL); gtk_text_buffer_create_tag(textbuffer1, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_buffer_create_tag(textbuffer1, "character", "font", conf.font, "scale", 1.3, NULL); gtk_text_buffer_create_tag(textbuffer1, "translation", "scale", 0.9, NULL); gtk_text_buffer_create_tag(textbuffer1, "pinyin", "scale", 1.1, NULL); ready = TRUE; // let_configure_event() know that it can start its setup // start monitoring system-wide keypresses g_thread_create (intercept_key_thread, NULL, FALSE, NULL); // make sure the window positions and size are legal screen = gtk_window_get_screen(GTK_WINDOW(window)); // get screen size screen_width = gdk_screen_get_width(screen); screen_height = gdk_screen_get_height(screen); xx = MAX(MIN(screen_width-width, conf.x), 0); // set the position of the main window yy = MAX(MIN(screen_height-height, conf.y), 0); gtk_widget_set_uposition(window, xx, yy); xx = MIN(screen_width, conf.dx); // set the size of the lookup window yy = MIN(screen_height, conf.dy); gtk_widget_set_usize(lookup, xx, yy); xx = MAX(MIN(screen_width-conf.dx, conf.lx), 0); // set the position of the lookup window yy = MAX(MIN(screen_height-conf.dy, conf.ly), 0); gtk_widget_set_uposition(lookup, xx, yy); g_timeout_add (100, checkfocus, NULL); // check the inputfocus (each 1/10s) ////////////////////////////////////////////////////////////// //on_full_screen_button_pressed(); // start the full screen mode ////////////////////////////////////////////////////////////// gtk_main(); // start the main loop sprintf(filepad, "%s/.lock", pad); // remove the lock setlock(filepad, 0, FALSE); // save all settings to file sprintf(filepad, "%s/xpen.cfg", pad); save_preferences (filepad); g_free(pad); free_all(); wtpen_window_done(); wtlib_done(); SDL_CloseAudio(); SDL_Quit(); //on_full_screen_button_pressed(); return 0; }
PreferencesPageDCC * preferences_page_dcc_new (gpointer prefs_dialog, GtkBuilder *xml) { PreferencesPageDCC *page = g_object_new (PREFERENCES_PAGE_DCC_TYPE, NULL); PreferencesDialog *p = (PreferencesDialog *) prefs_dialog; #define GW(name) GtkWidget *name = GTK_WIDGET (gtk_builder_get_object (xml, #name)) GW(download_dir_button); GW(completed_dir_button); GW(convert_spaces); GW(save_nicknames_dcc); GW(autoaccept_dcc_chat); GW(autoaccept_dcc_file); GW(get_dcc_ip_from_server); GW(use_specified_dcc_ip); GW(special_ip_address); GW(individual_send_throttle); GW(global_send_throttle); GW(individual_receive_throttle); GW(global_receive_throttle); #undef GW page->special_ip_address = special_ip_address; gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER (download_dir_button), get_default_download_dir(), NULL); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (download_dir_button), prefs.dccdir); if (strlen (prefs.dcc_completed_dir) == 0) { gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (completed_dir_button), prefs.dccdir); } else { gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER (completed_dir_button), get_default_download_dir(), NULL); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (completed_dir_button), prefs.dcc_completed_dir); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convert_spaces), prefs.dcc_send_fillspaces); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (save_nicknames_dcc), prefs.dccwithnick); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoaccept_dcc_chat), prefs.autodccchat); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoaccept_dcc_file), prefs.autodccsend); if (prefs.ip_from_server) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (get_dcc_ip_from_server), TRUE); gtk_widget_set_sensitive (special_ip_address, FALSE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (use_specified_dcc_ip), TRUE); gtk_entry_set_text (GTK_ENTRY (special_ip_address), prefs.dcc_ip_str); gtk_widget_set_sensitive (special_ip_address, FALSE); } gtk_spin_button_set_value (GTK_SPIN_BUTTON (individual_send_throttle), (gdouble) prefs.dcc_max_send_cps); gtk_spin_button_set_value (GTK_SPIN_BUTTON (global_send_throttle), (gdouble) prefs.dcc_global_max_send_cps); gtk_spin_button_set_value (GTK_SPIN_BUTTON (individual_receive_throttle), (gdouble) prefs.dcc_max_get_cps); gtk_spin_button_set_value (GTK_SPIN_BUTTON (global_receive_throttle), (gdouble) prefs.dcc_global_max_get_cps); g_signal_connect (G_OBJECT (download_dir_button), "selection-changed", G_CALLBACK (path_changed), prefs.dccdir); g_signal_connect (G_OBJECT (completed_dir_button), "selection-changed", G_CALLBACK (path_changed), prefs.dcc_completed_dir); g_signal_connect (G_OBJECT (convert_spaces), "toggled", G_CALLBACK (toggle_changed), &prefs.dcc_send_fillspaces); g_signal_connect (G_OBJECT (save_nicknames_dcc), "toggled", G_CALLBACK (toggle_changed), &prefs.dccwithnick); g_signal_connect (G_OBJECT (autoaccept_dcc_chat), "toggled", G_CALLBACK (toggle_changed), &prefs.autodccchat); g_signal_connect (G_OBJECT (autoaccept_dcc_file), "toggled", G_CALLBACK (toggle_changed), &prefs.autodccsend); g_signal_connect (G_OBJECT (get_dcc_ip_from_server), "toggled", G_CALLBACK (get_ip_from_server_changed), page); g_signal_connect (G_OBJECT (special_ip_address), "changed", G_CALLBACK (special_ip_changed), NULL); g_signal_connect (G_OBJECT (individual_send_throttle), "value-changed", G_CALLBACK (spin_changed), &prefs.dcc_max_send_cps); g_signal_connect (G_OBJECT (global_send_throttle), "value-changed", G_CALLBACK (spin_changed), &prefs.dcc_global_max_send_cps); g_signal_connect (G_OBJECT (individual_receive_throttle), "value-changed", G_CALLBACK (spin_changed), &prefs.dcc_max_get_cps); g_signal_connect (G_OBJECT (global_receive_throttle), "value-changed", G_CALLBACK (spin_changed), &prefs.dcc_global_max_get_cps); GtkIconTheme *theme = gtk_icon_theme_get_default (); PREFERENCES_PAGE (page)->icon = gtk_icon_theme_load_icon (theme, "xchat-gnome-dcc", 16, 0, NULL); GtkTreeIter iter; gtk_list_store_append (p->page_store, &iter); gtk_list_store_set (p->page_store, &iter, 0, PREFERENCES_PAGE (page)->icon, 1, _("File Transfers & DCC"), 2, 3, -1); return page; }
/* Gets the widgets from the XML file and returns TRUE if they are all available. */ static gboolean get_widgets (Dialog *dialog) { #define GW(name) glade_xml_get_widget (dialog->xml, name) dialog->toplevel = GW ("alarm-dialog"); if (!dialog->toplevel) return FALSE; dialog->action = GW ("action"); dialog->interval_value = GW ("interval-value"); dialog->value_units = GW ("value-units"); dialog->relative = GW ("relative"); dialog->time = GW ("time"); dialog->repeat_toggle = GW ("repeat-toggle"); dialog->repeat_group = GW ("repeat-group"); dialog->repeat_quantity = GW ("repeat-quantity"); dialog->repeat_value = GW ("repeat-value"); dialog->repeat_unit = GW ("repeat-unit"); dialog->option_notebook = GW ("option-notebook"); dialog->dalarm_group = GW ("dalarm-group"); dialog->dalarm_message = GW ("dalarm-message"); dialog->dalarm_description = GW ("dalarm-description"); dialog->aalarm_group = GW ("aalarm-group"); dialog->aalarm_sound = GW ("aalarm-sound"); dialog->aalarm_file_chooser = GW ("aalarm-file-chooser"); dialog->malarm_group = GW ("malarm-group"); dialog->malarm_address_group = GW ("malarm-address-group"); dialog->malarm_addressbook = GW ("malarm-addressbook"); dialog->malarm_message = GW ("malarm-message"); dialog->malarm_description = GW ("malarm-description"); dialog->palarm_group = GW ("palarm-group"); dialog->palarm_program = GW ("palarm-program"); dialog->palarm_args = GW ("palarm-args"); #undef GW return (dialog->action && dialog->interval_value && dialog->value_units && dialog->relative && dialog->time && dialog->repeat_toggle && dialog->repeat_group && dialog->repeat_quantity && dialog->repeat_value && dialog->repeat_unit && dialog->option_notebook && dialog->dalarm_group && dialog->dalarm_message && dialog->dalarm_description && dialog->aalarm_group && dialog->aalarm_sound && dialog->aalarm_file_chooser && dialog->malarm_group && dialog->malarm_address_group && dialog->malarm_addressbook && dialog->malarm_message && dialog->malarm_description && dialog->palarm_group && dialog->palarm_program && dialog->palarm_args); }
int main( int argc, char **argv ) { GtkBuilder *builder; GError *error = NULL; int ret; /* MagickWand Init */ MagickWandGenesis(); camera_params.wand_data.display_magick_wand=NewMagickWand(); camera_params.wand_data.processed_magick_wand=NewMagickWand(); camera_params.wand_data.raw_magick_wand=NewMagickWand(); camera_params.wand_data.raw_directory=NULL; camera_params.wand_data.processed_directory=NULL; camera_params.wand_data.processed_img_ok = 0; camera_params.wand_data.raw_img_ok = 0; pthread_mutex_init(&camera_params.wand_data.processed_img_mutex, NULL); pthread_mutex_init(&camera_params.wand_data.raw_img_mutex, NULL); pthread_mutex_init(&camera_params.wand_data.display_img_mutex, NULL); pthread_mutex_init(&camera_params.wand_data.background_img_mutex, NULL); camera_params.list_file = fopen (LIST_FILENAME, "w"); if (camera_params.list_file == NULL) g_print("cannot open %s\n",LIST_FILENAME); else { fprintf(camera_params.list_file,"#image_number\timage_acq_number\ttime\tmean\tmean_soft\tmean_soft_roi1\tmean_soft_roi2\n"); } /* We are using a threaded program we must say it to gtk */ if( ! g_thread_supported() ) g_thread_init(NULL); gdk_threads_init(); /* Obtain gtk's global lock */ gdk_threads_enter(); /* Init GTK+ */ gtk_init( &argc, &argv ); /* Create new GtkBuilder object */ builder = gtk_builder_new(); /* Load UI from file. If error occurs, report it and quit application. * Replace "tut.glade" with your saved project. */ if( ! gtk_builder_add_from_file( builder, "camera_interface.glade", &error ) ) { g_warning( "%s", error->message ); g_free( error ); return( 1 ); } /* Allocate data structure */ camera_params.objects = g_slice_new( gui_objects_t ); /* Get objects from UI */ #define GW( name ) CH_GET_WIDGET( builder, name, data ) GW( main_window ); GW( main_status_bar ); GW( camera_text ); GW( image_number ); GW( raw_image ); GW( processed_image ); GW( trig_mult ); GW( trig_single ); GW( trig_cont ); GW( freerun_trig ); GW( ext1_trig ); GW( ext2_trig ); GW( framerate_trig ); GW( directorychooserdialog ); GW( imagesavedialog ); GW( listsavedialog ); GW( no_image_dialog ); GW( ROI_confirm_dialog ); GW( ROI_confirm_dialog_text ); GW( stats_treeview ); GW( acq_toggle ); GW( mean_bar ); GW( soft_rotate_image ); GW( soft_magn_x2 ); GW( soft_magn_x4 ); GW( soft_magn_x8 ); GW( soft_cut_img ); GW( soft_image_text ); GW( soft_display_mean_roi1 ); GW( soft_compute_mean_roi1 ); GW( soft_display_mean_roi2 ); GW( soft_compute_mean_roi2 ); GW( soft_background_info_text ); GW( soft_background_button ); GW( processed_mean_bar ); GW( processed_mean_roi1 ); GW( processed_mean_roi1_bar ); GW( processed_mean_roi2 ); GW( processed_mean_roi2_bar ); GW( soft_dont_update_current ); GW( soft_timing_text ); GW( ROI_height ); GW( ROI_width ); GW( ROI_start_x ); GW( ROI_start_y ); GW( Exp_gain ); GW( Exp_time ); GW( raw_autosave ); GW( raw_text ); GW( list_text ); GW( camera_choose_win ); GW( camera_list_combo ); GW( trig_framerate ); GW( net_expander ); #undef GW /* Get adjustments objects from UI */ #define GA( name ) CH_GET_ADJUSTMENT( builder, name, data ) GA( Exp_adj_gain ); GA( Exp_adj_time ); GA( ROI_adjust_x ); GA( ROI_adjust_y ); GA( ROI_adjust_width ); GA( ROI_adjust_height ); GA( Bin_X_adj ); GA( Bin_Y_adj ); GA( Bytes_per_sec_adj ); GA( Trig_nbframes_adj); GA( Trig_framerate_adj); GA( min_meanbar ); GA( max_meanbar ); GA( soft_angle_adj ); GA( soft_level_min_adj ); GA( soft_level_max_adj ); GA( ROI_soft_adjust_width ); GA( ROI_soft_adjust_height ); GA( ROI_soft_adjust_x ); GA( ROI_soft_adjust_y ); GA( ROI_soft_mean_adjust_x1 ); GA( ROI_soft_mean_adjust_width1 ); GA( ROI_soft_mean_adjust_y1 ); GA( ROI_soft_mean_adjust_height1 ); GA( ROI_soft_mean_adjust_x2 ); GA( ROI_soft_mean_adjust_width2 ); GA( ROI_soft_mean_adjust_y2 ); GA( ROI_soft_mean_adjust_height2 ); GA( processed_mean_min_adj ); GA( processed_mean_max_adj ); GA( processed_mean_roi1_min_adj ); GA( processed_mean_roi1_max_adj ); GA( processed_mean_roi2_min_adj ); GA( processed_mean_roi2_max_adj ); #undef GA #define GL( name ) CH_GET_LIST_STORE( builder, name, data ) GL( statistics_list ); GL( camera_list ); #undef GL /* Connect signals */ gtk_builder_connect_signals( builder, NULL ); /* Destroy builder, since we don't need it anymore */ g_object_unref( G_OBJECT( builder ) ); /* Show window. All other widgets are automatically shown by GtkBuilder */ gtk_widget_show( camera_params.objects->main_window ); //Hide some of the widgets gtk_widget_hide_all(camera_params.objects->processed_mean_roi1); gtk_widget_hide_all(camera_params.objects->processed_mean_roi2); //Good values, the images are stored on 16 bits gtk_adjustment_set_upper(camera_params.objects->processed_mean_min_adj,1<<16); gtk_adjustment_set_upper(camera_params.objects->processed_mean_max_adj,1<<16); gtk_adjustment_set_value(camera_params.objects->processed_mean_max_adj,1<<16); gtk_adjustment_set_upper(camera_params.objects->processed_mean_roi1_min_adj,1<<16); gtk_adjustment_set_upper(camera_params.objects->processed_mean_roi1_max_adj,1<<16); gtk_adjustment_set_value(camera_params.objects->processed_mean_roi1_max_adj,1<<16); gtk_adjustment_set_upper(camera_params.objects->processed_mean_roi2_min_adj,1<<16); gtk_adjustment_set_upper(camera_params.objects->processed_mean_roi2_max_adj,1<<16); gtk_adjustment_set_value(camera_params.objects->processed_mean_roi2_max_adj,1<<16); /* Start the camera thread */ ret=pthread_create(&(camera_params.camera_thread), NULL, camera_thread_func, &camera_params); if(ret){ g_warning( "Thread creation error %d", ret ); return( 1 ); } gchar *msg; if (camera_params.list_file == NULL) { msg = g_strdup_printf ("Problem openning %s for writing",LIST_FILENAME); } else { msg = g_strdup_printf ("The list will be continuously saved in %s",LIST_FILENAME); } gtk_text_buffer_set_text(gtk_text_view_get_buffer (GTK_TEXT_VIEW (camera_params.objects->list_text)),msg,-1); g_free (msg); /* Start main loop */ gtk_main(); /* Release gtk's global lock */ gdk_threads_leave(); pthread_join(camera_params.camera_thread, NULL); /* We derease the pixbuf reference counter */ if(camera_params.raw_image_pixbuff!=NULL) g_object_unref(camera_params.raw_image_pixbuff); /* Free any allocated data */ g_slice_free( gui_objects_t, camera_params.objects ); pthread_mutex_destroy(&camera_params.wand_data.processed_img_mutex); pthread_mutex_destroy(&camera_params.wand_data.raw_img_mutex); pthread_mutex_destroy(&camera_params.wand_data.display_img_mutex); pthread_mutex_destroy(&camera_params.wand_data.background_img_mutex); if(camera_params.wand_data.raw_directory) free(camera_params.wand_data.raw_directory); if(camera_params.wand_data.processed_directory) free(camera_params.wand_data.processed_directory); if(camera_params.background_set) DestroyMagickWand(camera_params.wand_data.background_wand); if(camera_params.wand_data.saving_wand) DestroyMagickWand(camera_params.wand_data.saving_wand); DestroyMagickWand(camera_params.wand_data.raw_magick_wand); DestroyMagickWand(camera_params.wand_data.processed_magick_wand); DestroyMagickWand(camera_params.wand_data.display_magick_wand); MagickWandTerminus(); if (camera_params.list_file != NULL) fclose(camera_params.list_file); return( 0 ); }