/usr/include/d/gtkd-3/gtk/IMContext.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /*
* 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 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gtk.IMContext;
private import gdk.Window;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
private import gtk.c.functions;
public import gtk.c.types;
public import gtkc.gtktypes;
private import pango.PgAttributeList;
private import std.algorithm;
/**
* #GtkIMContext defines the interface for GTK+ input methods. An input method
* is used by GTK+ text input widgets like #GtkEntry to map from key events to
* Unicode character strings.
*
* The default input method can be set programmatically via the
* #GtkSettings:gtk-im-module GtkSettings property. Alternatively, you may set
* the GTK_IM_MODULE environment variable as documented in
* [Running GTK+ Applications][gtk-running].
*
* The #GtkEntry #GtkEntry:im-module and #GtkTextView #GtkTextView:im-module
* properties may also be used to set input methods for specific widget
* instances. For instance, a certain entry widget might be expected to contain
* certain characters which would be easier to input with a certain input
* method.
*
* An input method may consume multiple key events in sequence and finally
* output the composed result. This is called preediting, and an input method
* may provide feedback about this process by displaying the intermediate
* composition states as preedit text. For instance, the default GTK+ input
* method implements the input of arbitrary Unicode code points by holding down
* the Control and Shift keys and then typing āUā followed by the hexadecimal
* digits of the code point. When releasing the Control and Shift keys,
* preediting ends and the character is inserted as text. Ctrl+Shift+u20AC for
* example results in the ā¬ sign.
*
* Additional input methods can be made available for use by GTK+ widgets as
* loadable modules. An input method module is a small shared library which
* implements a subclass of #GtkIMContext or #GtkIMContextSimple and exports
* these four functions:
*
* |[<!-- language="C" -->
* void im_module_init(GTypeModule *module);
* ]|
* This function should register the #GType of the #GtkIMContext subclass which
* implements the input method by means of g_type_module_register_type(). Note
* that g_type_register_static() cannot be used as the type needs to be
* registered dynamically.
*
* |[<!-- language="C" -->
* void im_module_exit(void);
* ]|
* Here goes any cleanup code your input method might require on module unload.
*
* |[<!-- language="C" -->
* void im_module_list(const GtkIMContextInfo ***contexts, int *n_contexts)
* {
* *contexts = info_list;
* *n_contexts = G_N_ELEMENTS (info_list);
* }
* ]|
* This function returns the list of input methods provided by the module. The
* example implementation above shows a common solution and simply returns a
* pointer to statically defined array of #GtkIMContextInfo items for each
* provided input method.
*
* |[<!-- language="C" -->
* GtkIMContext * im_module_create(const gchar *context_id);
* ]|
* This function should return a pointer to a newly created instance of the
* #GtkIMContext subclass identified by @context_id. The context ID is the same
* as specified in the #GtkIMContextInfo array returned by im_module_list().
*
* After a new loadable input method module has been installed on the system,
* the configuration file `gtk.immodules` needs to be
* regenerated by [gtk-query-immodules-3.0][gtk-query-immodules-3.0],
* in order for the new input method to become available to GTK+ applications.
*/
public class IMContext : ObjectG
{
/** the main Gtk struct */
protected GtkIMContext* gtkIMContext;
/** Get the main Gtk struct */
public GtkIMContext* getIMContextStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gtkIMContext;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gtkIMContext;
}
protected override void setStruct(GObject* obj)
{
gtkIMContext = cast(GtkIMContext*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GtkIMContext* gtkIMContext, bool ownedRef = false)
{
this.gtkIMContext = gtkIMContext;
super(cast(GObject*)gtkIMContext, ownedRef);
}
/** */
public static GType getType()
{
return gtk_im_context_get_type();
}
/**
* Asks the widget that the input context is attached to to delete
* characters around the cursor position by emitting the
* GtkIMContext::delete_surrounding signal. Note that @offset and @n_chars
* are in characters not in bytes which differs from the usage other
* places in #GtkIMContext.
*
* In order to use this function, you should first call
* gtk_im_context_get_surrounding() to get the current context, and
* call this function immediately afterwards to make sure that you
* know what you are deleting. You should also account for the fact
* that even if the signal was handled, the input context might not
* have deleted all the characters that were requested to be deleted.
*
* This function is used by an input method that wants to make
* subsitutions in the existing text in response to new input. It is
* not useful for applications.
*
* Params:
* offset = offset from cursor position in chars;
* a negative value means start before the cursor.
* nChars = number of characters to delete.
*
* Returns: %TRUE if the signal was handled.
*/
public bool deleteSurrounding(int offset, int nChars)
{
return gtk_im_context_delete_surrounding(gtkIMContext, offset, nChars) != 0;
}
/**
* Allow an input method to internally handle key press and release
* events. If this function returns %TRUE, then no further processing
* should be done for this key event.
*
* Params:
* event = the key event
*
* Returns: %TRUE if the input method handled the key event.
*/
public bool filterKeypress(GdkEventKey* event)
{
return gtk_im_context_filter_keypress(gtkIMContext, event) != 0;
}
/**
* Notify the input method that the widget to which this
* input context corresponds has gained focus. The input method
* may, for example, change the displayed feedback to reflect
* this change.
*/
public void focusIn()
{
gtk_im_context_focus_in(gtkIMContext);
}
/**
* Notify the input method that the widget to which this
* input context corresponds has lost focus. The input method
* may, for example, change the displayed feedback or reset the contexts
* state to reflect this change.
*/
public void focusOut()
{
gtk_im_context_focus_out(gtkIMContext);
}
/**
* Retrieve the current preedit string for the input context,
* and a list of attributes to apply to the string.
* This string should be displayed inserted at the insertion
* point.
*
* Params:
* str = location to store the retrieved
* string. The string retrieved must be freed with g_free().
* attrs = location to store the retrieved
* attribute list. When you are done with this list, you
* must unreference it with pango_attr_list_unref().
* cursorPos = location to store position of cursor (in characters)
* within the preedit string.
*/
public void getPreeditString(out string str, out PgAttributeList attrs, out int cursorPos)
{
char* outstr = null;
PangoAttrList* outattrs = null;
gtk_im_context_get_preedit_string(gtkIMContext, &outstr, &outattrs, &cursorPos);
str = Str.toString(outstr);
attrs = ObjectG.getDObject!(PgAttributeList)(outattrs);
}
/**
* Retrieves context around the insertion point. Input methods
* typically want context in order to constrain input text based on
* existing text; this is important for languages such as Thai where
* only some sequences of characters are allowed.
*
* This function is implemented by emitting the
* GtkIMContext::retrieve_surrounding signal on the input method; in
* response to this signal, a widget should provide as much context as
* is available, up to an entire paragraph, by calling
* gtk_im_context_set_surrounding(). Note that there is no obligation
* for a widget to respond to the ::retrieve_surrounding signal, so input
* methods must be prepared to function without context.
*
* Params:
* text = location to store a UTF-8 encoded
* string of text holding context around the insertion point.
* If the function returns %TRUE, then you must free the result
* stored in this location with g_free().
* cursorIndex = location to store byte index of the insertion
* cursor within @text.
*
* Returns: %TRUE if surrounding text was provided; in this case
* you must free the result stored in *text.
*/
public bool getSurrounding(out string text, out int cursorIndex)
{
char* outtext = null;
auto p = gtk_im_context_get_surrounding(gtkIMContext, &outtext, &cursorIndex) != 0;
text = Str.toString(outtext);
return p;
}
/**
* Notify the input method that a change such as a change in cursor
* position has been made. This will typically cause the input
* method to clear the preedit state.
*/
public void reset()
{
gtk_im_context_reset(gtkIMContext);
}
/**
* Set the client window for the input context; this is the
* #GdkWindow in which the input appears. This window is
* used in order to correctly position status windows, and may
* also be used for purposes internal to the input method.
*
* Params:
* window = the client window. This may be %NULL to indicate
* that the previous client window no longer exists.
*/
public void setClientWindow(Window window)
{
gtk_im_context_set_client_window(gtkIMContext, (window is null) ? null : window.getWindowStruct());
}
/**
* Notify the input method that a change in cursor
* position has been made. The location is relative to the client
* window.
*
* Params:
* area = new location
*/
public void setCursorLocation(GdkRectangle* area)
{
gtk_im_context_set_cursor_location(gtkIMContext, area);
}
/**
* Sets surrounding context around the insertion point and preedit
* string. This function is expected to be called in response to the
* GtkIMContext::retrieve_surrounding signal, and will likely have no
* effect if called at other times.
*
* Params:
* text = text surrounding the insertion point, as UTF-8.
* the preedit string should not be included within
* @text.
* len = the length of @text, or -1 if @text is nul-terminated
* cursorIndex = the byte index of the insertion cursor within @text.
*/
public void setSurrounding(string text, int len, int cursorIndex)
{
gtk_im_context_set_surrounding(gtkIMContext, Str.toStringz(text), len, cursorIndex);
}
/**
* Sets whether the IM context should use the preedit string
* to display feedback. If @use_preedit is FALSE (default
* is TRUE), then the IM context may use some other method to display
* feedback, such as displaying it in a child of the root window.
*
* Params:
* usePreedit = whether the IM context should use the preedit string.
*/
public void setUsePreedit(bool usePreedit)
{
gtk_im_context_set_use_preedit(gtkIMContext, usePreedit);
}
protected class OnCommitDelegateWrapper
{
void delegate(string, IMContext) dlg;
gulong handlerId;
this(void delegate(string, IMContext) dlg)
{
this.dlg = dlg;
onCommitListeners ~= this;
}
void remove(OnCommitDelegateWrapper source)
{
foreach(index, wrapper; onCommitListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onCommitListeners[index] = null;
onCommitListeners = std.algorithm.remove(onCommitListeners, index);
break;
}
}
}
}
OnCommitDelegateWrapper[] onCommitListeners;
/**
* The ::commit signal is emitted when a complete input sequence
* has been entered by the user. This can be a single character
* immediately after a key press or the final result of preediting.
*
* Params:
* str = the completed character(s) entered by the user
*/
gulong addOnCommit(void delegate(string, IMContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnCommitDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"commit",
cast(GCallback)&callBackCommit,
cast(void*)wrapper,
cast(GClosureNotify)&callBackCommitDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackCommit(GtkIMContext* imcontextStruct, char* str, OnCommitDelegateWrapper wrapper)
{
wrapper.dlg(Str.toString(str), wrapper.outer);
}
extern(C) static void callBackCommitDestroy(OnCommitDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnDeleteSurroundingDelegateWrapper
{
bool delegate(int, int, IMContext) dlg;
gulong handlerId;
this(bool delegate(int, int, IMContext) dlg)
{
this.dlg = dlg;
onDeleteSurroundingListeners ~= this;
}
void remove(OnDeleteSurroundingDelegateWrapper source)
{
foreach(index, wrapper; onDeleteSurroundingListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onDeleteSurroundingListeners[index] = null;
onDeleteSurroundingListeners = std.algorithm.remove(onDeleteSurroundingListeners, index);
break;
}
}
}
}
OnDeleteSurroundingDelegateWrapper[] onDeleteSurroundingListeners;
/**
* The ::delete-surrounding signal is emitted when the input method
* needs to delete all or part of the context surrounding the cursor.
*
* Params:
* offset = the character offset from the cursor position of the text
* to be deleted. A negative value indicates a position before
* the cursor.
* nChars = the number of characters to be deleted
*
* Returns: %TRUE if the signal was handled.
*/
gulong addOnDeleteSurrounding(bool delegate(int, int, IMContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnDeleteSurroundingDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"delete-surrounding",
cast(GCallback)&callBackDeleteSurrounding,
cast(void*)wrapper,
cast(GClosureNotify)&callBackDeleteSurroundingDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static int callBackDeleteSurrounding(GtkIMContext* imcontextStruct, int offset, int nChars, OnDeleteSurroundingDelegateWrapper wrapper)
{
return wrapper.dlg(offset, nChars, wrapper.outer);
}
extern(C) static void callBackDeleteSurroundingDestroy(OnDeleteSurroundingDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnPreeditChangedDelegateWrapper
{
void delegate(IMContext) dlg;
gulong handlerId;
this(void delegate(IMContext) dlg)
{
this.dlg = dlg;
onPreeditChangedListeners ~= this;
}
void remove(OnPreeditChangedDelegateWrapper source)
{
foreach(index, wrapper; onPreeditChangedListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onPreeditChangedListeners[index] = null;
onPreeditChangedListeners = std.algorithm.remove(onPreeditChangedListeners, index);
break;
}
}
}
}
OnPreeditChangedDelegateWrapper[] onPreeditChangedListeners;
/**
* The ::preedit-changed signal is emitted whenever the preedit sequence
* currently being entered has changed. It is also emitted at the end of
* a preedit sequence, in which case
* gtk_im_context_get_preedit_string() returns the empty string.
*/
gulong addOnPreeditChanged(void delegate(IMContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnPreeditChangedDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"preedit-changed",
cast(GCallback)&callBackPreeditChanged,
cast(void*)wrapper,
cast(GClosureNotify)&callBackPreeditChangedDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackPreeditChanged(GtkIMContext* imcontextStruct, OnPreeditChangedDelegateWrapper wrapper)
{
wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackPreeditChangedDestroy(OnPreeditChangedDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnPreeditEndDelegateWrapper
{
void delegate(IMContext) dlg;
gulong handlerId;
this(void delegate(IMContext) dlg)
{
this.dlg = dlg;
onPreeditEndListeners ~= this;
}
void remove(OnPreeditEndDelegateWrapper source)
{
foreach(index, wrapper; onPreeditEndListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onPreeditEndListeners[index] = null;
onPreeditEndListeners = std.algorithm.remove(onPreeditEndListeners, index);
break;
}
}
}
}
OnPreeditEndDelegateWrapper[] onPreeditEndListeners;
/**
* The ::preedit-end signal is emitted when a preediting sequence
* has been completed or canceled.
*/
gulong addOnPreeditEnd(void delegate(IMContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnPreeditEndDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"preedit-end",
cast(GCallback)&callBackPreeditEnd,
cast(void*)wrapper,
cast(GClosureNotify)&callBackPreeditEndDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackPreeditEnd(GtkIMContext* imcontextStruct, OnPreeditEndDelegateWrapper wrapper)
{
wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackPreeditEndDestroy(OnPreeditEndDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnPreeditStartDelegateWrapper
{
void delegate(IMContext) dlg;
gulong handlerId;
this(void delegate(IMContext) dlg)
{
this.dlg = dlg;
onPreeditStartListeners ~= this;
}
void remove(OnPreeditStartDelegateWrapper source)
{
foreach(index, wrapper; onPreeditStartListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onPreeditStartListeners[index] = null;
onPreeditStartListeners = std.algorithm.remove(onPreeditStartListeners, index);
break;
}
}
}
}
OnPreeditStartDelegateWrapper[] onPreeditStartListeners;
/**
* The ::preedit-start signal is emitted when a new preediting sequence
* starts.
*/
gulong addOnPreeditStart(void delegate(IMContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnPreeditStartDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"preedit-start",
cast(GCallback)&callBackPreeditStart,
cast(void*)wrapper,
cast(GClosureNotify)&callBackPreeditStartDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackPreeditStart(GtkIMContext* imcontextStruct, OnPreeditStartDelegateWrapper wrapper)
{
wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackPreeditStartDestroy(OnPreeditStartDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
protected class OnRetrieveSurroundingDelegateWrapper
{
bool delegate(IMContext) dlg;
gulong handlerId;
this(bool delegate(IMContext) dlg)
{
this.dlg = dlg;
onRetrieveSurroundingListeners ~= this;
}
void remove(OnRetrieveSurroundingDelegateWrapper source)
{
foreach(index, wrapper; onRetrieveSurroundingListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onRetrieveSurroundingListeners[index] = null;
onRetrieveSurroundingListeners = std.algorithm.remove(onRetrieveSurroundingListeners, index);
break;
}
}
}
}
OnRetrieveSurroundingDelegateWrapper[] onRetrieveSurroundingListeners;
/**
* The ::retrieve-surrounding signal is emitted when the input method
* requires the context surrounding the cursor. The callback should set
* the input method surrounding context by calling the
* gtk_im_context_set_surrounding() method.
*
* Returns: %TRUE if the signal was handled.
*/
gulong addOnRetrieveSurrounding(bool delegate(IMContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnRetrieveSurroundingDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"retrieve-surrounding",
cast(GCallback)&callBackRetrieveSurrounding,
cast(void*)wrapper,
cast(GClosureNotify)&callBackRetrieveSurroundingDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static int callBackRetrieveSurrounding(GtkIMContext* imcontextStruct, OnRetrieveSurroundingDelegateWrapper wrapper)
{
return wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackRetrieveSurroundingDestroy(OnRetrieveSurroundingDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|