[Xfce4-commits] <ristretto:master> Add Monitor-chooser widget to xfce-wallpaper-manager
Stephan Arts
noreply at xfce.org
Sun Sep 11 22:50:01 CEST 2011
Updating branch refs/heads/master
to 20d2e742ef8dda6236c851258b815116b67842f9 (commit)
from b1c868e1092b5ccb8c53822a68866eb68bab9733 (commit)
commit 20d2e742ef8dda6236c851258b815116b67842f9
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Sep 11 22:46:58 2011 +0200
Add Monitor-chooser widget to xfce-wallpaper-manager
src/Makefile.am | 1 +
src/monitor_chooser.c | 528 ++++++++++++++++++++++++++++++++++++++++++
src/monitor_chooser.h | 83 +++++++
src/xfce_wallpaper_manager.c | 57 ++---
4 files changed, 631 insertions(+), 38 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 062938d..8fbcad8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ ristretto_SOURCES = \
main_window_ui.h \
main_window.c main_window.h \
wallpaper_manager.c wallpaper_manager.h \
+ monitor_chooser.c monitor_chooser.h \
xfce_wallpaper_manager.c xfce_wallpaper_manager.h \
gnome_wallpaper_manager.c gnome_wallpaper_manager.h \
app_menu_item.c app_menu_item.h \
diff --git a/src/monitor_chooser.c b/src/monitor_chooser.c
new file mode 100644
index 0000000..c1be5ba
--- /dev/null
+++ b/src/monitor_chooser.c
@@ -0,0 +1,528 @@
+/*
+ * Copyright (C) Stephan Arts 2011 <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkmarshal.h>
+#include <string.h>
+#include <math.h>
+
+#include "monitor_chooser.h"
+
+typedef struct {
+ gint width;
+ gint height;
+ GdkPixbuf *pixbuf;
+} Monitor;
+
+struct _RsttoMonitorChooserPriv
+{
+ GSList *monitors;
+ gint selected;
+};
+
+static GtkWidgetClass *parent_class = NULL;
+
+static void
+rstto_monitor_chooser_init(RsttoMonitorChooser *);
+
+static void
+rstto_monitor_chooser_class_init(RsttoMonitorChooserClass *);
+
+static void
+rstto_monitor_chooser_finalize(GObject *object);
+
+static void
+rstto_monitor_chooser_realize(GtkWidget *widget);
+static void
+rstto_monitor_chooser_size_request(GtkWidget *, GtkRequisition *);
+static void
+rstto_monitor_chooser_size_allocate(GtkWidget *, GtkAllocation *);
+static gboolean
+rstto_monitor_chooser_expose(GtkWidget *, GdkEventExpose *);
+static gboolean
+rstto_monitor_chooser_paint(GtkWidget *widget);
+
+static void
+cb_rstto_button_press_event (GtkWidget *, GdkEventButton *event);
+
+static void
+paint_monitor ( cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ gchar *label,
+ Monitor *monitor,
+ gboolean active);
+
+GType
+rstto_monitor_chooser_get_type (void)
+{
+ static GType rstto_monitor_chooser_type = 0;
+
+ if (!rstto_monitor_chooser_type)
+ {
+ static const GTypeInfo rstto_monitor_chooser_info =
+ {
+ sizeof (RsttoMonitorChooserClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) rstto_monitor_chooser_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (RsttoMonitorChooser),
+ 0,
+ (GInstanceInitFunc) rstto_monitor_chooser_init,
+ NULL
+ };
+
+ rstto_monitor_chooser_type = g_type_register_static (GTK_TYPE_WIDGET, "RsttoMonitorChooser", &rstto_monitor_chooser_info, 0);
+ }
+ return rstto_monitor_chooser_type;
+}
+
+static void
+rstto_monitor_chooser_init(RsttoMonitorChooser *chooser)
+{
+ chooser->priv = g_new0(RsttoMonitorChooserPriv, 1);
+ chooser->priv->selected = -1;
+
+ gtk_widget_set_double_buffered (GTK_WIDGET(chooser), TRUE);
+
+ g_signal_connect(G_OBJECT(chooser), "button-press-event", G_CALLBACK(cb_rstto_button_press_event), NULL);
+
+ gtk_widget_set_redraw_on_allocate(GTK_WIDGET(chooser), TRUE);
+ gtk_widget_set_events (GTK_WIDGET(chooser),
+ GDK_POINTER_MOTION_MASK);
+}
+
+static void
+rstto_monitor_chooser_class_init(RsttoMonitorChooserClass *chooser_class)
+{
+ GtkWidgetClass *widget_class;
+ GObjectClass *object_class;
+ GtkButtonClass *button_class;
+
+ widget_class = (GtkWidgetClass*)chooser_class;
+ object_class = (GObjectClass*)chooser_class;
+ button_class = (GtkButtonClass*)chooser_class;
+
+ parent_class = g_type_class_peek_parent(chooser_class);
+
+ widget_class->expose_event = rstto_monitor_chooser_expose;
+ widget_class->realize = rstto_monitor_chooser_realize;
+ widget_class->size_request = rstto_monitor_chooser_size_request;
+ widget_class->size_allocate = rstto_monitor_chooser_size_allocate;
+
+ object_class->finalize = rstto_monitor_chooser_finalize;
+}
+
+static void
+rstto_monitor_chooser_finalize(GObject *object)
+{
+ RsttoMonitorChooser *chooser = RSTTO_MONITOR_CHOOSER(object);
+}
+
+/**
+ * rstto_monitor_chooser_realize:
+ * @widget:
+ *
+ */
+static void
+rstto_monitor_chooser_realize(GtkWidget *widget)
+{
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (RSTTO_IS_MONITOR_CHOOSER (widget));
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.event_mask = gtk_widget_get_events (widget) |
+ GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.colormap = gtk_widget_get_colormap (widget);
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ widget->window = gdk_window_new (gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+ gdk_window_set_user_data (widget->window, widget);
+
+ gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
+}
+
+
+static void
+rstto_monitor_chooser_size_request(GtkWidget *widget, GtkRequisition *requisition)
+{
+ requisition->height = 200;
+ requisition->width = 400;
+}
+
+static void
+rstto_monitor_chooser_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
+{
+ widget->allocation = *allocation;
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ gdk_window_move_resize (widget->window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+ }
+}
+
+static gboolean
+rstto_monitor_chooser_expose(GtkWidget *widget, GdkEventExpose *event)
+{
+ rstto_monitor_chooser_paint (widget);
+ return FALSE;
+}
+
+static gboolean
+rstto_monitor_chooser_paint(GtkWidget *widget)
+{
+ RsttoMonitorChooser *chooser = RSTTO_MONITOR_CHOOSER (widget);
+ GSList *iter = chooser->priv->monitors;
+ cairo_t *ctx = gdk_cairo_create (widget->window);
+ Monitor *monitor;
+ gdouble width, height;
+ gchar *label = NULL;
+ gint row_width = 0;
+ gint id = 0;
+
+ GdkPixbuf *pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
+ "image-missing",
+ 128,
+ 0,
+ NULL);
+ gdk_window_clear (widget->window);
+
+ if (g_slist_length (chooser->priv->monitors) > 1)
+ {
+ while (NULL != iter)
+ {
+ monitor = iter->data;
+ /* Render the selected monitor a little bigger */
+ if (chooser->priv->selected == g_slist_index (chooser->priv->monitors, monitor))
+ {
+ if (monitor->width > monitor->height)
+ {
+ width = widget->allocation.width*0.4;
+ height = (gdouble)width / (gdouble)monitor->width * (gdouble)monitor->height;
+ }
+ else
+ {
+ height = widget->allocation.width*0.4;
+ width = (gdouble)height / (gdouble)monitor->height * (gdouble)monitor->width;
+ }
+ label = g_strdup_printf("%d", g_slist_index (chooser->priv->monitors, monitor)+1);
+ paint_monitor (ctx,
+ ((gdouble)widget->allocation.width/4) - (width/2.0),
+ ((gdouble)widget->allocation.height - height)/2.0,
+ width,
+ height,
+ label,
+ monitor,
+ TRUE);
+ g_free (label);
+ }
+ else
+ {
+ row_width = sqrt (g_slist_length(chooser->priv->monitors));
+
+ if (monitor->width > monitor->height)
+ {
+ width = widget->allocation.width*(0.4/((gdouble)row_width+1));
+ height = (gdouble)width / (gdouble)monitor->width * (gdouble)monitor->height;
+ }
+ else
+ {
+ height = widget->allocation.width*(0.4/g_slist_length(chooser->priv->monitors));
+ width = (gdouble)height / (gdouble)monitor->height * (gdouble)monitor->width;
+ }
+
+
+ label = g_strdup_printf("%d", g_slist_index (chooser->priv->monitors, monitor)+1);
+ paint_monitor (ctx,
+ ((gdouble)widget->allocation.width/2)+
+ (((gdouble)widget->allocation.width/2)/
+ (row_width+1))*(id%(row_width)+1)-
+ (width/2.0),
+ ((gdouble)widget->allocation.height/
+ (row_width+2)*(id/row_width+1))-
+ (height/2.0),
+ width,
+ height,
+ label,
+ monitor,
+ FALSE);
+ g_free (label);
+
+ id++;
+ }
+ iter = g_slist_next(iter);
+ }
+ }
+ else
+ {
+ if (iter)
+ {
+ monitor = iter->data;
+ if (monitor->width > monitor->height)
+ {
+ width = 200;
+ height = (gdouble)width / (gdouble)monitor->width * (gdouble)monitor->height;
+ }
+ else
+ {
+ height = 200;
+ width = (gdouble)height / (gdouble)monitor->height * (gdouble)monitor->width;
+ }
+ paint_monitor (ctx,
+ ((gdouble)widget->allocation.width - width)/2.0,
+ ((gdouble)widget->allocation.height - height)/2.0,
+ width,
+ height,
+ "1",
+ monitor,
+ TRUE);
+ }
+ }
+}
+
+static void
+paint_monitor ( cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ gchar *label,
+ Monitor *monitor,
+ gboolean active)
+{
+ gdouble line_width = 3.0;
+ double corner_radius = height / 10;
+ double radius = corner_radius / 1.0;
+ double degrees = M_PI / 180.0;
+ gint text_width = 0.0;
+ gint text_height = 0.0;
+ gdouble scale = 1.0;
+ PangoLayout *layout;
+ PangoFontDescription *font_description;
+ g_return_if_fail (NULL != monitor);
+
+ /*
+ * Set path for monitor outline and background-color.
+ */
+ cairo_new_sub_path (cr);
+ cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
+ cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
+ cairo_arc (cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
+ cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
+ cairo_close_path (cr);
+
+ /* Fill the background-color */
+ cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
+ cairo_fill_preserve (cr);
+
+ /* Paint the outside border */
+ cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 1.0);
+ cairo_set_line_width (cr, line_width);
+ cairo_stroke (cr);
+
+ cairo_new_sub_path (cr);
+ cairo_arc (cr, x + width - radius-line_width, y + radius+line_width, radius, -90 * degrees, 0 * degrees);
+ cairo_arc (cr, x + width - radius-line_width, y + height - radius-line_width, radius, 0 * degrees, 90 * degrees);
+ cairo_arc (cr, x + radius+line_width, y + height - radius-line_width, radius, 90 * degrees, 180 * degrees);
+ cairo_arc (cr, x + radius+line_width, y + radius+line_width, radius, 180 * degrees, 270 * degrees);
+ cairo_close_path (cr);
+
+ /* Paint the inside border */
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
+ cairo_set_line_width (cr, line_width);
+ cairo_stroke (cr);
+
+ /* Set the path that limits the image-size */
+ cairo_new_sub_path (cr);
+ cairo_move_to (cr, x + height / 10.0, y + height / 10.0);
+ cairo_line_to (cr, x + width - height / 10, y + height / 10.0);
+ cairo_line_to (cr, x + width - height / 10, y + height - height / 10.0);
+ cairo_line_to (cr, x + height / 10.0, y + height - height / 10.0);
+ cairo_close_path (cr);
+
+ /* Color the background black */
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_fill_preserve (cr);
+
+ cairo_clip_preserve (cr);
+ if (monitor->pixbuf)
+ {
+ scale = width / (gdk_pixbuf_get_width(monitor->pixbuf));
+ cairo_scale (cr, scale, scale);
+
+ gdk_cairo_set_source_pixbuf (cr,
+ monitor->pixbuf,
+ x/scale+((width/scale)-gdk_pixbuf_get_width(monitor->pixbuf))/2,
+ y/scale+((height/10)/scale));
+ }
+ cairo_paint(cr);
+ cairo_reset_clip(cr);
+ cairo_scale (cr, 1/scale, 1/scale);
+
+ if (FALSE == active)
+ {
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
+ cairo_fill_preserve (cr);
+ }
+
+ cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 1.0);
+ cairo_set_line_width (cr, 2.0);
+ cairo_stroke (cr);
+
+
+ font_description = pango_font_description_new ();
+ pango_font_description_set_family (font_description, "sans");
+ pango_font_description_set_weight (font_description, PANGO_WEIGHT_BOLD);
+ pango_font_description_set_absolute_size (font_description, height*0.4 * PANGO_SCALE);
+
+
+ layout = pango_cairo_create_layout (cr);
+ pango_layout_set_font_description (layout, font_description);
+ pango_layout_set_text (layout, label, -1);
+ pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+ pango_cairo_update_layout (cr, layout);
+ pango_layout_get_pixel_size (layout, &text_width, &text_height);
+
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.9);
+ cairo_move_to (cr, x+(width-(gdouble)text_width) / 2, y+(height/2 + ((gdouble)text_height / 3)));
+ pango_cairo_show_layout_line (cr, pango_layout_get_line (layout, 0));
+
+ g_object_unref (layout);
+ pango_font_description_free (font_description);
+}
+
+GtkWidget *
+rstto_monitor_chooser_new ()
+{
+ RsttoMonitorChooser *chooser;
+
+ chooser = g_object_new(RSTTO_TYPE_MONITOR_CHOOSER, NULL);
+
+ return GTK_WIDGET(chooser);
+}
+
+gint
+rstto_monitor_chooser_add (
+ RsttoMonitorChooser *chooser,
+ gint width,
+ gint height)
+{
+ Monitor *monitor = g_new0 (Monitor, 1);
+ monitor->width = width;
+ monitor->height = height;
+ if (NULL == chooser->priv->monitors)
+ {
+ chooser->priv->selected = 0;
+ }
+
+
+ chooser->priv->monitors = g_slist_append (chooser->priv->monitors, monitor);
+
+ return g_slist_index (chooser->priv->monitors, monitor);
+}
+
+gint
+rstto_monitor_chooser_set_pixbuf (
+ RsttoMonitorChooser *chooser,
+ gint monitor_id,
+ GdkPixbuf *pixbuf,
+ GError **error)
+{
+ Monitor *monitor = g_slist_nth_data (chooser->priv->monitors, monitor_id);
+ if (monitor)
+ {
+ if (monitor->pixbuf)
+ {
+ g_object_unref (monitor->pixbuf);
+ }
+ if (pixbuf)
+ {
+ g_object_ref (pixbuf);
+ }
+ monitor->pixbuf = pixbuf;
+ }
+}
+
+static void
+cb_rstto_button_press_event (GtkWidget *widget, GdkEventButton *event)
+{
+ RsttoMonitorChooser *chooser = RSTTO_MONITOR_CHOOSER(widget);
+ gint row_width = 0;
+ gint id = 0;
+ gint width, height;
+
+ if (g_slist_length (chooser->priv->monitors) > 1)
+ {
+ row_width = sqrt (g_slist_length(chooser->priv->monitors));
+
+ width = widget->allocation.width*(0.4/((gdouble)row_width+1));
+ height = width;
+
+ for (id = 0; id < g_slist_length(chooser->priv->monitors); ++id)
+ {
+ if ( (event->x > ((gdouble)widget->allocation.width/2)+
+ (((gdouble)widget->allocation.width/2)/
+ (row_width+1))*(id%(row_width)+1)-
+ (width/2.0)) &&
+ (event->x < ((gdouble)widget->allocation.width/2)+
+ (((gdouble)widget->allocation.width/2)/
+ (row_width+1))*(id%(row_width)+1)+
+ (width/2.0)) &&
+ (event->y > ((gdouble)widget->allocation.height/
+ (row_width+2)*(id/row_width+1)-
+ (height/2.0))) &&
+ (event->y < ((gdouble)widget->allocation.height/
+ (row_width+2)*(id/row_width+1)+
+ (height/2.0))))
+ {
+ if (id < chooser->priv->selected)
+ {
+ chooser->priv->selected = id;
+ }
+ else
+ {
+ chooser->priv->selected = id+1;
+ }
+
+ rstto_monitor_chooser_paint (widget);
+ }
+ }
+
+ }
+}
diff --git a/src/monitor_chooser.h b/src/monitor_chooser.h
new file mode 100644
index 0000000..385b7e2
--- /dev/null
+++ b/src/monitor_chooser.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) Stephan Arts 2006-2010 <stephan at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __RISTRETTO_MONITOR_CHOOSER_H__
+#define __RISTRETTO_MONITOR_CHOOSER_H__
+
+G_BEGIN_DECLS
+
+#define RSTTO_TYPE_MONITOR_CHOOSER rstto_monitor_chooser_get_type()
+
+#define RSTTO_MONITOR_CHOOSER(obj)( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ RSTTO_TYPE_MONITOR_CHOOSER, \
+ RsttoMonitorChooser))
+
+#define RSTTO_IS_MONITOR_CHOOSER(obj)( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ RSTTO_TYPE_MONITOR_CHOOSER))
+
+#define RSTTO_MONITOR_CHOOSER_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ RSTTO_TYPE_MONITOR_CHOOSER, \
+ RsttoMonitorChooserClass))
+
+#define RSTTO_IS_MONITOR_CHOOSER_CLASS(klass)( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ RSTTO_TYPE_MONITOR_CHOOSER()))
+
+typedef struct _RsttoMonitorChooserPriv RsttoMonitorChooserPriv;
+
+typedef struct _RsttoMonitorChooser RsttoMonitorChooser;
+
+struct _RsttoMonitorChooser
+{
+ GtkWidget parent;
+ RsttoMonitorChooserPriv *priv;
+};
+
+typedef struct _RsttoMonitorChooserClass RsttoMonitorChooserClass;
+
+struct _RsttoMonitorChooserClass
+{
+ GtkWidgetClass parent_class;
+};
+
+GType rstto_monitor_chooser_get_type();
+
+GtkWidget *rstto_monitor_chooser_new ();
+
+gint
+rstto_monitor_chooser_add (
+ RsttoMonitorChooser *,
+ gint width,
+ gint height);
+
+gint
+rstto_monitor_chooser_set_pixbuf (
+ RsttoMonitorChooser *,
+ gint monitor_id,
+ GdkPixbuf *pixbuf,
+ GError **);
+
+gint
+rstto_monitor_chooser_get_selected ( RsttoMonitorChooser * );
+
+G_END_DECLS
+
+#endif /* __RISTRETTO_MONITOR_CHOOSER_H__ */
diff --git a/src/xfce_wallpaper_manager.c b/src/xfce_wallpaper_manager.c
index 348f793..214b0ac 100644
--- a/src/xfce_wallpaper_manager.c
+++ b/src/xfce_wallpaper_manager.c
@@ -26,6 +26,7 @@
#include <libxfce4util/libxfce4util.h>
#include <gio/gio.h>
+#include "monitor_chooser.h"
#include "wallpaper_manager.h"
#include "xfce_wallpaper_manager.h"
@@ -80,6 +81,7 @@ rstto_xfce_wallpaper_manager_configure_dialog_run (RsttoWallpaperManager *self,
gchar *str = NULL;
GdkScreen *screen = gdk_screen_get_default ();
gint n_monitors = gdk_screen_get_n_monitors (screen);
+ GdkRectangle monitor_geometry;
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:"));
@@ -92,22 +94,32 @@ rstto_xfce_wallpaper_manager_configure_dialog_run (RsttoWallpaperManager *self,
GtkObject *saturation_adjustment = gtk_adjustment_new (1.0, 0.0, 10.0, 0.1, 0.5, 0);
GtkWidget *brightness_slider = gtk_hscale_new (GTK_ADJUSTMENT (brightness_adjustment));
GtkWidget *saturation_slider = gtk_hscale_new (GTK_ADJUSTMENT (saturation_adjustment));
- GtkWidget *image_hbox = gtk_hbox_new (FALSE, 4);
GdkPixbuf *image_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
"image-missing",
128,
0,
NULL);
- GtkWidget *image_box = gtk_image_new_from_pixbuf (image_pixbuf);
GtkWidget *prop_table = gtk_table_new (1, 2, FALSE);
GtkWidget *image_prop_table = gtk_table_new (2, 2, FALSE);
+ GtkWidget *monitor_chooser = rstto_monitor_chooser_new ();
+
+ for (i = 0; i < n_monitors; ++i)
+ {
+ gdk_screen_get_monitor_geometry (screen, i, &monitor_geometry);
+ rstto_monitor_chooser_add (RSTTO_MONITOR_CHOOSER(monitor_chooser), monitor_geometry.width, monitor_geometry.height);
+ rstto_monitor_chooser_set_pixbuf (
+ RSTTO_MONITOR_CHOOSER(monitor_chooser),
+ i,
+ gdk_pixbuf_new_from_file_at_size(
+ g_file_get_path(file),
+ 500,
+ 500,
+ NULL),
+ NULL);
+ }
- gtk_widget_set_size_request (image_box, 128, 128);
- gtk_misc_set_padding (GTK_MISC (image_box), 4, 4);
- 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_box_pack_start (GTK_BOX (vbox), monitor_chooser, 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);
@@ -131,37 +143,6 @@ rstto_xfce_wallpaper_manager_configure_dialog_run (RsttoWallpaperManager *self,
gtk_combo_box_append_text (GTK_COMBO_BOX (style_combo), _("Zoomed"));
gtk_combo_box_set_active (GTK_COMBO_BOX (style_combo), 4);
- if (n_monitors > 1)
- {
- gtk_table_attach (GTK_TABLE (prop_table), monitor_label, 0, 1, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (prop_table), monitor_combo, 1, 2, 1, 2, 0, 0, 0, 0);
- }
- for (i = 0; i < n_monitors; ++i)
- {
- switch ( i )
- {
- case 0:
- gtk_combo_box_append_text (GTK_COMBO_BOX (monitor_combo), _("One"));
- break;
- case 1:
- gtk_combo_box_append_text (GTK_COMBO_BOX (monitor_combo), _("Two"));
- break;
- case 2:
- gtk_combo_box_append_text (GTK_COMBO_BOX (monitor_combo), _("Three"));
- break;
- case 3:
- gtk_combo_box_append_text (GTK_COMBO_BOX (monitor_combo), _("Four"));
- break;
- default:
- str = g_strdup_printf("%d", i+1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (monitor_combo), str);
- g_free (str);
- break;
- }
- }
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (monitor_combo), 0);
-
manager->priv->screen = gdk_screen_get_number (screen);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
More information about the Xfce4-commits
mailing list