~ubuntu-branches/debian/sid/ibus/sid

« back to all changes in this revision

Viewing changes to tools/main.c

  • Committer: Package Import Robot
  • Author(s): Osamu Aoki, Aron Xu, Osamu Aoki
  • Date: 2014-08-04 22:42:19 UTC
  • mfrom: (1.5.7)
  • Revision ID: package-import@ubuntu.com-20140804224219-mjprlql1jdwi5sxm
Tags: 1.5.8-1
[ Aron Xu ]
* Allow parallel building

[ Osamu Aoki ]
* Update ibus document with Qt5 support

[ Aron Xu ]
* Imported Upstream version 1.5.8
* Remove patch for chasing HEAD, imported new upstream release
* Remove the patch for updating IBusKeymap jp, applied upstream
* Drop gtk2 version of the password patch because it's never executed
* Drop ibus-541492-xkb.patch
* Drop ibus-530711-preload-sys.patch
* Drop ibus-810211-no-switch-by-no-trigger.patch
* Drop 999-update-po.patch

[ Osamu Aoki ]
* linux-any for ibus-wayland
* Remove some symbols matching ibus-541492-xkb.patch
* Remove old patch for GTK+ 3.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <config.h>
32
32
#include <stdio.h>
33
33
#include <glib/gi18n-lib.h>
 
34
#include <gio/gio.h>
34
35
#include <locale.h>
35
36
#include <gobject/gvaluecollector.h>
36
37
 
54
55
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
55
56
#define _g_free0(var) (var = (g_free (var), NULL))
56
57
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
 
58
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
57
59
 
58
60
#define TYPE_COMMAND_ENTRY (command_entry_get_type ())
59
61
typedef struct _CommandEntry CommandEntry;
129
131
gint read_cache (gchar** argv, int argv_length1);
130
132
gint write_cache (gchar** argv, int argv_length1);
131
133
gint print_address (gchar** argv, int argv_length1);
 
134
gint read_config (gchar** argv, int argv_length1);
 
135
gint reset_config (gchar** argv, int argv_length1);
132
136
gint print_help (gchar** argv, int argv_length1);
133
137
void print_usage (FILE* stream);
134
138
GType command_entry_get_type (void) G_GNUC_CONST;
143
147
static gint _read_cache_entry_func (gchar** argv, int argv_length1, gpointer self);
144
148
static gint _write_cache_entry_func (gchar** argv, int argv_length1, gpointer self);
145
149
static gint _print_address_entry_func (gchar** argv, int argv_length1, gpointer self);
 
150
static gint _read_config_entry_func (gchar** argv, int argv_length1, gpointer self);
 
151
static gint _reset_config_entry_func (gchar** argv, int argv_length1, gpointer self);
146
152
static gint _print_help_entry_func (gchar** argv, int argv_length1, gpointer self);
147
153
gint _vala_main (gchar** argv, int argv_length1);
148
154
static gchar** _vala_array_dup1 (gchar** self, int length);
149
155
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
150
156
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
157
static gint _vala_array_length (gpointer array);
151
158
 
152
 
const CommandEntry commands[10] = {{"engine", "Set or get engine", _get_set_engine_entry_func}, {"exit", "Exit ibus-daemon", _exit_daemon_entry_func}, {"list-engine", "Show available engines", _list_engine_entry_func}, {"watch", "(Not implemented)", _message_watch_entry_func}, {"restart", "Restart ibus-daemon", _restart_daemon_entry_func}, {"version", "Show version", _print_version_entry_func}, {"read-cache", "Show the content of registry cache", _read_cache_entry_func}, {"write-cache", "Create registry cache", _write_cache_entry_func}, {"address", "Print the D-Bus address of ibus-daemon", _print_address_entry_func}, {"help", "Show this information", _print_help_entry_func}};
 
159
const gchar* IBUS_SCHEMAS[3] = {"org.freedesktop.ibus.general", "org.freedesktop.ibus.general.hotkey", "org.freedesktop.ibus.panel"};
 
