Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions src/bz-app-size-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,7 @@ static void
open_user_data_folder_cb (GtkWidget *widget,
BzAppSizeDialog *self)
{
const char *id = NULL;
g_autofree char *path = NULL;
g_autoptr (GFile) file = NULL;
g_autoptr (GtkFileLauncher) launcher = NULL;
GtkRoot *root = NULL;

if (self->group == NULL)
return;

id = bz_entry_group_get_id (self->group);
if (id == NULL)
return;

path = bz_dup_user_data_path (id);
file = g_file_new_for_path (path);
launcher = gtk_file_launcher_new (file);
root = gtk_widget_get_root (widget);

gtk_file_launcher_launch (launcher, GTK_WINDOW (root), NULL, NULL, NULL);
gtk_widget_activate_action (GTK_WIDGET (gtk_widget_get_root (widget)), "window.open-user-data-folder", "s", bz_entry_group_get_id (self->group));
}

static void
Expand Down
121 changes: 60 additions & 61 deletions src/bz-user-data-page.blp
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,69 @@ template $BzUserDataPage: Adw.NavigationPage {
[top]
Adw.HeaderBar {}

content: Adw.BreakpointBin {
width-request: 360;
height-request: 450;
child: Adw.ViewStack stack {
enable-transitions: true;
transition-duration: 400;
Adw.ViewStackPage {
name: "loading";
title: _("Loading");
child:Adw.Spinner {
halign: fill;
valign: center;
width-request: 64;
height-request: 64;
margin-bottom: 18;
};
}
Adw.ViewStackPage {
name: "empty";
title: _("Empty");
child: Adw.StatusPage {
icon-name: "folder-documents-symbolic";
title: _("No User Data Found");
};
}
Adw.ViewStackPage {
name: "content";
title: _("User Data");
child: ScrolledWindow {
hscrollbar-policy: never;
child: Adw.ClampScrollable {
maximum-size: 650;
child: ListView list_view {
styles [
"navigation-sidebar",
"user-data-list-view"
]
margin-start: 25;
margin-end: 25;
overflow: visible;
model: NoSelection {
model: bind template.model;
};
factory: BuilderListItemFactory {
template ListItem {
activatable: false;
selectable: false;
focusable: false;
child: $BzUserDataTile {
group: bind template.item as <$BzEntryGroup>;
};
}
};
content: Adw.ViewStack stack {
enable-transitions: true;
transition-duration: 400;

Adw.ViewStackPage {
name: "loading";
title: _("Loading");

child: Adw.Spinner {
halign: fill;
valign: center;
width-request: 64;
height-request: 64;
margin-bottom: 18;
};
}

Adw.ViewStackPage {
name: "empty";
title: _("Empty");

child: Adw.StatusPage {
icon-name: "folder-documents-symbolic";
title: _("No User Data Found");
};
}

Adw.ViewStackPage {
name: "content";
title: _("User Data");

child: ScrolledWindow {
hscrollbar-policy: never;

child: Adw.ClampScrollable {
maximum-size: 650;

child: ListView list_view {
styles [
"navigation-sidebar",
"user-data-list-view",
]

overflow: visible;

model: NoSelection {
model: bind template.model;
};

factory: BuilderListItemFactory {
template ListItem {
activatable: false;
selectable: false;
focusable: false;

child: $BzUserDataTile {
group: bind template.item as <$BzEntryGroup>;
};
}
};
};
};
}
};
Adw.Breakpoint {
condition ("max-width: 700px")
setters {
list_view.margin-start: 0;
list_view.margin-end: 0;
}
};
}
};
}
Expand Down
31 changes: 23 additions & 8 deletions src/bz-user-data-page.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#include "config.h"

#include <glib/gi18n.h>

#include "bz-application-map-factory.h"
Expand Down Expand Up @@ -226,16 +228,18 @@ fetch_user_data_fiber (GWeakRef *wr)
GHashTableIter iter = { 0 };
g_autoptr (GtkStringList) id_list = NULL;
BzApplicationMapFactory *factory = NULL;
g_autoptr (GListModel) model = NULL;
g_autoptr (GListStore) sorted_store = NULL;
GListModel *installed_groups = NULL;
g_autoptr (GHashTable) installed_ids = NULL;
guint n_items;
const char *own_id = NULL;
guint n_items = 0;

self = g_weak_ref_get (wr);
if (self == NULL)
return dex_future_new_reject (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Page destroyed");

own_id = g_application_get_application_id (g_application_get_default ());

installed_groups = bz_state_info_get_all_installed_entry_groups (self->state);
installed_ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

Expand Down Expand Up @@ -274,20 +278,31 @@ fetch_user_data_fiber (GWeakRef *wr)
if (!g_hash_table_iter_next (&iter, (gpointer *) &app_id, NULL))
break;

if (!g_hash_table_contains (installed_ids, app_id))
if (!g_hash_table_contains (installed_ids, app_id) &&
g_strcmp0 (app_id, own_id) != 0)
gtk_string_list_append (id_list, app_id);
}

factory = bz_state_info_get_application_factory (self->state);
model = bz_application_map_factory_generate (factory, G_LIST_MODEL (id_list));

factory = bz_state_info_get_application_factory (self->state);
sorted_store = g_list_store_new (BZ_TYPE_ENTRY_GROUP);
n_items = g_list_model_get_n_items (model);
n_items = g_list_model_get_n_items (G_LIST_MODEL (id_list));

for (guint i = 0; i < n_items; i++)
{
g_autoptr (BzEntryGroup) group = g_list_model_get_item (model, i);
GtkStringObject *str_obj = NULL;
g_autofree char *id_copy = NULL;
g_autoptr (BzEntryGroup) group = NULL;

str_obj = g_list_model_get_item (G_LIST_MODEL (id_list), i);
id_copy = g_strdup (gtk_string_object_get_string (str_obj));

group = bz_application_map_factory_convert_one (factory, str_obj);
if (group == NULL)
group = bz_entry_group_new_manual (id_copy, id_copy, NULL);

g_list_store_append (sorted_store, group);
}

g_list_store_sort (sorted_store, (GCompareDataFunc) compare_entry_groups_by_title, NULL);

if (self->model != NULL)
Expand Down
64 changes: 47 additions & 17 deletions src/bz-user-data-tile.blp
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,40 @@ template $BzUserDataTile: Adw.Bin {
child: Revealer {
transition-type: slide_down;
reveal-child: bind $invert_boolean($is_zero(template.group as <$BzEntryGroup>.user-data-size) as <bool>) as <bool>;

child: Adw.Bin {
accessibility {
labelled-by: title_label;
described-by: description_label;
}

margin-bottom: 4;
margin-start: 4;
margin-end: 4;
margin-top: 4;

styles [
"card",
]

child: Box {
orientation: horizontal;
spacing: 10;

Picture icon_picture {
margin-start: 10;
margin-top: 10;
margin-bottom: 10;
height-request: 48;
width-request: 48;
paintable: bind template.group as <$BzEntryGroup>.ui-entry as <$BzResult>.object as <$BzEntry>.icon-paintable;
visible: bind $invert_boolean($is_null(template.group as <$BzEntryGroup>.ui-entry as <$BzResult>.object as <$BzEntry>.icon-paintable) as <bool>) as <bool>;
styles ["icon-dropshadow"]
visible: bind try {$invert_boolean($is_null(template.group as <$BzEntryGroup>.ui-entry as <$BzResult>.object as <$BzEntry>.icon-paintable) as <bool>) as <bool>, false};

styles [
"icon-dropshadow",
]
}

Image fallback_icon {
margin-start: 10;
margin-top: 10;
Expand All @@ -38,13 +47,18 @@ template $BzUserDataTile: Adw.Bin {
width-request: 48;
pixel-size: 48;
icon-name: "application-x-executable";
visible: bind $is_null(template.group as <$BzEntryGroup>.ui-entry as <$BzResult>.object as <$BzEntry>.icon-paintable) as <bool>;
styles ["icon-dropshadow"]
visible: bind icon_picture.visible inverted;

styles [
"icon-dropshadow",
]
}

Box {
orientation: vertical;
valign: center;
spacing: 4;

Label title_label {
xalign: 0.0;
ellipsize: end;
Expand All @@ -53,27 +67,43 @@ template $BzUserDataTile: Adw.Bin {
tooltip-text: bind template.group as <$BzEntryGroup>.id;
label: bind template.group as <$BzEntryGroup>.title;
}

Label description_label {
halign: start;
label: bind $format_size(template.group as <$BzEntryGroup>.user-data-size as <uint64>) as <string>;
styles ["accent", "caption-heading"]

styles [
"caption-heading",
]
}
}
Button remove_button {
styles [
"flat",
"destructive-action",
]

Box {
hexpand: true;
halign: end;
width-request: 32;
height-request: 32;
valign: center;
halign: end;
spacing: 8;
margin-end: 16;
has-tooltip: true;
tooltip-text: _("Trash User Data");
icon-name: "user-trash-symbolic";
clicked => $remove_cb() swapped;

Button {
styles [
"flat",
]
tooltip-text: _("Open User Data Folder");
icon-name: "folder-open-symbolic";
clicked => $folder_cb() swapped;
}

Button {
styles [
"flat",
"destructive-action",
]

tooltip-text: _("Trash User Data");
icon-name: "user-trash-symbolic";
clicked => $remove_cb() swapped;
}
}
};
};
Expand Down
19 changes: 10 additions & 9 deletions src/bz-user-data-tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#include "config.h"

#include <glib/gi18n.h>

#include "bz-entry-group.h"
Expand All @@ -34,11 +36,6 @@ struct _BzUserDataTile
BzListTile parent_instance;

BzEntryGroup *group;

GtkPicture *icon_picture;
GtkImage *fallback_icon;
GtkLabel *title_label;
GtkButton *remove_button;
};

G_DEFINE_FINAL_TYPE (BzUserDataTile, bz_user_data_tile, ADW_TYPE_BIN)
Expand Down Expand Up @@ -157,6 +154,13 @@ reap_user_data_done (DexFuture *future,
return dex_future_new_true ();
}

static void
folder_cb (BzUserDataTile *self,
GtkButton *button)
{
gtk_widget_activate_action (GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (self))), "window.open-user-data-folder", "s", bz_entry_group_get_id (self->group));
}

static void
remove_cb (BzUserDataTile *self,
GtkButton *button)
Expand Down Expand Up @@ -198,14 +202,11 @@ bz_user_data_tile_class_init (BzUserDataTileClass *klass)
g_type_ensure (BZ_TYPE_ENTRY_GROUP);

gtk_widget_class_set_template_from_resource (widget_class, "/io/github/kolunmi/Bazaar/bz-user-data-tile.ui");
gtk_widget_class_bind_template_child (widget_class, BzUserDataTile, icon_picture);
gtk_widget_class_bind_template_child (widget_class, BzUserDataTile, fallback_icon);
gtk_widget_class_bind_template_child (widget_class, BzUserDataTile, title_label);
gtk_widget_class_bind_template_child (widget_class, BzUserDataTile, remove_button);
gtk_widget_class_bind_template_callback (widget_class, invert_boolean);
gtk_widget_class_bind_template_callback (widget_class, is_null);
gtk_widget_class_bind_template_callback (widget_class, is_zero);
gtk_widget_class_bind_template_callback (widget_class, format_size);
gtk_widget_class_bind_template_callback (widget_class, folder_cb);
gtk_widget_class_bind_template_callback (widget_class, remove_cb);

gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
Expand Down
Loading
Loading