-
-
Notifications
You must be signed in to change notification settings - Fork 121
Rework Add-ons dialog #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rework Add-ons dialog #1342
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
efdc814
Rework Add-ons dialog
AlexanderVanhee b32540a
Fix outlines and tweak anim speed
AlexanderVanhee 05b5d4a
fix title missing warnings
AlexanderVanhee 40adc49
Fix pop issues
AlexanderVanhee 6465654
Fixes
AlexanderVanhee 404a38d
Fix empty dialog when opening quickly after app start
AlexanderVanhee 9781965
Fix style issues
AlexanderVanhee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| using Gtk 4.0; | ||
|
|
||
| template $BzAddonTile: $BzListTile { | ||
| accessibility { | ||
| labelled-by: title_label; | ||
| described-by: description_label; | ||
| } | ||
|
|
||
| child: Box { | ||
| orientation: horizontal; | ||
| spacing: 10; | ||
| height-request: 64; | ||
|
|
||
| Box { | ||
| orientation: vertical; | ||
| valign: center; | ||
| spacing: 4; | ||
| margin-start: 10; | ||
|
|
||
| Label title_label { | ||
| xalign: 0.0; | ||
| ellipsize: end; | ||
| single-line-mode: true; | ||
| has-tooltip: true; | ||
| tooltip-text: bind template.group as <$BzEntryGroup>.id; | ||
| label: bind template.group as <$BzEntryGroup>.title; | ||
| } | ||
|
|
||
| Label description_label { | ||
| halign: start; | ||
| label: bind template.group as <$BzEntryGroup>.description; | ||
| visible: bind eol_label.visible inverted; | ||
| xalign: 0.0; | ||
| ellipsize: end; | ||
| single-line-mode: true; | ||
| styles ["dim-label", "caption"] | ||
| } | ||
|
|
||
| Label eol_label{ | ||
| visible: bind $invert_boolean($is_null(template.group as <$BzEntryGroup>.eol) as <bool>) as <bool>; | ||
| wrap: true; | ||
| wrap-mode: word_char; | ||
| ellipsize: end; | ||
| vexpand: true; | ||
| lines: 2; | ||
| single-line-mode: true; | ||
| halign: start; | ||
| hexpand: true; | ||
| label: _("Stopped Receiving Updates"); | ||
|
|
||
| styles [ | ||
| "warning", | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| Box { | ||
| orientation: horizontal; | ||
| spacing: 8; | ||
| margin-end: 8; | ||
| hexpand: true; | ||
| halign: end; | ||
|
|
||
| Button install_remove_button { | ||
| styles ["flat"] | ||
| width-request: 32; | ||
| height-request: 32; | ||
| valign: center; | ||
| has-tooltip: true; | ||
| visible: bind $invert_boolean($logical_and($is_zero(template.group as <$BzEntryGroup>.removable) as <bool>, $is_zero(template.group as <$BzEntryGroup>.installable) as <bool>) as <bool>) as <bool>; | ||
| tooltip-text: bind $get_install_remove_tooltip(template.group as <$BzEntryGroup>.removable) as <string>; | ||
| sensitive: bind $switch_bool( | ||
| template.group as <$BzEntryGroup>.removable, | ||
| $invert_boolean($is_zero(template.group as <$BzEntryGroup>.removable-and-available) as <bool>) as <bool>, | ||
| $invert_boolean($is_zero(template.group as <$BzEntryGroup>.installable-and-available) as <bool>) as <bool>, | ||
| ) as <bool>; | ||
| icon-name: bind $get_install_remove_icon(template.group as <$BzEntryGroup>.removable) as <string>; | ||
| clicked => $install_remove_cb() swapped; | ||
| } | ||
|
|
||
| Image { | ||
| pixel-size: 14; | ||
| icon-name: "go-next-symbolic"; | ||
| margin-end: 4; | ||
| styles ["dimmed"] | ||
| } | ||
| } | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,239 @@ | ||
| /* bz-addon-tile.c | ||
| * | ||
| * Copyright 2026 Alexander Vanhee | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program 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 General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| * | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| */ | ||
|
|
||
| #include <glib/gi18n.h> | ||
|
|
||
| #include "bz-addon-tile.h" | ||
| #include "bz-entry-group.h" | ||
| #include "bz-state-info.h" | ||
| #include "bz-window.h" | ||
|
|
||
| struct _BzAddonTile | ||
| { | ||
| BzListTile parent_instance; | ||
|
|
||
| BzEntryGroup *group; | ||
|
|
||
| GtkButton *install_remove_button; | ||
| }; | ||
|
|
||
| G_DEFINE_FINAL_TYPE (BzAddonTile, bz_addon_tile, BZ_TYPE_LIST_TILE) | ||
|
|
||
| enum | ||
| { | ||
| PROP_0, | ||
|
|
||
| PROP_GROUP, | ||
|
|
||
| LAST_PROP | ||
| }; | ||
| static GParamSpec *props[LAST_PROP] = { 0 }; | ||
|
|
||
| static void | ||
| install_remove_cb (BzAddonTile *self, | ||
| GtkButton *button) | ||
| { | ||
| int removable = 0; | ||
|
|
||
| if (self->group == NULL) | ||
| return; | ||
|
|
||
| removable = bz_entry_group_get_removable (self->group); | ||
|
|
||
| if (removable > 0) | ||
| gtk_widget_activate_action (GTK_WIDGET (self), "window.remove-group", "(sb)", | ||
| bz_entry_group_get_id (self->group), FALSE); | ||
| else | ||
| gtk_widget_activate_action (GTK_WIDGET (self), "window.install-group", "(sb)", | ||
| bz_entry_group_get_id (self->group), TRUE); | ||
| } | ||
|
|
||
| static void | ||
| bz_addon_tile_dispose (GObject *object) | ||
| { | ||
| BzAddonTile *self = BZ_ADDON_TILE (object); | ||
|
|
||
| g_clear_object (&self->group); | ||
|
|
||
| G_OBJECT_CLASS (bz_addon_tile_parent_class)->dispose (object); | ||
| } | ||
|
|
||
| static void | ||
| bz_addon_tile_get_property (GObject *object, | ||
| guint prop_id, | ||
| GValue *value, | ||
| GParamSpec *pspec) | ||
| { | ||
| BzAddonTile *self = BZ_ADDON_TILE (object); | ||
|
|
||
| switch (prop_id) | ||
| { | ||
| case PROP_GROUP: | ||
| g_value_set_object (value, bz_addon_tile_get_group (self)); | ||
| break; | ||
| default: | ||
| G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
| } | ||
| } | ||
|
|
||
| static void | ||
| bz_addon_tile_set_property (GObject *object, | ||
| guint prop_id, | ||
| const GValue *value, | ||
| GParamSpec *pspec) | ||
| { | ||
| BzAddonTile *self = BZ_ADDON_TILE (object); | ||
|
|
||
| switch (prop_id) | ||
| { | ||
| case PROP_GROUP: | ||
| bz_addon_tile_set_group (self, g_value_get_object (value)); | ||
| break; | ||
| default: | ||
| G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
| } | ||
| } | ||
|
|
||
| static gboolean | ||
| is_zero (gpointer object, | ||
| int value) | ||
| { | ||
| return value == 0; | ||
| } | ||
|
|
||
| static gboolean | ||
| invert_boolean (gpointer object, | ||
| gboolean value) | ||
| { | ||
| return !value; | ||
| } | ||
|
|
||
| static gboolean | ||
| is_null (gpointer object, | ||
| GObject *value) | ||
| { | ||
| return value == NULL; | ||
| } | ||
|
|
||
| static gboolean | ||
| logical_and (gpointer object, | ||
| gboolean value1, | ||
| gboolean value2) | ||
| { | ||
| return value1 && value2; | ||
| } | ||
|
|
||
| static char * | ||
| get_install_remove_tooltip (gpointer object, | ||
| int removable) | ||
| { | ||
| if (removable > 0) | ||
| return g_strdup (_ ("Uninstall")); | ||
| else | ||
| return g_strdup (_ ("Install")); | ||
| } | ||
|
|
||
| static char * | ||
| get_install_remove_icon (gpointer object, | ||
| int removable) | ||
| { | ||
| if (removable > 0) | ||
| return g_strdup ("user-trash-symbolic"); | ||
| else | ||
| return g_strdup ("document-save-symbolic"); | ||
| } | ||
|
|
||
| static gboolean | ||
| switch_bool (gpointer object, | ||
| gboolean condition, | ||
| gboolean true_value, | ||
| gboolean false_value) | ||
| { | ||
| return condition ? true_value : false_value; | ||
| } | ||
|
|
||
| static void | ||
| bz_addon_tile_class_init (BzAddonTileClass *klass) | ||
| { | ||
| GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
| GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); | ||
|
|
||
| object_class->dispose = bz_addon_tile_dispose; | ||
| object_class->get_property = bz_addon_tile_get_property; | ||
| object_class->set_property = bz_addon_tile_set_property; | ||
|
|
||
| props[PROP_GROUP] = | ||
| g_param_spec_object ( | ||
| "group", | ||
| NULL, NULL, | ||
| BZ_TYPE_ENTRY_GROUP, | ||
| G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); | ||
|
|
||
| g_object_class_install_properties (object_class, LAST_PROP, props); | ||
|
|
||
| g_type_ensure (BZ_TYPE_LIST_TILE); | ||
| g_type_ensure (BZ_TYPE_ENTRY_GROUP); | ||
|
|
||
| gtk_widget_class_set_template_from_resource (widget_class, "/io/github/kolunmi/Bazaar/bz-addon-tile.ui"); | ||
| gtk_widget_class_bind_template_child (widget_class, BzAddonTile, install_remove_button); | ||
| gtk_widget_class_bind_template_callback (widget_class, is_zero); | ||
| 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, logical_and); | ||
| gtk_widget_class_bind_template_callback (widget_class, get_install_remove_tooltip); | ||
| gtk_widget_class_bind_template_callback (widget_class, get_install_remove_icon); | ||
| gtk_widget_class_bind_template_callback (widget_class, switch_bool); | ||
| gtk_widget_class_bind_template_callback (widget_class, install_remove_cb); | ||
|
|
||
| gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON); | ||
| } | ||
|
|
||
| static void | ||
| bz_addon_tile_init (BzAddonTile *self) | ||
| { | ||
| gtk_widget_init_template (GTK_WIDGET (self)); | ||
| } | ||
|
|
||
| GtkWidget * | ||
| bz_addon_tile_new (void) | ||
| { | ||
| return g_object_new (BZ_TYPE_ADDON_TILE, NULL); | ||
| } | ||
|
|
||
| void | ||
| bz_addon_tile_set_group (BzAddonTile *self, | ||
| BzEntryGroup *group) | ||
| { | ||
| g_return_if_fail (BZ_IS_ADDON_TILE (self)); | ||
| g_return_if_fail (group == NULL || BZ_IS_ENTRY_GROUP (group)); | ||
|
|
||
| g_clear_object (&self->group); | ||
| if (group != NULL) | ||
| self->group = g_object_ref (group); | ||
|
|
||
| g_object_notify_by_pspec (G_OBJECT (self), props[PROP_GROUP]); | ||
| } | ||
|
|
||
| BzEntryGroup * | ||
| bz_addon_tile_get_group (BzAddonTile *self) | ||
| { | ||
| g_return_val_if_fail (BZ_IS_ADDON_TILE (self), NULL); | ||
| return self->group; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* bz-addon-tile.h | ||
| * | ||
| * Copyright 2026 Alexander Vanhee | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program 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 General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| * | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "bz-entry-group.h" | ||
| #include "bz-list-tile.h" | ||
| #include <adwaita.h> | ||
|
|
||
| G_BEGIN_DECLS | ||
|
|
||
| #define BZ_TYPE_ADDON_TILE (bz_addon_tile_get_type ()) | ||
| G_DECLARE_FINAL_TYPE (BzAddonTile, bz_addon_tile, BZ, ADDON_TILE, BzListTile) | ||
|
|
||
| GtkWidget * | ||
| bz_addon_tile_new (void); | ||
|
|
||
| void | ||
| bz_addon_tile_set_group (BzAddonTile *self, | ||
| BzEntryGroup *group); | ||
|
|
||
| BzEntryGroup * | ||
| bz_addon_tile_get_group (BzAddonTile *self); | ||
|
|
||
| G_END_DECLS |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderVanhee This file does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed as part of #1367.