~ubuntu-branches/ubuntu/karmic/ibus/karmic-updates

« back to all changes in this revision

Viewing changes to bus/inputcontext.c

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing
  • Date: 2009-06-13 11:39:05 UTC
  • mfrom: (1.1.3 upstream) (6.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090613113905-0mfi5hhoz8w9y6k2
Tags: 1.1.0.20090612-1
* new upstream release.
* Fix "python-ibus should depends on iso-codes" (Closes: #532163)
* debian/libibus0.symbols: update symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
    IBusLookupTable *lookup_table;
98
98
    gboolean lookup_table_visible;
99
99
 
100
 
    /* properties */
101
 
    IBusPropList *props;
 
100
    /* filter release */
 
101
    gboolean filter_release;
 
102
 
102
103
};
103
104
 
104
105
typedef struct _BusInputContextPrivate BusInputContextPrivate;
557
558
    priv->lookup_table_visible = FALSE;
558
559
 
559
560
    g_object_ref (props_empty);
560
 
    priv->props = props_empty;
561
561
}
562
562
 
563
563
static void
590
590
        priv->lookup_table = NULL;
591
591
    }
592
592
 
593
 
    if (priv->props) {
594
 
        g_object_unref (priv->props);
595
 
        priv->props = NULL;
596
 
    }
