diff options
author | Julian Sparber <julian@sparber.net> | 2018-02-06 22:43:26 +0100 |
---|---|---|
committer | Julian Sparber <julian@sparber.net> | 2018-02-17 22:27:19 +0100 |
commit | 81e1bf07c93a1df6f8c979969ce3e9a10f49febf (patch) | |
tree | d75dd5f811e2d3e2ed10379114ff6424d993dee1 | |
parent | edf69bde765e01633a0e216f3b0d10fa3e026eb9 (diff) | |
download | gnome-control-center-wip/jsparber/background.tar.gz |
background: clean up files and code and remove build warningswip/jsparber/background
- remove bg-source and bg-wallpapers-source files
- remove build warnings
- add Julian Sparber as author to cc-background-panel.c
https://bugzilla.gnome.org/show_bug.cgi?id=788515
-rw-r--r-- | panels/background/bg-source.c | 202 | ||||
-rw-r--r-- | panels/background/bg-source.h | 46 | ||||
-rw-r--r-- | panels/background/bg-wallpapers-source.c | 173 | ||||
-rw-r--r-- | panels/background/bg-wallpapers-source.h | 38 | ||||
-rw-r--r-- | panels/background/cc-background-grid-item.c | 13 | ||||
-rw-r--r-- | panels/background/cc-background-item.c | 8 | ||||
-rw-r--r-- | panels/background/cc-background-panel.c | 11 | ||||
-rw-r--r-- | panels/background/cc-background-store.c | 21 | ||||
-rw-r--r-- | panels/background/cc-background-xml.h | 22 | ||||
-rw-r--r-- | panels/background/meson.build | 2 |
10 files changed, 39 insertions, 497 deletions
diff --git a/panels/background/bg-source.c b/panels/background/bg-source.c deleted file mode 100644 index f1fac842f..000000000 --- a/panels/background/bg-source.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2010 Intel, Inc - * - * 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 2 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 <http://www.gnu.org/licenses/>. - * - * Author: Thomas Wood <thomas.wood@intel.com> - * - */ - -#include "bg-source.h" -#include "cc-background-item.h" - -#include <cairo-gobject.h> - -#define THUMBNAIL_WIDTH 256 -#define THUMBNAIL_HEIGHT (THUMBNAIL_WIDTH * 3 / 4) - -typedef struct -{ - GtkListStore *store; - GtkWidget *window; - gint thumbnail_height; - gint thumbnail_width; -} BgSourcePrivate; - -G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (BgSource, bg_source, G_TYPE_OBJECT) - -enum -{ - PROP_LISTSTORE = 1, - PROP_WINDOW -}; - - -static void -bg_source_calculate_thumbnail_dimensions (BgSource *source) -{ - BgSourcePrivate *priv = bg_source_get_instance_private (source); - gint scale_factor; - - priv->thumbnail_height = THUMBNAIL_HEIGHT; - priv->thumbnail_width = THUMBNAIL_WIDTH; - - if (priv->window == NULL) - return; - - - scale_factor = gtk_widget_get_scale_factor (priv->window); - - if (scale_factor > 1) - { - priv->thumbnail_height *= scale_factor; - priv->thumbnail_width *= scale_factor; - } -} - -static void -bg_source_constructed (GObject *object) -{ - G_OBJECT_CLASS (bg_source_parent_class)->constructed (object); - - bg_source_calculate_thumbnail_dimensions (BG_SOURCE (object)); -} - -static void -bg_source_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - BgSource *source = BG_SOURCE (object); - - switch (property_id) - { - case PROP_LISTSTORE: - g_value_set_object (value, bg_source_get_liststore (source)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -bg_source_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - BgSource *source = BG_SOURCE (object); - BgSourcePrivate *priv = bg_source_get_instance_private (source); - - switch (property_id) - { - case PROP_WINDOW: - priv->window = GTK_WIDGET (g_value_get_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -bg_source_dispose (GObject *object) -{ - BgSource *source = BG_SOURCE (object); - BgSourcePrivate *priv = bg_source_get_instance_private (source); - - g_clear_object (&priv->store); - - G_OBJECT_CLASS (bg_source_parent_class)->dispose (object); -} - -static void -bg_source_class_init (BgSourceClass *klass) -{ - GParamSpec *pspec; - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructed = bg_source_constructed; - object_class->get_property = bg_source_get_property; - object_class->set_property = bg_source_set_property; - object_class->dispose = bg_source_dispose; - - pspec = g_param_spec_object ("liststore", - "Liststore", - "Liststore used in the source", - GTK_TYPE_LIST_STORE, - 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_WIDGET, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_WINDOW, pspec); -} - -static void -bg_source_init (BgSource *self) -{ - BgSourcePrivate *priv = bg_source_get_instance_private (self); - priv->store = gtk_list_store_new (3, CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_OBJECT, G_TYPE_STRING); -} - -GtkListStore* -bg_source_get_liststore (BgSource *source) -{ - BgSourcePrivate *priv; - - g_return_val_if_fail (BG_IS_SOURCE (source), NULL); - - priv = bg_source_get_instance_private (source); - return priv->store; -} - -gint -bg_source_get_scale_factor (BgSource *source) -{ - BgSourcePrivate *priv; - - 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); -} - -gint -bg_source_get_thumbnail_height (BgSource *source) -{ - BgSourcePrivate *priv; - - g_return_val_if_fail (BG_IS_SOURCE (source), THUMBNAIL_HEIGHT); - - priv = bg_source_get_instance_private (source); - return priv->thumbnail_height; -} - -gint -bg_source_get_thumbnail_width (BgSource *source) -{ - BgSourcePrivate *priv; - - g_return_val_if_fail (BG_IS_SOURCE (source), THUMBNAIL_WIDTH); - - priv = bg_source_get_instance_private (source); - return priv->thumbnail_width; -} diff --git a/panels/background/bg-source.h b/panels/background/bg-source.h deleted file mode 100644 index c6f9b4005..000000000 --- a/panels/background/bg-source.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2010 Intel, Inc - * - * 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 2 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 <http://www.gnu.org/licenses/>. - * - * Author: Thomas Wood <thomas.wood@intel.com> - * - */ - -#ifndef _BG_SOURCE_H -#define _BG_SOURCE_H - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define BG_TYPE_SOURCE (bg_source_get_type ()) -G_DECLARE_DERIVABLE_TYPE (BgSource, bg_source, BG, SOURCE, GObject) - -struct _BgSourceClass -{ - GObjectClass parent_class; -}; - -GtkListStore* bg_source_get_liststore (BgSource *source); - -gint bg_source_get_scale_factor (BgSource *source); - -gint bg_source_get_thumbnail_height (BgSource *source); - -gint bg_source_get_thumbnail_width (BgSource *source); - -G_END_DECLS - -#endif /* _BG_SOURCE_H */ diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c deleted file mode 100644 index 1b891e55c..000000000 --- a/panels/background/bg-wallpapers-source.c +++ /dev/null @@ -1,173 +0,0 @@ -/* bg-wallpapers-source.c */ -/* - * Copyright (C) 2010 Intel, Inc - * - * 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 2 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 <http://www.gnu.org/licenses/>. - * - * Author: Thomas Wood <thomas.wood@intel.com> - * - */ - -#include "bg-wallpapers-source.h" - -#include "cc-background-item.h" -#include "cc-background-xml.h" - -#include <cairo-gobject.h> -#include <libgnome-desktop/gnome-desktop-thumbnail.h> -#include <gio/gio.h> - -struct _BgWallpapersSource -{ - BgSource parent_instance; - GnomeDesktopThumbnailFactory *thumb_factory; - CcBackgroundXml *xml; -}; - -G_DEFINE_TYPE (BgWallpapersSource, bg_wallpapers_source, BG_TYPE_SOURCE) - -static void -load_wallpapers (gchar *key, - CcBackgroundItem *item, - BgWallpapersSource *source) -{ - GtkTreeIter iter; - g_autoptr(GdkPixbuf) pixbuf = NULL; - GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source)); - cairo_surface_t *surface; - gboolean deleted; - gint scale_factor; - gint thumbnail_height; - gint thumbnail_width; - - g_object_get (G_OBJECT (item), "is-deleted", &deleted, NULL); - - if (deleted) - return; - - //gtk_list_store_append (store, &iter); - - scale_factor = bg_source_get_scale_factor (BG_SOURCE (source)); - thumbnail_height = bg_source_get_thumbnail_height (BG_SOURCE (source)); - thumbnail_width = bg_source_get_thumbnail_width (BG_SOURCE (source)); - pixbuf = cc_background_item_get_thumbnail (item, source->thumb_factory, - thumbnail_width, thumbnail_height, - scale_factor); - if (pixbuf == NULL) - return; - - surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor, NULL); - - gtk_list_store_insert_with_values (store, &iter, -1, - 0, surface, - 1, item, - 2, cc_background_item_get_name (item), - -1); - - /* gtk_list_store_set (store, &iter, - 0, surface, - 1, item, - 2, cc_background_item_get_name (item), - -1); - */ - g_clear_pointer (&surface, (GDestroyNotify) cairo_surface_destroy); -} - -static void -list_load_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - cc_background_xml_load_list_finish (res); -} - -static void -item_added (CcBackgroundXml *xml, - CcBackgroundItem *item, - BgWallpapersSource *self) -{ - load_wallpapers (NULL, item, self); -} - -static void -load_default_bg (BgWallpapersSource *self) -{ - const char * const *system_data_dirs; - guint i; - - /* FIXME We could do this nicer if we had the XML source in GSettings */ - - system_data_dirs = g_get_system_data_dirs (); - for (i = 0; system_data_dirs[i]; i++) { - g_autofree gchar *filename = NULL; - - filename = g_build_filename (system_data_dirs[i], - "gnome-background-properties", - "adwaita.xml", - NULL); - if (cc_background_xml_load_xml (self->xml, filename)) - break; - } -} - -static void -bg_wallpapers_source_constructed (GObject *object) -{ - BgWallpapersSource *self = BG_WALLPAPERS_SOURCE (object); - - G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->constructed (object); - - g_signal_connect (G_OBJECT (self->xml), "added", - G_CALLBACK (item_added), self); - - /* Try adding the default background first */ - load_default_bg (self); - - cc_background_xml_load_list_async (self->xml, NULL, list_load_cb, self); -} - -static void -bg_wallpapers_source_dispose (GObject *object) -{ - BgWallpapersSource *self = BG_WALLPAPERS_SOURCE (object); - - g_clear_object (&self->thumb_factory); - g_clear_object (&self->xml); - - G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->dispose (object); -} - -static void -bg_wallpapers_source_init (BgWallpapersSource *self) -{ - self->thumb_factory = - gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); - self->xml = cc_background_xml_new (); -} - -static void -bg_wallpapers_source_class_init (BgWallpapersSourceClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructed = bg_wallpapers_source_constructed; - object_class->dispose = bg_wallpapers_source_dispose; -} - -BgWallpapersSource * -bg_wallpapers_source_new (GtkWidget *window) -{ - return g_object_new (BG_TYPE_WALLPAPERS_SOURCE, "window", window, NULL); -} - diff --git a/panels/background/bg-wallpapers-source.h b/panels/background/bg-wallpapers-source.h deleted file mode 100644 index 3d0d2e0f9..000000000 --- a/panels/background/bg-wallpapers-source.h +++ /dev/null @@ -1,38 +0,0 @@ -/* bg-wallpapers-source.h */ -/* - * Copyright (C) 2010 Intel, Inc - * - * 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 2 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 <http://www.gnu.org/licenses/>. - * - * Author: Thomas Wood <thomas.wood@intel.com> - * - */ - - -#ifndef _BG_WALLPAPERS_SOURCE_H -#define _BG_WALLPAPERS_SOURCE_H - -#include <gtk/gtk.h> -#include "bg-source.h" - -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 (GtkWidget *); - -G_END_DECLS - -#endif /* _BG_WALLPAPERS_SOURCE_H */ diff --git a/panels/background/cc-background-grid-item.c b/panels/background/cc-background-grid-item.c index 33ea52d35..e6c10000f 100644 --- a/panels/background/cc-background-grid-item.c +++ b/panels/background/cc-background-grid-item.c @@ -46,9 +46,10 @@ G_DEFINE_TYPE (CcBackgroundGridItem, cc_background_grid_item, GTK_TYPE_DRAWING_A }; static GdkPixbuf * -load_slideshow_emblem (CcBackgroundGridItem *item, gint scale_factor) +load_slideshow_emblem (CcBackgroundGridItem *item, + gint scale_factor) { - GdkPixbuf *slideshow_emblem; + GdkPixbuf *slideshow_emblem = NULL; GIcon *icon = NULL; GtkIconInfo *icon_info = NULL; GError *error = NULL; @@ -113,9 +114,9 @@ add_slideshow_emblem (CcBackgroundGridItem *item, } static void -on_gallery_item_size_allocate (GtkWidget *widget, +on_gallery_item_size_allocate (GtkWidget *widget, GdkRectangle *allocation, - gpointer *pointer) + gpointer pointer) { CcBackgroundGridItem *item = (CcBackgroundGridItem *) widget; GdkPixbuf *resized_pixbuf; @@ -206,7 +207,7 @@ cc_background_grid_item_dispose (GObject *object) static void cc_background_grid_item_set_property (GObject *object, - guint prop_id, + guint prop_id, const GValue *value, GParamSpec *pspec) { @@ -228,7 +229,7 @@ cc_background_grid_item_set_property (GObject *object, static void cc_background_grid_item_get_property (GObject *object, - guint prop_id, + guint prop_id, GValue *value, GParamSpec *pspec) { diff --git a/panels/background/cc-background-item.c b/panels/background/cc-background-item.c index c547cb150..db1d4691a 100644 --- a/panels/background/cc-background-item.c +++ b/panels/background/cc-background-item.c @@ -83,7 +83,9 @@ G_DEFINE_TYPE (CcBackgroundItem, cc_background_item, G_TYPE_OBJECT) static GdkPixbuf *slideshow_emblem = NULL; static GdkPixbuf * -get_emblemed_pixbuf (CcBackgroundItem *item, GdkPixbuf *pixbuf, gint scale_factor) +get_emblemed_pixbuf (CcBackgroundItem *item, + GdkPixbuf *pixbuf, + gint scale_factor) { int eh; int ew; @@ -201,8 +203,8 @@ update_size (CcBackgroundItem *item) static GdkPixbuf * render_at_size (GnomeBG *bg, - gint width, - gint height) + gint width, + gint height) { GdkPixbuf *pixbuf; diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c index 2d6978358..1e2512a54 100644 --- a/panels/background/cc-background-panel.c +++ b/panels/background/cc-background-panel.c @@ -14,7 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. * - * Author: Thomas Wood <thomas.wood@intel.com> + * Authors: Thomas Wood <thomas.wood@intel.com> + * Julian Sparber <julian@sparber.net> * */ @@ -208,7 +209,7 @@ on_preview_draw (GtkWidget *widget, } static void -on_panel_resize (GtkWidget *widget, +on_panel_resize (GtkWidget *widget, GdkRectangle *allocation, gpointer user_data) { @@ -226,7 +227,7 @@ on_panel_resize (GtkWidget *widget, static void reload_current_bg (CcBackgroundPanel *panel, - GSettings *settings) + GSettings *settings) { g_autoptr(CcBackgroundItem) saved = NULL; CcBackgroundItem *configured; @@ -390,7 +391,7 @@ on_background_select (GtkFlowBox *box, static void on_open_gnome_photos (GtkWidget *widget, - gpointer user_data) + gpointer user_data) { g_autoptr(GAppLaunchContext) context = NULL; g_autoptr(GDesktopAppInfo) appInfo = NULL; @@ -410,7 +411,7 @@ on_open_gnome_photos (GtkWidget *widget, static void on_open_picture_folder (GtkWidget *widget, - gpointer user_data) + gpointer user_data) { g_autoptr(GDBusProxy) proxy = NULL; g_autoptr(GVariant) retval = NULL; diff --git a/panels/background/cc-background-store.c b/panels/background/cc-background-store.c index 1d11d89d6..a9dfeb9d1 100644 --- a/panels/background/cc-background-store.c +++ b/panels/background/cc-background-store.c @@ -54,19 +54,18 @@ cc_background_store_finalize (GObject *gobject) G_OBJECT_CLASS (cc_background_store_parent_class)->finalize (gobject); } - static void item_added (CcBackgroundXml *xml, CcBackgroundItem *item, - CcBackgroundStore *self) + CcBackgroundStore *self) { g_list_store_append (self->model, item); } static void -list_load_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) +list_load_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) { cc_background_xml_load_list_finish (res); } @@ -96,18 +95,18 @@ cc_background_store_init (CcBackgroundStore *self) } void -cc_background_store_bind_flow_box (CcBackgroundStore *self, - gpointer panel, - GtkWidget *widget, - GtkFlowBoxCreateWidgetFunc create_widget_fun) { +cc_background_store_bind_flow_box (CcBackgroundStore *self, + gpointer panel, + GtkWidget *widget, + GtkFlowBoxCreateWidgetFunc create_widget_fun) +{ gtk_flow_box_bind_model (GTK_FLOW_BOX (widget), - G_LIST_MODEL(self->model), + G_LIST_MODEL (self->model), create_widget_fun, panel, NULL); } - CcBackgroundStore * cc_background_store_new () { diff --git a/panels/background/cc-background-xml.h b/panels/background/cc-background-xml.h index bf0687f78..ccaada496 100644 --- a/panels/background/cc-background-xml.h +++ b/panels/background/cc-background-xml.h @@ -31,17 +31,17 @@ G_DECLARE_FINAL_TYPE (CcBackgroundXml, cc_background_xml, CC, BACKGROUND_XML, GO CcBackgroundXml *cc_background_xml_new (void); -void cc_background_xml_save (CcBackgroundItem *item, - const char *filename); - -CcBackgroundItem *cc_background_xml_get_item (const char *filename); -gboolean cc_background_xml_load_xml (CcBackgroundXml *data, - const char *filename); -void cc_background_xml_load_list_async (CcBackgroundXml *data, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -const GHashTable *cc_background_xml_load_list_finish (GAsyncResult *async_result); +void cc_background_xml_save (CcBackgroundItem *item, + const char *filename); + +CcBackgroundItem *cc_background_xml_get_item (const char *filename); +gboolean cc_background_xml_load_xml (CcBackgroundXml *data, + const char *filename); +void cc_background_xml_load_list_async (CcBackgroundXml *data, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +const GHashTable *cc_background_xml_load_list_finish (GAsyncResult *async_result); G_END_DECLS diff --git a/panels/background/meson.build b/panels/background/meson.build index faa44830f..64f55f988 100644 --- a/panels/background/meson.build +++ b/panels/background/meson.build @@ -58,8 +58,6 @@ common_sources += gnome.compile_resources( ) sources = common_sources + files( - 'bg-source.c', - 'bg-wallpapers-source.c', 'cc-background-item.c', 'cc-background-grid-item.c', 'cc-background-store.c', |