Enhancement: Fixes #308, Build - enable asan

This commit is contained in:
Rory Fewell
2024-06-05 06:46:08 +01:00
parent afb3922342
commit da7a18c76b
32 changed files with 960 additions and 357 deletions

View File

@@ -27,10 +27,37 @@ struct _WinTCTaskbandApplication
static void wintc_taskband_application_activate(
GApplication* application
);
static gint wintc_taskband_application_command_line(
GApplication* application,
GApplicationCommandLine* command_line
);
static gint wintc_taskband_application_handle_local_options(
GApplication* application,
GVariantDict* options
);
static void wintc_taskband_application_shutdown(
GApplication* application
);
static void wintc_taskband_application_startup(
GApplication* application
);
//
// STATIC DATA
//
static const GOptionEntry S_OPTIONS[] = {
{
"quit",
'q',
G_OPTION_FLAG_NONE,
G_OPTION_ARG_NONE,
NULL,
"Quit a running Windows taskband instance.",
NULL
},
{ 0 }
};
//
// GTK TYPE DEFINITION & CTORS
//
@@ -46,13 +73,27 @@ static void wintc_taskband_application_class_init(
{
GApplicationClass* application_class = G_APPLICATION_CLASS(klass);
application_class->activate = wintc_taskband_application_activate;
application_class->startup = wintc_taskband_application_startup;
application_class->activate =
wintc_taskband_application_activate;
application_class->command_line =
wintc_taskband_application_command_line;
application_class->handle_local_options =
wintc_taskband_application_handle_local_options;
application_class->shutdown =
wintc_taskband_application_shutdown;
application_class->startup =
wintc_taskband_application_startup;
}
static void wintc_taskband_application_init(
WINTC_UNUSED(WinTCTaskbandApplication* self)
) {}
WinTCTaskbandApplication* self
)
{
g_application_add_main_option_entries(
G_APPLICATION(self),
S_OPTIONS
);
}
//
// PUBLIC FUNCTIONS
@@ -67,6 +108,7 @@ WinTCTaskbandApplication* wintc_taskband_application_new(void)
g_object_new(
wintc_taskband_application_get_type(),
"application-id", "uk.co.oddmatics.wintc.taskband",
"flags", G_APPLICATION_HANDLES_COMMAND_LINE,
NULL
);
@@ -93,6 +135,54 @@ static void wintc_taskband_application_activate(
gtk_widget_show_all(taskband_app->host_window);
}
static gint wintc_taskband_application_command_line(
GApplication* application,
GApplicationCommandLine* command_line
)
{
GVariantDict* options =
g_application_command_line_get_options_dict(command_line);
// Just check for --quit
//
if (g_variant_dict_contains(options, "quit"))
{
g_application_quit(application);
return 0;
}
g_application_activate(application);
return 0;
}
static gint wintc_taskband_application_handle_local_options(
WINTC_UNUSED(GApplication* application),
WINTC_UNUSED(GVariantDict* options)
)
{
// Stub
return -1;
}
static void wintc_taskband_application_shutdown(
GApplication* application
)
{
GList* window_iter = NULL;
while (
(window_iter =
gtk_application_get_windows(GTK_APPLICATION(application)))
)
{
gtk_widget_destroy(GTK_WIDGET(window_iter->data));
}
(G_APPLICATION_CLASS(wintc_taskband_application_parent_class))
->shutdown(application);
}
static void wintc_taskband_application_startup(
GApplication* application
)

View File

