[gnome-control-center/gbsneto/background: 4/6] background: Make BgSource receive a GtkWidget
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/background: 4/6] background: Make BgSource receive a GtkWidget
- Date: Wed, 22 May 2019 15:35:28 +0000 (UTC)
commit 5ae46238cf4d00df2c53f32340cf9af7f0cc929c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue May 21 15:50:30 2019 -0300
background: Make BgSource receive a GtkWidget
Instead of a GtkWindow. We don't really depend on GtkWindow
itself, just any widget with access to the scale factor.
panels/background/bg-colors-source.c | 4 ++--
panels/background/bg-colors-source.h | 2 +-
panels/background/bg-pictures-source.c | 4 ++--
panels/background/bg-pictures-source.h | 2 +-
panels/background/bg-source.c | 24 ++++++++++++------------
panels/background/bg-wallpapers-source.c | 4 ++--
panels/background/bg-wallpapers-source.h | 2 +-
panels/background/cc-background-chooser-dialog.c | 6 +++---
8 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/panels/background/bg-colors-source.c b/panels/background/bg-colors-source.c
index 7c837b809..3512772bb 100644
--- a/panels/background/bg-colors-source.c
+++ b/panels/background/bg-colors-source.c
@@ -249,8 +249,8 @@ bg_colors_source_class_init (BgColorsSourceClass *klass)
}
BgColorsSource *
-bg_colors_source_new (GtkWindow *window)
+bg_colors_source_new (GtkWidget *widget)
{
- return g_object_new (BG_TYPE_COLORS_SOURCE, "window", window, NULL);
+ return g_object_new (BG_TYPE_COLORS_SOURCE, "widget", widget, NULL);
}
diff --git a/panels/background/bg-colors-source.h b/panels/background/bg-colors-source.h
index de1d93c50..e0d37df6d 100644
--- a/panels/background/bg-colors-source.h
+++ b/panels/background/bg-colors-source.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
#define BG_TYPE_COLORS_SOURCE (bg_colors_source_get_type ())
G_DECLARE_FINAL_TYPE (BgColorsSource, bg_colors_source, BG, COLORS_SOURCE, BgSource)
-BgColorsSource *bg_colors_source_new (GtkWindow *window);
+BgColorsSource *bg_colors_source_new (GtkWidget *widget);
gboolean bg_colors_source_add (BgColorsSource *self,
GdkRGBA *rgba,
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index 714c7f744..8c0d6db34 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -989,9 +989,9 @@ bg_pictures_source_init (BgPicturesSource *self)
}
BgPicturesSource *
-bg_pictures_source_new (GtkWindow *window)
+bg_pictures_source_new (GtkWidget *widget)
{
- return g_object_new (BG_TYPE_PICTURES_SOURCE, "window", window, NULL);
+ return g_object_new (BG_TYPE_PICTURES_SOURCE, "widget", widget, NULL);
}
const char * const *
diff --git a/panels/background/bg-pictures-source.h b/panels/background/bg-pictures-source.h
index 476ecb749..c57a61ff4 100644
--- a/panels/background/bg-pictures-source.h
+++ b/panels/background/bg-pictures-source.h
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
#define BG_TYPE_PICTURES_SOURCE (bg_pictures_source_get_type ())
G_DECLARE_FINAL_TYPE (BgPicturesSource, bg_pictures_source, BG, PICTURES_SOURCE, BgSource)
-BgPicturesSource *bg_pictures_source_new (GtkWindow *window);
+BgPicturesSource *bg_pictures_source_new (GtkWidget *widget);
char *bg_pictures_source_get_cache_path (void);
char *bg_pictures_source_get_unique_path(const char *uri);
gboolean bg_pictures_source_add (BgPicturesSource *bg_source,
diff --git a/panels/background/bg-source.c b/panels/background/bg-source.c
index e48daf0f2..18688ff42 100644
--- a/panels/background/bg-source.c
+++ b/panels/background/bg-source.c
@@ -29,7 +29,7 @@
typedef struct
{
GtkListStore *store;
- GtkWidget *window;
+ GtkWidget *widget;
gint thumbnail_height;
gint thumbnail_width;
} BgSourcePrivate;
@@ -39,7 +39,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (BgSource, bg_source, G_TYPE_OBJECT)
enum
{
PROP_LISTSTORE = 1,
- PROP_WINDOW
+ PROP_WIDGET
};
@@ -52,10 +52,10 @@ bg_source_calculate_thumbnail_dimensions (BgSource *source)
priv->thumbnail_height = THUMBNAIL_HEIGHT;
priv->thumbnail_width = THUMBNAIL_WIDTH;
- if (priv->window == NULL)
+ if (priv->widget == NULL)
return;
- scale_factor = gtk_widget_get_scale_factor (priv->window);
+ scale_factor = gtk_widget_get_scale_factor (priv->widget);
if (scale_factor > 1)
{
priv->thumbnail_height *= scale_factor;
@@ -101,8 +101,8 @@ bg_source_set_property (GObject *object,
switch (property_id)
{
- case PROP_WINDOW:
- priv->window = GTK_WIDGET (g_value_get_object (value));
+ case PROP_WIDGET:
+ priv->widget = GTK_WIDGET (g_value_get_object (value));
break;
default:
@@ -139,12 +139,12 @@ bg_source_class_init (BgSourceClass *klass)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_LISTSTORE, pspec);
- pspec = g_param_spec_object ("window",
- "Window",
- "Toplevel window used to view the source",
- GTK_TYPE_WINDOW,
+ pspec = g_param_spec_object ("widget",
+ "Widget",
+ "Widget used to view the source",
+ GTK_TYPE_WIDGET,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_WINDOW, pspec);
+ g_object_class_install_property (object_class, PROP_WIDGET, pspec);
}
static void
@@ -173,7 +173,7 @@ bg_source_get_scale_factor (BgSource *source)
g_return_val_if_fail (BG_IS_SOURCE (source), 1);
priv = bg_source_get_instance_private (source);
- return gtk_widget_get_scale_factor (priv->window);
+ return gtk_widget_get_scale_factor (priv->widget);
}
gint
diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c
index ccb7e2f08..21fbba4bb 100644
--- a/panels/background/bg-wallpapers-source.c
+++ b/panels/background/bg-wallpapers-source.c
@@ -160,8 +160,8 @@ bg_wallpapers_source_class_init (BgWallpapersSourceClass *klass)
}
BgWallpapersSource *
-bg_wallpapers_source_new (GtkWindow *window)
+bg_wallpapers_source_new (GtkWidget *widget)
{
- return g_object_new (BG_TYPE_WALLPAPERS_SOURCE, "window", window, NULL);
+ return g_object_new (BG_TYPE_WALLPAPERS_SOURCE, "widget", widget, NULL);
}
diff --git a/panels/background/bg-wallpapers-source.h b/panels/background/bg-wallpapers-source.h
index 129c24931..90c93df8b 100644
--- a/panels/background/bg-wallpapers-source.h
+++ b/panels/background/bg-wallpapers-source.h
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
#define BG_TYPE_WALLPAPERS_SOURCE (bg_wallpapers_source_get_type ())
G_DECLARE_FINAL_TYPE (BgWallpapersSource, bg_wallpapers_source, BG, WALLPAPERS_SOURCE, BgSource)
-BgWallpapersSource *bg_wallpapers_source_new (GtkWindow *window);
+BgWallpapersSource *bg_wallpapers_source_new (GtkWidget *widget);
G_END_DECLS
diff --git a/panels/background/cc-background-chooser-dialog.c
b/panels/background/cc-background-chooser-dialog.c
index 81f913ac5..5c35c4dbc 100644
--- a/panels/background/cc-background-chooser-dialog.c
+++ b/panels/background/cc-background-chooser-dialog.c
@@ -445,9 +445,9 @@ cc_background_chooser_dialog_init (CcBackgroundChooserDialog *chooser)
g_autofree gchar *pictures_dir_uri = NULL;
GtkTargetList *target_list;
- chooser->wallpapers_source = bg_wallpapers_source_new (GTK_WINDOW (chooser));
- chooser->pictures_source = bg_pictures_source_new (GTK_WINDOW (chooser));
- chooser->colors_source = bg_colors_source_new (GTK_WINDOW (chooser));
+ chooser->wallpapers_source = bg_wallpapers_source_new (GTK_WIDGET (chooser));
+ chooser->pictures_source = bg_pictures_source_new (GTK_WIDGET (chooser));
+ chooser->colors_source = bg_colors_source_new (GTK_WIDGET (chooser));
gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);
gtk_window_set_resizable (GTK_WINDOW (chooser), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]