SRC += menu.c
SRC += window.c
SRC += filebrowser.c
+SRC += gtk-filesview.c
SRC += $(MZUI)
*/
typedef struct FileBrowser {
UiContext *ctx;
+
+ /*
+ * view tabview (icon-grid, list)
+ */
+ UiInteger *view;
+
+ /*
+ * gridview file list
+ */
+ UiList *grid_files;
+
+ /*
+ * file listview list
+ */
+ UiList *list_files;
} FileBrowser;
UiContext *ctx = ui_document_context(browser);
browser->ctx = ctx;
+ browser->view = ui_int_new(ctx, "view");
+
+ browser->grid_files = ui_list_new(ctx, "grid_files");
+ browser->list_files = ui_list_new(ctx, "list_files");
+
return browser;
}
--- /dev/null
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2024 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gtk-filesview.h"
+
+
+
+
+G_DEFINE_TYPE(MzFilesView, mz_files_view, GTK_TYPE_WIDGET)
+
+static void mz_files_view_class_init(MzFilesViewClass *klass) {
+ printf("mz_files_view_class_init\n");
+ klass->parent_class.snapshot = mz_files_view_snapshot;
+}
+
+static void mz_files_view_init(MzFilesView *self) {
+ self->data = NULL;
+}
+
+MzFilesView* mz_files_view_new(void) {
+ MzFilesView *obj = g_object_new(mz_files_view_get_type(), NULL);
+ obj->data = NULL;
+ return obj;
+}
+
+void mz_files_view_snapshot(GtkWidget *widget, GtkSnapshot *snapshot) {
+ printf("mz_files_view_snapshot\n");
+
+ GdkRGBA red;
+ gdk_rgba_parse (&red, "red");
+
+ int w = gtk_widget_get_width(widget);
+ int h = gtk_widget_get_height(widget);
+
+ gtk_snapshot_append_color(snapshot, &red, &GRAPHENE_RECT_INIT(0, 0, w, h));
+}
--- /dev/null
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2024 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MZ_GTK_FILEVIEW_H
+#define MZ_GTK_FILEVIEW_H
+
+#include "application.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct MzFilesView {
+ GtkWidget widget;
+ void *data;
+} MzFilesView;
+
+typedef struct MzFilesViewClass {
+ GtkWidgetClass parent_class;
+} MzFilesViewClass;
+
+MzFilesView* mz_files_view_new(void);
+
+void mz_files_view_snapshot(GtkWidget *widget, GtkSnapshot *snapshot);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MZ_GTK_FILEVIEW_H */
+
#include "filebrowser.h"
+#ifdef GTK_MAJOR_VERSION
+#include "gtk-filesview.h"
+#endif
+
UiObject* window_create(const char *url) {
// toplevel window object
UiObject *obj = ui_sidebar_window("Mizunara", NULL);
ui_attach_document(obj->ctx, browser);
// add UI
- ui_sidebar0(obj) {
+ ui_sidebar0(obj) {
UiSubList sublists[] = {
{ .value = wdata->default_dirs, .userdata = window_sidebar_default_dirs_item },
{ .value = wdata->user_dirs, .userdata = window_sidebar_user_dirs_item, .separator = TRUE }
ui_sourcelist(obj, .sublists = sublists, .numsublists = 2, .getvalue = window_sidebar_getvalue);
}
+ ui_hbox(obj, .spacing = 4, .fill = UI_OFF) {
+ ui_button(obj, .style_class = "flat", .icon = UI_ICON_GO_BACK);
+ ui_button(obj, .style_class = "flat", .icon = UI_ICON_GO_FORWARD);
+ ui_path_textfield(obj, .varname = "path", .fill = UI_ON);
+ }
+
+ window_create_browser_view(obj, wdata);
+ ui_set(browser->view, 0); // select default view
+
+
return obj;
}
+#ifdef GTK_MAJOR_VERSION
+static UIWIDGET create_filesview(UiObject *obj, UiWidgetArgs args, void *userdata) {
+ MzFilesView *view = mz_files_view_new();
+ return GTK_WIDGET(view);
+}
+#endif
+
+void window_create_browser_view(UiObject *obj, MainWindow *win) {
+ ui_tabview(obj, .tabview = UI_TABVIEW_INVISIBLE, .varname = "view") {
+ ui_tab(obj, "iconview") {
+ ui_customwidget(obj, create_filesview, NULL, .fill = UI_ON);
+ }
+
+ ui_tab(obj, "listview") {
+
+ }
+ }
+}
+
void windowdata_init(UiContext *ctx, MainWindow *win) {
win->default_dirs = ui_list_new(ctx, NULL);
UiObject* window_create(const char *url);
+void window_create_browser_view(UiObject *obj, MainWindow *win);
+
void windowdata_init(UiContext *ctx, MainWindow *win);
void window_sidebar_getvalue(void *sublist_userdata, void *rowdata, int index, UiSubListItem *item);
return 1;
}
+UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args) {
+ UiObject* current = uic_current_obj(obj);
+
+ UIWIDGET widget = create_widget(obj, args, userdata);
+
+ UI_APPLY_LAYOUT1(current, args);
+ current->container->add(current->container, widget, FALSE);
+
+ return widget;
+}
+
GtkWidget* ui_gtk_vbox_new(int spacing) {
#if GTK_MAJOR_VERSION >= 3
return gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing);
UI_HEADERBAR_ALTERNATIVE_BOX
} UiHeaderbarAlternative;
+typedef struct UiWidgetArgs {
+ UiTri fill;
+ UiBool hexpand;
+ UiBool vexpand;
+ UiBool hfill;
+ UiBool vfill;
+ int colspan;
+ int rowspan;
+ const char *name;
+ const char *style_class;
+} UiWidgetArgs;
+
typedef struct UiContainerArgs {
UiTri fill;
UiBool hexpand;
UIEXPORT UiObject* ui_document_tab(UiTabbedPane *view);
+typedef UIWIDGET (*ui_createwidget_func)(UiObject *obj, UiWidgetArgs args, void *userdata);
+UIEXPORT UIWIDGET ui_customwidget_create(UiObject *obj, ui_createwidget_func create_widget, void *userdata, UiWidgetArgs args);
+
+#define ui_customwidget(obj, create_widget, userdata, ...) ui_customwidget_create(obj, create_widget, userdata, (UiWidgetArgs) { __VA_ARGS__ })
+
+
/* used for macro */
UIEXPORT void ui_container_begin_close(UiObject *obj);
UIEXPORT int ui_container_finish(UiObject *obj);