160
const CommandEntry commands[12] = {{"engine", "Set or get engine", _get_set_engine_entry_func}, {"exit", "Exit ibus-daemon", _exit_daemon_entry_func}, {"list-engine", "Show available engines", _list_engine_entry_func}, {"watch", "(Not implemented)", _message_watch_entry_func}, {"restart", "Restart ibus-daemon", _restart_daemon_entry_func}, {"version", "Show version", _print_version_entry_func}, {"read-cache", "Show the content of registry cache", _read_cache_entry_func}, {"write-cache", "Create registry cache", _write_cache_entry_func}, {"address", "Print the D-Bus address of ibus-daemon", _print_address_entry_func}, {"read-config", "Show the configuration values", _read_config_entry_func}, {"reset-config", "Reset the configuration values", _reset_config_entry_func}, {"help", "Show this information", _print_help_entry_func}};
153
161
 
154
162
EngineList* engine_list_construct (GType object_type) {
155
163
        EngineList* self = NULL;
896
904
                        const gchar* _tmp50_ = NULL;
897
905
                        _tmp49_ = engine;
898
906
                        _tmp50_ = ibus_engine_desc_get_layout (_tmp49_);
899
 
                        g_warning ("main.vala:126: Switch xkb layout to %s failed.", _tmp50_);
 
907
                        g_warning ("main.vala:132: Switch xkb layout to %s failed.", _tmp50_);
900
908
                        result = EXIT_FAILURE;
901
909
                        args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
902
910
                        _g_free0 (standard_error);
916
924
                _inner_error_ = NULL;
917
925
                _tmp51_ = e;
918
926
                _tmp52_ = _tmp51_->message;
919
 
                g_warning ("main.vala:131: Execute setxkbmap failed: %s", _tmp52_);
 
927
                g_warning ("main.vala:137: Execute setxkbmap failed: %s", _tmp52_);
920
928
                result = EXIT_FAILURE;
921
929
                _g_error_free0 (e);
922
930
                args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
946
954
                if (_tmp54_ == NULL) {
947
955
                        _tmp54_ = "(null)";
948
956
                }
949
 
                g_warning ("main.vala:136: Execute setxkbmap failed: %s", _tmp54_);
 
957
                g_warning ("main.vala:142: Execute setxkbmap failed: %s", _tmp54_);
950
958
                result = EXIT_FAILURE;
951
959
                args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
952
960
                _g_free0 (standard_error);
1383
1391
}
1384
1392
 
