~micahg/ubuntu/natty/pidgin/2.7.9-2

« back to all changes in this revision

Viewing changes to finch/libgnt/gntcombobox.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-08-11 14:16:15 UTC
  • mfrom: (1.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20100811141615-lsqya0vlqrnu14lo
Tags: 1:2.7.3-1ubuntu1
* Resync on Debian, workaround build issue (lp:#600952) 
* debian/control:
  - Build-Depends on liblaunchpad-integration-dev
  - Drop libpurple0 dependency from libpurple-bin
  - Drop pidgin-data dependency from libpurple0
  - Recommends pidgin-libnotify
* debian/libpurple0.symbols: 
  - add epochs
* debian/patches/02_lpi.patch:
  - launchpad integration
* debian/patches/04_let_crasher_for_apport.patch:
  - stop catching the SIGSEGV signal and let apport handle it
* debian/patches/05_default_to_irc_ubuntu_com.patch:
  - set the default IRC server to irc.ubuntu.com
* debian/patches/10_docklet_default_off.patch:
  - default behavior to have no notification area icon.
* debian/patches/11_buddy_list_really_show.patch:
  - the buddy list tries harder to appear.  This fixes some issues with it
    not appearing.
* debian/patches/ 13_sounds_and_timers.patch:
  - adjusts the time out for sounds to be 15 seconds, 
    which helps get fewer spurious login notifications on slow connections.
* debian/patches/60_1024x600_gtk*.c.patch: 
  - add scrollbars into preferences and pounce dialogs
* debian/prefs.xml: 
  - Update to set the notify plugin prefs /plugins/gtk/X11/notify/*, 
    set /pidgin/plugins/loaded to load the notify plugin and enable 
    the standard logging options by default
* debian/rules:
  - install a launcher in the message indicator
  - set translation domain and update template
  - use simple-patchsys rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "gntcombobox.h"
26
26
#include "gnttree.h"
27
27
#include "gntmarshal.h"
 
28
#include "gntstyle.h"
28
29
#include "gntutils.h"
29
30
 
30
31
#include <string.h>
149
150
gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
150
151
{
151
152
        GntComboBox *box = GNT_COMBO_BOX(widget);
152
 
        if (GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED))
153
 
        {
154
 
                if (text[1] == 0)
155
 
                {
156
 
                        switch (text[0])
157
 
                        {
 
153
        gboolean showing = !!GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED);
 
154
 
 
155
        if (showing) {
 
156
                if (text[1] == 0) {
 
157
                        switch (text[0]) {
158
158
                                case '\r':
159
159
                                case '\t':
160
160
                                case '\n':
165
165
                                        return TRUE;
166
166
                        }
167
167
                }
168
 
                if (gnt_widget_key_pressed(box->dropdown, text))
169
 
                        return TRUE;
170
 
        }
171
 
        else
 
168
        }
 
169
 
 
170
        if (gnt_widget_key_pressed(box->dropdown, text)) {
 
171
                if (!showing)
 
172
                        popup_dropdown(box);
 
173
                return TRUE;
 
174
        }
 
175
 
172
176
        {
173
 
                if (text[0] == 27)
174
 
                {
175
 
                        if (strcmp(text, GNT_KEY_UP) == 0 ||
176
 
                                        strcmp(text, GNT_KEY_DOWN) == 0)
177
 
                        {
178
 
                                popup_dropdown(box);
179
 
                                return TRUE;
180
 
                        }
181
 
                }
 
177
#define SEARCH_IN_RANGE(start, end) do { \
 
178
                GntTreeRow *row; \
 
179
                for (row = start; row != end; \
 
180
                                row = gnt_tree_row_get_next(tree, row)) { \
 
181
                        gpointer key = gnt_tree_row_get_key(tree, row); \
 
182
                        GList *list = gnt_tree_get_row_text_list(tree, key); \
 
183
                        gboolean found = FALSE; \
 
184
                        found = (list->data && g_ascii_strncasecmp(text, list->data, len) == 0); \
 
185
                        g_list_foreach(list, (GFunc)g_free, NULL); \
 
186
                        g_list_free(list); \
 
187
                        if (found) { \
 
188
                                if (!showing) \
 
189
                                        popup_dropdown(box); \
 
190
                                gnt_tree_set_selected(tree, key); \
 
191
                                return TRUE; \
 
192
                        } \
 
193
                } \
 
194
} while (0)
 
195
 
 
196
                int len = strlen(text);
 
197
                GntTree *tree = GNT_TREE(box->dropdown);
 
198
                GntTreeRow *current = tree->current;
 
199
 
 
200
                SEARCH_IN_RANGE(gnt_tree_row_get_next(tree, current), NULL);
 
201
                SEARCH_IN_RANGE(tree->top, current);
 
202
 
 
203
#undef SEARCH_IN_RANGE
182
204
        }
183
205
 
184
206
        return FALSE;
229
251
        gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height);
230
252
}
231
253
 
 
254
static gboolean
 
255
dropdown_menu(GntBindable *b, GList *null)
 
256
{
 
257
        if (GNT_WIDGET_IS_FLAG_SET(GNT_COMBO_BOX(b)->dropdown->parent, GNT_WIDGET_MAPPED))
 
258
                return FALSE;
 
259
        popup_dropdown(GNT_COMBO_BOX(b));
 
260
        return TRUE;
 
261
}
 
262
 
232
263
static void
233
264
gnt_combo_box_class_init(GntComboBoxClass *klass)
234
265
{
 
266
        GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
 
267
 
235
268
        parent_class = GNT_WIDGET_CLASS(klass);
236
269
 
237
270
        parent_class->destroy = gnt_combo_box_destroy;
245
278
        widget_lost_focus = parent_class->lost_focus;
246
279
        parent_class->lost_focus = gnt_combo_box_lost_focus;
247
280
 
248
 
        signals[SIG_SELECTION_CHANGED] = 
 
281
        signals[SIG_SELECTION_CHANGED] =
249
282
                g_signal_new("selection-changed",
250
283
                                         G_TYPE_FROM_CLASS(klass),
251
284
                                         G_SIGNAL_RUN_LAST,
254
287
                                         gnt_closure_marshal_VOID__POINTER_POINTER,
255
288
                                         G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
256
289
 
 
290
        gnt_bindable_class_register_action(bindable, "dropdown", dropdown_menu,
 
291
                        GNT_KEY_DOWN, NULL);
 
292
        gnt_bindable_register_binding(bindable, "dropdown", GNT_KEY_UP, NULL);
 
293
 
 
294
        gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
 
295
 
257
296
        GNTDEBUG;
258
297
}
259
298
 
272
311
        GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT);
273
312
        gnt_box_set_pad(GNT_BOX(box), 0);
274
313
        gnt_box_add_widget(GNT_BOX(box), combo->dropdown);
275
 
        
 
314
 
276
315
        widget->priv.minw = 4;
277
316
        widget->priv.minh = 3;
278
317
        GNTDEBUG;