~ubuntu-branches/ubuntu/hardy/pidgin/hardy

« back to all changes in this revision

Viewing changes to finch/libgnt/gntmenu.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-21 02:48:06 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071221024806-pd44a5k9tiyh12mp
Tags: 1:2.3.1-2ubuntu1
* Sync with Debian, remaining Ubuntu changes; (LP: #177811)
  - Set Maintainer to Ubuntu Core Developers.
  - Add build-deps on liblaunchpad-integration-dev, intltool,
    libnm-glib-dev (for --enable-nm) (Ubuntu #112720).
  - Drop build-deps on libsilc-1.1-2-dev | libsilc-dev (>= 1.1.1) as 
    this library is in universe.
  - Drop the libpurple0 recommends on libpurple-bin.
  - Add a gaim transitionnal package for upgrades.
  - Ship compatibility symlinks via debian/gaim.links.
  - Pass --enable-nm to configure to enable NetworkManager support.
  - Pass --disable-silc to configure to disable silc support even if 
    it's installed in the build environment.
  - Add X-Ubuntu-Gettext-Domain to the desktop file and update the
    translation templates in common-install-impl::.
   - Update debian/prefs.xml to set the notify plugin prefs
    /plugins/gtk/X11/notify/* and set /pidgin/plugins/loaded to load 
    the notify plugin; Ubuntu: #13389.
  - Add LPI integration patch, 02_lpi.
  - Add patch 04_let_crasher_for_apport to stop catching the SIGSEGV signal
    and let apport handle it.
  - Add patch 05_default_to_irc_ubuntu_com to set the default IRC 
    server to irc.ubuntu.com.
  - Add autoconf patch, 70_autoconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
static void (*org_size_request)(GntWidget *wid);
48
48
static gboolean (*org_key_pressed)(GntWidget *w, const char *t);
49
49
 
 
50
static void menuitem_activate(GntMenu *menu, GntMenuItem *item);
 
51
 
 
52
static void
 
53
menu_hide_all(GntMenu *menu)
 
54
{
 
55
        while (menu->parentmenu)
 
56
                menu = menu->parentmenu;
 
57
        gnt_widget_hide(GNT_WIDGET(menu));
 
58
}
 
59
 
 
60
static void
 
61
show_submenu(GntMenu *menu)
 
62
{
 
63
        GntMenuItem *item;
 
64
 
 
65
        if (menu->type != GNT_MENU_TOPLEVEL)
 
66
                        return;
 
67
 
 
68
        item = g_list_nth_data(menu->list, menu->selected);
 
69
        if (!item || !item->submenu)
 
70
                return;
 
71
        menuitem_activate(menu, item);
 
72
}
 
73
 
50
74
static void
51
75
gnt_menu_draw(GntWidget *widget)
52
76
{
56
80
        int i;
57
81
 
58
82
        if (menu->type == GNT_MENU_TOPLEVEL) {
59
 
                wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT));
 
83
                wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_HIGHLIGHT));
60
84
                werase(widget->window);
61
85
 
62
86
                for (i = 0, iter = menu->list; iter; iter = iter->next, i++) {
63
87
                        GntMenuItem *item = GNT_MENU_ITEM(iter->data);
64
 
                        type = ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT);
 
88
                        type = ' ' | gnt_color_pair(GNT_COLOR_HIGHLIGHT);
65
89
                        if (i == menu->selected)
66
90
                                type |= A_REVERSE;
67
91
                        item->priv.x = getcurx(widget->window) + widget->priv.x;
181
205
static void
182
206
menuitem_activate(GntMenu *menu, GntMenuItem *item)
183
207
{
184
 
        if (item) {
 
208
        if (!item)
 
209
                return;
 
210
 
 
211
        if (gnt_menuitem_activate(item)) {
 
212
                menu_hide_all(menu);
 
213
        } else {
185
214
                if (item->submenu) {
186
215
                        GntMenu *sub = GNT_MENU(item->submenu);
187
216
                        menu->submenu = sub;
195
224
                        gnt_widget_set_position(GNT_WIDGET(sub), item->priv.x, item->priv.y);
196
225
                        GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(sub), GNT_WIDGET_INVISIBLE);
197
226
                        gnt_widget_draw(GNT_WIDGET(sub));
198
 
                } else if (item->callback) {
199
 
                        item->callback(item, item->callbackdata);
200
 
                        while (menu) {
201
 
                                gnt_widget_hide(GNT_WIDGET(menu));
202
 
                                menu = menu->parentmenu;
203
 
                        }
 
227
                } else {
 
228
                        menu_hide_all(menu);
204
229
                }
205
230
        }
206
231
}
226
251
 
227
252
        if (nth == NULL)
228
253
                return FALSE;
229
 
                
 
254
 
230
255
        find = find_item_with_trigger(nth->next, NULL, trigger);
231
256
        if (!find)
232
257
                find = find_item_with_trigger(menu->list, nth->next, trigger);
267
292
                        gnt_widget_hide(widget);
268
293
                } else
269
294
                        gnt_widget_hide(widget);
 
295
                if (par && par->type == GNT_MENU_TOPLEVEL)
 
296
                        gnt_menu_key_pressed(GNT_WIDGET(par), text);
270
297
                return TRUE;
271
298
        }
272
299
 
286
313
 
287
314
                if (current != menu->selected) {
288
315
                        GntMenu *sub = menu->submenu;
289
 
                        while (sub) {
 
316
                        if (sub)
290
317
                                gnt_widget_hide(GNT_WIDGET(sub));
291
 
                                sub = sub->submenu;
292
 
                        }
 
318
                        show_submenu(menu);
293
319
                        gnt_widget_draw(widget);
294
320
                        return TRUE;
295
321
                }
326
352
        GntMenu *menu = GNT_MENU(tree);
327
353
        gboolean check = gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item));
328
354
        gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !check);
329
 
        if (item->callback)
330
 
                item->callback(item, item->callbackdata);
 
355
        gnt_menuitem_activate(item);
331
356
        while (menu) {
332
357
                gnt_widget_hide(GNT_WIDGET(menu));
333
358
                menu = menu->parentmenu;
459
484
        menu->list = g_list_append(menu->list, item);
460
485
}
461
486
 
 
487
GntMenuItem *gnt_menu_get_item(GntMenu *menu, const char *id)
 
488
{
 
489
        GntMenuItem *item = NULL;
 
490
        GList *iter = menu->list;
 
491
 
 
492
        if (!id || !*id)
 
493
                return NULL;
 
494
 
 
495
        for (; iter; iter = iter->next) {
 
496
                GntMenu *sub;
 
497
                item = iter->data;
 
498
                sub = gnt_menuitem_get_submenu(item);
 
499
                if (sub) {
 
500
                        item = gnt_menu_get_item(sub, id);
 
501
                        if (item)
 
502
                                break;
 
503
                } else {
 
504
                        const char *itid = gnt_menuitem_get_id(item);
 
505
                        if (itid && strcmp(itid, id) == 0)
 
506
                                break;
 
507
                        /* XXX: Perhaps look at the menu-label as well? */
 
508
                }
 
509
                item = NULL;
 
510
        }
 
511
 
 
512
        return item;
 
513
}
 
514