Changeset ee3b28a9 in mainline for uspace/app


Ignore:
Timestamp:
2024-02-26T13:30:48Z (20 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
d92b8e8f
Parents:
90ba06c
git-author:
Jiri Svoboda <jiri@…> (2024-02-25 16:12:29)
git-committer:
Jiri Svoboda <jiri@…> (2024-02-26 13:30:48)
Message:

Notify taskbar when start menu changes

Location:
uspace/app
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskbar-cfg/smeedit.c

    r90ba06c ree3b28a9  
    403403
    404404                startmenu_repaint(smee->startmenu);
     405                (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    405406        } else {
    406407                /* Edit existing entry */
     
    419420                (void)smenu_entry_save(smee->smentry->entry);
    420421                startmenu_entry_update(smee->smentry);
     422                (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    421423        }
    422424
  • uspace/app/taskbar-cfg/startmenu.c

    r90ba06c ree3b28a9  
    515515
    516516        (void)smee;
     517        (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    517518}
    518519
     
    533534        (void)startmenu_insert(smenu, entry, &smentry);
    534535        (void)ui_control_paint(ui_list_ctl(smenu->entries_list));
     536        (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    535537}
    536538
     
    633635        free(smentry);
    634636        (void)ui_control_paint(ui_list_ctl(smenu->entries_list));
     637        (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    635638}
    636639
     
    685688
    686689        (void)ui_control_paint(ui_list_ctl(smenu->entries_list));
     690        (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    687691}
    688692
     
    711715
    712716        (void)ui_control_paint(ui_list_ctl(smenu->entries_list));
     717        (void)tbarcfg_notify(TBARCFG_NOTIFY_DEFAULT);
    713718}
    714719
  • uspace/app/taskbar/taskbar.c

    r90ba06c ree3b28a9  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4848#include "wndlist.h"
    4949
     50#define TASKBAR_CONFIG_FILE "/cfg/taskbar.sif"
     51
    5052static void taskbar_wnd_close(ui_window_t *, void *);
    5153static void taskbar_wnd_kbd(ui_window_t *, void *, kbd_event_t *);
    5254static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *);
     55static void taskbar_notif_cb(void *);
    5356
    5457static ui_window_cb_t window_cb = {
     
    201204        }
    202205
    203         rc = tbsmenu_load(taskbar->tbsmenu, "/cfg/taskbar.sif");
     206        rc = tbsmenu_load(taskbar->tbsmenu, TASKBAR_CONFIG_FILE);
    204207        if (rc != EOK) {
    205208                printf("Error loading start menu from '%s'.\n",
    206                     "/cfg/taskbar.sif");
     209                    TASKBAR_CONFIG_FILE);
     210        }
     211
     212        rc = tbarcfg_listener_create(TBARCFG_NOTIFY_DEFAULT,
     213            taskbar_notif_cb, (void *)taskbar, &taskbar->lst);
     214        if (rc != EOK) {
     215                printf("Error listening for configuration changes.\n");
    207216        }
    208217
     
    287296        return EOK;
    288297error:
     298        if (taskbar->lst != NULL)
     299                tbarcfg_listener_destroy(taskbar->lst);
    289300        if (taskbar->clock != NULL)
    290301                taskbar_clock_destroy(taskbar->clock);
     
    304315void taskbar_destroy(taskbar_t *taskbar)
    305316{
     317        if (taskbar->lst != NULL)
     318                tbarcfg_listener_destroy(taskbar->lst);
    306319        ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock));
    307320        taskbar_clock_destroy(taskbar->clock);
     
    312325}
    313326
     327/** Configuration change notification callback.
     328 *
     329 * Called when configuration changed.
     330 *
     331 * @param arg Argument (taskbar_t *)
     332 */
     333static void taskbar_notif_cb(void *arg)
     334{
     335        taskbar_t *taskbar = (taskbar_t *)arg;
     336
     337        ui_lock(taskbar->ui);
     338        tbsmenu_reload(taskbar->tbsmenu);
     339        ui_unlock(taskbar->ui);
     340}
     341
    314342/** @}
    315343 */
  • uspace/app/taskbar/tbsmenu.c

    r90ba06c ree3b28a9  
    135135        errno_t rc;
    136136
     137        if (tbsmenu->repopath != NULL)
     138                free(tbsmenu->repopath);
     139
     140        tbsmenu->repopath = str_dup(repopath);
     141        if (tbsmenu->repopath == NULL)
     142                return ENOMEM;
     143
     144        /* Remove existing entries */
     145        tentry = tbsmenu_first(tbsmenu);
     146        while (tentry != NULL) {
     147                tbsmenu_remove(tbsmenu, tentry, false);
     148                tentry = tbsmenu_first(tbsmenu);
     149        }
     150
    137151        rc = tbarcfg_open(repopath, &tbcfg);
    138152        if (rc != EOK)
     
    170184}
    171185
     186/** Reload start menu from repository (or schedule reload).
     187 *
     188 * @param tbsmenu Start menu
     189 */
     190void tbsmenu_reload(tbsmenu_t *tbsmenu)
     191{
     192        if (!tbsmenu_is_open(tbsmenu))
     193                (void) tbsmenu_load(tbsmenu, tbsmenu->repopath);
     194        else
     195                tbsmenu->needs_reload = true;
     196}
     197
    172198/** Set start menu rectangle.
    173199 *
     
    198224{
    199225        ui_menu_close(tbsmenu->smenu);
     226
     227        if (tbsmenu->needs_reload)
     228                (void) tbsmenu_load(tbsmenu, tbsmenu->repopath);
    200229}
    201230
  • uspace/app/taskbar/tbsmenu.h

    r90ba06c ree3b28a9  
    4848extern errno_t tbsmenu_create(ui_window_t *, ui_fixed_t *, tbsmenu_t **);
    4949extern errno_t tbsmenu_load(tbsmenu_t *, const char *);
     50extern void tbsmenu_reload(tbsmenu_t *);
    5051extern void tbsmenu_set_rect(tbsmenu_t *, gfx_rect_t *);
    5152extern void tbsmenu_open(tbsmenu_t *);
  • uspace/app/taskbar/types/taskbar.h

    r90ba06c ree3b28a9  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6060        /** Clock */
    6161        taskbar_clock_t *clock;
     62        /** Configuration change listener */
     63        tbarcfg_listener_t *lst;
    6264} taskbar_t;
    6365
  • uspace/app/taskbar/types/tbsmenu.h

    r90ba06c ree3b28a9  
    4040#include <gfx/coord.h>
    4141#include <stdbool.h>
     42#include <tbarcfg/tbarcfg.h>
    4243#include <ui/pbutton.h>
    4344#include <ui/fixed.h>
     
    8485        /** Device ID of last input event */
    8586        sysarg_t ev_idev_id;
     87
     88        /** Repository path name */
     89        char *repopath;
     90
     91        /** Need to reload menu when possible */
     92        bool needs_reload;
    8693} tbsmenu_t;
    8794
Note: See TracChangeset for help on using the changeset viewer.