|
1
|
1 #import "NSComboBox+fb2k.h"
|
|
|
2
|
|
|
3 namespace fb2k {
|
|
|
4 void comboSetupHistory(NSComboBox * box, cfg_dropdown_history & var) {
|
|
|
5 [box removeAllItems];
|
|
|
6 pfc::string8 temp; var.get_state( temp );
|
|
|
7 NSString * str = [NSString stringWithUTF8String: temp.c_str()];
|
|
|
8 if ( str.length == 0 ) return;
|
|
|
9 NSArray * arr = [str componentsSeparatedByCharactersInSet: NSCharacterSet.newlineCharacterSet];
|
|
|
10 if ( arr.count == 0 ) return;
|
|
|
11 for( NSString * str in arr ) {
|
|
|
12 if ( str.length > 0 ) [box addItemWithObjectValue: str];
|
|
|
13 }
|
|
|
14 box.stringValue = arr.firstObject;
|
|
|
15
|
|
|
16 [box.menu addItem: NSMenuItem.separatorItem];
|
|
|
17 }
|
|
|
18
|
|
|
19 void comboAddToHistory(NSComboBox * box, cfg_dropdown_history & var) {
|
|
|
20 NSString * str = box.stringValue;
|
|
|
21 if ( str.length > 0 ) var.add_item( str.UTF8String );
|
|
|
22 }
|
|
|
23 } // namespace fb2k
|