Commit e5d62254 authored by Nick Schermer's avatar Nick Schermer

* dialogs/display-settings/, dialogs/Makefile.am,

	  configure.ac.in: Initial import of the display
	  dialog code. Some basic stuff is working, but
	  not finished yet.
	* dialogs/mouse-settings/main.c: Set display name
	  as tooltip to make ellipsized string readable
	  with resizing the dialog.
	* TODO: Update.

(Old svn revision: 27286)
parent d663903d
2008-07-14 Nick Schermer <nick@xfce.org>
* dialogs/display-settings/, dialogs/Makefile.am,
configure.ac.in: Initial import of the display
dialog code. Some basic stuff is working, but
not finished yet.
* dialogs/mouse-settings/main.c: Set display name
as tooltip to make ellipsized string readable
with resizing the dialog.
* TODO: Update.
2008-07-13 Nick Schermer <nick@xfce.org>
* xfce4-settings-manager/Makefile.am,
......
......@@ -6,9 +6,26 @@ Keyboard settings (Jannis)
(* Maybe add support for keyboard themes again)
Mouse settings (Nick)
Mouse Settings (Nick)
------------------------------------------------------------------------
* Figure out the needed Xi and Xcursor dependency version.
Settings Helper
------------------------------------------------------------------------
* Fixup some of the Makefiles.
* Add signal watch to xfce4-setting-helper to quit the main loop when
receiving a sigterm.
receiving a sigterm. (Nick)
Display Settings (Nick)
------------------------------------------------------------------------
* Make it all work for individual screens.
* Simple dual screen support (2 monitors only).
* Figure out the needed Xrandr and Xxf86vm dependency version.
* Maybe some sort of stored configurations for different setups
(probably not in 4.6).
* Hotplug support. Notify the user (with button to change the
display settings). Could be integrated with the stored configs.
......@@ -81,6 +81,8 @@ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [0])
XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.34])
XDT_CHECK_PACKAGE([XI], [xi], [1.1.0])
XDT_CHECK_PACKAGE([LIBX11], [x11], [1.1.0])
XDT_CHECK_PACKAGE([XXF86VM], [xxf86vm], [1.0.0])
XDT_CHECK_PACKAGE([XRANDR], [xrandr], [1.2.0])
dnl **************************************
dnl *** Optional support for Libnotify ***
......@@ -205,6 +207,7 @@ po/Makefile.in
dialogs/Makefile
dialogs/appearance-settings/Makefile
dialogs/accessibility-settings/Makefile
dialogs/display-settings/Makefile
dialogs/keyboard-settings/Makefile
dialogs/mouse-settings/Makefile
xfce4-settings-helper/Makefile
......
......@@ -3,5 +3,6 @@
SUBDIRS = \
appearance-settings \
accessibility-settings \
display-settings \
keyboard-settings \
mouse-settings
# $Id$
INCLUDES = \
-I${top_srcdir} \
-DDATADIR=\"$(datadir)\" \
-DSRCDIR=\"$(top_srcdir)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DG_LOG_DOMAIN=\"xfce4-display-settings\" \
$(PLATFORM_CPPFLAGS)
bin_PROGRAMS = \
xfce4-display-settings
xfce4_display_settings_SOURCES = \
main.c \
display-dialog_glade.h
xfce4_display_settings_CFLAGS = \
$(GTK_CFLAGS) \
$(GLIB_CFLAGS) \
$(GLADE_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
$(LIBXFCEGUI4_CFLAGS) \
$(XFCONF_CFLAGS) \
$(XRANDR_CFLAGS) \
$(XXF86VM_CFLAGS)
xfce4_displaye_settings_LDFLAGS = \
-no-undefined \
$(PLATFORM_LDFLAGS)
xfce4_display_settings_LDADD = \
$(GTK_LIBS) \
$(GLIB_LIBS) \
$(GLADE_LIBS) \
$(DBUS_GLIB_LIBS) \
$(LIBXFCEGUI4_LIBS) \
$(XFCONF_LIBS) \
$(XRANDR_LIBS) \
$(XXF86VM_LIBS)
if MAINTAINER_MODE
BUILT_SOURCES = \
display-dialog_glade.h
display-dialog_glade.h: display-dialog.glade
exo-csource --static --name=display_dialog_glade $< >$@
endif
desktopdir = $(datadir)/applications
desktop_in_files = xfce4-display-settings.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
settingsdir = $(datadir)/xfce4/settings-dialogs
settings_DATA = $(desktop_DATA)
@INTLTOOL_DESKTOP_RULE@
EXTRA_DIST = \
$(desktop_in_files) \
display-dialog.glade
DISTCLEANFILES = \
$(desktop_DATA)
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Mon Jul 14 21:24:09 2008 -->
<glade-interface>
<requires lib="xfce4"/>
<widget class="XfceTitledDialog" id="display-dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Xfce Display Settings</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="icon_name">video-display</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<property name="subtitle" translatable="yes">Configure the screen settings and configuration</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<widget class="GtkNotebook" id="notebook1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">6</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="spacing">12</property>
<property name="homogeneous">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkTreeView" id="devices-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="enable_search">False</property>
<property name="show_expanders">False</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkComboBox" id="screen-resolution">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="screen-refresh-rate">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="screen-rotation">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkHScale" id="screen-gamma">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0.10000000000000001 0.10000000000000001 10 0.10000000000000001 1 10</property>
<property name="digits">2</property>
<property name="value_pos">GTK_POS_RIGHT</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">R_esolution:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Re_fresh rate:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Ro_tation:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Ga_mma:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Display Mode</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="tab_fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button-apply">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-apply</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button-close">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
/*
* Copyright (c) 2008 Nick Schermer <nick@xfce.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <glade/glade.h>
#include <libxfcegui4/libxfcegui4.h>
#include <libxfce4util/libxfce4util.h>
#include <xfconf/xfconf.h>
#include <X11/extensions/randr.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/xf86vmode.h>
#include "display-dialog_glade.h"
#define IS_STRING(string) (string != NULL && *string != '\0')
enum
{
COLUMN_MONITOR_NAME,
COLUMN_MONITOR_ICON,
COLUMN_MONITOR_ID,
N_MONITOR_COLUMNS
};
enum
{
COLUMN_COMBO_NAME,
COLUMN_COMBO_VALUE,
N_COMBO_COLUMNS
};
/* xrandr rotation name conversion */
typedef struct {
Rotation rotation;
const gchar *name;
} RotationTypes;
static const RotationTypes rotation_names[] =
{
{ RR_Rotate_0, N_("Normal") },
{ RR_Rotate_90, N_("Left") },
{ RR_Rotate_180, N_("Inverted") },
{ RR_Rotate_270, N_("Right") }
};
/* option entries */
static gboolean opt_version = FALSE;
static GOptionEntry option_entries[] =
{
{ "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, N_("Version information"), NULL },
{ NULL }
};
/* global xfconf channel */
static XfconfChannel *display_channel;
/* active xrandr configuration */
XRRScreenConfiguration *screen_config = NULL;
static void
display_setting_populate_rotation (GladeXML *gxml)
{
GtkTreeModel *model;
GtkWidget *combobox;
Rotation rotations;
Rotation current_rotation;
guint active, i;
GtkTreeIter iter;
/* get the combo box store and clear it */
combobox = glade_xml_get_widget (gxml, "screen-rotation");
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
gtk_list_store_clear (GTK_LIST_STORE (model));
/* get the active and possible rotations */
rotations = XRRConfigRotations (screen_config, &current_rotation);
/* test and append rotations */
for (active = i = 0; i < G_N_ELEMENTS (rotation_names); i++)
{
if ((rotations & rotation_names[i].rotation) != 0)
{
/* insert in store */
gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, i, COLUMN_COMBO_NAME, _(rotation_names[i].name),
COLUMN_COMBO_VALUE, rotation_names[i].rotation, -1);
/* get active rotation */
if (rotation_names[i].rotation == current_rotation)
active = i;
}
}
/* set the active item */
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), active);
}
static void
display_setting_populate_refresh_rates (GladeXML *gxml,
gint selected_size)
{
GtkTreeModel *model;
GtkWidget *combobox;
GtkTreeIter iter;
gshort *rates, current_rate;
gshort current_diff, diff = G_MAXSHORT;
gint active, n, nrates;
gchar *string;
/* get the combo box store and clear it */
combobox = glade_xml_get_widget (gxml, "screen-refresh-rate");
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
gtk_list_store_clear (GTK_LIST_STORE (model));
/* get refresh rates for this resolution */
rates = XRRConfigRates (screen_config, selected_size, &nrates);
current_rate = XRRConfigCurrentRate (screen_config);
/* insert in store */
for (active = n = 0; n < nrates; n++)
{
/* create string and insert into the store */
string = g_strdup_printf ("%d %s", rates[n], _("Hz"));
gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, n, COLUMN_COMBO_NAME, string, COLUMN_COMBO_VALUE, rates[n], -1);
g_free (string);
/* get the active item closest to the current diff */
current_diff = ABS (rates[n] - current_rate);
/* store active size */
if (diff > current_diff)
{
active = n;
diff = current_diff;
}
}
/* select the active resolution */
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), active);
}
static void
display_setting_populate_resolutions (GladeXML *gxml)
{
GtkTreeModel *model;
GtkWidget *combobox;
GtkTreeIter iter;
SizeID current_size;
XRRScreenSize *sizes;
gint n, nsizes;
Rotation rotation;
gchar *string;
/* get the combo box store and clear it */
combobox = glade_xml_get_widget (gxml, "screen-resolution");
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
gtk_list_store_clear (GTK_LIST_STORE (model));
/* get current reolution and list or possible resolutions */
sizes = XRRConfigSizes (screen_config, &nsizes);
current_size = XRRConfigCurrentConfiguration (screen_config, &rotation);
/* insert in store */
for (n = 0; n < nsizes; n++)
{
/* insert resultion in to store */
string = g_strdup_printf ("%d x %d", sizes[n].width, sizes[n].height);
gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, n, 0, string, 1, n, -1);
g_free (string);
/* select active resolution */
if (n == current_size)
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
}
}
static void
display_settings_populate_treeview (GladeXML *gxml)
{
GtkWidget *treeview;
GtkListStore *store;
GdkDisplay *display;
gint n, nscreens;
Display *xdisplay;
XF86VidModeMonitor monitor;
gchar *name;
GtkTreePath *path;
GtkTreeSelection *selection;
/* create a new list store */
store = gtk_list_store_new (N_MONITOR_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
/* get the default display */
display = gdk_display_get_default ();
/* get the number of screens */
nscreens = gdk_display_get_n_screens (display);
/* get the x display */
xdisplay = gdk_x11_display_get_xdisplay (display);
/* walk the screens on this display */
for (n = 0; n < nscreens; n++)
{
/* get the monitor information from x */
if (XF86VidModeGetMonitor (xdisplay, n, &monitor) == True)
{
/* get a suitable name for in the treeview */
if (IS_STRING (monitor.model) && IS_STRING (monitor.vendor)
&& strcasestr (monitor.model, monitor.vendor) == NULL)
name = g_strdup_printf ("%s %s", monitor.vendor, monitor.model);
else if (IS_STRING (monitor.model))
name = g_strdup (monitor.model);
else
name = g_strdup_printf ("%s %d", _("Screen"), n + 1);
/* insert in the store */
gtk_list_store_insert_with_values (store, NULL, n,
COLUMN_MONITOR_ID, n,
COLUMN_MONITOR_ICON, "video-display",
COLUMN_MONITOR_NAME, name, -1);
/* cleanup */
g_free (name);
}
}
/* set the treeview model */
treeview = glade_xml_get_widget (gxml, "devices-treeview");
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
g_object_unref (G_OBJECT (store));
/* select first item */
path = gtk_tree_path_new_first ();
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
/* treeview has initial focus */
gtk_widget_grab_focus (treeview);