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
2 changes: 1 addition & 1 deletion src/bazaar.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<file preprocess="xml-stripblanks">bz-releases-list.ui</file>
<file preprocess="xml-stripblanks">bz-releases-dialog.ui</file>
<file preprocess="xml-stripblanks">bz-rich-app-tile.ui</file>
<file preprocess="xml-stripblanks">bz-screenshot-dialog.ui</file>
<file preprocess="xml-stripblanks">bz-screenshot-page.ui</file>
<file preprocess="xml-stripblanks">bz-screenshots-carousel.ui</file>
<file preprocess="xml-stripblanks">bz-search-widget.ui</file>
<file preprocess="xml-stripblanks">bz-section-view.ui</file>
Expand Down
1 change: 1 addition & 0 deletions src/bz-full-view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ template $BzFullView: Adw.Bin {
vexpand: true;
hexpand: true;
visible: bind template.debounced-ui-entry as <$BzResult>.resolved as <bool>;
clicked => $screenshot_clicked_cb() swapped;

model: $BzLazyAsyncTextureModel {
model: bind template.debounced-ui-entry as <$BzResult>.object as <$BzEntry>.screenshot-paintables;
Expand Down
153 changes: 87 additions & 66 deletions src/bz-full-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <glib/gi18n.h>
#include <json-glib/json-glib.h>

#include "bz-application.h"
#include "bz-addons-dialog.h"
#include "bz-app-size-dialog.h"
#include "bz-app-tile.h"
Expand All @@ -40,6 +39,7 @@
#include "bz-lazy-async-texture-model.h"
#include "bz-license-dialog.h"
#include "bz-releases-list.h"
#include "bz-screenshot-page.h"
#include "bz-screenshots-carousel.h"
#include "bz-section-view.h"
#include "bz-share-list.h"
Expand All @@ -61,17 +61,17 @@ struct _BzFullView
BzResult *group_model;
gboolean show_sidebar;

guint debounce_timeout;
DexFuture *loading_forge_stars;
guint debounce_timeout;
DexFuture *loading_forge_stars;
GMenuModel *main_menu;

/* Template widgets */
GtkScrolledWindow *main_scroll;
AdwViewStack *stack;
GtkWidget *shadow_overlay;
GtkWidget *forge_stars;
GtkLabel *forge_stars_label;
GtkToggleButton *description_toggle;
AdwViewStack *stack;
GtkWidget *shadow_overlay;
GtkWidget *forge_stars;
GtkLabel *forge_stars_label;
GtkToggleButton *description_toggle;
};

G_DEFINE_FINAL_TYPE (BzFullView, bz_full_view, ADW_TYPE_BIN)
Expand Down Expand Up @@ -199,8 +199,8 @@ bz_full_view_set_property (GObject *object,
case PROP_DEBOUNCED_UI_ENTRY:
case PROP_MAIN_MENU:
if (self->main_menu)
g_object_unref(self->main_menu);
self->main_menu = g_value_dup_object(value);
g_object_unref (self->main_menu);
self->main_menu = g_value_dup_object (value);
break;
case PROP_SHOW_SIDEBAR:
self->show_sidebar = g_value_get_boolean (value);
Expand Down Expand Up @@ -450,66 +450,66 @@ pick_license_warning (gpointer object,
static char *
format_other_apps_label (gpointer object, const char *developer)
{
if (!developer || *developer == '\0')
return g_strdup (_("Other Apps by this Developer"));
if (!developer || *developer == '\0')
return g_strdup (_ ("Other Apps by this Developer"));

return g_strdup_printf (_("Other Apps by %s"), developer);
return g_strdup_printf (_ ("Other Apps by %s"), developer);
}

static gpointer
filter_own_app_id (BzEntry *entry, GtkStringList *app_ids)
{
const char *own_id;
g_autoptr (GtkStringList) filtered = NULL;
guint n_items = 0;
const char *own_id;
g_autoptr (GtkStringList) filtered = NULL;
guint n_items = 0;

if (!BZ_IS_ENTRY(entry) || !GTK_IS_STRING_LIST(app_ids))
return NULL;
if (!BZ_IS_ENTRY (entry) || !GTK_IS_STRING_LIST (app_ids))
return NULL;

own_id = bz_entry_get_id (entry);
if (!own_id)
return NULL;
own_id = bz_entry_get_id (entry);
if (!own_id)
return NULL;

filtered = gtk_string_list_new (NULL);
n_items = g_list_model_get_n_items (G_LIST_MODEL (app_ids));
filtered = gtk_string_list_new (NULL);
n_items = g_list_model_get_n_items (G_LIST_MODEL (app_ids));

for (guint i = 0; i < n_items; i++)
{
const char *id = NULL;
for (guint i = 0; i < n_items; i++)
{
const char *id = NULL;

id = gtk_string_list_get_string (app_ids, i);
if (g_strcmp0 (id, own_id) != 0)
gtk_string_list_append (filtered, id);
}
id = gtk_string_list_get_string (app_ids, i);
if (g_strcmp0 (id, own_id) != 0)
gtk_string_list_append (filtered, id);
}

if (g_list_model_get_n_items (G_LIST_MODEL (filtered)) > 0)
return g_steal_pointer (&filtered);
else
return NULL;
if (g_list_model_get_n_items (G_LIST_MODEL (filtered)) > 0)
return g_steal_pointer (&filtered);
else
return NULL;
}

static gboolean
has_other_apps (gpointer object, GtkStringList *app_ids, BzEntry *entry )
has_other_apps (gpointer object, GtkStringList *app_ids, BzEntry *entry)
{
g_autoptr (GtkStringList) filtered = filter_own_app_id (BZ_ENTRY (entry), app_ids);
return filtered != NULL;
g_autoptr (GtkStringList) filtered = filter_own_app_id (BZ_ENTRY (entry), app_ids);
return filtered != NULL;
}

static GListModel *
get_developer_apps_entries (gpointer object, GtkStringList *app_ids, BzEntry *entry)
{
BzFullView *self = BZ_FULL_VIEW (object);
g_autoptr (GtkStringList) filtered = filter_own_app_id (BZ_ENTRY (entry), app_ids);
BzApplicationMapFactory *factory;
BzFullView *self = BZ_FULL_VIEW (object);
g_autoptr (GtkStringList) filtered = filter_own_app_id (BZ_ENTRY (entry), app_ids);
BzApplicationMapFactory *factory;

if (!filtered)
return NULL;
if (!filtered)
return NULL;

factory = bz_state_info_get_application_factory (self->state);
if (!factory)
return NULL;
factory = bz_state_info_get_application_factory (self->state);
if (!factory)
return NULL;

return bz_application_map_factory_generate (factory, G_LIST_MODEL (filtered));
return bz_application_map_factory_generate (factory, G_LIST_MODEL (filtered));
}

static gboolean
Expand All @@ -521,10 +521,10 @@ scroll_to_top_idle (GtkAdjustment *vadj)

static void
app_tile_clicked_cb (BzFullView *self,
BzAppTile *tile)
BzAppTile *tile)
{
GtkAdjustment *vadj;
BzEntryGroup *group = bz_app_tile_get_group (tile);
BzEntryGroup *group = bz_app_tile_get_group (tile);

bz_full_view_set_entry_group (self, group);

Expand All @@ -534,20 +534,20 @@ app_tile_clicked_cb (BzFullView *self,

static void
bind_app_tile_cb (BzFullView *self,
BzAppTile *tile,
BzEntryGroup *group,
BzDynamicListView *view)
BzAppTile *tile,
BzEntryGroup *group,
BzDynamicListView *view)
{
g_signal_connect_swapped (tile, "clicked",
G_CALLBACK (app_tile_clicked_cb),
self);
G_CALLBACK (app_tile_clicked_cb),
self);
}

static void
unbind_app_tile_cb (BzFullView *self,
BzAppTile *tile,
BzEntryGroup *group,
BzDynamicListView *view)
BzAppTile *tile,
BzEntryGroup *group,
BzDynamicListView *view)
{
g_signal_handlers_disconnect_by_func (tile, G_CALLBACK (app_tile_clicked_cb), self);
}
Expand Down Expand Up @@ -630,6 +630,26 @@ dl_stats_cb (BzFullView *self,
bz_stats_dialog_animate_open (BZ_STATS_DIALOG (dialog));
}

static void
screenshot_clicked_cb (BzFullView *self,
guint index,
BzScreenshotsCarousel *carousel)
{
GListModel *screenshots = NULL;
AdwNavigationPage *page = NULL;
GtkWidget *nav_view = NULL;

screenshots = bz_screenshots_carousel_get_model (carousel);
if (screenshots == NULL)
return;

page = bz_screenshot_page_new (screenshots, index);

nav_view = gtk_widget_get_ancestor (GTK_WIDGET (self), ADW_TYPE_NAVIGATION_VIEW);
if (nav_view != NULL)
adw_navigation_view_push (ADW_NAVIGATION_VIEW (nav_view), page);
}

static void
size_cb (BzFullView *self,
GtkButton *button)
Expand Down Expand Up @@ -861,18 +881,18 @@ bz_full_view_class_init (BzFullViewClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

props[PROP_MAIN_MENU] =
g_param_spec_object(
"main-menu",
NULL, NULL,
G_TYPE_MENU_MODEL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_param_spec_object (
"main-menu",
NULL, NULL,
G_TYPE_MENU_MODEL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);

props[PROP_SHOW_SIDEBAR] =
g_param_spec_boolean(
"show-sidebar",
NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
g_param_spec_boolean (
"show-sidebar",
NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);

g_object_class_install_properties (object_class, LAST_PROP, props);

Expand Down Expand Up @@ -982,6 +1002,7 @@ bz_full_view_class_init (BzFullViewClass *klass)
gtk_widget_class_bind_template_callback (widget_class, open_flathub_url_cb);
gtk_widget_class_bind_template_callback (widget_class, license_cb);
gtk_widget_class_bind_template_callback (widget_class, dl_stats_cb);
gtk_widget_class_bind_template_callback (widget_class, screenshot_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, size_cb);
gtk_widget_class_bind_template_callback (widget_class, formfactor_cb);
gtk_widget_class_bind_template_callback (widget_class, run_cb);
Expand Down
Loading