ui/gtk/list.c

branch
newapi
changeset 413
b8e41d42f400
parent 411
3e91b7aff6a1
--- a/ui/gtk/list.c	Thu Dec 12 11:23:33 2024 +0100
+++ b/ui/gtk/list.c	Thu Dec 12 16:34:39 2024 +0100
@@ -1025,12 +1025,42 @@
     }
 } 
 
+#ifdef UI_GTK3
+typedef struct _UiSidebarListBoxClass {
+    GtkListBoxClass parent_class; 
+} UiSidebarListBoxClass;
+
+typedef struct _UiSidebarListBox {
+    GtkListBox parent_instance;
+} UiSidebarListBox;
+
+G_DEFINE_TYPE(UiSidebarListBox, ui_sidebar_list_box, GTK_TYPE_LIST_BOX)
+
+/* Initialize the instance */
+static void ui_sidebar_list_box_class_init(UiSidebarListBoxClass *klass) {
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+    gtk_widget_class_set_css_name (widget_class, "placessidebar");
+}
+
+static void ui_sidebar_list_box_init(UiSidebarListBox *self) {
+    
+}
+#endif
+
 UIEXPORT UIWIDGET ui_sourcelist_create(UiObject *obj, UiSourceListArgs args) {
     UiObject* current = uic_current_obj(obj);
     
+#ifdef UI_GTK3
+    GtkWidget *listbox = g_object_new(ui_sidebar_list_box_get_type(), NULL);
+#else
     GtkWidget *listbox = gtk_list_box_new();
+#endif
     if(!args.style_class) {
+#if GTK_MAJOR_VERSION >= 4
         WIDGET_ADD_CSS_CLASS(listbox, "navigation-sidebar");
+#else
+        WIDGET_ADD_CSS_CLASS(listbox, "sidebar");
+#endif
     }
     gtk_list_box_set_header_func(GTK_LIST_BOX(listbox), listbox_create_header, NULL, NULL);
     GtkWidget *scroll_area = SCROLLEDWINDOW_NEW();

mercurial