URI: 
       label.c - ltk - GUI toolkit for X11 (WIP)
  HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/ltk.git (encrypted, but very slow)
  HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ltk.git (over tor)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       label.c (1850B)
       ---
            1 /*
            2  * Copyright (c) 2021-2024 lumidify <nobody@lumidify.org>
            3  *
            4  * Permission to use, copy, modify, and/or distribute this software for any
            5  * purpose with or without fee is hereby granted, provided that the above
            6  * copyright notice and this permission notice appear in all copies.
            7  *
            8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
            9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
           10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
           11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
           12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
           13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
           14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
           15  */
           16 
           17 #include <stddef.h>
           18 
           19 #include "err.h"
           20 #include "ltkd.h"
           21 #include "widget.h"
           22 #include "cmd.h"
           23 
           24 #include <ltk/ltk.h>
           25 #include <ltk/util.h>
           26 #include <ltk/label.h>
           27 
           28 /* label <label id> create <text> */
           29 static int
           30 ltkd_label_cmd_create(
           31     ltk_window *window,
           32     ltkd_widget *widget_unneeded,
           33     ltkd_cmd_token *tokens,
           34     size_t num_tokens,
           35     ltkd_error *err) {
           36         (void)widget_unneeded;
           37         ltkd_cmdarg_parseinfo cmd[] = {
           38                 {.type = CMDARG_IGNORE, .optional = 0},
           39                 {.type = CMDARG_STRING, .optional = 0},
           40                 {.type = CMDARG_IGNORE, .optional = 0},
           41                 {.type = CMDARG_STRING, .optional = 0},
           42         };
           43         if (ltkd_parse_cmd(tokens, num_tokens, cmd, LENGTH(cmd), err))
           44                 return 1;
           45         ltk_label *label = ltk_label_create(window, cmd[3].val.str);
           46         if (!ltkd_widget_create(LTK_CAST_WIDGET(label), cmd[1].val.str, NULL, 0, err)) {
           47                 ltk_widget_destroy(LTK_CAST_WIDGET(label), 1);
           48                 err->arg = 1;
           49                 return 1;
           50         }
           51 
           52         return 0;
           53 }
           54 
           55 static ltkd_cmd_info label_cmds[] = {
           56         {"create", &ltkd_label_cmd_create, 1},
           57 };
           58 
           59 GEN_CMD_HELPERS(ltkd_label_cmd, LTK_WIDGET_LABEL, label_cmds)