[xdg-desktop-portal-gnome/wip/exalm/polish: 2/4] screenshot: Refine screenshot display
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xdg-desktop-portal-gnome/wip/exalm/polish: 2/4] screenshot: Refine screenshot display
- Date: Fri, 4 Feb 2022 22:14:08 +0000 (UTC)
commit bfc5d6273784b678fee8ad2b60e2c5b49723bf3a
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Feb 5 02:53:27 2022 +0500
screenshot: Refine screenshot display
Use GtkPicture instead of GtkImage, make the preview larger, remove
borders.
Constrain the window size instead of image size, stop using pixbufs.
src/screenshotdialog.c | 28 +++-------------------------
src/screenshotdialog.css | 3 ---
src/screenshotdialog.ui | 8 +++-----
src/xdg-desktop-portal-gnome.gresource.xml | 1 -
4 files changed, 6 insertions(+), 34 deletions(-)
---
diff --git a/src/screenshotdialog.c b/src/screenshotdialog.c
index a8b29af..6dd6790 100644
--- a/src/screenshotdialog.c
+++ b/src/screenshotdialog.c
@@ -13,7 +13,7 @@
struct _ScreenshotDialog {
GtkWindow parent;
- GtkWidget *image;
+ GtkWidget *picture;
GtkWidget *heading;
GtkWidget *accept_button;
GtkWidget *options_button;
@@ -127,13 +127,10 @@ static void
show_screenshot (ScreenshotDialog *dialog,
const char *filename)
{
- g_autoptr(GdkPixbuf) pixbuf = NULL;
-
g_free (dialog->filename);
dialog->filename = g_strdup (filename);
- pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, 500, 400, TRUE, NULL);
- gtk_image_set_from_pixbuf (GTK_IMAGE (dialog->image), pixbuf);
+ gtk_picture_set_filename (GTK_PICTURE (dialog->picture), filename);
gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "screenshot");
gtk_stack_set_visible_child_name (GTK_STACK (dialog->header_stack), "screenshot");
@@ -367,23 +364,6 @@ screenshot_dialog_close_request (GtkWindow *dialog)
return TRUE;
}
-static void
-screenshot_dialog_map (GtkWidget *widget)
-{
- static GtkCssProvider *provider;
-
- GTK_WIDGET_CLASS (screenshot_dialog_parent_class)->map (widget);
-
- if (provider == NULL)
- {
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_resource (provider,
"/org/freedesktop/portal/desktop/gnome/screenshotdialog.css");
- gtk_style_context_add_provider_for_display (gtk_widget_get_display (widget),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
-}
-
static void
screenshot_dialog_class_init (ScreenshotDialogClass *class)
{
@@ -395,8 +375,6 @@ screenshot_dialog_class_init (ScreenshotDialogClass *class)
window_class->close_request = screenshot_dialog_close_request;
- widget_class->map = screenshot_dialog_map;
-
signals[DONE] = g_signal_new ("done",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
@@ -412,7 +390,7 @@ screenshot_dialog_class_init (ScreenshotDialogClass *class)
gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, options_button);
gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, screenshot_button);
gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, heading);
- gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, image);
+ gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, picture);
gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, stack);
gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, header_stack);
gtk_widget_class_bind_template_child (widget_class, ScreenshotDialog, delay_adjustment);
diff --git a/src/screenshotdialog.ui b/src/screenshotdialog.ui
index 97c2339..cafc467 100644
--- a/src/screenshotdialog.ui
+++ b/src/screenshotdialog.ui
@@ -3,6 +3,8 @@
<requires lib="gtk" version="4.0"/>
<template class="ScreenshotDialog" parent="GtkWindow">
<property name="resizable">0</property>
+ <property name="default-width">500</property>
+ <property name="default-height">400</property>
<property name="title" translatable="yes">Screenshot</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="titlebar">
@@ -81,12 +83,8 @@
<object class="GtkLabel" id="heading"/>
</child>
<child>
- <object class="GtkImage" id="image">
- <property name="hexpand">1</property>
+ <object class="GtkPicture" id="picture">
<property name="vexpand">1</property>
- <style>
- <class name="screenshot"/>
- </style>
</object>
</child>
</object>
diff --git a/src/xdg-desktop-portal-gnome.gresource.xml b/src/xdg-desktop-portal-gnome.gresource.xml
index aee9b53..ffaed6b 100644
--- a/src/xdg-desktop-portal-gnome.gresource.xml
+++ b/src/xdg-desktop-portal-gnome.gresource.xml
@@ -5,7 +5,6 @@
<file>appchooserdialog.ui</file>
<file>appchooserrow.ui</file>
<file>screenshotdialog.ui</file>
- <file>screenshotdialog.css</file>
<file>screencastwidget.ui</file>
<file>screencastdialog.ui</file>
<file>remotedesktopdialog.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]