[Xfce4-commits] <ristretto:master> Add configure dialog for set-wallpeper Fix compile issues
Stephan Arts
noreply at xfce.org
Sun Oct 25 21:14:01 CET 2009
Updating branch refs/heads/master
to bc4001f617669450b7abca15db8e9d264c964aae (commit)
from 9112f41c262427b7dd60b1b77bb7373044850b55 (commit)
commit bc4001f617669450b7abca15db8e9d264c964aae
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Oct 25 21:12:21 2009 +0100
Add configure dialog for set-wallpeper
Fix compile issues
ChangeLog | 4 +
src/app_menu_item.c | 1 -
src/main_window.c | 35 ++++-------
src/picture_viewer.c | 3 +-
src/preferences_dialog.c | 2 -
src/settings.c | 2 +
src/thumbnail.c | 8 +-
src/thumbnail_bar.c | 2 +-
src/wallpaper_manager.c | 9 +--
src/xfce_wallpaper_manager.c | 142 ++++++++++++++++++++++++++++++++++++------
10 files changed, 153 insertions(+), 55 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 17e70a8..4480a7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-10-25 Stephan Arts <stephan at xfce.org>
+ * src/xfce_wallpaper_manager.c: Add configure-dialog
+
+2009-10-25 Stephan Arts <stephan at xfce.org>
+
* src/image_list.c,
src/image_list.h,
src/settings.c,
diff --git a/src/app_menu_item.c b/src/app_menu_item.c
index 9b5c35f..fe505fa 100644
--- a/src/app_menu_item.c
+++ b/src/app_menu_item.c
@@ -74,7 +74,6 @@ rstto_app_menu_item_init (RsttoAppMenuItem *menu_item)
static void
rstto_app_menu_item_class_init(RsttoAppMenuItemClass *app_menu_item_class)
{
- GtkWidgetClass *widget_class;
GtkMenuItemClass *menu_item_class;
GObjectClass *object_class;
diff --git a/src/main_window.c b/src/main_window.c
index 15aea93..674c617 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -153,8 +153,6 @@ cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window);
static void
cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window);
static void
-cb_rstto_main_window_image_list_iter_prepare_change (RsttoImageListIter *iter, RsttoMainWindow *window);
-static void
cb_rstto_main_window_image_updated (RsttoImage *image, RsttoMainWindow *window);
static void
@@ -705,7 +703,7 @@ rstto_main_window_new (RsttoImageList *image_list, gboolean fullscreen)
static void
rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
{
- gchar *path, *basename, *title, *status;
+ gchar *path, *path_basename, *title, *status;
GFile *file = NULL;
GFileInfo *file_info = NULL;
RsttoImage *cur_image;
@@ -747,19 +745,19 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
path = g_file_get_path (file);
- basename = g_path_get_basename (path);
+ path_basename = g_path_get_basename (path);
- title = g_strdup_printf ("%s - %s [%d/%d]", RISTRETTO_APP_TITLE, basename, position+1, count);
+ title = g_strdup_printf ("%s - %s [%d/%d]", RISTRETTO_APP_TITLE, path_basename, position+1, count);
if (width > 0)
{
status = g_strdup_printf ("%d x %d", width, height);
}
else
{
- status = g_strdup_printf ("Loading '%s'", basename);
+ status = g_strdup_printf ("Loading '%s'", path_basename);
}
- g_free (basename);
+ g_free (path_basename);
g_free (path);
}
else
@@ -791,16 +789,6 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window)
}
-static void
-cb_rstto_main_window_image_list_iter_prepare_change (RsttoImageListIter *iter, RsttoMainWindow *window)
-{
- RsttoImage *image = rstto_image_list_iter_get_image (iter);
- if (image)
- {
- g_signal_handlers_disconnect_by_func (image, cb_rstto_main_window_image_updated, window);
- }
-}
-
/**
* rstto_main_window_update_buttons:
* @window:
@@ -2202,17 +2190,20 @@ cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window)
static void
cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window)
{
- g_return_if_fail (rstto_image_list_get_n_images (window->priv->props.image_list) > 0);
RsttoImage *image = rstto_image_list_iter_get_image (window->priv->iter);
GFile *file = rstto_image_get_file (image);
gchar *path = g_file_get_path (file);
- gchar *basename = g_path_get_basename (path);
- GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ gchar *path_basename = g_path_get_basename (path);
+ GtkWidget *dialog;
+ g_return_if_fail (rstto_image_list_get_n_images (window->priv->props.image_list) > 0);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK_CANCEL,
N_("Are you sure you want to delete image '%s' from disk?"),
- basename);
+ path_basename);
+
g_object_ref (image);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
{
@@ -2226,7 +2217,7 @@ cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window)
}
}
gtk_widget_destroy (dialog);
- g_free (basename);
+ g_free (path_basename);
g_free (path);
g_object_unref (image);
}
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 0eb1897..fb4a031 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -411,6 +411,7 @@ rstto_picture_viewer_paint (GtkWidget *widget)
{
RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER(widget);
GdkPixbuf *pixbuf = viewer->priv->dst_pixbuf;
+ GdkPixbuf *n_pixbuf = NULL;
GdkColor color;
GdkColor line_color;
gint i, a, height, width;
@@ -613,7 +614,7 @@ rstto_picture_viewer_paint (GtkWidget *widget)
if (pixbuf)
{
gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0, TRUE);
- GdkPixbuf *n_pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 40, 40, bg_color->pixel, bg_color->pixel);
+ n_pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 40, 40, bg_color->pixel, bg_color->pixel);
g_object_unref (pixbuf);
pixbuf = n_pixbuf;
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index e4cad7e..4b8a570 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -191,8 +191,6 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
GdkColor *bgcolor;
GtkWidget *timeout_lbl, *timeout_hscale;
- GtkWidget *thumbnail_lbl;
- GtkWidget *widget;
GtkObject *cache_adjustment;
GtkWidget *display_main_vbox;
GtkWidget *display_main_lbl;
diff --git a/src/settings.c b/src/settings.c
index 669797e..13ca18a 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -690,6 +690,8 @@ rstto_settings_get_navbar_position (RsttoSettings *settings) {
return 2;
if (!strcmp (settings->priv->navigationbar_position, "bottom"))
return 3;
+
+ return 0;
}
/** Convenience functions */
diff --git a/src/thumbnail.c b/src/thumbnail.c
index 85eaabc..16e8f27 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -288,7 +288,7 @@ rstto_thumbnail_paint(RsttoThumbnail *thumb)
GtkWidget *
rstto_thumbnail_new (RsttoImage *image)
{
- gchar *path, *basename;
+ gchar *path, *path_basename;
GFile *file = NULL;
RsttoThumbnail *thumb;
@@ -302,11 +302,11 @@ rstto_thumbnail_new (RsttoImage *image)
file = rstto_image_get_file (image);
path = g_file_get_path (file);
- basename = g_path_get_basename (path);
+ path_basename = g_path_get_basename (path);
- gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), basename);
+ gtk_widget_set_tooltip_text(GTK_WIDGET(thumb), path_basename);
- g_free (basename);
+ g_free (path_basename);
g_free (path);
return GTK_WIDGET(thumb);
}
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
index 9215322..6de645e 100644
--- a/src/thumbnail_bar.c
+++ b/src/thumbnail_bar.c
@@ -379,6 +379,7 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
GdkEventExpose *n_ex = g_new0(GdkEventExpose, 1);
+ GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
gint border_width = GTK_CONTAINER(bar)->border_width;
gint film_border_width = bar->film_border_width;
gint i = 0;
@@ -402,7 +403,6 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
n_ex->area.height = ex->area.height;
n_ex->count = ex->count;
- GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &color, FALSE, TRUE);
gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &dot_color, FALSE, TRUE);
gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &bar_color, FALSE, TRUE);
diff --git a/src/wallpaper_manager.c b/src/wallpaper_manager.c
index 4ac5997..e0bc7ef 100644
--- a/src/wallpaper_manager.c
+++ b/src/wallpaper_manager.c
@@ -33,25 +33,24 @@
gint
rstto_wallpaper_manager_configure_dialog_run (RsttoWallpaperManager *self, RsttoImage *image)
{
- RSTTO_WALLPAPER_MANAGER_GET_IFACE (self)->configure_dialog_run(self, image);
+ return RSTTO_WALLPAPER_MANAGER_GET_IFACE (self)->configure_dialog_run(self, image);
}
gboolean
rstto_wallpaper_manager_check_running (RsttoWallpaperManager *self)
{
- RSTTO_WALLPAPER_MANAGER_GET_IFACE (self)->check_running (self);
+ return RSTTO_WALLPAPER_MANAGER_GET_IFACE (self)->check_running (self);
}
gboolean
rstto_wallpaper_manager_set (RsttoWallpaperManager *self, RsttoImage *image)
{
- RSTTO_WALLPAPER_MANAGER_GET_IFACE (self)->set (self, image);
+ return RSTTO_WALLPAPER_MANAGER_GET_IFACE (self)->set (self, image);
}
static void
-rstto_wallpaper_manager_iface_init (gpointer g_iface,
- gpointer iface_data)
+rstto_wallpaper_manager_iface_init (gpointer g_iface)
{
RsttoWallpaperManagerIface *iface = (RsttoWallpaperManagerIface *)g_iface;
iface->configure_dialog_run = rstto_wallpaper_manager_configure_dialog_run;
diff --git a/src/xfce_wallpaper_manager.c b/src/xfce_wallpaper_manager.c
index 9a9b0ad..34d5693 100644
--- a/src/xfce_wallpaper_manager.c
+++ b/src/xfce_wallpaper_manager.c
@@ -58,6 +58,13 @@ static RsttoXfceWallpaperManager *xfce_wallpaper_manager_object;
struct _RsttoXfceWallpaperManagerPriv
{
XfconfChannel *channel;
+ gint screen;
+ gint monitor;
+ gint style;
+ gdouble saturation;
+ gint brightness;
+ RsttoColor *color1;
+ RsttoColor *color2;
};
@@ -69,20 +76,68 @@ enum
static gint
rstto_xfce_wallpaper_manager_configure_dialog_run (RsttoWallpaperManager *self, RsttoImage *image)
{
- return GTK_RESPONSE_OK;
+ RsttoXfceWallpaperManager *manager = RSTTO_XFCE_WALLPAPER_MANAGER (self);
+ gint response = GTK_RESPONSE_OK;
+ GdkScreen *screen = gdk_screen_get_default ();
+ //gint n_monitors = gdk_screen_get_n_monitors (screen);
+ GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Set as wallpaper"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ GtkWidget *vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ GtkWidget *style_label = gtk_label_new( _("Style:"));
+ GtkWidget *style_combo = gtk_combo_box_new_text();
+ GtkWidget *brightness_label = gtk_label_new( _("Brightness:"));
+ GtkWidget *saturation_label = gtk_label_new( _("Saturation:"));
+ GtkWidget *brightness_slider = gtk_hscale_new_with_range (-1, 1, 0.1);
+ GtkWidget *saturation_slider = gtk_hscale_new_with_range (-1, 2, 0.1);
+ GtkWidget *image_hbox = gtk_hbox_new (FALSE, 4);
+ GtkWidget *image_box = gtk_image_new_from_pixbuf (rstto_image_get_thumbnail (image));
+ GtkWidget *prop_table = gtk_table_new (1, 2, FALSE);
+ GtkWidget *image_prop_table = gtk_table_new (2, 2, FALSE);
+
+ gtk_box_pack_start (GTK_BOX (vbox), image_hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (image_hbox), image_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (image_hbox), prop_table, FALSE, FALSE, 0);
+ gtk_table_attach (GTK_TABLE (prop_table), style_label, 0, 1, 0, 1, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (prop_table), style_combo, 1, 2, 0, 1, 0, 0, 0, 0);
+
+ gtk_box_pack_start (GTK_BOX (vbox), image_prop_table, FALSE, FALSE, 0);
+ gtk_table_attach (GTK_TABLE (image_prop_table), brightness_label, 0, 1, 0, 1, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (image_prop_table), brightness_slider, 1, 2, 0, 1, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (image_prop_table), saturation_label, 0, 1, 1, 2, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (image_prop_table), saturation_slider, 1, 2, 1, 2, 0, 0, 0, 0);
+
+ gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Auto"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Centered"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Tiled"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Stretched"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Scaled"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Zoomed"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (style_combo), 4);
+
+ manager->priv->screen = gdk_screen_get_number (screen);
+
+ gtk_widget_show_all (vbox);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (dialog);
+ if (response == GTK_RESPONSE_OK)
+ {
+ manager->priv->style = gtk_combo_box_get_active (GTK_COMBO_BOX (style_combo));
+ }
+
+ gtk_widget_destroy (dialog);
+ return response;
}
static gboolean
rstto_xfce_wallpaper_manager_check_running (RsttoWallpaperManager *self)
{
gchar selection_name[100];
-
+ Atom xfce_selection_atom;
GdkScreen *gdk_screen = gdk_screen_get_default();
gint xscreen = gdk_screen_get_number(gdk_screen);
g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen);
- Atom xfce_selection_atom = XInternAtom (gdk_display, selection_name, False);
+ xfce_selection_atom = XInternAtom (gdk_display, selection_name, False);
if((XGetSelectionOwner(GDK_DISPLAY(), xfce_selection_atom)))
{
return TRUE;
@@ -96,16 +151,63 @@ rstto_xfce_wallpaper_manager_set (RsttoWallpaperManager *self, RsttoImage *image
RsttoXfceWallpaperManager *manager = RSTTO_XFCE_WALLPAPER_MANAGER (self);
GFile *file = rstto_image_get_file (image);
gchar *uri = g_file_get_path (file);
-
- RsttoColor *color = g_new0 (RsttoColor, 1);
- color->a = 0xffff;
- xfconf_channel_set_string (manager->priv->channel, "/backdrop/screen0/monitor0/image-path", uri);
- xfconf_channel_set_bool (manager->priv->channel, "/backdrop/screen0/monitor0/image-show", TRUE);
- xfconf_channel_set_int (manager->priv->channel, "/backdrop/screen0/monitor0/image-style", 4);
- xfconf_channel_set_int (manager->priv->channel, "/backdrop/screen0/monitor0/brightness", 0);
- xfconf_channel_set_double (manager->priv->channel, "/backdrop/screen0/monitor0/saturation", 1.0);
- xfconf_channel_set_struct (manager->priv->channel, "/backdrop/screen0/monitor0/color1", color, XFCONF_TYPE_INT16, XFCONF_TYPE_INT16, XFCONF_TYPE_INT16, XFCONF_TYPE_INT16, G_TYPE_INVALID);
+ gchar *image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-path",
+ manager->priv->screen,
+ manager->priv->monitor);
+ gchar *image_show_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-show",
+ manager->priv->screen,
+ manager->priv->monitor);
+ gchar *image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-style",
+ manager->priv->screen,
+ manager->priv->monitor);
+ gchar *brightness_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/brightness",
+ manager->priv->screen,
+ manager->priv->monitor);
+ gchar *saturation_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/saturation",
+ manager->priv->screen,
+ manager->priv->monitor);
+
+ gchar *color1_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/color1",
+ manager->priv->screen,
+ manager->priv->monitor);
+ gchar *color2_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/color2",
+ manager->priv->screen,
+ manager->priv->monitor);
+
+ xfconf_channel_set_string (manager->priv->channel,
+ image_path_prop, uri);
+ xfconf_channel_set_bool (manager->priv->channel,
+ image_show_prop, TRUE);
+ xfconf_channel_set_int (manager->priv->channel,
+ image_style_prop, manager->priv->style);
+
+ xfconf_channel_set_int (manager->priv->channel,
+ brightness_prop, manager->priv->brightness);
+ xfconf_channel_set_double (manager->priv->channel,
+ saturation_prop,
+ manager->priv->saturation);
+
+ xfconf_channel_set_struct (manager->priv->channel,
+ color1_prop,
+ manager->priv->color1,
+ XFCONF_TYPE_INT16, XFCONF_TYPE_INT16,
+ XFCONF_TYPE_INT16, XFCONF_TYPE_INT16,
+ G_TYPE_INVALID);
+ xfconf_channel_set_struct (manager->priv->channel,
+ color2_prop,
+ manager->priv->color2,
+ XFCONF_TYPE_INT16, XFCONF_TYPE_INT16,
+ XFCONF_TYPE_INT16, XFCONF_TYPE_INT16,
+ G_TYPE_INVALID);
+
+ g_free (image_path_prop);
+ g_free (image_show_prop);
+ g_free (image_style_prop);
+ g_free (brightness_prop);
+ g_free (saturation_prop);
+ g_free (color1_prop);
+ g_free (color2_prop);
return FALSE;
}
@@ -139,15 +241,14 @@ rstto_xfce_wallpaper_manager_get_type (void)
NULL
};
- rstto_xfce_wallpaper_manager_type = g_type_register_static (G_TYPE_OBJECT, "RsttoXfceWallpaperManager", &rstto_xfce_wallpaper_manager_info, 0);
-
static const GInterfaceInfo wallpaper_manager_iface_info =
{
- (GInstanceInitFunc) rstto_xfce_wallpaper_manager_iface_init,
+ (GInterfaceInitFunc) rstto_xfce_wallpaper_manager_iface_init,
NULL,
NULL
};
+ rstto_xfce_wallpaper_manager_type = g_type_register_static (G_TYPE_OBJECT, "RsttoXfceWallpaperManager", &rstto_xfce_wallpaper_manager_info, 0);
g_type_add_interface_static (rstto_xfce_wallpaper_manager_type, RSTTO_WALLPAPER_MANAGER_TYPE, &wallpaper_manager_iface_info);
}
@@ -158,20 +259,23 @@ rstto_xfce_wallpaper_manager_get_type (void)
static void
rstto_xfce_wallpaper_manager_init (GObject *object)
{
- gchar *accelmap_path = NULL;
-
RsttoXfceWallpaperManager *xfce_wallpaper_manager = RSTTO_XFCE_WALLPAPER_MANAGER (object);
xfce_wallpaper_manager->priv = g_new0 (RsttoXfceWallpaperManagerPriv, 1);
xfce_wallpaper_manager->priv->channel = xfconf_channel_new ("xfce4-desktop");
+ xfce_wallpaper_manager->priv->color1 = g_new0 (RsttoColor, 1);
+ xfce_wallpaper_manager->priv->color1->a = 0xffff;
+ xfce_wallpaper_manager->priv->color2 = g_new0 (RsttoColor, 1);
+ xfce_wallpaper_manager->priv->color2->a = 0xffff;
+ xfce_wallpaper_manager->priv->style = 4;
+ xfce_wallpaper_manager->priv->brightness = 0;
+ xfce_wallpaper_manager->priv->saturation = 1.0;
}
static void
rstto_xfce_wallpaper_manager_class_init (GObjectClass *object_class)
{
- GParamSpec *pspec;
-
RsttoXfceWallpaperManagerClass *xfce_wallpaper_manager_class = RSTTO_XFCE_WALLPAPER_MANAGER_CLASS (object_class);
parent_class = g_type_class_peek_parent (xfce_wallpaper_manager_class);
More information about the Xfce4-commits
mailing list