-
Notifications
You must be signed in to change notification settings - Fork 71
/
APILookupGtk.txt
4947 lines (4444 loc) · 128 KB
/
APILookupGtk.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# This file is part of gtkD.
#
# gtkD is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# gtkD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with gtkD; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#############################################
### Definitions for wrapping Gtk+ ###########
#############################################
# must start with wrap
wrap: gtk
file: Gtk-3.0.gir
addAliases: start
alias GtkAllocation* Allocation;
addAliases: end
struct: Action
import: gtk.Image
import: gtk.Menu
import: gtk.MenuItem
import: gtk.ToolItem
noCode: get_stock_id
noCode: create_icon
noCode: create_menu_item
noCode: create_tool_item
noCode: create_menu
code: start
/**
* Creates a new GtkAction object. To add the action to a
* GtkActionGroup and set the accelerator for the action,
* call gtk_action_group_add_action_with_accel().
* See the section called UI Definitions for information on allowed action
* names.
* Since 2.4
* Params:
* name = A unique name for the action
* label = the label displayed in menu items and on buttons, or NULL
* tooltip = a tooltip for the action, or NULL
* stockId = the stock icon to display in widgets representing the
* action.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (string name, string label, string tooltip, StockID stockId)
{
this(name, label, tooltip, cast(string)stockId);
}
/**
* Gets the stock id of action.
* Since 2.16
* Returns: the stock id
*/
public StockID getStockId()
{
return cast(StockID)Str.toString(gtk_action_get_stock_id(gtkAction));
}
/**
* Sets the stock id on action
* Since 2.16
* Params:
* stockId = the stock id
*/
public void setStockId(StockID stockId)
{
setStockId(stockId);
}
/**
* This function is intended for use by action implementations to
* create icons displayed in the proxy widgets.
* Since 2.4
* Params:
* iconSize = the size of the icon that should be created. [type int]
* Returns: a widget that displays the icon for this action.
*/
public Image createIcon(GtkIconSize iconSize)
{
// GtkWidget * gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size);
auto p = gtk_action_create_icon(gtkAction, iconSize);
if(p is null)
{
return null;
}
return new Image(cast(GtkImage*) p);
}
/**
* Creates a menu item widget that proxies for the given action.
* Since 2.4
* Returns: a menu item connected to the action.
*/
public MenuItem createMenuItem()
{
// GtkWidget * gtk_action_create_menu_item (GtkAction *action);
auto p = gtk_action_create_menu_item(gtkAction);
if(p is null)
{
return null;
}
return new MenuItem(cast(GtkMenuItem*) p);
}
/**
* Creates a toolbar item widget that proxies for the given action.
* Since 2.4
* Returns: a toolbar item connected to the action.
*/
public ToolItem createToolItem()
{
// GtkWidget * gtk_action_create_tool_item (GtkAction *action);
auto p = gtk_action_create_tool_item(gtkAction);
if(p is null)
{
return null;
}
return new ToolItem(cast(GtkToolItem*) p);
}
/**
* If action provides a GtkMenu widget as a submenu for the menu
* item or the toolbar item it creates, this function returns an
* instance of that menu.
* Since 2.12
* Returns: the menu item provided by the action, or NULL.
*/
public Menu createMenu()
{
// GtkWidget * gtk_action_create_menu (GtkAction *action);
auto p = gtk_action_create_menu(gtkAction);
if(p is null)
{
return null;
}
return new Menu(cast(GtkMenu*) p);
}
code: end
struct: Alignment
code: start
/** */
public static Alignment center(Widget widget)
{
Alignment a = new Alignment(0.5, 0.5, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment north(Widget widget)
{
Alignment a = new Alignment(0.5, 0.0, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment south(Widget widget)
{
Alignment a = new Alignment(0.5, 1.0, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment east(Widget widget)
{
Alignment a = new Alignment(1.0, 0.5, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment west(Widget widget)
{
Alignment a = new Alignment(0.0, 0.5, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment northWest(Widget widget)
{
Alignment a = new Alignment(0.0, 0.0, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment southWest(Widget widget)
{
Alignment a = new Alignment(0.0, 0.5, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment northEast(Widget widget)
{
Alignment a = new Alignment(1.0, 0.0, 0, 0);
a.add(widget);
return a;
}
/** */
public static Alignment southEast(Widget widget)
{
Alignment a = new Alignment(1.0, 1.0, 0, 0);
a.add(widget);
return a;
}
code: end
struct: Application
noCode: set_accels_for_action
code: start
/**
* Sets zero or more keyboard accelerators that will trigger the
* given action. The first item in accels will be the primary
* accelerator, which may be displayed in the UI.
*
* To remove all accelerators for an action, use an empty
* array for accels.
*
* Params:
* detailedActionName = a detailed action name, specifying an action
* and target to associate accelerators with
* accels = a list of accelerators in the format
* understood by gtk_accelerator_parse()
*
* Since: 3.12
*/
public void setAccelsForAction(string detailedActionName, string[] accels)
{
char** accel;
if (accels)
accel = Str.toStringzArray(accels);
else
accel = [cast(char*)null].ptr;
gtk_application_set_accels_for_action(gtkApplication, Str.toStringz(detailedActionName), accel);
}
code: end
struct: Buildable
alias: set_name buildableSetName
alias: get_name buildableGetName
struct: Builder
noCode: new
noCode: get_objects
#There are now 3 constructors that have a single string parameter, disable 2 of them.
noCode: new_from_resource
noCode: new_from_string
array: add_from_string buffer length
import: glib.c.functions
import: std.string
#imports for gtk_builder_real_get_type_from_name_override
import: gobject.c.functions
import: gtkd.paths
import: glib.Module
import: gobject.Type
code: start
/**
* Creates a new builder object.
* Since 2.12
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this ()
{
// GtkBuilder* gtk_builder_new (void);
auto p = gtk_builder_new();
if(p is null)
{
throw new ConstructionException("null returned by gtk_builder_new()");
}
this(cast(GtkBuilder*) p);
GtkBuilderClass* klass = Type.getInstanceClass!(GtkBuilderClass)( this );
klass.getTypeFromName = >k_builder_real_get_type_from_name_override;
}
/**
* This function is a modification of _gtk_builder_resolve_type_lazily from "gtk/gtkbuilder.c".
* It is needed because it assumes we are linking at compile time to the gtk libs.
* specifically the NULL in g_module_open( NULL, 0 );
* It replaces the default function pointer "get_type_from_name" in GtkBuilderClass.
*/
extern(C) private static GType gtk_builder_real_get_type_from_name_override ( GtkBuilder* builder, const(char)* name )
{
GType gtype;
gtype = g_type_from_name( name );
if (gtype != GType.INVALID)
{
return gtype;
}
/*
* Try to map a type name to a _get_type function
* and call it, eg:
*
* GtkWindow -> gtk_window_get_type
* GtkHBox -> gtk_hbox_get_type
* GtkUIManager -> gtk_ui_manager_get_type
*
*/
char c;
string symbol_name;
for (int i = 0; name[i] != '\0'; i++)
{
c = name[i];
/* skip if uppercase, first or previous is uppercase */
if ((c == Str.asciiToupper (c) &&
i > 0 && name[i-1] != Str.asciiToupper (name[i-1])) ||
(i > 2 && name[i] == Str.asciiToupper (name[i]) &&
name[i-1] == Str.asciiToupper (name[i-1]) &&
name[i-2] == Str.asciiToupper (name[i-2]))
)
symbol_name ~= '_';
symbol_name ~= Str.asciiTolower (c);
}
symbol_name ~= "_get_type" ;
/* scan linked librarys for function symbol */
foreach ( lib; importLibs )
{
GType function() func;
Module mod = Module.open( lib, GModuleFlags.LAZY );
if( mod is null )
continue;
scope(exit) mod.close();
if ( mod.symbol( symbol_name, cast(void**)&func ) ) {
return func();
}
}
return GType.INVALID;
}
/**
* Gets all objects that have been constructed by builder.
* Since 2.12
* Returns: an array containing all the objects constructed by the GtkBuilder instance.
*/
public ObjectG[] getObjects()
{
ObjectG[] objects;
// GSList* gtk_builder_get_objects (GtkBuilder *builder);
GSList* list = gtk_builder_get_objects(gtkBuilder);
while ( list.next !is null )
{
objects ~= ObjectG.getDObject!(ObjectG)(cast(GObject*) list.data);
list = list.next;
}
g_slist_free(list);
return objects;
}
code: end
struct: Button
import: gtk.Image
noCode: new_with_mnemonic
noCode: new_with_label
noCode: new_from_stock
code: start
private static IconSize currentIconSize = IconSize.BUTTON;
/** */
public static void setIconSize(IconSize iconSize)
{
currentIconSize = iconSize;
}
/** */
public static IconSize getIconSize()
{
return currentIconSize;
}
/**
* Creates a new GtkButton containing a label.
* If characters in label are preceded by an underscore, they are underlined.
* If you need a literal underscore character in a label, use '__' (two
* underscores). The first underlined character represents a keyboard
* accelerator called a mnemonic.
* Pressing Alt and that key activates the button.
* Params:
* label = The text of the button, with an underscore in front of the
* mnemonic character
* mnemonic = true if the button has an mnemnonic
* Returns:
* a new GtkButton
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (string label, bool mnemonic=true)
{
GtkButton* p;
if ( mnemonic )
{
// GtkWidget* gtk_button_new_with_mnemonic (const gchar *label);
p = cast(GtkButton*)gtk_button_new_with_mnemonic(Str.toStringz(label));
}
else
{
// GtkWidget* gtk_button_new_with_label (const gchar *label);
p = cast(GtkButton*)gtk_button_new_with_label(Str.toStringz(label));
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_button_new_with_label");
}
this(p);
}
/**
* Creates a new GtkButton containing the image and text from a stock item.
* Some stock ids have preprocessor macros like GTK_STOCK_OK and
* GTK_STOCK_APPLY.
* If stock_id is unknown, then it will be treated as a mnemonic
* label (as for gtk_button_new_with_mnemonic()).
* Params:
* StockID = the name of the stock item
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (StockID stockID, bool hideLabel=false)
{
// GtkWidget* gtk_button_new_from_stock (const gchar *stock_id);
if ( hideLabel )
{
this();
Image image = new Image(stockID,currentIconSize);
add(image);
}
else
{
auto p = gtk_button_new_from_stock(Str.toStringz(stockID));
if(p is null)
{
throw new ConstructionException("null returned by gtk_button_new_from_stock");
}
this(cast(GtkButton*) p);
}
}
/** */
public this(StockID stockID, void delegate(Button) dlg, bool hideLabel=false)
{
this(stockID, hideLabel);
addOnClicked(dlg);
}
/** */
public this(string label, void delegate(Button) dlg, bool mnemonic=true)
{
this(label, mnemonic);
addOnClicked(dlg);
}
/** */
public this(string label, void delegate(Button) dlg, string action)
{
this(label);
setActionName(action);
addOnClicked(dlg);
}
code: end
struct: ButtonBox
import: gtk.Button
import: gtk.HButtonBox
import: gtk.VButtonBox
code: start
/** */
static ButtonBox createActionBox(
void delegate(Button) onClicked,
StockID[] stocks,
string[] actions,
bool vertical=false
)
{
ButtonBox bBox;
if ( vertical )
{
bBox = VButtonBox.createActionBox();
}
else
{
bBox = HButtonBox.createActionBox();
}
Button button;
for( int i=0 ; i<stocks.length && i<actions.length ; i++)
{
button = new Button(stocks[i]);
bBox.packEnd(button, false, false, 7);
button.setActionName(actions[i]);
button.addOnClicked(onClicked);
}
return bBox;
}
/** */
static ButtonBox createOkBox(void delegate(Button) onClicked)
{
static StockID[] stocks = [StockID.OK];
string[] actions;
actions ~= "action.ok";
return createActionBox(onClicked, stocks, actions);
}
/** */
static ButtonBox createOkCancelBox(void delegate(Button) onClicked)
{
static StockID[] stocks = [StockID.OK, StockID.CANCEL];
string[] actions;
actions ~= "action.ok";
actions ~= "action.cancel";
return createActionBox(onClicked, stocks, actions);
}
code: end
version 3.24: start
struct: CellAccessibleParent
out: get_cell_position row
out: get_cell_position column
version: end
struct: CellView
noCode: new_with_text
noCode: new_with_markup
code: start
/**
* Creates a new GtkCellView widget, adds a GtkCellRendererText
* to it, and makes its show text.
* If markup is true the text can be marked up with the Pango text
* markup language.
* Since: 2.6
* Params:
* text = the text to display in the cell view
* Returns:
* A newly created GtkCellView widget.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (string text, bool markup=true)
{
GtkCellView* p;
if ( markup )
{
// GtkWidget* gtk_cell_view_new_with_markup (const gchar *markup);
p = cast(GtkCellView*)gtk_cell_view_new_with_markup(Str.toStringz(text));
}
else
{
// GtkWidget* gtk_cell_view_new_with_text (const gchar *text);
p = cast(GtkCellView*)gtk_cell_view_new_with_text(Str.toStringz(text));
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_cell_view_new_with_");
}
this(p);
}
code: end
struct: CheckButton
import: glib.Str
import: gtk.Button
noCode: new_with_label
noCode: new_with_mnemonic
code: start
/**
* Creates a new GtkCheckButton with a GtkLabel to the right of it.
* If mnemonic is true the label
* will be created using gtk_label_new_with_mnemonic(), so underscores
* in label indicate the mnemonic for the check button.
* Params:
* label = The text of the button, with an underscore in front of the
* mnemonic character
* mnemonic = true if the button has an mnemnonic
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (string label, bool mnemonic=true)
{
GtkCheckButton* p;
if ( mnemonic )
{
// GtkWidget* gtk_check_button_new_with_mnemonic (const gchar *label);
p = cast(GtkCheckButton*)gtk_check_button_new_with_mnemonic(Str.toStringz(label));
}
else
{
// GtkWidget* gtk_check_button_new_with_label (const gchar *label);
p = cast(GtkCheckButton*)gtk_check_button_new_with_label(Str.toStringz(label));
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_check_button_new_");
}
this(p);
}
/** */
public this(string label, void delegate(CheckButton) onClicked, bool mnemonic=true)
{
this(label, mnemonic);
addOnClicked(cast(void delegate(Button))onClicked);
}
code: end
struct: CheckMenuItem
import: glib.Str
noCode: new_with_label
noCode: new_with_mnemonic
code: start
/**
* Creates a new GtkCheckMenuItem with a label.
* Params:
* label = the string to use for the label.
* mnemonic = if true the label
* will be created using gtk_label_new_with_mnemonic(), so underscores
* in label indicate the mnemonic for the menu item.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (string label, bool mnemonic=true)
{
GtkCheckMenuItem* p;
if ( mnemonic )
{
// GtkWidget* gtk_check_menu_item_new_with_mnemonic (const gchar *label);
p = cast(GtkCheckMenuItem*)gtk_check_menu_item_new_with_mnemonic(Str.toStringz(label));
}
else
{
// GtkWidget* gtk_check_menu_item_new_with_label (const gchar *label);
p = cast(GtkCheckMenuItem*)gtk_check_menu_item_new_with_label(Str.toStringz(label));
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_check_menu_item_new_with_");
}
this(p);
}
code: end
struct: ColorButton
#Use the functions from the mixed in interface.
noCode: set_rgba
noCode: get_rgba
noCode: set_use_alpha
noCode: get_use_alpha
struct: ColorChooser
interfaceCode: start
/**
* Gets the currently-selected color.
*
* Returns: a gdk.RGBA to fill in with the current color.
*
* Since: 3.4
*/
public final RGBA getRgba()
{
RGBA color;
getRgba(color);
return color;
}
interfaceCode: end
struct: ColorSelectionDialog
import: gtk.ColorSelection
noCode: get_color_selection
code: start
/**
* Retrieves the ColorSelection widget embedded in the dialog.
*
* Return: the embedded ColorSelection
*
* Since: 2.14
*/
public ColorSelection getColorSelection()
{
auto p = gtk_color_selection_dialog_get_color_selection(gtkColorSelectionDialog);
if(p is null)
{
return null;
}
return ObjectG.getDObject!(ColorSelection)(cast(GtkColorSelection*) p);
}
code: end
struct: ComboBox
import: glib.ConstructionException
noCode: new
noCode: new_with_entry
noCode: new_with_model
noCode: new_with_model_and_entry
noCode: new_with_area
noCode: new_with_area_and_entry
code: start
/**
* Creates a new empty GtkComboBox.
* Params:
* entry = If true, create an empty ComboBox with an entry.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (bool entry=true)
{
GtkComboBox* p;
if ( entry )
{
// GtkWidget* gtk_combo_box_new_text (void);
p = cast(GtkComboBox*)gtk_combo_box_new_with_entry();
}
else
{
// GtkWidget* gtk_combo_box_new (void);
p = cast(GtkComboBox*)gtk_combo_box_new();
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_combo_box_new");
}
this(p);
}
/**
* Creates a new GtkComboBox with the model initialized to model.
* Params:
* model = A GtkTreeModel.
* entry = If true, create an empty ComboBox with an entry.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (TreeModelIF model, bool entry=true)
{
GtkComboBox* p;
if ( entry )
{
// GtkWidget* gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model);
p = cast(GtkComboBox*)gtk_combo_box_new_with_model_and_entry((model is null) ? null : model.getTreeModelStruct());
}
else
{
// GtkWidget* gtk_combo_box_new_with_model (GtkTreeModel *model);
p = cast(GtkComboBox*)gtk_combo_box_new_with_model((model is null) ? null : model.getTreeModelStruct());
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_combo_box_new");
}
this(p);
}
/**
* Creates a new empty GtkComboBox using area to layout cells.
* Params:
* area = the GtkCellArea to use to layout cell renderers.
* entry = If true, create an empty ComboBox with an entry.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (CellArea area, bool entry=true)
{
GtkComboBox* p;
if ( entry )
{
// GtkWidget* gtk_combo_box_new_with_area_and_entry (GtkCellArea *area);
p = cast(GtkComboBox*)gtk_combo_box_new_with_area_and_entry((area is null) ? null : area.getCellAreaStruct());
}
else
{
// GtkWidget* gtk_combo_box_new_with_area (GtkCellArea* area);
p = cast(GtkComboBox*)gtk_combo_box_new_with_area((area is null) ? null : area.getCellAreaStruct());
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_combo_box_new");
}
this(p);
}
code: end
struct: ComboBoxText
import: glib.ConstructionException
import: gobject.Signals
import: gtk.TreeIter
import: gtk.TreeModelIF
import: gdk.c.types
import: std.algorithm
override: remove_all
noCode: new
noCode: new_with_entry
code: start
/**
* Creates a new ComboBoxText, which is a ComboBox just displaying strings.
* Params:
* entry = If true, create an ComboBox with an entry.
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this (bool entry=true)
{
GtkComboBoxText* p;
if ( entry )
{
// GtkWidget* gtk_combo_box_text_new_with_entry (void);
p = cast(GtkComboBoxText*)gtk_combo_box_text_new_with_entry();
}
else
{
// GtkWidget* gtk_combo_box_text_new (void);
p = cast(GtkComboBoxText*)gtk_combo_box_text_new();
}
if(p is null)
{
throw new ConstructionException("null returned by gtk_combo_box_new");
}
this(p);
}
/** */
public void setActiveText(string text, bool insert=false)
{
int active = 0;
setActive(0);
while ( getActive() >= 0 ) // returns -1 if end of list if reached
{
if( text == getActiveText() ) return;
++active;
setActive(active);
}
// was not found, the combo has now nothing selected
if ( insert )
{
append("", text);
setActive(active);
}
}
/** */
int getIndex(string text)
{
TreeIter iter;
TreeModelIF model = getModel();
int index = 0;
bool found = false;
bool end = false;
if ( model.getIterFirst(iter) )
{
iter.setModel(model);
while ( !end && iter !is null && !found )
{
found = iter.getValueString(0) == text;
if ( !found )
{
end = !model.iterNext(iter);
++index;
}
}
}
else
{
end = true;
}
return end ? -1 : index;
}
/** */
void prependOrReplaceText(string text)
{
int index = getIndex(text);
if ( index > 0 )
{
remove(index);
prepend("", text);
}
else if ( index == -1 )
{
prepend("", text);
}
}
/**
* The changed signal is emitted when the active
* item is changed. The can be due to the user selecting
* a different item from the list, or due to a
* call to gtk_combo_box_set_active_iter().
* It will also be emitted while typing into the entry of a combo box
* with an entry.
*
* Since: 2.4
*/
gulong addOnChanged(void delegate(ComboBoxText) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
}
/**
* For combo boxes that are created with an entry (See GtkComboBox:has-entry).
*
* A signal which allows you to change how the text displayed in a combo box's
* entry is displayed.
*
* Connect a signal handler which returns an allocated string representing
* @path. That string will then be used to set the text in the combo box's entry.
* The default signal handler uses the text from the GtkComboBox::entry-text-column
* model column.
*
* Here's an example signal handler which fetches data from the model and
* displays it in the entry.
* |[<!-- language="C" -->
* static gchar*
* format_entry_text_callback (GtkComboBox *combo,
* const gchar *path,
* gpointer user_data)
* {
* GtkTreeIter iter;
* GtkTreeModel model;
* gdouble value;
*
* model = gtk_combo_box_get_model (combo);
*
* gtk_tree_model_get_iter_from_string (model, &iter, path);
* gtk_tree_model_get (model, &iter,
* THE_DOUBLE_VALUE_COLUMN, &value,
* -1);
*
* return g_strdup_printf ("%g", value);
* }
* ]|
*
* Params:
* path = the GtkTreePath string from the combo box's current model to format text for
*
* Return: a newly allocated string representing @path
* for the current GtkComboBox model.
*
* Since: 3.4
*/
gulong addOnFormatEntryText(string delegate(string, ComboBoxText) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
return Signals.connect(this, "format-entry-text", dlg, connectFlags ^ ConnectFlags.SWAPPED);
}
/**
* The ::move-active signal is a
* [keybinding signal][GtkBindingSignal]
* which gets emitted to move the active selection.
*
* Params: