From 588a68b2cc99d3f06589aa88f577d491989efd23 Mon Sep 17 00:00:00 2001 From: Joshua Strobl Date: Wed, 24 Feb 2021 20:17:18 +0200 Subject: [PATCH] Port to GTK4, start implementation of Local Music view, Artist and Album Views. --- data/style.css | 16 ++ meson.build | 2 +- src/indexer/album.c | 2 +- src/indexer/file-indexer.c | 22 +- src/indexer/file-indexer.h | 1 + src/koto-button.c | 143 ++++++------ src/koto-button.h | 6 +- src/koto-expander.c | 37 ++-- src/koto-expander.h | 4 +- src/koto-headerbar.c | 45 ---- src/koto-headerbar.ui | 2 +- src/koto-nav.c | 71 +++--- src/koto-nav.h | 5 +- src/koto-playerbar.c | 92 ++++---- src/koto-playerbar.h | 5 +- src/koto-track-item.c | 120 +++++++++++ src/{koto-headerbar.h => koto-track-item.h} | 13 +- src/koto-utils.c | 22 +- src/koto-utils.h | 2 + src/koto-window.c | 78 +++++-- src/koto-window.h | 3 +- src/meson.build | 9 +- src/pages/music/album-view.c | 169 +++++++++++++++ src/pages/music/album-view.h | 36 ++++ src/pages/music/artist-view.c | 167 ++++++++++++++ src/pages/music/artist-view.h | 36 ++++ src/pages/music/music-local.c | 227 ++++++++++++++++++++ src/pages/music/music-local.h | 38 ++++ 28 files changed, 1103 insertions(+), 270 deletions(-) delete mode 100644 src/koto-headerbar.c create mode 100644 src/koto-track-item.c rename src/{koto-headerbar.h => koto-track-item.h} (62%) create mode 100644 src/pages/music/album-view.c create mode 100644 src/pages/music/album-view.h create mode 100644 src/pages/music/artist-view.c create mode 100644 src/pages/music/artist-view.h create mode 100644 src/pages/music/music-local.c create mode 100644 src/pages/music/music-local.h diff --git a/data/style.css b/data/style.css index 1e3d5d1..24b0cba 100644 --- a/data/style.css +++ b/data/style.css @@ -1,3 +1,11 @@ +window { + background-color: #2e2e2e; +} + +headerbar, .player-bar { + background-color: #1d1d1d; +} + .primary-nav > .frame > box >.koto-button > box { padding: 10px 0; } @@ -19,3 +27,11 @@ .expander-header label { font-size: large; } + +.page-music-local .artist-list { + background-color: #1d1d1d; +} + +.page-music-local row { + padding: 10px; +} diff --git a/meson.build b/meson.build index 0b6195d..ca1ee90 100644 --- a/meson.build +++ b/meson.build @@ -27,6 +27,6 @@ subdir('po') gnome.post_install( glib_compile_schemas: true, - gtk_update_icon_cache: true + gtk_update_icon_cache: false ) meson.add_install_script('build-aux/meson/postinstall.py') diff --git a/src/indexer/album.c b/src/indexer/album.c index 589c7eb..ec4104a 100644 --- a/src/indexer/album.c +++ b/src/indexer/album.c @@ -267,7 +267,7 @@ void koto_indexed_album_update_path(KotoIndexedAlbum *self, const gchar* new_pat g_free(album_art_no_ext); g_free(lower_art); - } else if (g_str_has_prefix(mime_type, "audio/")) { // Is an audio file + } else if (g_str_has_prefix(mime_type, "audio/") || g_str_has_prefix(mime_type, "video/ogg")) { // Is an audio file or ogg because it is special KotoIndexedFile *file = koto_indexed_file_new(full_path); if (file != NULL) { // Is a file diff --git a/src/indexer/file-indexer.c b/src/indexer/file-indexer.c index 7609485..e8ea155 100644 --- a/src/indexer/file-indexer.c +++ b/src/indexer/file-indexer.c @@ -72,9 +72,7 @@ void koto_indexed_library_add_artist(KotoIndexedLibrary *self, KotoIndexedArtist return; } - if (self->music_artists == NULL) { // Not a HashTable - self->music_artists = g_hash_table_new(g_str_hash, g_str_equal); - } + koto_indexed_library_get_artists(self); // Call to generate if needed gchar *artist_name; g_object_get(artist, "name", &artist_name, NULL); @@ -92,21 +90,25 @@ KotoIndexedArtist* koto_indexed_library_get_artist(KotoIndexedLibrary *self, gch return NULL; } - if (self->music_artists == NULL) { // Not a HashTable - return NULL; - } + koto_indexed_library_get_artists(self); // Call to generate if needed return g_hash_table_lookup(self->music_artists, (KotoIndexedArtist*) artist_name); } +GHashTable* koto_indexed_library_get_artists(KotoIndexedLibrary *self) { + if (self->music_artists == NULL) { // Not a HashTable + self->music_artists = g_hash_table_new(g_str_hash, g_str_equal); + } + + return self->music_artists; +} + void koto_indexed_library_remove_artist(KotoIndexedLibrary *self, KotoIndexedArtist *artist) { if (artist == NULL) { return; } - if (self->music_artists == NULL) { // Not a HashTable - return; - } + koto_indexed_library_get_artists(self); // Call to generate if needed gchar *artist_name; g_object_get(artist, "name", &artist_name, NULL); @@ -223,6 +225,8 @@ void index_folder(KotoIndexedLibrary *self, gchar *path, guint depth) { } void output_artists(gpointer artist_key, gpointer artist_ptr, gpointer data) { + (void)artist_key; + (void)data; KotoIndexedArtist *artist = (KotoIndexedArtist*) artist_ptr; gchar *artist_name; g_object_get(artist, "name", &artist_name, NULL); diff --git a/src/indexer/file-indexer.h b/src/indexer/file-indexer.h index 97b25cc..59af814 100644 --- a/src/indexer/file-indexer.h +++ b/src/indexer/file-indexer.h @@ -28,6 +28,7 @@ KotoIndexedLibrary* koto_indexed_library_new(const gchar *path); void koto_indexed_library_add_artist(KotoIndexedLibrary *self, KotoIndexedArtist *artist); KotoIndexedArtist* koto_indexed_library_get_artist(KotoIndexedLibrary *self, gchar* artist_name); +GHashTable* koto_indexed_library_get_artists(KotoIndexedLibrary *self); void koto_indexed_library_remove_artist(KotoIndexedLibrary *self, KotoIndexedArtist *artist); void start_indexing(KotoIndexedLibrary *self); void index_folder(KotoIndexedLibrary *self, gchar *path, guint depth); diff --git a/src/koto-button.c b/src/koto-button.c index 7067b9a..7af5dc7 100644 --- a/src/koto-button.c +++ b/src/koto-button.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include "koto-button.h" #include "koto-config.h" @@ -51,10 +51,10 @@ guint koto_get_pixbuf_size(KotoButtonPixbufSize s) { enum { PROP_BTN_0, + PROP_USE_FROM_FILE, PROP_PIX_SIZE, PROP_TEXT, PROP_BADGE_TEXT, - PROP_PIX, PROP_ICON_NAME, PROP_ALT_ICON_NAME, N_BTN_PROPERTIES @@ -63,11 +63,10 @@ enum { static GParamSpec *btn_props[N_BTN_PROPERTIES] = { NULL, }; struct _KotoButton { - GtkEventBox parent_instance; - GtkBox *content; + GtkBox parent_instance; guint pix_size; - GtkWidget *button_image; + GtkWidget *button_pic; GtkWidget *badge_label; GtkWidget *button_label; @@ -76,7 +75,7 @@ struct _KotoButton { gchar *alt_icon_name; gchar *text; - GdkPixbuf *pix; + gboolean use_from_file; gboolean currently_showing_alt; }; @@ -84,17 +83,27 @@ struct _KotoButtonClass { GtkBoxClass parent_class; }; -G_DEFINE_TYPE(KotoButton, koto_button, GTK_TYPE_EVENT_BOX); +G_DEFINE_TYPE(KotoButton, koto_button, GTK_TYPE_BOX); +static void koto_button_constructed(GObject *obj); static void koto_button_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *spec); static void koto_button_set_property(GObject *obj, guint prop_id, const GValue *val, GParamSpec *spec); static void koto_button_class_init(KotoButtonClass *c) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS(c); + gobject_class->constructed = koto_button_constructed; gobject_class->set_property = koto_button_set_property; gobject_class->get_property = koto_button_get_property; + btn_props[PROP_USE_FROM_FILE] = g_param_spec_boolean( + "use-from-file", + "Use from a file / file name", + "Use from a file / file name", + FALSE, + G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_READWRITE + ); + btn_props[PROP_PIX_SIZE] = g_param_spec_uint( "pixbuf-size", "Pixbuf Size", @@ -121,14 +130,6 @@ static void koto_button_class_init(KotoButtonClass *c) { G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_READWRITE ); - btn_props[PROP_PIX] = g_param_spec_object( - "pixbuf", - "Pixbuf", - "Pixbuf", - GDK_TYPE_PIXBUF, - G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_READWRITE - ); - btn_props[PROP_ICON_NAME] = g_param_spec_string( "icon-name", "Icon Name", @@ -149,17 +150,24 @@ static void koto_button_class_init(KotoButtonClass *c) { } static void koto_button_init(KotoButton *self) { + self->currently_showing_alt = FALSE; +} + +static void koto_button_constructed(GObject *obj) { + KotoButton *self = KOTO_BUTTON(obj); GtkStyleContext *style = gtk_widget_get_style_context(GTK_WIDGET(self)); gtk_style_context_add_class(style, "koto-button"); - self->currently_showing_alt = FALSE; - self->content = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); - gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->content)); + + G_OBJECT_CLASS (koto_button_parent_class)->constructed (obj); } static void koto_button_get_property(GObject *obj, guint prop_id, GValue *val, GParamSpec *spec) { KotoButton *self = KOTO_BUTTON(obj); switch (prop_id) { + case PROP_USE_FROM_FILE: + g_value_set_boolean(val, self->use_from_file); + break; case PROP_PIX_SIZE: g_value_set_uint(val, self->pix_size); break; @@ -175,9 +183,6 @@ static void koto_button_get_property(GObject *obj, guint prop_id, GValue *val, G case PROP_ALT_ICON_NAME: g_value_set_string(val, self->alt_icon_name); break; - case PROP_PIX: - g_value_set_object(val, self->pix); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, spec); break; @@ -188,18 +193,23 @@ static void koto_button_set_property(GObject *obj, guint prop_id, const GValue * KotoButton *self = KOTO_BUTTON(obj); switch (prop_id) { + case PROP_USE_FROM_FILE: + self->use_from_file = g_value_get_boolean(val); + break; case PROP_PIX_SIZE: koto_button_set_pixbuf_size(self, g_value_get_uint(val)); break; case PROP_TEXT: - koto_button_set_text(self, g_strdup(g_value_get_string(val))); + if (val == NULL) { + koto_button_set_text(self, NULL); + } else { + koto_button_set_text(self, g_strdup(g_value_get_string(val))); + } + break; case PROP_BADGE_TEXT: koto_button_set_badge_text(self, g_strdup(g_value_get_string(val))); break; - case PROP_PIX: - koto_button_set_pixbuf(self, (GdkPixbuf*) g_value_get_object(val)); - break; case PROP_ICON_NAME: koto_button_set_icon_name(self, g_strdup(g_value_get_string(val)), FALSE); if (!self->currently_showing_alt) { // Not showing alt @@ -234,7 +244,7 @@ void koto_button_set_badge_text(KotoButton *self, gchar *text) { gtk_label_set_text(GTK_LABEL(self->badge_label), self->badge_text); } else { self->badge_label = gtk_label_new(self->badge_text); // Create our label - gtk_box_pack_end(self->content, self->badge_label, FALSE, FALSE, 0); // Add to the end of the box + gtk_box_append(GTK_BOX(self), self->badge_label); } if (strcmp(self->badge_text, "") != 0) { // Empty badge @@ -271,8 +281,8 @@ void koto_button_set_icon_name(KotoButton *self, gchar *icon_name, gboolean for_ } if (hide_image) { // Should hide the image - if (GTK_IS_IMAGE(self->button_image)) { // If we already have a button image - gtk_widget_hide(self->button_image); // Hide + if (GTK_IS_PICTURE(self->button_pic)) { // If we already have a button image + gtk_widget_hide(self->button_pic); // Hide } return; @@ -281,48 +291,20 @@ void koto_button_set_icon_name(KotoButton *self, gchar *icon_name, gboolean for_ g_object_notify_by_pspec(G_OBJECT(self), for_alt ? btn_props[PROP_ALT_ICON_NAME] : btn_props[PROP_ICON_NAME]); } -void koto_button_set_pixbuf(KotoButton *self, GdkPixbuf *pix) { - g_return_if_fail(self->pix_size != 0); // Return if don't have a pixbuf size to indicate what to scale to - - if (!GDK_IS_PIXBUF(pix)) { - return; - } - - self->pix = pix; - - GdkPixbuf *use_pix = pix; // Default to using our provided pixbuf - if (gdk_pixbuf_get_height(pix) > (int) self->pix_size) { // If our height is greater than our desired pixel size - use_pix = gdk_pixbuf_scale_simple(pix, -1, self->pix_size, GDK_INTERP_BILINEAR); // Scale using bilnear - g_return_if_fail(use_pix != NULL); // Return if we could not allocate memory for the scaling - } - - if (GTK_IS_IMAGE(self->button_image)) { // If we already have a button image - gtk_image_set_from_pixbuf(GTK_IMAGE(self->button_image), use_pix); // Update our pixbuf - gtk_widget_show(self->button_image); // Ensure we show the image - } else { // No image set - GtkWidget *new_image = gtk_image_new_from_pixbuf(use_pix); // Create our new image - g_return_if_fail(GTK_IS_IMAGE(new_image)); // Return if we failed to create our image - self->button_image = new_image; - gtk_box_pack_start(self->content, self->button_image, FALSE, FALSE, 0); // Prepend the image - gtk_box_reorder_child(self->content, self->button_image, 0); - } - - g_object_notify_by_pspec(G_OBJECT(self), btn_props[PROP_PIX]); -} - void koto_button_set_pixbuf_size(KotoButton *self, guint size) { g_return_if_fail(size != self->pix_size); // If the sizes aren't different, return self->pix_size = size; - - if (GDK_PIXBUF(self->pix)) { // If we already have a pixbuf set and we're changing the size - koto_button_set_pixbuf(self, self->pix); - } + gtk_widget_set_size_request(GTK_WIDGET(self), self->pix_size, self->pix_size); g_object_notify_by_pspec(G_OBJECT(self), btn_props[PROP_PIX_SIZE]); } void koto_button_set_text(KotoButton *self, gchar *text) { + if (text == NULL) { + return; + } + gchar *copied_text = g_strdup(text); // Copy our text if (strcmp(copied_text, "") == 0) { // Clearing our text @@ -336,17 +318,18 @@ void koto_button_set_text(KotoButton *self, gchar *text) { gtk_label_set_text(GTK_LABEL(self->button_label), self->text); gtk_widget_show(self->button_label); // Show the label } else { // Have a label but no longer text - gtk_container_remove(GTK_CONTAINER(self), self->button_label); // Remove the label + gtk_box_remove(GTK_BOX(self), self->button_label); g_free(self->button_label); } } else { // If we do not have a button label if (strcmp(self->text, "") != 0) { // If we have text self->button_label = gtk_label_new(self->text); // Create our label gtk_label_set_xalign(GTK_LABEL(self->button_label), 0); - gtk_box_pack_start(self->content, self->button_label, FALSE, FALSE, 0); // Add to the beginning of the box - if (GTK_IS_IMAGE(self->button_image)) { // If we have an image - gtk_box_reorder_child(self->content, self->button_image, 0); // Move to the beginning + if (GTK_IS_IMAGE(self->button_pic)) { // If we have an image + gtk_box_insert_child_after(GTK_BOX(self), self->button_label, self->button_pic); + } else { + gtk_box_prepend(GTK_BOX(self), GTK_WIDGET(self->button_label)); } } } @@ -361,11 +344,22 @@ void koto_button_show_image(KotoButton *self, gboolean use_alt) { return; } - GtkIconTheme *theme = gtk_icon_theme_get_default(); // Get the default icon theme - GdkPixbuf* icon_pix = gtk_icon_theme_load_icon_for_scale(theme, use_alt ? self->alt_icon_name : self->icon_name, (gint) self->pix_size, 1, GTK_ICON_LOOKUP_USE_BUILTIN & GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); - g_return_if_fail(GDK_IS_PIXBUF(icon_pix)); // Return if not a pixbuf - koto_button_set_pixbuf(self, icon_pix); - self->currently_showing_alt = use_alt; + if (self->use_from_file) { // Use from a file instead of icon name + // TODO: Add + } else { // From icon name + self->currently_showing_alt = use_alt; + gchar *name = use_alt ? self->alt_icon_name : self->icon_name; + + if (GTK_IS_IMAGE(self->button_pic)) { + gtk_image_set_from_icon_name(GTK_IMAGE(self->button_pic), name); // Just update the existing iamge + } else { // Not an image + self->button_pic = gtk_image_new_from_icon_name(name); // Get our new image + gtk_image_set_pixel_size(GTK_IMAGE(self->button_pic), self->pix_size); + gtk_box_prepend(GTK_BOX(self), self->button_pic); // Prepend to the box + } + + gtk_image_set_icon_size(GTK_IMAGE(self->button_pic), GTK_ICON_SIZE_INHERIT); // Inherit height of parent widget + } } KotoButton* koto_button_new_plain(gchar *label) { @@ -384,12 +378,3 @@ KotoButton* koto_button_new_with_icon(gchar *label, gchar *icon_name, gchar *alt NULL ); } - -KotoButton* koto_button_new_with_pixbuf(gchar *label, GdkPixbuf *pix, KotoButtonPixbufSize size) { - return g_object_new(KOTO_TYPE_BUTTON, - "button-text", label, - "pixbuf", pix, - "pixbuf-size", koto_get_pixbuf_size(size), - NULL - ); -} diff --git a/src/koto-button.h b/src/koto-button.h index c267247..d839709 100644 --- a/src/koto-button.h +++ b/src/koto-button.h @@ -17,9 +17,9 @@ #pragma once -#include +#include #include -#include +#include G_BEGIN_DECLS @@ -37,7 +37,7 @@ typedef enum { #define KOTO_TYPE_BUTTON (koto_button_get_type()) -G_DECLARE_FINAL_TYPE (KotoButton, koto_button, KOTO, BUTTON, GtkEventBox) +G_DECLARE_FINAL_TYPE (KotoButton, koto_button, KOTO, BUTTON, GtkBox) guint koto_get_pixbuf_size(KotoButtonPixbufSize size); diff --git a/src/koto-expander.c b/src/koto-expander.c index 639da81..1201137 100644 --- a/src/koto-expander.c +++ b/src/koto-expander.c @@ -16,7 +16,7 @@ */ #include -#include +#include #include "koto-config.h" #include "koto-button.h" #include "koto-expander.h" @@ -128,7 +128,8 @@ static void koto_expander_set_property(GObject *obj, guint prop_id, const GValue if (GTK_IS_WIDGET(new_button)) { // Created our widget successfully self->header_button = new_button; - gtk_box_pack_start(GTK_BOX(self->header), GTK_WIDGET(self->header_button), TRUE, TRUE, 0); // Add it + gtk_widget_set_hexpand(GTK_WIDGET(self->header_button), TRUE); + gtk_box_prepend(GTK_BOX(self->header), GTK_WIDGET(self->header_button)); } } @@ -154,11 +155,9 @@ static void koto_expander_set_property(GObject *obj, guint prop_id, const GValue } static void koto_expander_init(KotoExpander *self) { - GtkSettings *settings = gtk_settings_get_default(); - g_object_set(settings, "gtk_application_prefer_dark_theme", TRUE, NULL); - GtkStyleContext *style = gtk_widget_get_style_context(GTK_WIDGET(self)); gtk_style_context_add_class(style, "expander"); + gtk_widget_set_hexpand((GTK_WIDGET(self)), TRUE); self->header = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); @@ -170,14 +169,16 @@ static void koto_expander_init(KotoExpander *self) { gtk_revealer_set_transition_type(GTK_REVEALER(self->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN); self->header_expand_button = koto_button_new_with_icon("", "pan-down-symbolic", "pan-up-symbolic", KOTO_BUTTON_PIXBUF_SIZE_SMALL); - gtk_box_pack_end(GTK_BOX(self->header), GTK_WIDGET(self->header_expand_button), FALSE, FALSE, 0); + gtk_box_append(GTK_BOX(self->header), GTK_WIDGET(self->header_expand_button)); - gtk_box_pack_start(GTK_BOX(self), self->header, FALSE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(self), self->revealer, TRUE, TRUE, 0); + gtk_box_prepend(GTK_BOX(self), self->header); + gtk_box_append(GTK_BOX(self), self->revealer); self->constructed = TRUE; - g_signal_connect(self->header_expand_button, "button-release-event", G_CALLBACK(koto_expander_toggle_content), self); + GtkGesture *controller = gtk_gesture_click_new(); // Create a new GtkGestureClick + g_signal_connect(controller, "pressed", G_CALLBACK(koto_expander_toggle_content), self); + gtk_widget_add_controller(GTK_WIDGET(self->header_expand_button), GTK_EVENT_CONTROLLER(controller)); } void koto_expander_set_secondary_button(KotoExpander *self, KotoButton *new_button) { @@ -190,11 +191,11 @@ void koto_expander_set_secondary_button(KotoExpander *self, KotoButton *new_butt } if (GTK_IS_WIDGET(self->header_secondary_button)) { // Already have a button - gtk_container_remove(GTK_CONTAINER(self->header), GTK_WIDGET(self->header_secondary_button)); + gtk_box_remove(GTK_BOX(self->header), GTK_WIDGET(self->header_secondary_button)); } self->header_secondary_button = new_button; - gtk_box_pack_end(GTK_BOX(self->header), GTK_WIDGET(self->header_secondary_button), FALSE, FALSE, 0); + gtk_box_append(GTK_BOX(self->header), GTK_WIDGET(self->header_secondary_button)); g_object_notify_by_pspec(G_OBJECT(self), expander_props[PROP_HEADER_SECONDARY_BUTTON]); } @@ -204,20 +205,22 @@ void koto_expander_set_content(KotoExpander *self, GtkWidget *new_content) { return; } - if (self->content != NULL) { // Already have content - gtk_container_remove(GTK_CONTAINER(self->revealer), self->content); - g_free(self->content); + if (GTK_IS_WIDGET(self->content)) { // Already have content + gtk_revealer_set_child(GTK_REVEALER(self->revealer), NULL); + g_object_unref(self->content); } self->content = new_content; - gtk_container_add(GTK_CONTAINER(self->revealer), self->content); + gtk_revealer_set_child(GTK_REVEALER(self->revealer), self->content); g_object_notify_by_pspec(G_OBJECT(self), expander_props[PROP_CONTENT]); } -void koto_expander_toggle_content(GtkWidget *button, GdkEvent *event, gpointer data) { +void koto_expander_toggle_content(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data) { + (void) gesture; (void) n_press; (void) x; (void) y; KotoExpander* self = data; - koto_button_flip(KOTO_BUTTON(button)); + + koto_button_flip(KOTO_BUTTON(self->header_expand_button)); GtkRevealer* rev = GTK_REVEALER(self->revealer); gtk_revealer_set_reveal_child(rev, !gtk_revealer_get_reveal_child(rev)); // Invert our values } diff --git a/src/koto-expander.h b/src/koto-expander.h index 6d82a94..680c9f1 100644 --- a/src/koto-expander.h +++ b/src/koto-expander.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include "koto-button.h" G_BEGIN_DECLS @@ -32,6 +32,6 @@ void koto_expander_set_icon_name(KotoExpander *self, const gchar *in); void koto_expander_set_label(KotoExpander *self, const gchar *label); void koto_expander_set_secondary_button(KotoExpander *self, KotoButton *new_button); void koto_expander_set_content(KotoExpander *self, GtkWidget *new_content); -void koto_expander_toggle_content(GtkWidget *button, GdkEvent *event, gpointer data); +void koto_expander_toggle_content(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data); G_END_DECLS diff --git a/src/koto-headerbar.c b/src/koto-headerbar.c deleted file mode 100644 index 64dab78..0000000 --- a/src/koto-headerbar.c +++ /dev/null @@ -1,45 +0,0 @@ -/* koto-headerbar.c - * - * Copyright 2021 Joshua Strobl - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "koto-config.h" -#include "koto-headerbar.h" - -struct _KotoHeaderBar { - GtkHeaderBar parent_instance; - GtkButton *menu_button; - GtkWidget *search; -}; - -struct _KotoHeaderBarClass { - GtkHeaderBarClass parent_class; -}; - -G_DEFINE_TYPE(KotoHeaderBar, koto_headerbar, GTK_TYPE_HEADER_BAR) - -static void koto_headerbar_class_init(KotoHeaderBarClass *c) { - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(c); - gtk_widget_class_set_template_from_resource(widget_class, "/com/github/joshstrobl/koto/koto-headerbar.ui"); -} - -static void koto_headerbar_init(KotoHeaderBar *self) { - gtk_widget_init_template(GTK_WIDGET(self)); - gtk_widget_show_all(GTK_WIDGET(self)); -} - -KotoHeaderBar* koto_headerbar_new(void) { - return g_object_new(KOTO_TYPE_HEADERBAR, NULL); -} diff --git a/src/koto-headerbar.ui b/src/koto-headerbar.ui index 03384fe..43244f9 100644 --- a/src/koto-headerbar.ui +++ b/src/koto-headerbar.ui @@ -7,7 +7,7 @@ audio-headphones 3 -