12 | 12 |
#include <libgnomekbd/gkbd-configuration.h>
|
13 | 13 |
|
14 | 14 |
#include "xapp-kbd-layout-controller.h"
|
|
15 |
|
|
16 |
/**
|
|
17 |
* SECTION:xapp-kbd-layout-controller
|
|
18 |
* @Short_description: Keyboard layout selection UI element provider.
|
|
19 |
* @Title: XAppKbdLayoutController
|
|
20 |
*
|
|
21 |
* A GObject wrapper for Gkbd that provides additional UI element
|
|
22 |
* support for keyboard layout flags and abbreviations, as well as
|
|
23 |
* Wfacilities to distinguish regional and hardware-based variants
|
|
24 |
* which might otherwise appear identical in a layout list.
|
|
25 |
*/
|
15 | 26 |
|
16 | 27 |
enum
|
17 | 28 |
{
|
|
60 | 71 |
{
|
61 | 72 |
GkbdConfiguration *config;
|
62 | 73 |
|
63 | |
gint num_groups;
|
|
74 |
guint num_groups;
|
64 | 75 |
|
65 | 76 |
GPtrArray *group_data;
|
66 | 77 |
|
|
129 | 140 |
|
130 | 141 |
/* Populate the GroupData pointer array */
|
131 | 142 |
|
132 | |
gint i, j, group_dupe_id, variant_dupe_id;
|
|
143 |
gint group_dupe_id, variant_dupe_id;
|
|
144 |
guint i, j;
|
|
145 |
|
133 | 146 |
GPtrArray *list = g_ptr_array_new_with_free_func ((GDestroyNotify) group_data_free);
|
134 | 147 |
|
135 | 148 |
for (i = 0; i < priv->num_groups; i++)
|
|
385 | 398 |
0, G_TYPE_NONE);
|
386 | 399 |
}
|
387 | 400 |
|
|
401 |
/**
|
|
402 |
* xapp_kbd_layout_controller_new
|
|
403 |
*
|
|
404 |
* Creates a new XAppKbdLayoutController instance.
|
|
405 |
*
|
|
406 |
* Returns: (transfer full): a new #XAppKbdLayoutController instance
|
|
407 |
*/
|
388 | 408 |
XAppKbdLayoutController *
|
389 | 409 |
xapp_kbd_layout_controller_new (void)
|
390 | 410 |
{
|
391 | 411 |
return g_object_new (XAPP_TYPE_KBD_LAYOUT_CONTROLLER, NULL);
|
392 | 412 |
}
|
393 | 413 |
|
|
414 |
/**
|
|
415 |
* xapp_kbd_layout_controller_get_enabled:
|
|
416 |
* @controller: the #XAppKbdLayoutController
|
|
417 |
*
|
|
418 |
* Returns whether or not the layout controller is enabled
|
|
419 |
*/
|
394 | 420 |
gboolean
|
395 | 421 |
xapp_kbd_layout_controller_get_enabled (XAppKbdLayoutController *controller)
|
396 | 422 |
{
|
397 | 423 |
return controller->priv->enabled;
|
398 | 424 |
}
|
399 | 425 |
|
|
426 |
/**
|
|
427 |
* xapp_kbd_layout_controller_get_current_group:
|
|
428 |
* @controller: the #XAppKbdLayoutController
|
|
429 |
*
|
|
430 |
* Selects the previous group in the group list.
|
|
431 |
*/
|
400 | 432 |
guint
|
401 | 433 |
xapp_kbd_layout_controller_get_current_group (XAppKbdLayoutController *controller)
|
402 | 434 |
{
|
|
405 | 437 |
return gkbd_configuration_get_current_group (controller->priv->config);
|
406 | 438 |
}
|
407 | 439 |
|
|
440 |
/**
|
|
441 |
* xapp_kbd_layout_controller_set_current_group
|
|
442 |
* @controller: the #XAppKbdLayoutController
|
|
443 |
* @group: the group number to make active
|
|
444 |
*
|
|
445 |
* Selects the given group number as active.
|
|
446 |
*/
|
408 | 447 |
void
|
409 | 448 |
xapp_kbd_layout_controller_set_current_group (XAppKbdLayoutController *controller,
|
410 | 449 |
guint group)
|
|
420 | 459 |
}
|
421 | 460 |
}
|
422 | 461 |
|
|
462 |
/**
|
|
463 |
* xapp_kbd_layout_controller_next_group
|
|
464 |
* @controller: the #XAppKbdLayoutController
|
|
465 |
*
|
|
466 |
* Selects the next group in the group list.
|
|
467 |
*/
|
423 | 468 |
void
|
424 | 469 |
xapp_kbd_layout_controller_next_group (XAppKbdLayoutController *controller)
|
425 | 470 |
{
|
|
428 | 473 |
gkbd_configuration_lock_next_group (controller->priv->config);
|
429 | 474 |
}
|
430 | 475 |
|
|
476 |
/**
|
|
477 |
* xapp_kbd_layout_controller_previous_group
|
|
478 |
* @controller: the #XAppKbdLayoutController
|
|
479 |
*
|
|
480 |
* Selects the previous group in the group list.
|
|
481 |
*/
|
431 | 482 |
void
|
432 | 483 |
xapp_kbd_layout_controller_previous_group (XAppKbdLayoutController *controller)
|
433 | 484 |
{
|
|
451 | 502 |
|
452 | 503 |
/**
|
453 | 504 |
* xapp_kbd_layout_controller_get_current_name:
|
|
505 |
* @controller: the #XAppKbdLayoutController
|
454 | 506 |
*
|
455 | 507 |
* Returns the full name of the current keyboard layout.
|
456 | 508 |
*
|
|
467 | 519 |
|
468 | 520 |
/**
|
469 | 521 |
* xapp_kbd_layout_controller_get_all_names:
|
|
522 |
* @controller: the #XAppKbdLayoutController
|
470 | 523 |
*
|
471 | 524 |
* Returns an array of all full layout names
|
472 | 525 |
*
|
|
482 | 535 |
|
483 | 536 |
/**
|
484 | 537 |
* xapp_kbd_layout_controller_get_current_icon_name:
|
|
538 |
* @controller: the #XAppKbdLayoutController
|
485 | 539 |
*
|
486 | 540 |
* Returns the icon file name (no path or extension) to use for the current layout
|
487 | 541 |
*
|
|
501 | 555 |
|
502 | 556 |
/**
|
503 | 557 |
* xapp_kbd_layout_controller_get_icon_name_for_group:
|
|
558 |
* @controller: the #XAppKbdLayoutController
|
|
559 |
* @group: a group number
|
504 | 560 |
*
|
505 | 561 |
* Returns the icon file name (no path or extension) to use for the specified layout.
|
506 | 562 |
*
|
|
520 | 576 |
|
521 | 577 |
/**
|
522 | 578 |
* xapp_kbd_layout_controller_get_current_flag_id:
|
|
579 |
* @controller: the #XAppKbdLayoutController
|
523 | 580 |
*
|
524 | 581 |
* Returns the duplicate id for the current layout
|
525 | 582 |
*
|
|
540 | 597 |
|
541 | 598 |
/**
|
542 | 599 |
* xapp_kbd_layout_controller_flag_id_for_group:
|
|
600 |
* @controller: the #XAppKbdLayoutController
|
|
601 |
* @group: a group number
|
543 | 602 |
*
|
544 | 603 |
* Returns the duplicate id for the specified layout
|
545 | 604 |
*
|
|
559 | 618 |
|
560 | 619 |
/**
|
561 | 620 |
* xapp_kbd_layout_controller_get_current_short_group_label:
|
|
621 |
* @controller: the #XAppKbdLayoutController
|
562 | 622 |
*
|
563 | 623 |
* Returns the short group label (and subscript, if any) of the current layout
|
564 | 624 |
*
|
|
578 | 638 |
|
579 | 639 |
/**
|
580 | 640 |
* xapp_kbd_layout_controller_get_short_group_label_for_group:
|
|
641 |
* @controller: the #XAppKbdLayoutController
|
|
642 |
* @group: a group number
|
581 | 643 |
*
|
582 | 644 |
* Returns the short group label and subscript of the specified layout.
|
583 | 645 |
*
|
|
598 | 660 |
|
599 | 661 |
/**
|
600 | 662 |
* xapp_kbd_layout_controller_get_current_variant_label:
|
|
663 |
* @controller: the #XAppKbdLayoutController
|
601 | 664 |
*
|
602 | 665 |
* Returns the variant label (and subscript, if any) of the current layout
|
603 | 666 |
*
|
|
617 | 680 |
|
618 | 681 |
/**
|
619 | 682 |
* xapp_kbd_layout_controller_get_variant_label_for_group:
|
|
683 |
* @controller: the #XAppKbdLayoutController
|
|
684 |
* @group: a group number
|
620 | 685 |
*
|
621 | 686 |
* Returns the variant label and subscript of the specified layout.
|
622 | 687 |
*
|
|
635 | 700 |
return g_strdup (GROUP_DATA (priv->group_data, group)->variant_label);
|
636 | 701 |
}
|
637 | 702 |
|
|
703 |
/**
|
|
704 |
* xapp_kbd_layout_controller_render_cairo_subscript:
|
|
705 |
* @cr: a #cairo_t
|
|
706 |
* @x: the x position of the drawing area
|
|
707 |
* @y: the y position of the drawing area
|
|
708 |
* @width: the width of the drawing area
|
|
709 |
* @height: the height of the drawing area
|
|
710 |
* @subscript: the number to render
|
|
711 |
*
|
|
712 |
* Renders a subscript number in the given work area. This should
|
|
713 |
* be called from within a "draw" or "paint" widget/actor function,
|
|
714 |
* where a valid cairo_t is provided to draw with.
|
|
715 |
*/
|
638 | 716 |
void
|
639 | 717 |
xapp_kbd_layout_controller_render_cairo_subscript (cairo_t *cr,
|
640 | 718 |
gdouble x,
|