qulogic/libgnt

539d64974ff7
Parents 80dbe1b57ab7
Children 20106af4c17b
wms/s: Special case "MainWindow" instead of "buddylist" window

This patch changes the sample window manager from demonstrating
specially handling a window named "buddylist" to handling one named
"MainWindow" instead. This is an additional change in order to make
the sample window manager more generic and less bound to its
libpurple roots. The keyboard shortcut was kept as Alt+B as I
couldn't find a more appropriate alternative which wasn't already
used.
  • +14 -13
    wms/s.c
  • --- a/wms/s.c Thu Dec 06 21:13:52 2018 -0600
    +++ b/wms/s.c Wed Dec 19 13:37:30 2018 -0600
    @@ -33,7 +33,7 @@
    static void (*org_new_window)(GntWM *wm, GntWidget *win);
    static void
    -envelope_buddylist(GntWidget *win)
    +envelope_main_window(GntWidget *win)
    {
    int w, h;
    gnt_widget_get_size(win, &w, &h);
    @@ -61,8 +61,8 @@
    const char *name;
    name = gnt_widget_get_name(win);
    - if (name && strcmp(name, "buddylist") == 0) {
    - envelope_buddylist(win);
    + if (name && strcmp(name, "MainWindow") == 0) {
    + envelope_main_window(win);
    } else {
    envelope_normal_window(win);
    }
    @@ -80,7 +80,7 @@
    int x, y, w, h;
    int maxx, maxy;
    const char *name;
    - gboolean blist = FALSE;
    + gboolean main_window = FALSE;
    if (!GNT_IS_MENU(win)) {
    getmaxyx(stdscr, maxy, maxx);
    @@ -90,12 +90,12 @@
    name = gnt_widget_get_name(win);
    - if (name && strcmp(name, "buddylist") == 0) {
    - /* The buddylist doesn't have no border nor nothing! */
    + if (name && strcmp(name, "MainWindow") == 0) {
    + /* The MainWindow doesn't have no border nor nothing! */
    x = 0;
    y = 0;
    h = maxy - 1;
    - blist = TRUE;
    + main_window = TRUE;
    gnt_box_set_toplevel(GNT_BOX(win), FALSE);
    GNT_WIDGET_SET_FLAGS(win, GNT_WIDGET_CAN_TAKE_FOCUS);
    @@ -118,7 +118,7 @@
    }
    org_new_window(wm, win);
    - if (blist)
    + if (main_window)
    gnt_wm_raise_window(wm, win);
    }
    @@ -161,12 +161,12 @@
    }
    static gboolean
    -raise_buddylist(GntBindable *bindable, GList *null)
    +raise_main_window(GntBindable *bindable, GList *null)
    {
    GntWM *wm = GNT_WM(bindable);
    - GntWidget *blist = find_widget(wm, "buddylist");
    - if (blist)
    - gnt_wm_raise_window(wm, blist);
    + GntWidget *main_window = find_widget(wm, "MainWindow");
    + if (main_window)
    + gnt_wm_raise_window(wm, main_window);
    return TRUE;
    }
    @@ -183,7 +183,8 @@
    pclass->mouse_clicked = s_mouse_clicked;
    gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass),
    - "raise-buddylist", raise_buddylist, "\033" "b", NULL);
    + "raise-main-window", raise_main_window,
    + "\033" "b", NULL);
    gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
    GNTDEBUG;
    }