/**
 * cc_rr_labeler_show:
 * @labeler: A #CcRRLabeler
 *
 * Show the labels.
 */
void
cc_rr_labeler_show (CcRRLabeler *labeler)
{
	int i;
	gboolean created_window_for_clone;
	GnomeRROutputInfo **outputs;

	g_return_if_fail (GNOME_IS_RR_LABELER (labeler));

	if (labeler->priv->windows != NULL)
		return;

	labeler->priv->windows = g_new (GtkWidget *, labeler->priv->num_outputs);

	created_window_for_clone = FALSE;

	outputs = gnome_rr_config_get_outputs (labeler->priv->config);

	for (i = 0; i < labeler->priv->num_outputs; i++) {
		if (!created_window_for_clone && gnome_rr_output_info_is_active (outputs[i])) {
			labeler->priv->windows[i] = create_label_window (labeler, outputs[i], labeler->priv->palette + i);

			if (gnome_rr_config_get_clone (labeler->priv->config))
				created_window_for_clone = TRUE;
		} else
			labeler->priv->windows[i] = NULL;
	}
}
Exemplo n.º 2
0
static void gnome_rr_output_info_get_tiled_geometry (GnomeRROutputInfo *self,
                                                     int *x,
                                                     int *y,
                                                     int *width,
                                                     int *height)
{
    GnomeRROutputInfo **outputs;
    gboolean active;
    int i;
    int ht, vt;
    int total_w = 0, total_h = 0;

    outputs = gnome_rr_config_get_outputs (self->priv->config);

    /*
     * iterate over all the outputs from 0,0 -> h,v
     * find the output for each tile,
     * if it is the 0 tile, store the x/y offsets.
     * if the tile is active, add the tile to the total w/h
     * for the output if the tile is in the 0 row or 0 column.
     */
    for (ht = 0; ht < self->priv->tile.max_horiz_tiles; ht++)
    {
        for (vt = 0; vt < self->priv->tile.max_vert_tiles; vt++)
        {
            for (i = 0; outputs[i]; i++)
            {
                GnomeRRTile *this_tile = &outputs[i]->priv->tile;

                if (!outputs[i]->priv->is_tiled)
                    continue;

                if (this_tile->group_id != self->priv->tile.group_id)
                    continue;

                if (this_tile->loc_horiz != ht ||
                    this_tile->loc_vert != vt)
                    continue;

                if (vt == 0 && ht == 0)
                {
                    if (x)
                        *x = outputs[i]->priv->x;
                    if (y)
                        *y = outputs[i]->priv->y;
                }

                active = gnome_rr_output_info_is_active (outputs[i]);
                if (!active)
                    continue;

                if (this_tile->loc_horiz == 0)
                    total_h += outputs[i]->priv->height;

                if (this_tile->loc_vert == 0)
                    total_w += outputs[i]->priv->width;
            }
        }
    }

    if (width)
        *width = total_w;
    if (height)
        *height = total_h;
}
/* Update the display of available monitors based on the latest
 * information from RandR. At the moment the chooser is just a
 * a combobox crudely listing available outputs. The UI mockup
 * has something more akin to the Display panel, with the ability
 * to do rubber-band selection of multiple outputs (note: the
 * g-s-d backend can only handle a single output at the moment)
 */
static void
update_monitor_chooser (CcWacomMappingPanel *self)
{
	GtkListStore *store;
	GnomeRROutputInfo **outputs;
	GdkRectangle geom;
	GSettings *settings;
	gint monitor;
	gboolean single_mon;
	guint i;

	store = gtk_list_store_new (MONITOR_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
	gtk_combo_box_set_model (GTK_COMBO_BOX(self->priv->combobox), GTK_TREE_MODEL(store));

	if (self->priv->device == NULL) {
		set_combobox_sensitive (self, FALSE);
		g_object_unref (store);
		return;
	}

	settings = gsd_wacom_device_get_settings (self->priv->device);
	monitor = gsd_wacom_device_get_display_monitor (self->priv->device);
	single_mon = (monitor != GSD_WACOM_SET_ALL_MONITORS);

	g_signal_handlers_block_by_func (G_OBJECT (self->priv->checkbutton), checkbutton_toggled_cb, self);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(self->priv->checkbutton), single_mon);
	g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->checkbutton), checkbutton_toggled_cb, self);

	g_signal_handlers_block_by_func (G_OBJECT (self->priv->aspectswitch), aspectswitch_toggled_cb, self);
	gtk_switch_set_active (GTK_SWITCH(self->priv->aspectswitch), g_settings_get_boolean (settings, "keep-aspect"));
	g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->aspectswitch), aspectswitch_toggled_cb, self);

	/* FIXME: does this break screen tablets? What's the default
	 * for unconfigured tablets? */
	if (monitor < 0)
		monitor = 0;
	gdk_screen_get_monitor_geometry (gdk_screen_get_default (), monitor, &geom);

	outputs = get_rr_outputs ();
	if (outputs == NULL)
		goto bail;

	for (i = 0; outputs[i] != NULL; i++) {
		GnomeRROutputInfo *output = outputs[i];

		if (gnome_rr_output_info_is_active (output)) {
			GtkTreeIter iter;
			gchar *name, *disp_name, *text;
			int x, y, w, h;
			int mon_at_point;

			name = gnome_rr_output_info_get_name (output);
			disp_name = gnome_rr_output_info_get_display_name (output);
			text = g_strdup_printf ("%s (%s)", name, disp_name);

			gnome_rr_output_info_get_geometry (output, &x, &y, &w, &h);
			mon_at_point = gdk_screen_get_monitor_at_point (gdk_screen_get_default (), x, y);
			gtk_list_store_append (store, &iter);
			gtk_list_store_set (store, &iter, MONITOR_NAME_COLUMN, text, MONITOR_NUM_COLUMN, mon_at_point, -1);

			if (x == geom.x && y == geom.y && w == geom.width && h == geom.height) {
				g_signal_handlers_block_by_func (G_OBJECT (self->priv->combobox), combobox_changed_cb, self);
				gtk_combo_box_set_active_iter (GTK_COMBO_BOX(self->priv->combobox), &iter);
				g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->combobox), combobox_changed_cb, self);
			}

			g_free (text);
		}
	}

bail:
	set_combobox_sensitive (self, single_mon);
	g_object_unref (store);
}