1385
1393
 
 
1394
gint read_config (gchar** argv, int argv_length1) {
 
1395
        gint result = 0;
 
1396
        GString* output = NULL;
 
1397
        GString* _tmp0_ = NULL;
 
1398
        GString* _tmp18_ = NULL;
 
1399
        const gchar* _tmp19_ = NULL;
 
1400
        _tmp0_ = g_string_new ("");
 
1401
        output = _tmp0_;
 
1402
        {
 
1403
                const gchar** schema_collection = NULL;
 
1404
                gint schema_collection_length1 = 0;
 
1405
                gint _schema_collection_size_ = 0;
 
1406
                gint schema_it = 0;
 
1407
                schema_collection = IBUS_SCHEMAS;
 
1408
                schema_collection_length1 = G_N_ELEMENTS (IBUS_SCHEMAS);
 
1409
                for (schema_it = 0; schema_it < G_N_ELEMENTS (IBUS_SCHEMAS); schema_it = schema_it + 1) {
 
1410
                        gchar* _tmp1_ = NULL;
 
1411
                        gchar* schema = NULL;
 
1412
                        _tmp1_ = g_strdup (schema_collection[schema_it]);
 
1413
                        schema = _tmp1_;
 
1414
                        {
 
1415
                                GSettings* settings = NULL;
 
1416
                                const gchar* _tmp2_ = NULL;
 
1417
                                GSettings* _tmp3_ = NULL;
 
1418
                                GString* _tmp4_ = NULL;
 
1419
                                const gchar* _tmp5_ = NULL;
 
1420
                                GSettings* _tmp6_ = NULL;
 
1421
                                gchar** _tmp7_ = NULL;
 
1422
                                gchar** _tmp8_ = NULL;
 
1423
                                _tmp2_ = schema;
 
1424
                                _tmp3_ = g_settings_new (_tmp2_);
 
1425
                                settings = _tmp3_;
 
1426
                                _tmp4_ = output;
 
1427
                                _tmp5_ = schema;
 
1428
                                g_string_append_printf (_tmp4_, "SCHEMA: %s\n", _tmp5_);
 
1429
                                _tmp6_ = settings;
 
1430
                                _tmp8_ = _tmp7_ = g_settings_list_keys (_tmp6_);
 
1431
                                {
 
1432
                                        gchar** key_collection = NULL;
 
1433
                                        gint key_collection_length1 = 0;
 
1434
                                        gint _key_collection_size_ = 0;
 
1435
                                        gint key_it = 0;
 
1436
                                        key_collection = _tmp8_;
 
1437
                                        key_collection_length1 = _vala_array_length (_tmp7_);
 
1438
                                        for (key_it = 0; key_it < _vala_array_length (_tmp7_); key_it = key_it + 1) {
 
1439
                                                gchar* _tmp9_ = NULL;
 
1440
                                                gchar* key = NULL;
 
1441
                                                _tmp9_ = g_strdup (key_collection[key_it]);
 
1442
                                                key = _tmp9_;
 
1443
                                                {
 
1444
                                                        GVariant* variant = NULL;
 
1445
                                                        GSettings* _tmp10_ = NULL;
 
1446
                                                        const gchar* _tmp11_ = NULL;
 
1447
                                                        GVariant* _tmp12_ = NULL;
 
1448
                                                        GString* _tmp13_ = NULL;
 
1449
                                                        const gchar* _tmp14_ = NULL;
 
1450
                                                        GVariant* _tmp15_ = NULL;
 
1451
                                                        gchar* _tmp16_ = NULL;
 
1452
                                                        gchar* _tmp17_ = NULL;
 
1453
                                                        _tmp10_ = settings;
 
1454
                                                        _tmp11_ = key;
 
1455
                                                        _tmp12_ = g_settings_get_value (_tmp10_, _tmp11_);
 
1456
                                                        variant = _tmp12_;
 
1457
                                                        _tmp13_ = output;
 
1458
                                                        _tmp14_ = key;
 
1459
                                                        _tmp15_ = variant;
 
1460
                                                        _tmp16_ = g_variant_print (_tmp15_, TRUE);
 
1461
                                                        _tmp17_ = _tmp16_;
 
1462
                                                        g_string_append_printf (_tmp13_, "  %s: %s\n", _tmp14_, _tmp17_);
 
1463
                                                        _g_free0 (_tmp17_);
 
1464
                                                        _g_variant_unref0 (variant);
 
1465
                                                        _g_free0 (key);
 
1466
                                                }
 
1467
                                        }
 
1468
                                        key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
 
1469
                                }
 
1470
                                _g_object_unref0 (settings);
 
1471
                                _g_free0 (schema);
 
1472
                        }
 
1473
                }
 
1474
        }
 
1475
        _tmp18_ = output;
 
1476
        _tmp19_ = _tmp18_->str;
 
1477
        g_print ("%s", _tmp19_);
 
1478
        result = EXIT_SUCCESS;
 
1479
        _g_string_free0 (output);
 
1480
        return result;
 
1481
}
 
