static void update_by_media_type_entry() { GtkWidget* window = UI_DIALOG(g_main_window)->window; GtkWidget* entry = LookupWidget(window, "media_type_entry"); short type_value = NameToValue(CNCL_MEDIATYPE, (char*)gtk_entry_get_text(GTK_ENTRY(entry))); // Save current supply value. short supply_value = GetCurrentnValue(CNCL_MEDIASUPPLY); UpdateMenuLink(CNCL_MEDIATYPE, type_value); // If changed the supply value, show the alert. if( supply_value != GetCurrentnValue(CNCL_MEDIASUPPLY) ) { confirm_media_supply_change(supply_value); } UpdateWidgets(window, "media_type_combo"); #ifdef GUI_WITH_PIXMAPS UpdateDrawingArea(window, "basic_draw_area"); #endif g_media_type_entry_changed = FALSE; }
/* item value(nValue) -> combo index */ short ValueToComboIndex( GtkWidget *combo , short object , short target_value ) //nValueで指定 { short result = -1; short item_count = 0; char *combo_item_name = NULL; short combo_item_value = -1; // search in the list of the combo if(gtk_combo_box_get_active_text( GTK_COMBO_BOX( combo )) ){ while( 1 ){ gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), item_count ); combo_item_name = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); if( ! combo_item_name ) break; combo_item_value = NameToValue( object, combo_item_name ); /* convert name(string) to CNCLID */ if( combo_item_value == target_value ){ result = item_count; break; } item_count++; } } return result; }
/* Set items in "GList" to GtkComboBox */ short SetGListToComboBox(GtkWidget* window, gchar *combo_name, GList* glist, gchar* current , short objectid ) { GtkWidget* combo = LookupWidget(window, combo_name); GList* glist_tmp = glist; short current_id; char *str; short active_item,item_count; /* Remove all items in current list */ if(gtk_combo_box_get_active_text( GTK_COMBO_BOX( combo )) ){ while( 1 ){ gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), 0 ); if( ! gtk_combo_box_get_active_text( GTK_COMBO_BOX( combo )) ) break; gtk_combo_box_remove_text( GTK_COMBO_BOX( combo ), 0 ); } } /* Add items in "glist" */ item_count = 0; active_item = 0; current_id = NameToValue( objectid , (char *)current); while( glist_tmp ) { str = (char *)glist_tmp->data; if( str != NULL ) { /* append one item */ gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), str ); if( current_id == NameToValue( objectid , str ) ) active_item = item_count; item_count++; } glist_tmp = glist_tmp->next; } /* Set active item */ gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), active_item ); return item_count; }
static void update_by_cartridge_type_entry() { GtkWidget* window = UI_DIALOG(g_main_window)->window; GtkWidget* entry = LookupWidget(window, "cartridge_type_entry"); short new_cartridge_value = NameToValue(CNCL_CARTRIDGE, (char*)gtk_entry_get_text(GTK_ENTRY(entry))); short media_type_value = GetCurrentnValue(CNCL_MEDIATYPE); if( !IsAvailableMedia(g_mediatype_dialog, media_type_value, new_cartridge_value) ) { short new_media_type_value; if( (new_media_type_value = ShowMediaTypeDialog(g_mediatype_dialog, media_type_value, new_cartridge_value)) != -1 ) { UpdateMenuLink(CNCL_MEDIATYPE, new_media_type_value); UpdateMenuLink(CNCL_CARTRIDGE, new_cartridge_value); #ifdef NEED_TO_SAVE_GRAYSCALE if( GetCurrentnValue(CNCL_GRAYSCALE) != CND_BJGRAYSCALE_GRAY ) { short gray_scale_value = IsGrayPrint(g_main_window)? CND_BJGRAYSCALE_ON : CND_BJGRAYSCALE_OFF; UpdateMenuLink(CNCL_GRAYSCALE, gray_scale_value); } #endif UpdateWidgets(window, "cartridge_type_combo"); } else { UpdateWidgets(window, NULL); } } else { UpdateMenuLink(CNCL_CARTRIDGE, new_cartridge_value); #ifdef NEED_TO_SAVE_GRAYSCALE if( GetCurrentnValue(CNCL_GRAYSCALE) != CND_BJGRAYSCALE_GRAY ) { short gray_scale_value = IsGrayPrint(g_main_window)? CND_BJGRAYSCALE_ON : CND_BJGRAYSCALE_OFF; UpdateMenuLink(CNCL_GRAYSCALE, gray_scale_value); } #endif UpdateWidgets(window, "cartridge_type_combo"); } #ifdef GUI_WITH_PIXMAPS UpdateDrawingArea(window, "basic_draw_area"); #endif g_cartridge_type_entry_changed = FALSE; }
void on_color_dialog_gamma_entry_changed (GtkEditable *editable, gpointer user_data) { short gamma = NameToValue(CNCL_INPUT_GAMMA, (char*)gtk_entry_get_text(GTK_ENTRY(editable))); UpdateMenuLink(CNCL_INPUT_GAMMA, gamma); }
TEnumValueType CEnumeratedTypeValues::FindValue(const CTempString& name) const { const TNameToValue& m = NameToValue(); TNameToValue::const_iterator i = m.find(name); if ( i == m.end() ) { NCBI_THROW(CSerialException,eInvalidData, "invalid value of enumerated type"); } return i->second; }
static void update_by_paper_gap_entry() { GtkWidget* window = UI_DIALOG(g_main_window)->window; GtkWidget* entry = LookupWidget(window, "paper_gap_entry"); short value = NameToValue(CNCL_PAPERGAP_COMMAND, (char*)gtk_entry_get_text(GTK_ENTRY(entry))); UpdateMenuLink(CNCL_PAPERGAP_COMMAND, value); UpdateWidgets(window, "paper_gap_combo"); #ifdef GUI_WITH_PIXMAPS UpdateDrawingArea(window, "basic_draw_area"); #endif g_paper_gap_entry_changed = FALSE; }
static void update_by_media_supply_entry() { GtkWidget* window = UI_DIALOG(g_main_window)->window; GtkWidget* entry = LookupWidget(window, "media_supply_entry"); short value = NameToValue(CNCL_MEDIASUPPLY, (char*)gtk_entry_get_text(GTK_ENTRY(entry))); UpdateMenuLink(CNCL_MEDIASUPPLY, value); UpdateWidgets(window, "media_supply_combo"); #ifdef GUI_WITH_PIXMAPS UpdateDrawingArea(window, "basic_draw_area"); #endif g_media_supply_entry_changed = FALSE; }
static void update_by_media_size_entry() { GtkWidget* window = UI_DIALOG(g_main_window)->window; GtkWidget* entry = LookupWidget(window, "media_size_entry"); short value = NameToValue(CNCL_PAPERSIZE, (char*)gtk_entry_get_text(GTK_ENTRY(entry))); UpdateMenuLink(CNCL_PAPERSIZE, value); if( CND_SIZE_USER == GetCurrentnValue(CNCL_PAPERSIZE) ) { set_user_paper_size(); } UpdateWidgets(window, "media_size_combo"); #ifdef GUI_WITH_PIXMAPS UpdateDrawingArea(window, "basic_draw_area"); #endif g_media_size_entry_changed = FALSE; }
bool CEnumeratedTypeValues::IsValidName(const CTempString& name) const { const TNameToValue& m = NameToValue(); return ( m.find(name) != m.end() ); }
void UpdateWidgets(GtkWidget* window, gchar* except_name) { char *current_comb_supply = NULL; char *current_comb_supply_local = NULL; short len = 0; short current_comb_supply_id = 0; #ifdef _PRINTUI_DEBUG_ fprintf(stderr,"\n### UpdateWidgets :except_name = %s ###\n",except_name); #endif /* Ver.2.70: for "Front for Plain" */ if( except_name!=NULL ){ /* Store "media_supply_entry" setting(UI strings) */ /* Ver.2.80 */ GtkWidget* combo = LookupWidget(window, "media_supply_combo"); current_comb_supply = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); len = strlen(current_comb_supply) + 1; current_comb_supply_local = malloc( len ); memset(current_comb_supply_local,0x00, len ); strncpy( current_comb_supply_local , current_comb_supply , len ); current_comb_supply_local[len-1] = '\0'; #ifdef _PRINTUI_DEBUG_ fprintf(stderr,"current_comb_supply_local = %s\n",current_comb_supply_local); #endif } // Print bw button if( !SameName(except_name, "print_bw_button") ) { gboolean sensitive = TRUE; switch( GetCurrentnValue(CNCL_GRAYSCALE) ) { case CND_BJGRAYSCALE_OFF: break; case CND_BJGRAYSCALE_ON: break; case CND_BJGRAYSCALE_GRAY: sensitive = FALSE; break; default: break; } gtk_widget_set_sensitive( LookupWidget(window, "print_bw_button1"), sensitive); gtk_widget_set_sensitive( LookupWidget(window, "print_bw_button2"), sensitive); } // Media type combo if( !SameName(except_name, "media_type_combo") ) { #ifdef _PRINTUI_DEBUG_ fprintf(stderr,"UpdateWidgets:media_type_combo\n"); #endif SetItemsToComboBox(window, "media_type_combo", CNCL_MEDIATYPE, GetCurrentnValue(CNCL_MEDIATYPE));/* Ver.2.80 */ } // Media supply combo if( !SameName(except_name, "media_supply_combo") ) { GList* glist = GetComboList(CNCL_MEDIASUPPLY); /* iP3300,MP510:Add "Front for Plain" (This value is always available) */ { char *str; //GetAllFlags:If CND_SUPPLY_CASSETTE_04 exist --> str > 0 if( GetAllFlags( CNCL_MEDIASUPPLY , CND_SUPPLY_CASSETTE_04 ) >= 0 ){ str = ValueToName( CNCL_MEDIASUPPLY , CND_SUPPLY_FRONT_FOR_PLAIN ); glist = g_list_append(glist, str); } } /* Ver.2.70: for "Front for Plain" */ if( except_name!=NULL ){ /* UI setting at the top of this function is not disable on CNCLDB --> use it (to UI) */ /* UI setting at the top of this function is disable on CNCLDB --> use current value of CNCLDB (to UI) */ current_comb_supply_id = NameToValue( CNCL_MEDIASUPPLY , current_comb_supply_local ); /* Replace "CND_SUPPLY_FRONT_FOR_PLAIN" with "CND_SUPPLY_ASF" before check */ if( current_comb_supply_id == CND_SUPPLY_FRONT_FOR_PLAIN ) current_comb_supply_id = CND_SUPPLY_ASF; if( IsAvailableValue( CNCL_MEDIASUPPLY , current_comb_supply_id ) ){ /* UI setting is not disable on CNCLDB */ SetGListToComboBox(window, "media_supply_combo",glist, current_comb_supply_local , CNCL_MEDIASUPPLY );/* Ver.2.80 */ }else{ /* UI setting is disable on CNCLDB */ #ifdef _PRINTUI_DEBUG_ fprintf(stderr," IsAvailableValue(%s,ID=%d): not Available!!\n",current_comb_supply_local,current_comb_supply_id); #endif SetGListToComboBox(window, "media_supply_combo",glist, GetCurrentString(CNCL_MEDIASUPPLY) , CNCL_MEDIASUPPLY );/* Ver.2.80 */ } } else{ //NULL --> Select "CNCLDB current value" on UI SetGListToComboBox(window, "media_supply_combo",glist, GetCurrentString(CNCL_MEDIASUPPLY) , CNCL_MEDIASUPPLY);/* Ver.2.80 */ } } // Cartridge type combo if( !SameName(except_name, "cartridge_type_combo") ) { #ifdef _PRINTUI_DEBUG_ fprintf(stderr,"UpdateWidgets:cartridge_type_combo\n"); #endif SetItemsToComboBox(window, "cartridge_type_combo", CNCL_CARTRIDGE, GetCurrentnValue(CNCL_CARTRIDGE));/* Ver.2.80 */ } // Quality radio button { gboolean custom_active = GTK_TOGGLE_BUTTON( LookupWidget(window, "quality_custom_button"))->active; GtkWidget* custom_button = LookupWidget(window, "quality_dialog_button"); short quality = GetCurrentnValue(CNCL_PRINTQUALITY); GtkWidget* button; short value[3]; int i; for( i = 0 ; i < 3 ; i++ ) { button = LookupWidget(window, g_quality_button_name[i]); value[i] = GetCurrentnValue(g_mess_map[i]); if( !custom_active && value[i] == quality ) { // activate button gtk_widget_set_sensitive(custom_button, FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); } if( value[i] != CND_QUALITY_ABSOLUTE_NA ) gtk_widget_set_sensitive(button, TRUE); else gtk_widget_set_sensitive(button, FALSE); } if( custom_active ){ // activate custom button gtk_widget_set_sensitive(custom_button, TRUE); } } // Color auto radio button { GtkWidget* button = LookupWidget(window, "color_auto_button"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(button), g_main_window->color_auto ); } // Color adjust radio button { GtkWidget* button = LookupWidget(window, "color_dialog_button"); if( GTK_TOGGLE_BUTTON( LookupWidget(window, "color_manual_button"))->active ) gtk_widget_set_sensitive(button, TRUE); else gtk_widget_set_sensitive(button, FALSE); } // Guide(Thickness etc...) { GtkWidget* label = LookupWidget(window, "thick_msg_label"); char* position_msg = GetCurrentString(CNCL_MESS_THICK); gtk_label_set_text(GTK_LABEL(label), (gchar*)position_msg); } #ifdef _PRINTUI_DEBUG_ fprintf(stderr,"UpdateWidgets:8\n"); #endif // Paper gap combo if( !SameName(except_name, "paper_gap_combo") ) { #ifdef _PRINTUI_DEBUG_ fprintf(stderr,"UpdateWidgets:paper_gap_combo\n"); #endif SetItemsToComboBox(window, "paper_gap_combo", CNCL_PAPERGAP_COMMAND, GetCurrentnValue(CNCL_PAPERGAP_COMMAND));/* Ver.2.80 */ } ///////////////////////////////////////////////////////////////// // Media size combo if( !SameName(except_name, "media_size_combo") ) { //Ver.3.00 SetItemsToComboBox(window, "media_size_combo", CNCL_PAPERSIZE, GetCurrentnValue(CNCL_PAPERSIZE)); } // Printing type combo if( !SameName(except_name, "printing_type_combo") ) { SetTextArrayToComboBox(window, "printing_type_combo", (const gchar**)g_printing_type_name, (const short*)g_printing_type_value, g_main_window->printing_type); } // Printing scaling hbox. { GtkWidget* hbox = LookupWidget(window, "scaling_hbox"); if( g_main_window->printing_type == PRINTING_TYPE_SCALE ) gtk_widget_show(hbox); else gtk_widget_hide(hbox); } // Printing scaling spin. if( !SameName(except_name, "printing_scaling_button") ) { GtkSpinButton* scaling_spin = (GtkSpinButton*)LookupWidget(window, "printing_scaling_spin"); gtk_adjustment_set_value(scaling_spin->adjustment, (gfloat)g_main_window->scaling); } // Centering button. if( !SameName(except_name, "centering_button") ) { gboolean active = (g_main_window->centering == LOCATION_CENTER)? TRUE : FALSE; gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window, "centering_button")), active); } if( IsAvailableBorderless() ) { short margin_type = GetCurrentnValue(CNCL_MARGINTYPE); gboolean active = (margin_type == CND_MARGIN_MINUS)? TRUE : FALSE; // Borderless hbox. GtkWidget* hbox = LookupWidget(window, "borderless_hbox"); // gtk_widget_set_sensitive(hbox, active); if( active == TRUE ) gtk_widget_show(hbox); else gtk_widget_hide(hbox); // Borderless button. if( !SameName(except_name, "borderless_button") ) { GtkWidget* button = LookupWidget(window, "borderless_button"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active); } // Border ext button. if( !SameName(except_name, "border_ext_button") ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window, g_border_ext_button_name[g_main_window->ext_border])), TRUE); } } if( IsAvailableDuplex() ) { GtkWidget* duplex_vbox; GtkWidget* duplex_hbox; gboolean active; // Duplex vbox. duplex_vbox = LookupWidget(window, "duplex_vbox"); gtk_widget_set_sensitive(duplex_vbox, IsAvailableValue(CNCL_DUPLEX_PRINTING, CND_DUPLEX_AUTO)); // Duplex hbox. active = (CND_DUPLEX_AUTO == GetCurrentnValue(CNCL_DUPLEX_PRINTING))? TRUE : FALSE; /* Ver.2.70 */ duplex_hbox = LookupWidget(window, "duplex_hbox"); gtk_widget_set_sensitive(duplex_hbox, active); // Auto Duplex button. if( !SameName(except_name, "auto_duplex_button") ) { // GtkWidget* button = LookupWidget(window, "auto_duplex_button"); // not in use... } // Stapleside if( !SameName(except_name, "stapleside_button") ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(LookupWidget(UI_DIALOG(g_main_window)->window, g_staple_button_name[g_main_window->stapleside])), TRUE); } } // Copies spin. if( !SameName(except_name, "copies_spin") ) { GtkSpinButton* copies_spin = (GtkSpinButton*)LookupWidget(window, "copies_spin"); gtk_adjustment_set_value(copies_spin->adjustment, (gfloat)g_main_window->copies); } if(current_comb_supply_local){ free(current_comb_supply_local); current_comb_supply_local = NULL; } // Ver.2.90:Custom Paper Size dialog button { GtkWidget* hbox_user = LookupWidget(window, "hbox_user"); // GtkWidget* space_user = LookupWidget(window, "usersize_space_label"); //Ver.3.10テスト中 if( CND_SIZE_USER == GetCurrentnValue(CNCL_PAPERSIZE) ) { gtk_widget_show(hbox_user); // gtk_widget_show(space_user); }else { gtk_widget_hide(hbox_user); // gtk_widget_hide(space_user); } } /* Ver.3.00: Show supply position */ { GtkWidget* supply_mes_label2 = LookupWidget(window, "supply_label2"); short media,size; media = GetCurrentnValue(CNCL_MEDIATYPE); size = GetCurrentnValue(CNCL_PAPERSIZE); if( GetCurrentnValue(CNCL_MEDIASUPPLY) == CND_SUPPLY_AUTO_SELECT ) { if( ( media==CND_MEDIA_PLAIN ) && ( size==CND_SIZE_A4 || size==CND_SIZE_A5 || size==CND_SIZE_B5 || size==CND_SIZE_LETTER ) ){ gtk_widget_hide(supply_mes_label2); } else{ gtk_label_set_text(GTK_LABEL(supply_mes_label2), (gchar*)ValueToName( CNCL_MEDIASUPPLY , CND_SUPPLY_ASF )); gtk_widget_show(supply_mes_label2); } } else{ gtk_widget_hide(supply_mes_label2); } } }
gboolean CheckMediaSizeCombination(LPBJFLTDEVICE bjdev, gboolean* change_item) { MediaSizeTable* table = GetMediaSizeTable(bjdev->bjfltModelID); char* media = ValueToKey(CNCL_MEDIATYPE, bjdev->bjfltMediaType); char* size = ValueToKey(CNCL_PAPERSIZE, bjdev->bjfltPaperSize); int change; gboolean exec_print; int result = TRUE; gchar* applied = NULL; gchar* applied_title = NULL; GtkWidget *window = UI_DIALOG(g_main_window)->window; *change_item = FALSE; if( table == NULL ) return TRUE; while( table->base != NULL ) { if( !strcmp(media, table->base) ) { // Get available media size. applied = GetAvailableSize(table->applied); if( SearchWord(size, applied) == NULL ) { applied_title = GetAvailableSize(table->applied_title); change = UI_MEDIASIZE_CHANGE_SIZE; break; } } else if( !strcmp(size, table->base) ) { // Get available media type. applied = GetAvailableMedia(table->applied); if( SearchWord(media, applied) == NULL ) { applied_title = GetAvailableMedia(table->applied_title); change = UI_MEDIASIZE_CHANGE_MEDIA; break; } } table++; } if( table->base ) { UIMediaSizeDialog* dialog = NULL; int (*show_dialog)(UIMediaSizeDialog*, gchar*) = NULL; switch( table->type ) { case UI_MEDIASIZE_ILLEGAL: if( 1 >= CountWords(applied) ) { dialog = g_mediasize_illegal_dialog; show_dialog = ShowMediaSizeIllegalDialog; } else { dialog = g_mediasize_illegal_select_dialog; show_dialog = ShowMediaSizeIllegalSelectDialog; } break; case UI_MEDIASIZE_RECOMMEND: dialog = g_mediasize_recommend_dialog; show_dialog = ShowMediaSizeRecommendDialog; break; } // Show the dialog when the number of applied item is more than 1. if( dialog && strlen(applied) > 0 ) { dialog->media = media; dialog->size = size; dialog->table = (void*)table; dialog->change = change; // Show dialog. exec_print = show_dialog(dialog, applied_title); if( dialog->apply ) { GtkWidget* analyzer_combo = NULL; char *change_to_value_str = NULL; short change_to_id; if( dialog->item_count > 1 ) /* multiple items -> get value id of chenge item */ { /* Ver.3.20 */ if( table->type == UI_MEDIASIZE_RECOMMEND ) /* recommend */ analyzer_combo = LookupWidget(UI_DIALOG(dialog)->window, "mediasize_recommend_combo"); else /* illegal */ analyzer_combo = LookupWidget(UI_DIALOG(dialog)->window, "mediasize_illegal_combo"); change_to_value_str = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(analyzer_combo)); if( dialog->change == UI_MEDIASIZE_CHANGE_SIZE ) /* change size */ change_to_id = NameToValue( CNCL_PAPERSIZE , change_to_value_str ); else /* change media */ change_to_id = NameToValue( CNCL_MEDIATYPE , change_to_value_str ); dialog->current_change_to_id = change_to_id; if(change_to_value_str){ free(change_to_value_str); change_to_value_str = NULL; } } if( dialog->change == UI_MEDIASIZE_CHANGE_SIZE ) { UpdateMenuLink(CNCL_PAPERSIZE, dialog->current_change_to_id); DisableSignal(); UpdateWidgets(window, NULL); EnableSignal(); } else { // Save current supply value. short supply_value = GetCurrentnValue(CNCL_MEDIASUPPLY); // Change the media type. UpdateMenuLink(CNCL_MEDIATYPE, dialog->current_change_to_id); DisableSignal(); UpdateWidgets(window, NULL); EnableSignal(); if( supply_value != GetCurrentnValue(CNCL_MEDIASUPPLY) ) { // If no supply value for the current media type, // Some alert should be shown. // Only restore the saved supply value in this version. //UpdateMenuLink(CNCL_MEDIASUPPLY, supply_value); } } *change_item = TRUE; } result = exec_print; } } if( applied ) g_free(applied); if( applied_title ) g_free(applied_title); /* Ver.3.00 */ return result; }