[gnome-control-center] display: use consistent indentation and spacing
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] display: use consistent indentation and spacing
- Date: Sun, 21 Nov 2010 01:38:55 +0000 (UTC)
commit 88df7df3a93920e62b6a2441e92513f0bc9004b0
Author: William Jon McCann <jmccann redhat com>
Date: Sat Nov 20 18:30:40 2010 -0500
display: use consistent indentation and spacing
panels/display/scrollarea.c | 1420 +++++++++++-----------
panels/display/scrollarea.h | 42 +-
panels/display/xrandr-capplet.c | 2660 +++++++++++++++++++-------------------
3 files changed, 2061 insertions(+), 2061 deletions(-)
---
diff --git a/panels/display/scrollarea.c b/panels/display/scrollarea.c
index 4e785bb..3262e51 100644
--- a/panels/display/scrollarea.c
+++ b/panels/display/scrollarea.c
@@ -35,84 +35,84 @@ typedef struct AutoScrollInfo AutoScrollInfo;
struct InputPath
{
- gboolean is_stroke;
- cairo_fill_rule_t fill_rule;
- double line_width;
- cairo_path_t *path; /* In canvas coordinates */
+ gboolean is_stroke;
+ cairo_fill_rule_t fill_rule;
+ double line_width;
+ cairo_path_t *path; /* In canvas coordinates */
- FooScrollAreaEventFunc func;
- gpointer data;
+ FooScrollAreaEventFunc func;
+ gpointer data;
- InputPath *next;
+ InputPath *next;
};
/* InputRegions are mutually disjoint */
struct InputRegion
{
- /* the boundary of this area in canvas coordinates */
- cairo_region_t *region;
+ /* the boundary of this area in canvas coordinates */
+ cairo_region_t *region;
- InputPath *paths;
+ InputPath *paths;
};
struct AutoScrollInfo
{
- int dx;
- int dy;
- int timeout_id;
- int begin_x;
- int begin_y;
- double res_x;
- double res_y;
- GTimer *timer;
+ int dx;
+ int dy;
+ int timeout_id;
+ int begin_x;
+ int begin_y;
+ double res_x;
+ double res_y;
+ GTimer *timer;
};
struct FooScrollAreaPrivate
{
- GdkWindow *input_window;
+ GdkWindow *input_window;
- int width;
- int height;
+ int width;
+ int height;
- GtkAdjustment *hadj;
- GtkAdjustment *vadj;
- int x_offset;
- int y_offset;
+ GtkAdjustment *hadj;
+ GtkAdjustment *vadj;
+ int x_offset;
+ int y_offset;
- int min_width;
- int min_height;
+ int min_width;
+ int min_height;
- GPtrArray *input_regions;
+ GPtrArray *input_regions;
- AutoScrollInfo *auto_scroll_info;
+ AutoScrollInfo *auto_scroll_info;
- /* During expose, this region is set to the region
- * being exposed. At other times, it is NULL
- *
- * It is used for clipping of input areas
- */
- InputRegion *current_input;
+ /* During expose, this region is set to the region
+ * being exposed. At other times, it is NULL
+ *
+ * It is used for clipping of input areas
+ */
+ InputRegion *current_input;
- gboolean grabbed;
- FooScrollAreaEventFunc grab_func;
- gpointer grab_data;
+ gboolean grabbed;
+ FooScrollAreaEventFunc grab_func;
+ gpointer grab_data;
- cairo_surface_t *surface;
- cairo_region_t *update_region; /* In canvas coordinates */
+ cairo_surface_t *surface;
+ cairo_region_t *update_region; /* In canvas coordinates */
};
enum
-{
+ {
VIEWPORT_CHANGED,
PAINT,
INPUT,
LAST_SIGNAL,
-};
+ };
enum {
- PROP_0,
- PROP_VADJUSTMENT,
- PROP_HADJUSTMENT
+ PROP_0,
+ PROP_VADJUSTMENT,
+ PROP_HADJUSTMENT
};
static guint signals [LAST_SIGNAL] = { 0 };
@@ -145,38 +145,38 @@ static gboolean foo_scroll_area_motion (GtkWidget *widget,
static void
foo_scroll_area_map (GtkWidget *widget)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
- GTK_WIDGET_CLASS (parent_class)->map (widget);
+ GTK_WIDGET_CLASS (parent_class)->map (widget);
- if (area->priv->input_window)
- gdk_window_show (area->priv->input_window);
+ if (area->priv->input_window)
+ gdk_window_show (area->priv->input_window);
}
static void
foo_scroll_area_unmap (GtkWidget *widget)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
- if (area->priv->input_window)
- gdk_window_hide (area->priv->input_window);
+ if (area->priv->input_window)
+ gdk_window_hide (area->priv->input_window);
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
+ GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
foo_scroll_area_finalize (GObject *object)
{
- FooScrollArea *scroll_area = FOO_SCROLL_AREA (object);
+ FooScrollArea *scroll_area = FOO_SCROLL_AREA (object);
- g_object_unref (scroll_area->priv->hadj);
- g_object_unref (scroll_area->priv->vadj);
+ g_object_unref (scroll_area->priv->hadj);
+ g_object_unref (scroll_area->priv->vadj);
- g_ptr_array_free (scroll_area->priv->input_regions, TRUE);
+ g_ptr_array_free (scroll_area->priv->input_regions, TRUE);
- g_free (scroll_area->priv);
+ g_free (scroll_area->priv);
- G_OBJECT_CLASS (foo_scroll_area_parent_class)->finalize (object);
+ G_OBJECT_CLASS (foo_scroll_area_parent_class)->finalize (object);
}
static void
@@ -206,99 +206,99 @@ foo_scroll_area_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- switch (property_id) {
- case PROP_VADJUSTMENT:
- foo_scroll_area_set_vadjustment (FOO_SCROLL_AREA (object), g_value_get_object (value));
- break;
- case PROP_HADJUSTMENT:
- foo_scroll_area_set_hadjustment (FOO_SCROLL_AREA (object), g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ switch (property_id) {
+ case PROP_VADJUSTMENT:
+ foo_scroll_area_set_vadjustment (FOO_SCROLL_AREA (object), g_value_get_object (value));
+ break;
+ case PROP_HADJUSTMENT:
+ foo_scroll_area_set_hadjustment (FOO_SCROLL_AREA (object), g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
}
static void
foo_scroll_area_class_init (FooScrollAreaClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-
- object_class->finalize = foo_scroll_area_finalize;
- object_class->set_property = foo_scroll_area_set_property;
- object_class->get_property = foo_scroll_area_get_property;
-
- widget_class->get_preferred_width = foo_scroll_area_get_preferred_width;
- widget_class->get_preferred_height = foo_scroll_area_get_preferred_height;
- widget_class->draw = foo_scroll_area_draw;
- widget_class->size_allocate = foo_scroll_area_size_allocate;
- widget_class->realize = foo_scroll_area_realize;
- widget_class->unrealize = foo_scroll_area_unrealize;
- widget_class->button_press_event = foo_scroll_area_button_press;
- widget_class->button_release_event = foo_scroll_area_button_release;
- widget_class->motion_notify_event = foo_scroll_area_motion;
- widget_class->map = foo_scroll_area_map;
- widget_class->unmap = foo_scroll_area_unmap;
-
- parent_class = g_type_class_peek_parent (class);
-
- /* Scrollable interface properties */
- g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
- g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
-
- signals[VIEWPORT_CHANGED] =
- g_signal_new ("viewport_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (FooScrollAreaClass,
- viewport_changed),
- NULL, NULL,
- foo_marshal_VOID__BOXED_BOXED,
- G_TYPE_NONE, 2,
- GDK_TYPE_RECTANGLE,
- GDK_TYPE_RECTANGLE);
-
- signals[PAINT] =
- g_signal_new ("paint",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (FooScrollAreaClass,
- paint),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ object_class->finalize = foo_scroll_area_finalize;
+ object_class->set_property = foo_scroll_area_set_property;
+ object_class->get_property = foo_scroll_area_get_property;
+
+ widget_class->get_preferred_width = foo_scroll_area_get_preferred_width;
+ widget_class->get_preferred_height = foo_scroll_area_get_preferred_height;
+ widget_class->draw = foo_scroll_area_draw;
+ widget_class->size_allocate = foo_scroll_area_size_allocate;
+ widget_class->realize = foo_scroll_area_realize;
+ widget_class->unrealize = foo_scroll_area_unrealize;
+ widget_class->button_press_event = foo_scroll_area_button_press;
+ widget_class->button_release_event = foo_scroll_area_button_release;
+ widget_class->motion_notify_event = foo_scroll_area_motion;
+ widget_class->map = foo_scroll_area_map;
+ widget_class->unmap = foo_scroll_area_unmap;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ /* Scrollable interface properties */
+ g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
+ g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
+
+ signals[VIEWPORT_CHANGED] =
+ g_signal_new ("viewport_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (FooScrollAreaClass,
+ viewport_changed),
+ NULL, NULL,
+ foo_marshal_VOID__BOXED_BOXED,
+ G_TYPE_NONE, 2,
+ GDK_TYPE_RECTANGLE,
+ GDK_TYPE_RECTANGLE);
+
+ signals[PAINT] =
+ g_signal_new ("paint",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (FooScrollAreaClass,
+ paint),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
}
static GtkAdjustment *
new_adjustment (void)
{
- return GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ return GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
}
static void
foo_scroll_area_init (FooScrollArea *scroll_area)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- widget = GTK_WIDGET (scroll_area);
+ widget = GTK_WIDGET (scroll_area);
- gtk_widget_set_has_window (widget, FALSE);
- gtk_widget_set_redraw_on_allocate (widget, FALSE);
+ gtk_widget_set_has_window (widget, FALSE);
+ gtk_widget_set_redraw_on_allocate (widget, FALSE);
- scroll_area->priv = g_new0 (FooScrollAreaPrivate, 1);
- scroll_area->priv->width = 0;
- scroll_area->priv->height = 0;
- scroll_area->priv->hadj = g_object_ref_sink (new_adjustment());
- scroll_area->priv->vadj = g_object_ref_sink (new_adjustment());
- scroll_area->priv->x_offset = 0.0;
- scroll_area->priv->y_offset = 0.0;
- scroll_area->priv->min_width = -1;
- scroll_area->priv->min_height = -1;
- scroll_area->priv->auto_scroll_info = NULL;
- scroll_area->priv->input_regions = g_ptr_array_new ();
- scroll_area->priv->surface = NULL;
- scroll_area->priv->update_region = cairo_region_create ();
+ scroll_area->priv = g_new0 (FooScrollAreaPrivate, 1);
+ scroll_area->priv->width = 0;
+ scroll_area->priv->height = 0;
+ scroll_area->priv->hadj = g_object_ref_sink (new_adjustment());
+ scroll_area->priv->vadj = g_object_ref_sink (new_adjustment());
+ scroll_area->priv->x_offset = 0.0;
+ scroll_area->priv->y_offset = 0.0;
+ scroll_area->priv->min_width = -1;
+ scroll_area->priv->min_height = -1;
+ scroll_area->priv->auto_scroll_info = NULL;
+ scroll_area->priv->input_regions = g_ptr_array_new ();
+ scroll_area->priv->surface = NULL;
+ scroll_area->priv->update_region = cairo_region_create ();
}
typedef void (* PathForeachFunc) (double *x,
@@ -310,69 +310,69 @@ path_foreach_point (cairo_path_t *path,
PathForeachFunc func,
gpointer user_data)
{
- int i;
+ int i;
- for (i = 0; i < path->num_data; i += path->data[i].header.length)
+ for (i = 0; i < path->num_data; i += path->data[i].header.length)
{
- cairo_path_data_t *data = &(path->data[i]);
+ cairo_path_data_t *data = &(path->data[i]);
- switch (data->header.type)
+ switch (data->header.type)
{
case CAIRO_PATH_MOVE_TO:
case CAIRO_PATH_LINE_TO:
- func (&(data[1].point.x), &(data[1].point.y), user_data);
- break;
+ func (&(data[1].point.x), &(data[1].point.y), user_data);
+ break;
case CAIRO_PATH_CURVE_TO:
- func (&(data[1].point.x), &(data[1].point.y), user_data);
- func (&(data[2].point.x), &(data[2].point.y), user_data);
- func (&(data[3].point.x), &(data[3].point.y), user_data);
- break;
+ func (&(data[1].point.x), &(data[1].point.y), user_data);
+ func (&(data[2].point.x), &(data[2].point.y), user_data);
+ func (&(data[3].point.x), &(data[3].point.y), user_data);
+ break;
case CAIRO_PATH_CLOSE_PATH:
- break;
+ break;
}
}
}
typedef struct
{
- double x1, y1, x2, y2;
+ double x1, y1, x2, y2;
} Box;
static void
input_path_free_list (InputPath *paths)
{
- if (!paths)
- return;
+ if (!paths)
+ return;
- input_path_free_list (paths->next);
- cairo_path_destroy (paths->path);
- g_free (paths);
+ input_path_free_list (paths->next);
+ cairo_path_destroy (paths->path);
+ g_free (paths);
}
static void
input_region_free (InputRegion *region)
{
- input_path_free_list (region->paths);
- cairo_region_destroy (region->region);
+ input_path_free_list (region->paths);
+ cairo_region_destroy (region->region);
- g_free (region);
+ g_free (region);
}
static void
get_viewport (FooScrollArea *scroll_area,
GdkRectangle *viewport)
{
- GtkAllocation allocation;
- GtkWidget *widget = GTK_WIDGET (scroll_area);
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (scroll_area);
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (widget, &allocation);
- viewport->x = scroll_area->priv->x_offset;
- viewport->y = scroll_area->priv->y_offset;
- viewport->width = allocation.width;
- viewport->height = allocation.height;
+ viewport->x = scroll_area->priv->x_offset;
+ viewport->y = scroll_area->priv->y_offset;
+ viewport->width = allocation.width;
+ viewport->height = allocation.height;
}
static void
@@ -380,40 +380,40 @@ allocation_to_canvas (FooScrollArea *area,
int *x,
int *y)
{
- *x += area->priv->x_offset;
- *y += area->priv->y_offset;
+ *x += area->priv->x_offset;
+ *y += area->priv->y_offset;
}
static void
clear_exposed_input_region (FooScrollArea *area,
cairo_region_t *exposed) /* in canvas coordinates */
{
- int i;
- cairo_region_t *viewport;
- GdkRectangle allocation;
+ int i;
+ cairo_region_t *viewport;
+ GdkRectangle allocation;
- gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
- allocation.x = 0;
- allocation.y = 0;
- allocation_to_canvas (area, &allocation.x, &allocation.y);
+ gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
+ allocation.x = 0;
+ allocation.y = 0;
+ allocation_to_canvas (area, &allocation.x, &allocation.y);
- viewport = cairo_region_create_rectangle (&allocation);
- cairo_region_subtract (viewport, exposed);
+ viewport = cairo_region_create_rectangle (&allocation);
+ cairo_region_subtract (viewport, exposed);
- for (i = 0; i < area->priv->input_regions->len; ++i)
+ for (i = 0; i < area->priv->input_regions->len; ++i)
{
- InputRegion *region = area->priv->input_regions->pdata[i];
+ InputRegion *region = area->priv->input_regions->pdata[i];
- cairo_region_intersect (region->region, viewport);
+ cairo_region_intersect (region->region, viewport);
- if (cairo_region_is_empty (region->region))
+ if (cairo_region_is_empty (region->region))
{
- input_region_free (region);
- g_ptr_array_remove_index_fast (area->priv->input_regions, i--);
+ input_region_free (region);
+ g_ptr_array_remove_index_fast (area->priv->input_regions, i--);
}
}
- cairo_region_destroy (viewport);
+ cairo_region_destroy (viewport);
}
/* taken from mutter */
@@ -443,72 +443,72 @@ static void
initialize_background (GtkWidget *widget,
cairo_t *cr)
{
- setup_background_cr (gtk_widget_get_window (widget), cr, 0, 0);
+ setup_background_cr (gtk_widget_get_window (widget), cr, 0, 0);
- cairo_paint (cr);
+ cairo_paint (cr);
}
static gboolean
foo_scroll_area_draw (GtkWidget *widget,
cairo_t *cr)
{
- FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
- cairo_region_t *region;
- int x_offset, y_offset;
- GtkAllocation widget_allocation;
+ FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
+ cairo_region_t *region;
+ int x_offset, y_offset;
+ GtkAllocation widget_allocation;
- /* Note that this function can be called at a time
- * where the adj->value is different from x_offset.
- * Ie., the GtkScrolledWindow changed the adj->value
- * without emitting the value_changed signal.
- *
- * Hence we must always use the value we got
- * the last time the signal was emitted, ie.,
- * priv->{x,y}_offset.
- */
- x_offset = scroll_area->priv->x_offset;
- y_offset = scroll_area->priv->y_offset;
+ /* Note that this function can be called at a time
+ * where the adj->value is different from x_offset.
+ * Ie., the GtkScrolledWindow changed the adj->value
+ * without emitting the value_changed signal.
+ *
+ * Hence we must always use the value we got
+ * the last time the signal was emitted, ie.,
+ * priv->{x,y}_offset.
+ */
+ x_offset = scroll_area->priv->x_offset;
+ y_offset = scroll_area->priv->y_offset;
- /* Setup input areas */
- clear_exposed_input_region (scroll_area, scroll_area->priv->update_region);
+ /* Setup input areas */
+ clear_exposed_input_region (scroll_area, scroll_area->priv->update_region);
- scroll_area->priv->current_input = g_new0 (InputRegion, 1);
- scroll_area->priv->current_input->region = cairo_region_copy (scroll_area->priv->update_region);
- scroll_area->priv->current_input->paths = NULL;
- g_ptr_array_add (scroll_area->priv->input_regions,
- scroll_area->priv->current_input);
+ scroll_area->priv->current_input = g_new0 (InputRegion, 1);
+ scroll_area->priv->current_input->region = cairo_region_copy (scroll_area->priv->update_region);
+ scroll_area->priv->current_input->paths = NULL;
+ g_ptr_array_add (scroll_area->priv->input_regions,
+ scroll_area->priv->current_input);
- region = scroll_area->priv->update_region;
- scroll_area->priv->update_region = cairo_region_create ();
+ region = scroll_area->priv->update_region;
+ scroll_area->priv->update_region = cairo_region_create ();
- initialize_background (widget, cr);
+ initialize_background (widget, cr);
- g_signal_emit (widget, signals[PAINT], 0, cr);
+ g_signal_emit (widget, signals[PAINT], 0, cr);
- scroll_area->priv->current_input = NULL;
+ scroll_area->priv->current_input = NULL;
- gtk_widget_get_allocation (widget, &widget_allocation);
+ gtk_widget_get_allocation (widget, &widget_allocation);
- /* Finally draw the backing surface */
- cairo_set_source_surface (cr, scroll_area->priv->surface,
- widget_allocation.x, widget_allocation.y);
- cairo_fill (cr);
+ /* Finally draw the backing surface */
+ cairo_set_source_surface (cr, scroll_area->priv->surface,
+ widget_allocation.x, widget_allocation.y);
+ cairo_fill (cr);
- cairo_region_destroy (region);
+ cairo_region_destroy (region);
- return TRUE;
+ return TRUE;
}
void
foo_scroll_area_get_viewport (FooScrollArea *scroll_area,
GdkRectangle *viewport)
{
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- if (!viewport)
- return;
+ if (!viewport)
+ return;
- get_viewport (scroll_area, viewport);
+ get_viewport (scroll_area, viewport);
}
static void
@@ -522,167 +522,167 @@ emit_viewport_changed (FooScrollArea *scroll_area,
GdkRectangle *new_viewport,
GdkRectangle *old_viewport)
{
- int px, py;
- g_signal_emit (scroll_area, signals[VIEWPORT_CHANGED], 0,
- new_viewport, old_viewport);
+ int px, py;
+ g_signal_emit (scroll_area, signals[VIEWPORT_CHANGED], 0,
+ new_viewport, old_viewport);
- gdk_window_get_pointer (scroll_area->priv->input_window, &px, &py, NULL);
+ gdk_window_get_pointer (scroll_area->priv->input_window, &px, &py, NULL);
#if 0
- g_print ("procc\n");
+ g_print ("procc\n");
#endif
- process_event (scroll_area, FOO_MOTION, px, py);
+ process_event (scroll_area, FOO_MOTION, px, py);
}
static void
clamp_adjustment (GtkAdjustment *adj)
{
- if (gtk_adjustment_get_upper (adj) >= gtk_adjustment_get_page_size (adj))
- gtk_adjustment_set_value (adj, CLAMP (gtk_adjustment_get_value (adj), 0.0,
- gtk_adjustment_get_upper (adj)
- - gtk_adjustment_get_page_size (adj)));
- else
- gtk_adjustment_set_value (adj, 0.0);
+ if (gtk_adjustment_get_upper (adj) >= gtk_adjustment_get_page_size (adj))
+ gtk_adjustment_set_value (adj, CLAMP (gtk_adjustment_get_value (adj), 0.0,
+ gtk_adjustment_get_upper (adj)
+ - gtk_adjustment_get_page_size (adj)));
+ else
+ gtk_adjustment_set_value (adj, 0.0);
- gtk_adjustment_changed (adj);
+ gtk_adjustment_changed (adj);
}
static gboolean
set_adjustment_values (FooScrollArea *scroll_area)
{
- GtkAllocation allocation;
+ GtkAllocation allocation;
- GtkAdjustment *hadj = scroll_area->priv->hadj;
- GtkAdjustment *vadj = scroll_area->priv->vadj;
+ GtkAdjustment *hadj = scroll_area->priv->hadj;
+ GtkAdjustment *vadj = scroll_area->priv->vadj;
- /* Horizontal */
- gtk_widget_get_allocation (GTK_WIDGET (scroll_area), &allocation);
- g_object_freeze_notify (G_OBJECT (hadj));
- gtk_adjustment_set_page_size (hadj, allocation.width);
- gtk_adjustment_set_step_increment (hadj, 0.1 * allocation.width);
- gtk_adjustment_set_page_increment (hadj, 0.9 * allocation.width);
- gtk_adjustment_set_lower (hadj, 0.0);
- gtk_adjustment_set_upper (hadj, scroll_area->priv->width);
- g_object_thaw_notify (G_OBJECT (hadj));
+ /* Horizontal */
+ gtk_widget_get_allocation (GTK_WIDGET (scroll_area), &allocation);
+ g_object_freeze_notify (G_OBJECT (hadj));
+ gtk_adjustment_set_page_size (hadj, allocation.width);
+ gtk_adjustment_set_step_increment (hadj, 0.1 * allocation.width);
+ gtk_adjustment_set_page_increment (hadj, 0.9 * allocation.width);
+ gtk_adjustment_set_lower (hadj, 0.0);
+ gtk_adjustment_set_upper (hadj, scroll_area->priv->width);
+ g_object_thaw_notify (G_OBJECT (hadj));
- /* Vertical */
- g_object_freeze_notify (G_OBJECT (vadj));
- gtk_adjustment_set_page_size (vadj, allocation.height);
- gtk_adjustment_set_step_increment (vadj, 0.1 * allocation.height);
- gtk_adjustment_set_page_increment (vadj, 0.9 * allocation.height);
- gtk_adjustment_set_lower (vadj, 0.0);
- gtk_adjustment_set_upper (vadj, scroll_area->priv->height);
- g_object_thaw_notify (G_OBJECT (vadj));
+ /* Vertical */
+ g_object_freeze_notify (G_OBJECT (vadj));
+ gtk_adjustment_set_page_size (vadj, allocation.height);
+ gtk_adjustment_set_step_increment (vadj, 0.1 * allocation.height);
+ gtk_adjustment_set_page_increment (vadj, 0.9 * allocation.height);
+ gtk_adjustment_set_lower (vadj, 0.0);
+ gtk_adjustment_set_upper (vadj, scroll_area->priv->height);
+ g_object_thaw_notify (G_OBJECT (vadj));
- clamp_adjustment (hadj);
- clamp_adjustment (vadj);
+ clamp_adjustment (hadj);
+ clamp_adjustment (vadj);
- return TRUE;
+ return TRUE;
}
static void
foo_scroll_area_realize (GtkWidget *widget)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
- GdkWindowAttr attributes;
- GtkAllocation widget_allocation;
- GdkWindow *window;
- gint attributes_mask;
- cairo_t *cr;
-
- gtk_widget_get_allocation (widget, &widget_allocation);
- gtk_widget_set_realized (widget, TRUE);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget_allocation.x;
- attributes.y = widget_allocation.y;
- attributes.width = widget_allocation.width;
- attributes.height = widget_allocation.height;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_BUTTON2_MOTION_MASK |
- GDK_BUTTON3_MOTION_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gtk_widget_get_parent_window (widget);
- gtk_widget_set_window (widget, window);
- g_object_ref (window);
-
- area->priv->input_window = gdk_window_new (window,
- &attributes, attributes_mask);
-
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- area->priv->surface = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR,
- widget_allocation.width,
- widget_allocation.height);
- cairo_destroy (cr);
-
- gdk_window_set_user_data (area->priv->input_window, area);
-
- gtk_widget_style_attach (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ GdkWindowAttr attributes;
+ GtkAllocation widget_allocation;
+ GdkWindow *window;
+ gint attributes_mask;
+ cairo_t *cr;
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ gtk_widget_set_realized (widget, TRUE);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = widget_allocation.x;
+ attributes.y = widget_allocation.y;
+ attributes.width = widget_allocation.width;
+ attributes.height = widget_allocation.height;
+ attributes.wclass = GDK_INPUT_ONLY;
+ attributes.event_mask = gtk_widget_get_events (widget);
+ attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_BUTTON1_MOTION_MASK |
+ GDK_BUTTON2_MOTION_MASK |
+ GDK_BUTTON3_MOTION_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK);
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
+
+ area->priv->input_window = gdk_window_new (window,
+ &attributes, attributes_mask);
+
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+ area->priv->surface = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR,
+ widget_allocation.width,
+ widget_allocation.height);
+ cairo_destroy (cr);
+
+ gdk_window_set_user_data (area->priv->input_window, area);
+
+ gtk_widget_style_attach (widget);
}
static void
foo_scroll_area_unrealize (GtkWidget *widget)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
- if (area->priv->input_window)
+ if (area->priv->input_window)
{
- gdk_window_set_user_data (area->priv->input_window, NULL);
- gdk_window_destroy (area->priv->input_window);
- area->priv->input_window = NULL;
+ gdk_window_set_user_data (area->priv->input_window, NULL);
+ gdk_window_destroy (area->priv->input_window);
+ area->priv->input_window = NULL;
}
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static cairo_surface_t *
create_new_surface (GtkWidget *widget,
cairo_surface_t *old)
{
- GtkAllocation widget_allocation;
- cairo_surface_t *new;
- cairo_t *cr;
-
- gtk_widget_get_allocation (widget, &widget_allocation);
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- new = cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR,
- widget_allocation.width,
- widget_allocation.height);
- cairo_destroy (cr);
-
- /* Unfortunately we don't know in which direction we were resized,
- * so we just assume we were dragged from the south-east corner.
- *
- * Although, maybe we could get the root coordinates of the input-window?
- * That might just work, actually. We need to make sure metacity uses
- * static gravity for the window before this will be useful.
- */
- cr = cairo_create (new);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_surface (cr, old, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- return new;
+ GtkAllocation widget_allocation;
+ cairo_surface_t *new;
+ cairo_t *cr;
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+ new = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR,
+ widget_allocation.width,
+ widget_allocation.height);
+ cairo_destroy (cr);
+
+ /* Unfortunately we don't know in which direction we were resized,
+ * so we just assume we were dragged from the south-east corner.
+ *
+ * Although, maybe we could get the root coordinates of the input-window?
+ * That might just work, actually. We need to make sure metacity uses
+ * static gravity for the window before this will be useful.
+ */
+ cr = cairo_create (new);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface (cr, old, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ return new;
}
static void
allocation_to_canvas_region (FooScrollArea *area,
cairo_region_t *region)
{
- cairo_region_translate (region, area->priv->x_offset, area->priv->y_offset);
+ cairo_region_translate (region, area->priv->x_offset, area->priv->y_offset);
}
static void
@@ -705,49 +705,49 @@ static void
foo_scroll_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
- GdkRectangle new_viewport;
- GdkRectangle old_viewport;
- cairo_region_t *old_allocation;
- cairo_region_t *invalid;
- GtkAllocation widget_allocation;
+ FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
+ GdkRectangle new_viewport;
+ GdkRectangle old_viewport;
+ cairo_region_t *old_allocation;
+ cairo_region_t *invalid;
+ GtkAllocation widget_allocation;
- get_viewport (scroll_area, &old_viewport);
+ get_viewport (scroll_area, &old_viewport);
- gtk_widget_get_allocation (widget, &widget_allocation);
+ gtk_widget_get_allocation (widget, &widget_allocation);
- old_allocation = cairo_region_create_rectangle (&widget_allocation);
- cairo_region_translate (old_allocation,
- -widget_allocation.x, -widget_allocation.y);
+ old_allocation = cairo_region_create_rectangle (&widget_allocation);
+ cairo_region_translate (old_allocation,
+ -widget_allocation.x, -widget_allocation.y);
- invalid = cairo_region_create_rectangle (allocation);
- cairo_region_translate (invalid, -allocation->x, -allocation->y);
- _cairo_region_xor (invalid, old_allocation);
- allocation_to_canvas_region (scroll_area, invalid);
- foo_scroll_area_invalidate_region (scroll_area, invalid);
+ invalid = cairo_region_create_rectangle (allocation);
+ cairo_region_translate (invalid, -allocation->x, -allocation->y);
+ _cairo_region_xor (invalid, old_allocation);
+ allocation_to_canvas_region (scroll_area, invalid);
+ foo_scroll_area_invalidate_region (scroll_area, invalid);
- cairo_region_destroy (old_allocation);
- cairo_region_destroy (invalid);
+ cairo_region_destroy (old_allocation);
+ cairo_region_destroy (invalid);
- gtk_widget_set_allocation (widget, allocation);
+ gtk_widget_set_allocation (widget, allocation);
- if (scroll_area->priv->input_window)
+ if (scroll_area->priv->input_window)
{
- cairo_surface_t *new_surface;
+ cairo_surface_t *new_surface;
- gdk_window_move_resize (scroll_area->priv->input_window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
+ gdk_window_move_resize (scroll_area->priv->input_window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
- new_surface = create_new_surface (widget, scroll_area->priv->surface);
- cairo_surface_destroy (scroll_area->priv->surface);
+ new_surface = create_new_surface (widget, scroll_area->priv->surface);
+ cairo_surface_destroy (scroll_area->priv->surface);
- scroll_area->priv->surface = new_surface;
+ scroll_area->priv->surface = new_surface;
}
- get_viewport (scroll_area, &new_viewport);
+ get_viewport (scroll_area, &new_viewport);
- emit_viewport_changed (scroll_area, &new_viewport, &old_viewport);
+ emit_viewport_changed (scroll_area, &new_viewport, &old_viewport);
}
static void
@@ -758,19 +758,19 @@ emit_input (FooScrollArea *scroll_area,
FooScrollAreaEventFunc func,
gpointer data)
{
- FooScrollAreaEvent event;
+ FooScrollAreaEvent event;
- if (!func)
- return;
+ if (!func)
+ return;
- if (type != FOO_MOTION)
- emit_input (scroll_area, FOO_MOTION, x, y, func, data);
+ if (type != FOO_MOTION)
+ emit_input (scroll_area, FOO_MOTION, x, y, func, data);
- event.type = type;
- event.x = x;
- event.y = y;
+ event.type = type;
+ event.x = x;
+ event.y = y;
- func (scroll_area, &event, data);
+ func (scroll_area, &event, data);
}
static void
@@ -779,71 +779,71 @@ process_event (FooScrollArea *scroll_area,
int x,
int y)
{
- GtkWidget *widget = GTK_WIDGET (scroll_area);
- int i;
+ GtkWidget *widget = GTK_WIDGET (scroll_area);
+ int i;
- allocation_to_canvas (scroll_area, &x, &y);
+ allocation_to_canvas (scroll_area, &x, &y);
- if (scroll_area->priv->grabbed)
+ if (scroll_area->priv->grabbed)
{
- emit_input (scroll_area, input_type, x, y,
- scroll_area->priv->grab_func,
- scroll_area->priv->grab_data);
- return;
+ emit_input (scroll_area, input_type, x, y,
+ scroll_area->priv->grab_func,
+ scroll_area->priv->grab_data);
+ return;
}
#if 0
- g_print ("number of input regions: %d\n", scroll_area->priv->input_regions->len);
+ g_print ("number of input regions: %d\n", scroll_area->priv->input_regions->len);
#endif
- for (i = 0; i < scroll_area->priv->input_regions->len; ++i)
+ for (i = 0; i < scroll_area->priv->input_regions->len; ++i)
{
- InputRegion *region = scroll_area->priv->input_regions->pdata[i];
+ InputRegion *region = scroll_area->priv->input_regions->pdata[i];
#if 0
- g_print ("region %d (looking for %d,%d) ", i, x, y);
+ g_print ("region %d (looking for %d,%d) ", i, x, y);
#endif
- if (cairo_region_contains_point (region->region, x, y))
+ if (cairo_region_contains_point (region->region, x, y))
{
- InputPath *path;
+ InputPath *path;
- path = region->paths;
- while (path)
+ path = region->paths;
+ while (path)
{
- cairo_t *cr;
- gboolean inside;
+ cairo_t *cr;
+ gboolean inside;
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- cairo_set_fill_rule (cr, path->fill_rule);
- cairo_set_line_width (cr, path->line_width);
- cairo_append_path (cr, path->path);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+ cairo_set_fill_rule (cr, path->fill_rule);
+ cairo_set_line_width (cr, path->line_width);
+ cairo_append_path (cr, path->path);
- if (path->is_stroke)
- inside = cairo_in_stroke (cr, x, y);
- else
- inside = cairo_in_fill (cr, x, y);
+ if (path->is_stroke)
+ inside = cairo_in_stroke (cr, x, y);
+ else
+ inside = cairo_in_fill (cr, x, y);
- cairo_destroy (cr);
+ cairo_destroy (cr);
- if (inside)
+ if (inside)
{
- emit_input (scroll_area, input_type,
- x, y,
- path->func,
- path->data);
- return;
+ emit_input (scroll_area, input_type,
+ x, y,
+ path->func,
+ path->data);
+ return;
}
- path = path->next;
+ path = path->next;
}
- /* Since the regions are all disjoint, no other region
- * can match. Of course we could be clever and try and
- * sort the regions, but so far I have been unable to
- * make this loop show up on a profile.
- */
- return;
+ /* Since the regions are all disjoint, no other region
+ * can match. Of course we could be clever and try and
+ * sort the regions, but so far I have been unable to
+ * make this loop show up on a profile.
+ */
+ return;
}
}
}
@@ -854,50 +854,50 @@ process_gdk_event (FooScrollArea *scroll_area,
int y,
GdkEvent *event)
{
- FooScrollAreaEventType input_type;
+ FooScrollAreaEventType input_type;
- if (event->type == GDK_BUTTON_PRESS)
- input_type = FOO_BUTTON_PRESS;
- else if (event->type == GDK_BUTTON_RELEASE)
- input_type = FOO_BUTTON_RELEASE;
- else if (event->type == GDK_MOTION_NOTIFY)
- input_type = FOO_MOTION;
- else
- return;
+ if (event->type == GDK_BUTTON_PRESS)
+ input_type = FOO_BUTTON_PRESS;
+ else if (event->type == GDK_BUTTON_RELEASE)
+ input_type = FOO_BUTTON_RELEASE;
+ else if (event->type == GDK_MOTION_NOTIFY)
+ input_type = FOO_MOTION;
+ else
+ return;
- process_event (scroll_area, input_type, x, y);
+ process_event (scroll_area, input_type, x, y);
}
static gboolean
foo_scroll_area_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
- process_gdk_event (area, event->x, event->y, (GdkEvent *)event);
+ process_gdk_event (area, event->x, event->y, (GdkEvent *)event);
- return TRUE;
+ return TRUE;
}
static gboolean
foo_scroll_area_button_release (GtkWidget *widget,
GdkEventButton *event)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
- process_gdk_event (area, event->x, event->y, (GdkEvent *)event);
+ process_gdk_event (area, event->x, event->y, (GdkEvent *)event);
- return FALSE;
+ return FALSE;
}
static gboolean
foo_scroll_area_motion (GtkWidget *widget,
GdkEventMotion *event)
{
- FooScrollArea *area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *area = FOO_SCROLL_AREA (widget);
- process_gdk_event (area, event->x, event->y, (GdkEvent *)event);
- return TRUE;
+ process_gdk_event (area, event->x, event->y, (GdkEvent *)event);
+ return TRUE;
}
void
@@ -907,17 +907,17 @@ foo_scroll_area_set_size_fixed_y (FooScrollArea *scroll_area,
int old_y,
int new_y)
{
- scroll_area->priv->width = width;
- scroll_area->priv->height = height;
+ scroll_area->priv->width = width;
+ scroll_area->priv->height = height;
#if 0
- g_print ("diff: %d\n", new_y - old_y);
+ g_print ("diff: %d\n", new_y - old_y);
#endif
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
- gtk_adjustment_set_value (scroll_area->priv->vadj, new_y);
+ g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
+ gtk_adjustment_set_value (scroll_area->priv->vadj, new_y);
- set_adjustment_values (scroll_area);
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
+ set_adjustment_values (scroll_area);
+ g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
}
void
@@ -925,27 +925,27 @@ foo_scroll_area_set_size (FooScrollArea *scroll_area,
int width,
int height)
{
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- /* FIXME: Default scroll algorithm should probably be to
- * keep the same *area* outside the screen as before.
- *
- * For wrapper widgets that will do something roughly
- * right. For widgets that don't change size, it
- * will do the right thing. Except for idle-layouting
- * widgets.
- *
- * Maybe there should be some generic support for those
- * widgets. Can that even be done?
- *
- * Should we have a version of this function using
- * fixed points?
- */
+ /* FIXME: Default scroll algorithm should probably be to
+ * keep the same *area* outside the screen as before.
+ *
+ * For wrapper widgets that will do something roughly
+ * right. For widgets that don't change size, it
+ * will do the right thing. Except for idle-layouting
+ * widgets.
+ *
+ * Maybe there should be some generic support for those
+ * widgets. Can that even be done?
+ *
+ * Should we have a version of this function using
+ * fixed points?
+ */
- scroll_area->priv->width = width;
- scroll_area->priv->height = height;
+ scroll_area->priv->width = width;
+ scroll_area->priv->height = height;
- set_adjustment_values (scroll_area);
+ set_adjustment_values (scroll_area);
}
static void
@@ -953,14 +953,14 @@ foo_scroll_area_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
- FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
- if (minimum != NULL) {
- *minimum = scroll_area->priv->min_width;
- }
- if (natural != NULL) {
- *natural = scroll_area->priv->min_width;
- }
+ if (minimum != NULL) {
+ *minimum = scroll_area->priv->min_width;
+ }
+ if (natural != NULL) {
+ *natural = scroll_area->priv->min_width;
+ }
}
static void
@@ -968,14 +968,14 @@ foo_scroll_area_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
- FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
+ FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
- if (minimum != NULL) {
- *minimum = scroll_area->priv->min_height;
- }
- if (natural != NULL) {
- *natural = scroll_area->priv->min_height;
- }
+ if (minimum != NULL) {
+ *minimum = scroll_area->priv->min_height;
+ }
+ if (natural != NULL) {
+ *natural = scroll_area->priv->min_height;
+ }
}
static void
@@ -983,106 +983,106 @@ foo_scroll_area_scroll (FooScrollArea *area,
gint dx,
gint dy)
{
- GdkRectangle allocation;
- GdkRectangle src_area;
- GdkRectangle move_area;
- cairo_region_t *invalid_region;
+ GdkRectangle allocation;
+ GdkRectangle src_area;
+ GdkRectangle move_area;
+ cairo_region_t *invalid_region;
- gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
- allocation.x = 0;
- allocation.y = 0;
+ gtk_widget_get_allocation (GTK_WIDGET (area), &allocation);
+ allocation.x = 0;
+ allocation.y = 0;
- src_area = allocation;
- src_area.x -= dx;
- src_area.y -= dy;
+ src_area = allocation;
+ src_area.x -= dx;
+ src_area.y -= dy;
- invalid_region = cairo_region_create_rectangle (&allocation);
+ invalid_region = cairo_region_create_rectangle (&allocation);
- if (gdk_rectangle_intersect (&allocation, &src_area, &move_area))
+ if (gdk_rectangle_intersect (&allocation, &src_area, &move_area))
{
- cairo_region_t *move_region;
- cairo_t *cr;
+ cairo_region_t *move_region;
+ cairo_t *cr;
#if 0
- g_print ("scrolling %d %d %d %d (%d %d)\n",
- move_area.x, move_area.y,
- move_area.width, move_area.height,
- dx, dy);
+ g_print ("scrolling %d %d %d %d (%d %d)\n",
+ move_area.x, move_area.y,
+ move_area.width, move_area.height,
+ dx, dy);
#endif
- cr = cairo_create (area->priv->surface);
+ cr = cairo_create (area->priv->surface);
- /* Cairo doesn't allow self-copies, so we do this little trick instead:
- * 1) Clip so the group size is small.
- * 2) Call push_group() which creates a temporary pixmap as a workaround
- */
- gdk_cairo_rectangle (cr, &move_area);
- cairo_clip (cr);
- cairo_push_group (cr);
+ /* Cairo doesn't allow self-copies, so we do this little trick instead:
+ * 1) Clip so the group size is small.
+ * 2) Call push_group() which creates a temporary pixmap as a workaround
+ */
+ gdk_cairo_rectangle (cr, &move_area);
+ cairo_clip (cr);
+ cairo_push_group (cr);
- cairo_set_source_surface (cr, area->priv->surface, dx, dy);
- gdk_cairo_rectangle (cr, &move_area);
- cairo_fill (cr);
+ cairo_set_source_surface (cr, area->priv->surface, dx, dy);
+ gdk_cairo_rectangle (cr, &move_area);
+ cairo_fill (cr);
- cairo_pop_group_to_source (cr);
- cairo_paint (cr);
+ cairo_pop_group_to_source (cr);
+ cairo_paint (cr);
- cairo_destroy (cr);
+ cairo_destroy (cr);
- gtk_widget_queue_draw (GTK_WIDGET (area));
+ gtk_widget_queue_draw (GTK_WIDGET (area));
- move_region = cairo_region_create_rectangle (&move_area);
- cairo_region_translate (move_region, dx, dy);
- cairo_region_subtract (invalid_region, move_region);
- cairo_region_destroy (move_region);
+ move_region = cairo_region_create_rectangle (&move_area);
+ cairo_region_translate (move_region, dx, dy);
+ cairo_region_subtract (invalid_region, move_region);
+ cairo_region_destroy (move_region);
}
- allocation_to_canvas_region (area, invalid_region);
+ allocation_to_canvas_region (area, invalid_region);
- foo_scroll_area_invalidate_region (area, invalid_region);
+ foo_scroll_area_invalidate_region (area, invalid_region);
- cairo_region_destroy (invalid_region);
+ cairo_region_destroy (invalid_region);
}
static void
foo_scrollbar_adjustment_changed (GtkAdjustment *adj,
FooScrollArea *scroll_area)
{
- GtkWidget *widget = GTK_WIDGET (scroll_area);
- gint dx = 0;
- gint dy = 0;
- GdkRectangle old_viewport, new_viewport;
+ GtkWidget *widget = GTK_WIDGET (scroll_area);
+ gint dx = 0;
+ gint dy = 0;
+ GdkRectangle old_viewport, new_viewport;
- get_viewport (scroll_area, &old_viewport);
+ get_viewport (scroll_area, &old_viewport);
- if (adj == scroll_area->priv->hadj)
+ if (adj == scroll_area->priv->hadj)
{
- /* FIXME: do we treat the offset as int or double, and,
- * if int, how do we round?
- */
- dx = (int)gtk_adjustment_get_value (adj) - scroll_area->priv->x_offset;
- scroll_area->priv->x_offset = gtk_adjustment_get_value (adj);
+ /* FIXME: do we treat the offset as int or double, and,
+ * if int, how do we round?
+ */
+ dx = (int)gtk_adjustment_get_value (adj) - scroll_area->priv->x_offset;
+ scroll_area->priv->x_offset = gtk_adjustment_get_value (adj);
}
- else if (adj == scroll_area->priv->vadj)
+ else if (adj == scroll_area->priv->vadj)
{
- dy = (int)gtk_adjustment_get_value (adj) - scroll_area->priv->y_offset;
- scroll_area->priv->y_offset = gtk_adjustment_get_value (adj);
+ dy = (int)gtk_adjustment_get_value (adj) - scroll_area->priv->y_offset;
+ scroll_area->priv->y_offset = gtk_adjustment_get_value (adj);
}
- else
+ else
{
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
- if (gtk_widget_get_realized (widget))
+ if (gtk_widget_get_realized (widget))
{
- foo_scroll_area_scroll (scroll_area, -dx, -dy);
+ foo_scroll_area_scroll (scroll_area, -dx, -dy);
- //translate_input_regions (scroll_area, -dx, -dy);
+ //translate_input_regions (scroll_area, -dx, -dy);
}
- get_viewport (scroll_area, &new_viewport);
+ get_viewport (scroll_area, &new_viewport);
- emit_viewport_changed (scroll_area, &new_viewport, &old_viewport);
+ emit_viewport_changed (scroll_area, &new_viewport, &old_viewport);
}
static void
@@ -1090,55 +1090,55 @@ set_one_adjustment (FooScrollArea *scroll_area,
GtkAdjustment *adjustment,
GtkAdjustment **location)
{
- g_return_if_fail (location != NULL);
+ g_return_if_fail (location != NULL);
- if (adjustment == *location)
- return;
+ if (adjustment == *location)
+ return;
- if (!adjustment)
- adjustment = new_adjustment ();
+ if (!adjustment)
+ adjustment = new_adjustment ();
- g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
+ g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
- if (*location)
+ if (*location)
{
- g_signal_handlers_disconnect_by_func (
- *location, foo_scrollbar_adjustment_changed, scroll_area);
+ g_signal_handlers_disconnect_by_func (
+ *location, foo_scrollbar_adjustment_changed, scroll_area);
- g_object_unref (*location);
+ g_object_unref (*location);
}
- *location = adjustment;
+ *location = adjustment;
- g_object_ref_sink (*location);
+ g_object_ref_sink (*location);
- g_signal_connect (*location, "value_changed",
- G_CALLBACK (foo_scrollbar_adjustment_changed),
- scroll_area);
+ g_signal_connect (*location, "value_changed",
+ G_CALLBACK (foo_scrollbar_adjustment_changed),
+ scroll_area);
}
static void
foo_scroll_area_set_hadjustment (FooScrollArea *scroll_area,
GtkAdjustment *hadjustment)
{
- set_one_adjustment (scroll_area, hadjustment, &scroll_area->priv->hadj);
+ set_one_adjustment (scroll_area, hadjustment, &scroll_area->priv->hadj);
- set_adjustment_values (scroll_area);
+ set_adjustment_values (scroll_area);
}
static void
foo_scroll_area_set_vadjustment (FooScrollArea *scroll_area,
GtkAdjustment *vadjustment)
{
- set_one_adjustment (scroll_area, vadjustment, &scroll_area->priv->vadj);
+ set_one_adjustment (scroll_area, vadjustment, &scroll_area->priv->vadj);
- set_adjustment_values (scroll_area);
+ set_adjustment_values (scroll_area);
}
FooScrollArea *
foo_scroll_area_new (void)
{
- return g_object_new (FOO_TYPE_SCROLL_AREA, NULL);
+ return g_object_new (FOO_TYPE_SCROLL_AREA, NULL);
}
void
@@ -1146,16 +1146,16 @@ foo_scroll_area_set_min_size (FooScrollArea *scroll_area,
int min_width,
int min_height)
{
- scroll_area->priv->min_width = min_width;
- scroll_area->priv->min_height = min_height;
+ scroll_area->priv->min_width = min_width;
+ scroll_area->priv->min_height = min_height;
- /* FIXME: think through invalidation.
- *
- * Goals: - no repainting everything on size_allocate(),
- * - make sure input boxes are invalidated when
- * needed
- */
- gtk_widget_queue_resize (GTK_WIDGET (scroll_area));
+ /* FIXME: think through invalidation.
+ *
+ * Goals: - no repainting everything on size_allocate(),
+ * - make sure input boxes are invalidated when
+ * needed
+ */
+ gtk_widget_queue_resize (GTK_WIDGET (scroll_area));
}
static void
@@ -1163,10 +1163,10 @@ user_to_device (double *x, double *y,
gpointer data)
{
#if 0
- cairo_t *cr = data;
+ cairo_t *cr = data;
- /* FIXME: not set transform in first place? */
- cairo_user_to_device (cr, x, y);
+ /* FIXME: not set transform in first place? */
+ cairo_user_to_device (cr, x, y);
#endif
}
@@ -1177,18 +1177,18 @@ make_path (FooScrollArea *area,
FooScrollAreaEventFunc func,
gpointer data)
{
- InputPath *path = g_new0 (InputPath, 1);
+ InputPath *path = g_new0 (InputPath, 1);
- path->is_stroke = is_stroke;
- path->fill_rule = cairo_get_fill_rule (cr);
- path->line_width = cairo_get_line_width (cr);
- path->path = cairo_copy_path (cr);
- path_foreach_point (path->path, user_to_device, cr);
- path->func = func;
- path->data = data;
- path->next = area->priv->current_input->paths;
- area->priv->current_input->paths = path;
- return path;
+ path->is_stroke = is_stroke;
+ path->fill_rule = cairo_get_fill_rule (cr);
+ path->line_width = cairo_get_line_width (cr);
+ path->path = cairo_copy_path (cr);
+ path_foreach_point (path->path, user_to_device, cr);
+ path->func = func;
+ path->data = data;
+ path->next = area->priv->current_input->paths;
+ area->priv->current_input->paths = path;
+ return path;
}
/* FIXME: we probably really want a
@@ -1204,11 +1204,11 @@ foo_scroll_area_add_input_from_fill (FooScrollArea *scroll_area,
FooScrollAreaEventFunc func,
gpointer data)
{
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- g_return_if_fail (cr != NULL);
- g_return_if_fail (scroll_area->priv->current_input);
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (scroll_area->priv->current_input);
- make_path (scroll_area, cr, FALSE, func, data);
+ make_path (scroll_area, cr, FALSE, func, data);
}
void
@@ -1217,72 +1217,72 @@ foo_scroll_area_add_input_from_stroke (FooScrollArea *scroll_area,
FooScrollAreaEventFunc func,
gpointer data)
{
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- g_return_if_fail (cr != NULL);
- g_return_if_fail (scroll_area->priv->current_input);
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (scroll_area->priv->current_input);
- make_path (scroll_area, cr, TRUE, func, data);
+ make_path (scroll_area, cr, TRUE, func, data);
}
void
foo_scroll_area_invalidate (FooScrollArea *scroll_area)
{
- GtkAllocation allocation;
- GtkWidget *widget = GTK_WIDGET (scroll_area);
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (scroll_area);
- gtk_widget_get_allocation (widget, &allocation);
- foo_scroll_area_invalidate_rect (scroll_area,
- scroll_area->priv->x_offset, scroll_area->priv->y_offset,
- allocation.width,
- allocation.height);
+ gtk_widget_get_allocation (widget, &allocation);
+ foo_scroll_area_invalidate_rect (scroll_area,
+ scroll_area->priv->x_offset, scroll_area->priv->y_offset,
+ allocation.width,
+ allocation.height);
}
static void
canvas_to_window (FooScrollArea *area,
cairo_region_t *region)
{
- GtkAllocation allocation;
- GtkWidget *widget = GTK_WIDGET (area);
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (area);
- gtk_widget_get_allocation (widget, &allocation);
- cairo_region_translate (region,
- -area->priv->x_offset + allocation.x,
- -area->priv->y_offset + allocation.y);
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_region_translate (region,
+ -area->priv->x_offset + allocation.x,
+ -area->priv->y_offset + allocation.y);
}
static void
window_to_canvas (FooScrollArea *area,
cairo_region_t *region)
{
- GtkAllocation allocation;
- GtkWidget *widget = GTK_WIDGET (area);
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (area);
- gtk_widget_get_allocation (widget, &allocation);
- cairo_region_translate (region,
- area->priv->x_offset - allocation.x,
- area->priv->y_offset - allocation.y);
+ gtk_widget_get_allocation (widget, &allocation);
+ cairo_region_translate (region,
+ area->priv->x_offset - allocation.x,
+ area->priv->y_offset - allocation.y);
}
void
foo_scroll_area_invalidate_region (FooScrollArea *area,
cairo_region_t *region)
{
- GtkWidget *widget;
+ GtkWidget *widget;
- g_return_if_fail (FOO_IS_SCROLL_AREA (area));
+ g_return_if_fail (FOO_IS_SCROLL_AREA (area));
- widget = GTK_WIDGET (area);
+ widget = GTK_WIDGET (area);
- cairo_region_union (area->priv->update_region, region);
+ cairo_region_union (area->priv->update_region, region);
- if (gtk_widget_get_realized (widget))
+ if (gtk_widget_get_realized (widget))
{
- canvas_to_window (area, region);
+ canvas_to_window (area, region);
- gdk_window_invalidate_region (gtk_widget_get_window (widget),
- region, TRUE);
+ gdk_window_invalidate_region (gtk_widget_get_window (widget),
+ region, TRUE);
- window_to_canvas (area, region);
+ window_to_canvas (area, region);
}
}
@@ -1293,16 +1293,16 @@ foo_scroll_area_invalidate_rect (FooScrollArea *scroll_area,
int width,
int height)
{
- cairo_rectangle_int_t rect = { x, y, width, height };
- cairo_region_t *region;
+ cairo_rectangle_int_t rect = { x, y, width, height };
+ cairo_region_t *region;
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- region = cairo_region_create_rectangle (&rect);
+ region = cairo_region_create_rectangle (&rect);
- foo_scroll_area_invalidate_region (scroll_area, region);
+ foo_scroll_area_invalidate_region (scroll_area, region);
- cairo_region_destroy (region);
+ cairo_region_destroy (region);
}
void
@@ -1310,31 +1310,31 @@ foo_scroll_area_begin_grab (FooScrollArea *scroll_area,
FooScrollAreaEventFunc func,
gpointer input_data)
{
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- g_return_if_fail (!scroll_area->priv->grabbed);
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (!scroll_area->priv->grabbed);
- scroll_area->priv->grabbed = TRUE;
- scroll_area->priv->grab_func = func;
- scroll_area->priv->grab_data = input_data;
+ scroll_area->priv->grabbed = TRUE;
+ scroll_area->priv->grab_func = func;
+ scroll_area->priv->grab_data = input_data;
- /* FIXME: we should probably take a server grab */
- /* Also, maybe there should be support for setting the grab cursor */
+ /* FIXME: we should probably take a server grab */
+ /* Also, maybe there should be support for setting the grab cursor */
}
void
foo_scroll_area_end_grab (FooScrollArea *scroll_area)
{
- g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
+ g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- scroll_area->priv->grabbed = FALSE;
- scroll_area->priv->grab_func = NULL;
- scroll_area->priv->grab_data = NULL;
+ scroll_area->priv->grabbed = FALSE;
+ scroll_area->priv->grab_func = NULL;
+ scroll_area->priv->grab_data = NULL;
}
gboolean
foo_scroll_area_is_grabbed (FooScrollArea *scroll_area)
{
- return scroll_area->priv->grabbed;
+ return scroll_area->priv->grabbed;
}
void
@@ -1342,104 +1342,104 @@ foo_scroll_area_set_viewport_pos (FooScrollArea *scroll_area,
int x,
int y)
{
- g_object_freeze_notify (G_OBJECT (scroll_area->priv->hadj));
- g_object_freeze_notify (G_OBJECT (scroll_area->priv->vadj));
- gtk_adjustment_set_value (scroll_area->priv->hadj, x);
- gtk_adjustment_set_value (scroll_area->priv->vadj, y);
+ g_object_freeze_notify (G_OBJECT (scroll_area->priv->hadj));
+ g_object_freeze_notify (G_OBJECT (scroll_area->priv->vadj));
+ gtk_adjustment_set_value (scroll_area->priv->hadj, x);
+ gtk_adjustment_set_value (scroll_area->priv->vadj, y);
- set_adjustment_values (scroll_area);
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->hadj));
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
+ set_adjustment_values (scroll_area);
+ g_object_thaw_notify (G_OBJECT (scroll_area->priv->hadj));
+ g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
}
static gboolean
rect_contains (const GdkRectangle *rect, int x, int y)
{
- return (x >= rect->x &&
- y >= rect->y &&
- x < rect->x + rect->width &&
- y < rect->y + rect->height);
+ return (x >= rect->x &&
+ y >= rect->y &&
+ x < rect->x + rect->width &&
+ y < rect->y + rect->height);
}
static void
stop_scrolling (FooScrollArea *area)
{
#if 0
- g_print ("stop scrolling\n");
+ g_print ("stop scrolling\n");
#endif
- if (area->priv->auto_scroll_info)
+ if (area->priv->auto_scroll_info)
{
- g_source_remove (area->priv->auto_scroll_info->timeout_id);
- g_timer_destroy (area->priv->auto_scroll_info->timer);
- g_free (area->priv->auto_scroll_info);
+ g_source_remove (area->priv->auto_scroll_info->timeout_id);
+ g_timer_destroy (area->priv->auto_scroll_info->timer);
+ g_free (area->priv->auto_scroll_info);
- area->priv->auto_scroll_info = NULL;
+ area->priv->auto_scroll_info = NULL;
}
}
static gboolean
scroll_idle (gpointer data)
{
- GdkRectangle viewport, new_viewport;
- FooScrollArea *area = data;
- AutoScrollInfo *info = area->priv->auto_scroll_info;
- int new_x, new_y;
- double elapsed;
+ GdkRectangle viewport, new_viewport;
+ FooScrollArea *area = data;
+ AutoScrollInfo *info = area->priv->auto_scroll_info;
+ int new_x, new_y;
+ double elapsed;
- get_viewport (area, &viewport);
+ get_viewport (area, &viewport);
#if 0
- g_print ("old info: %d %d\n", info->dx, info->dy);
+ g_print ("old info: %d %d\n", info->dx, info->dy);
- g_print ("timeout (%d %d)\n", dx, dy);
+ g_print ("timeout (%d %d)\n", dx, dy);
#endif
#if 0
- g_print ("new info %d %d\n", info->dx, info->dy);
+ g_print ("new info %d %d\n", info->dx, info->dy);
#endif
- elapsed = g_timer_elapsed (info->timer, NULL);
+ elapsed = g_timer_elapsed (info->timer, NULL);
- info->res_x = elapsed * info->dx / 0.2;
- info->res_y = elapsed * info->dy / 0.2;
+ info->res_x = elapsed * info->dx / 0.2;
+ info->res_y = elapsed * info->dy / 0.2;
#if 0
- g_print ("%f %f\n", info->res_x, info->res_y);
+ g_print ("%f %f\n", info->res_x, info->res_y);
#endif
- new_x = viewport.x + info->res_x;
- new_y = viewport.y + info->res_y;
+ new_x = viewport.x + info->res_x;
+ new_y = viewport.y + info->res_y;
#if 0
- g_print ("%f\n", elapsed * (info->dx / 0.2));
+ g_print ("%f\n", elapsed * (info->dx / 0.2));
#endif
#if 0
- g_print ("new_x, new_y\n: %d %d\n", new_x, new_y);
+ g_print ("new_x, new_y\n: %d %d\n", new_x, new_y);
#endif
- foo_scroll_area_set_viewport_pos (area, new_x, new_y);
+ foo_scroll_area_set_viewport_pos (area, new_x, new_y);
#if 0
- viewport.x + info->dx,
- viewport.y + info->dy);
+ viewport.x + info->dx,
+ viewport.y + info->dy);
#endif
- get_viewport (area, &new_viewport);
+get_viewport (area, &new_viewport);
- if (viewport.x == new_viewport.x &&
- viewport.y == new_viewport.y &&
- (info->res_x > 1.0 ||
- info->res_y > 1.0 ||
- info->res_x < -1.0 ||
- info->res_y < -1.0))
- {
- stop_scrolling (area);
+if (viewport.x == new_viewport.x &&
+ viewport.y == new_viewport.y &&
+ (info->res_x > 1.0 ||
+ info->res_y > 1.0 ||
+ info->res_x < -1.0 ||
+ info->res_y < -1.0))
+ {
+ stop_scrolling (area);
- /* stop scrolling if it didn't have an effect */
- return FALSE;
- }
+ /* stop scrolling if it didn't have an effect */
+ return FALSE;
+ }
- return TRUE;
+return TRUE;
}
static void
@@ -1447,86 +1447,86 @@ ensure_scrolling (FooScrollArea *area,
int dx,
int dy)
{
- if (!area->priv->auto_scroll_info)
+ if (!area->priv->auto_scroll_info)
{
#if 0
- g_print ("start scrolling\n");
+ g_print ("start scrolling\n");
#endif
- area->priv->auto_scroll_info = g_new0 (AutoScrollInfo, 1);
- area->priv->auto_scroll_info->timeout_id =
- g_idle_add (scroll_idle, area);
- area->priv->auto_scroll_info->timer = g_timer_new ();
+ area->priv->auto_scroll_info = g_new0 (AutoScrollInfo, 1);
+ area->priv->auto_scroll_info->timeout_id =
+ g_idle_add (scroll_idle, area);
+ area->priv->auto_scroll_info->timer = g_timer_new ();
}
#if 0
- g_print ("setting scrolling to %d %d\n", dx, dy);
+ g_print ("setting scrolling to %d %d\n", dx, dy);
#endif
#if 0
- g_print ("dx, dy: %d %d\n", dx, dy);
+ g_print ("dx, dy: %d %d\n", dx, dy);
#endif
- area->priv->auto_scroll_info->dx = dx;
- area->priv->auto_scroll_info->dy = dy;
+ area->priv->auto_scroll_info->dx = dx;
+ area->priv->auto_scroll_info->dy = dy;
}
void
foo_scroll_area_auto_scroll (FooScrollArea *scroll_area,
FooScrollAreaEvent *event)
{
- GdkRectangle viewport;
+ GdkRectangle viewport;
- get_viewport (scroll_area, &viewport);
+ get_viewport (scroll_area, &viewport);
- if (rect_contains (&viewport, event->x, event->y))
+ if (rect_contains (&viewport, event->x, event->y))
{
- stop_scrolling (scroll_area);
+ stop_scrolling (scroll_area);
}
- else
+ else
{
- int dx, dy;
+ int dx, dy;
- dx = dy = 0;
+ dx = dy = 0;
- if (event->y < viewport.y)
+ if (event->y < viewport.y)
{
- dy = event->y - viewport.y;
- dy = MIN (dy + 2, 0);
+ dy = event->y - viewport.y;
+ dy = MIN (dy + 2, 0);
}
- else if (event->y >= viewport.y + viewport.height)
+ else if (event->y >= viewport.y + viewport.height)
{
- dy = event->y - (viewport.y + viewport.height - 1);
- dy = MAX (dy - 2, 0);
+ dy = event->y - (viewport.y + viewport.height - 1);
+ dy = MAX (dy - 2, 0);
}
- if (event->x < viewport.x)
+ if (event->x < viewport.x)
{
- dx = event->x - viewport.x;
- dx = MIN (dx + 2, 0);
+ dx = event->x - viewport.x;
+ dx = MIN (dx + 2, 0);
}
- else if (event->x >= viewport.x + viewport.width)
+ else if (event->x >= viewport.x + viewport.width)
{
- dx = event->x - (viewport.x + viewport.width - 1);
- dx = MAX (dx - 2, 0);
+ dx = event->x - (viewport.x + viewport.width - 1);
+ dx = MAX (dx - 2, 0);
}
#if 0
- g_print ("dx, dy: %d %d\n", dx, dy);
+ g_print ("dx, dy: %d %d\n", dx, dy);
#endif
- ensure_scrolling (scroll_area, dx, dy);
+ ensure_scrolling (scroll_area, dx, dy);
}
}
void
foo_scroll_area_begin_auto_scroll (FooScrollArea *scroll_area)
{
- /* noop for now */
+ /* noop for now */
}
void
foo_scroll_area_end_auto_scroll (FooScrollArea *scroll_area)
{
- stop_scrolling (scroll_area);
+ stop_scrolling (scroll_area);
}
diff --git a/panels/display/scrollarea.h b/panels/display/scrollarea.h
index fba99ef..b394c17 100644
--- a/panels/display/scrollarea.h
+++ b/panels/display/scrollarea.h
@@ -31,17 +31,17 @@ typedef struct FooScrollAreaPrivate FooScrollAreaPrivate;
typedef struct FooScrollAreaEvent FooScrollAreaEvent;
typedef enum
-{
+ {
FOO_BUTTON_PRESS,
FOO_BUTTON_RELEASE,
FOO_MOTION
-} FooScrollAreaEventType;
+ } FooScrollAreaEventType;
struct FooScrollAreaEvent
{
- FooScrollAreaEventType type;
- int x;
- int y;
+ FooScrollAreaEventType type;
+ int x;
+ int y;
};
typedef void (* FooScrollAreaEventFunc) (FooScrollArea *area,
@@ -50,27 +50,27 @@ typedef void (* FooScrollAreaEventFunc) (FooScrollArea *area,
struct FooScrollArea
{
- GtkContainer parent_instance;
+ GtkContainer parent_instance;
- FooScrollAreaPrivate *priv;
+ FooScrollAreaPrivate *priv;
};
struct FooScrollAreaClass
{
- GtkContainerClass parent_class;
+ GtkContainerClass parent_class;
- void (*set_scroll_adjustments) (FooScrollArea *scroll_area,
- GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment);
+ void (*set_scroll_adjustments) (FooScrollArea *scroll_area,
+ GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment);
- void (*viewport_changed) (FooScrollArea *scroll_area,
- GdkRectangle *old_viewport,
- GdkRectangle *new_viewport);
+ void (*viewport_changed) (FooScrollArea *scroll_area,
+ GdkRectangle *old_viewport,
+ GdkRectangle *new_viewport);
- void (*paint) (FooScrollArea *scroll_area,
- cairo_t *cr,
- GdkRectangle *extents,
- cairo_region_t *region);
+ void (*paint) (FooScrollArea *scroll_area,
+ cairo_t *cr,
+ GdkRectangle *extents,
+ cairo_region_t *region);
};
GType foo_scroll_area_get_type (void);
@@ -101,9 +101,9 @@ void foo_scroll_area_add_input_from_stroke (FooScrollArea *sc
FooScrollAreaEventFunc func,
gpointer data);
void foo_scroll_area_add_input_from_fill (FooScrollArea *scroll_area,
- cairo_t *cr,
- FooScrollAreaEventFunc func,
- gpointer data);
+ cairo_t *cr,
+ FooScrollAreaEventFunc func,
+ gpointer data);
void foo_scroll_area_invalidate_region (FooScrollArea *area,
cairo_region_t *region);
void foo_scroll_area_invalidate (FooScrollArea *scroll_area);
diff --git a/panels/display/xrandr-capplet.c b/panels/display/xrandr-capplet.c
index 8074646..e9c7b04 100644
--- a/panels/display/xrandr-capplet.c
+++ b/panels/display/xrandr-capplet.c
@@ -43,41 +43,41 @@ typedef struct GrabInfo GrabInfo;
struct App
{
- GnomeRRScreen *screen;
- GnomeRRConfig *current_configuration;
- GnomeRRLabeler *labeler;
- GnomeOutputInfo *current_output;
-
- GtkBuilder *builder;
-
- GtkWidget *panel;
- GtkWidget *current_monitor_event_box;
- GtkWidget *current_monitor_label;
- GtkWidget *monitor_on_radio;
- GtkWidget *monitor_off_radio;
- GtkListStore *resolution_store;
- GtkWidget *resolution_combo;
- GtkWidget *rotation_combo;
- GtkWidget *clone_checkbox;
- GtkWidget *clone_label;
- GtkWidget *show_icon_checkbox;
-
- /* We store the event timestamp when the Apply button is clicked */
- GtkWidget *apply_button;
- guint32 apply_button_clicked_timestamp;
-
- GtkWidget *area;
- gboolean ignore_gui_changes;
-
- /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
- DBusGConnection *connection;
- DBusGProxy *proxy;
- DBusGProxyCall *proxy_call;
-
- enum {
- APPLYING_VERSION_1,
- APPLYING_VERSION_2
- } apply_configuration_state;
+ GnomeRRScreen *screen;
+ GnomeRRConfig *current_configuration;
+ GnomeRRLabeler *labeler;
+ GnomeOutputInfo *current_output;
+
+ GtkBuilder *builder;
+
+ GtkWidget *panel;
+ GtkWidget *current_monitor_event_box;
+ GtkWidget *current_monitor_label;
+ GtkWidget *monitor_on_radio;
+ GtkWidget *monitor_off_radio;
+ GtkListStore *resolution_store;
+ GtkWidget *resolution_combo;
+ GtkWidget *rotation_combo;
+ GtkWidget *clone_checkbox;
+ GtkWidget *clone_label;
+ GtkWidget *show_icon_checkbox;
+
+ /* We store the event timestamp when the Apply button is clicked */
+ GtkWidget *apply_button;
+ guint32 apply_button_clicked_timestamp;
+
+ GtkWidget *area;
+ gboolean ignore_gui_changes;
+
+ /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ DBusGProxyCall *proxy_call;
+
+ enum {
+ APPLYING_VERSION_1,
+ APPLYING_VERSION_2
+ } apply_configuration_state;
};
static void rebuild_gui (App *app);
@@ -93,65 +93,65 @@ static gboolean output_info_supports_mode (App *app, GnomeOutputInfo *info, int
static void
error_message (App *app, const char *primary_text, const char *secondary_text)
{
- GtkWidget *toplevel;
- GtkWidget *dialog;
+ GtkWidget *toplevel;
+ GtkWidget *dialog;
- if (app && app->panel)
- toplevel = gtk_widget_get_toplevel (app->panel);
- else
- toplevel = NULL;
+ if (app && app->panel)
+ toplevel = gtk_widget_get_toplevel (app->panel);
+ else
+ toplevel = NULL;
- dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", primary_text);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", primary_text);
- if (secondary_text)
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_text);
+ if (secondary_text)
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_text);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
static gboolean
do_free (gpointer data)
{
- g_free (data);
- return FALSE;
+ g_free (data);
+ return FALSE;
}
static gchar *
idle_free (gchar *s)
{
- g_idle_add (do_free, s);
+ g_idle_add (do_free, s);
- return s;
+ return s;
}
static void
on_screen_changed (GnomeRRScreen *scr,
gpointer data)
{
- GnomeRRConfig *current;
- App *app = data;
+ GnomeRRConfig *current;
+ App *app = data;
- current = gnome_rr_config_new_current (app->screen);
+ current = gnome_rr_config_new_current (app->screen);
- if (app->current_configuration)
- gnome_rr_config_free (app->current_configuration);
+ if (app->current_configuration)
+ gnome_rr_config_free (app->current_configuration);
- app->current_configuration = current;
- app->current_output = NULL;
+ app->current_configuration = current;
+ app->current_output = NULL;
- if (app->labeler) {
- gnome_rr_labeler_hide (app->labeler);
- g_object_unref (app->labeler);
- }
+ if (app->labeler) {
+ gnome_rr_labeler_hide (app->labeler);
+ g_object_unref (app->labeler);
+ }
- app->labeler = gnome_rr_labeler_new (app->current_configuration);
+ app->labeler = gnome_rr_labeler_new (app->current_configuration);
- select_current_output_from_dialog_position (app);
+ select_current_output_from_dialog_position (app);
}
static void
@@ -159,42 +159,42 @@ on_viewport_changed (FooScrollArea *scroll_area,
GdkRectangle *old_viewport,
GdkRectangle *new_viewport)
{
- foo_scroll_area_set_size (scroll_area,
- new_viewport->width,
- new_viewport->height);
+ foo_scroll_area_set_size (scroll_area,
+ new_viewport->width,
+ new_viewport->height);
- foo_scroll_area_invalidate (scroll_area);
+ foo_scroll_area_invalidate (scroll_area);
}
static void
layout_set_font (PangoLayout *layout, const char *font)
{
- PangoFontDescription *desc =
- pango_font_description_from_string (font);
+ PangoFontDescription *desc =
+ pango_font_description_from_string (font);
- if (desc)
+ if (desc)
{
- pango_layout_set_font_description (layout, desc);
+ pango_layout_set_font_description (layout, desc);
- pango_font_description_free (desc);
+ pango_font_description_free (desc);
}
}
static void
clear_combo (GtkWidget *widget)
{
- GtkComboBox *box = GTK_COMBO_BOX (widget);
- GtkTreeModel *model = gtk_combo_box_get_model (box);
- GtkListStore *store = GTK_LIST_STORE (model);
+ GtkComboBox *box = GTK_COMBO_BOX (widget);
+ GtkTreeModel *model = gtk_combo_box_get_model (box);
+ GtkListStore *store = GTK_LIST_STORE (model);
- gtk_list_store_clear (store);
+ gtk_list_store_clear (store);
}
typedef struct
{
- const char *text;
- gboolean found;
- GtkTreeIter iter;
+ const char *text;
+ gboolean found;
+ GtkTreeIter iter;
} ForeachInfo;
static gboolean
@@ -203,21 +203,21 @@ foreach (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- ForeachInfo *info = data;
- char *text = NULL;
+ ForeachInfo *info = data;
+ char *text = NULL;
- gtk_tree_model_get (model, iter, 0, &text, -1);
+ gtk_tree_model_get (model, iter, 0, &text, -1);
- g_assert (text != NULL);
+ g_assert (text != NULL);
- if (strcmp (info->text, text) == 0)
+ if (strcmp (info->text, text) == 0)
{
- info->found = TRUE;
- info->iter = *iter;
- return TRUE;
+ info->found = TRUE;
+ info->iter = *iter;
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
static void
@@ -226,156 +226,156 @@ add_key (GtkWidget *widget,
int width, int height, int rate,
GnomeRRRotation rotation)
{
- ForeachInfo info;
- GtkComboBox *box = GTK_COMBO_BOX (widget);
- GtkTreeModel *model = gtk_combo_box_get_model (box);
- GtkListStore *store = GTK_LIST_STORE (model);
- gboolean retval;
+ ForeachInfo info;
+ GtkComboBox *box = GTK_COMBO_BOX (widget);
+ GtkTreeModel *model = gtk_combo_box_get_model (box);
+ GtkListStore *store = GTK_LIST_STORE (model);
+ gboolean retval;
- info.text = text;
- info.found = FALSE;
+ info.text = text;
+ info.found = FALSE;
- gtk_tree_model_foreach (model, foreach, &info);
+ gtk_tree_model_foreach (model, foreach, &info);
- if (!info.found)
+ if (!info.found)
{
- GtkTreeIter iter;
- gtk_list_store_insert_with_values (store, &iter, -1,
- 0, text,
- 1, width,
- 2, height,
- 3, rate,
- 4, width * height,
- 5, rotation,
- -1);
-
- retval = TRUE;
+ GtkTreeIter iter;
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ 0, text,
+ 1, width,
+ 2, height,
+ 3, rate,
+ 4, width * height,
+ 5, rotation,
+ -1);
+
+ retval = TRUE;
}
- else
+ else
{
- retval = FALSE;
+ retval = FALSE;
}
}
static gboolean
combo_select (GtkWidget *widget, const char *text)
{
- GtkComboBox *box = GTK_COMBO_BOX (widget);
- GtkTreeModel *model = gtk_combo_box_get_model (box);
- ForeachInfo info;
+ GtkComboBox *box = GTK_COMBO_BOX (widget);
+ GtkTreeModel *model = gtk_combo_box_get_model (box);
+ ForeachInfo info;
- info.text = text;
- info.found = FALSE;
+ info.text = text;
+ info.found = FALSE;
- gtk_tree_model_foreach (model, foreach, &info);
+ gtk_tree_model_foreach (model, foreach, &info);
- if (!info.found)
- return FALSE;
+ if (!info.found)
+ return FALSE;
- gtk_combo_box_set_active_iter (box, &info.iter);
- return TRUE;
+ gtk_combo_box_set_active_iter (box, &info.iter);
+ return TRUE;
}
static GnomeRRMode **
get_current_modes (App *app)
{
- GnomeRROutput *output;
+ GnomeRROutput *output;
- if (app->current_configuration->clone)
+ if (app->current_configuration->clone)
{
- return gnome_rr_screen_list_clone_modes (app->screen);
+ return gnome_rr_screen_list_clone_modes (app->screen);
}
- else
+ else
{
- if (!app->current_output)
- return NULL;
+ if (!app->current_output)
+ return NULL;
- output = gnome_rr_screen_get_output_by_name (
- app->screen, app->current_output->name);
+ output = gnome_rr_screen_get_output_by_name (
+ app->screen, app->current_output->name);
- if (!output)
- return NULL;
+ if (!output)
+ return NULL;
- return gnome_rr_output_list_modes (output);
+ return gnome_rr_output_list_modes (output);
}
}
static void
rebuild_rotation_combo (App *app)
{
- typedef struct
- {
- GnomeRRRotation rotation;
- const char * name;
- } RotationInfo;
- static const RotationInfo rotations[] = {
- { GNOME_RR_ROTATION_0, N_("Normal") },
- { GNOME_RR_ROTATION_90, N_("Left") },
- { GNOME_RR_ROTATION_270, N_("Right") },
- { GNOME_RR_ROTATION_180, N_("Upside Down") },
- };
- const char *selection;
- GnomeRRRotation current;
- int i;
-
- clear_combo (app->rotation_combo);
-
- gtk_widget_set_sensitive (
- app->rotation_combo, app->current_output && app->current_output->on);
-
- if (!app->current_output)
- return;
-
- current = app->current_output->rotation;
-
- selection = NULL;
- for (i = 0; i < G_N_ELEMENTS (rotations); ++i)
+ typedef struct
+ {
+ GnomeRRRotation rotation;
+ const char * name;
+ } RotationInfo;
+ static const RotationInfo rotations[] = {
+ { GNOME_RR_ROTATION_0, N_("Normal") },
+ { GNOME_RR_ROTATION_90, N_("Left") },
+ { GNOME_RR_ROTATION_270, N_("Right") },
+ { GNOME_RR_ROTATION_180, N_("Upside Down") },
+ };
+ const char *selection;
+ GnomeRRRotation current;
+ int i;
+
+ clear_combo (app->rotation_combo);
+
+ gtk_widget_set_sensitive (
+ app->rotation_combo, app->current_output && app->current_output->on);
+
+ if (!app->current_output)
+ return;
+
+ current = app->current_output->rotation;
+
+ selection = NULL;
+ for (i = 0; i < G_N_ELEMENTS (rotations); ++i)
{
- const RotationInfo *info = &(rotations[i]);
+ const RotationInfo *info = &(rotations[i]);
- app->current_output->rotation = info->rotation;
+ app->current_output->rotation = info->rotation;
- /* NULL-GError --- FIXME: we should say why this rotation is not available! */
- if (gnome_rr_config_applicable (app->current_configuration, app->screen, NULL))
+ /* NULL-GError --- FIXME: we should say why this rotation is not available! */
+ if (gnome_rr_config_applicable (app->current_configuration, app->screen, NULL))
{
- add_key (app->rotation_combo, _(info->name), 0, 0, 0, info->rotation);
+ add_key (app->rotation_combo, _(info->name), 0, 0, 0, info->rotation);
- if (info->rotation == current)
- selection = _(info->name);
+ if (info->rotation == current)
+ selection = _(info->name);
}
}
- app->current_output->rotation = current;
+ app->current_output->rotation = current;
- if (!(selection && combo_select (app->rotation_combo, selection)))
- combo_select (app->rotation_combo, _("Normal"));
+ if (!(selection && combo_select (app->rotation_combo, selection)))
+ combo_select (app->rotation_combo, _("Normal"));
}
static int
count_active_outputs (App *app)
{
- int i, count = 0;
+ int i, count = 0;
- for (i = 0; app->current_configuration->outputs[i] != NULL; ++i)
+ for (i = 0; app->current_configuration->outputs[i] != NULL; ++i)
{
- GnomeOutputInfo *output = app->current_configuration->outputs[i];
- if (output->on)
- count++;
+ GnomeOutputInfo *output = app->current_configuration->outputs[i];
+ if (output->on)
+ count++;
}
- return count;
+ return count;
}
#if 0
static int
count_all_outputs (GnomeRRConfig *config)
{
- int i;
+ int i;
- for (i = 0; config->outputs[i] != NULL; i++)
- ;
+ for (i = 0; config->outputs[i] != NULL; i++)
+ ;
- return i;
+ return i;
}
#endif
@@ -388,209 +388,209 @@ count_all_outputs (GnomeRRConfig *config)
static gboolean
mirror_screens_is_supported (App *app)
{
- int clone_width, clone_height;
- gboolean have_clone_size;
- gboolean mirror_is_supported;
+ int clone_width, clone_height;
+ gboolean have_clone_size;
+ gboolean mirror_is_supported;
- mirror_is_supported = FALSE;
+ mirror_is_supported = FALSE;
- have_clone_size = get_clone_size (app->screen, &clone_width, &clone_height);
+ have_clone_size = get_clone_size (app->screen, &clone_width, &clone_height);
- if (have_clone_size) {
- int i;
- int num_outputs_with_clone_size;
+ if (have_clone_size) {
+ int i;
+ int num_outputs_with_clone_size;
- num_outputs_with_clone_size = 0;
+ num_outputs_with_clone_size = 0;
- for (i = 0; app->current_configuration->outputs[i] != NULL; i++)
- {
- GnomeOutputInfo *output = app->current_configuration->outputs[i];
-
- /* We count the connected outputs that support the clone size. It
- * doesn't matter if those outputs aren't actually On currently; we
- * will turn them on in on_clone_changed().
- */
- if (output->connected && output_info_supports_mode (app, output, clone_width, clone_height))
- num_outputs_with_clone_size++;
- }
+ for (i = 0; app->current_configuration->outputs[i] != NULL; i++)
+ {
+ GnomeOutputInfo *output = app->current_configuration->outputs[i];
- if (num_outputs_with_clone_size >= 2)
- mirror_is_supported = TRUE;
- }
+ /* We count the connected outputs that support the clone size. It
+ * doesn't matter if those outputs aren't actually On currently; we
+ * will turn them on in on_clone_changed().
+ */
+ if (output->connected && output_info_supports_mode (app, output, clone_width, clone_height))
+ num_outputs_with_clone_size++;
+ }
- return mirror_is_supported;
+ if (num_outputs_with_clone_size >= 2)
+ mirror_is_supported = TRUE;
+ }
+
+ return mirror_is_supported;
}
static void
rebuild_mirror_screens (App *app)
{
- gboolean mirror_is_active;
- gboolean mirror_is_supported;
+ gboolean mirror_is_active;
+ gboolean mirror_is_supported;
+
+ g_signal_handlers_block_by_func (app->clone_checkbox, G_CALLBACK (on_clone_changed), app);
- g_signal_handlers_block_by_func (app->clone_checkbox, G_CALLBACK (on_clone_changed), app);
+ mirror_is_active = app->current_configuration && app->current_configuration->clone;
- mirror_is_active = app->current_configuration && app->current_configuration->clone;
+ /* If mirror_is_active, then it *must* be possible to turn mirroring off */
+ mirror_is_supported = mirror_is_active || mirror_screens_is_supported (app);
- /* If mirror_is_active, then it *must* be possible to turn mirroring off */
- mirror_is_supported = mirror_is_active || mirror_screens_is_supported (app);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->clone_checkbox), mirror_is_active);
- gtk_widget_set_sensitive (app->clone_checkbox, mirror_is_supported);
- gtk_widget_set_sensitive (app->clone_label, mirror_is_supported);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->clone_checkbox), mirror_is_active);
+ gtk_widget_set_sensitive (app->clone_checkbox, mirror_is_supported);
+ gtk_widget_set_sensitive (app->clone_label, mirror_is_supported);
- g_signal_handlers_unblock_by_func (app->clone_checkbox, G_CALLBACK (on_clone_changed), app);
+ g_signal_handlers_unblock_by_func (app->clone_checkbox, G_CALLBACK (on_clone_changed), app);
}
static void
rebuild_current_monitor_label (App *app)
{
- char *str, *tmp;
- GdkColor color;
- gboolean use_color;
+ char *str, *tmp;
+ GdkColor color;
+ gboolean use_color;
- if (app->current_output)
- {
- if (app->current_configuration->clone)
- tmp = g_strdup (_("Mirror Screens"));
- else
- tmp = g_strdup (app->current_output->display_name);
-
- str = g_strdup_printf ("<b>%s</b>", tmp);
- gnome_rr_labeler_get_color_for_output (app->labeler, app->current_output, &color);
- use_color = TRUE;
- g_free (tmp);
- }
- else
- {
- str = g_strdup_printf ("<b>%s</b>", _("Monitor"));
- use_color = FALSE;
- }
+ if (app->current_output)
+ {
+ if (app->current_configuration->clone)
+ tmp = g_strdup (_("Mirror Screens"));
+ else
+ tmp = g_strdup (app->current_output->display_name);
+
+ str = g_strdup_printf ("<b>%s</b>", tmp);
+ gnome_rr_labeler_get_color_for_output (app->labeler, app->current_output, &color);
+ use_color = TRUE;
+ g_free (tmp);
+ }
+ else
+ {
+ str = g_strdup_printf ("<b>%s</b>", _("Monitor"));
+ use_color = FALSE;
+ }
- gtk_label_set_markup (GTK_LABEL (app->current_monitor_label), str);
- g_free (str);
+ gtk_label_set_markup (GTK_LABEL (app->current_monitor_label), str);
+ g_free (str);
- if (use_color)
- {
- GdkColor black = { 0, 0, 0, 0 };
+ if (use_color)
+ {
+ GdkColor black = { 0, 0, 0, 0 };
- gtk_widget_modify_bg (app->current_monitor_event_box, gtk_widget_get_state (app->current_monitor_event_box), &color);
+ gtk_widget_modify_bg (app->current_monitor_event_box, gtk_widget_get_state (app->current_monitor_event_box), &color);
- /* Make the label explicitly black. We don't want it to follow the
- * theme's colors, since the label is always shown against a light
- * pastel background. See bgo#556050
- */
- gtk_widget_modify_fg (app->current_monitor_label, gtk_widget_get_state (app->current_monitor_label), &black);
- }
- else
- {
- /* Remove any modifications we did on the label's color */
- GtkRcStyle *reset_rc_style;
+ /* Make the label explicitly black. We don't want it to follow the
+ * theme's colors, since the label is always shown against a light
+ * pastel background. See bgo#556050
+ */
+ gtk_widget_modify_fg (app->current_monitor_label, gtk_widget_get_state (app->current_monitor_label), &black);
+ }
+ else
+ {
+ /* Remove any modifications we did on the label's color */
+ GtkRcStyle *reset_rc_style;
- reset_rc_style = gtk_rc_style_new ();
- gtk_widget_modify_style (app->current_monitor_label, reset_rc_style); /* takes ownership of, and destroys, the rc style */
- }
+ reset_rc_style = gtk_rc_style_new ();
+ gtk_widget_modify_style (app->current_monitor_label, reset_rc_style); /* takes ownership of, and destroys, the rc style */
+ }
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (app->current_monitor_event_box), use_color);
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (app->current_monitor_event_box), use_color);
}
static void
rebuild_on_off_radios (App *app)
{
- gboolean sensitive;
- gboolean on_active;
- gboolean off_active;
+ gboolean sensitive;
+ gboolean on_active;
+ gboolean off_active;
- g_signal_handlers_block_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
- g_signal_handlers_block_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+ g_signal_handlers_block_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+ g_signal_handlers_block_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
- sensitive = FALSE;
- on_active = FALSE;
- off_active = FALSE;
+ sensitive = FALSE;
+ on_active = FALSE;
+ off_active = FALSE;
- if (!app->current_configuration->clone && app->current_output)
+ if (!app->current_configuration->clone && app->current_output)
{
- if (count_active_outputs (app) > 1 || !app->current_output->on)
- sensitive = TRUE;
- else
- sensitive = FALSE;
+ if (count_active_outputs (app) > 1 || !app->current_output->on)
+ sensitive = TRUE;
+ else
+ sensitive = FALSE;
- on_active = app->current_output->on;
- off_active = !on_active;
+ on_active = app->current_output->on;
+ off_active = !on_active;
}
- gtk_widget_set_sensitive (app->monitor_on_radio, sensitive);
- gtk_widget_set_sensitive (app->monitor_off_radio, sensitive);
+ gtk_widget_set_sensitive (app->monitor_on_radio, sensitive);
+ gtk_widget_set_sensitive (app->monitor_off_radio, sensitive);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_on_radio), on_active);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_off_radio), off_active);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_on_radio), on_active);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_off_radio), off_active);
- g_signal_handlers_unblock_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
- g_signal_handlers_unblock_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+ g_signal_handlers_unblock_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
+ g_signal_handlers_unblock_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app);
}
static char *
make_resolution_string (int width, int height)
{
- int ratio;
- const char *aspect = NULL;
-
- if (width && height) {
- if (width > height)
- ratio = width * 10 / height;
- else
- ratio = height * 10 / width;
-
- switch (ratio) {
- case 13:
- aspect = "4:3";
- break;
- case 16:
- aspect = "16:10";
- break;
- case 17:
- aspect = "16:9";
- break;
- case 12:
- aspect = "5:4";
- break;
- /* This catches 1.5625 as well (1600x1024) when maybe it shouldn't. */
- case 15:
- aspect = "3:2";
- break;
- case 18:
- aspect = "9:5";
- break;
- case 10:
- aspect = "1:1";
- break;
- }
- }
+ int ratio;
+ const char *aspect = NULL;
- if (aspect != NULL)
- return g_strdup_printf (_("%d x %d (%s)"), width, height, aspect);
+ if (width && height) {
+ if (width > height)
+ ratio = width * 10 / height;
else
- return g_strdup_printf (_("%d x %d"), width, height);
+ ratio = height * 10 / width;
+
+ switch (ratio) {
+ case 13:
+ aspect = "4:3";
+ break;
+ case 16:
+ aspect = "16:10";
+ break;
+ case 17:
+ aspect = "16:9";
+ break;
+ case 12:
+ aspect = "5:4";
+ break;
+ /* This catches 1.5625 as well (1600x1024) when maybe it shouldn't. */
+ case 15:
+ aspect = "3:2";
+ break;
+ case 18:
+ aspect = "9:5";
+ break;
+ case 10:
+ aspect = "1:1";
+ break;
+ }
+ }
+
+ if (aspect != NULL)
+ return g_strdup_printf (_("%d x %d (%s)"), width, height, aspect);
+ else
+ return g_strdup_printf (_("%d x %d"), width, height);
}
static void
find_best_mode (GnomeRRMode **modes, int *out_width, int *out_height)
{
- int i;
+ int i;
- *out_width = 0;
- *out_height = 0;
+ *out_width = 0;
+ *out_height = 0;
- for (i = 0; modes[i] != NULL; i++)
+ for (i = 0; modes[i] != NULL; i++)
{
- int w, h;
+ int w, h;
- w = gnome_rr_mode_get_width (modes[i]);
- h = gnome_rr_mode_get_height (modes[i]);
+ w = gnome_rr_mode_get_width (modes[i]);
+ h = gnome_rr_mode_get_height (modes[i]);
- if (w * h > *out_width * *out_height)
+ if (w * h > *out_width * *out_height)
{
- *out_width = w;
- *out_height = h;
+ *out_width = w;
+ *out_height = h;
}
}
}
@@ -598,301 +598,301 @@ find_best_mode (GnomeRRMode **modes, int *out_width, int *out_height)
static void
rebuild_resolution_combo (App *app)
{
- int i;
- GnomeRRMode **modes;
- const char *current;
+ int i;
+ GnomeRRMode **modes;
+ const char *current;
- clear_combo (app->resolution_combo);
+ clear_combo (app->resolution_combo);
- if (!(modes = get_current_modes (app))
- || !app->current_output
- || !app->current_output->on)
+ if (!(modes = get_current_modes (app))
+ || !app->current_output
+ || !app->current_output->on)
{
- gtk_widget_set_sensitive (app->resolution_combo, FALSE);
- return;
+ gtk_widget_set_sensitive (app->resolution_combo, FALSE);
+ return;
}
- g_assert (app->current_output != NULL);
- g_assert (app->current_output->width != 0 && app->current_output->height != 0);
+ g_assert (app->current_output != NULL);
+ g_assert (app->current_output->width != 0 && app->current_output->height != 0);
- gtk_widget_set_sensitive (app->resolution_combo, TRUE);
+ gtk_widget_set_sensitive (app->resolution_combo, TRUE);
- for (i = 0; modes[i] != NULL; ++i)
+ for (i = 0; modes[i] != NULL; ++i)
{
- int width, height;
+ int width, height;
- width = gnome_rr_mode_get_width (modes[i]);
- height = gnome_rr_mode_get_height (modes[i]);
+ width = gnome_rr_mode_get_width (modes[i]);
+ height = gnome_rr_mode_get_height (modes[i]);
- add_key (app->resolution_combo,
- idle_free (make_resolution_string (width, height)),
- width, height, 0, -1);
+ add_key (app->resolution_combo,
+ idle_free (make_resolution_string (width, height)),
+ width, height, 0, -1);
}
- current = idle_free (make_resolution_string (app->current_output->width, app->current_output->height));
+ current = idle_free (make_resolution_string (app->current_output->width, app->current_output->height));
- if (!combo_select (app->resolution_combo, current))
+ if (!combo_select (app->resolution_combo, current))
{
- int best_w, best_h;
+ int best_w, best_h;
- find_best_mode (modes, &best_w, &best_h);
- combo_select (app->resolution_combo, idle_free (make_resolution_string (best_w, best_h)));
+ find_best_mode (modes, &best_w, &best_h);
+ combo_select (app->resolution_combo, idle_free (make_resolution_string (best_w, best_h)));
}
}
static void
rebuild_gui (App *app)
{
- gboolean sensitive;
+ gboolean sensitive;
- /* We would break spectacularly if we recursed, so
- * just assert if that happens
- */
- g_assert (app->ignore_gui_changes == FALSE);
+ /* We would break spectacularly if we recursed, so
+ * just assert if that happens
+ */
+ g_assert (app->ignore_gui_changes == FALSE);
- app->ignore_gui_changes = TRUE;
+ app->ignore_gui_changes = TRUE;
- sensitive = app->current_output ? TRUE : FALSE;
+ sensitive = app->current_output ? TRUE : FALSE;
#if 0
- g_debug ("rebuild gui, is on: %d", app->current_output->on);
+ g_debug ("rebuild gui, is on: %d", app->current_output->on);
#endif
- rebuild_mirror_screens (app);
- rebuild_current_monitor_label (app);
- rebuild_on_off_radios (app);
- rebuild_resolution_combo (app);
- rebuild_rotation_combo (app);
+ rebuild_mirror_screens (app);
+ rebuild_current_monitor_label (app);
+ rebuild_on_off_radios (app);
+ rebuild_resolution_combo (app);
+ rebuild_rotation_combo (app);
#if 0
- g_debug ("sensitive: %d, on: %d", sensitive, app->current_output->on);
+ g_debug ("sensitive: %d, on: %d", sensitive, app->current_output->on);
#endif
- app->ignore_gui_changes = FALSE;
+ app->ignore_gui_changes = FALSE;
}
static gboolean
get_mode (GtkWidget *widget, int *width, int *height, int *freq, GnomeRRRotation *rot)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkComboBox *box = GTK_COMBO_BOX (widget);
- int dummy;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkComboBox *box = GTK_COMBO_BOX (widget);
+ int dummy;
- if (!gtk_combo_box_get_active_iter (box, &iter))
- return FALSE;
+ if (!gtk_combo_box_get_active_iter (box, &iter))
+ return FALSE;
- if (!width)
- width = &dummy;
+ if (!width)
+ width = &dummy;
- if (!height)
- height = &dummy;
+ if (!height)
+ height = &dummy;
- if (!freq)
- freq = &dummy;
+ if (!freq)
+ freq = &dummy;
- if (!rot)
- rot = (GnomeRRRotation *)&dummy;
+ if (!rot)
+ rot = (GnomeRRRotation *)&dummy;
- model = gtk_combo_box_get_model (box);
- gtk_tree_model_get (model, &iter,
- 1, width,
- 2, height,
- 3, freq,
- 5, rot,
- -1);
+ model = gtk_combo_box_get_model (box);
+ gtk_tree_model_get (model, &iter,
+ 1, width,
+ 2, height,
+ 3, freq,
+ 5, rot,
+ -1);
- return TRUE;
+ return TRUE;
}
static void
on_rotation_changed (GtkComboBox *box, gpointer data)
{
- App *app = data;
- GnomeRRRotation rotation;
+ App *app = data;
+ GnomeRRRotation rotation;
- if (!app->current_output)
- return;
+ if (!app->current_output)
+ return;
- if (get_mode (app->rotation_combo, NULL, NULL, NULL, &rotation))
- app->current_output->rotation = rotation;
+ if (get_mode (app->rotation_combo, NULL, NULL, NULL, &rotation))
+ app->current_output->rotation = rotation;
- foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
+ foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
}
static void
select_resolution_for_current_output (App *app)
{
- GnomeRRMode **modes;
- int width, height;
+ GnomeRRMode **modes;
+ int width, height;
- if (app->current_output->pref_width != 0 && app->current_output->pref_height != 0)
+ if (app->current_output->pref_width != 0 && app->current_output->pref_height != 0)
{
- app->current_output->width = app->current_output->pref_width;
- app->current_output->height = app->current_output->pref_height;
- return;
+ app->current_output->width = app->current_output->pref_width;
+ app->current_output->height = app->current_output->pref_height;
+ return;
}
- modes = get_current_modes (app);
- if (!modes)
- return;
+ modes = get_current_modes (app);
+ if (!modes)
+ return;
- find_best_mode (modes, &width, &height);
+ find_best_mode (modes, &width, &height);
- app->current_output->width = width;
- app->current_output->height = height;
+ app->current_output->width = width;
+ app->current_output->height = height;
}
static void
monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data)
{
- App *app = data;
- gboolean is_on;
+ App *app = data;
+ gboolean is_on;
- if (!app->current_output)
- return;
+ if (!app->current_output)
+ return;
- if (!gtk_toggle_button_get_active (toggle))
- return;
+ if (!gtk_toggle_button_get_active (toggle))
+ return;
- if (GTK_WIDGET (toggle) == app->monitor_on_radio)
- is_on = TRUE;
- else if (GTK_WIDGET (toggle) == app->monitor_off_radio)
- is_on = FALSE;
- else
+ if (GTK_WIDGET (toggle) == app->monitor_on_radio)
+ is_on = TRUE;
+ else if (GTK_WIDGET (toggle) == app->monitor_off_radio)
+ is_on = FALSE;
+ else
{
- g_assert_not_reached ();
- return;
+ g_assert_not_reached ();
+ return;
}
- app->current_output->on = is_on;
+ app->current_output->on = is_on;
- if (is_on)
- select_resolution_for_current_output (app);
+ if (is_on)
+ select_resolution_for_current_output (app);
- rebuild_gui (app);
- foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
+ rebuild_gui (app);
+ foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
}
static void
realign_outputs_after_resolution_change (App *app, GnomeOutputInfo *output_that_changed, int old_width, int old_height)
{
- /* We find the outputs that were below or to the right of the output that
- * changed, and realign them; we also do that for outputs that shared the
- * right/bottom edges with the output that changed. The outputs that are
- * above or to the left of that output don't need to change.
- */
+ /* We find the outputs that were below or to the right of the output that
+ * changed, and realign them; we also do that for outputs that shared the
+ * right/bottom edges with the output that changed. The outputs that are
+ * above or to the left of that output don't need to change.
+ */
- int i;
- int old_right_edge, old_bottom_edge;
- int dx, dy;
+ int i;
+ int old_right_edge, old_bottom_edge;
+ int dx, dy;
- g_assert (app->current_configuration != NULL);
+ g_assert (app->current_configuration != NULL);
- if (output_that_changed->width == old_width && output_that_changed->height == old_height)
- return;
+ if (output_that_changed->width == old_width && output_that_changed->height == old_height)
+ return;
- old_right_edge = output_that_changed->x + old_width;
- old_bottom_edge = output_that_changed->y + old_height;
+ old_right_edge = output_that_changed->x + old_width;
+ old_bottom_edge = output_that_changed->y + old_height;
- dx = output_that_changed->width - old_width;
- dy = output_that_changed->height - old_height;
+ dx = output_that_changed->width - old_width;
+ dy = output_that_changed->height - old_height;
- for (i = 0; app->current_configuration->outputs[i] != NULL; i++) {
- GnomeOutputInfo *output;
- int output_width, output_height;
+ for (i = 0; app->current_configuration->outputs[i] != NULL; i++) {
+ GnomeOutputInfo *output;
+ int output_width, output_height;
- output = app->current_configuration->outputs[i];
+ output = app->current_configuration->outputs[i];
- if (output == output_that_changed || !output->connected)
- continue;
+ if (output == output_that_changed || !output->connected)
+ continue;
- get_geometry (output, &output_width, &output_height);
+ get_geometry (output, &output_width, &output_height);
- if (output->x >= old_right_edge)
- output->x += dx;
- else if (output->x + output_width == old_right_edge)
- output->x = output_that_changed->x + output_that_changed->width - output_width;
+ if (output->x >= old_right_edge)
+ output->x += dx;
+ else if (output->x + output_width == old_right_edge)
+ output->x = output_that_changed->x + output_that_changed->width - output_width;
- if (output->y >= old_bottom_edge)
- output->y += dy;
- else if (output->y + output_height == old_bottom_edge)
- output->y = output_that_changed->y + output_that_changed->height - output_height;
- }
+ if (output->y >= old_bottom_edge)
+ output->y += dy;
+ else if (output->y + output_height == old_bottom_edge)
+ output->y = output_that_changed->y + output_that_changed->height - output_height;
+ }
}
static void
on_resolution_changed (GtkComboBox *box, gpointer data)
{
- App *app = data;
- int old_width, old_height;
- int width;
- int height;
+ App *app = data;
+ int old_width, old_height;
+ int width;
+ int height;
- if (!app->current_output)
- return;
+ if (!app->current_output)
+ return;
- old_width = app->current_output->width;
- old_height = app->current_output->height;
+ old_width = app->current_output->width;
+ old_height = app->current_output->height;
- if (get_mode (app->resolution_combo, &width, &height, NULL, NULL))
+ if (get_mode (app->resolution_combo, &width, &height, NULL, NULL))
{
- app->current_output->width = width;
- app->current_output->height = height;
+ app->current_output->width = width;
+ app->current_output->height = height;
- if (width == 0 || height == 0)
- app->current_output->on = FALSE;
- else
- app->current_output->on = TRUE;
+ if (width == 0 || height == 0)
+ app->current_output->on = FALSE;
+ else
+ app->current_output->on = TRUE;
}
- realign_outputs_after_resolution_change (app, app->current_output, old_width, old_height);
+ realign_outputs_after_resolution_change (app, app->current_output, old_width, old_height);
- rebuild_rotation_combo (app);
+ rebuild_rotation_combo (app);
- foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
+ foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
}
static void
lay_out_outputs_horizontally (App *app)
{
- int i;
- int x;
+ int i;
+ int x;
- /* Lay out all the monitors horizontally when "mirror screens" is turned
- * off, to avoid having all of them overlapped initially. We put the
- * outputs turned off on the right-hand side.
- */
+ /* Lay out all the monitors horizontally when "mirror screens" is turned
+ * off, to avoid having all of them overlapped initially. We put the
+ * outputs turned off on the right-hand side.
+ */
- x = 0;
+ x = 0;
- /* First pass, all "on" outputs */
+ /* First pass, all "on" outputs */
- for (i = 0; app->current_configuration->outputs[i]; ++i)
+ for (i = 0; app->current_configuration->outputs[i]; ++i)
{
- GnomeOutputInfo *output;
-
- output = app->current_configuration->outputs[i];
- if (output->connected && output->on) {
- output->x = x;
- output->y = 0;
- x += output->width;
- }
+ GnomeOutputInfo *output;
+
+ output = app->current_configuration->outputs[i];
+ if (output->connected && output->on) {
+ output->x = x;
+ output->y = 0;
+ x += output->width;
+ }
}
- /* Second pass, all the black screens */
+ /* Second pass, all the black screens */
- for (i = 0; app->current_configuration->outputs[i]; ++i)
+ for (i = 0; app->current_configuration->outputs[i]; ++i)
{
- GnomeOutputInfo *output;
-
- output = app->current_configuration->outputs[i];
- if (!(output->connected && output->on)) {
- output->x = x;
- output->y = 0;
- x += output->width;
- }
+ GnomeOutputInfo *output;
+
+ output = app->current_configuration->outputs[i];
+ if (!(output->connected && output->on)) {
+ output->x = x;
+ output->y = 0;
+ x += output->width;
+ }
}
}
@@ -903,129 +903,129 @@ lay_out_outputs_horizontally (App *app)
static gboolean
get_clone_size (GnomeRRScreen *screen, int *width, int *height)
{
- GnomeRRMode **modes = gnome_rr_screen_list_clone_modes (screen);
- int best_w, best_h;
- int i;
+ GnomeRRMode **modes = gnome_rr_screen_list_clone_modes (screen);
+ int best_w, best_h;
+ int i;
- best_w = 0;
- best_h = 0;
+ best_w = 0;
+ best_h = 0;
- for (i = 0; modes[i] != NULL; ++i) {
- GnomeRRMode *mode = modes[i];
- int w, h;
+ for (i = 0; modes[i] != NULL; ++i) {
+ GnomeRRMode *mode = modes[i];
+ int w, h;
- w = gnome_rr_mode_get_width (mode);
- h = gnome_rr_mode_get_height (mode);
+ w = gnome_rr_mode_get_width (mode);
+ h = gnome_rr_mode_get_height (mode);
- if (w * h > best_w * best_h) {
- best_w = w;
- best_h = h;
- }
- }
+ if (w * h > best_w * best_h) {
+ best_w = w;
+ best_h = h;
+ }
+ }
- if (best_w > 0 && best_h > 0) {
- if (width)
- *width = best_w;
- if (height)
- *height = best_h;
+ if (best_w > 0 && best_h > 0) {
+ if (width)
+ *width = best_w;
+ if (height)
+ *height = best_h;
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
output_info_supports_mode (App *app, GnomeOutputInfo *info, int width, int height)
{
- GnomeRROutput *output;
- GnomeRRMode **modes;
- int i;
+ GnomeRROutput *output;
+ GnomeRRMode **modes;
+ int i;
- if (!info->connected)
- return FALSE;
+ if (!info->connected)
+ return FALSE;
- output = gnome_rr_screen_get_output_by_name (app->screen, info->name);
- if (!output)
- return FALSE;
+ output = gnome_rr_screen_get_output_by_name (app->screen, info->name);
+ if (!output)
+ return FALSE;
- modes = gnome_rr_output_list_modes (output);
+ modes = gnome_rr_output_list_modes (output);
- for (i = 0; modes[i]; i++) {
- if (gnome_rr_mode_get_width (modes[i]) == width
- && gnome_rr_mode_get_height (modes[i]) == height)
- return TRUE;
- }
+ for (i = 0; modes[i]; i++) {
+ if (gnome_rr_mode_get_width (modes[i]) == width
+ && gnome_rr_mode_get_height (modes[i]) == height)
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
on_clone_changed (GtkWidget *box, gpointer data)
{
- App *app = data;
+ App *app = data;
- app->current_configuration->clone =
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->clone_checkbox));
+ app->current_configuration->clone =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->clone_checkbox));
- if (app->current_configuration->clone)
+ if (app->current_configuration->clone)
{
- int i;
- int width, height;
+ int i;
+ int width, height;
- for (i = 0; app->current_configuration->outputs[i]; ++i)
+ for (i = 0; app->current_configuration->outputs[i]; ++i)
{
- if (app->current_configuration->outputs[i]->connected)
+ if (app->current_configuration->outputs[i]->connected)
{
- app->current_output = app->current_configuration->outputs[i];
- break;
+ app->current_output = app->current_configuration->outputs[i];
+ break;
}
}
- /* Turn on all the connected screens that support the best clone mode.
- * The user may hit "Mirror Screens", but he shouldn't have to turn on
- * all the required outputs as well.
- */
+ /* Turn on all the connected screens that support the best clone mode.
+ * The user may hit "Mirror Screens", but he shouldn't have to turn on
+ * all the required outputs as well.
+ */
- get_clone_size (app->screen, &width, &height);
+ get_clone_size (app->screen, &width, &height);
- for (i = 0; app->current_configuration->outputs[i]; i++) {
- if (output_info_supports_mode (app, app->current_configuration->outputs[i], width, height)) {
- app->current_configuration->outputs[i]->on = TRUE;
- app->current_configuration->outputs[i]->width = width;
- app->current_configuration->outputs[i]->height = height;
- }
+ for (i = 0; app->current_configuration->outputs[i]; i++) {
+ if (output_info_supports_mode (app, app->current_configuration->outputs[i], width, height)) {
+ app->current_configuration->outputs[i]->on = TRUE;
+ app->current_configuration->outputs[i]->width = width;
+ app->current_configuration->outputs[i]->height = height;
}
+ }
}
- else
+ else
{
- if (output_overlaps (app->current_output, app->current_configuration))
- lay_out_outputs_horizontally (app);
+ if (output_overlaps (app->current_output, app->current_configuration))
+ lay_out_outputs_horizontally (app);
}
- rebuild_gui (app);
+ rebuild_gui (app);
}
static void
get_geometry (GnomeOutputInfo *output, int *w, int *h)
{
- if (output->on)
+ if (output->on)
{
- *h = output->height;
- *w = output->width;
+ *h = output->height;
+ *w = output->width;
}
- else
+ else
{
- *h = output->pref_height;
- *w = output->pref_width;
+ *h = output->pref_height;
+ *w = output->pref_width;
+ }
+ if ((output->rotation & GNOME_RR_ROTATION_90) || (output->rotation & GNOME_RR_ROTATION_270))
+ {
+ int tmp;
+ tmp = *h;
+ *h = *w;
+ *w = tmp;
}
- if ((output->rotation & GNOME_RR_ROTATION_90) || (output->rotation & GNOME_RR_ROTATION_270))
- {
- int tmp;
- tmp = *h;
- *h = *w;
- *w = tmp;
- }
}
#define SPACE 15
@@ -1034,227 +1034,227 @@ get_geometry (GnomeOutputInfo *output, int *w, int *h)
static GList *
list_connected_outputs (App *app, int *total_w, int *total_h)
{
- int i, dummy;
- GList *result = NULL;
+ int i, dummy;
+ GList *result = NULL;
- if (!total_w)
- total_w = &dummy;
- if (!total_h)
- total_h = &dummy;
+ if (!total_w)
+ total_w = &dummy;
+ if (!total_h)
+ total_h = &dummy;
- *total_w = 0;
- *total_h = 0;
- for (i = 0; app->current_configuration->outputs[i] != NULL; ++i)
+ *total_w = 0;
+ *total_h = 0;
+ for (i = 0; app->current_configuration->outputs[i] != NULL; ++i)
{
- GnomeOutputInfo *output = app->current_configuration->outputs[i];
+ GnomeOutputInfo *output = app->current_configuration->outputs[i];
- if (output->connected)
+ if (output->connected)
{
- int w, h;
+ int w, h;
- result = g_list_prepend (result, output);
+ result = g_list_prepend (result, output);
- get_geometry (output, &w, &h);
+ get_geometry (output, &w, &h);
- *total_w += w;
- *total_h += h;
+ *total_w += w;
+ *total_h += h;
}
}
- return g_list_reverse (result);
+ return g_list_reverse (result);
}
static int
get_n_connected (App *app)
{
- GList *connected_outputs = list_connected_outputs (app, NULL, NULL);
- int n = g_list_length (connected_outputs);
+ GList *connected_outputs = list_connected_outputs (app, NULL, NULL);
+ int n = g_list_length (connected_outputs);
- g_list_free (connected_outputs);
+ g_list_free (connected_outputs);
- return n;
+ return n;
}
static double
compute_scale (App *app)
{
- int available_w, available_h;
- int total_w, total_h;
- int n_monitors;
- GdkRectangle viewport;
- GList *connected_outputs;
+ int available_w, available_h;
+ int total_w, total_h;
+ int n_monitors;
+ GdkRectangle viewport;
+ GList *connected_outputs;
- foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area), &viewport);
+ foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area), &viewport);
- connected_outputs = list_connected_outputs (app, &total_w, &total_h);
+ connected_outputs = list_connected_outputs (app, &total_w, &total_h);
- n_monitors = g_list_length (connected_outputs);
+ n_monitors = g_list_length (connected_outputs);
- g_list_free (connected_outputs);
+ g_list_free (connected_outputs);
- available_w = viewport.width - 2 * MARGIN - (n_monitors - 1) * SPACE;
- available_h = viewport.height - 2 * MARGIN - (n_monitors - 1) * SPACE;
+ available_w = viewport.width - 2 * MARGIN - (n_monitors - 1) * SPACE;
+ available_h = viewport.height - 2 * MARGIN - (n_monitors - 1) * SPACE;
- return MIN ((double)available_w / total_w, (double)available_h / total_h);
+ return MIN ((double)available_w / total_w, (double)available_h / total_h);
}
typedef struct Edge
{
- GnomeOutputInfo *output;
- int x1, y1;
- int x2, y2;
+ GnomeOutputInfo *output;
+ int x1, y1;
+ int x2, y2;
} Edge;
typedef struct Snap
{
- Edge *snapper; /* Edge that should be snapped */
- Edge *snappee;
- int dy, dx;
+ Edge *snapper; /* Edge that should be snapped */
+ Edge *snappee;
+ int dy, dx;
} Snap;
static void
add_edge (GnomeOutputInfo *output, int x1, int y1, int x2, int y2, GArray *edges)
{
- Edge e;
+ Edge e;
- e.x1 = x1;
- e.x2 = x2;
- e.y1 = y1;
- e.y2 = y2;
- e.output = output;
+ e.x1 = x1;
+ e.x2 = x2;
+ e.y1 = y1;
+ e.y2 = y2;
+ e.output = output;
- g_array_append_val (edges, e);
+ g_array_append_val (edges, e);
}
static void
list_edges_for_output (GnomeOutputInfo *output, GArray *edges)
{
- int x, y, w, h;
+ int x, y, w, h;
- x = output->x;
- y = output->y;
- get_geometry (output, &w, &h);
+ x = output->x;
+ y = output->y;
+ get_geometry (output, &w, &h);
- /* Top, Bottom, Left, Right */
- add_edge (output, x, y, x + w, y, edges);
- add_edge (output, x, y + h, x + w, y + h, edges);
- add_edge (output, x, y, x, y + h, edges);
- add_edge (output, x + w, y, x + w, y + h, edges);
+ /* Top, Bottom, Left, Right */
+ add_edge (output, x, y, x + w, y, edges);
+ add_edge (output, x, y + h, x + w, y + h, edges);
+ add_edge (output, x, y, x, y + h, edges);
+ add_edge (output, x + w, y, x + w, y + h, edges);
}
static void
list_edges (GnomeRRConfig *config, GArray *edges)
{
- int i;
+ int i;
- for (i = 0; config->outputs[i]; ++i)
+ for (i = 0; config->outputs[i]; ++i)
{
- GnomeOutputInfo *output = config->outputs[i];
+ GnomeOutputInfo *output = config->outputs[i];
- if (output->connected)
- list_edges_for_output (output, edges);
+ if (output->connected)
+ list_edges_for_output (output, edges);
}
}
static gboolean
overlap (int s1, int e1, int s2, int e2)
{
- return (!(e1 < s2 || s1 >= e2));
+ return (!(e1 < s2 || s1 >= e2));
}
static gboolean
horizontal_overlap (Edge *snapper, Edge *snappee)
{
- if (snapper->y1 != snapper->y2 || snappee->y1 != snappee->y2)
- return FALSE;
+ if (snapper->y1 != snapper->y2 || snappee->y1 != snappee->y2)
+ return FALSE;
- return overlap (snapper->x1, snapper->x2, snappee->x1, snappee->x2);
+ return overlap (snapper->x1, snapper->x2, snappee->x1, snappee->x2);
}
static gboolean
vertical_overlap (Edge *snapper, Edge *snappee)
{
- if (snapper->x1 != snapper->x2 || snappee->x1 != snappee->x2)
- return FALSE;
+ if (snapper->x1 != snapper->x2 || snappee->x1 != snappee->x2)
+ return FALSE;
- return overlap (snapper->y1, snapper->y2, snappee->y1, snappee->y2);
+ return overlap (snapper->y1, snapper->y2, snappee->y1, snappee->y2);
}
static void
add_snap (GArray *snaps, Snap snap)
{
- if (ABS (snap.dx) <= 200 || ABS (snap.dy) <= 200)
- g_array_append_val (snaps, snap);
+ if (ABS (snap.dx) <= 200 || ABS (snap.dy) <= 200)
+ g_array_append_val (snaps, snap);
}
static void
add_edge_snaps (Edge *snapper, Edge *snappee, GArray *snaps)
{
- Snap snap;
+ Snap snap;
- snap.snapper = snapper;
- snap.snappee = snappee;
+ snap.snapper = snapper;
+ snap.snappee = snappee;
- if (horizontal_overlap (snapper, snappee))
+ if (horizontal_overlap (snapper, snappee))
{
- snap.dx = 0;
- snap.dy = snappee->y1 - snapper->y1;
+ snap.dx = 0;
+ snap.dy = snappee->y1 - snapper->y1;
- add_snap (snaps, snap);
+ add_snap (snaps, snap);
}
- else if (vertical_overlap (snapper, snappee))
+ else if (vertical_overlap (snapper, snappee))
{
- snap.dy = 0;
- snap.dx = snappee->x1 - snapper->x1;
+ snap.dy = 0;
+ snap.dx = snappee->x1 - snapper->x1;
- add_snap (snaps, snap);
+ add_snap (snaps, snap);
}
- /* Corner snaps */
- /* 1->1 */
- snap.dx = snappee->x1 - snapper->x1;
- snap.dy = snappee->y1 - snapper->y1;
+ /* Corner snaps */
+ /* 1->1 */
+ snap.dx = snappee->x1 - snapper->x1;
+ snap.dy = snappee->y1 - snapper->y1;
- add_snap (snaps, snap);
+ add_snap (snaps, snap);
- /* 1->2 */
- snap.dx = snappee->x2 - snapper->x1;
- snap.dy = snappee->y2 - snapper->y1;
+ /* 1->2 */
+ snap.dx = snappee->x2 - snapper->x1;
+ snap.dy = snappee->y2 - snapper->y1;
- add_snap (snaps, snap);
+ add_snap (snaps, snap);
- /* 2->2 */
- snap.dx = snappee->x2 - snapper->x2;
- snap.dy = snappee->y2 - snapper->y2;
+ /* 2->2 */
+ snap.dx = snappee->x2 - snapper->x2;
+ snap.dy = snappee->y2 - snapper->y2;
- add_snap (snaps, snap);
+ add_snap (snaps, snap);
- /* 2->1 */
- snap.dx = snappee->x1 - snapper->x2;
- snap.dy = snappee->y1 - snapper->y2;
+ /* 2->1 */
+ snap.dx = snappee->x1 - snapper->x2;
+ snap.dy = snappee->y1 - snapper->y2;
- add_snap (snaps, snap);
+ add_snap (snaps, snap);
}
static void
list_snaps (GnomeOutputInfo *output, GArray *edges, GArray *snaps)
{
- int i;
+ int i;
- for (i = 0; i < edges->len; ++i)
+ for (i = 0; i < edges->len; ++i)
{
- Edge *output_edge = &(g_array_index (edges, Edge, i));
+ Edge *output_edge = &(g_array_index (edges, Edge, i));
- if (output_edge->output == output)
+ if (output_edge->output == output)
{
- int j;
+ int j;
- for (j = 0; j < edges->len; ++j)
+ for (j = 0; j < edges->len; ++j)
{
- Edge *edge = &(g_array_index (edges, Edge, j));
+ Edge *edge = &(g_array_index (edges, Edge, j));
- if (edge->output != output)
- add_edge_snaps (output_edge, edge, snaps);
+ if (edge->output != output)
+ add_edge_snaps (output_edge, edge, snaps);
}
}
}
@@ -1264,182 +1264,182 @@ list_snaps (GnomeOutputInfo *output, GArray *edges, GArray *snaps)
static void
print_edge (Edge *edge)
{
- g_debug ("(%d %d %d %d)", edge->x1, edge->y1, edge->x2, edge->y2);
+ g_debug ("(%d %d %d %d)", edge->x1, edge->y1, edge->x2, edge->y2);
}
#endif
static gboolean
corner_on_edge (int x, int y, Edge *e)
{
- if (x == e->x1 && x == e->x2 && y >= e->y1 && y <= e->y2)
- return TRUE;
+ if (x == e->x1 && x == e->x2 && y >= e->y1 && y <= e->y2)
+ return TRUE;
- if (y == e->y1 && y == e->y2 && x >= e->x1 && x <= e->x2)
- return TRUE;
+ if (y == e->y1 && y == e->y2 && x >= e->x1 && x <= e->x2)
+ return TRUE;
- return FALSE;
+ return FALSE;
}
static gboolean
edges_align (Edge *e1, Edge *e2)
{
- if (corner_on_edge (e1->x1, e1->y1, e2))
- return TRUE;
+ if (corner_on_edge (e1->x1, e1->y1, e2))
+ return TRUE;
- if (corner_on_edge (e2->x1, e2->y1, e1))
- return TRUE;
+ if (corner_on_edge (e2->x1, e2->y1, e1))
+ return TRUE;
- return FALSE;
+ return FALSE;
}
static gboolean
output_is_aligned (GnomeOutputInfo *output, GArray *edges)
{
- gboolean result = FALSE;
- int i;
+ gboolean result = FALSE;
+ int i;
- for (i = 0; i < edges->len; ++i)
+ for (i = 0; i < edges->len; ++i)
{
- Edge *output_edge = &(g_array_index (edges, Edge, i));
+ Edge *output_edge = &(g_array_index (edges, Edge, i));
- if (output_edge->output == output)
+ if (output_edge->output == output)
{
- int j;
+ int j;
- for (j = 0; j < edges->len; ++j)
+ for (j = 0; j < edges->len; ++j)
{
- Edge *edge = &(g_array_index (edges, Edge, j));
+ Edge *edge = &(g_array_index (edges, Edge, j));
- /* We are aligned if an output edge matches
- * an edge of another output
- */
- if (edge->output != output_edge->output)
+ /* We are aligned if an output edge matches
+ * an edge of another output
+ */
+ if (edge->output != output_edge->output)
{
- if (edges_align (output_edge, edge))
+ if (edges_align (output_edge, edge))
{
- result = TRUE;
- goto done;
+ result = TRUE;
+ goto done;
}
}
}
}
}
-done:
+ done:
- return result;
+ return result;
}
static void
get_output_rect (GnomeOutputInfo *output, GdkRectangle *rect)
{
- int w, h;
+ int w, h;
- get_geometry (output, &w, &h);
+ get_geometry (output, &w, &h);
- rect->width = w;
- rect->height = h;
- rect->x = output->x;
- rect->y = output->y;
+ rect->width = w;
+ rect->height = h;
+ rect->x = output->x;
+ rect->y = output->y;
}
static gboolean
output_overlaps (GnomeOutputInfo *output, GnomeRRConfig *config)
{
- int i;
- GdkRectangle output_rect;
+ int i;
+ GdkRectangle output_rect;
- g_assert (output != NULL);
+ g_assert (output != NULL);
- get_output_rect (output, &output_rect);
+ get_output_rect (output, &output_rect);
- for (i = 0; config->outputs[i]; ++i)
+ for (i = 0; config->outputs[i]; ++i)
{
- GnomeOutputInfo *other = config->outputs[i];
+ GnomeOutputInfo *other = config->outputs[i];
- if (other != output && other->connected)
+ if (other != output && other->connected)
{
- GdkRectangle other_rect;
+ GdkRectangle other_rect;
- get_output_rect (other, &other_rect);
- if (gdk_rectangle_intersect (&output_rect, &other_rect, NULL))
- return TRUE;
+ get_output_rect (other, &other_rect);
+ if (gdk_rectangle_intersect (&output_rect, &other_rect, NULL))
+ return TRUE;
}
}
- return FALSE;
+ return FALSE;
}
static gboolean
gnome_rr_config_is_aligned (GnomeRRConfig *config, GArray *edges)
{
- int i;
- gboolean result = TRUE;
+ int i;
+ gboolean result = TRUE;
- for (i = 0; config->outputs[i]; ++i)
+ for (i = 0; config->outputs[i]; ++i)
{
- GnomeOutputInfo *output = config->outputs[i];
+ GnomeOutputInfo *output = config->outputs[i];
- if (output->connected)
+ if (output->connected)
{
- if (!output_is_aligned (output, edges))
- return FALSE;
+ if (!output_is_aligned (output, edges))
+ return FALSE;
- if (output_overlaps (output, config))
- return FALSE;
+ if (output_overlaps (output, config))
+ return FALSE;
}
}
- return result;
+ return result;
}
struct GrabInfo
{
- int grab_x;
- int grab_y;
- int output_x;
- int output_y;
+ int grab_x;
+ int grab_y;
+ int output_x;
+ int output_y;
};
static gboolean
is_corner_snap (const Snap *s)
{
- return s->dx != 0 && s->dy != 0;
+ return s->dx != 0 && s->dy != 0;
}
static int
compare_snaps (gconstpointer v1, gconstpointer v2)
{
- const Snap *s1 = v1;
- const Snap *s2 = v2;
- int sv1 = MAX (ABS (s1->dx), ABS (s1->dy));
- int sv2 = MAX (ABS (s2->dx), ABS (s2->dy));
- int d;
-
- d = sv1 - sv2;
-
- /* This snapping algorithm is good enough for rock'n'roll, but
- * this is probably a better:
- *
- * First do a horizontal/vertical snap, then
- * with the new coordinates from that snap,
- * do a corner snap.
- *
- * Right now, it's confusing that corner snapping
- * depends on the distance in an axis that you can't actually see.
- *
- */
- if (d == 0)
+ const Snap *s1 = v1;
+ const Snap *s2 = v2;
+ int sv1 = MAX (ABS (s1->dx), ABS (s1->dy));
+ int sv2 = MAX (ABS (s2->dx), ABS (s2->dy));
+ int d;
+
+ d = sv1 - sv2;
+
+ /* This snapping algorithm is good enough for rock'n'roll, but
+ * this is probably a better:
+ *
+ * First do a horizontal/vertical snap, then
+ * with the new coordinates from that snap,
+ * do a corner snap.
+ *
+ * Right now, it's confusing that corner snapping
+ * depends on the distance in an axis that you can't actually see.
+ *
+ */
+ if (d == 0)
{
- if (is_corner_snap (s1) && !is_corner_snap (s2))
- return -1;
- else if (is_corner_snap (s2) && !is_corner_snap (s1))
- return 1;
- else
- return 0;
+ if (is_corner_snap (s1) && !is_corner_snap (s2))
+ return -1;
+ else if (is_corner_snap (s2) && !is_corner_snap (s1))
+ return 1;
+ else
+ return 0;
}
- else
+ else
{
- return d;
+ return d;
}
}
@@ -1450,34 +1450,34 @@ compare_snaps (gconstpointer v1, gconstpointer v2)
static void
set_cursor (GtkWidget *widget, GdkCursorType type)
{
- GdkCursor *cursor;
- GdkWindow *window;
+ GdkCursor *cursor;
+ GdkWindow *window;
- if (type == GDK_BLANK_CURSOR)
- cursor = NULL;
- else
- cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), type);
+ if (type == GDK_BLANK_CURSOR)
+ cursor = NULL;
+ else
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), type);
- window = gtk_widget_get_window (widget);
+ window = gtk_widget_get_window (widget);
- if (window)
- gdk_window_set_cursor (window, cursor);
+ if (window)
+ gdk_window_set_cursor (window, cursor);
- if (cursor)
- gdk_cursor_unref (cursor);
+ if (cursor)
+ gdk_cursor_unref (cursor);
}
static void
set_monitors_tooltip (App *app, gboolean is_dragging)
{
- const char *text;
+ const char *text;
- if (is_dragging)
- text = NULL;
- else
- text = _("Select a monitor to change its properties; drag it to rearrange its placement.");
+ if (is_dragging)
+ text = NULL;
+ else
+ text = _("Select a monitor to change its properties; drag it to rearrange its placement.");
- gtk_widget_set_tooltip_text (app->area, text);
+ gtk_widget_set_tooltip_text (app->area, text);
}
static void
@@ -1485,112 +1485,112 @@ on_output_event (FooScrollArea *area,
FooScrollAreaEvent *event,
gpointer data)
{
- GnomeOutputInfo *output = data;
- App *app = g_object_get_data (G_OBJECT (area), "app");
+ GnomeOutputInfo *output = data;
+ App *app = g_object_get_data (G_OBJECT (area), "app");
- /* If the mouse is inside the outputs, set the cursor to "you can move me". See
- * on_canvas_event() for where we reset the cursor to the default if it
- * exits the outputs' area.
- */
- if (!app->current_configuration->clone && get_n_connected (app) > 1)
- set_cursor (GTK_WIDGET (area), GDK_FLEUR);
+ /* If the mouse is inside the outputs, set the cursor to "you can move me". See
+ * on_canvas_event() for where we reset the cursor to the default if it
+ * exits the outputs' area.
+ */
+ if (!app->current_configuration->clone && get_n_connected (app) > 1)
+ set_cursor (GTK_WIDGET (area), GDK_FLEUR);
- if (event->type == FOO_BUTTON_PRESS)
+ if (event->type == FOO_BUTTON_PRESS)
{
- GrabInfo *info;
+ GrabInfo *info;
- app->current_output = output;
+ app->current_output = output;
- rebuild_gui (app);
- set_monitors_tooltip (app, TRUE);
+ rebuild_gui (app);
+ set_monitors_tooltip (app, TRUE);
- if (!app->current_configuration->clone && get_n_connected (app) > 1)
+ if (!app->current_configuration->clone && get_n_connected (app) > 1)
{
- foo_scroll_area_begin_grab (area, on_output_event, data);
+ foo_scroll_area_begin_grab (area, on_output_event, data);
- info = g_new0 (GrabInfo, 1);
- info->grab_x = event->x;
- info->grab_y = event->y;
- info->output_x = output->x;
- info->output_y = output->y;
+ info = g_new0 (GrabInfo, 1);
+ info->grab_x = event->x;
+ info->grab_y = event->y;
+ info->output_x = output->x;
+ info->output_y = output->y;
- output->user_data = info;
+ output->user_data = info;
}
- foo_scroll_area_invalidate (area);
+ foo_scroll_area_invalidate (area);
}
- else
+ else
{
- if (foo_scroll_area_is_grabbed (area))
+ if (foo_scroll_area_is_grabbed (area))
{
- GrabInfo *info = output->user_data;
- double scale = compute_scale (app);
- int old_x, old_y;
- int new_x, new_y;
- int i;
- GArray *edges, *snaps, *new_edges;
+ GrabInfo *info = output->user_data;
+ double scale = compute_scale (app);
+ int old_x, old_y;
+ int new_x, new_y;
+ int i;
+ GArray *edges, *snaps, *new_edges;
- old_x = output->x;
- old_y = output->y;
- new_x = info->output_x + (event->x - info->grab_x) / scale;
- new_y = info->output_y + (event->y - info->grab_y) / scale;
+ old_x = output->x;
+ old_y = output->y;
+ new_x = info->output_x + (event->x - info->grab_x) / scale;
+ new_y = info->output_y + (event->y - info->grab_y) / scale;
- output->x = new_x;
- output->y = new_y;
+ output->x = new_x;
+ output->y = new_y;
- edges = g_array_new (TRUE, TRUE, sizeof (Edge));
- snaps = g_array_new (TRUE, TRUE, sizeof (Snap));
- new_edges = g_array_new (TRUE, TRUE, sizeof (Edge));
+ edges = g_array_new (TRUE, TRUE, sizeof (Edge));
+ snaps = g_array_new (TRUE, TRUE, sizeof (Snap));
+ new_edges = g_array_new (TRUE, TRUE, sizeof (Edge));
- list_edges (app->current_configuration, edges);
- list_snaps (output, edges, snaps);
+ list_edges (app->current_configuration, edges);
+ list_snaps (output, edges, snaps);
- g_array_sort (snaps, compare_snaps);
+ g_array_sort (snaps, compare_snaps);
- output->x = info->output_x;
- output->y = info->output_y;
+ output->x = info->output_x;
+ output->y = info->output_y;
- for (i = 0; i < snaps->len; ++i)
+ for (i = 0; i < snaps->len; ++i)
{
- Snap *snap = &(g_array_index (snaps, Snap, i));
- GArray *new_edges = g_array_new (TRUE, TRUE, sizeof (Edge));
+ Snap *snap = &(g_array_index (snaps, Snap, i));
+ GArray *new_edges = g_array_new (TRUE, TRUE, sizeof (Edge));
- output->x = new_x + snap->dx;
- output->y = new_y + snap->dy;
+ output->x = new_x + snap->dx;
+ output->y = new_y + snap->dy;
- g_array_set_size (new_edges, 0);
- list_edges (app->current_configuration, new_edges);
+ g_array_set_size (new_edges, 0);
+ list_edges (app->current_configuration, new_edges);
- if (gnome_rr_config_is_aligned (app->current_configuration, new_edges))
+ if (gnome_rr_config_is_aligned (app->current_configuration, new_edges))
{
- g_array_free (new_edges, TRUE);
- break;
+ g_array_free (new_edges, TRUE);
+ break;
}
- else
+ else
{
- output->x = info->output_x;
- output->y = info->output_y;
+ output->x = info->output_x;
+ output->y = info->output_y;
}
}
- g_array_free (new_edges, TRUE);
- g_array_free (snaps, TRUE);
- g_array_free (edges, TRUE);
+ g_array_free (new_edges, TRUE);
+ g_array_free (snaps, TRUE);
+ g_array_free (edges, TRUE);
- if (event->type == FOO_BUTTON_RELEASE)
+ if (event->type == FOO_BUTTON_RELEASE)
{
- foo_scroll_area_end_grab (area);
- set_monitors_tooltip (app, FALSE);
+ foo_scroll_area_end_grab (area);
+ set_monitors_tooltip (app, FALSE);
- g_free (output->user_data);
- output->user_data = NULL;
+ g_free (output->user_data);
+ output->user_data = NULL;
#if 0
- g_debug ("new position: %d %d %d %d", output->x, output->y, output->width, output->height);
+ g_debug ("new position: %d %d %d %d", output->x, output->y, output->width, output->height);
#endif
}
- foo_scroll_area_invalidate (area);
+ foo_scroll_area_invalidate (area);
}
}
}
@@ -1600,204 +1600,204 @@ on_canvas_event (FooScrollArea *area,
FooScrollAreaEvent *event,
gpointer data)
{
- /* If the mouse exits the outputs, reset the cursor to the default. See
- * on_output_event() for where we set the cursor to the movement cursor if
- * it is over one of the outputs.
- */
- set_cursor (GTK_WIDGET (area), GDK_BLANK_CURSOR);
+ /* If the mouse exits the outputs, reset the cursor to the default. See
+ * on_output_event() for where we set the cursor to the movement cursor if
+ * it is over one of the outputs.
+ */
+ set_cursor (GTK_WIDGET (area), GDK_BLANK_CURSOR);
}
static PangoLayout *
get_display_name (App *app,
GnomeOutputInfo *output)
{
- PangoLayout *layout;
- char *text;
+ PangoLayout *layout;
+ char *text;
- if (app->current_configuration->clone) {
- /* Translators: this is the feature where what you see on your laptop's
- * screen is the same as your external monitor. Here, "Mirror" is being
- * used as an adjective, not as a verb. For example, the Spanish
- * translation could be "Pantallas en Espejo", *not* "Espejar Pantallas".
- */
- text = g_strdup(_("Mirror Screens"));
- } else {
- text = g_strdup (output->display_name);
- }
+ if (app->current_configuration->clone) {
+ /* Translators: this is the feature where what you see on your laptop's
+ * screen is the same as your external monitor. Here, "Mirror" is being
+ * used as an adjective, not as a verb. For example, the Spanish
+ * translation could be "Pantallas en Espejo", *not* "Espejar Pantallas".
+ */
+ text = g_strdup(_("Mirror Screens"));
+ } else {
+ text = g_strdup (output->display_name);
+ }
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (app->area), text);
- g_free (text);
- pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (app->area), text);
+ g_free (text);
+ pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
- return layout;
+ return layout;
}
static void
paint_background (FooScrollArea *area,
cairo_t *cr)
{
- GdkRectangle viewport;
- GtkWidget *widget;
- GtkStyle *widget_style;
+ GdkRectangle viewport;
+ GtkWidget *widget;
+ GtkStyle *widget_style;
- widget = GTK_WIDGET (area);
+ widget = GTK_WIDGET (area);
- foo_scroll_area_get_viewport (area, &viewport);
- widget_style = gtk_widget_get_style (widget);
+ foo_scroll_area_get_viewport (area, &viewport);
+ widget_style = gtk_widget_get_style (widget);
- cairo_set_source_rgb (cr,
- widget_style->mid[GTK_STATE_NORMAL].red / 65535.0,
- widget_style->mid[GTK_STATE_NORMAL].green / 65535.0,
- widget_style->mid[GTK_STATE_NORMAL].blue / 65535.0);
+ cairo_set_source_rgb (cr,
+ widget_style->mid[GTK_STATE_NORMAL].red / 65535.0,
+ widget_style->mid[GTK_STATE_NORMAL].green / 65535.0,
+ widget_style->mid[GTK_STATE_NORMAL].blue / 65535.0);
- cairo_rectangle (cr,
- viewport.x, viewport.y,
- viewport.width, viewport.height);
+ cairo_rectangle (cr,
+ viewport.x, viewport.y,
+ viewport.width, viewport.height);
- cairo_fill_preserve (cr);
+ cairo_fill_preserve (cr);
- foo_scroll_area_add_input_from_fill (area, cr, on_canvas_event, NULL);
+ foo_scroll_area_add_input_from_fill (area, cr, on_canvas_event, NULL);
- cairo_set_source_rgb (cr,
- widget_style->dark[GTK_STATE_NORMAL].red / 65535.0,
- widget_style->dark[GTK_STATE_NORMAL].green / 65535.0,
- widget_style->dark[GTK_STATE_NORMAL].blue / 65535.0);
+ cairo_set_source_rgb (cr,
+ widget_style->dark[GTK_STATE_NORMAL].red / 65535.0,
+ widget_style->dark[GTK_STATE_NORMAL].green / 65535.0,
+ widget_style->dark[GTK_STATE_NORMAL].blue / 65535.0);
- cairo_stroke (cr);
+ cairo_stroke (cr);
}
static void
paint_output (App *app, cairo_t *cr, int i)
{
- int w, h;
- double scale = compute_scale (app);
- double x, y;
- int total_w, total_h;
- GList *connected_outputs = list_connected_outputs (app, &total_w, &total_h);
- GnomeOutputInfo *output = g_list_nth (connected_outputs, i)->data;
- PangoLayout *layout = get_display_name (app, output);
- PangoRectangle ink_extent, log_extent;
- GdkRectangle viewport;
- GdkColor output_color;
- double r, g, b;
- double available_w;
- double factor;
-
- cairo_save (cr);
-
- foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area), &viewport);
- get_geometry (output, &w, &h);
+ int w, h;
+ double scale = compute_scale (app);
+ double x, y;
+ int total_w, total_h;
+ GList *connected_outputs = list_connected_outputs (app, &total_w, &total_h);
+ GnomeOutputInfo *output = g_list_nth (connected_outputs, i)->data;
+ PangoLayout *layout = get_display_name (app, output);
+ PangoRectangle ink_extent, log_extent;
+ GdkRectangle viewport;
+ GdkColor output_color;
+ double r, g, b;
+ double available_w;
+ double factor;
+
+ cairo_save (cr);
+
+ foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area), &viewport);
+ get_geometry (output, &w, &h);
#if 0
- g_debug ("%s (%p) geometry %d %d %d", output->name, output,
- w, h, output->rate);
+ g_debug ("%s (%p) geometry %d %d %d", output->name, output,
+ w, h, output->rate);
#endif
- viewport.height -= 2 * MARGIN;
- viewport.width -= 2 * MARGIN;
+ viewport.height -= 2 * MARGIN;
+ viewport.width -= 2 * MARGIN;
- x = output->x * scale + MARGIN + (viewport.width - total_w * scale) / 2.0;
- y = output->y * scale + MARGIN + (viewport.height - total_h * scale) / 2.0;
+ x = output->x * scale + MARGIN + (viewport.width - total_w * scale) / 2.0;
+ y = output->y * scale + MARGIN + (viewport.height - total_h * scale) / 2.0;
#if 0
- g_debug ("scaled: %f %f", x, y);
+ g_debug ("scaled: %f %f", x, y);
- g_debug ("scale: %f", scale);
+ g_debug ("scale: %f", scale);
- g_debug ("%f %f %f %f", x, y, w * scale + 0.5, h * scale + 0.5);
+ g_debug ("%f %f %f %f", x, y, w * scale + 0.5, h * scale + 0.5);
#endif
- cairo_translate (cr,
- x + (w * scale + 0.5) / 2,
- y + (h * scale + 0.5) / 2);
+ cairo_translate (cr,
+ x + (w * scale + 0.5) / 2,
+ y + (h * scale + 0.5) / 2);
- /* rotation is already applied in get_geometry */
+ /* rotation is already applied in get_geometry */
- if (output->rotation & GNOME_RR_REFLECT_X)
- cairo_scale (cr, -1, 1);
+ if (output->rotation & GNOME_RR_REFLECT_X)
+ cairo_scale (cr, -1, 1);
- if (output->rotation & GNOME_RR_REFLECT_Y)
- cairo_scale (cr, 1, -1);
+ if (output->rotation & GNOME_RR_REFLECT_Y)
+ cairo_scale (cr, 1, -1);
- cairo_translate (cr,
- - x - (w * scale + 0.5) / 2,
- - y - (h * scale + 0.5) / 2);
+ cairo_translate (cr,
+ - x - (w * scale + 0.5) / 2,
+ - y - (h * scale + 0.5) / 2);
- if (output == app->current_output)
+ if (output == app->current_output)
{
- GtkStyle *style;
- GdkColor color;
- double r, g, b;
+ GtkStyle *style;
+ GdkColor color;
+ double r, g, b;
- style = gtk_widget_get_style (app->area);
- color = style->bg[GTK_STATE_SELECTED];
- r = (float)color.red / 65535.0;
- g = (float)color.green / 65535.0;
- b = (float)color.blue / 65535.0;
+ style = gtk_widget_get_style (app->area);
+ color = style->bg[GTK_STATE_SELECTED];
+ r = (float)color.red / 65535.0;
+ g = (float)color.green / 65535.0;
+ b = (float)color.blue / 65535.0;
- cairo_rectangle (cr, x - 2, y - 2, w * scale + 0.5 + 4, h * scale + 0.5 + 4);
+ cairo_rectangle (cr, x - 2, y - 2, w * scale + 0.5 + 4, h * scale + 0.5 + 4);
- cairo_set_line_width (cr, 4);
- cairo_set_source_rgba (cr, r, g, b, 0.5);
- cairo_stroke (cr);
+ cairo_set_line_width (cr, 4);
+ cairo_set_source_rgba (cr, r, g, b, 0.5);
+ cairo_stroke (cr);
}
- cairo_rectangle (cr, x, y, w * scale + 0.5, h * scale + 0.5);
- cairo_clip_preserve (cr);
+ cairo_rectangle (cr, x, y, w * scale + 0.5, h * scale + 0.5);
+ cairo_clip_preserve (cr);
- gnome_rr_labeler_get_color_for_output (app->labeler, output, &output_color);
- r = output_color.red / 65535.0;
- g = output_color.green / 65535.0;
- b = output_color.blue / 65535.0;
+ gnome_rr_labeler_get_color_for_output (app->labeler, output, &output_color);
+ r = output_color.red / 65535.0;
+ g = output_color.green / 65535.0;
+ b = output_color.blue / 65535.0;
- if (!output->on)
+ if (!output->on)
{
- /* If the output is turned off, just darken the selected color */
- r *= 0.2;
- g *= 0.2;
- b *= 0.2;
+ /* If the output is turned off, just darken the selected color */
+ r *= 0.2;
+ g *= 0.2;
+ b *= 0.2;
}
- cairo_set_source_rgba (cr, r, g, b, 1.0);
+ cairo_set_source_rgba (cr, r, g, b, 1.0);
- foo_scroll_area_add_input_from_fill (FOO_SCROLL_AREA (app->area),
- cr, on_output_event, output);
- cairo_fill (cr);
+ foo_scroll_area_add_input_from_fill (FOO_SCROLL_AREA (app->area),
+ cr, on_output_event, output);
+ cairo_fill (cr);
- cairo_rectangle (cr, x + 0.5, y + 0.5, w * scale + 0.5 - 1, h * scale + 0.5 - 1);
+ cairo_rectangle (cr, x + 0.5, y + 0.5, w * scale + 0.5 - 1, h * scale + 0.5 - 1);
- cairo_set_line_width (cr, 1);
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_set_line_width (cr, 1);
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
- cairo_stroke (cr);
- cairo_set_line_width (cr, 2);
+ cairo_stroke (cr);
+ cairo_set_line_width (cr, 2);
- layout_set_font (layout, "Sans 10");
- pango_layout_get_pixel_extents (layout, &ink_extent, &log_extent);
+ layout_set_font (layout, "Sans 10");
+ pango_layout_get_pixel_extents (layout, &ink_extent, &log_extent);
- available_w = w * scale + 0.5 - 6; /* Same as the inner rectangle's width, minus 1 pixel of padding on each side */
- if (available_w < ink_extent.width)
- factor = available_w / ink_extent.width;
- else
- factor = 1.0;
+ available_w = w * scale + 0.5 - 6; /* Same as the inner rectangle's width, minus 1 pixel of padding on each side */
+ if (available_w < ink_extent.width)
+ factor = available_w / ink_extent.width;
+ else
+ factor = 1.0;
- cairo_move_to (cr,
- x + ((w * scale + 0.5) - factor * log_extent.width) / 2,
- y + ((h * scale + 0.5) - factor * log_extent.height) / 2);
+ cairo_move_to (cr,
+ x + ((w * scale + 0.5) - factor * log_extent.width) / 2,
+ y + ((h * scale + 0.5) - factor * log_extent.height) / 2);
- cairo_scale (cr, factor, factor);
+ cairo_scale (cr, factor, factor);
- if (output->on)
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- else
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ if (output->on)
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ else
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
- pango_cairo_show_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
- cairo_restore (cr);
+ cairo_restore (cr);
- g_object_unref (layout);
+ g_object_unref (layout);
}
static void
@@ -1805,115 +1805,115 @@ on_area_paint (FooScrollArea *area,
cairo_t *cr,
gpointer data)
{
- App *app = data;
- double scale;
- GList *connected_outputs = NULL;
- GList *list;
+ App *app = data;
+ double scale;
+ GList *connected_outputs = NULL;
+ GList *list;
- paint_background (area, cr);
+ paint_background (area, cr);
- if (!app->current_configuration)
- return;
+ if (!app->current_configuration)
+ return;
- scale = compute_scale (app);
- connected_outputs = list_connected_outputs (app, NULL, NULL);
+ scale = compute_scale (app);
+ connected_outputs = list_connected_outputs (app, NULL, NULL);
#if 0
- g_debug ("scale: %f", scale);
+ g_debug ("scale: %f", scale);
#endif
- for (list = connected_outputs; list != NULL; list = list->next)
+ for (list = connected_outputs; list != NULL; list = list->next)
{
- paint_output (app, cr, g_list_position (connected_outputs, list));
+ paint_output (app, cr, g_list_position (connected_outputs, list));
- if (app->current_configuration->clone)
- break;
+ if (app->current_configuration->clone)
+ break;
}
}
static void
make_text_combo (GtkWidget *widget, int sort_column)
{
- GtkComboBox *box = GTK_COMBO_BOX (widget);
- GtkListStore *store = gtk_list_store_new (
- 6,
- G_TYPE_STRING, /* Text */
- G_TYPE_INT, /* Width */
- G_TYPE_INT, /* Height */
- G_TYPE_INT, /* Frequency */
- G_TYPE_INT, /* Width * Height */
- G_TYPE_INT); /* Rotation */
+ GtkComboBox *box = GTK_COMBO_BOX (widget);
+ GtkListStore *store = gtk_list_store_new (
+ 6,
+ G_TYPE_STRING, /* Text */
+ G_TYPE_INT, /* Width */
+ G_TYPE_INT, /* Height */
+ G_TYPE_INT, /* Frequency */
+ G_TYPE_INT, /* Width * Height */
+ G_TYPE_INT); /* Rotation */
- GtkCellRenderer *cell;
+ GtkCellRenderer *cell;
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget));
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget));
- gtk_combo_box_set_model (box, GTK_TREE_MODEL (store));
+ gtk_combo_box_set_model (box, GTK_TREE_MODEL (store));
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (box), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (box), cell,
- "text", 0,
- NULL);
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (box), cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (box), cell,
+ "text", 0,
+ NULL);
- if (sort_column != -1)
+ if (sort_column != -1)
{
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
- sort_column,
- GTK_SORT_DESCENDING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ sort_column,
+ GTK_SORT_DESCENDING);
}
}
static void
compute_virtual_size_for_configuration (GnomeRRConfig *config, int *ret_width, int *ret_height)
{
- int i;
- int width, height;
+ int i;
+ int width, height;
- width = height = 0;
+ width = height = 0;
- for (i = 0; config->outputs[i] != NULL; i++)
+ for (i = 0; config->outputs[i] != NULL; i++)
{
- GnomeOutputInfo *output;
+ GnomeOutputInfo *output;
- output = config->outputs[i];
+ output = config->outputs[i];
- if (output->on)
+ if (output->on)
{
- width = MAX (width, output->x + output->width);
- height = MAX (height, output->y + output->height);
+ width = MAX (width, output->x + output->width);
+ height = MAX (height, output->y + output->height);
}
}
- *ret_width = width;
- *ret_height = height;
+ *ret_width = width;
+ *ret_height = height;
}
static void
check_required_virtual_size (App *app)
{
- int req_width, req_height;
- int min_width, max_width;
- int min_height, max_height;
+ int req_width, req_height;
+ int min_width, max_width;
+ int min_height, max_height;
- compute_virtual_size_for_configuration (app->current_configuration, &req_width, &req_height);
+ compute_virtual_size_for_configuration (app->current_configuration, &req_width, &req_height);
- gnome_rr_screen_get_ranges (app->screen, &min_width, &max_width, &min_height, &max_height);
+ gnome_rr_screen_get_ranges (app->screen, &min_width, &max_width, &min_height, &max_height);
#if 0
- g_debug ("X Server supports:");
- g_debug ("min_width = %d, max_width = %d", min_width, max_width);
- g_debug ("min_height = %d, max_height = %d", min_height, max_height);
+ g_debug ("X Server supports:");
+ g_debug ("min_width = %d, max_width = %d", min_width, max_width);
+ g_debug ("min_height = %d, max_height = %d", min_height, max_height);
- g_debug ("Requesting size of %dx%d", req_width, req_height);
+ g_debug ("Requesting size of %dx%d", req_width, req_height);
#endif
- if (!(min_width <= req_width && req_width <= max_width
- && min_height <= req_height && req_height <= max_height))
+ if (!(min_width <= req_width && req_width <= max_width
+ && min_height <= req_height && req_height <= max_height))
{
- /* FIXME: present a useful dialog, maybe even before the user tries to Apply */
+ /* FIXME: present a useful dialog, maybe even before the user tries to Apply */
#if 0
- g_debug ("Your X server needs a larger Virtual size!");
+ g_debug ("Your X server needs a larger Virtual size!");
#endif
}
}
@@ -1921,74 +1921,74 @@ check_required_virtual_size (App *app)
static void
begin_version2_apply_configuration (App *app, GdkWindow *parent_window, guint32 timestamp)
{
- XID parent_window_xid;
-
- parent_window_xid = GDK_WINDOW_XID (parent_window);
-
- app->proxy = dbus_g_proxy_new_for_name (app->connection,
- "org.gnome.SettingsDaemon",
- "/org/gnome/SettingsDaemon/XRANDR",
- "org.gnome.SettingsDaemon.XRANDR_2");
- g_assert (app->proxy != NULL); /* that call does not fail unless we pass bogus names */
-
- app->apply_configuration_state = APPLYING_VERSION_2;
- app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
- apply_configuration_returned_cb, app,
- NULL,
- G_TYPE_INT64, (gint64) parent_window_xid,
- G_TYPE_INT64, (gint64) timestamp,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- /* FIXME: we don't check for app->proxy_call == NULL, which could happen if
- * the connection was disconnected. This is left as an exercise for the
- * reader.
- */
+ XID parent_window_xid;
+
+ parent_window_xid = GDK_WINDOW_XID (parent_window);
+
+ app->proxy = dbus_g_proxy_new_for_name (app->connection,
+ "org.gnome.SettingsDaemon",
+ "/org/gnome/SettingsDaemon/XRANDR",
+ "org.gnome.SettingsDaemon.XRANDR_2");
+ g_assert (app->proxy != NULL); /* that call does not fail unless we pass bogus names */
+
+ app->apply_configuration_state = APPLYING_VERSION_2;
+ app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
+ apply_configuration_returned_cb, app,
+ NULL,
+ G_TYPE_INT64, (gint64) parent_window_xid,
+ G_TYPE_INT64, (gint64) timestamp,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ /* FIXME: we don't check for app->proxy_call == NULL, which could happen if
+ * the connection was disconnected. This is left as an exercise for the
+ * reader.
+ */
}
static void
begin_version1_apply_configuration (App *app)
{
- app->proxy = dbus_g_proxy_new_for_name (app->connection,
- "org.gnome.SettingsDaemon",
- "/org/gnome/SettingsDaemon/XRANDR",
- "org.gnome.SettingsDaemon.XRANDR");
- g_assert (app->proxy != NULL); /* that call does not fail unless we pass bogus names */
-
- app->apply_configuration_state = APPLYING_VERSION_1;
- app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
- apply_configuration_returned_cb, app,
- NULL,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- /* FIXME: we don't check for app->proxy_call == NULL, which could happen if
- * the connection was disconnected. This is left as an exercise for the
- * reader.
- */
+ app->proxy = dbus_g_proxy_new_for_name (app->connection,
+ "org.gnome.SettingsDaemon",
+ "/org/gnome/SettingsDaemon/XRANDR",
+ "org.gnome.SettingsDaemon.XRANDR");
+ g_assert (app->proxy != NULL); /* that call does not fail unless we pass bogus names */
+
+ app->apply_configuration_state = APPLYING_VERSION_1;
+ app->proxy_call = dbus_g_proxy_begin_call (app->proxy, "ApplyConfiguration",
+ apply_configuration_returned_cb, app,
+ NULL,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ /* FIXME: we don't check for app->proxy_call == NULL, which could happen if
+ * the connection was disconnected. This is left as an exercise for the
+ * reader.
+ */
}
static void
ensure_current_configuration_is_saved (void)
{
- GnomeRRScreen *rr_screen;
- GnomeRRConfig *rr_config;
+ GnomeRRScreen *rr_screen;
+ GnomeRRConfig *rr_config;
- /* Normally, gnome_rr_config_save() creates a backup file based on the
- * old monitors.xml. However, if *that* file didn't exist, there is
- * nothing from which to create a backup. So, here we'll save the
- * current/unchanged configuration and then let our caller call
- * gnome_rr_config_save() again with the new/changed configuration, so
- * that there *will* be a backup file in the end.
- */
+ /* Normally, gnome_rr_config_save() creates a backup file based on the
+ * old monitors.xml. However, if *that* file didn't exist, there is
+ * nothing from which to create a backup. So, here we'll save the
+ * current/unchanged configuration and then let our caller call
+ * gnome_rr_config_save() again with the new/changed configuration, so
+ * that there *will* be a backup file in the end.
+ */
- rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, NULL); /* NULL-GError */
- if (!rr_screen)
- return;
+ rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, NULL); /* NULL-GError */
+ if (!rr_screen)
+ return;
- rr_config = gnome_rr_config_new_current (rr_screen);
- gnome_rr_config_save (rr_config, NULL); /* NULL-GError */
+ rr_config = gnome_rr_config_new_current (rr_screen);
+ gnome_rr_config_save (rr_config, NULL); /* NULL-GError */
- gnome_rr_config_free (rr_config);
- gnome_rr_screen_destroy (rr_screen);
+ gnome_rr_config_free (rr_config);
+ gnome_rr_screen_destroy (rr_screen);
}
/* Callback for dbus_g_proxy_begin_call() */
@@ -1997,93 +1997,93 @@ apply_configuration_returned_cb (DBusGProxy *proxy,
DBusGProxyCall *call_id,
void *data)
{
- App *app = data;
- gboolean success;
- GError *error;
+ App *app = data;
+ gboolean success;
+ GError *error;
- g_assert (call_id == app->proxy_call);
+ g_assert (call_id == app->proxy_call);
- error = NULL;
- success = dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
+ error = NULL;
+ success = dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID);
- if (!success) {
- if (app->apply_configuration_state == APPLYING_VERSION_2
- && g_error_matches (error, DBUS_GERROR, DBUS_GERROR_UNKNOWN_METHOD)) {
- g_error_free (error);
+ if (!success) {
+ if (app->apply_configuration_state == APPLYING_VERSION_2
+ && g_error_matches (error, DBUS_GERROR, DBUS_GERROR_UNKNOWN_METHOD)) {
+ g_error_free (error);
- g_object_unref (app->proxy);
- app->proxy = NULL;
+ g_object_unref (app->proxy);
+ app->proxy = NULL;
- begin_version1_apply_configuration (app);
- return;
- } else {
- /* We don't pop up an error message; gnome-settings-daemon already does that
- * in case the selected RANDR configuration could not be applied.
- */
- g_error_free (error);
- }
+ begin_version1_apply_configuration (app);
+ return;
+ } else {
+ /* We don't pop up an error message; gnome-settings-daemon already does that
+ * in case the selected RANDR configuration could not be applied.
+ */
+ g_error_free (error);
}
+ }
- g_object_unref (app->proxy);
- app->proxy = NULL;
+ g_object_unref (app->proxy);
+ app->proxy = NULL;
- dbus_g_connection_unref (app->connection);
- app->connection = NULL;
- app->proxy_call = NULL;
+ dbus_g_connection_unref (app->connection);
+ app->connection = NULL;
+ app->proxy_call = NULL;
- gtk_widget_set_sensitive (app->panel, TRUE);
+ gtk_widget_set_sensitive (app->panel, TRUE);
}
static gboolean
sanitize_and_save_configuration (App *app)
{
- GError *error;
+ GError *error;
- gnome_rr_config_sanitize (app->current_configuration);
+ gnome_rr_config_sanitize (app->current_configuration);
- check_required_virtual_size (app);
+ check_required_virtual_size (app);
- foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
+ foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
- ensure_current_configuration_is_saved ();
+ ensure_current_configuration_is_saved ();
- error = NULL;
- if (!gnome_rr_config_save (app->current_configuration, &error))
+ error = NULL;
+ if (!gnome_rr_config_save (app->current_configuration, &error))
{
- error_message (app, _("Could not save the monitor configuration"), error->message);
- g_error_free (error);
- return FALSE;
+ error_message (app, _("Could not save the monitor configuration"), error->message);
+ g_error_free (error);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
static void
apply (App *app)
{
- GError *error = NULL;
- GdkWindow *window;
+ GError *error = NULL;
+ GdkWindow *window;
- if (!sanitize_and_save_configuration (app))
- return;
+ if (!sanitize_and_save_configuration (app))
+ return;
- g_assert (app->connection == NULL);
- g_assert (app->proxy == NULL);
- g_assert (app->proxy_call == NULL);
+ g_assert (app->connection == NULL);
+ g_assert (app->proxy == NULL);
+ g_assert (app->proxy_call == NULL);
- app->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (app->connection == NULL) {
- error_message (app, _("Could not get session bus while applying display configuration"), error->message);
- g_error_free (error);
- return;
- }
+ app->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (app->connection == NULL) {
+ error_message (app, _("Could not get session bus while applying display configuration"), error->message);
+ g_error_free (error);
+ return;
+ }
- gtk_widget_set_sensitive (app->panel, FALSE);
+ gtk_widget_set_sensitive (app->panel, FALSE);
- window = gtk_widget_get_window (gtk_widget_get_toplevel (app->panel));
+ window = gtk_widget_get_window (gtk_widget_get_toplevel (app->panel));
- begin_version2_apply_configuration (app, window,
- app->apply_button_clicked_timestamp);
+ begin_version2_apply_configuration (app, window,
+ app->apply_button_clicked_timestamp);
}
#if 0
@@ -2091,84 +2091,84 @@ apply (App *app)
static gboolean
driver_is_randr_10 (GnomeRRConfig *config)
{
- /* In the Xorg code, see xserver/randr/rrinfo.c:RRScanOldConfig(). It gets
- * called when the graphics driver doesn't support RANDR 1.2 yet, just 1.0.
- * In that case, the X server's base code (which supports RANDR 1.2) will
- * simulate having a single output called "default". For drivers that *do*
- * support RANDR 1.2, the separate outputs will be named differently, we
- * hope.
- *
- * This heuristic is courtesy of Dirk Mueller <dmueller suse de>
- *
- * FIXME: however, we don't even check for XRRQueryVersion() returning 1.2, neither
- * here nor in gnome-desktop/libgnomedesktop*.c. Do we need to check for that,
- * or is gnome_rr_screen_new()'s return value sufficient?
- */
-
- return (count_all_outputs (config) == 1 && strcmp (config->outputs[0]->name, "default") == 0);
+ /* In the Xorg code, see xserver/randr/rrinfo.c:RRScanOldConfig(). It gets
+ * called when the graphics driver doesn't support RANDR 1.2 yet, just 1.0.
+ * In that case, the X server's base code (which supports RANDR 1.2) will
+ * simulate having a single output called "default". For drivers that *do*
+ * support RANDR 1.2, the separate outputs will be named differently, we
+ * hope.
+ *
+ * This heuristic is courtesy of Dirk Mueller <dmueller suse de>
+ *
+ * FIXME: however, we don't even check for XRRQueryVersion() returning 1.2, neither
+ * here nor in gnome-desktop/libgnomedesktop*.c. Do we need to check for that,
+ * or is gnome_rr_screen_new()'s return value sufficient?
+ */
+
+ return (count_all_outputs (config) == 1 && strcmp (config->outputs[0]->name, "default") == 0);
}
#endif
static void
on_detect_displays (GtkWidget *widget, gpointer data)
{
- App *app = data;
- GError *error;
+ App *app = data;
+ GError *error;
- error = NULL;
- if (!gnome_rr_screen_refresh (app->screen, &error)) {
- if (error) {
- error_message (app, _("Could not detect displays"), error->message);
- g_error_free (error);
- }
+ error = NULL;
+ if (!gnome_rr_screen_refresh (app->screen, &error)) {
+ if (error) {
+ error_message (app, _("Could not detect displays"), error->message);
+ g_error_free (error);
}
+ }
}
static GnomeOutputInfo *
get_nearest_output (GnomeRRConfig *configuration, int x, int y)
{
- int i;
- int nearest_index;
- int nearest_dist;
+ int i;
+ int nearest_index;
+ int nearest_dist;
- nearest_index = -1;
- nearest_dist = G_MAXINT;
+ nearest_index = -1;
+ nearest_dist = G_MAXINT;
- for (i = 0; configuration->outputs[i] != NULL; i++)
+ for (i = 0; configuration->outputs[i] != NULL; i++)
{
- GnomeOutputInfo *output;
- int dist_x, dist_y;
+ GnomeOutputInfo *output;
+ int dist_x, dist_y;
- output = configuration->outputs[i];
+ output = configuration->outputs[i];
- if (!(output->connected && output->on))
- continue;
+ if (!(output->connected && output->on))
+ continue;
- if (x < output->x)
- dist_x = output->x - x;
- else if (x >= output->x + output->width)
- dist_x = x - (output->x + output->width) + 1;
- else
- dist_x = 0;
+ if (x < output->x)
+ dist_x = output->x - x;
+ else if (x >= output->x + output->width)
+ dist_x = x - (output->x + output->width) + 1;
+ else
+ dist_x = 0;
- if (y < output->y)
- dist_y = output->y - y;
- else if (y >= output->y + output->height)
- dist_y = y - (output->y + output->height) + 1;
- else
- dist_y = 0;
+ if (y < output->y)
+ dist_y = output->y - y;
+ else if (y >= output->y + output->height)
+ dist_y = y - (output->y + output->height) + 1;
+ else
+ dist_y = 0;
- if (MIN (dist_x, dist_y) < nearest_dist)
+ if (MIN (dist_x, dist_y) < nearest_dist)
{
- nearest_dist = MIN (dist_x, dist_y);
- nearest_index = i;
+ nearest_dist = MIN (dist_x, dist_y);
+ nearest_index = i;
}
}
- if (nearest_index != -1)
- return configuration->outputs[nearest_index];
- else
- return NULL;
+ if (nearest_index != -1)
+ return configuration->outputs[nearest_index];
+ else
+ return NULL;
}
@@ -2178,48 +2178,48 @@ get_nearest_output (GnomeRRConfig *configuration, int x, int y)
static GnomeOutputInfo *
get_output_for_window (GnomeRRConfig *configuration, GdkWindow *window)
{
- GdkRectangle win_rect;
- int i;
- int largest_area;
- int largest_index;
+ GdkRectangle win_rect;
+ int i;
+ int largest_area;
+ int largest_index;
- gdk_window_get_geometry (window, &win_rect.x, &win_rect.y, &win_rect.width, &win_rect.height, NULL);
- gdk_window_get_origin (window, &win_rect.x, &win_rect.y);
+ gdk_window_get_geometry (window, &win_rect.x, &win_rect.y, &win_rect.width, &win_rect.height, NULL);
+ gdk_window_get_origin (window, &win_rect.x, &win_rect.y);
- largest_area = 0;
- largest_index = -1;
+ largest_area = 0;
+ largest_index = -1;
- for (i = 0; configuration->outputs[i] != NULL; i++)
+ for (i = 0; configuration->outputs[i] != NULL; i++)
{
- GnomeOutputInfo *output;
- GdkRectangle output_rect, intersection;
+ GnomeOutputInfo *output;
+ GdkRectangle output_rect, intersection;
- output = configuration->outputs[i];
+ output = configuration->outputs[i];
- output_rect.x = output->x;
- output_rect.y = output->y;
- output_rect.width = output->width;
- output_rect.height = output->height;
+ output_rect.x = output->x;
+ output_rect.y = output->y;
+ output_rect.width = output->width;
+ output_rect.height = output->height;
- if (output->connected && gdk_rectangle_intersect (&win_rect, &output_rect, &intersection))
+ if (output->connected && gdk_rectangle_intersect (&win_rect, &output_rect, &intersection))
{
- int area;
+ int area;
- area = intersection.width * intersection.height;
- if (area > largest_area)
+ area = intersection.width * intersection.height;
+ if (area > largest_area)
{
- largest_area = area;
- largest_index = i;
+ largest_area = area;
+ largest_index = i;
}
}
}
- if (largest_index != -1)
- return configuration->outputs[largest_index];
- else
- return get_nearest_output (configuration,
- win_rect.x + win_rect.width / 2,
- win_rect.y + win_rect.height / 2);
+ if (largest_index != -1)
+ return configuration->outputs[largest_index];
+ else
+ return get_nearest_output (configuration,
+ win_rect.x + win_rect.width / 2,
+ win_rect.y + win_rect.height / 2);
}
static void
@@ -2237,18 +2237,18 @@ on_toplevel_realized (GtkWidget *widget,
static void
select_current_output_from_dialog_position (App *app)
{
- GtkWidget *toplevel;
+ GtkWidget *toplevel;
- toplevel = gtk_widget_get_toplevel (app->panel);
+ toplevel = gtk_widget_get_toplevel (app->panel);
- if (gtk_widget_get_realized (toplevel)) {
- app->current_output = get_output_for_window (app->current_configuration,
- gtk_widget_get_window (toplevel));
- rebuild_gui (app);
- } else {
- g_signal_connect (toplevel, "realize", G_CALLBACK (on_toplevel_realized), app);
- app->current_output = NULL;
- }
+ if (gtk_widget_get_realized (toplevel)) {
+ app->current_output = get_output_for_window (app->current_configuration,
+ gtk_widget_get_window (toplevel));
+ rebuild_gui (app);
+ } else {
+ g_signal_connect (toplevel, "realize", G_CALLBACK (on_toplevel_realized), app);
+ app->current_output = NULL;
+ }
}
/* This is a GtkWidget::map-event handler. We wait for the display-properties
@@ -2258,41 +2258,41 @@ select_current_output_from_dialog_position (App *app)
static gboolean
dialog_map_event_cb (GtkWidget *widget, GdkEventAny *event, gpointer data)
{
- App *app = data;
+ App *app = data;
- select_current_output_from_dialog_position (app);
- return FALSE;
+ select_current_output_from_dialog_position (app);
+ return FALSE;
}
static void
apply_button_clicked_cb (GtkButton *button, gpointer data)
{
- App *app = data;
+ App *app = data;
- /* We simply store the timestamp at which the Apply button was clicked.
- * We'll just wait for the dialog to return from gtk_dialog_run(), and
- * *then* use the timestamp when applying the RANDR configuration.
- */
+ /* We simply store the timestamp at which the Apply button was clicked.
+ * We'll just wait for the dialog to return from gtk_dialog_run(), and
+ * *then* use the timestamp when applying the RANDR configuration.
+ */
- app->apply_button_clicked_timestamp = gtk_get_current_event_time ();
+ app->apply_button_clicked_timestamp = gtk_get_current_event_time ();
}
static GtkWidget*
_gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
{
- return GTK_WIDGET (gtk_builder_get_object (builder, name));
+ return GTK_WIDGET (gtk_builder_get_object (builder, name));
}
static void
destroy_app (App *app)
{
- gnome_rr_screen_destroy (app->screen);
- g_object_unref (app->builder);
- gnome_rr_labeler_hide (app->labeler);
- g_object_unref (app->labeler);
+ gnome_rr_screen_destroy (app->screen);
+ g_object_unref (app->builder);
+ gnome_rr_labeler_hide (app->labeler);
+ g_object_unref (app->labeler);
- g_free (app);
+ g_free (app);
}
GtkWidget*
@@ -2302,107 +2302,107 @@ run_application (void)
#define UIDIR "."
#endif
#define UI_FILE UIDIR "/display-capplet.ui"
- GtkBuilder *builder;
- GtkWidget *align;
- GError *error;
- gchar *objects[] = {"display-panel", "rotation-liststore", NULL};
- App *app;
+ GtkBuilder *builder;
+ GtkWidget *align;
+ GError *error;
+ gchar *objects[] = {"display-panel", "rotation-liststore", NULL};
+ App *app;
- app = g_new0 (App, 1);
+ app = g_new0 (App, 1);
- error = NULL;
- app->builder = builder = gtk_builder_new ();
+ error = NULL;
+ app->builder = builder = gtk_builder_new ();
- if (!gtk_builder_add_objects_from_file (builder, UI_FILE, objects, &error))
+ if (!gtk_builder_add_objects_from_file (builder, UI_FILE, objects, &error))
{
- g_warning ("Could not parse UI definition: %s", error->message);
- g_error_free (error);
- g_object_unref (builder);
- return NULL;
+ g_warning ("Could not parse UI definition: %s", error->message);
+ g_error_free (error);
+ g_object_unref (builder);
+ return NULL;
}
- app->screen = gnome_rr_screen_new (gdk_screen_get_default (),
- on_screen_changed, app, &error);
- if (!app->screen)
+ app->screen = gnome_rr_screen_new (gdk_screen_get_default (),
+ on_screen_changed, app, &error);
+ if (!app->screen)
{
- error_message (NULL, _("Could not get screen information"), error->message);
- g_error_free (error);
- g_object_unref (builder);
- return NULL;
+ error_message (NULL, _("Could not get screen information"), error->message);
+ g_error_free (error);
+ g_object_unref (builder);
+ return NULL;
}
- app->panel = _gtk_builder_get_widget (builder, "display-panel");
+ app->panel = _gtk_builder_get_widget (builder, "display-panel");
- if (!app->panel)
- g_warning ("Missing display-panel object");
- g_signal_connect_after (app->panel, "show",
- G_CALLBACK (dialog_map_event_cb), app);
+ if (!app->panel)
+ g_warning ("Missing display-panel object");
+ g_signal_connect_after (app->panel, "show",
+ G_CALLBACK (dialog_map_event_cb), app);
- app->current_monitor_event_box = _gtk_builder_get_widget (builder,
- "current_monitor_event_box");
- app->current_monitor_label = _gtk_builder_get_widget (builder,
- "current_monitor_label");
+ app->current_monitor_event_box = _gtk_builder_get_widget (builder,
+ "current_monitor_event_box");
+ app->current_monitor_label = _gtk_builder_get_widget (builder,
+ "current_monitor_label");
- app->monitor_on_radio = _gtk_builder_get_widget (builder,
- "monitor_on_radio");
- app->monitor_off_radio = _gtk_builder_get_widget (builder,
- "monitor_off_radio");
- g_signal_connect (app->monitor_on_radio, "toggled",
- G_CALLBACK (monitor_on_off_toggled_cb), app);
- g_signal_connect (app->monitor_off_radio, "toggled",
- G_CALLBACK (monitor_on_off_toggled_cb), app);
+ app->monitor_on_radio = _gtk_builder_get_widget (builder,
+ "monitor_on_radio");
+ app->monitor_off_radio = _gtk_builder_get_widget (builder,
+ "monitor_off_radio");
+ g_signal_connect (app->monitor_on_radio, "toggled",
+ G_CALLBACK (monitor_on_off_toggled_cb), app);
+ g_signal_connect (app->monitor_off_radio, "toggled",
+ G_CALLBACK (monitor_on_off_toggled_cb), app);
- app->resolution_combo = _gtk_builder_get_widget (builder,
- "resolution_combo");
- g_signal_connect (app->resolution_combo, "changed",
- G_CALLBACK (on_resolution_changed), app);
+ app->resolution_combo = _gtk_builder_get_widget (builder,
+ "resolution_combo");
+ g_signal_connect (app->resolution_combo, "changed",
+ G_CALLBACK (on_resolution_changed), app);
- app->rotation_combo = _gtk_builder_get_widget (builder, "rotation_combo");
- g_signal_connect (app->rotation_combo, "changed",
- G_CALLBACK (on_rotation_changed), app);
+ app->rotation_combo = _gtk_builder_get_widget (builder, "rotation_combo");
+ g_signal_connect (app->rotation_combo, "changed",
+ G_CALLBACK (on_rotation_changed), app);
- app->clone_checkbox = _gtk_builder_get_widget (builder, "clone_checkbox");
- g_signal_connect (app->clone_checkbox, "toggled",
- G_CALLBACK (on_clone_changed), app);
+ app->clone_checkbox = _gtk_builder_get_widget (builder, "clone_checkbox");
+ g_signal_connect (app->clone_checkbox, "toggled",
+ G_CALLBACK (on_clone_changed), app);
- app->clone_label = _gtk_builder_get_widget (builder, "clone_resolution_warning_label");
+ app->clone_label = _gtk_builder_get_widget (builder, "clone_resolution_warning_label");
- g_signal_connect (_gtk_builder_get_widget (builder, "detect_displays_button"),
- "clicked", G_CALLBACK (on_detect_displays), app);
+ g_signal_connect (_gtk_builder_get_widget (builder, "detect_displays_button"),
+ "clicked", G_CALLBACK (on_detect_displays), app);
- make_text_combo (app->resolution_combo, 4);
- make_text_combo (app->rotation_combo, -1);
+ make_text_combo (app->resolution_combo, 4);
+ make_text_combo (app->rotation_combo, -1);
- /* Scroll Area */
- app->area = (GtkWidget *)foo_scroll_area_new ();
+ /* Scroll Area */
+ app->area = (GtkWidget *)foo_scroll_area_new ();
- g_object_set_data (G_OBJECT (app->area), "app", app);
+ g_object_set_data (G_OBJECT (app->area), "app", app);
- set_monitors_tooltip (app, FALSE);
+ set_monitors_tooltip (app, FALSE);
- /* FIXME: this should be computed dynamically */
- foo_scroll_area_set_min_size (FOO_SCROLL_AREA (app->area), -1, 200);
- gtk_widget_show (app->area);
- g_signal_connect (app->area, "paint",
- G_CALLBACK (on_area_paint), app);
- g_signal_connect (app->area, "viewport_changed",
- G_CALLBACK (on_viewport_changed), app);
+ /* FIXME: this should be computed dynamically */
+ foo_scroll_area_set_min_size (FOO_SCROLL_AREA (app->area), -1, 200);
+ gtk_widget_show (app->area);
+ g_signal_connect (app->area, "paint",
+ G_CALLBACK (on_area_paint), app);
+ g_signal_connect (app->area, "viewport_changed",
+ G_CALLBACK (on_viewport_changed), app);
- align = _gtk_builder_get_widget (builder, "align");
+ align = _gtk_builder_get_widget (builder, "align");
- gtk_container_add (GTK_CONTAINER (align), app->area);
+ gtk_container_add (GTK_CONTAINER (align), app->area);
- app->apply_button = _gtk_builder_get_widget (builder, "apply_button");
- g_signal_connect (app->apply_button, "clicked",
- G_CALLBACK (apply_button_clicked_cb), app);
+ app->apply_button = _gtk_builder_get_widget (builder, "apply_button");
+ g_signal_connect (app->apply_button, "clicked",
+ G_CALLBACK (apply_button_clicked_cb), app);
- on_screen_changed (app->screen, app);
+ on_screen_changed (app->screen, app);
- g_signal_connect_swapped (_gtk_builder_get_widget (builder, "apply_button"),
- "clicked", G_CALLBACK (apply), app);
+ g_signal_connect_swapped (_gtk_builder_get_widget (builder, "apply_button"),
+ "clicked", G_CALLBACK (apply), app);
- g_object_weak_ref (G_OBJECT (app->panel), (GWeakNotify) destroy_app, app);
+ g_object_weak_ref (G_OBJECT (app->panel), (GWeakNotify) destroy_app, app);
- return app->panel;
+ return app->panel;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]