gnome-desktop r5184 - trunk/libgnome-desktop
- From: federico svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-desktop r5184 - trunk/libgnome-desktop
- Date: Sat, 16 Aug 2008 01:46:50 +0000 (UTC)
Author: federico
Date: Sat Aug 16 01:46:50 2008
New Revision: 5184
URL: http://svn.gnome.org/viewvc/gnome-desktop?rev=5184&view=rev
Log:
Implement creation of the label windows
Signed-off-by: Federico Mena Quintero <federico novell com>
Modified:
trunk/libgnome-desktop/gnome-rr-labeler.c
Modified: trunk/libgnome-desktop/gnome-rr-labeler.c
==============================================================================
--- trunk/libgnome-desktop/gnome-rr-labeler.c (original)
+++ trunk/libgnome-desktop/gnome-rr-labeler.c Sat Aug 16 01:46:50 2008
@@ -25,6 +25,7 @@
#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <config.h>
#include "libgnomeui/gnome-rr-labeler.h"
#include <gtk/gtk.h>
@@ -211,10 +212,75 @@
}
}
+#define LABEL_WINDOW_EDGE_THICKNESS 2
+#define LABEL_WINDOW_PADDING 12
+
+static gboolean
+label_window_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+{
+ cairo_t *cr;
+ GdkColor *color;
+
+ color = g_object_get_data (G_OBJECT (widget), "color");
+
+ cr = gdk_cairo_create (widget->window);
+
+ /* edge outline */
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr,
+ LABEL_WINDOW_EDGE_THICKNESS / 2.0,
+ LABEL_WINDOW_EDGE_THICKNESS / 2.0,
+ widget->allocation.width - LABEL_WINDOW_EDGE_THICKNESS,
+ widget->allocation.height - LABEL_WINDOW_EDGE_THICKNESS);
+ cairo_set_line_width (cr, LABEL_WINDOW_EDGE_THICKNESS);
+ cairo_stroke (cr);
+
+ /* fill */
+
+ gdk_cairo_set_source_color (cr, color);
+ cairo_rectangle (cr,
+ LABEL_WINDOW_EDGE_THICKNESS,
+ LABEL_WINDOW_EDGE_THICKNESS,
+ widget->allocation.width - LABEL_WINDOW_EDGE_THICKNESS * 2,
+ widget->allocation.height - LABEL_WINDOW_EDGE_THICKNESS * 2);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
+ return FALSE;
+}
+
static GtkWidget *
create_label_window (GnomeRRLabeler *labeler, GnomeOutputInfo *output, GdkColor *color)
{
- /* FIXME */
+ GtkWidget *window;
+ GtkWidget *widget;
+
+ window = gtk_window_new (GTK_WINDOW_POPUP);
+ GTK_WIDGET_SET_FLAGS (window, GTK_APP_PAINTABLE);
+
+ gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);
+
+ /* This is semi-dangerous. The color is part of the labeler->palette
+ * array. Note that in gnome_rr_labeler_finalize(), we are careful to
+ * free the palette only after we free the windows.
+ */
+ g_object_set_data (G_OBJECT (window), "color", color);
+
+ g_signal_connect (window, "expose-event",
+ G_CALLBACK (label_window_expose_event_cb), labeler);
+
+ widget = gtk_label_new (output->display_name);
+
+ gtk_container_add (GTK_CONTAINER (window), widget);
+
+ /* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
+ gtk_window_move (GTK_WINDOW (window), output->x, output->y);
+
+ gtk_widget_show_all (window);
+
+ return window;
}
static void
@@ -222,12 +288,14 @@
{
int i;
+ /* FIXME: this doesn't handle cloned outputs yet */
+
labeler->windows = g_new (GtkWidget *, labeler->num_outputs);
for (i = 0; i < labeler->num_outputs; i++) {
- if (labeler->config->outputs[i]->on)
+ if (labeler->config->outputs[i]->on) {
labeler->windows[i] = create_label_window (labeler, labeler->config->outputs[i], labeler->palette + i);
- else
+ } else
labeler->windows[i] = NULL;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]