source: trunk/dports/sysutils/amttools/files/patch-gamt.c-switch-to-GTK3.diff @ 146024

Last change on this file since 146024 was 146024, checked in by ionic@…, 3 years ago

amttools: new port.

Includes amttool (for querying AMT properties), amtterm (for connecting
to SoL virtual adapters), gamt (GTK3-/vte-based SoL terminal) and the
famous amt-howto man page.

File size: 7.5 KB
  • gamt.c

    old new static void menu_cb_config_font(GtkActio 
    259259    char *fontname;
    260260    int done = 0;
    261261
    262     dialog = gtk_font_selection_dialog_new("Terminal font");
     262    dialog = gtk_font_chooser_dialog_new("Terminal font", NULL);
    263263    fontname = cfg_get_str(CFG_FONT);
    264     gtk_font_selection_dialog_set_font_name
    265         (GTK_FONT_SELECTION_DIALOG(dialog), fontname);
     264    gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dialog), fontname);
    266265
    267266    gtk_widget_show_all(dialog);
    268267    while (!done) {
    static void menu_cb_config_font(GtkActio 
    271270            done=1;
    272271            /* fall through */
    273272        case GTK_RESPONSE_APPLY:
    274             fontname = gtk_font_selection_dialog_get_font_name
    275                 (GTK_FONT_SELECTION_DIALOG(dialog));
     273            fontname = gtk_font_chooser_get_font(GTK_FONT_CHOOSER(dialog));
    276274            vte_terminal_set_font_from_string(VTE_TERMINAL(gamt->vte), fontname);
    277275            cfg_set_str(CFG_FONT, fontname);
    278276            break;
    static void menu_cb_config_font(GtkActio 
    284282    gtk_widget_destroy(dialog);
    285283}
    286284
    287 static int pickcolor(char *title, GdkColor *color)
     285static int pickcolor(char *title, GdkRGBA *color)
    288286{
    289287    GtkWidget *dialog;
    290     GtkColorSelection *csel;
    291288    int rc = -1;
    292289
    293     dialog = gtk_color_selection_dialog_new(title);
    294     csel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel);
    295     gtk_color_selection_set_has_opacity_control(csel, FALSE);
    296     gtk_color_selection_set_current_color(csel, color);
     290    dialog = gtk_color_chooser_dialog_new(title, NULL);
     291    gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(dialog), color);
    297292
    298293    gtk_widget_show_all(dialog);
    299294    switch (gtk_dialog_run(GTK_DIALOG(dialog))) {
    300295    case GTK_RESPONSE_OK:
    301         gtk_color_selection_get_current_color(csel, color);
    302         rc = 0;
     296            gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(dialog), color);
     297            rc = 0;
    303298    }
    304299    gtk_widget_destroy(dialog);
    305300    return rc;
    static int pickcolor(char *title, GdkCol 
    308303static void menu_cb_config_fg(GtkAction *action, void *data)
    309304{
    310305    struct gamt_window *gamt = data;
    311     GdkColor color = {0,0,0,0};
     306    GdkRGBA color = {};
    312307    char name[16];
    313308
    314     gdk_color_parse(cfg_get_str(CFG_FOREGROUND), &color);
     309    gdk_rgba_parse(&color, cfg_get_str(CFG_FOREGROUND));
    315310    if (0 != pickcolor("Text color", &color))
    316         return;
    317     vte_terminal_set_color_foreground(VTE_TERMINAL(gamt->vte), &color);
     311            return;
     312    vte_terminal_set_color_foreground_rgba(VTE_TERMINAL(gamt->vte), &color);
    318313    snprintf(name, sizeof(name), "#%04x%04x%04x",
    319              color.red, color.green, color.blue);
     314             (int)(color.red * 65535),
     315             (int)(color.green * 65535),
     316             (int)(color.blue * 65535));
    320317    cfg_set_str(CFG_FOREGROUND, name);
    321318}
    322319
    323320static void menu_cb_config_bg(GtkAction *action, void *data)
    324321{
    325322    struct gamt_window *gamt = data;
    326     GdkColor color = {0,0,0,0};
     323    GdkRGBA color = {};
    327324    char name[16];
    328325
    329     gdk_color_parse(cfg_get_str(CFG_BACKGROUND), &color);
     326    gdk_rgba_parse(&color, cfg_get_str(CFG_BACKGROUND));
    330327    if (0 != pickcolor("Background color", &color))
    331328        return;
    332     vte_terminal_set_color_background(VTE_TERMINAL(gamt->vte), &color);
     329    vte_terminal_set_color_background_rgba(VTE_TERMINAL(gamt->vte), &color);
    333330    snprintf(name, sizeof(name), "#%04x%04x%04x",
    334              color.red, color.green, color.blue);
     331             (int)(color.red * 65535),
     332             (int)(color.green * 65535),
     333             (int)(color.blue * 65535));
    335334    cfg_set_str(CFG_BACKGROUND, name);
    336335}
    337336
    static void menu_cb_blink_cursor(GtkTogg 
    339338{
    340339    struct gamt_window *gamt = user_data;
    341340    gboolean state = gtk_toggle_action_get_active(action);
     341    VteTerminalCursorBlinkMode blink;
    342342
    343343    if (amt_debug)
    344344        fprintf(stderr, "%s: %s\n", __FUNCTION__, state ? "on" : "off");
    345345    cfg_set_bool(CFG_BLINK, state);
    346     vte_terminal_set_cursor_blinks(VTE_TERMINAL(gamt->vte), state);
     346    blink = state ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF;
     347    vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(gamt->vte), blink);
    347348}
    348349
    349350static void menu_cb_quit(GtkAction *action, void *data)
    static void show_manpage(char *page, cha 
    370371        /* ... fallback is an xterm with man */
    371372        snprintf(buf, sizeof(buf), "manual page: %s(%s)", page, section);
    372373        execlp("xterm", "xterm",
    373                "-title", buf, 
     374               "-title", buf,
    374375               "-e", "man", section, page,
    375376               NULL);
    376377        perror("execlp(xterm)");
    static char hosts_xml_end[] = 
    624625static int gamt_getstring(GtkWidget *window, char *title, char *message,
    625626                          char *dest, int dlen, int hide)
    626627{
    627     GtkWidget *dialog, *label, *entry;
     628    GtkWidget *dialog, *label, *entry, *box;
    628629    const char *txt;
    629630    int retval;
    630631
    static int gamt_getstring(GtkWidget *win 
    648649    if (hide)
    649650        gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
    650651
    651     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
    652     gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry);
    653     gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 10);
     652    box = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
     653    gtk_container_add(GTK_CONTAINER(box), label);
     654    gtk_container_add(GTK_CONTAINER(box), entry);
    654655#if 0 /* FIXME: doesn't work ... */
    655     gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 10);
     656    gtk_box_set_spacing(GTK_BOX(box), 10);
     657    gtk_container_set_border_width(GTK_CONTAINER(box), 10);
    656658#endif
    657659
    658660    /* show and wait for response */
    static int gamt_connect(struct gamt_wind 
    779781static struct gamt_window *gamt_window()
    780782{
    781783    GtkWidget *vbox, *hbox, *frame, *item;
    782     GdkColor color;
     784    VteTerminalCursorBlinkMode blink;
     785    GdkRGBA color;
    783786    GError *err;
    784787    gboolean state;
    785788    struct gamt_window *gamt;
    static struct gamt_window *gamt_window() 
    831834    item = gtk_ui_manager_get_widget(gamt->ui, "/MainMenu/ConfigMenu/BlinkCursor");
    832835    state = cfg_get_bool(CFG_BLINK, 0);
    833836    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), state);
    834     vte_terminal_set_cursor_blinks(VTE_TERMINAL(gamt->vte), state);
     837    blink = state ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF;
     838    vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(gamt->vte), blink);
    835839
    836840    /* other widgets */
    837841    gamt->status = gtk_label_new("idle");
    static struct gamt_window *gamt_window() 
    841845                                          GTK_ICON_SIZE_SMALL_TOOLBAR);
    842846
    843847    /* Make a vbox and put stuff in */
    844     vbox = gtk_vbox_new(FALSE, 1);
    845     hbox = gtk_hbox_new(FALSE, 1);
     848    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1);
     849    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
    846850    gtk_container_set_border_width(GTK_CONTAINER(vbox), 1);
    847851    gtk_container_add(GTK_CONTAINER(gamt->win), vbox);
    848852    item = gtk_ui_manager_get_widget(gamt->ui, "/MainMenu");
    static struct gamt_window *gamt_window() 
    867871
    868872    str = cfg_get_str(CFG_FOREGROUND);
    869873    if (str) {
    870         gdk_color_parse(str, &color);
    871         vte_terminal_set_color_foreground(VTE_TERMINAL(gamt->vte), &color);
     874        gdk_rgba_parse(&color, str);
     875        vte_terminal_set_color_foreground_rgba(VTE_TERMINAL(gamt->vte), &color);
    872876    }
    873877    str = cfg_get_str(CFG_BACKGROUND);
    874878    if (str) {
    875         gdk_color_parse(str, &color);
    876         vte_terminal_set_color_background(VTE_TERMINAL(gamt->vte), &color);
     879        gdk_rgba_parse(&color, str);
     880        vte_terminal_set_color_background_rgba(VTE_TERMINAL(gamt->vte), &color);
    877881    }
    878882
    879883    return gamt;
Note: See TracBrowser for help on using the repository browser.