@@ -26,6 +26,9 @@ static gint wintc_notification_behaviour_signals[N_SIGNALS] = { 0 };
//
// FORWARD DECLARATIONS
//
static void wintc_notification_behaviour_finalize(
GObject* object
);
static void wintc_notification_behaviour_get_property(
GObject* object,
guint prop_id,
@@ -54,6 +57,7 @@ static void wintc_notification_behaviour_class_init(
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->finalize = wintc_notification_behaviour_finalize;
object_class->get_property = wintc_notification_behaviour_get_property;
object_class->set_property = wintc_notification_behaviour_set_property;
@@ -105,6 +109,19 @@ static void wintc_notification_behaviour_init(
//
// CLASS VIRTUAL METHODS
//
static void wintc_notification_behaviour_finalize(
GObject* object
)
{
WinTCNotificationBehaviour* behaviour =
WINTC_NOTIFICATION_BEHAVIOUR(object);
g_free(behaviour->icon_name);
(G_OBJECT_CLASS(wintc_notification_behaviour_parent_class))
->finalize(object);
}
static void wintc_notification_behaviour_get_property(
GObject* object,
guint prop_id,

View File

@@ -30,6 +30,10 @@ struct _WinTCNotificationArea
//
// FORWARD DECLARATIONS
//
static void wintc_notification_area_dispose(
GObject* object
);
static GtkWidget* wintc_notification_area_append_icon(
WinTCNotificationArea* notif_area
);
@@ -59,8 +63,13 @@ G_DEFINE_TYPE(
)
static void wintc_notification_area_class_init(
WINTC_UNUSED(WinTCNotificationAreaClass* klass)
) {}
WinTCNotificationAreaClass* klass
)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->dispose = wintc_notification_area_dispose;
}
static void wintc_notification_area_init(
WinTCNotificationArea* self
@@ -69,7 +78,12 @@ static void wintc_notification_area_init(
// Create map for notification widgets --> behaviours
//
self->map_widget_to_behaviour =
g_hash_table_new(g_direct_hash, g_direct_equal);
g_hash_table_new_full(
g_direct_hash,
g_direct_equal,
NULL,
g_object_unref
);
// Set up UI
//
@@ -112,6 +126,27 @@ static void wintc_notification_area_init(
);
}
//
// CLASS VIRTUAL METHODS
//
static void wintc_notification_area_dispose(
GObject* object
)
{
WinTCNotificationArea* notif_area = WINTC_NOTIFICATION_AREA(object);
g_clear_object(&(notif_area->clock_runner));
if (notif_area->map_widget_to_behaviour)
{
g_hash_table_unref(
g_steal_pointer(&(notif_area->map_widget_to_behaviour))
);
}
(G_OBJECT_CLASS(wintc_notification_area_parent_class))->dispose(object);
}
//
// PUBLIC FUNCTIONS
//

View File

@@ -339,8 +339,10 @@ static void on_snd_output_muted_changed(
WinTCNotificationVolume* volume =
WINTC_NOTIFICATION_VOLUME(user_data);
gboolean muted = wintc_sndapi_output_is_muted(output);
gchar* icon_name = muted ? "audio-volume-muted" : "audio-volume-medium";
gboolean muted = wintc_sndapi_output_is_muted(output);
const gchar* icon_name = muted ?
"audio-volume-muted" :
"audio-volume-medium";
volume->syncing_state = TRUE;
gtk_toggle_button_set_active(

View File

@@ -29,6 +29,10 @@ struct _TaskButtonBar
//
// FORWARD DECLARATIONS
//
static void taskbutton_bar_finalize(
GObject* object
);
static void taskbutton_bar_get_preferred_height(
GtkWidget* widget,
gint* minimum_height,
@@ -94,6 +98,9 @@ static void taskbutton_bar_class_init(
{
GtkContainerClass* container_class = GTK_CONTAINER_CLASS(klass);
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->finalize = taskbutton_bar_finalize;
widget_class->get_preferred_height = taskbutton_bar_get_preferred_height;
widget_class->get_preferred_height_for_width =
@@ -124,6 +131,19 @@ static void taskbutton_bar_init(
//
// CLASS VIRTUAL METHODS
//
static void taskbutton_bar_finalize(
GObject* object
)
{
TaskButtonBar* taskbutton_bar = TASKBUTTON_BAR(object);
window_monitor_destroy(
taskbutton_bar->window_monitor
);
(G_OBJECT_CLASS(taskbutton_bar_parent_class))->finalize(object);
}
static void taskbutton_bar_add(
GtkContainer* container,
GtkWidget* widget

View File

@@ -78,6 +78,16 @@ static void window_manager_update_text(
//
// PUBLIC FUNCTIONS
//
void window_monitor_destroy(
WindowMonitor* monitor
)
{
g_hash_table_unref(monitor->window_manager_map);
g_free(monitor);
wintc_wndmgmt_shutdown();
}
WindowMonitor* window_monitor_init_management(
GtkContainer* container
)
@@ -86,9 +96,11 @@ WindowMonitor* window_monitor_init_management(
window_monitor->container = container;
window_monitor->screen = wintc_wndmgmt_screen_get_default();
window_monitor->window_manager_map = g_hash_table_new(
window_monitor->window_manager_map = g_hash_table_new_full(
g_direct_hash,
g_direct_equal
g_direct_equal,
NULL,
g_free
);
g_signal_connect(
@@ -319,7 +331,6 @@ static void on_window_closed(
gtk_widget_destroy(GTK_WIDGET(window_manager->button));
}
g_free(window_manager);
g_hash_table_remove(window_monitor->window_manager_map, window);
}

View File

@@ -14,6 +14,10 @@ typedef struct _WindowMonitor WindowMonitor;
//
// PUBLIC FUNCTIONS
//
void window_monitor_destroy(
WindowMonitor* monitor
);
WindowMonitor* window_monitor_init_management(
GtkContainer* container
);

View File

@@ -29,6 +29,10 @@ typedef enum
//
// FORWARD DECLARATIONS
//
static void wintc_taskband_window_dispose(
GObject* object
);
static void wintc_taskband_window_create_toolbar(
WinTCTaskbandWindow* taskband,
GType toolbar_type,
@@ -65,11 +69,15 @@ struct _WinTCTaskbandWindow
{
GtkApplicationWindow __parent__;
// UI
//
GtkWidget* main_box;
GtkWidget* notification_area;
GtkWidget* start_button;
GtkWidget* taskbuttons;
GSList* toolbars;
};
//
@@ -82,8 +90,13 @@ G_DEFINE_TYPE(
)
static void wintc_taskband_window_class_init(
WINTC_UNUSED(WinTCTaskbandWindowClass* klass)
) {}
WinTCTaskbandWindowClass* klass
)
{
GObjectClass* object_class = G_OBJECT_CLASS(klass);
object_class->dispose = wintc_taskband_window_dispose;
}
static void wintc_taskband_window_init(
WinTCTaskbandWindow* self
@@ -121,6 +134,20 @@ static void wintc_taskband_window_init(
);
}
//
// FORWARD DECLARATIONS
//
static void wintc_taskband_window_dispose(
GObject* object
)
{
WinTCTaskbandWindow* wnd = WINTC_TASKBAND_WINDOW(object);
g_clear_slist(&(wnd->toolbars), g_object_unref);
(G_OBJECT_CLASS(wintc_taskband_window_parent_class))->dispose(object);
}
//
// PUBLIC FUNCTIONS
//
@@ -155,6 +182,12 @@ static void wintc_taskband_window_create_toolbar(
toolbar
);
taskband->toolbars =
g_slist_append(
taskband->toolbars,
toolbar
);
gtk_box_pack_start(
GTK_BOX(taskband->main_box),
root,