Changeset ee3b28a9 in mainline for uspace/app/taskbar/taskbar.c


Ignore:
Timestamp:
2024-02-26T13:30:48Z (9 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 */
Note: See TracChangeset for help on using the changeset viewer.