Browse Source

add file search entry

Implements https://todo.sr.ht/~alextee/zrythm-feature/414.
audio_region_bpm_change_fix
Alexandros Theodotou 11 months ago
parent
commit
da2e581a03
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 20
      inc/audio/supported_file.h
  2. 26
      inc/gui/widgets/panel_file_browser.h
  3. 4
      inc/gui/widgets/plugin_browser.h
  4. 6
      resources/ui/panel_file_browser.ui
  5. 3
      resources/ui/plugin_browser.ui
  6. 90
      src/gui/widgets/panel_file_browser.c
  7. 23
      src/gui/widgets/plugin_browser.c

20
inc/audio/supported_file.h

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2019-2021 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/**
* \file

26
inc/gui/widgets/panel_file_browser.h

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
#ifndef __GUI_WIDGETS_PANEL_FILE_BROWSER_H__
#define __GUI_WIDGETS_PANEL_FILE_BROWSER_H__
@ -45,14 +29,14 @@ G_DECLARE_FINAL_TYPE ( @@ -45,14 +29,14 @@ G_DECLARE_FINAL_TYPE (
panel_file_browser_widget,
Z,
PANEL_FILE_BROWSER_WIDGET,
GtkBox)
GtkWidget)
#define MW_PANEL_FILE_BROWSER \
MW_RIGHT_DOCK_EDGE->file_browser
typedef struct _PanelFileBrowserWidget
{
GtkBox parent_instance;
GtkWidget parent_instance;
GtkPaned * paned;
@ -65,6 +49,8 @@ typedef struct _PanelFileBrowserWidget @@ -65,6 +49,8 @@ typedef struct _PanelFileBrowserWidget
GtkLabel * file_info;
ZFileType selected_type;
GtkSearchEntry * file_search_entry;
GtkCustomFilter * files_filter;
GtkFilterListModel * files_filter_model;
GtkSingleSelection * files_selection_model;

4
inc/gui/widgets/plugin_browser.h

@ -22,7 +22,7 @@ G_DECLARE_FINAL_TYPE ( @@ -22,7 +22,7 @@ G_DECLARE_FINAL_TYPE (
plugin_browser_widget,
Z,
PLUGIN_BROWSER_WIDGET,
GtkBox)
GtkWidget)
TYPEDEF_STRUCT_UNDERSCORED (ExpanderBoxWidget);
TYPEDEF_STRUCT (PluginCollection);
@ -64,7 +64,7 @@ typedef enum @@ -64,7 +64,7 @@ typedef enum
*/
typedef struct _PluginBrowserWidget
{
GtkBox parent_instance;
GtkWidget parent_instance;
GtkPaned * paned;

6
resources/ui/panel_file_browser.ui

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="PanelFileBrowserWidget" parent="GtkBox">
<template class="PanelFileBrowserWidget" parent="GtkWidget">
<property name="vexpand">true</property>
<child>
<object class="GtkPaned" id="paned">
<property name="shrink-end-child">0</property>
@ -53,6 +54,9 @@ @@ -53,6 +54,9 @@
<object class="FileBrowserFiltersWidget" id="filters_toolbar">
</object>
</child>
<child>
<object class="GtkSearchEntry" id="file_search_entry"/>
</child>
<child>
<object class="GtkScrolledWindow" id="files_scroll">
<property name="focusable">1</property>

3
resources/ui/plugin_browser.ui

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="PluginBrowserWidget" parent="GtkBox">
<template class="PluginBrowserWidget" parent="GtkWidget">
<property name="vexpand">true</property>
<child>
<object class="GtkPaned" id="paned">
<property name="shrink-end-child">0</property>

90
src/gui/widgets/panel_file_browser.c

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/**
* \file
@ -48,6 +32,7 @@ @@ -48,6 +32,7 @@
#include "utils/io.h"
#include "utils/objects.h"
#include "utils/resources.h"
#include "utils/string.h"
#include "zrythm.h"
#include "zrythm_app.h"
@ -57,7 +42,7 @@ @@ -57,7 +42,7 @@
G_DEFINE_TYPE (
PanelFileBrowserWidget,
panel_file_browser_widget,
GTK_TYPE_BOX)
GTK_TYPE_WIDGET)
enum
{
@ -214,6 +199,17 @@ files_filter_func (GObject * item, gpointer user_data) @@ -214,6 +199,17 @@ files_filter_func (GObject * item, gpointer user_data)
bool all_toggles_off =
!show_audio && !show_midi && !show_presets;
/* filter by name */
const char * text = gtk_editable_get_text (
GTK_EDITABLE (self->file_search_entry));
if (
text && strlen (text) > 0
&& !string_contains_substr_case_insensitive (
descr->label, text))
{
return false;
}
bool visible = false;
switch (descr->type)
{
@ -345,6 +341,16 @@ on_bookmark_row_activated ( @@ -345,6 +341,16 @@ on_bookmark_row_activated (
self->files_selection_model));
}
static void
on_file_search_changed (
GtkSearchEntry * search_entry,
PanelFileBrowserWidget * self)
{
gtk_filter_changed (
GTK_FILTER (self->files_filter),
GTK_FILTER_CHANGE_DIFFERENT);
}
static void
on_file_row_activated (
GtkListView * list_view,
@ -647,6 +653,18 @@ panel_file_browser_widget_new () @@ -647,6 +653,18 @@ panel_file_browser_widget_new ()
self->files_list_view, "activate",
G_CALLBACK (on_file_row_activated), self);
/* setup file search entry */
gtk_search_entry_set_key_capture_widget (
self->file_search_entry,
GTK_WIDGET (self->files_list_view));
g_object_set (
G_OBJECT (self->file_search_entry),
"placeholder-text", _ ("Search..."), NULL);
g_signal_connect (
G_OBJECT (self->file_search_entry),
"search-changed",
G_CALLBACK (on_file_search_changed), self);
g_signal_connect (
G_OBJECT (self), "map", G_CALLBACK (on_map),
self);
@ -668,6 +686,25 @@ panel_file_browser_widget_new () @@ -668,6 +686,25 @@ panel_file_browser_widget_new ()
return self;
}
static void
dispose (PanelFileBrowserWidget * self)
{
gtk_widget_unparent (
GTK_WIDGET (self->popover_menu));
G_OBJECT_CLASS (
panel_file_browser_widget_parent_class)
->dispose (G_OBJECT (self));
}
static void
finalize (PanelFileBrowserWidget * self)
{
G_OBJECT_CLASS (
panel_file_browser_widget_parent_class)
->finalize (G_OBJECT (self));
}
static void
panel_file_browser_widget_class_init (
@ -686,12 +723,21 @@ panel_file_browser_widget_class_init ( @@ -686,12 +723,21 @@ panel_file_browser_widget_class_init (
BIND_CHILD (browser_top);
BIND_CHILD (browser_bot);
BIND_CHILD (file_info);
BIND_CHILD (file_search_entry);
BIND_CHILD (files_list_view);
BIND_CHILD (filters_toolbar);
BIND_CHILD (bookmarks_tree_view);
BIND_CHILD (auditioner_controls);
#undef BIND_CHILD
gtk_widget_class_set_layout_manager_type (
klass, GTK_TYPE_BIN_LAYOUT);
GObjectClass * goklass = G_OBJECT_CLASS (_klass);
goklass->dispose = (GObjectFinalizeFunc) dispose;
goklass->finalize =
(GObjectFinalizeFunc) finalize;
}
static void
@ -706,9 +752,9 @@ panel_file_browser_widget_init ( @@ -706,9 +752,9 @@ panel_file_browser_widget_init (
self->popover_menu = GTK_POPOVER_MENU (
gtk_popover_menu_new_from_model (NULL));
gtk_box_append (
GTK_BOX (self),
GTK_WIDGET (self->popover_menu));
gtk_widget_set_parent (
GTK_WIDGET (self->popover_menu),
GTK_WIDGET (self));
gtk_widget_set_hexpand (
GTK_WIDGET (self->paned), true);

23
src/gui/widgets/plugin_browser.c

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
G_DEFINE_TYPE (
PluginBrowserWidget,
plugin_browser_widget,
GTK_TYPE_BOX)
GTK_TYPE_WIDGET)
enum
{
@ -1386,6 +1386,17 @@ on_plugin_search_changed ( @@ -1386,6 +1386,17 @@ on_plugin_search_changed (
GTK_FILTER_CHANGE_DIFFERENT);
}
static void
dispose (PluginBrowserWidget * self)
{
gtk_widget_unparent (
GTK_WIDGET (self->popover_menu));
G_OBJECT_CLASS (
plugin_browser_widget_parent_class)
->dispose (G_OBJECT (self));
}
static void
finalize (PluginBrowserWidget * self)
{
@ -1623,7 +1634,11 @@ plugin_browser_widget_class_init ( @@ -1623,7 +1634,11 @@ plugin_browser_widget_class_init (
#undef BIND_SIGNAL
gtk_widget_class_set_layout_manager_type (
klass, GTK_TYPE_BIN_LAYOUT);
GObjectClass * goklass = G_OBJECT_CLASS (_klass);
goklass->dispose = (GObjectFinalizeFunc) dispose;
goklass->finalize =
(GObjectFinalizeFunc) finalize;
}
@ -1636,9 +1651,9 @@ plugin_browser_widget_init ( @@ -1636,9 +1651,9 @@ plugin_browser_widget_init (
self->popover_menu = GTK_POPOVER_MENU (
gtk_popover_menu_new_from_model (NULL));
gtk_box_append (
GTK_BOX (self),
GTK_WIDGET (self->popover_menu));
gtk_widget_set_parent (
GTK_WIDGET (self->popover_menu),
GTK_WIDGET (self));
self->stack_switcher =
ADW_VIEW_SWITCHER (adw_view_switcher_new ());

Loading…
Cancel
Save