Thu, 12 Dec 2024 16:34:39 +0100
fix gtk3 sourcelist styling
ui/gtk/list.c | file | annotate | diff | comparison | revisions | |
ui/gtk/toolkit.c | file | annotate | diff | comparison | revisions | |
ui/gtk/window.c | file | annotate | diff | comparison | revisions |
--- 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();
--- a/ui/gtk/toolkit.c Thu Dec 12 11:23:33 2024 +0100 +++ b/ui/gtk/toolkit.c Thu Dec 12 16:34:39 2024 +0100 @@ -396,6 +396,21 @@ ".ui_label_title {\n" " font-weight: bold;\n" "}\n" +"placessidebar row {\n" +" padding-left: 10px;\n" +"}\n" +".ui-listbox-header {\n" +" font-weight: bold;\n" +" margin-left: 10px;\n" +" margin-top: 12px;\n" +" margin-bottom: 10px;\n" +"}\n" +".ui-listbox-header-first {\n" +" font-weight: bold;\n" +" margin-left: 10px;\n" +" margin-top: 4px;\n" +" margin-bottom: 10px;\n" +"}\n" ; #endif
--- a/ui/gtk/window.c Thu Dec 12 11:23:33 2024 +0100 +++ b/ui/gtk/window.c Thu Dec 12 16:34:39 2024 +0100 @@ -136,7 +136,7 @@ } else { gtk_window_set_default_size( GTK_WINDOW(obj->widget), - window_default_width, + window_default_width + sidebar*250, window_default_height); } @@ -236,6 +236,7 @@ gtk_paned_add2(GTK_PANED(paned), content_box); BOX_ADD_EXPAND(GTK_BOX(vbox), paned); g_object_set_data(G_OBJECT(obj->widget), "ui_sidebar", sidebar_vbox); + gtk_paned_set_position (GTK_PANED(paned), 200); } else { BOX_ADD_EXPAND(GTK_BOX(vbox), content_box); }