[gnome-control-center/wip/jsparber/background: 41/58] [feat] change size of preview when panel is heigher then 700
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/jsparber/background: 41/58] [feat] change size of preview when panel is heigher then 700
- Date: Fri, 24 Nov 2017 21:48:12 +0000 (UTC)
commit 4e5cb46798b9b140922e97e7073e53c51562e1eb
Author: Julian Sparber <julian sparber net>
Date: Sat Nov 11 17:43:48 2017 +0100
[feat] change size of preview when panel is heigher then 700
panels/background/background.ui | 5 +--
panels/background/cc-background-panel.c | 47 +++++++++++++++++++++---------
2 files changed, 35 insertions(+), 17 deletions(-)
---
diff --git a/panels/background/background.ui b/panels/background/background.ui
index 29da671..ddfa5e2 100644
--- a/panels/background/background.ui
+++ b/panels/background/background.ui
@@ -13,8 +13,8 @@
<property name="margin">16</property>
<property name="halign">fill</property>
<property name="orientation">vertical</property>
- <property name="expand">True</property>
- <property name="height_request">200</property>
+ <property name="expand">False</property>
+ <property name="height_request">150</property>
<child>
<object class="GtkAspectFrame">
<property name="visible">True</property>
@@ -121,7 +121,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
- <property name="height_request">450</property>
<style>
<class name="background-gallery"/>
</style>
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index c4b37da..3f99447 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -201,25 +201,24 @@ on_preview_draw (GtkWidget *widget,
CcBackgroundPanel *panel)
{
GdkPixbuf *pixbuf;
- const gint width = gtk_widget_get_allocated_width (panel);
- gint height = gtk_widget_get_allocated_height (panel);
- gint request_height;
- const gint preview_width = gtk_widget_get_allocated_width (widget);
- const gint preview_height = gtk_widget_get_allocated_height (widget);
- /*g_print ("Height %d", height);
- if (preview_width > 310) {
+ /*const gint width = gtk_widget_get_allocated_width (panel);
+ gint height = gtk_widget_get_allocated_height (panel);
+ gint request_height;
+ const gint preview_width = gtk_widget_get_allocated_width (widget);
+ const gint preview_height = gtk_widget_get_allocated_height (widget);
+ g_print ("Height %d", height);
+ if (preview_width > 310) {
gtk_widget_set_vexpand (WID ("background-preview"), FALSE);
gtk_widget_set_size_request (widget, 310, preview_height);
- }
- else {
+ }
+ else {
gtk_widget_set_vexpand (WID ("background-preview"), TRUE);
gtk_widget_set_size_request (widget, -1, -1);
- }
- */
+ }
- /*gtk_widget_get_size_request (WID ("background-gallery-box"), NULL, &request_height);
- g_print ("Height %d\n", height);
- gtk_widget_set_size_request (WID ("background-gallery-box"), -1, height - 300);
+ gtk_widget_get_size_request (WID ("background-gallery-box"), NULL, &request_height);
+ g_print ("Height %d\n", height);
+ gtk_widget_set_size_request (WID ("background-gallery-box"), -1, height - 300);
*/
pixbuf = get_or_create_cached_pixbuf (panel,
@@ -234,6 +233,23 @@ on_preview_draw (GtkWidget *widget,
}
static void
+on_panel_resize (GtkWidget *widget,
+ GdkRectangle *allocation,
+ gpointer user_data)
+{
+ CcBackgroundPanel *panel = CC_BACKGROUND_PANEL (user_data);
+ GtkWidget *preview = WID ("background-preview");
+
+ if (allocation->height > 700) {
+ gtk_widget_set_size_request (preview, -1, 200);
+ }
+ else {
+ gtk_widget_set_size_request (preview, -1, 150);
+ }
+}
+
+
+static void
reload_current_bg (CcBackgroundPanel *panel,
GSettings *settings)
{
@@ -753,6 +769,9 @@ cc_background_panel_init (CcBackgroundPanel *panel)
widget = WID ("background-desktop-drawingarea");
g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw), panel);
+ /* Add handler for resizing the preview */
+ g_signal_connect (panel, "size-allocate", G_CALLBACK (on_panel_resize), panel);
+
panel->copy_cancellable = g_cancellable_new ();
panel->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]