597
 
 
598
593
    if (priv->connection) {
599
594
        g_signal_handlers_disconnect_by_func (priv->connection,
600
595
                                         (GCallback) _connection_destroy_cb,
714
709
    retval = bus_input_context_filter_keyboard_shortcuts (context, keyval, modifiers);
715
710
 
716
711
    if (retval) {
 
712
        priv->filter_release = TRUE;
717
713
        reply = ibus_message_new_method_return (message);
718
714
        ibus_message_append_args (reply,
719
715
                                  G_TYPE_BOOLEAN, &retval,
1156
1152
    if (priv->capabilities & IBUS_CAP_FOCUS) {
1157
1153
        g_signal_emit (context, context_signals[FOCUS_IN], 0);
1158
1154
 
1159
 
        if ((priv->capabilities & IBUS_CAP_PROPERTY) == 0) {
1160
 
            g_signal_emit (context,
1161
 
                           context_signals[REGISTER_PROPERTIES],
1162
 
                           0,
1163
 
                           priv->props);
1164
 
        }
1165
1155
        if (priv->preedit_visible && (priv->capabilities & IBUS_CAP_PREEDIT_TEXT) == 0) {
1166
1156
            g_signal_emit (context,
1167
1157
                           context_signals[UPDATE_PREEDIT_TEXT],
1218
1208
    }
1219
1209
}
1220
1210
 
1221
 
void
1222
 
bus_input_context_page_up (BusInputContext *context)
1223
 
{
1224
 
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1225
 
 
1226
 
    BusInputContextPrivate *priv;
1227
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1228
 
 
1229
 
    if (priv->engine) {
1230
 
        bus_engine_proxy_page_up (priv->engine);
1231
 
    }
1232
 
}
1233
 
 
1234
 
void
1235
 
bus_input_context_page_down (BusInputContext *context)
1236
 
{
1237
 
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1238
 
 
1239
 
    BusInputContextPrivate *priv;
1240
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1241
 
 
1242
 
    if (priv->engine) {
1243
 
        bus_engine_proxy_page_down (priv->engine);
1244
 
    }
1245
 
}
1246
 
 
1247
 
void
1248
 
bus_input_context_cursor_up (BusInputContext *context)
1249
 
{
1250
 
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1251
 
 
1252
 
    BusInputContextPrivate *priv;
1253
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1254
 
 
1255
 
    if (priv->engine) {
1256
 
        bus_engine_proxy_cursor_up (priv->engine);
1257
 
    }
1258
 
}
1259
 
 
1260
 
void
1261
 
bus_input_context_cursor_down (BusInputContext *context)
1262
 
{
1263
 
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1264
 
 
1265
 
    BusInputContextPrivate *priv;
1266
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1267
 
 
1268
 
    if (priv->engine) {
1269
 
        bus_engine_proxy_cursor_down (priv->engine);
 
1211
#define DEFINE_FUNC(name)                                   \
 
1212
    void                                                    \
 
1213
    bus_input_context_##name (BusInputContext *context)     \
 
1214
    {                                                       \
 
1215
        g_assert (BUS_IS_INPUT_CONTEXT (context));          \
 
1216
                                                            \
 
1217
        BusInputContextPrivate *priv;                       \
 
1218
        priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);     \
 
1219
                                                            \
 
1220
        if (priv->engine) {                                 \
 
1221
            bus_engine_proxy_##name (priv->engine);         \
 
1222
        }                                                   \
 
1223
    }
 
1224
 
 
1225
DEFINE_FUNC(page_up)
 
1226
DEFINE_FUNC(page_down)
 
1227
DEFINE_FUNC(cursor_up)
 
1228
DEFINE_FUNC(cursor_down)
 
1229
 
 
1230
#undef DEFINE_FUNC
 
1231
 
 
1232
void
 
1233
bus_input_context_candidate_clicked (BusInputContext *context,
 
1234
                                     guint            index,
 
1235
                                     guint            button,
 
1236
                                     guint            state)
 
1237
{
 
1238
    g_assert (BUS_IS_INPUT_CONTEXT (context));
 
1239
 
 
1240
    BusInputContextPrivate *priv;
 
1241
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
 
1242
 
 
1243
    if (priv->engine) {
 
1244
        bus_engine_proxy_candidate_clicked (priv->engine,
 
1245
                                            index,
 
1246
                                            button,
 
1247
                                            state);
1270
1248
    }
1271
1249
}
1272
1250
 
1650
1628
    BusInputContextPrivate *priv;
1651
1629
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1652
1630
 
1653
 
    if (priv->props) {
1654
 
        g_object_unref (priv->props);
1655
 
    }
1656
 
 
1657
 
    priv->props = (IBusPropList *) g_object_ref (props ? props : props_empty);
1658
 
 
1659
1631
    if (priv->capabilities & IBUS_CAP_PROPERTY) {
1660
1632
        bus_input_context_send_signal (context,
1661
1633
                                       "RegisterProperties",
1662
 
                                       IBUS_TYPE_PROP_LIST, &(priv->props),
 
1634
                                       IBUS_TYPE_PROP_LIST, &props,
1663
1635
                                       G_TYPE_INVALID);
1664
1636
    }
1665
1637
    else {
1666
1638
        g_signal_emit (context,
1667
1639
                       context_signals[REGISTER_PROPERTIES],
1668
1640
                       0,
1669
 
                       priv->props);
 
1641
                       props);
1670
1642
    }
1671
1643
}
1672
1644
 
1680
1652
    BusInputContextPrivate *priv;
1681
1653
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1682
1654
 
1683
 
    if (priv->props == props_empty) {
1684
 
        return;
1685
 
    }
1686
 
 
1687
 
    if (!ibus_prop_list_update_property (priv->props, prop)) {
1688
 
        return;
1689
 
    }
1690
 
 
1691
1655
    if (priv->capabilities & IBUS_CAP_PROPERTY) {
1692
1656
        bus_input_context_send_signal (context,
1693
1657
                                       "UpdateProperty",
2055
2019
    BusInputContextPrivate *priv;
2056
2020
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
2057
2021
 
 
2022
    gboolean retval = FALSE;
 
2023
 
2058
2024
    static GQuark trigger;
2059
2025
    static GQuark next_factory;
2060
2026
    static GQuark prev_factory;
2067
2033
        prev_factory = g_quark_from_static_string ("prev-engine");
2068
2034
    }
2069
2035
 
 
2036
    if (priv->filter_release){
 
2037
        if(modifiers & IBUS_RELEASE_MASK) {
 
2038
            /* filter release key event */
 
2039
            return TRUE;
 
2040
        }
 
2041
        else {
 
2042
            /* stop filter release key event */
 
2043
            priv->filter_release = FALSE;
 
2044
        }
 
2045
    }
 
2046
 
2070
2047
    event = ibus_hotkey_profile_filter_key_event (BUS_DEFAULT_HOTKEY_PROFILE,
2071
2048
                                                  keyval,
2072
2049
                                                  modifiers,
2086
2063
            bus_input_context_enable (context);
2087
2064
        }
2088
2065
 
2089
 
        return enabled != priv->enabled;
 
2066
        retval = (enabled != priv->enabled);
2090
2067
    }
2091
2068
    else if (event == next_factory) {
2092
2069
        if (priv->engine == NULL || priv->enabled == FALSE) {
2093
 
            return FALSE;
2094
 
        }
2095
 
        g_signal_emit (context, context_signals[REQUEST_NEXT_ENGINE], 0);
2096
 
        return TRUE;
 
2070
            retval =  FALSE;
 
2071
        }
 
2072
        else {
 
2073
            g_signal_emit (context, context_signals[REQUEST_NEXT_ENGINE], 0);
 
2074
            retval = TRUE;
 
2075
        }
2097
2076
    }
2098
2077
    else if (event == prev_factory) {
2099
2078
        if (priv->engine == NULL || priv->enabled == FALSE) {
2100
 
            return FALSE;
2101
 
        }
2102
 
        g_signal_emit (context, context_signals[REQUEST_PREV_ENGINE], 0);
2103
 
        return TRUE;
2104
 
    }
2105
 
    else
2106
 
        return FALSE;
 
2079
            retval = FALSE;
 
2080
        }
 
2081
        else {
 
2082
            g_signal_emit (context, context_signals[REQUEST_PREV_ENGINE], 0);
 
2083
            retval = TRUE;
 
2084
        }
 
2085
    }
 
2086
 
 
2087
    if (retval == TRUE) {
 
2088
        /* begine filter release key event */
 
2089
        priv->filter_release = TRUE;
 
2090
    }
 
2091
 
 
2092
    return retval;
2107
2093
}
2108
2094
 
2109
2095