1482
 
 
1483
 
 
1484
gint reset_config (gchar** argv, int argv_length1) {
 
1485
        gint result = 0;
 
1486
        const gchar* _tmp0_ = NULL;
 
1487
        const gchar* _tmp12_ = NULL;
 
1488
        _tmp0_ = _ ("Resetting…");
 
1489
        g_print ("%s\n", _tmp0_);
 
1490
        {
 
1491
                const gchar** schema_collection = NULL;
 
1492
                gint schema_collection_length1 = 0;
 
1493
                gint _schema_collection_size_ = 0;
 
1494
                gint schema_it = 0;
 
1495
                schema_collection = IBUS_SCHEMAS;
 
1496
                schema_collection_length1 = G_N_ELEMENTS (IBUS_SCHEMAS);
 
1497
                for (schema_it = 0; schema_it < G_N_ELEMENTS (IBUS_SCHEMAS); schema_it = schema_it + 1) {
 
1498
                        gchar* _tmp1_ = NULL;
 
1499
                        gchar* schema = NULL;
 
1500
                        _tmp1_ = g_strdup (schema_collection[schema_it]);
 
1501
                        schema = _tmp1_;
 
1502
                        {
 
1503
                                GSettings* settings = NULL;
 
1504
                                const gchar* _tmp2_ = NULL;
 
1505
                                GSettings* _tmp3_ = NULL;
 
1506
                                const gchar* _tmp4_ = NULL;
 
1507
                                GSettings* _tmp5_ = NULL;
 
1508
                                gchar** _tmp6_ = NULL;
 
1509
                                gchar** _tmp7_ = NULL;
 
1510
                                _tmp2_ = schema;
 
1511
                                _tmp3_ = g_settings_new (_tmp2_);
 
1512
                                settings = _tmp3_;
 
1513
                                _tmp4_ = schema;
 
1514
                                g_print ("SCHEMA: %s\n", _tmp4_);
 
1515
                                _tmp5_ = settings;
 
1516
                                _tmp7_ = _tmp6_ = g_settings_list_keys (_tmp5_);
 
1517
                                {
 
1518
                                        gchar** key_collection = NULL;
 
1519
                                        gint key_collection_length1 = 0;
 
1520
                                        gint _key_collection_size_ = 0;
 
1521
                                        gint key_it = 0;
 
1522
                                        key_collection = _tmp7_;
 
1523
                                        key_collection_length1 = _vala_array_length (_tmp6_);
 
1524
                                        for (key_it = 0; key_it < _vala_array_length (_tmp6_); key_it = key_it + 1) {
 
1525
                                                gchar* _tmp8_ = NULL;
 
1526
                                                gchar* key = NULL;
 
1527
                                                _tmp8_ = g_strdup (key_collection[key_it]);
 
1528
                                                key = _tmp8_;
 
1529
                                                {
 
1530
                                                        const gchar* _tmp9_ = NULL;
 
1531
                                                        GSettings* _tmp10_ = NULL;
 
1532
                                                        const gchar* _tmp11_ = NULL;
 
1533
                                                        _tmp9_ = key;
 
1534
                                                        g_print ("  %s\n", _tmp9_);
 
1535
                                                        _tmp10_ = settings;
 
1536
                                                        _tmp11_ = key;
 
1537
                                                        g_settings_reset (_tmp10_, _tmp11_);
 
1538
                                                        _g_free0 (key);
 
1539
                                                }
 
1540
                                        }
 
1541
                                        key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
 
1542
                                }
 
1543
                                _g_object_unref0 (settings);
 
1544
                                _g_free0 (schema);
 
1545
                        }
 
1546
                }
 
1547
        }
 
1548
        g_settings_sync ();
 
1549
        _tmp12_ = _ ("Done");
 
1550
        g_print ("%s\n", _tmp12_);
 
1551
        result = EXIT_SUCCESS;
 
1552
        return result;
 
1553
}
 
1554
 
 
1555
 
1386
1556
gint print_help (gchar** argv, int argv_length1) {
1387
1557
        gint result = 0;
1388
1558
        FILE* _tmp0_ = NULL;
1480
1650
}
1481
1651
 
1482
1652
 
 
1653
static gint _read_config_entry_func (gchar** argv, int argv_length1, gpointer self) {
 
1654
        gint result;
 
1655
        result = read_config (argv, argv_length1);
 
1656
        return result;
 
1657
}
 
1658
 
 
1659
 
 
1660
static gint _reset_config_entry_func (gchar** argv, int argv_length1, gpointer self) {
 
1661
        gint result;
 
1662
        result = reset_config (argv, argv_length1);
 
1663
        return result;
 
1664
}
 
1665
 
 
1666
 
1483
1667
static gint _print_help_entry_func (gchar** argv, int argv_length1, gpointer self) {
1484
1668
        gint result;
1485
1669
        result = print_help (argv, argv_length1);
1535
1719
                                _tmp13_ = commands[_tmp12_];
1536
1720
                                _tmp14_ = _tmp13_.description;
1537
1721
                                _tmp15_ = g_dgettext (NULL, _tmp14_);
1538
 
                                fprintf (_tmp8_, "  %-11s    %s\n", _tmp11_, _tmp15_);
 
1722
                                fprintf (_tmp8_, "  %-12s    %s\n", _tmp11_, _tmp15_);
1539
1723
                        }
1540
1724
                }
1541
1725
        }
1717
1901
}
1718
1902
 
1719
1903
 
 
1904
static gint _vala_array_length (gpointer array) {
 
1905
        int length;
 
1906
        length = 0;
 
1907
        if (array) {
 
1908
                while (((gpointer*) array)[length]) {
 
1909
                        length++;
 
1910
                }
 
1911
        }
 
1912
        return length;
 
1913
}
 
1914
 
 
1915
 
1720
1916