background: Use G_DEFINE_TYPE
This commit is contained in:
parent
045b1f03b9
commit
378e837a06
18 changed files with 441 additions and 760 deletions
|
@ -28,10 +28,12 @@
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include <gdesktop-enums.h>
|
#include <gdesktop-enums.h>
|
||||||
|
|
||||||
G_DEFINE_TYPE (BgColorsSource, bg_colors_source, BG_TYPE_SOURCE)
|
struct _BgColorsSource
|
||||||
|
{
|
||||||
|
BgSource parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
#define COLORS_SOURCE_PRIVATE(o) \
|
G_DEFINE_TYPE (BgColorsSource, bg_colors_source, BG_TYPE_SOURCE)
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_COLORS_SOURCE, BgColorsSourcePrivate))
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GDesktopBackgroundShading type;
|
GDesktopBackgroundShading type;
|
||||||
|
|
|
@ -27,42 +27,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define BG_TYPE_COLORS_SOURCE bg_colors_source_get_type()
|
#define BG_TYPE_COLORS_SOURCE (bg_colors_source_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (BgColorsSource, bg_colors_source, BG, COLORS_SOURCE, BgSource)
|
||||||
#define BG_COLORS_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
BG_TYPE_COLORS_SOURCE, BgColorsSource))
|
|
||||||
|
|
||||||
#define BG_COLORS_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
BG_TYPE_COLORS_SOURCE, BgColorsSourceClass))
|
|
||||||
|
|
||||||
#define BG_IS_COLORS_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
BG_TYPE_COLORS_SOURCE))
|
|
||||||
|
|
||||||
#define BG_IS_COLORS_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
BG_TYPE_COLORS_SOURCE))
|
|
||||||
|
|
||||||
#define BG_COLORS_SOURCE_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
BG_TYPE_COLORS_SOURCE, BgColorsSourceClass))
|
|
||||||
|
|
||||||
typedef struct _BgColorsSource BgColorsSource;
|
|
||||||
typedef struct _BgColorsSourceClass BgColorsSourceClass;
|
|
||||||
|
|
||||||
struct _BgColorsSource
|
|
||||||
{
|
|
||||||
BgSource parent;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _BgColorsSourceClass
|
|
||||||
{
|
|
||||||
BgSourceClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType bg_colors_source_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
BgColorsSource *bg_colors_source_new (GtkWindow *window);
|
BgColorsSource *bg_colors_source_new (GtkWindow *window);
|
||||||
|
|
||||||
|
|
|
@ -33,17 +33,14 @@
|
||||||
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
|
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
|
||||||
#include <gdesktop-enums.h>
|
#include <gdesktop-enums.h>
|
||||||
|
|
||||||
G_DEFINE_TYPE (BgPicturesSource, bg_pictures_source, BG_TYPE_SOURCE)
|
|
||||||
|
|
||||||
#define PICTURES_SOURCE_PRIVATE(o) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_PICTURES_SOURCE, BgPicturesSourcePrivate))
|
|
||||||
|
|
||||||
#define ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_NAME "," \
|
#define ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_NAME "," \
|
||||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," \
|
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," \
|
||||||
G_FILE_ATTRIBUTE_TIME_MODIFIED
|
G_FILE_ATTRIBUTE_TIME_MODIFIED
|
||||||
|
|
||||||
struct _BgPicturesSourcePrivate
|
struct _BgPicturesSource
|
||||||
{
|
{
|
||||||
|
BgSource parent_instance;
|
||||||
|
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
|
|
||||||
CcBackgroundGriloMiner *grl_miner;
|
CcBackgroundGriloMiner *grl_miner;
|
||||||
|
@ -56,6 +53,8 @@ struct _BgPicturesSourcePrivate
|
||||||
GHashTable *known_items;
|
GHashTable *known_items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (BgPicturesSource, bg_pictures_source, BG_TYPE_SOURCE)
|
||||||
|
|
||||||
const char * const content_types[] = {
|
const char * const content_types[] = {
|
||||||
"image/png",
|
"image/png",
|
||||||
"image/jp2",
|
"image/jp2",
|
||||||
|
@ -78,16 +77,16 @@ static void picture_opened_for_read (GObject *source_object, GAsyncResult *res,
|
||||||
static void
|
static void
|
||||||
bg_pictures_source_dispose (GObject *object)
|
bg_pictures_source_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
BgPicturesSourcePrivate *priv = BG_PICTURES_SOURCE (object)->priv;
|
BgPicturesSource *source = BG_PICTURES_SOURCE (object);
|
||||||
|
|
||||||
if (priv->cancellable)
|
if (source->cancellable)
|
||||||
{
|
{
|
||||||
g_cancellable_cancel (priv->cancellable);
|
g_cancellable_cancel (source->cancellable);
|
||||||
g_clear_object (&priv->cancellable);
|
g_clear_object (&source->cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&priv->grl_miner);
|
g_clear_object (&source->grl_miner);
|
||||||
g_clear_object (&priv->thumb_factory);
|
g_clear_object (&source->thumb_factory);
|
||||||
|
|
||||||
G_OBJECT_CLASS (bg_pictures_source_parent_class)->dispose (object);
|
G_OBJECT_CLASS (bg_pictures_source_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -97,12 +96,12 @@ bg_pictures_source_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
BgPicturesSource *bg_source = BG_PICTURES_SOURCE (object);
|
BgPicturesSource *bg_source = BG_PICTURES_SOURCE (object);
|
||||||
|
|
||||||
g_clear_object (&bg_source->priv->thumb_factory);
|
g_clear_object (&bg_source->thumb_factory);
|
||||||
|
|
||||||
g_clear_pointer (&bg_source->priv->known_items, g_hash_table_destroy);
|
g_clear_pointer (&bg_source->known_items, g_hash_table_destroy);
|
||||||
|
|
||||||
g_clear_object (&bg_source->priv->picture_dir_monitor);
|
g_clear_object (&bg_source->picture_dir_monitor);
|
||||||
g_clear_object (&bg_source->priv->cache_dir_monitor);
|
g_clear_object (&bg_source->cache_dir_monitor);
|
||||||
|
|
||||||
G_OBJECT_CLASS (bg_pictures_source_parent_class)->finalize (object);
|
G_OBJECT_CLASS (bg_pictures_source_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -112,8 +111,6 @@ bg_pictures_source_class_init (BgPicturesSourceClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (BgPicturesSourcePrivate));
|
|
||||||
|
|
||||||
object_class->dispose = bg_pictures_source_dispose;
|
object_class->dispose = bg_pictures_source_dispose;
|
||||||
object_class->finalize = bg_pictures_source_finalize;
|
object_class->finalize = bg_pictures_source_finalize;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +228,7 @@ picture_scaled (GObject *source_object,
|
||||||
g_object_set_data (G_OBJECT (item), "needs-rotation", GINT_TO_POINTER (TRUE));
|
g_object_set_data (G_OBJECT (item), "needs-rotation", GINT_TO_POINTER (TRUE));
|
||||||
g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref);
|
g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref);
|
||||||
g_file_read_async (G_FILE (file), G_PRIORITY_DEFAULT,
|
g_file_read_async (G_FILE (file), G_PRIORITY_DEFAULT,
|
||||||
bg_source->priv->cancellable,
|
bg_source->cancellable,
|
||||||
picture_opened_for_read, bg_source);
|
picture_opened_for_read, bg_source);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -264,7 +261,7 @@ picture_scaled (GObject *source_object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_insert (bg_source->priv->known_items,
|
g_hash_table_insert (bg_source->known_items,
|
||||||
bg_pictures_source_get_unique_filename (uri),
|
bg_pictures_source_get_unique_filename (uri),
|
||||||
GINT_TO_POINTER (TRUE));
|
GINT_TO_POINTER (TRUE));
|
||||||
|
|
||||||
|
@ -326,7 +323,7 @@ picture_opened_for_read (GObject *source_object,
|
||||||
gdk_pixbuf_new_from_stream_at_scale_async (G_INPUT_STREAM (stream),
|
gdk_pixbuf_new_from_stream_at_scale_async (G_INPUT_STREAM (stream),
|
||||||
thumbnail_width, thumbnail_height,
|
thumbnail_width, thumbnail_height,
|
||||||
TRUE,
|
TRUE,
|
||||||
bg_source->priv->cancellable,
|
bg_source->cancellable,
|
||||||
picture_scaled, bg_source);
|
picture_scaled, bg_source);
|
||||||
g_object_unref (stream);
|
g_object_unref (stream);
|
||||||
}
|
}
|
||||||
|
@ -364,7 +361,7 @@ picture_copied_for_read (GObject *source_object,
|
||||||
g_object_set_data_full (G_OBJECT (native_file), "item", g_object_ref (item), g_object_unref);
|
g_object_set_data_full (G_OBJECT (native_file), "item", g_object_ref (item), g_object_unref);
|
||||||
g_file_read_async (native_file,
|
g_file_read_async (native_file,
|
||||||
G_PRIORITY_DEFAULT,
|
G_PRIORITY_DEFAULT,
|
||||||
bg_source->priv->cancellable,
|
bg_source->cancellable,
|
||||||
picture_opened_for_read,
|
picture_opened_for_read,
|
||||||
bg_source);
|
bg_source);
|
||||||
|
|
||||||
|
@ -543,7 +540,7 @@ add_single_file (BgPicturesSource *bg_source,
|
||||||
{
|
{
|
||||||
g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref);
|
g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref);
|
||||||
g_file_read_async (file, G_PRIORITY_DEFAULT,
|
g_file_read_async (file, G_PRIORITY_DEFAULT,
|
||||||
bg_source->priv->cancellable,
|
bg_source->cancellable,
|
||||||
picture_opened_for_read, bg_source);
|
picture_opened_for_read, bg_source);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -576,7 +573,7 @@ add_single_file (BgPicturesSource *bg_source,
|
||||||
native_file,
|
native_file,
|
||||||
G_FILE_COPY_ALL_METADATA,
|
G_FILE_COPY_ALL_METADATA,
|
||||||
G_PRIORITY_DEFAULT,
|
G_PRIORITY_DEFAULT,
|
||||||
bg_source->priv->cancellable,
|
bg_source->cancellable,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
picture_copied_for_read,
|
picture_copied_for_read,
|
||||||
|
@ -689,7 +686,7 @@ bg_pictures_source_remove (BgPicturesSource *bg_source,
|
||||||
{
|
{
|
||||||
char *uuid;
|
char *uuid;
|
||||||
uuid = bg_pictures_source_get_unique_filename (uri);
|
uuid = bg_pictures_source_get_unique_filename (uri);
|
||||||
g_hash_table_insert (bg_source->priv->known_items,
|
g_hash_table_insert (bg_source->known_items,
|
||||||
uuid, NULL);
|
uuid, NULL);
|
||||||
|
|
||||||
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
|
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
|
||||||
|
@ -763,15 +760,15 @@ file_info_async_ready (GObject *source,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dir_enum_async_ready (GObject *source,
|
dir_enum_async_ready (GObject *s,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
BgPicturesSourcePrivate *priv;
|
BgPicturesSource *source = (BgPicturesSource *) user_data;
|
||||||
GFileEnumerator *enumerator;
|
GFileEnumerator *enumerator;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
enumerator = g_file_enumerate_children_finish (G_FILE (source), res, &err);
|
enumerator = g_file_enumerate_children_finish (G_FILE (s), res, &err);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
|
@ -781,13 +778,11 @@ dir_enum_async_ready (GObject *source,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = BG_PICTURES_SOURCE (user_data)->priv;
|
|
||||||
|
|
||||||
/* get the files */
|
/* get the files */
|
||||||
g_file_enumerator_next_files_async (enumerator,
|
g_file_enumerator_next_files_async (enumerator,
|
||||||
G_MAXINT,
|
G_MAXINT,
|
||||||
G_PRIORITY_LOW,
|
G_PRIORITY_LOW,
|
||||||
priv->cancellable,
|
source->cancellable,
|
||||||
file_info_async_ready,
|
file_info_async_ready,
|
||||||
user_data);
|
user_data);
|
||||||
g_object_unref (enumerator);
|
g_object_unref (enumerator);
|
||||||
|
@ -846,7 +841,7 @@ bg_pictures_source_is_known (BgPicturesSource *bg_source,
|
||||||
char *uuid;
|
char *uuid;
|
||||||
|
|
||||||
uuid = bg_pictures_source_get_unique_filename (uri);
|
uuid = bg_pictures_source_get_unique_filename (uri);
|
||||||
retval = (GPOINTER_TO_INT (g_hash_table_lookup (bg_source->priv->known_items, uuid)));
|
retval = (GPOINTER_TO_INT (g_hash_table_lookup (bg_source->known_items, uuid)));
|
||||||
g_free (uuid);
|
g_free (uuid);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -969,12 +964,12 @@ monitor_path (BgPicturesSource *self,
|
||||||
g_file_enumerate_children_async (dir,
|
g_file_enumerate_children_async (dir,
|
||||||
ATTRIBUTES,
|
ATTRIBUTES,
|
||||||
G_FILE_QUERY_INFO_NONE,
|
G_FILE_QUERY_INFO_NONE,
|
||||||
G_PRIORITY_LOW, self->priv->cancellable,
|
G_PRIORITY_LOW, self->cancellable,
|
||||||
dir_enum_async_ready, self);
|
dir_enum_async_ready, self);
|
||||||
|
|
||||||
monitor = g_file_monitor_directory (dir,
|
monitor = g_file_monitor_directory (dir,
|
||||||
G_FILE_MONITOR_NONE,
|
G_FILE_MONITOR_NONE,
|
||||||
self->priv->cancellable,
|
self->cancellable,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (monitor)
|
if (monitor)
|
||||||
|
@ -1004,14 +999,11 @@ static void
|
||||||
bg_pictures_source_init (BgPicturesSource *self)
|
bg_pictures_source_init (BgPicturesSource *self)
|
||||||
{
|
{
|
||||||
const gchar *pictures_path;
|
const gchar *pictures_path;
|
||||||
BgPicturesSourcePrivate *priv;
|
|
||||||
char *cache_path;
|
char *cache_path;
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
|
|
||||||
priv = self->priv = PICTURES_SOURCE_PRIVATE (self);
|
self->cancellable = g_cancellable_new ();
|
||||||
|
self->known_items = g_hash_table_new_full (g_str_hash,
|
||||||
priv->cancellable = g_cancellable_new ();
|
|
||||||
priv->known_items = g_hash_table_new_full (g_str_hash,
|
|
||||||
g_str_equal,
|
g_str_equal,
|
||||||
(GDestroyNotify) g_free,
|
(GDestroyNotify) g_free,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -1020,17 +1012,17 @@ bg_pictures_source_init (BgPicturesSource *self)
|
||||||
if (pictures_path == NULL)
|
if (pictures_path == NULL)
|
||||||
pictures_path = g_get_home_dir ();
|
pictures_path = g_get_home_dir ();
|
||||||
|
|
||||||
priv->picture_dir_monitor = monitor_path (self, pictures_path);
|
self->picture_dir_monitor = monitor_path (self, pictures_path);
|
||||||
|
|
||||||
cache_path = bg_pictures_source_get_cache_path ();
|
cache_path = bg_pictures_source_get_cache_path ();
|
||||||
priv->cache_dir_monitor = monitor_path (self, cache_path);
|
self->cache_dir_monitor = monitor_path (self, cache_path);
|
||||||
g_free (cache_path);
|
g_free (cache_path);
|
||||||
|
|
||||||
priv->grl_miner = cc_background_grilo_miner_new ();
|
self->grl_miner = cc_background_grilo_miner_new ();
|
||||||
g_signal_connect_swapped (priv->grl_miner, "media-found", G_CALLBACK (media_found_cb), self);
|
g_signal_connect_swapped (self->grl_miner, "media-found", G_CALLBACK (media_found_cb), self);
|
||||||
cc_background_grilo_miner_start (priv->grl_miner);
|
cc_background_grilo_miner_start (self->grl_miner);
|
||||||
|
|
||||||
priv->thumb_factory =
|
self->thumb_factory =
|
||||||
gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
||||||
|
|
||||||
store = bg_source_get_liststore (BG_SOURCE (self));
|
store = bg_source_get_liststore (BG_SOURCE (self));
|
||||||
|
|
|
@ -29,45 +29,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define BG_TYPE_PICTURES_SOURCE bg_pictures_source_get_type()
|
#define BG_TYPE_PICTURES_SOURCE (bg_pictures_source_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (BgPicturesSource, bg_pictures_source, BG, PICTURES_SOURCE, BgSource)
|
||||||
#define BG_PICTURES_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
BG_TYPE_PICTURES_SOURCE, BgPicturesSource))
|
|
||||||
|
|
||||||
#define BG_PICTURES_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
BG_TYPE_PICTURES_SOURCE, BgPicturesSourceClass))
|
|
||||||
|
|
||||||
#define BG_IS_PICTURES_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
BG_TYPE_PICTURES_SOURCE))
|
|
||||||
|
|
||||||
#define BG_IS_PICTURES_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
BG_TYPE_PICTURES_SOURCE))
|
|
||||||
|
|
||||||
#define BG_PICTURES_SOURCE_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
BG_TYPE_PICTURES_SOURCE, BgPicturesSourceClass))
|
|
||||||
|
|
||||||
typedef struct _BgPicturesSource BgPicturesSource;
|
|
||||||
typedef struct _BgPicturesSourceClass BgPicturesSourceClass;
|
|
||||||
typedef struct _BgPicturesSourcePrivate BgPicturesSourcePrivate;
|
|
||||||
|
|
||||||
struct _BgPicturesSource
|
|
||||||
{
|
|
||||||
BgSource parent;
|
|
||||||
|
|
||||||
BgPicturesSourcePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _BgPicturesSourceClass
|
|
||||||
{
|
|
||||||
BgSourceClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType bg_pictures_source_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
BgPicturesSource *bg_pictures_source_new (GtkWindow *window);
|
BgPicturesSource *bg_pictures_source_new (GtkWindow *window);
|
||||||
char *bg_pictures_source_get_cache_path (void);
|
char *bg_pictures_source_get_cache_path (void);
|
||||||
|
|
|
@ -26,18 +26,15 @@
|
||||||
#define THUMBNAIL_WIDTH 256
|
#define THUMBNAIL_WIDTH 256
|
||||||
#define THUMBNAIL_HEIGHT (THUMBNAIL_WIDTH * 3 / 4)
|
#define THUMBNAIL_HEIGHT (THUMBNAIL_WIDTH * 3 / 4)
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (BgSource, bg_source, G_TYPE_OBJECT)
|
typedef struct
|
||||||
|
|
||||||
#define SOURCE_PRIVATE(o) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_SOURCE, BgSourcePrivate))
|
|
||||||
|
|
||||||
struct _BgSourcePrivate
|
|
||||||
{
|
{
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
gint thumbnail_height;
|
gint thumbnail_height;
|
||||||
gint thumbnail_width;
|
gint thumbnail_width;
|
||||||
};
|
} BgSourcePrivate;
|
||||||
|
|
||||||
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (BgSource, bg_source, G_TYPE_OBJECT)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -49,7 +46,7 @@ enum
|
||||||
static void
|
static void
|
||||||
bg_source_calculate_thumbnail_dimensions (BgSource *source)
|
bg_source_calculate_thumbnail_dimensions (BgSource *source)
|
||||||
{
|
{
|
||||||
BgSourcePrivate *priv = source->priv;
|
BgSourcePrivate *priv = bg_source_get_instance_private (source);
|
||||||
gint scale_factor;
|
gint scale_factor;
|
||||||
|
|
||||||
priv->thumbnail_height = THUMBNAIL_HEIGHT;
|
priv->thumbnail_height = THUMBNAIL_HEIGHT;
|
||||||
|
@ -99,7 +96,8 @@ bg_source_set_property (GObject *object,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
BgSourcePrivate *priv = BG_SOURCE (object)->priv;
|
BgSource *source = BG_SOURCE (object);
|
||||||
|
BgSourcePrivate *priv = bg_source_get_instance_private (source);
|
||||||
|
|
||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +113,8 @@ bg_source_set_property (GObject *object,
|
||||||
static void
|
static void
|
||||||
bg_source_dispose (GObject *object)
|
bg_source_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
BgSourcePrivate *priv = BG_SOURCE (object)->priv;
|
BgSource *source = BG_SOURCE (object);
|
||||||
|
BgSourcePrivate *priv = bg_source_get_instance_private (source);
|
||||||
|
|
||||||
g_clear_object (&priv->store);
|
g_clear_object (&priv->store);
|
||||||
|
|
||||||
|
@ -128,8 +127,6 @@ bg_source_class_init (BgSourceClass *klass)
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (BgSourcePrivate));
|
|
||||||
|
|
||||||
object_class->constructed = bg_source_constructed;
|
object_class->constructed = bg_source_constructed;
|
||||||
object_class->get_property = bg_source_get_property;
|
object_class->get_property = bg_source_get_property;
|
||||||
object_class->set_property = bg_source_set_property;
|
object_class->set_property = bg_source_set_property;
|
||||||
|
@ -153,41 +150,50 @@ bg_source_class_init (BgSourceClass *klass)
|
||||||
static void
|
static void
|
||||||
bg_source_init (BgSource *self)
|
bg_source_init (BgSource *self)
|
||||||
{
|
{
|
||||||
BgSourcePrivate *priv;
|
BgSourcePrivate *priv = bg_source_get_instance_private (self);
|
||||||
|
|
||||||
priv = self->priv = SOURCE_PRIVATE (self);
|
|
||||||
|
|
||||||
priv->store = gtk_list_store_new (3, CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_OBJECT, G_TYPE_STRING);
|
priv->store = gtk_list_store_new (3, CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_OBJECT, G_TYPE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkListStore*
|
GtkListStore*
|
||||||
bg_source_get_liststore (BgSource *source)
|
bg_source_get_liststore (BgSource *source)
|
||||||
{
|
{
|
||||||
|
BgSourcePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (BG_IS_SOURCE (source), NULL);
|
g_return_val_if_fail (BG_IS_SOURCE (source), NULL);
|
||||||
|
|
||||||
return source->priv->store;
|
priv = bg_source_get_instance_private (source);
|
||||||
|
return priv->store;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
bg_source_get_scale_factor (BgSource *source)
|
bg_source_get_scale_factor (BgSource *source)
|
||||||
{
|
{
|
||||||
|
BgSourcePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (BG_IS_SOURCE (source), 1);
|
g_return_val_if_fail (BG_IS_SOURCE (source), 1);
|
||||||
|
|
||||||
return gtk_widget_get_scale_factor (source->priv->window);
|
priv = bg_source_get_instance_private (source);
|
||||||
|
return gtk_widget_get_scale_factor (priv->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
bg_source_get_thumbnail_height (BgSource *source)
|
bg_source_get_thumbnail_height (BgSource *source)
|
||||||
{
|
{
|
||||||
|
BgSourcePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (BG_IS_SOURCE (source), THUMBNAIL_HEIGHT);
|
g_return_val_if_fail (BG_IS_SOURCE (source), THUMBNAIL_HEIGHT);
|
||||||
|
|
||||||
return source->priv->thumbnail_height;
|
priv = bg_source_get_instance_private (source);
|
||||||
|
return priv->thumbnail_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
bg_source_get_thumbnail_width (BgSource *source)
|
bg_source_get_thumbnail_width (BgSource *source)
|
||||||
{
|
{
|
||||||
|
BgSourcePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (BG_IS_SOURCE (source), THUMBNAIL_WIDTH);
|
g_return_val_if_fail (BG_IS_SOURCE (source), THUMBNAIL_WIDTH);
|
||||||
|
|
||||||
return source->priv->thumbnail_width;
|
priv = bg_source_get_instance_private (source);
|
||||||
|
return priv->thumbnail_width;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,46 +25,14 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define BG_TYPE_SOURCE bg_source_get_type()
|
#define BG_TYPE_SOURCE (bg_source_get_type ())
|
||||||
|
G_DECLARE_DERIVABLE_TYPE (BgSource, bg_source, BG, SOURCE, GObject)
|
||||||
#define BG_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
BG_TYPE_SOURCE, BgSource))
|
|
||||||
|
|
||||||
#define BG_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
BG_TYPE_SOURCE, BgSourceClass))
|
|
||||||
|
|
||||||
#define BG_IS_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
BG_TYPE_SOURCE))
|
|
||||||
|
|
||||||
#define BG_IS_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
BG_TYPE_SOURCE))
|
|
||||||
|
|
||||||
#define BG_SOURCE_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
BG_TYPE_SOURCE, BgSourceClass))
|
|
||||||
|
|
||||||
typedef struct _BgSource BgSource;
|
|
||||||
typedef struct _BgSourceClass BgSourceClass;
|
|
||||||
typedef struct _BgSourcePrivate BgSourcePrivate;
|
|
||||||
|
|
||||||
struct _BgSource
|
|
||||||
{
|
|
||||||
GObject parent;
|
|
||||||
|
|
||||||
BgSourcePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _BgSourceClass
|
struct _BgSourceClass
|
||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType bg_source_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GtkListStore* bg_source_get_liststore (BgSource *source);
|
GtkListStore* bg_source_get_liststore (BgSource *source);
|
||||||
|
|
||||||
gint bg_source_get_scale_factor (BgSource *source);
|
gint bg_source_get_scale_factor (BgSource *source);
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "bg-wallpapers-source.h"
|
#include "bg-wallpapers-source.h"
|
||||||
|
|
||||||
#include "cc-background-item.h"
|
#include "cc-background-item.h"
|
||||||
|
@ -29,24 +28,20 @@
|
||||||
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
|
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
G_DEFINE_TYPE (BgWallpapersSource, bg_wallpapers_source, BG_TYPE_SOURCE)
|
struct _BgWallpapersSource
|
||||||
|
|
||||||
#define WALLPAPERS_SOURCE_PRIVATE(o) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_WALLPAPERS_SOURCE, BgWallpapersSourcePrivate))
|
|
||||||
|
|
||||||
struct _BgWallpapersSourcePrivate
|
|
||||||
{
|
{
|
||||||
|
BgSource parent_instance;
|
||||||
GnomeDesktopThumbnailFactory *thumb_factory;
|
GnomeDesktopThumbnailFactory *thumb_factory;
|
||||||
CcBackgroundXml *xml;
|
CcBackgroundXml *xml;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (BgWallpapersSource, bg_wallpapers_source, BG_TYPE_SOURCE)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_wallpapers (gchar *key,
|
load_wallpapers (gchar *key,
|
||||||
CcBackgroundItem *item,
|
CcBackgroundItem *item,
|
||||||
BgWallpapersSource *source)
|
BgWallpapersSource *source)
|
||||||
{
|
{
|
||||||
BgWallpapersSourcePrivate *priv = source->priv;
|
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source));
|
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source));
|
||||||
|
@ -66,7 +61,7 @@ load_wallpapers (gchar *key,
|
||||||
scale_factor = bg_source_get_scale_factor (BG_SOURCE (source));
|
scale_factor = bg_source_get_scale_factor (BG_SOURCE (source));
|
||||||
thumbnail_height = bg_source_get_thumbnail_height (BG_SOURCE (source));
|
thumbnail_height = bg_source_get_thumbnail_height (BG_SOURCE (source));
|
||||||
thumbnail_width = bg_source_get_thumbnail_width (BG_SOURCE (source));
|
thumbnail_width = bg_source_get_thumbnail_width (BG_SOURCE (source));
|
||||||
pixbuf = cc_background_item_get_thumbnail (item, priv->thumb_factory,
|
pixbuf = cc_background_item_get_thumbnail (item, source->thumb_factory,
|
||||||
thumbnail_width, thumbnail_height,
|
thumbnail_width, thumbnail_height,
|
||||||
scale_factor);
|
scale_factor);
|
||||||
if (pixbuf == NULL)
|
if (pixbuf == NULL)
|
||||||
|
@ -116,7 +111,7 @@ load_default_bg (BgWallpapersSource *self)
|
||||||
"gnome-background-properties",
|
"gnome-background-properties",
|
||||||
"adwaita.xml",
|
"adwaita.xml",
|
||||||
NULL);
|
NULL);
|
||||||
if (cc_background_xml_load_xml (self->priv->xml, filename)) {
|
if (cc_background_xml_load_xml (self->xml, filename)) {
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -128,26 +123,25 @@ static void
|
||||||
bg_wallpapers_source_constructed (GObject *object)
|
bg_wallpapers_source_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
BgWallpapersSource *self = BG_WALLPAPERS_SOURCE (object);
|
BgWallpapersSource *self = BG_WALLPAPERS_SOURCE (object);
|
||||||
BgWallpapersSourcePrivate *priv = self->priv;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->constructed (object);
|
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->constructed (object);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (priv->xml), "added",
|
g_signal_connect (G_OBJECT (self->xml), "added",
|
||||||
G_CALLBACK (item_added), self);
|
G_CALLBACK (item_added), self);
|
||||||
|
|
||||||
/* Try adding the default background first */
|
/* Try adding the default background first */
|
||||||
load_default_bg (self);
|
load_default_bg (self);
|
||||||
|
|
||||||
cc_background_xml_load_list_async (priv->xml, NULL, list_load_cb, self);
|
cc_background_xml_load_list_async (self->xml, NULL, list_load_cb, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bg_wallpapers_source_dispose (GObject *object)
|
bg_wallpapers_source_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
BgWallpapersSourcePrivate *priv = BG_WALLPAPERS_SOURCE (object)->priv;
|
BgWallpapersSource *self = BG_WALLPAPERS_SOURCE (object);
|
||||||
|
|
||||||
g_clear_object (&priv->thumb_factory);
|
g_clear_object (&self->thumb_factory);
|
||||||
g_clear_object (&priv->xml);
|
g_clear_object (&self->xml);
|
||||||
|
|
||||||
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->dispose (object);
|
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -155,13 +149,9 @@ bg_wallpapers_source_dispose (GObject *object)
|
||||||
static void
|
static void
|
||||||
bg_wallpapers_source_init (BgWallpapersSource *self)
|
bg_wallpapers_source_init (BgWallpapersSource *self)
|
||||||
{
|
{
|
||||||
BgWallpapersSourcePrivate *priv;
|
self->thumb_factory =
|
||||||
|
|
||||||
priv = self->priv = WALLPAPERS_SOURCE_PRIVATE (self);
|
|
||||||
|
|
||||||
priv->thumb_factory =
|
|
||||||
gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
||||||
priv->xml = cc_background_xml_new ();
|
self->xml = cc_background_xml_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -169,8 +159,6 @@ bg_wallpapers_source_class_init (BgWallpapersSourceClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (BgWallpapersSourcePrivate));
|
|
||||||
|
|
||||||
object_class->constructed = bg_wallpapers_source_constructed;
|
object_class->constructed = bg_wallpapers_source_constructed;
|
||||||
object_class->dispose = bg_wallpapers_source_dispose;
|
object_class->dispose = bg_wallpapers_source_dispose;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,45 +28,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define BG_TYPE_WALLPAPERS_SOURCE bg_wallpapers_source_get_type()
|
#define BG_TYPE_WALLPAPERS_SOURCE (bg_wallpapers_source_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (BgWallpapersSource, bg_wallpapers_source, BG, WALLPAPERS_SOURCE, BgSource)
|
||||||
#define BG_WALLPAPERS_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
BG_TYPE_WALLPAPERS_SOURCE, BgWallpapersSource))
|
|
||||||
|
|
||||||
#define BG_WALLPAPERS_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
BG_TYPE_WALLPAPERS_SOURCE, BgWallpapersSourceClass))
|
|
||||||
|
|
||||||
#define BG_IS_WALLPAPERS_SOURCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
BG_TYPE_WALLPAPERS_SOURCE))
|
|
||||||
|
|
||||||
#define BG_IS_WALLPAPERS_SOURCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
BG_TYPE_WALLPAPERS_SOURCE))
|
|
||||||
|
|
||||||
#define BG_WALLPAPERS_SOURCE_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
BG_TYPE_WALLPAPERS_SOURCE, BgWallpapersSourceClass))
|
|
||||||
|
|
||||||
typedef struct _BgWallpapersSource BgWallpapersSource;
|
|
||||||
typedef struct _BgWallpapersSourceClass BgWallpapersSourceClass;
|
|
||||||
typedef struct _BgWallpapersSourcePrivate BgWallpapersSourcePrivate;
|
|
||||||
|
|
||||||
struct _BgWallpapersSource
|
|
||||||
{
|
|
||||||
BgSource parent;
|
|
||||||
|
|
||||||
BgWallpapersSourcePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _BgWallpapersSourceClass
|
|
||||||
{
|
|
||||||
BgSourceClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType bg_wallpapers_source_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
BgWallpapersSource *bg_wallpapers_source_new (GtkWindow *window);
|
BgWallpapersSource *bg_wallpapers_source_new (GtkWindow *window);
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,10 @@ enum
|
||||||
SOURCE_COLORS,
|
SOURCE_COLORS,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CcBackgroundChooserDialogPrivate
|
struct _CcBackgroundChooserDialog
|
||||||
{
|
{
|
||||||
|
GtkDialog parent_instance;
|
||||||
|
|
||||||
GtkListStore *sources;
|
GtkListStore *sources;
|
||||||
GtkWidget *stack;
|
GtkWidget *stack;
|
||||||
GtkWidget *pictures_stack;
|
GtkWidget *pictures_stack;
|
||||||
|
@ -67,7 +69,7 @@ struct _CcBackgroundChooserDialogPrivate
|
||||||
gulong row_modified_id;
|
gulong row_modified_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CC_CHOOSER_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TYPE_BACKGROUND_CHOOSER_DIALOG, CcBackgroundChooserDialogPrivate))
|
G_DEFINE_TYPE (CcBackgroundChooserDialog, cc_background_chooser_dialog, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -85,8 +87,6 @@ static const GtkTargetEntry color_targets[] =
|
||||||
{ "application/x-color", 0, COLOR }
|
{ "application/x-color", 0, COLOR }
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcBackgroundChooserDialog, cc_background_chooser_dialog, GTK_TYPE_DIALOG)
|
|
||||||
|
|
||||||
static void on_visible_child_notify (CcBackgroundChooserDialog *chooser);
|
static void on_visible_child_notify (CcBackgroundChooserDialog *chooser);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -117,14 +117,13 @@ static void
|
||||||
cc_background_chooser_dialog_dispose (GObject *object)
|
cc_background_chooser_dialog_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
CcBackgroundChooserDialog *chooser = CC_BACKGROUND_CHOOSER_DIALOG (object);
|
CcBackgroundChooserDialog *chooser = CC_BACKGROUND_CHOOSER_DIALOG (object);
|
||||||
CcBackgroundChooserDialogPrivate *priv = chooser->priv;
|
|
||||||
|
|
||||||
if (priv->copy_cancellable)
|
if (chooser->copy_cancellable)
|
||||||
{
|
{
|
||||||
/* cancel any copy operation */
|
/* cancel any copy operation */
|
||||||
g_cancellable_cancel (priv->copy_cancellable);
|
g_cancellable_cancel (chooser->copy_cancellable);
|
||||||
|
|
||||||
g_clear_object (&priv->copy_cancellable);
|
g_clear_object (&chooser->copy_cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GtkStack triggers notify::visible-child during dispose and this
|
/* GtkStack triggers notify::visible-child during dispose and this
|
||||||
|
@ -133,17 +132,17 @@ cc_background_chooser_dialog_dispose (GObject *object)
|
||||||
* on_visible_child_notify() will get called while we're in an
|
* on_visible_child_notify() will get called while we're in an
|
||||||
* inconsistent state.
|
* inconsistent state.
|
||||||
*/
|
*/
|
||||||
if (priv->stack != NULL)
|
if (chooser->stack != NULL)
|
||||||
{
|
{
|
||||||
g_signal_handlers_disconnect_by_func (priv->stack, on_visible_child_notify, chooser);
|
g_signal_handlers_disconnect_by_func (chooser->stack, on_visible_child_notify, chooser);
|
||||||
priv->stack = NULL;
|
chooser->stack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_pointer (&chooser->priv->item_to_focus, gtk_tree_row_reference_free);
|
g_clear_pointer (&chooser->item_to_focus, gtk_tree_row_reference_free);
|
||||||
g_clear_object (&priv->pictures_source);
|
g_clear_object (&chooser->pictures_source);
|
||||||
g_clear_object (&priv->colors_source);
|
g_clear_object (&chooser->colors_source);
|
||||||
g_clear_object (&priv->wallpapers_source);
|
g_clear_object (&chooser->wallpapers_source);
|
||||||
g_clear_object (&priv->thumb_factory);
|
g_clear_object (&chooser->thumb_factory);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_background_chooser_dialog_parent_class)->dispose (object);
|
G_OBJECT_CLASS (cc_background_chooser_dialog_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -151,11 +150,10 @@ cc_background_chooser_dialog_dispose (GObject *object)
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
get_visible_view (CcBackgroundChooserDialog *chooser)
|
get_visible_view (CcBackgroundChooserDialog *chooser)
|
||||||
{
|
{
|
||||||
CcBackgroundChooserDialogPrivate *priv = chooser->priv;
|
|
||||||
GtkWidget *visible;
|
GtkWidget *visible;
|
||||||
GtkWidget *icon_view = NULL;
|
GtkWidget *icon_view = NULL;
|
||||||
|
|
||||||
visible = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
|
visible = gtk_stack_get_visible_child (GTK_STACK (chooser->stack));
|
||||||
if (GTK_IS_STACK (visible))
|
if (GTK_IS_STACK (visible))
|
||||||
{
|
{
|
||||||
GtkWidget *sw;
|
GtkWidget *sw;
|
||||||
|
@ -183,11 +181,11 @@ possibly_show_empty_pictures_box (GtkTreeModel *model,
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||||
{
|
{
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (chooser->priv->pictures_stack), "view");
|
gtk_stack_set_visible_child_name (GTK_STACK (chooser->pictures_stack), "view");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (chooser->priv->pictures_stack), "empty");
|
gtk_stack_set_visible_child_name (GTK_STACK (chooser->pictures_stack), "empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,28 +195,27 @@ on_source_modified_cb (GtkTreeModel *tree_model,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
CcBackgroundChooserDialog *chooser = user_data;
|
||||||
GtkTreePath *to_focus_path;
|
GtkTreePath *to_focus_path;
|
||||||
GtkWidget *icon_view;
|
GtkWidget *icon_view;
|
||||||
CcBackgroundChooserDialog *chooser = user_data;
|
|
||||||
CcBackgroundChooserDialogPrivate *priv = chooser->priv;
|
|
||||||
|
|
||||||
if (chooser->priv->item_to_focus == NULL)
|
if (chooser->item_to_focus == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
to_focus_path = gtk_tree_row_reference_get_path (chooser->priv->item_to_focus);
|
to_focus_path = gtk_tree_row_reference_get_path (chooser->item_to_focus);
|
||||||
|
|
||||||
if (gtk_tree_path_compare (to_focus_path, path) != 0)
|
if (gtk_tree_path_compare (to_focus_path, path) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Change source */
|
/* Change source */
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "pictures");
|
gtk_stack_set_visible_child_name (GTK_STACK (chooser->stack), "pictures");
|
||||||
|
|
||||||
/* And select the newly added item */
|
/* And select the newly added item */
|
||||||
icon_view = get_visible_view (chooser);
|
icon_view = get_visible_view (chooser);
|
||||||
gtk_icon_view_select_path (GTK_ICON_VIEW (icon_view), to_focus_path);
|
gtk_icon_view_select_path (GTK_ICON_VIEW (icon_view), to_focus_path);
|
||||||
gtk_icon_view_scroll_to_path (GTK_ICON_VIEW (icon_view),
|
gtk_icon_view_scroll_to_path (GTK_ICON_VIEW (icon_view),
|
||||||
to_focus_path, TRUE, 1.0, 1.0);
|
to_focus_path, TRUE, 1.0, 1.0);
|
||||||
g_clear_pointer (&chooser->priv->item_to_focus, gtk_tree_row_reference_free);
|
g_clear_pointer (&chooser->item_to_focus, gtk_tree_row_reference_free);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gtk_tree_path_free (to_focus_path);
|
gtk_tree_path_free (to_focus_path);
|
||||||
|
@ -247,7 +244,7 @@ monitor_pictures_model (CcBackgroundChooserDialog *chooser)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
|
|
||||||
model = GTK_TREE_MODEL (bg_source_get_liststore (BG_SOURCE (chooser->priv->pictures_source)));
|
model = GTK_TREE_MODEL (bg_source_get_liststore (BG_SOURCE (chooser->pictures_source)));
|
||||||
|
|
||||||
g_signal_connect (model, "row-inserted", G_CALLBACK (on_source_added_cb), chooser);
|
g_signal_connect (model, "row-inserted", G_CALLBACK (on_source_added_cb), chooser);
|
||||||
g_signal_connect (model, "row-deleted", G_CALLBACK (on_source_removed_cb), chooser);
|
g_signal_connect (model, "row-deleted", G_CALLBACK (on_source_removed_cb), chooser);
|
||||||
|
@ -292,9 +289,9 @@ static void
|
||||||
add_custom_wallpaper (CcBackgroundChooserDialog *chooser,
|
add_custom_wallpaper (CcBackgroundChooserDialog *chooser,
|
||||||
const char *uri)
|
const char *uri)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&chooser->priv->item_to_focus, gtk_tree_row_reference_free);
|
g_clear_pointer (&chooser->item_to_focus, gtk_tree_row_reference_free);
|
||||||
|
|
||||||
bg_pictures_source_add (chooser->priv->pictures_source, uri, &chooser->priv->item_to_focus);
|
bg_pictures_source_add (chooser->pictures_source, uri, &chooser->item_to_focus);
|
||||||
/* and wait for the item to get added */
|
/* and wait for the item to get added */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,11 +323,11 @@ cc_background_panel_drag_color (CcBackgroundChooserDialog *chooser,
|
||||||
rgba.blue = dropped[2] / 65535.;
|
rgba.blue = dropped[2] / 65535.;
|
||||||
rgba.alpha = dropped[3] / 65535.;
|
rgba.alpha = dropped[3] / 65535.;
|
||||||
|
|
||||||
if (bg_colors_source_add (chooser->priv->colors_source, &rgba, &row_ref) == FALSE)
|
if (bg_colors_source_add (chooser->colors_source, &rgba, &row_ref) == FALSE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Change source */
|
/* Change source */
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (chooser->priv->stack), "colors");
|
gtk_stack_set_visible_child_name (GTK_STACK (chooser->stack), "colors");
|
||||||
|
|
||||||
/* And select the newly added item */
|
/* And select the newly added item */
|
||||||
to_focus_path = gtk_tree_row_reference_get_path (row_ref);
|
to_focus_path = gtk_tree_row_reference_get_path (row_ref);
|
||||||
|
@ -368,7 +365,7 @@ cc_background_panel_drag_items (GtkWidget *widget,
|
||||||
for (i = 0; uris[i] != NULL; i++)
|
for (i = 0; uris[i] != NULL; i++)
|
||||||
{
|
{
|
||||||
uri = uris[i];
|
uri = uris[i];
|
||||||
if (!bg_pictures_source_is_known (chooser->priv->pictures_source, uri))
|
if (!bg_pictures_source_is_known (chooser->pictures_source, uri))
|
||||||
{
|
{
|
||||||
add_custom_wallpaper (chooser, uri);
|
add_custom_wallpaper (chooser, uri);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
@ -418,37 +415,35 @@ static void
|
||||||
cc_background_chooser_dialog_constructed (GObject *object)
|
cc_background_chooser_dialog_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
CcBackgroundChooserDialog *chooser = CC_BACKGROUND_CHOOSER_DIALOG (object);
|
CcBackgroundChooserDialog *chooser = CC_BACKGROUND_CHOOSER_DIALOG (object);
|
||||||
CcBackgroundChooserDialogPrivate *priv = chooser->priv;
|
|
||||||
GtkListStore *model;
|
GtkListStore *model;
|
||||||
GtkWidget *sw;
|
GtkWidget *sw;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_background_chooser_dialog_parent_class)->constructed (object);
|
G_OBJECT_CLASS (cc_background_chooser_dialog_parent_class)->constructed (object);
|
||||||
|
|
||||||
model = bg_source_get_liststore (BG_SOURCE (priv->wallpapers_source));
|
model = bg_source_get_liststore (BG_SOURCE (chooser->wallpapers_source));
|
||||||
sw = create_view (chooser, GTK_TREE_MODEL (model));
|
sw = create_view (chooser, GTK_TREE_MODEL (model));
|
||||||
gtk_stack_add_titled (GTK_STACK (priv->stack), sw, "wallpapers", _("Wallpapers"));
|
gtk_stack_add_titled (GTK_STACK (chooser->stack), sw, "wallpapers", _("Wallpapers"));
|
||||||
gtk_container_child_set (GTK_CONTAINER (priv->stack), sw, "position", 0, NULL);
|
gtk_container_child_set (GTK_CONTAINER (chooser->stack), sw, "position", 0, NULL);
|
||||||
|
|
||||||
model = bg_source_get_liststore (BG_SOURCE (priv->pictures_source));
|
model = bg_source_get_liststore (BG_SOURCE (chooser->pictures_source));
|
||||||
sw = create_view (chooser, GTK_TREE_MODEL (model));
|
sw = create_view (chooser, GTK_TREE_MODEL (model));
|
||||||
gtk_stack_add_named (GTK_STACK (priv->pictures_stack), sw, "view");
|
gtk_stack_add_named (GTK_STACK (chooser->pictures_stack), sw, "view");
|
||||||
|
|
||||||
model = bg_source_get_liststore (BG_SOURCE (priv->colors_source));
|
model = bg_source_get_liststore (BG_SOURCE (chooser->colors_source));
|
||||||
sw = create_view (chooser, GTK_TREE_MODEL (model));
|
sw = create_view (chooser, GTK_TREE_MODEL (model));
|
||||||
gtk_stack_add_titled (GTK_STACK (priv->stack), sw, "colors", _("Colors"));
|
gtk_stack_add_titled (GTK_STACK (chooser->stack), sw, "colors", _("Colors"));
|
||||||
|
|
||||||
vbox = gtk_dialog_get_content_area (GTK_DIALOG (chooser));
|
vbox = gtk_dialog_get_content_area (GTK_DIALOG (chooser));
|
||||||
gtk_widget_show_all (vbox);
|
gtk_widget_show_all (vbox);
|
||||||
|
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "wallpapers");
|
gtk_stack_set_visible_child_name (GTK_STACK (chooser->stack), "wallpapers");
|
||||||
monitor_pictures_model (chooser);
|
monitor_pictures_model (chooser);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_background_chooser_dialog_init (CcBackgroundChooserDialog *chooser)
|
cc_background_chooser_dialog_init (CcBackgroundChooserDialog *chooser)
|
||||||
{
|
{
|
||||||
CcBackgroundChooserDialogPrivate *priv;
|
|
||||||
GtkWidget *empty_pictures_box;
|
GtkWidget *empty_pictures_box;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *headerbar;
|
GtkWidget *headerbar;
|
||||||
|
@ -463,12 +458,9 @@ cc_background_chooser_dialog_init (CcBackgroundChooserDialog *chooser)
|
||||||
gchar *pictures_dir_uri;
|
gchar *pictures_dir_uri;
|
||||||
GtkTargetList *target_list;
|
GtkTargetList *target_list;
|
||||||
|
|
||||||
chooser->priv = CC_CHOOSER_DIALOG_GET_PRIVATE (chooser);
|
chooser->wallpapers_source = bg_wallpapers_source_new (GTK_WINDOW (chooser));
|
||||||
priv = chooser->priv;
|
chooser->pictures_source = bg_pictures_source_new (GTK_WINDOW (chooser));
|
||||||
|
chooser->colors_source = bg_colors_source_new (GTK_WINDOW (chooser));
|
||||||
priv->wallpapers_source = bg_wallpapers_source_new (GTK_WINDOW (chooser));
|
|
||||||
priv->pictures_source = bg_pictures_source_new (GTK_WINDOW (chooser));
|
|
||||||
priv->colors_source = bg_colors_source_new (GTK_WINDOW (chooser));
|
|
||||||
|
|
||||||
gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);
|
||||||
gtk_window_set_resizable (GTK_WINDOW (chooser), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (chooser), FALSE);
|
||||||
|
@ -478,30 +470,30 @@ cc_background_chooser_dialog_init (CcBackgroundChooserDialog *chooser)
|
||||||
vbox = gtk_dialog_get_content_area (GTK_DIALOG (chooser));
|
vbox = gtk_dialog_get_content_area (GTK_DIALOG (chooser));
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
||||||
|
|
||||||
priv->stack = gtk_stack_new ();
|
chooser->stack = gtk_stack_new ();
|
||||||
gtk_stack_set_homogeneous (GTK_STACK (priv->stack), TRUE);
|
gtk_stack_set_homogeneous (GTK_STACK (chooser->stack), TRUE);
|
||||||
gtk_container_add (GTK_CONTAINER (vbox), priv->stack);
|
gtk_container_add (GTK_CONTAINER (vbox), chooser->stack);
|
||||||
g_signal_connect_swapped (priv->stack, "notify::visible-child", G_CALLBACK (on_visible_child_notify), chooser);
|
g_signal_connect_swapped (chooser->stack, "notify::visible-child", G_CALLBACK (on_visible_child_notify), chooser);
|
||||||
|
|
||||||
/* Add drag and drop support for bg images */
|
/* Add drag and drop support for bg images */
|
||||||
gtk_drag_dest_set (priv->stack, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
|
gtk_drag_dest_set (chooser->stack, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
|
||||||
target_list = gtk_target_list_new (NULL, 0);
|
target_list = gtk_target_list_new (NULL, 0);
|
||||||
gtk_target_list_add_uri_targets (target_list, URI_LIST);
|
gtk_target_list_add_uri_targets (target_list, URI_LIST);
|
||||||
gtk_target_list_add_table (target_list, color_targets, 1);
|
gtk_target_list_add_table (target_list, color_targets, 1);
|
||||||
gtk_drag_dest_set_target_list (priv->stack, target_list);
|
gtk_drag_dest_set_target_list (chooser->stack, target_list);
|
||||||
gtk_target_list_unref (target_list);
|
gtk_target_list_unref (target_list);
|
||||||
g_signal_connect (priv->stack, "drag-data-received", G_CALLBACK (cc_background_panel_drag_items), chooser);
|
g_signal_connect (chooser->stack, "drag-data-received", G_CALLBACK (cc_background_panel_drag_items), chooser);
|
||||||
|
|
||||||
headerbar = gtk_dialog_get_header_bar (GTK_DIALOG (chooser));
|
headerbar = gtk_dialog_get_header_bar (GTK_DIALOG (chooser));
|
||||||
|
|
||||||
switcher = gtk_stack_switcher_new ();
|
switcher = gtk_stack_switcher_new ();
|
||||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (priv->stack));
|
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (chooser->stack));
|
||||||
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (headerbar), switcher);
|
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (headerbar), switcher);
|
||||||
gtk_widget_show (switcher);
|
gtk_widget_show (switcher);
|
||||||
|
|
||||||
priv->pictures_stack = gtk_stack_new ();
|
chooser->pictures_stack = gtk_stack_new ();
|
||||||
gtk_stack_set_homogeneous (GTK_STACK (priv->pictures_stack), TRUE);
|
gtk_stack_set_homogeneous (GTK_STACK (chooser->pictures_stack), TRUE);
|
||||||
gtk_stack_add_titled (GTK_STACK (priv->stack), priv->pictures_stack, "pictures", _("Pictures"));
|
gtk_stack_add_titled (GTK_STACK (chooser->stack), chooser->pictures_stack, "pictures", _("Pictures"));
|
||||||
|
|
||||||
empty_pictures_box = gtk_grid_new ();
|
empty_pictures_box = gtk_grid_new ();
|
||||||
gtk_grid_set_column_spacing (GTK_GRID (empty_pictures_box), 12);
|
gtk_grid_set_column_spacing (GTK_GRID (empty_pictures_box), 12);
|
||||||
|
@ -509,7 +501,7 @@ cc_background_chooser_dialog_init (CcBackgroundChooserDialog *chooser)
|
||||||
GTK_ORIENTATION_HORIZONTAL);
|
GTK_ORIENTATION_HORIZONTAL);
|
||||||
context = gtk_widget_get_style_context (empty_pictures_box);
|
context = gtk_widget_get_style_context (empty_pictures_box);
|
||||||
gtk_style_context_add_class (context, "dim-label");
|
gtk_style_context_add_class (context, "dim-label");
|
||||||
gtk_stack_add_named (GTK_STACK (priv->pictures_stack), empty_pictures_box, "empty");
|
gtk_stack_add_named (GTK_STACK (chooser->pictures_stack), empty_pictures_box, "empty");
|
||||||
img = gtk_image_new_from_icon_name ("emblem-photos-symbolic", GTK_ICON_SIZE_DIALOG);
|
img = gtk_image_new_from_icon_name ("emblem-photos-symbolic", GTK_ICON_SIZE_DIALOG);
|
||||||
gtk_image_set_pixel_size (GTK_IMAGE (img), 64);
|
gtk_image_set_pixel_size (GTK_IMAGE (img), 64);
|
||||||
gtk_widget_set_halign (img, GTK_ALIGN_END);
|
gtk_widget_set_halign (img, GTK_ALIGN_END);
|
||||||
|
@ -588,8 +580,6 @@ cc_background_chooser_dialog_class_init (CcBackgroundChooserDialogClass *klass)
|
||||||
|
|
||||||
widget_class = GTK_WIDGET_CLASS (klass);
|
widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
widget_class->realize = cc_background_chooser_dialog_realize;
|
widget_class->realize = cc_background_chooser_dialog_realize;
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (CcBackgroundChooserDialogPrivate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
|
|
@ -26,29 +26,9 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_BACKGROUND_CHOOSER_DIALOG (cc_background_chooser_dialog_get_type ())
|
#define CC_TYPE_BACKGROUND_CHOOSER_DIALOG (cc_background_chooser_dialog_get_type ())
|
||||||
#define CC_BACKGROUND_CHOOSER_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), CC_TYPE_BACKGROUND_CHOOSER_DIALOG, CcBackgroundChooserDialog))
|
G_DECLARE_FINAL_TYPE (CcBackgroundChooserDialog, cc_background_chooser_dialog, CC, BACKGROUND_CHOOSER_DIALOG, GtkDialog)
|
||||||
#define CC_BACKGROUND_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_BACKGROUND_CHOOSER_DIALOG, CcBackgroundChooserDialogClass))
|
|
||||||
#define CC_IS_BACKGROUND_CHOOSER_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), CC_TYPE_BACKGROUND_CHOOSER_DIALOG))
|
|
||||||
#define CC_IS_BACKGROUND_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_BACKGROUND_CHOOSER_DIALOG))
|
|
||||||
#define CC_BACKGROUND_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_BACKGROUND_CHOOSER_DIALOG, CcBackgroundChooserDialogClass))
|
|
||||||
|
|
||||||
typedef struct _CcBackgroundChooserDialog CcBackgroundChooserDialog;
|
|
||||||
typedef struct _CcBackgroundChooserDialogClass CcBackgroundChooserDialogClass;
|
|
||||||
typedef struct _CcBackgroundChooserDialogPrivate CcBackgroundChooserDialogPrivate;
|
|
||||||
|
|
||||||
struct _CcBackgroundChooserDialog
|
|
||||||
{
|
|
||||||
GtkDialog parent_instance;
|
|
||||||
CcBackgroundChooserDialogPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcBackgroundChooserDialogClass
|
|
||||||
{
|
|
||||||
GtkDialogClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType cc_background_chooser_dialog_get_type (void) G_GNUC_CONST;
|
|
||||||
GtkWidget * cc_background_chooser_dialog_new (GtkWindow *transient_for);
|
GtkWidget * cc_background_chooser_dialog_new (GtkWindow *transient_for);
|
||||||
|
|
||||||
CcBackgroundItem * cc_background_chooser_dialog_get_item (CcBackgroundChooserDialog *chooser);
|
CcBackgroundItem * cc_background_chooser_dialog_get_item (CcBackgroundChooserDialog *chooser);
|
||||||
|
|
|
@ -28,15 +28,13 @@
|
||||||
|
|
||||||
struct _CcBackgroundGriloMiner
|
struct _CcBackgroundGriloMiner
|
||||||
{
|
{
|
||||||
GObject parent;
|
GObject parent_instance;
|
||||||
|
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GList *accounts;
|
GList *accounts;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CcBackgroundGriloMinerClass
|
G_DEFINE_TYPE (CcBackgroundGriloMiner, cc_background_grilo_miner, G_TYPE_OBJECT)
|
||||||
{
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -46,8 +44,6 @@ enum
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcBackgroundGriloMiner, cc_background_grilo_miner, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
#define REMOTE_ITEM_COUNT 50
|
#define REMOTE_ITEM_COUNT 50
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
|
|
|
@ -23,32 +23,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_BACKGROUND_GRILO_MINER cc_background_grilo_miner_get_type()
|
#define CC_TYPE_BACKGROUND_GRILO_MINER (cc_background_grilo_miner_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (CcBackgroundGriloMiner, cc_background_grilo_miner, CC, BACKGROUND_GRILO_MINER, GObject);
|
||||||
#define CC_BACKGROUND_GRILO_MINER(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
CC_TYPE_BACKGROUND_GRILO_MINER, CcBackgroundGriloMiner))
|
|
||||||
|
|
||||||
#define CC_BACKGROUND_GRILO_MINER_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
CC_TYPE_BACKGROUND_GRILO_MINER, CcBackgroundGriloMinerClass))
|
|
||||||
|
|
||||||
#define CC_IS_BACKGROUND_GRILO_MINER(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
CC_TYPE_BACKGROUND_GRILO_MINER))
|
|
||||||
|
|
||||||
#define CC_IS_BACKGROUND_GRILO_MINER_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
CC_TYPE_BACKGROUND_GRILO_MINER))
|
|
||||||
|
|
||||||
#define CC_BACKGROUND_GRILO_MINER_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
CC_TYPE_BACKGROUND_GRILO_MINER, CcBackgroundGriloMinerClass))
|
|
||||||
|
|
||||||
typedef struct _CcBackgroundGriloMiner CcBackgroundGriloMiner;
|
|
||||||
typedef struct _CcBackgroundGriloMinerClass CcBackgroundGriloMinerClass;
|
|
||||||
|
|
||||||
GType cc_background_grilo_miner_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CcBackgroundGriloMiner *cc_background_grilo_miner_new (void);
|
CcBackgroundGriloMiner *cc_background_grilo_miner_new (void);
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
#include "cc-background-item.h"
|
#include "cc-background-item.h"
|
||||||
#include "gdesktop-enums-types.h"
|
#include "gdesktop-enums-types.h"
|
||||||
|
|
||||||
#define CC_BACKGROUND_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItemPrivate))
|
struct _CcBackgroundItem
|
||||||
|
|
||||||
struct CcBackgroundItemPrivate
|
|
||||||
{
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
char *name;
|
char *name;
|
||||||
char *uri;
|
char *uri;
|
||||||
|
@ -99,7 +99,7 @@ get_emblemed_pixbuf (CcBackgroundItem *item, GdkPixbuf *pixbuf, gint scale_facto
|
||||||
|
|
||||||
retval = g_object_ref (pixbuf);
|
retval = g_object_ref (pixbuf);
|
||||||
|
|
||||||
if (item->priv->slideshow_emblem == NULL) {
|
if (item->slideshow_emblem == NULL) {
|
||||||
if (slideshow_emblem == NULL) {
|
if (slideshow_emblem == NULL) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GtkIconTheme *theme;
|
GtkIconTheme *theme;
|
||||||
|
@ -126,9 +126,9 @@ get_emblemed_pixbuf (CcBackgroundItem *item, GdkPixbuf *pixbuf, gint scale_facto
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (slideshow_emblem), (gpointer *) (&slideshow_emblem));
|
g_object_add_weak_pointer (G_OBJECT (slideshow_emblem), (gpointer *) (&slideshow_emblem));
|
||||||
item->priv->slideshow_emblem = slideshow_emblem;
|
item->slideshow_emblem = slideshow_emblem;
|
||||||
} else {
|
} else {
|
||||||
item->priv->slideshow_emblem = g_object_ref (slideshow_emblem);
|
item->slideshow_emblem = g_object_ref (slideshow_emblem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,27 +153,27 @@ set_bg_properties (CcBackgroundItem *item)
|
||||||
GdkColor pcolor = { 0, 0, 0, 0 };
|
GdkColor pcolor = { 0, 0, 0, 0 };
|
||||||
GdkColor scolor = { 0, 0, 0, 0 };
|
GdkColor scolor = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
if (item->priv->uri) {
|
if (item->uri) {
|
||||||
GFile *file;
|
GFile *file;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
file = g_file_new_for_commandline_arg (item->priv->uri);
|
file = g_file_new_for_commandline_arg (item->uri);
|
||||||
filename = g_file_get_path (file);
|
filename = g_file_get_path (file);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
gnome_bg_set_filename (item->priv->bg, filename);
|
gnome_bg_set_filename (item->bg, filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->priv->primary_color != NULL) {
|
if (item->primary_color != NULL) {
|
||||||
gdk_color_parse (item->priv->primary_color, &pcolor);
|
gdk_color_parse (item->primary_color, &pcolor);
|
||||||
}
|
}
|
||||||
if (item->priv->secondary_color != NULL) {
|
if (item->secondary_color != NULL) {
|
||||||
gdk_color_parse (item->priv->secondary_color, &scolor);
|
gdk_color_parse (item->secondary_color, &scolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
gnome_bg_set_color (item->priv->bg, item->priv->shading, &pcolor, &scolor);
|
gnome_bg_set_color (item->bg, item->shading, &pcolor, &scolor);
|
||||||
gnome_bg_set_placement (item->priv->bg, item->priv->placement);
|
gnome_bg_set_placement (item->bg, item->placement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ cc_background_item_changes_with_time (CcBackgroundItem *item)
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), FALSE);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), FALSE);
|
||||||
|
|
||||||
changes = FALSE;
|
changes = FALSE;
|
||||||
if (item->priv->bg != NULL) {
|
if (item->bg != NULL) {
|
||||||
changes = gnome_bg_changes_with_time (item->priv->bg);
|
changes = gnome_bg_changes_with_time (item->bg);
|
||||||
}
|
}
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
@ -194,19 +194,19 @@ cc_background_item_changes_with_time (CcBackgroundItem *item)
|
||||||
static void
|
static void
|
||||||
update_size (CcBackgroundItem *item)
|
update_size (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&item->priv->size, g_free);
|
g_clear_pointer (&item->size, g_free);
|
||||||
|
|
||||||
if (item->priv->uri == NULL) {
|
if (item->uri == NULL) {
|
||||||
item->priv->size = g_strdup ("");
|
item->size = g_strdup ("");
|
||||||
} else {
|
} else {
|
||||||
if (gnome_bg_has_multiple_sizes (item->priv->bg) || gnome_bg_changes_with_time (item->priv->bg)) {
|
if (gnome_bg_has_multiple_sizes (item->bg) || gnome_bg_changes_with_time (item->bg)) {
|
||||||
item->priv->size = g_strdup (_("multiple sizes"));
|
item->size = g_strdup (_("multiple sizes"));
|
||||||
} else {
|
} else {
|
||||||
/* translators: 100 × 100px
|
/* translators: 100 × 100px
|
||||||
* Note that this is not an "x", but U+00D7 MULTIPLICATION SIGN */
|
* Note that this is not an "x", but U+00D7 MULTIPLICATION SIGN */
|
||||||
item->priv->size = g_strdup_printf (_("%d × %d"),
|
item->size = g_strdup_printf (_("%d × %d"),
|
||||||
item->priv->width,
|
item->width,
|
||||||
item->priv->height);
|
item->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,17 +249,17 @@ cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
|
||||||
* the slideshow frame though, so we can't do much better than this
|
* the slideshow frame though, so we can't do much better than this
|
||||||
* for now.
|
* for now.
|
||||||
*/
|
*/
|
||||||
pixbuf = render_at_size (item->priv->bg, width, height);
|
pixbuf = render_at_size (item->bg, width, height);
|
||||||
} else {
|
} else {
|
||||||
if (frame >= 0) {
|
if (frame >= 0) {
|
||||||
pixbuf = gnome_bg_create_frame_thumbnail (item->priv->bg,
|
pixbuf = gnome_bg_create_frame_thumbnail (item->bg,
|
||||||
thumbs,
|
thumbs,
|
||||||
gdk_screen_get_default (),
|
gdk_screen_get_default (),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
frame);
|
frame);
|
||||||
} else {
|
} else {
|
||||||
pixbuf = gnome_bg_create_thumbnail (item->priv->bg,
|
pixbuf = gnome_bg_create_thumbnail (item->bg,
|
||||||
thumbs,
|
thumbs,
|
||||||
gdk_screen_get_default (),
|
gdk_screen_get_default (),
|
||||||
width,
|
width,
|
||||||
|
@ -269,19 +269,19 @@ cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
|
||||||
|
|
||||||
if (pixbuf != NULL
|
if (pixbuf != NULL
|
||||||
&& frame != -2
|
&& frame != -2
|
||||||
&& gnome_bg_changes_with_time (item->priv->bg)) {
|
&& gnome_bg_changes_with_time (item->bg)) {
|
||||||
retval = get_emblemed_pixbuf (item, pixbuf, scale_factor);
|
retval = get_emblemed_pixbuf (item, pixbuf, scale_factor);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
} else {
|
} else {
|
||||||
retval = pixbuf;
|
retval = pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnome_bg_get_image_size (item->priv->bg,
|
gnome_bg_get_image_size (item->bg,
|
||||||
thumbs,
|
thumbs,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
&item->priv->width,
|
&item->width,
|
||||||
&item->priv->height);
|
&item->height);
|
||||||
|
|
||||||
update_size (item);
|
update_size (item);
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ update_info (CcBackgroundItem *item,
|
||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
|
|
||||||
if (_info == NULL) {
|
if (_info == NULL) {
|
||||||
file = g_file_new_for_uri (item->priv->uri);
|
file = g_file_new_for_uri (item->uri);
|
||||||
|
|
||||||
info = g_file_query_info (file,
|
info = g_file_query_info (file,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
||||||
|
@ -323,22 +323,22 @@ update_info (CcBackgroundItem *item,
|
||||||
info = g_object_ref (_info);
|
info = g_object_ref (_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_pointer (&item->priv->mime_type, g_free);
|
g_clear_pointer (&item->mime_type, g_free);
|
||||||
|
|
||||||
if (info == NULL
|
if (info == NULL
|
||||||
|| g_file_info_get_content_type (info) == NULL) {
|
|| g_file_info_get_content_type (info) == NULL) {
|
||||||
if (item->priv->uri == NULL) {
|
if (item->uri == NULL) {
|
||||||
item->priv->mime_type = g_strdup ("image/x-no-data");
|
item->mime_type = g_strdup ("image/x-no-data");
|
||||||
g_free (item->priv->name);
|
g_free (item->name);
|
||||||
item->priv->name = g_strdup (_("No Desktop Background"));
|
item->name = g_strdup (_("No Desktop Background"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item->priv->name == NULL)
|
if (item->name == NULL)
|
||||||
item->priv->name = g_strdup (g_file_info_get_display_name (info));
|
item->name = g_strdup (g_file_info_get_display_name (info));
|
||||||
|
|
||||||
item->priv->mime_type = g_strdup (g_file_info_get_content_type (info));
|
item->mime_type = g_strdup (g_file_info_get_content_type (info));
|
||||||
if (item->priv->modified == 0)
|
if (item->modified == 0)
|
||||||
item->priv->modified = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
item->modified = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info != NULL)
|
if (info != NULL)
|
||||||
|
@ -351,28 +351,28 @@ cc_background_item_load (CcBackgroundItem *item,
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), FALSE);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), FALSE);
|
||||||
|
|
||||||
if (item->priv->uri == NULL)
|
if (item->uri == NULL)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
update_info (item, info);
|
update_info (item, info);
|
||||||
|
|
||||||
if (item->priv->mime_type != NULL
|
if (item->mime_type != NULL
|
||||||
&& (g_str_has_prefix (item->priv->mime_type, "image/")
|
&& (g_str_has_prefix (item->mime_type, "image/")
|
||||||
|| strcmp (item->priv->mime_type, "application/xml") == 0)) {
|
|| strcmp (item->mime_type, "application/xml") == 0)) {
|
||||||
set_bg_properties (item);
|
set_bg_properties (item);
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME we should handle XML files as well */
|
/* FIXME we should handle XML files as well */
|
||||||
if (item->priv->mime_type != NULL &&
|
if (item->mime_type != NULL &&
|
||||||
g_str_has_prefix (item->priv->mime_type, "image/")) {
|
g_str_has_prefix (item->mime_type, "image/")) {
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
filename = g_filename_from_uri (item->priv->uri, NULL, NULL);
|
filename = g_filename_from_uri (item->uri, NULL, NULL);
|
||||||
gdk_pixbuf_get_file_info (filename,
|
gdk_pixbuf_get_file_info (filename,
|
||||||
&item->priv->width,
|
&item->width,
|
||||||
&item->priv->height);
|
&item->height);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
update_size (item);
|
update_size (item);
|
||||||
}
|
}
|
||||||
|
@ -384,8 +384,8 @@ static void
|
||||||
_set_name (CcBackgroundItem *item,
|
_set_name (CcBackgroundItem *item,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_free (item->priv->name);
|
g_free (item->name);
|
||||||
item->priv->name = g_strdup (value);
|
item->name = g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -393,20 +393,20 @@ cc_background_item_get_name (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->name;
|
return item->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_uri (CcBackgroundItem *item,
|
_set_uri (CcBackgroundItem *item,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_free (item->priv->uri);
|
g_free (item->uri);
|
||||||
if (value && *value == '\0') {
|
if (value && *value == '\0') {
|
||||||
item->priv->uri = NULL;
|
item->uri = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (value && strstr (value, "://") == NULL)
|
if (value && strstr (value, "://") == NULL)
|
||||||
g_warning ("URI '%s' is invalid", value);
|
g_warning ("URI '%s' is invalid", value);
|
||||||
item->priv->uri = g_strdup (value);
|
item->uri = g_strdup (value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,29 +415,29 @@ cc_background_item_get_uri (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->uri;
|
return item->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_placement (CcBackgroundItem *item,
|
_set_placement (CcBackgroundItem *item,
|
||||||
GDesktopBackgroundStyle value)
|
GDesktopBackgroundStyle value)
|
||||||
{
|
{
|
||||||
item->priv->placement = value;
|
item->placement = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_shading (CcBackgroundItem *item,
|
_set_shading (CcBackgroundItem *item,
|
||||||
GDesktopBackgroundShading value)
|
GDesktopBackgroundShading value)
|
||||||
{
|
{
|
||||||
item->priv->shading = value;
|
item->shading = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_primary_color (CcBackgroundItem *item,
|
_set_primary_color (CcBackgroundItem *item,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_free (item->priv->primary_color);
|
g_free (item->primary_color);
|
||||||
item->priv->primary_color = g_strdup (value);
|
item->primary_color = g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -445,15 +445,15 @@ cc_background_item_get_pcolor (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->primary_color;
|
return item->primary_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_secondary_color (CcBackgroundItem *item,
|
_set_secondary_color (CcBackgroundItem *item,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_free (item->priv->secondary_color);
|
g_free (item->secondary_color);
|
||||||
item->priv->secondary_color = g_strdup (value);
|
item->secondary_color = g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -461,7 +461,7 @@ cc_background_item_get_scolor (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->secondary_color;
|
return item->secondary_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDesktopBackgroundStyle
|
GDesktopBackgroundStyle
|
||||||
|
@ -469,7 +469,7 @@ cc_background_item_get_placement (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), G_DESKTOP_BACKGROUND_STYLE_SCALED);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), G_DESKTOP_BACKGROUND_STYLE_SCALED);
|
||||||
|
|
||||||
return item->priv->placement;
|
return item->placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDesktopBackgroundShading
|
GDesktopBackgroundShading
|
||||||
|
@ -477,22 +477,22 @@ cc_background_item_get_shading (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), G_DESKTOP_BACKGROUND_SHADING_SOLID);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), G_DESKTOP_BACKGROUND_SHADING_SOLID);
|
||||||
|
|
||||||
return item->priv->shading;
|
return item->shading;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_is_deleted (CcBackgroundItem *item,
|
_set_is_deleted (CcBackgroundItem *item,
|
||||||
gboolean value)
|
gboolean value)
|
||||||
{
|
{
|
||||||
item->priv->is_deleted = value;
|
item->is_deleted = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_source_url (CcBackgroundItem *item,
|
_set_source_url (CcBackgroundItem *item,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_free (item->priv->source_url);
|
g_free (item->source_url);
|
||||||
item->priv->source_url = g_strdup (value);
|
item->source_url = g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -500,15 +500,15 @@ cc_background_item_get_source_url (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->source_url;
|
return item->source_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_source_xml (CcBackgroundItem *item,
|
_set_source_xml (CcBackgroundItem *item,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
g_free (item->priv->source_xml);
|
g_free (item->source_xml);
|
||||||
item->priv->source_xml = g_strdup (value);
|
item->source_xml = g_strdup (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -516,14 +516,14 @@ cc_background_item_get_source_xml (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->source_xml;
|
return item->source_xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_flags (CcBackgroundItem *item,
|
_set_flags (CcBackgroundItem *item,
|
||||||
CcBackgroundItemFlags value)
|
CcBackgroundItemFlags value)
|
||||||
{
|
{
|
||||||
item->priv->flags = value;
|
item->flags = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
CcBackgroundItemFlags
|
CcBackgroundItemFlags
|
||||||
|
@ -531,7 +531,7 @@ cc_background_item_get_flags (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
||||||
|
|
||||||
return item->priv->flags;
|
return item->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -539,14 +539,14 @@ cc_background_item_get_size (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL);
|
||||||
|
|
||||||
return item->priv->size;
|
return item->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_needs_download (CcBackgroundItem *item,
|
_set_needs_download (CcBackgroundItem *item,
|
||||||
gboolean value)
|
gboolean value)
|
||||||
{
|
{
|
||||||
item->priv->needs_download = value;
|
item->needs_download = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -554,14 +554,14 @@ cc_background_item_get_needs_download (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
||||||
|
|
||||||
return item->priv->needs_download;
|
return item->needs_download;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_set_modified (CcBackgroundItem *item,
|
_set_modified (CcBackgroundItem *item,
|
||||||
guint64 value)
|
guint64 value)
|
||||||
{
|
{
|
||||||
item->priv->modified = value;
|
item->modified = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint64
|
guint64
|
||||||
|
@ -569,7 +569,7 @@ cc_background_item_get_modified (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
||||||
|
|
||||||
return item->priv->modified;
|
return item->modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -637,43 +637,43 @@ cc_background_item_get_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_NAME:
|
case PROP_NAME:
|
||||||
g_value_set_string (value, self->priv->name);
|
g_value_set_string (value, self->name);
|
||||||
break;
|
break;
|
||||||
case PROP_URI:
|
case PROP_URI:
|
||||||
g_value_set_string (value, self->priv->uri);
|
g_value_set_string (value, self->uri);
|
||||||
break;
|
break;
|
||||||
case PROP_PLACEMENT:
|
case PROP_PLACEMENT:
|
||||||
g_value_set_enum (value, self->priv->placement);
|
g_value_set_enum (value, self->placement);
|
||||||
break;
|
break;
|
||||||
case PROP_SHADING:
|
case PROP_SHADING:
|
||||||
g_value_set_enum (value, self->priv->shading);
|
g_value_set_enum (value, self->shading);
|
||||||
break;
|
break;
|
||||||
case PROP_PRIMARY_COLOR:
|
case PROP_PRIMARY_COLOR:
|
||||||
g_value_set_string (value, self->priv->primary_color);
|
g_value_set_string (value, self->primary_color);
|
||||||
break;
|
break;
|
||||||
case PROP_SECONDARY_COLOR:
|
case PROP_SECONDARY_COLOR:
|
||||||
g_value_set_string (value, self->priv->secondary_color);
|
g_value_set_string (value, self->secondary_color);
|
||||||
break;
|
break;
|
||||||
case PROP_IS_DELETED:
|
case PROP_IS_DELETED:
|
||||||
g_value_set_boolean (value, self->priv->is_deleted);
|
g_value_set_boolean (value, self->is_deleted);
|
||||||
break;
|
break;
|
||||||
case PROP_SOURCE_URL:
|
case PROP_SOURCE_URL:
|
||||||
g_value_set_string (value, self->priv->source_url);
|
g_value_set_string (value, self->source_url);
|
||||||
break;
|
break;
|
||||||
case PROP_SOURCE_XML:
|
case PROP_SOURCE_XML:
|
||||||
g_value_set_string (value, self->priv->source_xml);
|
g_value_set_string (value, self->source_xml);
|
||||||
break;
|
break;
|
||||||
case PROP_FLAGS:
|
case PROP_FLAGS:
|
||||||
g_value_set_flags (value, self->priv->flags);
|
g_value_set_flags (value, self->flags);
|
||||||
break;
|
break;
|
||||||
case PROP_SIZE:
|
case PROP_SIZE:
|
||||||
g_value_set_string (value, self->priv->size);
|
g_value_set_string (value, self->size);
|
||||||
break;
|
break;
|
||||||
case PROP_NEEDS_DOWNLOAD:
|
case PROP_NEEDS_DOWNLOAD:
|
||||||
g_value_set_boolean (value, self->priv->needs_download);
|
g_value_set_boolean (value, self->needs_download);
|
||||||
break;
|
break;
|
||||||
case PROP_MODIFIED:
|
case PROP_MODIFIED:
|
||||||
g_value_set_uint64 (value, self->priv->modified);
|
g_value_set_uint64 (value, self->modified);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -809,25 +809,20 @@ cc_background_item_class_init (CcBackgroundItemClass *klass)
|
||||||
G_MAXUINT64,
|
G_MAXUINT64,
|
||||||
0,
|
0,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcBackgroundItemPrivate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_background_item_init (CcBackgroundItem *item)
|
cc_background_item_init (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
item->priv = CC_BACKGROUND_ITEM_GET_PRIVATE (item);
|
item->bg = gnome_bg_new ();
|
||||||
|
|
||||||
item->priv->bg = gnome_bg_new ();
|
item->shading = G_DESKTOP_BACKGROUND_SHADING_SOLID;
|
||||||
|
item->placement = G_DESKTOP_BACKGROUND_STYLE_SCALED;
|
||||||
item->priv->shading = G_DESKTOP_BACKGROUND_SHADING_SOLID;
|
item->primary_color = g_strdup ("#000000000000");
|
||||||
item->priv->placement = G_DESKTOP_BACKGROUND_STYLE_SCALED;
|
item->secondary_color = g_strdup ("#000000000000");
|
||||||
item->priv->primary_color = g_strdup ("#000000000000");
|
item->needs_download = TRUE;
|
||||||
item->priv->secondary_color = g_strdup ("#000000000000");
|
item->flags = 0;
|
||||||
item->priv->needs_download = TRUE;
|
item->modified = 0;
|
||||||
item->priv->flags = 0;
|
|
||||||
item->priv->modified = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -840,21 +835,21 @@ cc_background_item_finalize (GObject *object)
|
||||||
|
|
||||||
item = CC_BACKGROUND_ITEM (object);
|
item = CC_BACKGROUND_ITEM (object);
|
||||||
|
|
||||||
g_return_if_fail (item->priv != NULL);
|
g_return_if_fail (item != NULL);
|
||||||
|
|
||||||
g_free (item->priv->name);
|
g_free (item->name);
|
||||||
g_free (item->priv->uri);
|
g_free (item->uri);
|
||||||
g_free (item->priv->primary_color);
|
g_free (item->primary_color);
|
||||||
g_free (item->priv->secondary_color);
|
g_free (item->secondary_color);
|
||||||
g_free (item->priv->mime_type);
|
g_free (item->mime_type);
|
||||||
g_free (item->priv->size);
|
g_free (item->size);
|
||||||
g_free (item->priv->source_url);
|
g_free (item->source_url);
|
||||||
g_free (item->priv->source_xml);
|
g_free (item->source_xml);
|
||||||
|
|
||||||
if (item->priv->bg != NULL)
|
if (item->bg != NULL)
|
||||||
g_object_unref (item->priv->bg);
|
g_object_unref (item->bg);
|
||||||
|
|
||||||
g_clear_object (&item->priv->slideshow_emblem);
|
g_clear_object (&item->slideshow_emblem);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_background_item_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cc_background_item_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -876,18 +871,18 @@ cc_background_item_copy (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
CcBackgroundItem *ret;
|
CcBackgroundItem *ret;
|
||||||
|
|
||||||
ret = cc_background_item_new (item->priv->uri);
|
ret = cc_background_item_new (item->uri);
|
||||||
ret->priv->name = g_strdup (item->priv->name);
|
ret->name = g_strdup (item->name);
|
||||||
ret->priv->size = g_strdup (item->priv->size);
|
ret->size = g_strdup (item->size);
|
||||||
ret->priv->placement = item->priv->placement;
|
ret->placement = item->placement;
|
||||||
ret->priv->shading = item->priv->shading;
|
ret->shading = item->shading;
|
||||||
ret->priv->primary_color = g_strdup (item->priv->primary_color);
|
ret->primary_color = g_strdup (item->primary_color);
|
||||||
ret->priv->secondary_color = g_strdup (item->priv->secondary_color);
|
ret->secondary_color = g_strdup (item->secondary_color);
|
||||||
ret->priv->source_url = g_strdup (item->priv->source_url);
|
ret->source_url = g_strdup (item->source_url);
|
||||||
ret->priv->source_xml = g_strdup (item->priv->source_xml);
|
ret->source_xml = g_strdup (item->source_xml);
|
||||||
ret->priv->is_deleted = item->priv->is_deleted;
|
ret->is_deleted = item->is_deleted;
|
||||||
ret->priv->needs_download = item->priv->needs_download;
|
ret->needs_download = item->needs_download;
|
||||||
ret->priv->flags = item->priv->flags;
|
ret->flags = item->flags;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -924,21 +919,18 @@ enum_to_str (GType type,
|
||||||
void
|
void
|
||||||
cc_background_item_dump (CcBackgroundItem *item)
|
cc_background_item_dump (CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
CcBackgroundItemPrivate *priv;
|
|
||||||
GString *flags;
|
GString *flags;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_return_if_fail (CC_IS_BACKGROUND_ITEM (item));
|
g_return_if_fail (CC_IS_BACKGROUND_ITEM (item));
|
||||||
|
|
||||||
priv = item->priv;
|
g_debug ("name:\t\t\t%s", item->name);
|
||||||
|
g_debug ("URI:\t\t\t%s", item->uri ? item->uri : "NULL");
|
||||||
g_debug ("name:\t\t\t%s", priv->name);
|
if (item->size)
|
||||||
g_debug ("URI:\t\t\t%s", priv->uri ? priv->uri : "NULL");
|
g_debug ("size:\t\t\t'%s'", item->size);
|
||||||
if (priv->size)
|
|
||||||
g_debug ("size:\t\t\t'%s'", priv->size);
|
|
||||||
flags = g_string_new (NULL);
|
flags = g_string_new (NULL);
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
if (priv->flags & (1 << i)) {
|
if (item->flags & (1 << i)) {
|
||||||
g_string_append (flags, flags_to_str (1 << i));
|
g_string_append (flags, flags_to_str (1 << i));
|
||||||
g_string_append_c (flags, ' ');
|
g_string_append_c (flags, ' ');
|
||||||
}
|
}
|
||||||
|
@ -947,21 +939,21 @@ cc_background_item_dump (CcBackgroundItem *item)
|
||||||
g_string_append (flags, "-none-");
|
g_string_append (flags, "-none-");
|
||||||
g_debug ("flags:\t\t\t%s", flags->str);
|
g_debug ("flags:\t\t\t%s", flags->str);
|
||||||
g_string_free (flags, TRUE);
|
g_string_free (flags, TRUE);
|
||||||
if (priv->primary_color)
|
if (item->primary_color)
|
||||||
g_debug ("pcolor:\t\t\t%s", priv->primary_color);
|
g_debug ("pcolor:\t\t\t%s", item->primary_color);
|
||||||
if (priv->secondary_color)
|
if (item->secondary_color)
|
||||||
g_debug ("scolor:\t\t\t%s", priv->secondary_color);
|
g_debug ("scolor:\t\t\t%s", item->secondary_color);
|
||||||
g_debug ("placement:\t\t%s", enum_to_str (G_DESKTOP_TYPE_DESKTOP_BACKGROUND_STYLE, priv->placement));
|
g_debug ("placement:\t\t%s", enum_to_str (G_DESKTOP_TYPE_DESKTOP_BACKGROUND_STYLE, item->placement));
|
||||||
g_debug ("shading:\t\t%s", enum_to_str (G_DESKTOP_TYPE_DESKTOP_BACKGROUND_SHADING, priv->shading));
|
g_debug ("shading:\t\t%s", enum_to_str (G_DESKTOP_TYPE_DESKTOP_BACKGROUND_SHADING, item->shading));
|
||||||
if (priv->source_url)
|
if (item->source_url)
|
||||||
g_debug ("source URL:\t\t%s", priv->source_url);
|
g_debug ("source URL:\t\t%s", item->source_url);
|
||||||
if (priv->source_xml)
|
if (item->source_xml)
|
||||||
g_debug ("source XML:\t\t%s", priv->source_xml);
|
g_debug ("source XML:\t\t%s", item->source_xml);
|
||||||
g_debug ("deleted:\t\t%s", priv->is_deleted ? "yes" : "no");
|
g_debug ("deleted:\t\t%s", item->is_deleted ? "yes" : "no");
|
||||||
if (priv->mime_type)
|
if (item->mime_type)
|
||||||
g_debug ("mime-type:\t\t%s", priv->mime_type);
|
g_debug ("mime-type:\t\t%s", item->mime_type);
|
||||||
g_debug ("dimensions:\t\t%d x %d", priv->width, priv->height);
|
g_debug ("dimensions:\t\t%d x %d", item->width, item->height);
|
||||||
g_debug ("modified: %"G_GUINT64_FORMAT, priv->modified);
|
g_debug ("modified: %"G_GUINT64_FORMAT, item->modified);
|
||||||
g_debug (" ");
|
g_debug (" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,31 +1002,31 @@ cc_background_item_compare (CcBackgroundItem *saved,
|
||||||
{
|
{
|
||||||
CcBackgroundItemFlags flags;
|
CcBackgroundItemFlags flags;
|
||||||
|
|
||||||
flags = saved->priv->flags;
|
flags = saved->flags;
|
||||||
if (flags == 0)
|
if (flags == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (flags & CC_BACKGROUND_ITEM_HAS_URI) {
|
if (flags & CC_BACKGROUND_ITEM_HAS_URI) {
|
||||||
if (files_equal (saved->priv->uri, configured->priv->uri) == FALSE)
|
if (files_equal (saved->uri, configured->uri) == FALSE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (flags & CC_BACKGROUND_ITEM_HAS_SHADING) {
|
if (flags & CC_BACKGROUND_ITEM_HAS_SHADING) {
|
||||||
if (saved->priv->shading != configured->priv->shading)
|
if (saved->shading != configured->shading)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT) {
|
if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT) {
|
||||||
if (saved->priv->placement != configured->priv->placement)
|
if (saved->placement != configured->placement)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (flags & CC_BACKGROUND_ITEM_HAS_PCOLOR) {
|
if (flags & CC_BACKGROUND_ITEM_HAS_PCOLOR) {
|
||||||
if (colors_equal (saved->priv->primary_color,
|
if (colors_equal (saved->primary_color,
|
||||||
configured->priv->primary_color) == FALSE) {
|
configured->primary_color) == FALSE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags & CC_BACKGROUND_ITEM_HAS_SCOLOR) {
|
if (flags & CC_BACKGROUND_ITEM_HAS_SCOLOR) {
|
||||||
if (colors_equal (saved->priv->secondary_color,
|
if (colors_equal (saved->secondary_color,
|
||||||
configured->priv->secondary_color) == FALSE) {
|
configured->secondary_color) == FALSE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_BACKGROUND_ITEM (cc_background_item_get_type ())
|
#define CC_TYPE_BACKGROUND_ITEM (cc_background_item_get_type ())
|
||||||
#define CC_BACKGROUND_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItem))
|
G_DECLARE_FINAL_TYPE (CcBackgroundItem, cc_background_item, CC, BACKGROUND_ITEM, GObject)
|
||||||
#define CC_BACKGROUND_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItemClass))
|
|
||||||
#define CC_IS_BACKGROUND_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_BACKGROUND_ITEM))
|
|
||||||
#define CC_IS_BACKGROUND_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_BACKGROUND_ITEM))
|
|
||||||
#define CC_BACKGROUND_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItemClass))
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CC_BACKGROUND_ITEM_HAS_SHADING = 1 << 0,
|
CC_BACKGROUND_ITEM_HAS_SHADING = 1 << 0,
|
||||||
|
@ -49,21 +45,6 @@ typedef enum {
|
||||||
CC_BACKGROUND_ITEM_HAS_SCOLOR & \
|
CC_BACKGROUND_ITEM_HAS_SCOLOR & \
|
||||||
CC_BACKGROUND_ITEM_HAS_FNAME)
|
CC_BACKGROUND_ITEM_HAS_FNAME)
|
||||||
|
|
||||||
typedef struct CcBackgroundItemPrivate CcBackgroundItemPrivate;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GObject parent;
|
|
||||||
CcBackgroundItemPrivate *priv;
|
|
||||||
} CcBackgroundItem;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GObjectClass parent_class;
|
|
||||||
} CcBackgroundItemClass;
|
|
||||||
|
|
||||||
GType cc_background_item_get_type (void);
|
|
||||||
|
|
||||||
CcBackgroundItem * cc_background_item_new (const char *uri);
|
CcBackgroundItem * cc_background_item_new (const char *uri);
|
||||||
CcBackgroundItem * cc_background_item_copy (CcBackgroundItem *item);
|
CcBackgroundItem * cc_background_item_copy (CcBackgroundItem *item);
|
||||||
gboolean cc_background_item_load (CcBackgroundItem *item,
|
gboolean cc_background_item_load (CcBackgroundItem *item,
|
||||||
|
|
|
@ -44,13 +44,10 @@
|
||||||
#define WP_PCOLOR_KEY "primary-color"
|
#define WP_PCOLOR_KEY "primary-color"
|
||||||
#define WP_SCOLOR_KEY "secondary-color"
|
#define WP_SCOLOR_KEY "secondary-color"
|
||||||
|
|
||||||
CC_PANEL_REGISTER (CcBackgroundPanel, cc_background_panel)
|
struct _CcBackgroundPanel
|
||||||
|
|
||||||
#define BACKGROUND_PANEL_PRIVATE(o) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_BACKGROUND_PANEL, CcBackgroundPanelPrivate))
|
|
||||||
|
|
||||||
struct _CcBackgroundPanelPrivate
|
|
||||||
{
|
{
|
||||||
|
CcPanel parent_instance;
|
||||||
|
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GDBusConnection *connection;
|
GDBusConnection *connection;
|
||||||
|
|
||||||
|
@ -72,9 +69,11 @@ struct _CcBackgroundPanelPrivate
|
||||||
char *screenshot_path;
|
char *screenshot_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WID(y) (GtkWidget *) gtk_builder_get_object (priv->builder, y)
|
CC_PANEL_REGISTER (CcBackgroundPanel, cc_background_panel)
|
||||||
#define CURRENT_BG (settings == priv->settings ? priv->current_background : priv->current_lock_background)
|
|
||||||
#define SAVE_PATH (settings == priv->settings ? "last-edited.xml" : "last-edited-lock.xml")
|
#define WID(y) (GtkWidget *) gtk_builder_get_object (panel->builder, y)
|
||||||
|
#define CURRENT_BG (settings == panel->settings ? panel->current_background : panel->current_lock_background)
|
||||||
|
#define SAVE_PATH (settings == panel->settings ? "last-edited.xml" : "last-edited-lock.xml")
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
cc_background_panel_get_help_uri (CcPanel *panel)
|
cc_background_panel_get_help_uri (CcPanel *panel)
|
||||||
|
@ -85,42 +84,42 @@ cc_background_panel_get_help_uri (CcPanel *panel)
|
||||||
static void
|
static void
|
||||||
cc_background_panel_dispose (GObject *object)
|
cc_background_panel_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = CC_BACKGROUND_PANEL (object)->priv;
|
CcBackgroundPanel *panel = CC_BACKGROUND_PANEL (object);
|
||||||
|
|
||||||
g_clear_object (&priv->builder);
|
g_clear_object (&panel->builder);
|
||||||
|
|
||||||
/* destroying the builder object will also destroy the spinner */
|
/* destroying the builder object will also destroy the spinner */
|
||||||
priv->spinner = NULL;
|
panel->spinner = NULL;
|
||||||
|
|
||||||
g_clear_object (&priv->settings);
|
g_clear_object (&panel->settings);
|
||||||
g_clear_object (&priv->lock_settings);
|
g_clear_object (&panel->lock_settings);
|
||||||
|
|
||||||
if (priv->copy_cancellable)
|
if (panel->copy_cancellable)
|
||||||
{
|
{
|
||||||
/* cancel any copy operation */
|
/* cancel any copy operation */
|
||||||
g_cancellable_cancel (priv->copy_cancellable);
|
g_cancellable_cancel (panel->copy_cancellable);
|
||||||
|
|
||||||
g_clear_object (&priv->copy_cancellable);
|
g_clear_object (&panel->copy_cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->capture_cancellable)
|
if (panel->capture_cancellable)
|
||||||
{
|
{
|
||||||
/* cancel screenshot operations */
|
/* cancel screenshot operations */
|
||||||
g_cancellable_cancel (priv->capture_cancellable);
|
g_cancellable_cancel (panel->capture_cancellable);
|
||||||
|
|
||||||
g_clear_object (&priv->capture_cancellable);
|
g_clear_object (&panel->capture_cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->chooser)
|
if (panel->chooser)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (priv->chooser);
|
gtk_widget_destroy (panel->chooser);
|
||||||
priv->chooser = NULL;
|
panel->chooser = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&priv->thumb_factory);
|
g_clear_object (&panel->thumb_factory);
|
||||||
g_clear_object (&priv->display_screenshot);
|
g_clear_object (&panel->display_screenshot);
|
||||||
|
|
||||||
g_clear_pointer (&priv->screenshot_path, g_free);
|
g_clear_pointer (&panel->screenshot_path, g_free);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
|
G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -128,10 +127,10 @@ cc_background_panel_dispose (GObject *object)
|
||||||
static void
|
static void
|
||||||
cc_background_panel_finalize (GObject *object)
|
cc_background_panel_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = CC_BACKGROUND_PANEL (object)->priv;
|
CcBackgroundPanel *panel = CC_BACKGROUND_PANEL (object);
|
||||||
|
|
||||||
g_clear_object (&priv->current_background);
|
g_clear_object (&panel->current_background);
|
||||||
g_clear_object (&priv->current_lock_background);
|
g_clear_object (&panel->current_lock_background);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_background_panel_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cc_background_panel_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -142,8 +141,6 @@ cc_background_panel_class_init (CcBackgroundPanelClass *klass)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcBackgroundPanelPrivate));
|
|
||||||
|
|
||||||
panel_class->get_help_uri = cc_background_panel_get_help_uri;
|
panel_class->get_help_uri = cc_background_panel_get_help_uri;
|
||||||
|
|
||||||
object_class->dispose = cc_background_panel_dispose;
|
object_class->dispose = cc_background_panel_dispose;
|
||||||
|
@ -151,9 +148,9 @@ cc_background_panel_class_init (CcBackgroundPanelClass *klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_preview (CcBackgroundPanelPrivate *priv,
|
update_preview (CcBackgroundPanel *panel,
|
||||||
GSettings *settings,
|
GSettings *settings,
|
||||||
CcBackgroundItem *item)
|
CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
gboolean changes_with_time;
|
gboolean changes_with_time;
|
||||||
CcBackgroundItem *current_background;
|
CcBackgroundItem *current_background;
|
||||||
|
@ -164,10 +161,10 @@ update_preview (CcBackgroundPanelPrivate *priv,
|
||||||
{
|
{
|
||||||
g_object_unref (current_background);
|
g_object_unref (current_background);
|
||||||
current_background = cc_background_item_copy (item);
|
current_background = cc_background_item_copy (item);
|
||||||
if (settings == priv->settings)
|
if (settings == panel->settings)
|
||||||
priv->current_background = current_background;
|
panel->current_background = current_background;
|
||||||
else
|
else
|
||||||
priv->current_lock_background = current_background;
|
panel->current_lock_background = current_background;
|
||||||
cc_background_item_load (current_background, NULL);
|
cc_background_item_load (current_background, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +175,7 @@ update_preview (CcBackgroundPanelPrivate *priv,
|
||||||
changes_with_time = cc_background_item_changes_with_time (current_background);
|
changes_with_time = cc_background_item_changes_with_time (current_background);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings == priv->settings)
|
if (settings == panel->settings)
|
||||||
{
|
{
|
||||||
gtk_widget_set_visible (WID ("slide_image"), changes_with_time);
|
gtk_widget_set_visible (WID ("slide_image"), changes_with_time);
|
||||||
gtk_widget_set_visible (WID ("slide-label"), changes_with_time);
|
gtk_widget_set_visible (WID ("slide-label"), changes_with_time);
|
||||||
|
@ -209,7 +206,6 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
CcBackgroundItem *background)
|
CcBackgroundItem *background)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = panel->priv;
|
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
const gint preview_width = 309;
|
const gint preview_width = 309;
|
||||||
const gint preview_height = 168;
|
const gint preview_height = 168;
|
||||||
|
@ -219,10 +215,10 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
|
||||||
pixbuf = g_object_get_data (G_OBJECT (background), "pixbuf");
|
pixbuf = g_object_get_data (G_OBJECT (background), "pixbuf");
|
||||||
if (pixbuf == NULL)
|
if (pixbuf == NULL)
|
||||||
{
|
{
|
||||||
if (background == priv->current_background &&
|
if (background == panel->current_background &&
|
||||||
priv->display_screenshot != NULL)
|
panel->display_screenshot != NULL)
|
||||||
{
|
{
|
||||||
pixbuf = gdk_pixbuf_scale_simple (priv->display_screenshot,
|
pixbuf = gdk_pixbuf_scale_simple (panel->display_screenshot,
|
||||||
preview_width,
|
preview_width,
|
||||||
preview_height,
|
preview_height,
|
||||||
GDK_INTERP_BILINEAR);
|
GDK_INTERP_BILINEAR);
|
||||||
|
@ -232,7 +228,7 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
scale_factor = gtk_widget_get_scale_factor (widget);
|
scale_factor = gtk_widget_get_scale_factor (widget);
|
||||||
pixbuf = cc_background_item_get_frame_thumbnail (background,
|
pixbuf = cc_background_item_get_frame_thumbnail (background,
|
||||||
priv->thumb_factory,
|
panel->thumb_factory,
|
||||||
preview_width,
|
preview_width,
|
||||||
preview_height,
|
preview_height,
|
||||||
scale_factor,
|
scale_factor,
|
||||||
|
@ -276,7 +272,6 @@ on_screenshot_finished (GObject *source,
|
||||||
{
|
{
|
||||||
ScreenshotData *data = user_data;
|
ScreenshotData *data = user_data;
|
||||||
CcBackgroundPanel *panel = data->panel;
|
CcBackgroundPanel *panel = data->panel;
|
||||||
CcBackgroundPanelPrivate *priv;
|
|
||||||
GError *error;
|
GError *error;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
@ -298,14 +293,11 @@ on_screenshot_finished (GObject *source,
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
/* fallback? */
|
/* fallback? */
|
||||||
priv = panel->priv;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
g_variant_unref (result);
|
g_variant_unref (result);
|
||||||
|
|
||||||
priv = panel->priv;
|
pixbuf = gdk_pixbuf_new_from_file (panel->screenshot_path, &error);
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (panel->priv->screenshot_path, &error);
|
|
||||||
if (pixbuf == NULL)
|
if (pixbuf == NULL)
|
||||||
{
|
{
|
||||||
g_debug ("Unable to use GNOME Shell's builtin screenshot interface: %s",
|
g_debug ("Unable to use GNOME Shell's builtin screenshot interface: %s",
|
||||||
|
@ -335,23 +327,23 @@ on_screenshot_finished (GObject *source,
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&panel->priv->display_screenshot);
|
g_clear_object (&panel->display_screenshot);
|
||||||
panel->priv->display_screenshot = gdk_pixbuf_get_from_surface (surface,
|
panel->display_screenshot = gdk_pixbuf_get_from_surface (surface,
|
||||||
0, 0,
|
0, 0,
|
||||||
data->monitor_rect.width,
|
data->monitor_rect.width,
|
||||||
data->monitor_rect.height);
|
data->monitor_rect.height);
|
||||||
/* invalidate existing cached pixbuf */
|
/* invalidate existing cached pixbuf */
|
||||||
g_object_set_data (G_OBJECT (priv->current_background), "pixbuf", NULL);
|
g_object_set_data (G_OBJECT (panel->current_background), "pixbuf", NULL);
|
||||||
|
|
||||||
/* remove the temporary file created by the shell */
|
/* remove the temporary file created by the shell */
|
||||||
g_unlink (panel->priv->screenshot_path);
|
g_unlink (panel->screenshot_path);
|
||||||
g_clear_pointer (&priv->screenshot_path, g_free);
|
g_clear_pointer (&panel->screenshot_path, g_free);
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
update_display_preview (panel, WID ("background-desktop-drawingarea"), priv->current_background);
|
update_display_preview (panel, WID ("background-desktop-drawingarea"), panel->current_background);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +368,6 @@ calculate_contiguous_workarea (ScreenshotData *data)
|
||||||
static void
|
static void
|
||||||
get_screenshot_async (CcBackgroundPanel *panel)
|
get_screenshot_async (CcBackgroundPanel *panel)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = panel->priv;
|
|
||||||
gchar *path, *tmpname;
|
gchar *path, *tmpname;
|
||||||
const gchar *method_name;
|
const gchar *method_name;
|
||||||
GVariant *method_params;
|
GVariant *method_params;
|
||||||
|
@ -406,8 +397,8 @@ get_screenshot_async (CcBackgroundPanel *panel)
|
||||||
g_mkdir_with_parents (path, USER_DIR_MODE);
|
g_mkdir_with_parents (path, USER_DIR_MODE);
|
||||||
|
|
||||||
tmpname = g_strdup_printf ("scr-%d.png", g_random_int ());
|
tmpname = g_strdup_printf ("scr-%d.png", g_random_int ());
|
||||||
g_free (panel->priv->screenshot_path);
|
g_free (panel->screenshot_path);
|
||||||
panel->priv->screenshot_path = g_build_filename (path, tmpname, NULL);
|
panel->screenshot_path = g_build_filename (path, tmpname, NULL);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_free (tmpname);
|
g_free (tmpname);
|
||||||
|
|
||||||
|
@ -416,9 +407,9 @@ get_screenshot_async (CcBackgroundPanel *panel)
|
||||||
data->capture_rect.x, data->capture_rect.y,
|
data->capture_rect.x, data->capture_rect.y,
|
||||||
data->capture_rect.width, data->capture_rect.height,
|
data->capture_rect.width, data->capture_rect.height,
|
||||||
FALSE, /* flash */
|
FALSE, /* flash */
|
||||||
panel->priv->screenshot_path);
|
panel->screenshot_path);
|
||||||
|
|
||||||
g_dbus_connection_call (panel->priv->connection,
|
g_dbus_connection_call (panel->connection,
|
||||||
"org.gnome.Shell.Screenshot",
|
"org.gnome.Shell.Screenshot",
|
||||||
"/org/gnome/Shell/Screenshot",
|
"/org/gnome/Shell/Screenshot",
|
||||||
"org.gnome.Shell.Screenshot",
|
"org.gnome.Shell.Screenshot",
|
||||||
|
@ -427,7 +418,7 @@ get_screenshot_async (CcBackgroundPanel *panel)
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
priv->capture_cancellable,
|
panel->capture_cancellable,
|
||||||
on_screenshot_finished,
|
on_screenshot_finished,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
|
@ -437,15 +428,14 @@ on_preview_draw (GtkWidget *widget,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
CcBackgroundPanel *panel)
|
CcBackgroundPanel *panel)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = panel->priv;
|
|
||||||
/* we have another shot in flight or an existing cache */
|
/* we have another shot in flight or an existing cache */
|
||||||
if (panel->priv->display_screenshot == NULL
|
if (panel->display_screenshot == NULL
|
||||||
&& panel->priv->screenshot_path == NULL)
|
&& panel->screenshot_path == NULL)
|
||||||
{
|
{
|
||||||
get_screenshot_async (panel);
|
get_screenshot_async (panel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
update_display_preview (panel, widget, priv->current_background);
|
update_display_preview (panel, widget, panel->current_background);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -455,21 +445,17 @@ on_lock_preview_draw (GtkWidget *widget,
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
CcBackgroundPanel *panel)
|
CcBackgroundPanel *panel)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = panel->priv;
|
update_display_preview (panel, widget, panel->current_lock_background);
|
||||||
update_display_preview (panel, widget, priv->current_lock_background);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reload_current_bg (CcBackgroundPanel *self,
|
reload_current_bg (CcBackgroundPanel *panel,
|
||||||
GSettings *settings)
|
GSettings *settings)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv;
|
|
||||||
CcBackgroundItem *saved, *configured;
|
CcBackgroundItem *saved, *configured;
|
||||||
gchar *uri, *pcolor, *scolor;
|
gchar *uri, *pcolor, *scolor;
|
||||||
|
|
||||||
priv = self->priv;
|
|
||||||
|
|
||||||
/* Load the saved configuration */
|
/* Load the saved configuration */
|
||||||
uri = get_save_path (SAVE_PATH);
|
uri = get_save_path (SAVE_PATH);
|
||||||
saved = cc_background_xml_get_item (uri);
|
saved = cc_background_xml_get_item (uri);
|
||||||
|
@ -520,15 +506,15 @@ reload_current_bg (CcBackgroundPanel *self,
|
||||||
if (saved != NULL)
|
if (saved != NULL)
|
||||||
g_object_unref (saved);
|
g_object_unref (saved);
|
||||||
|
|
||||||
if (settings == priv->settings)
|
if (settings == panel->settings)
|
||||||
{
|
{
|
||||||
g_clear_object (&priv->current_background);
|
g_clear_object (&panel->current_background);
|
||||||
priv->current_background = configured;
|
panel->current_background = configured;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_clear_object (&priv->current_lock_background);
|
g_clear_object (&panel->current_lock_background);
|
||||||
priv->current_lock_background = configured;
|
panel->current_lock_background = configured;
|
||||||
}
|
}
|
||||||
cc_background_item_load (configured, NULL);
|
cc_background_item_load (configured, NULL);
|
||||||
}
|
}
|
||||||
|
@ -559,7 +545,6 @@ copy_finished_cb (GObject *source_object,
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
CcBackgroundPanel *panel = (CcBackgroundPanel *) pointer;
|
CcBackgroundPanel *panel = (CcBackgroundPanel *) pointer;
|
||||||
CcBackgroundPanelPrivate *priv = panel->priv;
|
|
||||||
CcBackgroundItem *item;
|
CcBackgroundItem *item;
|
||||||
CcBackgroundItem *current_background;
|
CcBackgroundItem *current_background;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
@ -582,20 +567,20 @@ copy_finished_cb (GObject *source_object,
|
||||||
/* the panel may have been destroyed before the callback is run, so be sure
|
/* the panel may have been destroyed before the callback is run, so be sure
|
||||||
* to check the widgets are not NULL */
|
* to check the widgets are not NULL */
|
||||||
|
|
||||||
if (priv->spinner)
|
if (panel->spinner)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (GTK_WIDGET (priv->spinner));
|
gtk_widget_destroy (GTK_WIDGET (panel->spinner));
|
||||||
priv->spinner = NULL;
|
panel->spinner = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_background)
|
if (current_background)
|
||||||
cc_background_item_load (current_background, NULL);
|
cc_background_item_load (current_background, NULL);
|
||||||
|
|
||||||
if (priv->builder)
|
if (panel->builder)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
update_preview (priv, settings, item);
|
update_preview (panel, settings, item);
|
||||||
current_background = CURRENT_BG;
|
current_background = CURRENT_BG;
|
||||||
|
|
||||||
/* Save the source XML if there is one */
|
/* Save the source XML if there is one */
|
||||||
|
@ -613,7 +598,6 @@ set_background (CcBackgroundPanel *panel,
|
||||||
GSettings *settings,
|
GSettings *settings,
|
||||||
CcBackgroundItem *item)
|
CcBackgroundItem *item)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = panel->priv;
|
|
||||||
GDesktopBackgroundStyle style;
|
GDesktopBackgroundStyle style;
|
||||||
gboolean save_settings = TRUE;
|
gboolean save_settings = TRUE;
|
||||||
const char *uri;
|
const char *uri;
|
||||||
|
@ -663,24 +647,24 @@ set_background (CcBackgroundPanel *panel,
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
g_free (dest_path);
|
g_free (dest_path);
|
||||||
|
|
||||||
if (priv->copy_cancellable)
|
if (panel->copy_cancellable)
|
||||||
{
|
{
|
||||||
g_cancellable_cancel (priv->copy_cancellable);
|
g_cancellable_cancel (panel->copy_cancellable);
|
||||||
g_cancellable_reset (priv->copy_cancellable);
|
g_cancellable_reset (panel->copy_cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->spinner)
|
if (panel->spinner)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (GTK_WIDGET (priv->spinner));
|
gtk_widget_destroy (GTK_WIDGET (panel->spinner));
|
||||||
priv->spinner = NULL;
|
panel->spinner = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a spinner while the file downloads */
|
/* create a spinner while the file downloads */
|
||||||
priv->spinner = gtk_spinner_new ();
|
panel->spinner = gtk_spinner_new ();
|
||||||
gtk_spinner_start (GTK_SPINNER (priv->spinner));
|
gtk_spinner_start (GTK_SPINNER (panel->spinner));
|
||||||
gtk_box_pack_start (GTK_BOX (WID ("bottom-hbox")), priv->spinner, FALSE,
|
gtk_box_pack_start (GTK_BOX (WID ("bottom-hbox")), panel->spinner, FALSE,
|
||||||
FALSE, 6);
|
FALSE, 6);
|
||||||
gtk_widget_show (priv->spinner);
|
gtk_widget_show (panel->spinner);
|
||||||
|
|
||||||
/* reference the panel in case it is removed before the copy is
|
/* reference the panel in case it is removed before the copy is
|
||||||
* finished */
|
* finished */
|
||||||
|
@ -688,7 +672,7 @@ set_background (CcBackgroundPanel *panel,
|
||||||
g_object_set_data_full (G_OBJECT (source), "item", g_object_ref (item), g_object_unref);
|
g_object_set_data_full (G_OBJECT (source), "item", g_object_ref (item), g_object_unref);
|
||||||
g_object_set_data (G_OBJECT (source), "settings", settings);
|
g_object_set_data (G_OBJECT (source), "settings", settings);
|
||||||
g_file_copy_async (source, dest, G_FILE_COPY_OVERWRITE,
|
g_file_copy_async (source, dest, G_FILE_COPY_OVERWRITE,
|
||||||
G_PRIORITY_DEFAULT, priv->copy_cancellable,
|
G_PRIORITY_DEFAULT, panel->copy_cancellable,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
copy_finished_cb, panel);
|
copy_finished_cb, panel);
|
||||||
g_object_unref (source);
|
g_object_unref (source);
|
||||||
|
@ -764,32 +748,31 @@ on_chooser_dialog_response (GtkDialog *dialog,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
launch_chooser (CcBackgroundPanel *self,
|
launch_chooser (CcBackgroundPanel *panel,
|
||||||
GSettings *settings)
|
GSettings *settings)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv = self->priv;
|
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
dialog = cc_background_chooser_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (WID ("background-panel"))));
|
dialog = cc_background_chooser_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (WID ("background-panel"))));
|
||||||
g_object_set_data (G_OBJECT (dialog), "settings", settings);
|
g_object_set_data (G_OBJECT (dialog), "settings", settings);
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
g_signal_connect (dialog, "response", G_CALLBACK (on_chooser_dialog_response), self);
|
g_signal_connect (dialog, "response", G_CALLBACK (on_chooser_dialog_response), panel);
|
||||||
priv->chooser = dialog;
|
panel->chooser = dialog;
|
||||||
g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &priv->chooser);
|
g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &panel->chooser);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_background_button_clicked (GtkButton *button,
|
on_background_button_clicked (GtkButton *button,
|
||||||
CcBackgroundPanel *self)
|
CcBackgroundPanel *self)
|
||||||
{
|
{
|
||||||
launch_chooser (self, self->priv->settings);
|
launch_chooser (self, self->settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_lock_button_clicked (GtkButton *button,
|
on_lock_button_clicked (GtkButton *button,
|
||||||
CcBackgroundPanel *self)
|
CcBackgroundPanel *self)
|
||||||
{
|
{
|
||||||
launch_chooser (self, self->priv->lock_settings);
|
launch_chooser (self, self->lock_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -798,24 +781,21 @@ on_settings_changed (GSettings *settings,
|
||||||
CcBackgroundPanel *self)
|
CcBackgroundPanel *self)
|
||||||
{
|
{
|
||||||
reload_current_bg (self, settings);
|
reload_current_bg (self, settings);
|
||||||
update_preview (self->priv, settings, NULL);
|
update_preview (self, settings, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_background_panel_init (CcBackgroundPanel *self)
|
cc_background_panel_init (CcBackgroundPanel *panel)
|
||||||
{
|
{
|
||||||
CcBackgroundPanelPrivate *priv;
|
|
||||||
gchar *objects[] = {"background-panel", NULL };
|
gchar *objects[] = {"background-panel", NULL };
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
priv = self->priv = BACKGROUND_PANEL_PRIVATE (self);
|
panel->connection = g_application_get_dbus_connection (g_application_get_default ());
|
||||||
|
|
||||||
priv->connection = g_application_get_dbus_connection (g_application_get_default ());
|
|
||||||
g_resources_register (cc_background_get_resource ());
|
g_resources_register (cc_background_get_resource ());
|
||||||
|
|
||||||
priv->builder = gtk_builder_new ();
|
panel->builder = gtk_builder_new ();
|
||||||
gtk_builder_add_objects_from_resource (priv->builder,
|
gtk_builder_add_objects_from_resource (panel->builder,
|
||||||
"/org/gnome/control-center/background/background.ui",
|
"/org/gnome/control-center/background/background.ui",
|
||||||
objects, &err);
|
objects, &err);
|
||||||
|
|
||||||
|
@ -826,42 +806,42 @@ cc_background_panel_init (CcBackgroundPanel *self)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->settings = g_settings_new (WP_PATH_ID);
|
panel->settings = g_settings_new (WP_PATH_ID);
|
||||||
g_settings_delay (priv->settings);
|
g_settings_delay (panel->settings);
|
||||||
|
|
||||||
priv->lock_settings = g_settings_new (WP_LOCK_PATH_ID);
|
panel->lock_settings = g_settings_new (WP_LOCK_PATH_ID);
|
||||||
g_settings_delay (priv->lock_settings);
|
g_settings_delay (panel->lock_settings);
|
||||||
|
|
||||||
/* add the top level widget */
|
/* add the top level widget */
|
||||||
widget = WID ("background-panel");
|
widget = WID ("background-panel");
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (self), widget);
|
gtk_container_add (GTK_CONTAINER (panel), widget);
|
||||||
gtk_widget_show_all (GTK_WIDGET (self));
|
gtk_widget_show_all (GTK_WIDGET (panel));
|
||||||
|
|
||||||
/* setup preview area */
|
/* setup preview area */
|
||||||
widget = WID ("background-desktop-drawingarea");
|
widget = WID ("background-desktop-drawingarea");
|
||||||
g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw), self);
|
g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw), panel);
|
||||||
widget = WID ("background-lock-drawingarea");
|
widget = WID ("background-lock-drawingarea");
|
||||||
g_signal_connect (widget, "draw", G_CALLBACK (on_lock_preview_draw), self);
|
g_signal_connect (widget, "draw", G_CALLBACK (on_lock_preview_draw), panel);
|
||||||
|
|
||||||
priv->copy_cancellable = g_cancellable_new ();
|
panel->copy_cancellable = g_cancellable_new ();
|
||||||
priv->capture_cancellable = g_cancellable_new ();
|
panel->capture_cancellable = g_cancellable_new ();
|
||||||
|
|
||||||
priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
panel->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
||||||
|
|
||||||
/* Load the backgrounds */
|
/* Load the backgrounds */
|
||||||
reload_current_bg (self, priv->settings);
|
reload_current_bg (panel, panel->settings);
|
||||||
update_preview (priv, priv->settings, NULL);
|
update_preview (panel, panel->settings, NULL);
|
||||||
reload_current_bg (self, priv->lock_settings);
|
reload_current_bg (panel, panel->lock_settings);
|
||||||
update_preview (priv, priv->lock_settings, NULL);
|
update_preview (panel, panel->lock_settings, NULL);
|
||||||
|
|
||||||
/* Background settings */
|
/* Background settings */
|
||||||
g_signal_connect (priv->settings, "changed", G_CALLBACK (on_settings_changed), self);
|
g_signal_connect (panel->settings, "changed", G_CALLBACK (on_settings_changed), panel);
|
||||||
g_signal_connect (priv->lock_settings, "changed", G_CALLBACK (on_settings_changed), self);
|
g_signal_connect (panel->lock_settings, "changed", G_CALLBACK (on_settings_changed), panel);
|
||||||
|
|
||||||
/* Background buttons */
|
/* Background buttons */
|
||||||
widget = WID ("background-set-button");
|
widget = WID ("background-set-button");
|
||||||
g_signal_connect (widget, "clicked", G_CALLBACK (on_background_button_clicked), self);
|
g_signal_connect (widget, "clicked", G_CALLBACK (on_background_button_clicked), panel);
|
||||||
widget = WID ("background-lock-set-button");
|
widget = WID ("background-lock-set-button");
|
||||||
g_signal_connect (widget, "clicked", G_CALLBACK (on_lock_button_clicked), self);
|
g_signal_connect (widget, "clicked", G_CALLBACK (on_lock_button_clicked), panel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,45 +26,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_BACKGROUND_PANEL cc_background_panel_get_type()
|
#define CC_TYPE_BACKGROUND_PANEL (cc_background_panel_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (CcBackgroundPanel, cc_background_panel, CC, BACKGROUND_PANEL, CcPanel)
|
||||||
#define CC_BACKGROUND_PANEL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
CC_TYPE_BACKGROUND_PANEL, CcBackgroundPanel))
|
|
||||||
|
|
||||||
#define CC_BACKGROUND_PANEL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
CC_TYPE_BACKGROUND_PANEL, CcBackgroundPanelClass))
|
|
||||||
|
|
||||||
#define CC_IS_BACKGROUND_PANEL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
CC_TYPE_BACKGROUND_PANEL))
|
|
||||||
|
|
||||||
#define CC_IS_BACKGROUND_PANEL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
CC_TYPE_BACKGROUND_PANEL))
|
|
||||||
|
|
||||||
#define CC_BACKGROUND_PANEL_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
CC_TYPE_BACKGROUND_PANEL, CcBackgroundPanelClass))
|
|
||||||
|
|
||||||
typedef struct _CcBackgroundPanel CcBackgroundPanel;
|
|
||||||
typedef struct _CcBackgroundPanelClass CcBackgroundPanelClass;
|
|
||||||
typedef struct _CcBackgroundPanelPrivate CcBackgroundPanelPrivate;
|
|
||||||
|
|
||||||
struct _CcBackgroundPanel
|
|
||||||
{
|
|
||||||
CcPanel parent;
|
|
||||||
|
|
||||||
CcBackgroundPanelPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcBackgroundPanelClass
|
|
||||||
{
|
|
||||||
CcPanelClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType cc_background_panel_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,16 @@
|
||||||
* returning to the main loop */
|
* returning to the main loop */
|
||||||
#define NUM_ITEMS_PER_BATCH 1
|
#define NUM_ITEMS_PER_BATCH 1
|
||||||
|
|
||||||
struct CcBackgroundXmlPrivate
|
struct _CcBackgroundXml
|
||||||
{
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
GHashTable *wp_hash;
|
GHashTable *wp_hash;
|
||||||
GAsyncQueue *item_added_queue;
|
GAsyncQueue *item_added_queue;
|
||||||
guint item_added_id;
|
guint item_added_id;
|
||||||
GSList *monitors; /* GSList of GFileMonitor */
|
GSList *monitors; /* GSList of GFileMonitor */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CC_BACKGROUND_XML_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_BACKGROUND_XML, CcBackgroundXmlPrivate))
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ADDED,
|
ADDED,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
|
@ -118,20 +118,20 @@ idle_emit (CcBackgroundXml *xml)
|
||||||
GObject *item;
|
GObject *item;
|
||||||
guint i = NUM_ITEMS_PER_BATCH;
|
guint i = NUM_ITEMS_PER_BATCH;
|
||||||
|
|
||||||
g_async_queue_lock (xml->priv->item_added_queue);
|
g_async_queue_lock (xml->item_added_queue);
|
||||||
|
|
||||||
while (i > 0 && (item = g_async_queue_try_pop_unlocked (xml->priv->item_added_queue)) != NULL) {
|
while (i > 0 && (item = g_async_queue_try_pop_unlocked (xml->item_added_queue)) != NULL) {
|
||||||
g_signal_emit (G_OBJECT (xml), signals[ADDED], 0, item);
|
g_signal_emit (G_OBJECT (xml), signals[ADDED], 0, item);
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_async_queue_unlock (xml->priv->item_added_queue);
|
g_async_queue_unlock (xml->item_added_queue);
|
||||||
|
|
||||||
if (g_async_queue_length (xml->priv->item_added_queue) > 0) {
|
if (g_async_queue_length (xml->item_added_queue) > 0) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
xml->priv->item_added_id = 0;
|
xml->item_added_id = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,11 +140,11 @@ static void
|
||||||
emit_added_in_idle (CcBackgroundXml *xml,
|
emit_added_in_idle (CcBackgroundXml *xml,
|
||||||
GObject *object)
|
GObject *object)
|
||||||
{
|
{
|
||||||
g_async_queue_lock (xml->priv->item_added_queue);
|
g_async_queue_lock (xml->item_added_queue);
|
||||||
g_async_queue_push_unlocked (xml->priv->item_added_queue, object);
|
g_async_queue_push_unlocked (xml->item_added_queue, object);
|
||||||
if (xml->priv->item_added_id == 0)
|
if (xml->item_added_id == 0)
|
||||||
xml->priv->item_added_id = g_idle_add ((GSourceFunc) idle_emit, xml);
|
xml->item_added_id = g_idle_add ((GSourceFunc) idle_emit, xml);
|
||||||
g_async_queue_unlock (xml->priv->item_added_queue);
|
g_async_queue_unlock (xml->item_added_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NONE "(none)"
|
#define NONE "(none)"
|
||||||
|
@ -305,14 +305,14 @@ cc_background_xml_load_xml_internal (CcBackgroundXml *xml,
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
||||||
/* Make sure we don't already have this one and that filename exists */
|
/* Make sure we don't already have this one and that filename exists */
|
||||||
if (g_hash_table_lookup (xml->priv->wp_hash, id) != NULL) {
|
if (g_hash_table_lookup (xml->wp_hash, id) != NULL) {
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
g_free (id);
|
g_free (id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set (G_OBJECT (item), "flags", flags, NULL);
|
g_object_set (G_OBJECT (item), "flags", flags, NULL);
|
||||||
g_hash_table_insert (xml->priv->wp_hash,
|
g_hash_table_insert (xml->wp_hash,
|
||||||
g_strdup (id),
|
g_strdup (id),
|
||||||
g_object_ref (item));
|
g_object_ref (item));
|
||||||
if (in_thread)
|
if (in_thread)
|
||||||
|
@ -377,7 +377,7 @@ cc_background_xml_add_monitor (GFile *directory,
|
||||||
G_CALLBACK (gnome_wp_file_changed),
|
G_CALLBACK (gnome_wp_file_changed),
|
||||||
data);
|
data);
|
||||||
|
|
||||||
data->priv->monitors = g_slist_prepend (data->priv->monitors, monitor);
|
data->monitors = g_slist_prepend (data->monitors, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -460,7 +460,7 @@ cc_background_xml_load_list_finish (GAsyncResult *async_result)
|
||||||
g_warn_if_fail (g_simple_async_result_get_source_tag (result) == cc_background_xml_load_list_async);
|
g_warn_if_fail (g_simple_async_result_get_source_tag (result) == cc_background_xml_load_list_async);
|
||||||
|
|
||||||
data = CC_BACKGROUND_XML (g_simple_async_result_get_op_res_gpointer (result));
|
data = CC_BACKGROUND_XML (g_simple_async_result_get_op_res_gpointer (result));
|
||||||
return data->priv->wp_hash;
|
return data->wp_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -631,16 +631,14 @@ cc_background_xml_finalize (GObject *object)
|
||||||
|
|
||||||
xml = CC_BACKGROUND_XML (object);
|
xml = CC_BACKGROUND_XML (object);
|
||||||
|
|
||||||
g_return_if_fail (xml->priv != NULL);
|
g_slist_free_full (xml->monitors, g_object_unref);
|
||||||
|
|
||||||
g_slist_free_full (xml->priv->monitors, g_object_unref);
|
g_clear_pointer (&xml->wp_hash, g_hash_table_destroy);
|
||||||
|
if (xml->item_added_id != 0) {
|
||||||
g_clear_pointer (&xml->priv->wp_hash, g_hash_table_destroy);
|
g_source_remove (xml->item_added_id);
|
||||||
if (xml->priv->item_added_id != 0) {
|
xml->item_added_id = 0;
|
||||||
g_source_remove (xml->priv->item_added_id);
|
|
||||||
xml->priv->item_added_id = 0;
|
|
||||||
}
|
}
|
||||||
g_clear_pointer (&xml->priv->item_added_queue, g_async_queue_unref);
|
g_clear_pointer (&xml->item_added_queue, g_async_queue_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -657,19 +655,16 @@ cc_background_xml_class_init (CcBackgroundXmlClass *klass)
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__OBJECT,
|
g_cclosure_marshal_VOID__OBJECT,
|
||||||
G_TYPE_NONE, 1, CC_TYPE_BACKGROUND_ITEM);
|
G_TYPE_NONE, 1, CC_TYPE_BACKGROUND_ITEM);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcBackgroundXmlPrivate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_background_xml_init (CcBackgroundXml *xml)
|
cc_background_xml_init (CcBackgroundXml *xml)
|
||||||
{
|
{
|
||||||
xml->priv = CC_BACKGROUND_XML_GET_PRIVATE (xml);
|
xml->wp_hash = g_hash_table_new_full (g_str_hash,
|
||||||
xml->priv->wp_hash = g_hash_table_new_full (g_str_hash,
|
|
||||||
g_str_equal,
|
g_str_equal,
|
||||||
(GDestroyNotify) g_free,
|
(GDestroyNotify) g_free,
|
||||||
(GDestroyNotify) g_object_unref);
|
(GDestroyNotify) g_object_unref);
|
||||||
xml->priv->item_added_queue = g_async_queue_new_full ((GDestroyNotify) g_object_unref);
|
xml->item_added_queue = g_async_queue_new_full ((GDestroyNotify) g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
CcBackgroundXml *
|
CcBackgroundXml *
|
||||||
|
|
|
@ -26,28 +26,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_BACKGROUND_XML (cc_background_xml_get_type ())
|
#define CC_TYPE_BACKGROUND_XML (cc_background_xml_get_type ())
|
||||||
#define CC_BACKGROUND_XML(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_BACKGROUND_XML, CcBackgroundXml))
|
G_DECLARE_FINAL_TYPE (CcBackgroundXml, cc_background_xml, CC, BACKGROUND_XML, GObject)
|
||||||
#define CC_BACKGROUND_XML_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_BACKGROUND_XML, CcBackgroundXmlClass))
|
|
||||||
#define CC_IS_BACKGROUND_XML(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_BACKGROUND_XML))
|
|
||||||
#define CC_IS_BACKGROUND_XML_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_BACKGROUND_XML))
|
|
||||||
#define CC_BACKGROUND_XML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_BACKGROUND_XML, CcBackgroundXmlClass))
|
|
||||||
|
|
||||||
typedef struct CcBackgroundXmlPrivate CcBackgroundXmlPrivate;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GObject parent;
|
|
||||||
CcBackgroundXmlPrivate *priv;
|
|
||||||
} CcBackgroundXml;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GObjectClass parent_class;
|
|
||||||
void (*added) (CcBackgroundXml *xml, GObject *item);
|
|
||||||
} CcBackgroundXmlClass;
|
|
||||||
|
|
||||||
GType cc_background_xml_get_type (void);
|
|
||||||
|
|
||||||
CcBackgroundXml *cc_background_xml_new (void);
|
CcBackgroundXml *cc_background_xml_new (void);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue