Compare commits

...

136 Commits

Author SHA1 Message Date
Frédéric Péters
30dcaf167a Fixed window manager configure check (GNOME bug 619326) 2010-05-21 23:02:45 +02:00
Thomas Wood
67bf5e2a9d default-applications: add the correct CFLAGS/LIBS
Add the correct CFLAGS and LIBS entries to allow the default-applications
application to compile and link successfully.
2010-05-04 22:47:45 +01:00
Thomas Wood
48cc93d712 Revert "[about-me] add a --socket option"
This reverts commit 567c780dcc.
2010-05-04 22:18:53 +01:00
Thomas Wood
847a50d73e Revert "[display] add a --socket option"
This reverts commit e94adcf7e9.
2010-05-04 22:18:13 +01:00
Thomas Wood
7a64835a58 shell: make sure the main view can always be made smaller
This prevents the situation where the main view was made larger, but then
cannot shrink because it is inside a viewport which does not request the
smaller size.
2010-04-22 11:50:46 +01:00
Thomas Wood
5750eb1e4c network: remove debugging output 2010-04-22 11:43:56 +01:00
Thomas Wood
aed85d8398 network: make sure widgets are available before updating status
Some widgets were being updated before they were created.
2010-04-22 11:43:35 +01:00
Thomas Wood
f25f9353c5 network: Move the "Delete Location" button to the top of the panel
In single window mode, it makes more sense for the Delete Location button
to be next to the list of locations.
2010-04-22 10:51:12 +01:00
Thomas Wood
7118c996c5 network: remove the unnecessary GtkNotebook from the panel
The Notebook only had one page and displayed no tabs, so was not used in
any meaningful way. It also added an unnecessary extra frame.
2010-04-22 10:50:08 +01:00
Thomas Wood
0fe941396d shell: cancel the startup notification when raising another instance
GTK+ only automatically cancels startup notification when the first window
is shown. Therefore, when the shell is raising an existing window rather
than creating a new one, the startup notification should be cancelled
manually.
2010-04-21 11:34:17 +01:00
Thomas Wood
52692ab40f shell: don't specify a font size for the title
The title for each panel should not have a hard coded size
2010-04-21 11:23:47 +01:00
Thomas Wood
e57f859191 network: Remove socket option
The socket option is now redundant since this protocol is no longer used in
the shell
2010-04-21 11:18:31 +01:00
Thomas Wood
a108939848 keyboard: Remove socket option
The socket option is now redundant since this protocol is no longer used in
the shell
2010-04-21 11:01:26 +01:00
Thomas Wood
e3f56d166c appearance: Remove socket option
The socket option is now redundant since this protocol is no longer used in
the shell
2010-04-21 10:57:30 +01:00
Thomas Wood
127b87dd76 mouse: Remove socket option
The socket option is now redundant since this protocol is no longer used in
the shell
2010-04-21 10:53:50 +01:00
Thomas Wood
4f237fec30 mouse: initialise the gconf monitors and accessibility page in the panel
Complete the missing setup steps in the control center panel so that
changes are actually stored in gconf.
2010-04-21 10:46:13 +01:00
Thomas Wood
c9a72e10d8 shell: switch to the specified panel when activating an existing instance
Set the libunqnie message data for the "raise" function to that of the
panel id specified on the command line.
2010-04-14 16:13:32 +01:00
Thomas Wood
63c16a4204 shell: include cc-shell-marshal.list in distribution 2010-04-14 14:02:37 +01:00
Thomas Wood
2a49ad7f5d shell: add CcShellModel to store the list of available panels
CcShellModel is a GtkListStore subclass that implements storing the list of
available control center panels.
2010-04-13 17:16:48 +01:00
Thomas Wood
7f1303e4a2 shell: split iconview behaviour and category views into separate objects
CcShellItemView is a GtkIconView derived object that modifies the the
item activation behaviour to that required by the shell. In particular,
items can be activated by a single click, and double or triple clicks are
ignored. It also expects a particular model to be set and emits a signal
containing relevant data when an item is activated.

CcShellCategoryView is a widget that provides the category groups for the
main overview of the shell. It consists of a title and a CcSehllItemView.
2010-04-12 23:20:50 +01:00
Thomas Wood
f991e615be shell: Enable startup notification when starting executable panels
Use GDesktopAppInfo to launch panels to ensure startup notification is
used when possible to give feed back that a panel is starting.
2010-03-31 17:25:38 +01:00
Thomas Wood
fbb26e2477 shell: Add single instance support
Use libunique to add single instance support to the shell to prevent
multiple instances of the shell being started. If a second instance is
started it will raise the existing instance and quit.
2010-03-24 16:08:04 +00:00
Thomas Wood
3fd64e28cd keyboard: initialise the panel only when first activated
This improves the shell start up time by not initialising the panel at
the time the extension is loaded. Instead, initialisation can be done when
the panel is first activated.
2010-03-23 10:07:09 +00:00
Thomas Wood
9c38586a28 appearance: initialise the panel only when first activated
This improves the shell start up time by not initialising the panel at
the time the extension is loaded. Instead, initialisation can be done when
the panel is first activated.
2010-03-23 10:02:53 +00:00
Thomas Wood
c509d40023 libgnome-control-center-extension: make sure UIDIR is defined 2010-03-23 10:00:37 +00:00
Thomas Wood
daebff9dcd shell: add a timer to profile panel loading 2010-03-23 10:00:06 +00:00
Thomas Wood
c2a7f0106a Move CcShell object into libgnome-control-center-extension
The CcShell object needs to be in libgnome-control-center-extension so that
its symbols can be resolved by applications and libraries using
libgnome-control-center-extension.
2010-03-17 14:21:37 +00:00
Thomas Wood
88f7b25422 shell: Hide the search entry when in a capplet
The search entry only searches the list of capplets, not in individual
settings panels, therefore do not show it when display a settings panel.
2010-03-10 18:35:53 +00:00
Thomas Wood
f3925cd3c0 shell: don't open quite so wide by default 2010-03-04 15:13:54 +00:00
Thomas Wood
027f0e1552 Add a "shell" property to CcPanel
The shell property on CcPanel allows panels to access the shell they are
parented in. This means panels can switch the user to a new panel if
required.
2010-02-26 12:02:25 +00:00
Thomas Wood
16b135172c shell: Add public functions for setting current panel and title 2010-02-25 14:34:39 +00:00
Thomas Wood
4e70e91f7f shell: add an object to represent the shell
The CcShell object represents the control center shell. This will allow
panels to access certain aspects of the shell, such as switching to
different panels.
2010-02-25 11:08:19 +00:00
Thomas Wood
f7d10e3e29 shell: fix compiler warnings by casting to correct type 2010-02-24 22:15:15 +00:00
Thomas Wood
23b6c8e7c7 shell: start the panel specified on the command line
Start the panel specified by the .desktop file.
2010-02-24 21:27:36 +00:00
Thomas Wood
ff713287c8 shell: add a clear button the the search entry 2010-02-24 16:40:30 +00:00
Thomas Wood
85c8273f39 shell: Add a title inside the capplet area instead of using the titlebar 2010-02-24 16:40:10 +00:00
Thomas Wood
c28435ae98 don't include the accessibility capplet 2010-02-17 16:17:58 +00:00
Thomas Wood
21f9d16591 appearance: initialise a variable to prevent segmentation fault 2010-02-17 15:20:03 +00:00
Thomas Wood
4a11907664 Revert to showing the capplets in the menu by default
Show the normal capplets by default, since some capplets really do need
hiding by default.


Revert "Switch to only showing the shell menu item by default and hiding capplets"

This reverts commit 9ec8f36679.

Revert "Include "NoDisplay" items in the shell view"

This reverts commit 2fb9e62d07.
2010-02-17 14:51:00 +00:00
Thomas Wood
e927dae75c po: update POTFILES 2010-02-12 18:00:56 +00:00
Thomas Wood
937da8668e shell: fix distclean 2010-02-12 17:43:58 +00:00
Thomas Wood
6d52caec19 Add "pointer" module that has Mouse, Touchpad and Accessibility settings 2010-02-12 16:27:18 +00:00
Thomas Wood
5807382748 shell: fix typo 2010-02-12 16:16:36 +00:00
Thomas Wood
2fb9e62d07 Include "NoDisplay" items in the shell view
This allows the items to be hidden by default in menus.
2010-02-12 14:59:26 +00:00
Thomas Wood
dda833f2dd CCPanel requires GTK+ so add it to the #includes in the header 2010-02-12 14:59:26 +00:00
Thomas Wood
9ec8f36679 Switch to only showing the shell menu item by default and hiding capplets 2010-02-11 17:30:43 +00:00
Thomas Wood
544e03e1e8 Optionally allow the "userpasswd" utility to be used in about-me
Based on a patch from Fedora:

http://cvs.fedoraproject.org/viewvc/F-12/control-center/gnome-control-center-2.25.2-passwd.patch?revision=1.4&view=markup
2010-02-11 15:49:08 +00:00
Thomas Wood
2d33386995 Add support for mutter as a replacement requirement for metacity 2010-02-11 14:31:08 +00:00
Thomas Wood
2de6be9de1 Fix building about-me capplet 2010-02-11 12:36:15 +00:00
William Jon McCann
eb3dd23f6e [shell] Make the desktop file name match the process name
This ensures that WM_CLASS will be set properly.  See
http://live.gnome.org/GnomeShell/ApplicationBased
2010-02-02 00:33:41 -05:00
William Jon McCann
b4bd938ace [shell] Use gnome-control-center for icon in builder file
Since we use that icon in the desktop file.
2010-02-02 00:22:41 -05:00
William Jon McCann
d91de9a335 Fix include dir definition 2010-01-31 20:45:39 -05:00
William Jon McCann
1929e0fe3b [appearance] Fix a leak 2010-01-31 19:15:36 -05:00
Thomas Wood
762c4a59cc [default-applications] remove socket id option 2010-01-31 11:40:22 +00:00
Thomas Wood
e231655842 [shell] fix include of gnome-menus header
The gnome-menus package provides the full path to the header, so no
subpath should be included within the #include.
2010-01-31 11:04:34 +00:00
Thomas Wood
808567a6d0 [shell] make sure the control center menu is available before loading it 2010-01-31 10:35:04 +00:00
Thomas Wood
bc5bfe9a44 [shell] ensure the toolbar height remains constant
Even when the "All Settings" button is not visible, force the toolbar to
be the same height as if it was visible by adding the button and the
search entry to a size group.
2010-01-30 11:55:32 +00:00
Thomas Wood
fc0c6eff31 [shell] move panels hash table into data struct and ensure it is destroyed 2010-01-30 11:50:52 +00:00
Thomas Wood
90f8b5b90f [shell] mark window title string as translatable 2010-01-30 11:38:03 +00:00
Thomas Wood
a635c4b9c4 [shell] make sure the home button always appears when needed 2010-01-30 11:35:01 +00:00
Thomas Wood
7186088b33 [shell] ensure the pango layout is disposed 2010-01-30 10:49:35 +00:00
Thomas Wood
58961babdc [shell] use a common string as the search and filter target
Use the same search target string in the filter function as the
string displayed in the search result renderer.
2010-01-30 10:40:16 +00:00
Thomas Wood
82da73f3c1 [shell] improve search results by matching on and displaying descriptions
Show the reason for match in the search results by highlighting the
search term in bold within the searched string.
2010-01-29 17:41:32 +00:00
Bastien Nocera
2545c082ac [about-me] Fix fingerprint name on 2nd page
We were never changing the enrollment page's label to match
the selected fingerprint.
2010-01-29 16:14:25 +00:00
Thomas Wood
6769441a7c [shell] use only one model to store the list of capplets
Use a model filter for each category icon view.

Fixes activating search item results.
2010-01-29 11:19:58 +00:00
Thomas Wood
50273f97fe [shell] make sure multiple searches work correctly
Fix the search function by using a fixed number for each of the shell's
notebook pages. This prevents the search page being removed by mistake
after the user is returned to the home screen.
2010-01-29 10:48:26 +00:00
Thomas Wood
f0eec36f4d [shell] clean up compiler warnings
Mark functions as static when they do not need to be used outside the file
scope.

GCC warns about a missing initialiser for iter in item_activated_cb, so
Remove the need to initialise the iter bychecking whether it is valid from
the return value of gtk_tree_model_get_iter().
2010-01-29 10:30:05 +00:00
William Jon McCann
02a1531090 Fix distcheck 2010-01-27 04:02:34 -05:00
William Jon McCann
bfca136297 [network] Port network panel to new system 2010-01-27 03:36:57 -05:00
William Jon McCann
eb2a57311b Make sure to mark font page as active 2010-01-27 03:35:22 -05:00
William Jon McCann
6d71b55626 Fix distcheck 2010-01-26 23:49:24 -05:00
William Jon McCann
71dda58296 [appearance] Port the font configuration to new system 2010-01-26 23:42:42 -05:00
William Jon McCann
824cd26389 [appearance] Handle dialog responses 2010-01-26 19:33:56 -05:00
William Jon McCann
7e2f3c637e [appearance] Port the theme customization dialog 2010-01-26 19:33:56 -05:00
William Jon McCann
ace120e724 Make new thumbnailer use a helper process
This avoids nasty interactions with open file descriptors and
the gtk main loop.
2010-01-26 19:33:51 -05:00
William Jon McCann
4c13a994ec Add objectized theme thumbnailer 2010-01-26 15:39:01 -05:00
William Jon McCann
e63e737f55 [appearance] Port theme page code to the extension 2010-01-26 03:38:20 -05:00
Bastien Nocera
bfd349f0b9 Load extensions from the source tree
If there's none installed system-wide
2010-01-19 14:37:19 +00:00
Bastien Nocera
aae816fe96 Add check on whether we want to look for UI files in the sources 2010-01-19 14:36:49 +00:00
Bastien Nocera
d7c4f6d509 Support more types of Icon in .desktop files
Properly load desktop files that contain either absolute file paths,
or the name of a file with a suffix.

Also print out the error message properly when failing to load
an icon.
2010-01-19 13:57:59 +00:00
Bastien Nocera
2d8c22d766 Allow loading the UI from the source dir 2010-01-19 13:57:39 +00:00
William Jon McCann
26e9ffab84 [display] Only start doing stuff when the panel is active
This prevents the problem where the labeller etc start before
the panel is active.
2010-01-18 05:30:27 -05:00
William Jon McCann
c0baaca4ed Add ability for panels and pages to know if they are active or not
This will allow them to know if they should be doing stuff or not.
2010-01-18 05:11:05 -05:00
William Jon McCann
f4f68190b6 [display] Port display to extension system 2010-01-18 03:34:28 -05:00
William Jon McCann
e6c061012a Move common helper library into the extension library directory
This makes the build dependencies much saner.
2010-01-18 01:02:56 -05:00
William Jon McCann
6fc446b61f [keybindings] remove this as a top level panel
It is now part of the keyboard panel
2010-01-18 00:59:53 -05:00
William Jon McCann
148e86e954 [mouse] Port mouse to extension system 2010-01-18 00:59:48 -05:00
William Jon McCann
f1c215ef6d Add a library for use by extensions
This not only makes it easier to create extensions but also makes
the module symbol loading and object registration work much better.
2010-01-17 15:07:15 -05:00
William Jon McCann
0c605ffbfc [keyboard] Add the keybindings capplet as a page
It makes a lot more sense here instead of having two keyboard
related panels.
2010-01-17 01:27:26 -05:00
William Jon McCann
de38485c5f [keyboard] Convert to CcPage 2010-01-16 22:44:23 -05:00
William Jon McCann
ce6e1fe0b1 [default-applications] Don't build 2010-01-16 21:48:44 -05:00
William Jon McCann
a31f54e363 [a11y] Rename to Universal Access
And move to System category.
2010-01-16 21:38:03 -05:00
William Jon McCann
7f093ccc12 [windows] Don't build windows control panel 2010-01-16 21:31:38 -05:00
William Jon McCann
f2eea40632 [shell] Don't include both Personal and Look & Feel
It isn't really clear what the distinction is.
2010-01-16 21:17:35 -05:00
William Jon McCann
ccff1ff300 [appearance] Make sure to load the deleted flag 2010-01-16 06:10:45 -05:00
William Jon McCann
eabb94f9a8 [appearance] Select the next item when removing the current 2010-01-16 06:02:39 -05:00
William Jon McCann
f7cf140b9b [appearance] Set some default values for saving 2010-01-16 05:39:22 -05:00
William Jon McCann
1b9ec60b0d [appearance] Check for NULL values 2010-01-16 05:29:57 -05:00
William Jon McCann
3a47fedc6c Never use a horizontal scrollbar 2010-01-16 05:08:57 -05:00
William Jon McCann
702b08b2cc Increase border width of toolbar to 5 2010-01-16 05:08:57 -05:00
William Jon McCann
bf072998d0 Add extension point support
Keyboard and some of appearance capplet have been ported to it.
2010-01-16 05:08:01 -05:00
William Jon McCann
40e7e4f3c6 Add more warnings to the build 2010-01-16 05:08:00 -05:00
William Jon McCann
f0767d491e Remove libslab
libslab is not used by the shell rewrite.
2010-01-16 05:07:54 -05:00
William Jon McCann
871006b60b Always build the shell 2010-01-16 03:42:52 -05:00
William Jon McCann
e066ce30f3 [common] Don't include glib/gi18n.h in a header
This interferes with modules that may need to use glib/gi18n-lib.h
2010-01-16 03:42:52 -05:00
Thomas Wood
b360a31d86 [shell] implement search filter feature
Allow the user to filter the list by typing a search term in the search
box.
2010-01-14 15:35:15 +00:00
Thomas Wood
d4f3cb183d [shell] set the new title on the window after the notebook has switched
Prevent the window title being set until the capplet has loaded and been
shown. This also prevents a window title being set if the capplet does not
support embedding.
2010-01-14 12:08:44 +00:00
Thomas Wood
52e62106fc [shell] add a struct to store global data 2010-01-14 12:03:09 +00:00
Thomas Wood
be122f8254 [shell] hide the All Settings button when showing all settings
The All Settings button is unnecessary when the user is already in the view
that displays the available capplets.
2010-01-14 11:10:04 +00:00
Thomas Wood
c0cbb585d7 [shell] add a mnemonic accelerator to the All Setting button 2010-01-14 11:07:49 +00:00
Thomas Wood
67619e3bd7 [shell] use the window title rather than a separate header label
Remove the header label and use the window title to display the current
capplet's name.
2010-01-14 09:45:29 +00:00
Thomas Wood
2249ec8551 [shell] fix compiler warning
Cast the callback function to the correct type to prevent a compiler
warning
2010-01-14 09:36:24 +00:00
Thomas Wood
eb90411b3a [shell] simplify the toolbar packing
Remove the unnecessary containers and don't hide the applet title label when
not in use. Keeping the title label visible ensures the alignment of the
search box is always correct.
2010-01-13 12:11:53 +00:00
Thomas Wood
e6b366f84d [shell] fix installation
Install the UI file into the correct directory and ensure the binary is
actually installed.
2010-01-13 11:51:50 +00:00
Thomas Wood
ab6c567296 [keyboard] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-12 12:08:47 +00:00
Thomas Wood
92c9f7e7ac [keyboard] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-12 12:08:41 +00:00
Thomas Wood
e94adcf7e9 [display] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-12 12:08:29 +00:00
William Jon McCann
a63ed735c6 [shell] Center title label with respect to window
Change the design from using breadcrumbs to centering the title
with respect to the top level window.  This probably makes more
sense since we expect panels to hopefully be only one level deep.
2010-01-11 13:40:54 -05:00
William Jon McCann
cc9efdf41e [shell] Add "All" to Settings button 2010-01-11 13:36:01 -05:00
William Jon McCann
4e97e65ab6 [shell] Add window title and icon
Use System Settings and preferences-system.
2010-01-11 12:01:01 -05:00
William Jon McCann
9074de36c8 [shell] Install menu and ui files 2010-01-11 11:49:05 -05:00
William Jon McCann
040ad988e3 [shell] Need to initialize lists 2010-01-11 11:48:19 -05:00
William Jon McCann
b7efebc809 [shell] Check return code to make sure UI is loaded 2010-01-11 11:47:48 -05:00
Thomas Wood
3838b65f1c [shell] switch to the capplet after a delay
If the notebook is switched to the capplet page too quickly, a black filled
rectangle appears briefly.

This should be fixed properly in the future by adjusting the capplets so
that they only plug into the socket when fully ready.
2010-01-11 16:34:15 +00:00
Thomas Wood
ba814981bc [keybinding] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-11 14:48:16 +00:00
Thomas Wood
9125c030fd [default-applications] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-11 11:19:03 +00:00
Thomas Wood
567c780dcc [about-me] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-11 11:06:21 +00:00
Thomas Wood
698c637357 [shell] add author information 2010-01-11 09:41:51 +00:00
Thomas Wood
61bb2ef2fa [shell] remove use of deprecated functions 2010-01-11 09:41:41 +00:00
Thomas Wood
f22ed32a80 [shell] ensure there is no selection when the user switches back to icons
Remove the selection from all the icon views after a capplet has been
activated so that no item is selected if the user switches back to the icon
views.
2010-01-11 09:41:19 +00:00
Thomas Wood
f119dfb98d [shell] implement single click to "activate" items
Connect to button-release-event of the icon views to enable the user to
use a single click to activate items.
2010-01-11 09:41:11 +00:00
Thomas Wood
0305603d1f [shell] increase the padding around the toolbar
Since we want the button borders to be visible all the time (unlike normal
toolbar buttons) we should add some extra spacing around them to prevent
too much visual noise against the toolbar border.
2010-01-11 09:41:03 +00:00
Thomas Wood
40e8b77253 [shell] Group the icons by category
This involves separating icon views per category and using a label as the
heading above each one.
2010-01-11 09:40:51 +00:00
Thomas Wood
be6fa081f1 Add a new experimental shell that uses GtkSocket to capture capplets 2010-01-11 09:40:34 +00:00
Thomas Wood
22945de8be [mouse] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-11 09:40:20 +00:00
Thomas Wood
b91106c128 [appearance] add a --socket option
Allow embedding in another application by adding a --socket option to
specify the ID of an window.
2010-01-11 09:38:33 +00:00
188 changed files with 24784 additions and 15111 deletions

View File

@@ -1,13 +1,25 @@
SUBDIRS = po libwindow-settings capplets font-viewer help
DIST_SUBDIRS = po libwindow-settings capplets font-viewer help libslab shell typing-break
NULL =
if HAVE_LIBSLAB_DEPS
SUBDIRS += libslab
endif
SUBDIRS = \
po \
libwindow-settings \
libgnome-control-center-extension \
capplets \
shell \
font-viewer \
help \
$(NULL)
if HAVE_LIBSLAB
SUBDIRS += shell
endif
DIST_SUBDIRS = \
po \
libwindow-settings \
libgnome-control-center-extension \
capplets \
shell \
font-viewer \
help \
typing-break \
$(NULL)
if HAVE_TYPING_BREAK
SUBDIRS += typing-break

View File

@@ -1,20 +1,17 @@
NULL =
SUBDIRS = \
common \
accessibility \
appearance \
default-applications \
keybindings \
keyboard \
mouse \
network \
windows
$(NULL)
DIST_SUBDIRS = \
common \
accessibility \
appearance \
default-applications \
keybindings \
keyboard \
mouse \
network \

View File

@@ -31,8 +31,8 @@ marshal.c: fprintd-marshal.list
if BUILD_ABOUTME
bin_PROGRAMS = gnome-about-me
gnome_about_me_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(LIBEBOOK_LIBS)
gnome_about_me_LDFLAGS = -export-dynamic
gnome_about_me_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(LIBEBOOK_LIBS) $(EXTENSION_LIBS) $(EXTENSION_COMMON_LIBS)
gnome_about_me_LDFLAGS = -export-dynamic $(EXTENSION_LIBTOOL_FLAGS)
@INTLTOOL_DESKTOP_RULE@
@@ -43,6 +43,7 @@ uidir = $(pkgdatadir)/ui
ui_DATA = $(ui_files)
INCLUDES = \
$(EXTENSION_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(LIBEBOOK_CFLAGS) \
-DDATADIR="\"$(datadir)\"" \

View File

@@ -301,13 +301,27 @@ selected_finger (GtkBuilder *dialog)
static void
finger_radio_button_toggled (GtkToggleButton *button, EnrollData *data)
{
GtkBuilder *dialog = data->dialog;
char *msg;
data->finger = selected_finger (data->dialog);
msg = g_strdup_printf (finger_str_to_msg (data->finger, data->is_swipe), data->name);
gtk_label_set_text (GTK_LABEL (WID("enroll-label")), msg);
g_free (msg);
}
static void
finger_combobox_changed (GtkComboBox *combobox, EnrollData *data)
{
GtkBuilder *dialog = data->dialog;
char *msg;
data->finger = selected_finger (data->dialog);
msg = g_strdup_printf (finger_str_to_msg (data->finger, data->is_swipe), data->name);
gtk_label_set_text (GTK_LABEL (WID("enroll-label")), msg);
g_free (msg);
}
static void

View File

@@ -821,10 +821,14 @@ about_me_button_clicked_cb (GtkDialog *dialog, gint response_id, GnomeAboutMe *m
static void
about_me_passwd_clicked_cb (GtkWidget *button, GnomeAboutMe *me)
{
#ifdef HAVE_USERPASSWD
g_spawn_command_line_async ("/usr/bin/userpasswd", NULL);
#else
GtkBuilder *dialog;
dialog = me->dialog;
gnome_about_me_password (GTK_WINDOW (WID ("about-me-dialog")));
#endif
}
static void

View File

@@ -1,6 +1,6 @@
bin_PROGRAMS = gnome-at-properties
gnome_at_properties_LDADD = $(AT_CAPPLET_LIBS) $(GNOMECC_CAPPLETS_LIBS) $(top_builddir)/capplets/common/libcommon.la
gnome_at_properties_LDADD = $(AT_CAPPLET_LIBS) $(GNOMECC_CAPPLETS_LIBS) $(top_builddir)/libgnome-control-center-extension/libcommon.la
gnome_at_properties_SOURCES = \
main.c
gnome_at_properties_LDFLAGS = -export-dynamic
@@ -19,12 +19,15 @@ pixmap_DATA = \
uidir = $(pkgdatadir)/ui
ui_DATA = at-enable-dialog.ui
INCLUDES = $(AT_CAPPLET_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DUIDIR=\""$(uidir)"\" \
-DPIXMAPDIR=\""$(pixmapdir)"\" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\""
INCLUDES = \
$(AT_CAPPLET_CFLAGS) \
-I$(top_srcdir)/libgnome-control-center-extension/ \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DUIDIR=\""$(uidir)"\" \
-DPIXMAPDIR=\""$(pixmapdir)"\" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)
EXTRA_DIST = $(ui_DATA) $(pixmap_DATA)

View File

@@ -1,12 +1,12 @@
[Desktop Entry]
_Name=Assistive Technologies
_Comment=Choose which accessibility features to enable when you log in
_Name=Universal Access
_Comment=Change settings in order to make the system easier to use
Exec=gnome-at-properties
Icon=preferences-desktop-accessibility
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;
Categories=GNOME;GTK;Settings;X-GNOME-SystemSettings;
OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center

View File

@@ -1,17 +1,86 @@
NULL =
SUBDIRS = data
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = appearance
INCLUDES = \
$(METACITY_CFLAGS) \
-I$(top_srcdir)/libgnome-control-center-extension \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(FONT_CAPPLET_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
-DGNOMECC_PIXMAP_DIR="\"$(pixmapdir)\"" \
-DWALLPAPER_DATADIR="\"$(wallpaperdir)\""
AM_CFLAGS = -DGNOME_DESKTOP_USE_UNSTABLE_API
noinst_LTLIBRARIES = libappearance-common.la
bin_PROGRAMS = gnome-appearance-properties
libappearance_common_la_SOURCES = \
theme-installer.c \
theme-installer.h \
theme-save.c \
theme-save.h \
theme-util.c \
theme-util.h
ccmodulesdir = $(EXTENSIONSDIR)
ccmodules_LTLIBRARIES = libappearance.la
libappearance_la_SOURCES = \
appearance-module.c \
cc-backgrounds-monitor.h \
cc-backgrounds-monitor.c \
cc-background-item.h \
cc-background-item.c \
cc-background-page.h \
cc-background-page.c \
cc-theme-save-dialog.h \
cc-theme-save-dialog.c \
cc-theme-customize-dialog.h \
cc-theme-customize-dialog.c \
cc-theme-page.h \
cc-theme-page.c \
cc-font-common.h \
cc-font-common.c \
cc-font-page.h \
cc-font-page.c \
cc-font-details-dialog.h \
cc-font-details-dialog.c \
cc-appearance-panel.h \
cc-appearance-panel.c \
$(NULL)
libappearance_la_LDFLAGS = \
$(EXTENSION_LIBTOOL_FLAGS) \
$(NULL)
libappearance_la_LIBADD = \
libappearance-common.la \
$(EXTENSION_LIBS) \
$(FONT_CAPPLET_LIBS) \
$(EXTENSION_COMMON_LIBS) \
$(NULL)
libappearance_la_CFLAGS = \
$(EXTENSION_CFLAGS) \
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
libappearance_la_LIBTOOLFLAGS = --tag=disable-static
gnome_appearance_properties_SOURCES = \
appearance.h \
appearance-desktop.c \
appearance-desktop.h \
appearance-font.c \
appearance-font.h \
appearance-main.c \
appearance-themes.c \
appearance-themes.h \
appearance-style.c \
@@ -24,37 +93,21 @@ gnome_appearance_properties_SOURCES = \
gnome-wp-item.h \
gnome-wp-xml.c \
gnome-wp-xml.h \
theme-installer.c \
theme-installer.h \
theme-save.c \
theme-save.h \
theme-util.c \
theme-util.h
AM_CFLAGS = -DGNOME_DESKTOP_USE_UNSTABLE_API
appearance-main.c
gnome_appearance_properties_LDADD = \
libappearance-common.la \
$(top_builddir)/libwindow-settings/libgnome-window-settings.la \
$(top_builddir)/capplets/common/libcommon.la \
$(top_builddir)/libgnome-control-center-extension/libcommon.la \
$(GNOMECC_CAPPLETS_LIBS) \
$(FONT_CAPPLET_LIBS) \
$(METACITY_LIBS)
gnome_appearance_properties_LDFLAGS = -export-dynamic
gtkbuilderdir = $(pkgdatadir)/ui
uidir = $(pkgdatadir)/ui
pixmapdir = $(pkgdatadir)/pixmaps
wallpaperdir = $(datadir)/gnome-background-properties
INCLUDES = \
$(METACITY_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(FONT_CAPPLET_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_GTKBUILDER_DIR="\"$(gtkbuilderdir)\"" \
-DGNOMECC_PIXMAP_DIR="\"$(pixmapdir)\"" \
-DWALLPAPER_DATADIR="\"$(wallpaperdir)\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
-include $(top_srcdir)/git.mk

View File

@@ -192,10 +192,11 @@ wp_add_image (AppearanceData *data,
}
else
{
item = gnome_wp_item_new (filename, data->wp_hash, data->thumb_factory);
item = gnome_wp_item_new (filename, data->thumb_factory);
if (item != NULL)
{
g_hash_table_insert (data->wp_hash, item->filename, item);
wp_props_load_wallpaper (item->filename, item, data);
}
}
@@ -999,7 +1000,7 @@ wp_load_stuffs (void *user_data)
item = g_hash_table_lookup (data->wp_hash, "(none)");
if (item == NULL)
{
item = gnome_wp_item_new ("(none)", data->wp_hash, data->thumb_factory);
item = gnome_wp_item_new ("(none)", data->thumb_factory);
if (item != NULL)
{
wp_props_load_wallpaper (item->filename, item, data);

View File

@@ -43,7 +43,7 @@ init_appearance_data (int *argc, char ***argv, GOptionContext *context)
activate_settings_daemon ();
/* set up the data */
uifile = g_build_filename (GNOMECC_GTKBUILDER_DIR, "appearance.ui",
uifile = g_build_filename (GNOMECC_UI_DIR, "appearance.ui",
NULL);
ui = gtk_builder_new ();
gtk_builder_add_from_file (ui, uifile, &err);
@@ -167,6 +167,7 @@ main (int argc, char **argv)
/* prepare the main window */
w = appearance_capplet_get_widget (data, "appearance_window");
capplet_set_icon (w, "preferences-desktop-theme");
gtk_widget_show_all (w);

View File

@@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>
#include "cc-appearance-panel.h"
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
cc_appearance_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -0,0 +1,258 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2010 Intel, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnomeui/gnome-desktop-thumbnail.h>
#include "cc-theme-page.h"
#include "cc-background-page.h"
#include "cc-font-page.h"
#include "cc-appearance-panel.h"
#define CC_APPEARANCE_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanelPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcAppearancePanelPrivate
{
GtkWidget *notebook;
CcPage *theme_page;
CcPage *background_page;
CcPage *font_page;
};
enum {
PROP_0,
};
static void cc_appearance_panel_class_init (CcAppearancePanelClass *klass);
static void cc_appearance_panel_init (CcAppearancePanel *appearance_panel);
static void cc_appearance_panel_finalize (GObject *object);
G_DEFINE_DYNAMIC_TYPE (CcAppearancePanel, cc_appearance_panel, CC_TYPE_PANEL)
static void
cc_appearance_panel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_appearance_panel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
#if 0
/* FIXME */
static void
install_theme (CcAppearancePanel *panel,
const char *filename)
{
GFile *inst;
GtkWidget *toplevel;
g_assert (filename != NULL);
inst = g_file_new_for_commandline_arg (filename);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
if (GTK_WIDGET_TOPLEVEL (toplevel)) {
gnome_theme_install (inst, GTK_WINDOW (toplevel));
} else {
gnome_theme_install (inst, NULL);
}
g_object_unref (inst);
}
#endif
static void
on_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num,
CcAppearancePanel *panel)
{
if (page_num == 0) {
g_object_set (panel,
"current-page",
panel->priv->theme_page,
NULL);
} else if (page_num == 1) {
g_object_set (panel,
"current-page",
panel->priv->background_page,
NULL);
} else {
g_object_set (panel,
"current-page",
panel->priv->font_page,
NULL);
}
}
static void
setup_panel (CcAppearancePanel *panel,
gboolean is_active)
{
static gboolean initialised = FALSE;
GtkWidget *label;
char *display_name;
if (initialised)
return;
initialised = TRUE;
panel->priv->notebook = gtk_notebook_new ();
g_signal_connect (panel->priv->notebook,
"switch-page",
G_CALLBACK (on_notebook_switch_page),
panel);
gtk_container_add (GTK_CONTAINER (panel), panel->priv->notebook);
gtk_widget_show (panel->priv->notebook);
panel->priv->theme_page = cc_theme_page_new ();
g_object_get (panel->priv->theme_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook), GTK_WIDGET (panel->priv->theme_page), label);
gtk_widget_show (GTK_WIDGET (panel->priv->theme_page));
panel->priv->background_page = cc_background_page_new ();
g_object_get (panel->priv->background_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook), GTK_WIDGET (panel->priv->background_page), label);
gtk_widget_show (GTK_WIDGET (panel->priv->background_page));
panel->priv->font_page = cc_font_page_new ();
g_object_get (panel->priv->font_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook), GTK_WIDGET (panel->priv->font_page), label);
gtk_widget_show (GTK_WIDGET (panel->priv->font_page));
g_object_set (panel,
"current-page", panel->priv->theme_page,
NULL);
}
static GObject *
cc_appearance_panel_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcAppearancePanel *appearance_panel;
appearance_panel = CC_APPEARANCE_PANEL (G_OBJECT_CLASS (cc_appearance_panel_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (appearance_panel,
"display-name", _("Appearance"),
"id", "gnome-appearance-properties.desktop",
NULL);
return G_OBJECT (appearance_panel);
}
static void
cc_appearance_panel_class_init (CcAppearancePanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_appearance_panel_get_property;
object_class->set_property = cc_appearance_panel_set_property;
object_class->constructor = cc_appearance_panel_constructor;
object_class->finalize = cc_appearance_panel_finalize;
g_type_class_add_private (klass, sizeof (CcAppearancePanelPrivate));
}
static void
cc_appearance_panel_class_finalize (CcAppearancePanelClass *klass)
{
}
static void
cc_appearance_panel_init (CcAppearancePanel *panel)
{
panel->priv = CC_APPEARANCE_PANEL_GET_PRIVATE (panel);
g_signal_connect (panel, "active-changed", G_CALLBACK (setup_panel),
NULL);
}
static void
cc_appearance_panel_finalize (GObject *object)
{
CcAppearancePanel *appearance_panel;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_APPEARANCE_PANEL (object));
appearance_panel = CC_APPEARANCE_PANEL (object);
g_return_if_fail (appearance_panel->priv != NULL);
G_OBJECT_CLASS (cc_appearance_panel_parent_class)->finalize (object);
}
void
cc_appearance_panel_register (GIOModule *module)
{
cc_appearance_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
CC_TYPE_APPEARANCE_PANEL,
"appearance",
10);
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_APPEARANCE_PANEL_H
#define __CC_APPEARANCE_PANEL_H
#include <gtk/gtk.h>
#include "cc-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_APPEARANCE_PANEL (cc_appearance_panel_get_type ())
#define CC_APPEARANCE_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanel))
#define CC_APPEARANCE_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanelClass))
#define CC_IS_APPEARANCE_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_APPEARANCE_PANEL))
#define CC_IS_APPEARANCE_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_APPEARANCE_PANEL))
#define CC_APPEARANCE_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_APPEARANCE_PANEL, CcAppearancePanelClass))
typedef struct CcAppearancePanelPrivate CcAppearancePanelPrivate;
typedef struct
{
CcPanel parent;
CcAppearancePanelPrivate *priv;
} CcAppearancePanel;
typedef struct
{
CcPanelClass parent_class;
} CcAppearancePanelClass;
GType cc_appearance_panel_get_type (void);
void cc_appearance_panel_register (GIOModule *module);
G_END_DECLS
#endif /* __CC_APPEARANCE_PANEL_H */

View File

@@ -0,0 +1,711 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnomeui/gnome-bg.h>
#include "cc-background-item.h"
#define CC_BACKGROUND_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItemPrivate))
struct CcBackgroundItemPrivate
{
/* properties */
char *name;
char *filename;
char *description;
char *placement;
char *shading;
char *primary_color;
char *secondary_color;
gboolean is_deleted;
/* internal */
GnomeBG *bg;
char *mime_type;
int width;
int height;
};
enum {
PROP_0,
PROP_NAME,
PROP_FILENAME,
PROP_DESCRIPTION,
PROP_PLACEMENT,
PROP_SHADING,
PROP_PRIMARY_COLOR,
PROP_SECONDARY_COLOR,
PROP_IS_DELETED,
};
enum {
CHANGED,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
static void cc_background_item_class_init (CcBackgroundItemClass *klass);
static void cc_background_item_init (CcBackgroundItem *background_item);
static void cc_background_item_finalize (GObject *object);
G_DEFINE_TYPE (CcBackgroundItem, cc_background_item, G_TYPE_OBJECT)
static GConfEnumStringPair placement_lookup[] = {
{ GNOME_BG_PLACEMENT_CENTERED, "centered" },
{ GNOME_BG_PLACEMENT_FILL_SCREEN, "stretched" },
{ GNOME_BG_PLACEMENT_SCALED, "scaled" },
{ GNOME_BG_PLACEMENT_ZOOMED, "zoom" },
{ GNOME_BG_PLACEMENT_TILED, "wallpaper" },
{ 0, NULL }
};
static GConfEnumStringPair shading_lookup[] = {
{ GNOME_BG_COLOR_SOLID, "solid" },
{ GNOME_BG_COLOR_H_GRADIENT, "horizontal-gradient" },
{ GNOME_BG_COLOR_V_GRADIENT, "vertical-gradient" },
{ 0, NULL }
};
static const char *
placement_to_string (GnomeBGPlacement type)
{
return gconf_enum_to_string (placement_lookup, type);
}
static const char *
shading_to_string (GnomeBGColorType type)
{
return gconf_enum_to_string (shading_lookup, type);
}
static GnomeBGPlacement
string_to_placement (const char *option)
{
int i = GNOME_BG_PLACEMENT_SCALED;
if (option != NULL) {
gconf_string_to_enum (placement_lookup, option, &i);
}
return i;
}
static GnomeBGColorType
string_to_shading (const char *shading)
{
int i = GNOME_BG_COLOR_SOLID;
if (shading != NULL) {
gconf_string_to_enum (shading_lookup, shading, &i);
}
return i;
}
static GdkPixbuf *
add_slideshow_frame (GdkPixbuf *pixbuf)
{
GdkPixbuf *sheet;
GdkPixbuf *sheet2;
GdkPixbuf *tmp;
int w;
int h;
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
sheet = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, w, h);
gdk_pixbuf_fill (sheet, 0x00000000);
sheet2 = gdk_pixbuf_new_subpixbuf (sheet, 1, 1, w - 2, h - 2);
gdk_pixbuf_fill (sheet2, 0xffffffff);
g_object_unref (sheet2);
tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w + 6, h + 6);
gdk_pixbuf_fill (tmp, 0x00000000);
gdk_pixbuf_composite (sheet, tmp, 6, 6, w, h, 6.0, 6.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
gdk_pixbuf_composite (sheet, tmp, 3, 3, w, h, 3.0, 3.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
gdk_pixbuf_composite (pixbuf, tmp, 0, 0, w, h, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
g_object_unref (sheet);
return tmp;
}
static void
set_bg_properties (CcBackgroundItem *item)
{
int shading;
int placement;
GdkColor pcolor = { 0, 0, 0, 0 };
GdkColor scolor = { 0, 0, 0, 0 };
if (item->priv->filename)
gnome_bg_set_filename (item->priv->bg, item->priv->filename);
if (item->priv->primary_color != NULL) {
gdk_color_parse (item->priv->primary_color, &pcolor);
}
if (item->priv->secondary_color != NULL) {
gdk_color_parse (item->priv->secondary_color, &scolor);
}
placement = string_to_placement (item->priv->placement);
shading = string_to_shading (item->priv->shading);
gnome_bg_set_color (item->priv->bg, shading, &pcolor, &scolor);
gnome_bg_set_placement (item->priv->bg, placement);
}
gboolean
cc_background_item_changes_with_time (CcBackgroundItem *item)
{
gboolean changes;
changes = FALSE;
if (item->priv->bg != NULL) {
changes = gnome_bg_changes_with_time (item->priv->bg);
}
return changes;
}
static void
update_description (CcBackgroundItem *item)
{
g_free (item->priv->description);
item->priv->description = NULL;
if (strcmp (item->priv->filename, "(none)") == 0) {
item->priv->description = g_strdup (item->priv->name);
} else {
const char *description;
char *size;
char *dirname;
dirname = g_path_get_dirname (item->priv->filename);
description = NULL;
size = NULL;
if (item->priv->mime_type != NULL) {
if (strcmp (item->priv->mime_type, "application/xml") == 0) {
if (gnome_bg_changes_with_time (item->priv->bg))
description = _("Slide Show");
else if (item->priv->width > 0 && item->priv->height > 0)
description = _("Image");
} else {
description = g_content_type_get_description (item->priv->mime_type);
}
}
if (gnome_bg_has_multiple_sizes (item->priv->bg)) {
size = g_strdup (_("multiple sizes"));
} else if (item->priv->width > 0 && item->priv->height > 0) {
/* translators: x pixel(s) by y pixel(s) */
size = g_strdup_printf ("%d %s by %d %s",
item->priv->width,
ngettext ("pixel", "pixels", item->priv->width),
item->priv->height,
ngettext ("pixel", "pixels", item->priv->height));
}
if (description != NULL && size != NULL) {
/* translators: <b>wallpaper name</b>
* mime type, size
* Folder: /path/to/file
*/
item->priv->description = g_markup_printf_escaped (_("<b>%s</b>\n"
"%s, %s\n"
"Folder: %s"),
item->priv->name,
description,
size,
dirname);
} else {
/* translators: <b>wallpaper name</b>
* Image missing
* Folder: /path/to/file
*/
item->priv->description = g_markup_printf_escaped (_("<b>%s</b>\n"
"%s\n"
"Folder: %s"),
item->priv->name,
_("Image missing"),
dirname);
}
g_free (size);
g_free (dirname);
}
}
GdkPixbuf *
cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
GnomeDesktopThumbnailFactory *thumbs,
int width,
int height,
int frame)
{
GdkPixbuf *pixbuf = NULL;
set_bg_properties (item);
if (frame != -1)
pixbuf = gnome_bg_create_frame_thumbnail (item->priv->bg,
thumbs,
gdk_screen_get_default (),
width,
height,
frame);
else
pixbuf = gnome_bg_create_thumbnail (item->priv->bg,
thumbs,
gdk_screen_get_default(),
width,
height);
if (pixbuf != NULL
&& gnome_bg_changes_with_time (item->priv->bg)) {
GdkPixbuf *tmp;
tmp = add_slideshow_frame (pixbuf);
g_object_unref (pixbuf);
pixbuf = tmp;
}
gnome_bg_get_image_size (item->priv->bg,
thumbs,
width,
height,
&item->priv->width,
&item->priv->height);
update_description (item);
return pixbuf;
}
GdkPixbuf *
cc_background_item_get_thumbnail (CcBackgroundItem *item,
GnomeDesktopThumbnailFactory *thumbs,
int width,
int height)
{
return cc_background_item_get_frame_thumbnail (item, thumbs, width, height, -1);
}
static void
update_info (CcBackgroundItem *item)
{
GFile *file;
GFileInfo *info;
file = g_file_new_for_commandline_arg (item->priv->filename);
info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
g_object_unref (file);
g_free (item->priv->mime_type);
item->priv->mime_type = NULL;
if (info == NULL
|| g_file_info_get_content_type (info) == NULL) {
if (strcmp (item->priv->filename, "(none)") == 0) {
item->priv->mime_type = g_strdup ("image/x-no-data");
g_free (item->priv->name);
item->priv->name = g_strdup (_("No Desktop Background"));
//item->priv->size = 0;
}
} else {
if (item->priv->name == NULL) {
const char *name;
g_free (item->priv->name);
name = g_file_info_get_name (info);
if (g_utf8_validate (name, -1, NULL))
item->priv->name = g_strdup (name);
else
item->priv->name = g_filename_to_utf8 (name,
-1,
NULL,
NULL,
NULL);
}
item->priv->mime_type = g_strdup (g_file_info_get_content_type (info));
#if 0
item->priv->size = g_file_info_get_size (info);
item->priv->mtime = g_file_info_get_attribute_uint64 (info,
G_FILE_ATTRIBUTE_TIME_MODIFIED);
#endif
}
if (info != NULL)
g_object_unref (info);
}
static void
on_bg_changed (GnomeBG *bg,
CcBackgroundItem *item)
{
g_signal_emit (item, signals[CHANGED], 0);
}
gboolean
cc_background_item_load (CcBackgroundItem *item)
{
gboolean ret;
g_return_val_if_fail (item != NULL, FALSE);
update_info (item);
ret = FALSE;
if (item->priv->mime_type != NULL
&& (g_str_has_prefix (item->priv->mime_type, "image/")
|| strcmp (item->priv->mime_type, "application/xml") == 0)) {
ret = TRUE;
set_bg_properties (item);
} else {
/* FIXME: return error message? */
/* unknown mime type */
}
update_description (item);
return TRUE;
}
static void
_set_name (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->name);
item->priv->name = g_strdup (value);
}
static void
_set_filename (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->filename);
item->priv->filename = g_strdup (value);
}
static void
_set_description (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->description);
item->priv->description = g_strdup (value);
}
static void
_set_placement (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->placement);
item->priv->placement = g_strdup (value);
}
static void
_set_shading (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->shading);
item->priv->shading = g_strdup (value);
}
static void
_set_primary_color (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->primary_color);
item->priv->primary_color = g_strdup (value);
}
static void
_set_secondary_color (CcBackgroundItem *item,
const char *value)
{
g_free (item->priv->secondary_color);
item->priv->secondary_color = g_strdup (value);
}
static void
_set_is_deleted (CcBackgroundItem *item,
gboolean value)
{
item->priv->is_deleted = value;
}
static void
cc_background_item_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
CcBackgroundItem *self;
self = CC_BACKGROUND_ITEM (object);
switch (prop_id) {
case PROP_NAME:
_set_name (self, g_value_get_string (value));
break;
case PROP_FILENAME:
_set_filename (self, g_value_get_string (value));
break;
case PROP_DESCRIPTION:
_set_description (self, g_value_get_string (value));
break;
case PROP_PLACEMENT:
_set_placement (self, g_value_get_string (value));
break;
case PROP_SHADING:
_set_shading (self, g_value_get_string (value));
break;
case PROP_PRIMARY_COLOR:
_set_primary_color (self, g_value_get_string (value));
break;
case PROP_SECONDARY_COLOR:
_set_secondary_color (self, g_value_get_string (value));
break;
case PROP_IS_DELETED:
_set_is_deleted (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_background_item_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
CcBackgroundItem *self;
self = CC_BACKGROUND_ITEM (object);
switch (prop_id) {
case PROP_NAME:
g_value_set_string (value, self->priv->name);
break;
case PROP_FILENAME:
g_value_set_string (value, self->priv->filename);
break;
case PROP_DESCRIPTION:
g_value_set_string (value, self->priv->description);
break;
case PROP_PLACEMENT:
g_value_set_string (value, self->priv->placement);
break;
case PROP_SHADING:
g_value_set_string (value, self->priv->shading);
break;
case PROP_PRIMARY_COLOR:
g_value_set_string (value, self->priv->primary_color);
break;
case PROP_SECONDARY_COLOR:
g_value_set_string (value, self->priv->secondary_color);
break;
case PROP_IS_DELETED:
g_value_set_boolean (value, self->priv->is_deleted);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GObject *
cc_background_item_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcBackgroundItem *background_item;
background_item = CC_BACKGROUND_ITEM (G_OBJECT_CLASS (cc_background_item_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
return G_OBJECT (background_item);
}
static void
cc_background_item_class_init (CcBackgroundItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_background_item_get_property;
object_class->set_property = cc_background_item_set_property;
object_class->constructor = cc_background_item_constructor;
object_class->finalize = cc_background_item_finalize;
signals [CHANGED]
= g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
"name",
"name",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_FILENAME,
g_param_spec_string ("filename",
"filename",
"filename",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_DESCRIPTION,
g_param_spec_string ("description",
"description",
"description",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_PLACEMENT,
g_param_spec_string ("placement",
"placement",
"placement",
"scaled",
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_SHADING,
g_param_spec_string ("shading",
"shading",
"shading",
"solid",
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_PRIMARY_COLOR,
g_param_spec_string ("primary-color",
"primary-color",
"primary-color",
"#000000000000",
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_SECONDARY_COLOR,
g_param_spec_string ("secondary-color",
"secondary-color",
"secondary-color",
"#000000000000",
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IS_DELETED,
g_param_spec_boolean ("is-deleted",
NULL,
NULL,
FALSE,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (CcBackgroundItemPrivate));
}
static void
cc_background_item_init (CcBackgroundItem *item)
{
item->priv = CC_BACKGROUND_ITEM_GET_PRIVATE (item);
item->priv->bg = gnome_bg_new ();
g_signal_connect (item->priv->bg,
"changed",
G_CALLBACK (on_bg_changed),
item);
item->priv->shading = g_strdup ("solid");
item->priv->placement = g_strdup ("scaled");
item->priv->primary_color = g_strdup ("#000000000000");
item->priv->secondary_color = g_strdup ("#000000000000");
}
static void
cc_background_item_finalize (GObject *object)
{
CcBackgroundItem *item;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_BACKGROUND_ITEM (object));
item = CC_BACKGROUND_ITEM (object);
g_return_if_fail (item->priv != NULL);
g_free (item->priv->name);
g_free (item->priv->filename);
g_free (item->priv->description);
g_free (item->priv->primary_color);
g_free (item->priv->secondary_color);
g_free (item->priv->mime_type);
if (item->priv->bg != NULL)
g_object_unref (item->priv->bg);
G_OBJECT_CLASS (cc_background_item_parent_class)->finalize (object);
}
CcBackgroundItem *
cc_background_item_new (const char *filename)
{
GObject *object;
object = g_object_new (CC_TYPE_BACKGROUND_ITEM,
"filename", filename,
NULL);
return CC_BACKGROUND_ITEM (object);
}

View File

@@ -0,0 +1,71 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_BACKGROUND_ITEM_H
#define __CC_BACKGROUND_ITEM_H
#include <glib-object.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnomeui/gnome-desktop-thumbnail.h>
#include "cc-background-item.h"
G_BEGIN_DECLS
#define CC_TYPE_BACKGROUND_ITEM (cc_background_item_get_type ())
#define CC_BACKGROUND_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItem))
#define CC_BACKGROUND_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItemClass))
#define CC_IS_BACKGROUND_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_BACKGROUND_ITEM))
#define CC_IS_BACKGROUND_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_BACKGROUND_ITEM))
#define CC_BACKGROUND_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_BACKGROUND_ITEM, CcBackgroundItemClass))
typedef struct CcBackgroundItemPrivate CcBackgroundItemPrivate;
typedef struct
{
GObject parent;
CcBackgroundItemPrivate *priv;
} CcBackgroundItem;
typedef struct
{
GObjectClass parent_class;
void (* changed) (CcBackgroundItem *item);
} CcBackgroundItemClass;
GType cc_background_item_get_type (void);
CcBackgroundItem * cc_background_item_new (const char *filename);
gboolean cc_background_item_load (CcBackgroundItem *item);
gboolean cc_background_item_changes_with_time (CcBackgroundItem *item);
GdkPixbuf * cc_background_item_get_thumbnail (CcBackgroundItem *item,
GnomeDesktopThumbnailFactory *thumbs,
int width,
int height);
GdkPixbuf * cc_background_item_get_frame_thumbnail (CcBackgroundItem *item,
GnomeDesktopThumbnailFactory *thumbs,
int width,
int height,
int frame);
G_END_DECLS
#endif /* __CC_BACKGROUND_ITEM_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_BACKGROUND_PAGE_H
#define __CC_BACKGROUND_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_BACKGROUND_PAGE (cc_background_page_get_type ())
#define CC_BACKGROUND_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_BACKGROUND_PAGE, CcBackgroundPage))
#define CC_BACKGROUND_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_BACKGROUND_PAGE, CcBackgroundPageClass))
#define CC_IS_BACKGROUND_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_BACKGROUND_PAGE))
#define CC_IS_BACKGROUND_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_BACKGROUND_PAGE))
#define CC_BACKGROUND_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_BACKGROUND_PAGE, CcBackgroundPageClass))
typedef struct CcBackgroundPagePrivate CcBackgroundPagePrivate;
typedef struct
{
CcPage parent;
CcBackgroundPagePrivate *priv;
} CcBackgroundPage;
typedef struct
{
CcPageClass parent_class;
} CcBackgroundPageClass;
GType cc_background_page_get_type (void);
CcPage * cc_background_page_new (void);
G_END_DECLS
#endif /* __CC_BACKGROUND_PAGE_H */

View File

@@ -0,0 +1,715 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include "cc-backgrounds-monitor.h"
#include "cc-background-item.h"
#define CC_BACKGROUNDS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_BACKGROUNDS_MONITOR, CcBackgroundsMonitorPrivate))
struct CcBackgroundsMonitorPrivate
{
GHashTable *item_hash;
};
enum {
PROP_0,
};
enum {
ITEM_ADDED,
ITEM_REMOVED,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
static void cc_backgrounds_monitor_class_init (CcBackgroundsMonitorClass *klass);
static void cc_backgrounds_monitor_init (CcBackgroundsMonitor *backgrounds_monitor);
static void cc_backgrounds_monitor_finalize (GObject *object);
G_DEFINE_TYPE (CcBackgroundsMonitor, cc_backgrounds_monitor, G_TYPE_OBJECT)
#include <gio/gio.h>
#include <string.h>
#include <libxml/parser.h>
static gboolean
xml_get_bool (const xmlNode *parent,
const char *prop_name)
{
xmlChar * prop;
gboolean ret_val = FALSE;
g_assert (parent != NULL);
g_assert (prop_name != NULL);
prop = xmlGetProp ((xmlNode *) parent, (xmlChar*)prop_name);
if (prop == NULL) {
goto done;
}
if (!g_ascii_strcasecmp ((char *)prop, "true")
|| !g_ascii_strcasecmp ((char *)prop, "1")) {
ret_val = TRUE;
} else {
ret_val = FALSE;
}
g_free (prop);
done:
return ret_val;
}
static void
xml_set_bool (const xmlNode *parent,
const xmlChar *prop_name,
gboolean value)
{
g_assert (parent != NULL);
g_assert (prop_name != NULL);
if (value) {
xmlSetProp ((xmlNode *) parent, prop_name, (xmlChar *)"true");
} else {
xmlSetProp ((xmlNode *) parent, prop_name, (xmlChar *)"false");
}
}
static void
load_legacy (CcBackgroundsMonitor *monitor)
{
FILE *fp;
char *foo;
char *filename;
filename = g_build_filename (g_get_home_dir (),
".gnome2",
"wallpapers.list",
NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
if ((fp = fopen (filename, "r")) != NULL) {
foo = (char *) g_malloc (sizeof (char) * 4096);
while (fgets (foo, 4096, fp)) {
CcBackgroundItem *item;
if (foo[strlen (foo) - 1] == '\n') {
foo[strlen (foo) - 1] = '\0';
}
item = g_hash_table_lookup (monitor->priv->item_hash, foo);
if (item != NULL) {
continue;
}
if (!g_file_test (foo, G_FILE_TEST_EXISTS)) {
continue;
}
item = cc_background_item_new (foo);
if (cc_background_item_load (item)) {
cc_backgrounds_monitor_add_item (monitor, item);
} else {
g_object_unref (item);
}
}
fclose (fp);
g_free (foo);
}
}
g_free (filename);
}
static void
load_xml (CcBackgroundsMonitor *monitor,
const char *xml_filename)
{
xmlDoc *wplist;
xmlNode *root;
xmlNode *list;
xmlNode *wpa;
xmlChar *nodelang;
const char * const *syslangs;
int i;
//g_debug ("loading from: %s", xml_filename);
wplist = xmlParseFile (xml_filename);
if (wplist == NULL)
return;
syslangs = g_get_language_names ();
root = xmlDocGetRootElement (wplist);
for (list = root->children; list != NULL; list = list->next) {
char *filename;
char *name;
char *primary_color;
char *secondary_color;
char *options;
char *shade_type;
gboolean deleted;
if (strcmp ((char *)list->name, "wallpaper") != 0) {
continue;
}
filename = NULL;
name = NULL;
options = NULL;
shade_type = NULL;
primary_color = NULL;
secondary_color = NULL;
deleted = xml_get_bool (list, "deleted");
for (wpa = list->children; wpa != NULL; wpa = wpa->next) {
if (wpa->type == XML_COMMENT_NODE) {
continue;
}
if (strcmp ((char *)wpa->name, "filename") == 0) {
if (wpa->last != NULL
&& wpa->last->content != NULL) {
char *content;
content = g_strstrip ((char *)wpa->last->content);
if (strcmp (content, "(none)") == 0)
filename = g_strdup (content);
else if (g_utf8_validate (content, -1, NULL) &&
g_file_test (content, G_FILE_TEST_EXISTS))
filename = g_strdup (content);
else
filename = g_filename_from_utf8 (content, -1, NULL, NULL, NULL);
} else {
break;
}
} else if (strcmp ((char *)wpa->name, "name") == 0) {
if (wpa->last != NULL && wpa->last->content != NULL) {
nodelang = xmlNodeGetLang (wpa->last);
if (name == NULL && nodelang == NULL) {
name = g_strdup (g_strstrip ((char *)wpa->last->content));
} else {
for (i = 0; syslangs[i] != NULL; i++) {
if (strcmp (syslangs[i], (char *)nodelang) == 0) {
g_free (name);
name = g_strdup (g_strstrip ((char *)wpa->last->content));
break;
}
}
}
xmlFree (nodelang);
} else {
break;
}
} else if (strcmp ((char *)wpa->name, "options") == 0) {
if (wpa->last != NULL) {
options = g_strdup (g_strstrip ((char *)wpa->last->content));
}
} else if (strcmp ((char *)wpa->name, "shade_type") == 0) {
if (wpa->last != NULL) {
shade_type = g_strdup (g_strstrip ((char *)wpa->last->content));
}
} else if (strcmp ((char *)wpa->name, "pcolor") == 0) {
if (wpa->last != NULL) {
primary_color = g_strdup (g_strstrip ((char *)wpa->last->content));
}
} else if (strcmp ((char *)wpa->name, "scolor") == 0) {
if (wpa->last != NULL) {
secondary_color = g_strdup (g_strstrip ((char *)wpa->last->content));
}
} else if (strcmp ((char *)wpa->name, "text") == 0) {
/* Do nothing here, libxml2 is being weird */
} else {
g_warning ("Unknown Tag: %s", wpa->name);
}
}
/* Make sure we don't already have this one and that filename exists */
if (filename != NULL
&& g_hash_table_lookup (monitor->priv->item_hash, filename) == NULL) {
CcBackgroundItem *item;
item = cc_background_item_new (filename);
g_object_set (item,
"name", name,
"primary-color", primary_color,
"secondary-color", secondary_color,
"placement", options,
"shading", shade_type,
"is-deleted", deleted,
NULL);
if (cc_background_item_load (item)) {
if (cc_backgrounds_monitor_add_item (monitor, item)) {
g_debug ("Added item %s", name);
}
}
g_object_unref (item);
}
g_free (filename);
g_free (name);
g_free (primary_color);
g_free (secondary_color);
g_free (options);
g_free (shade_type);
}
xmlFreeDoc (wplist);
}
static void
file_changed (GFileMonitor *file_monitor,
GFile *file,
GFile *other_file,
GFileMonitorEvent event_type,
CcBackgroundsMonitor *monitor)
{
char *filename;
switch (event_type) {
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_CREATED:
filename = g_file_get_path (file);
load_xml (monitor, filename);
g_free (filename);
break;
default:
break;
}
}
static void
add_monitor (CcBackgroundsMonitor *monitor,
GFile *directory)
{
GFileMonitor *file_monitor;
GError *error = NULL;
file_monitor = g_file_monitor_directory (directory,
G_FILE_MONITOR_NONE,
NULL,
&error);
if (error != NULL) {
char *path;
path = g_file_get_parse_name (directory);
g_warning ("Unable to monitor directory %s: %s",
path,
error->message);
g_error_free (error);
g_free (path);
return;
}
g_signal_connect (file_monitor,
"changed",
G_CALLBACK (file_changed),
monitor);
}
static void
load_from_dir (CcBackgroundsMonitor *monitor,
const char *path)
{
GFile *directory;
GFileEnumerator *enumerator;
GError *error;
GFileInfo *info;
if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
return;
}
g_debug ("Loading from directory %s", path);
directory = g_file_new_for_path (path);
error = NULL;
enumerator = g_file_enumerate_children (directory,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE,
NULL,
&error);
if (error != NULL) {
g_warning ("Unable to check directory %s: %s", path, error->message);
g_error_free (error);
g_object_unref (directory);
return;
}
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL))) {
const char *filename;
char *fullpath;
filename = g_file_info_get_name (info);
fullpath = g_build_filename (path, filename, NULL);
g_object_unref (info);
load_xml (monitor, fullpath);
g_free (fullpath);
}
g_file_enumerator_close (enumerator, NULL, NULL);
add_monitor (monitor, directory);
g_object_unref (directory);
}
static void
ensure_none (CcBackgroundsMonitor *monitor)
{
CcBackgroundItem *item;
item = g_hash_table_lookup (monitor->priv->item_hash, "(none)");
if (item == NULL) {
item = cc_background_item_new ("(none)");
if (cc_background_item_load (item)) {
cc_backgrounds_monitor_add_item (monitor, item);
} else {
g_object_unref (item);
}
} else {
g_object_set (item, "is-deleted", FALSE, NULL);
}
}
void
cc_backgrounds_monitor_load (CcBackgroundsMonitor *monitor)
{
const char * const *system_data_dirs;
char *filename;
int i;
g_return_if_fail (monitor != NULL);
filename = g_build_filename (g_get_home_dir (),
".gnome2",
"backgrounds.xml",
NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
load_xml (monitor, filename);
} else {
g_free (filename);
filename = g_build_filename (g_get_home_dir (),
".gnome2",
"wp-list.xml",
NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
load_xml (monitor, filename);
}
}
g_free (filename);
filename = g_build_filename (g_get_user_data_dir (),
"gnome-background-properties",
NULL);
load_from_dir (monitor, filename);
g_free (filename);
system_data_dirs = g_get_system_data_dirs ();
for (i = 0; system_data_dirs[i]; i++) {
filename = g_build_filename (system_data_dirs[i],
"gnome-background-properties",
NULL);
load_from_dir (monitor, filename);
g_free (filename);
}
load_from_dir (monitor, WALLPAPER_DATADIR);
load_legacy (monitor);
/* We always want to have a (none) entry */
ensure_none (monitor);
}
static void
list_flatten (const char *key,
CcBackgroundItem *item,
GList **list)
{
g_return_if_fail (key != NULL);
g_return_if_fail (item != NULL);
*list = g_list_prepend (*list, item);
}
gboolean
cc_backgrounds_monitor_add_item (CcBackgroundsMonitor *monitor,
CcBackgroundItem *item)
{
char *uri;
gboolean deleted;
gboolean ret;
ret = FALSE;
g_return_val_if_fail (monitor != NULL, FALSE);
g_return_val_if_fail (item != NULL, FALSE);
uri = NULL;
g_object_get (item,
"filename", &uri,
"is-deleted", &deleted,
NULL);
if (g_hash_table_lookup (monitor->priv->item_hash, uri) == NULL) {
g_debug ("Inserting %s", uri);
g_hash_table_insert (monitor->priv->item_hash,
g_strdup (uri),
g_object_ref (item));
ret = TRUE;
} else if (!deleted) {
g_debug ("Undeleting %s", uri);
g_object_set (item, "is-deleted", FALSE, NULL);
ret = TRUE;
}
if (ret)
g_signal_emit (monitor, signals [ITEM_ADDED], 0, item);
g_free (uri);
return ret;
}
gboolean
cc_backgrounds_monitor_remove_item (CcBackgroundsMonitor *monitor,
CcBackgroundItem *item)
{
char *uri;
gboolean deleted;
gboolean ret;
ret = FALSE;
g_return_val_if_fail (monitor != NULL, FALSE);
g_return_val_if_fail (item != NULL, FALSE);
g_object_get (item,
"filename", &uri,
"is-deleted", &deleted,
NULL);
if (g_hash_table_lookup (monitor->priv->item_hash, uri) != NULL
&& !deleted) {
g_object_set (item, "is-deleted", TRUE, NULL);
g_signal_emit (monitor, signals [ITEM_REMOVED], 0, item);
ret = TRUE;
}
g_free (uri);
return ret;
}
GList *
cc_backgrounds_monitor_get_items (CcBackgroundsMonitor *monitor)
{
GList *list;
g_return_val_if_fail (monitor != NULL, NULL);
list = NULL;
g_hash_table_foreach (monitor->priv->item_hash,
(GHFunc) list_flatten,
&list);
list = g_list_reverse (list);
return list;
}
void
cc_backgrounds_monitor_save (CcBackgroundsMonitor *monitor)
{
xmlDoc *wplist;
xmlNode *root;
xmlNode *wallpaper;
xmlNode *node;
GList *list = NULL;
char *wpfile;
g_return_if_fail (monitor != NULL);
g_hash_table_foreach (monitor->priv->item_hash,
(GHFunc) list_flatten,
&list);
list = g_list_reverse (list);
wpfile = g_build_filename (g_get_home_dir (),
"/.gnome2",
"backgrounds.xml",
NULL);
xmlKeepBlanksDefault (0);
wplist = xmlNewDoc ((xmlChar *)"1.0");
xmlCreateIntSubset (wplist, (xmlChar *)"wallpapers", NULL, (xmlChar *)"gnome-wp-list.dtd");
root = xmlNewNode (NULL, (xmlChar *)"wallpapers");
xmlDocSetRootElement (wplist, root);
while (list != NULL) {
CcBackgroundItem *item;
char *scale;
char *shade;
char *filename;
char *utf8_filename;
char *name;
char *pcolor;
char *scolor;
gboolean deleted;
item = list->data;
g_object_get (item,
"filename", &filename,
"name", &name,
"primary-color", &pcolor,
"secondary-color", &scolor,
"shading", &shade,
"placement", &scale,
"is-deleted", &deleted,
NULL);
if (strcmp (filename, "(none)") == 0
|| (g_utf8_validate (filename, -1, NULL)
&& g_file_test (filename, G_FILE_TEST_EXISTS))) {
utf8_filename = g_strdup (filename);
} else {
utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
}
wallpaper = xmlNewChild (root, NULL, (xmlChar *)"wallpaper", NULL);
xml_set_bool (wallpaper, (xmlChar *)"deleted", deleted);
node = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"name", (xmlChar *)name);
node = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"filename", (xmlChar *)filename);
node = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"options", (xmlChar *)scale);
node = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"shade_type", (xmlChar *)shade);
node = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"pcolor", (xmlChar *)pcolor);
node = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"scolor", (xmlChar *)scolor);
g_free (pcolor);
g_free (scolor);
g_free (filename);
g_free (utf8_filename);
g_free (name);
g_free (shade);
g_free (scale);
list = g_list_delete_link (list, list);
}
xmlSaveFormatFile (wpfile, wplist, 1);
xmlFreeDoc (wplist);
g_free (wpfile);
}
static GObject *
cc_backgrounds_monitor_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcBackgroundsMonitor *backgrounds_monitor;
backgrounds_monitor = CC_BACKGROUNDS_MONITOR (G_OBJECT_CLASS (cc_backgrounds_monitor_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
return G_OBJECT (backgrounds_monitor);
}
static void
cc_backgrounds_monitor_class_init (CcBackgroundsMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = cc_backgrounds_monitor_constructor;
object_class->finalize = cc_backgrounds_monitor_finalize;
signals [ITEM_ADDED]
= g_signal_new ("item-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1, CC_TYPE_BACKGROUND_ITEM);
signals [ITEM_REMOVED]
= g_signal_new ("item-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1, CC_TYPE_BACKGROUND_ITEM);
g_type_class_add_private (klass, sizeof (CcBackgroundsMonitorPrivate));
}
static void
cc_backgrounds_monitor_init (CcBackgroundsMonitor *monitor)
{
monitor->priv = CC_BACKGROUNDS_MONITOR_GET_PRIVATE (monitor);
monitor->priv->item_hash = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_object_unref);
}
static void
cc_backgrounds_monitor_finalize (GObject *object)
{
CcBackgroundsMonitor *monitor;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_BACKGROUNDS_MONITOR (object));
monitor = CC_BACKGROUNDS_MONITOR (object);
g_return_if_fail (monitor->priv != NULL);
g_hash_table_destroy (monitor->priv->item_hash);
G_OBJECT_CLASS (cc_backgrounds_monitor_parent_class)->finalize (object);
}
CcBackgroundsMonitor *
cc_backgrounds_monitor_new (void)
{
GObject *object;
object = g_object_new (CC_TYPE_BACKGROUNDS_MONITOR, NULL);
return CC_BACKGROUNDS_MONITOR (object);
}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_BACKGROUNDS_MONITOR_H
#define __CC_BACKGROUNDS_MONITOR_H
#include <glib-object.h>
#include "cc-background-item.h"
G_BEGIN_DECLS
#define CC_TYPE_BACKGROUNDS_MONITOR (cc_backgrounds_monitor_get_type ())
#define CC_BACKGROUNDS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_BACKGROUNDS_MONITOR, CcBackgroundsMonitor))
#define CC_BACKGROUNDS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_BACKGROUNDS_MONITOR, CcBackgroundsMonitorClass))
#define CC_IS_BACKGROUNDS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_BACKGROUNDS_MONITOR))
#define CC_IS_BACKGROUNDS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_BACKGROUNDS_MONITOR))
#define CC_BACKGROUNDS_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_BACKGROUNDS_MONITOR, CcBackgroundsMonitorClass))
typedef struct CcBackgroundsMonitorPrivate CcBackgroundsMonitorPrivate;
typedef struct
{
GObject parent;
CcBackgroundsMonitorPrivate *priv;
} CcBackgroundsMonitor;
typedef struct
{
GObjectClass parent_class;
void (* item_added) (CcBackgroundsMonitor *monitor,
CcBackgroundItem *item);
void (* item_removed) (CcBackgroundsMonitor *monitor,
CcBackgroundItem *item);
} CcBackgroundsMonitorClass;
GType cc_backgrounds_monitor_get_type (void);
CcBackgroundsMonitor * cc_backgrounds_monitor_new (void);
void cc_backgrounds_monitor_load (CcBackgroundsMonitor *monitor);
void cc_backgrounds_monitor_save (CcBackgroundsMonitor *monitor);
GList * cc_backgrounds_monitor_get_items (CcBackgroundsMonitor *monitor);
gboolean cc_backgrounds_monitor_add_item (CcBackgroundsMonitor *monitor,
CcBackgroundItem *item);
gboolean cc_backgrounds_monitor_remove_item (CcBackgroundsMonitor *monitor,
CcBackgroundItem *item);
G_END_DECLS
#endif /* __CC_BACKGROUNDS_MONITOR_H */

View File

@@ -0,0 +1,244 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2002 Jonathan Blandford <jrb@gnome.org>
* Copyright (C) 2007 Jens Granseuer <jensgr@gmx.net>
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#ifdef HAVE_XFT2
#include <gdk/gdkx.h>
#include <X11/Xft/Xft.h>
#endif /* HAVE_XFT2 */
#include "cc-font-common.h"
#ifdef HAVE_XFT2
/*
* Code for displaying previews of font rendering with various Xft options
*/
static void
sample_size_request (GtkWidget *darea,
GtkRequisition *requisition)
{
GdkPixbuf *pixbuf = g_object_get_data (G_OBJECT (darea), "sample-pixbuf");
requisition->width = gdk_pixbuf_get_width (pixbuf) + 2;
requisition->height = gdk_pixbuf_get_height (pixbuf) + 2;
}
static void
sample_expose (GtkWidget *darea,
GdkEventExpose *expose)
{
GdkPixbuf *pixbuf = g_object_get_data (G_OBJECT (darea), "sample-pixbuf");
int width = gdk_pixbuf_get_width (pixbuf);
int height = gdk_pixbuf_get_height (pixbuf);
int x = (darea->allocation.width - width) / 2;
int y = (darea->allocation.height - height) / 2;
gdk_draw_rectangle (darea->window, darea->style->white_gc, TRUE,
0, 0,
darea->allocation.width, darea->allocation.height);
gdk_draw_rectangle (darea->window, darea->style->black_gc, FALSE,
0, 0,
darea->allocation.width - 1, darea->allocation.height - 1);
gdk_draw_pixbuf (darea->window, NULL, pixbuf, 0, 0, x, y, width, height,
GDK_RGB_DITHER_NORMAL, 0, 0);
}
static XftFont *
open_pattern (FcPattern *pattern,
Antialiasing antialiasing,
Hinting hinting)
{
#ifdef FC_HINT_STYLE
static const int hintstyles[] = {
FC_HINT_NONE, FC_HINT_SLIGHT, FC_HINT_MEDIUM, FC_HINT_FULL
};
#endif /* FC_HINT_STYLE */
FcPattern *res_pattern;
FcResult result;
XftFont *font;
Display *xdisplay = gdk_x11_get_default_xdisplay ();
int screen = gdk_x11_get_default_screen ();
res_pattern = XftFontMatch (xdisplay, screen, pattern, &result);
if (res_pattern == NULL)
return NULL;
FcPatternDel (res_pattern, FC_HINTING);
FcPatternAddBool (res_pattern, FC_HINTING, hinting != HINT_NONE);
#ifdef FC_HINT_STYLE
FcPatternDel (res_pattern, FC_HINT_STYLE);
FcPatternAddInteger (res_pattern, FC_HINT_STYLE, hintstyles[hinting]);
#endif /* FC_HINT_STYLE */
FcPatternDel (res_pattern, FC_ANTIALIAS);
FcPatternAddBool (res_pattern, FC_ANTIALIAS, antialiasing != ANTIALIAS_NONE);
FcPatternDel (res_pattern, FC_RGBA);
FcPatternAddInteger (res_pattern, FC_RGBA,
antialiasing == ANTIALIAS_RGBA ? FC_RGBA_RGB : FC_RGBA_NONE);
FcPatternDel (res_pattern, FC_DPI);
FcPatternAddInteger (res_pattern, FC_DPI, 96);
font = XftFontOpenPattern (xdisplay, res_pattern);
if (!font)
FcPatternDestroy (res_pattern);
return font;
}
void
setup_font_sample (GtkWidget *darea,
Antialiasing antialiasing,
Hinting hinting)
{
const char *string1 = "abcfgop AO ";
const char *string2 = "abcfgop";
XftColor black, white;
XRenderColor rendcolor;
Display *xdisplay = gdk_x11_get_default_xdisplay ();
GdkColormap *colormap = gdk_rgb_get_colormap ();
Colormap xcolormap = GDK_COLORMAP_XCOLORMAP (colormap);
GdkVisual *visual = gdk_colormap_get_visual (colormap);
Visual *xvisual = GDK_VISUAL_XVISUAL (visual);
FcPattern *pattern;
XftFont *font1, *font2;
XGlyphInfo extents1 = { 0 };
XGlyphInfo extents2 = { 0 };
GdkPixmap *pixmap;
XftDraw *draw;
GdkPixbuf *tmp_pixbuf, *pixbuf;
int width, height;
int ascent, descent;
pattern = FcPatternBuild (NULL,
FC_FAMILY, FcTypeString, "Serif",
FC_SLANT, FcTypeInteger, FC_SLANT_ROMAN,
FC_SIZE, FcTypeDouble, 18.,
NULL);
font1 = open_pattern (pattern, antialiasing, hinting);
FcPatternDestroy (pattern);
pattern = FcPatternBuild (NULL,
FC_FAMILY, FcTypeString, "Serif",
FC_SLANT, FcTypeInteger, FC_SLANT_ITALIC,
FC_SIZE, FcTypeDouble, 20.,
NULL);
font2 = open_pattern (pattern, antialiasing, hinting);
FcPatternDestroy (pattern);
ascent = 0;
descent = 0;
if (font1) {
XftTextExtentsUtf8 (xdisplay, font1, (unsigned char *) string1,
strlen (string1), &extents1);
ascent = MAX (ascent, font1->ascent);
descent = MAX (descent, font1->descent);
}
if (font2) {
XftTextExtentsUtf8 (xdisplay, font2, (unsigned char *) string2,
strlen (string2), &extents2);
ascent = MAX (ascent, font2->ascent);
descent = MAX (descent, font2->descent);
}
width = extents1.xOff + extents2.xOff + 4;
height = ascent + descent + 2;
pixmap = gdk_pixmap_new (NULL, width, height, visual->depth);
draw = XftDrawCreate (xdisplay, GDK_DRAWABLE_XID (pixmap), xvisual, xcolormap);
rendcolor.red = 0;
rendcolor.green = 0;
rendcolor.blue = 0;
rendcolor.alpha = 0xffff;
XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &black);
rendcolor.red = 0xffff;
rendcolor.green = 0xffff;
rendcolor.blue = 0xffff;
rendcolor.alpha = 0xffff;
XftColorAllocValue (xdisplay, xvisual, xcolormap, &rendcolor, &white);
XftDrawRect (draw, &white, 0, 0, width, height);
if (font1)
XftDrawStringUtf8 (draw,
&black,
font1,
2, 2 + ascent,
(unsigned char *) string1,
strlen (string1));
if (font2)
XftDrawStringUtf8 (draw,
&black,
font2,
2 + extents1.xOff,
2 + ascent,
(unsigned char *) string2,
strlen (string2));
XftDrawDestroy (draw);
if (font1)
XftFontClose (xdisplay, font1);
if (font2)
XftFontClose (xdisplay, font2);
tmp_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, colormap, 0, 0, 0, 0, width, height);
pixbuf = gdk_pixbuf_scale_simple (tmp_pixbuf, 1 * width, 1 * height, GDK_INTERP_TILES);
g_object_unref (pixmap);
g_object_unref (tmp_pixbuf);
g_object_set_data_full (G_OBJECT (darea),
"sample-pixbuf",
pixbuf,
(GDestroyNotify) g_object_unref);
g_signal_connect (darea, "size_request", G_CALLBACK (sample_size_request), NULL);
g_signal_connect (darea, "expose_event", G_CALLBACK (sample_expose), NULL);
}
#endif

View File

@@ -0,0 +1,78 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2002 Jonathan Blandford <jrb@gnome.org>
* Copyright (C) 2007 Jens Granseuer <jensgr@gmx.net>
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 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.
*
*/
#define GTK_FONT_KEY "/desktop/gnome/interface/font_name"
#define DESKTOP_FONT_KEY "/apps/nautilus/preferences/desktop_font"
#define METACITY_DIR "/apps/metacity/general"
#define WINDOW_TITLE_FONT_KEY METACITY_DIR "/titlebar_font"
#define WINDOW_TITLE_USES_SYSTEM_KEY METACITY_DIR "/titlebar_uses_system_font"
#define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name"
#define DOCUMENT_FONT_KEY "/desktop/gnome/interface/document_font_name"
#define FONT_RENDER_DIR "/desktop/gnome/font_rendering"
#define FONT_ANTIALIASING_KEY FONT_RENDER_DIR "/antialiasing"
#define FONT_HINTING_KEY FONT_RENDER_DIR "/hinting"
#define FONT_RGBA_ORDER_KEY FONT_RENDER_DIR "/rgba_order"
#define FONT_DPI_KEY FONT_RENDER_DIR "/dpi"
/* X servers sometimes lie about the screen's physical dimensions, so we cannot
* compute an accurate DPI value. When this happens, the user gets fonts that
* are too huge or too tiny. So, we see what the server returns: if it reports
* something outside of the range [DPI_LOW_REASONABLE_VALUE,
* DPI_HIGH_REASONABLE_VALUE], then we assume that it is lying and we use
* DPI_FALLBACK instead.
*
* See get_dpi_from_gconf_or_server() below, and also
* https://bugzilla.novell.com/show_bug.cgi?id=217790
*/
#define DPI_FALLBACK 96
#define DPI_LOW_REASONABLE_VALUE 50
#define DPI_HIGH_REASONABLE_VALUE 500
#define MAX_FONT_POINT_WITHOUT_WARNING 32
#define MAX_FONT_SIZE_WITHOUT_WARNING MAX_FONT_POINT_WITHOUT_WARNING*1024
typedef enum {
ANTIALIAS_NONE,
ANTIALIAS_GRAYSCALE,
ANTIALIAS_RGBA
} Antialiasing;
typedef enum {
HINT_NONE,
HINT_SLIGHT,
HINT_MEDIUM,
HINT_FULL
} Hinting;
typedef enum {
RGBA_RGB,
RGBA_BGR,
RGBA_VRGB,
RGBA_VBGR
} RgbaOrder;
void setup_font_sample (GtkWidget *drawing_area,
Antialiasing antialiasing,
Hinting hinting);

View File

@@ -0,0 +1,603 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2002 Jonathan Blandford <jrb@gnome.org>
* Copyright (C) 2007 Jens Granseuer <jensgr@gmx.net>
* Copyright (C) 2010 William Jon McCann
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <gconf/gconf-client.h>
#include "cc-font-details-dialog.h"
#include "cc-font-common.h"
#define CC_FONT_DETAILS_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_FONT_DETAILS_DIALOG, CcFontDetailsDialogPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcFontDetailsDialogPrivate
{
GSList *font_groups;
GtkWidget *dpi_spin_button;
GtkWidget *antialias_none_sample;
GtkWidget *antialias_grayscale_sample;
GtkWidget *antialias_subpixel_sample;
GtkWidget *antialias_none_radiobutton;
GtkWidget *antialias_grayscale_radiobutton;
GtkWidget *antialias_subpixel_radiobutton;
GtkWidget *hint_none_sample;
GtkWidget *hint_slight_sample;
GtkWidget *hint_medium_sample;
GtkWidget *hint_full_sample;
GtkWidget *hint_none_radiobutton;
GtkWidget *hint_slight_radiobutton;
GtkWidget *hint_medium_radiobutton;
GtkWidget *hint_full_radiobutton;
GtkWidget *subpixel_rgb_image;
GtkWidget *subpixel_bgr_image;
GtkWidget *subpixel_vrgb_image;
GtkWidget *subpixel_vbgr_image;
GtkWidget *subpixel_rgb_radiobutton;
GtkWidget *subpixel_bgr_radiobutton;
GtkWidget *subpixel_vrgb_radiobutton;
GtkWidget *subpixel_vbgr_radiobutton;
gboolean in_change;
guint dpi_notify_id;
};
enum {
PROP_0,
};
static void cc_font_details_dialog_class_init (CcFontDetailsDialogClass *klass);
static void cc_font_details_dialog_init (CcFontDetailsDialog *font_details_dialog);
static void cc_font_details_dialog_finalize (GObject *object);
G_DEFINE_TYPE (CcFontDetailsDialog, cc_font_details_dialog, GTK_TYPE_DIALOG)
static GConfEnumStringPair rgba_order_enums[] = {
{ RGBA_RGB, "rgb" },
{ RGBA_BGR, "bgr" },
{ RGBA_VRGB, "vrgb" },
{ RGBA_VBGR, "vbgr" },
{ -1, NULL }
};
static GConfEnumStringPair antialias_enums[] = {
{ ANTIALIAS_NONE, "none" },
{ ANTIALIAS_GRAYSCALE, "grayscale" },
{ ANTIALIAS_RGBA, "rgba" },
{ -1, NULL }
};
static GConfEnumStringPair hint_enums[] = {
{ HINT_NONE, "none" },
{ HINT_SLIGHT, "slight" },
{ HINT_MEDIUM, "medium" },
{ HINT_FULL, "full" },
{ -1, NULL }
};
static void
cc_font_details_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
CcFontDetailsDialog *self;
self = CC_FONT_DETAILS_DIALOG (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_font_details_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static double
dpi_from_pixels_and_mm (int pixels, int mm)
{
double dpi;
if (mm >= 1)
dpi = pixels / (mm / 25.4);
else
dpi = 0;
return dpi;
}
static double
get_dpi_from_x_server (void)
{
GdkScreen *screen;
double dpi;
screen = gdk_screen_get_default ();
if (screen) {
double width_dpi, height_dpi;
width_dpi = dpi_from_pixels_and_mm (gdk_screen_get_width (screen),
gdk_screen_get_width_mm (screen));
height_dpi = dpi_from_pixels_and_mm (gdk_screen_get_height (screen),
gdk_screen_get_height_mm (screen));
if (width_dpi < DPI_LOW_REASONABLE_VALUE || width_dpi > DPI_HIGH_REASONABLE_VALUE ||
height_dpi < DPI_LOW_REASONABLE_VALUE || height_dpi > DPI_HIGH_REASONABLE_VALUE)
dpi = DPI_FALLBACK;
else
dpi = (width_dpi + height_dpi) / 2.0;
} else {
/* Huh!? No screen? */
dpi = DPI_FALLBACK;
}
return dpi;
}
static void
dpi_load (CcFontDetailsDialog *dialog)
{
GConfClient *client;
GConfValue *value;
gdouble dpi;
client = gconf_client_get_default ();
value = gconf_client_get_without_default (client, FONT_DPI_KEY, NULL);
g_object_unref (client);
if (value) {
dpi = gconf_value_get_float (value);
gconf_value_free (value);
} else
dpi = get_dpi_from_x_server ();
if (dpi < DPI_LOW_REASONABLE_VALUE)
dpi = DPI_LOW_REASONABLE_VALUE;
dialog->priv->in_change = TRUE;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->dpi_spin_button), dpi);
dialog->priv->in_change = FALSE;
}
static void
on_dpi_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
CcFontDetailsDialog *dialog)
{
dpi_load (dialog);
}
static void
on_dpi_value_changed (GtkSpinButton *spinner,
CcFontDetailsDialog *dialog)
{
/* Like any time when using a spin button with GConf, there is
* a race condition here. When we change, we send the new
* value to GConf, then restore to the old value until
* we get a response to emulate the proper model/view behavior.
*
* If the user changes the value faster than responses are
* received from GConf, this may cause mildly strange effects.
*/
if (!dialog->priv->in_change) {
gdouble new_dpi;
GConfClient *client;
client = gconf_client_get_default ();
new_dpi = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->priv->dpi_spin_button));
gconf_client_set_float (client, FONT_DPI_KEY, new_dpi, NULL);
g_object_unref (client);
dpi_load (dialog);
}
}
/*
* EnumGroup - a group of radio buttons tied to a string enumeration
* value. We add this here because the gconf peditor
* equivalent of this is both painful to use (you have
* to supply functions to convert from enums to indices)
* and conceptually broken (the order of radio buttons
* in a group when using Glade is not predictable.
*/
typedef struct
{
GConfClient *client;
CcFontDetailsDialog *dialog;
GSList *items;
char *gconf_key;
GConfEnumStringPair *enums;
int default_value;
guint notify_id;
} EnumGroup;
typedef struct
{
EnumGroup *group;
GtkToggleButton *widget;
int value;
} EnumItem;
static void
enum_group_load (EnumGroup *group)
{
char *str = gconf_client_get_string (group->client, group->gconf_key, NULL);
int val = group->default_value;
GSList *tmp_list;
if (str)
gconf_string_to_enum (group->enums, str, &val);
g_free (str);
group->dialog->priv->in_change = TRUE;
for (tmp_list = group->items; tmp_list; tmp_list = tmp_list->next) {
EnumItem *item = tmp_list->data;
if (val == item->value)
gtk_toggle_button_set_active (item->widget, TRUE);
}
group->dialog->priv->in_change = FALSE;
}
static void
on_enum_group_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
EnumGroup *group)
{
enum_group_load (group);
}
static void
enum_item_toggled (GtkToggleButton *toggle_button,
EnumItem *item)
{
EnumGroup *group = item->group;
if (!group->dialog->priv->in_change) {
gconf_client_set_string (group->client,
group->gconf_key,
gconf_enum_to_string (group->enums, item->value),
NULL);
}
/* Restore back to the previous state until we get notification */
enum_group_load (group);
}
static EnumGroup *
enum_group_create (CcFontDetailsDialog *dialog,
const char *gconf_key,
GConfEnumStringPair *enums,
int default_value,
GtkWidget *first_widget,
...)
{
EnumGroup *group;
GtkWidget *widget;
va_list args;
group = g_new (EnumGroup, 1);
group->dialog = dialog;
group->client = gconf_client_get_default ();
group->gconf_key = g_strdup (gconf_key);
group->enums = enums;
group->default_value = default_value;
group->items = NULL;
va_start (args, first_widget);
widget = first_widget;
while (widget) {
EnumItem *item;
item = g_new (EnumItem, 1);
item->group = group;
item->widget = GTK_TOGGLE_BUTTON (widget);
item->value = va_arg (args, int);
g_signal_connect (item->widget,
"toggled",
G_CALLBACK (enum_item_toggled),
item);
group->items = g_slist_prepend (group->items, item);
widget = va_arg (args, GtkWidget *);
}
va_end (args);
enum_group_load (group);
group->notify_id = gconf_client_notify_add (group->client,
gconf_key,
(GConfClientNotifyFunc) on_enum_group_changed,
group,
NULL,
NULL);
return group;
}
static void
enum_group_destroy (EnumGroup *group)
{
g_free (group->gconf_key);
g_slist_foreach (group->items, (GFunc) g_free, NULL);
g_slist_free (group->items);
gconf_client_notify_remove (group->client, group->notify_id);
g_object_unref (group->client);
g_free (group);
}
static void
setup_dialog (CcFontDetailsDialog *dialog)
{
GtkBuilder *builder;
GtkWidget *widget;
GtkWidget *box;
GtkAdjustment *adjustment;
EnumGroup *group;
GConfClient *client;
GError *error;
builder = gtk_builder_new ();
error = NULL;
gtk_builder_add_from_file (builder,
GNOMECC_UI_DIR
"/appearance.ui",
&error);
if (error != NULL) {
g_error (_("Could not load user interface file: %s"),
error->message);
g_error_free (error);
return;
}
dialog->priv->dpi_spin_button = WID ("dpi_spinner");
/* pick a sensible maximum dpi */
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (dialog->priv->dpi_spin_button));
adjustment->upper = DPI_HIGH_REASONABLE_VALUE;
adjustment->lower = DPI_LOW_REASONABLE_VALUE;
adjustment->step_increment = 1;
dpi_load (dialog);
g_signal_connect (dialog->priv->dpi_spin_button,
"value_changed",
G_CALLBACK (on_dpi_value_changed),
dialog);
client = gconf_client_get_default ();
dialog->priv->dpi_notify_id = gconf_client_notify_add (client,
FONT_DPI_KEY,
(GConfClientNotifyFunc) on_dpi_changed,
dialog,
NULL,
NULL);
dialog->priv->antialias_none_sample = WID ("antialias_none_sample");
dialog->priv->antialias_grayscale_sample = WID ("antialias_grayscale_sample");
dialog->priv->antialias_subpixel_sample = WID ("antialias_subpixel_sample");
dialog->priv->antialias_none_radiobutton = WID ("antialias_none_radio");
dialog->priv->antialias_grayscale_radiobutton = WID ("antialias_grayscale_radio");
dialog->priv->antialias_subpixel_radiobutton = WID ("antialias_subpixel_radio");
dialog->priv->hint_none_sample = WID ("hint_none_sample");
dialog->priv->hint_slight_sample = WID ("hint_slight_sample");
dialog->priv->hint_medium_sample = WID ("hint_medium_sample");
dialog->priv->hint_full_sample = WID ("hint_full_sample");
dialog->priv->hint_none_radiobutton = WID ("hint_none_radio");
dialog->priv->hint_slight_radiobutton = WID ("hint_slight_radio");
dialog->priv->hint_medium_radiobutton = WID ("hint_medium_radio");
dialog->priv->hint_full_radiobutton = WID ("hint_full_radio");
dialog->priv->subpixel_rgb_image = WID ("subpixel_rgb_image");
dialog->priv->subpixel_bgr_image = WID ("subpixel_bgr_image");
dialog->priv->subpixel_vrgb_image = WID ("subpixel_vrgb_image");
dialog->priv->subpixel_vbgr_image = WID ("subpixel_vbgr_image");
dialog->priv->subpixel_rgb_radiobutton = WID ("subpixel_rgb_radio");
dialog->priv->subpixel_bgr_radiobutton = WID ("subpixel_bgr_radio");
dialog->priv->subpixel_vrgb_radiobutton = WID ("subpixel_vrgb_radio");
dialog->priv->subpixel_vbgr_radiobutton = WID ("subpixel_vbgr_radio");
setup_font_sample (dialog->priv->antialias_none_sample,
ANTIALIAS_NONE,
HINT_FULL);
setup_font_sample (dialog->priv->antialias_grayscale_sample,
ANTIALIAS_GRAYSCALE,
HINT_FULL);
setup_font_sample (dialog->priv->antialias_subpixel_sample,
ANTIALIAS_RGBA,
HINT_FULL);
group = enum_group_create (dialog,
FONT_ANTIALIASING_KEY,
antialias_enums,
ANTIALIAS_GRAYSCALE,
dialog->priv->antialias_none_radiobutton,
ANTIALIAS_NONE,
dialog->priv->antialias_grayscale_radiobutton,
ANTIALIAS_GRAYSCALE,
dialog->priv->antialias_subpixel_radiobutton,
ANTIALIAS_RGBA,
NULL);
dialog->priv->font_groups = g_slist_prepend (dialog->priv->font_groups, group);
setup_font_sample (dialog->priv->hint_none_sample, ANTIALIAS_GRAYSCALE, HINT_NONE);
setup_font_sample (dialog->priv->hint_slight_sample, ANTIALIAS_GRAYSCALE, HINT_SLIGHT);
setup_font_sample (dialog->priv->hint_medium_sample, ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
setup_font_sample (dialog->priv->hint_full_sample, ANTIALIAS_GRAYSCALE, HINT_FULL);
group = enum_group_create (dialog,
FONT_HINTING_KEY,
hint_enums,
HINT_FULL,
dialog->priv->hint_none_radiobutton, HINT_NONE,
dialog->priv->hint_slight_radiobutton, HINT_SLIGHT,
dialog->priv->hint_medium_radiobutton, HINT_MEDIUM,
dialog->priv->hint_full_radiobutton, HINT_FULL,
NULL);
dialog->priv->font_groups = g_slist_prepend (dialog->priv->font_groups, group);
gtk_image_set_from_file (GTK_IMAGE (dialog->priv->subpixel_rgb_image),
GNOMECC_PIXMAP_DIR "/subpixel-rgb.png");
gtk_image_set_from_file (GTK_IMAGE (dialog->priv->subpixel_bgr_image),
GNOMECC_PIXMAP_DIR "/subpixel-bgr.png");
gtk_image_set_from_file (GTK_IMAGE (dialog->priv->subpixel_vrgb_image),
GNOMECC_PIXMAP_DIR "/subpixel-vrgb.png");
gtk_image_set_from_file (GTK_IMAGE (dialog->priv->subpixel_vbgr_image),
GNOMECC_PIXMAP_DIR "/subpixel-vbgr.png");
group = enum_group_create (dialog,
FONT_RGBA_ORDER_KEY, rgba_order_enums, RGBA_RGB,
dialog->priv->subpixel_rgb_radiobutton, RGBA_RGB,
dialog->priv->subpixel_bgr_radiobutton, RGBA_BGR,
dialog->priv->subpixel_vrgb_radiobutton, RGBA_VRGB,
dialog->priv->subpixel_vbgr_radiobutton, RGBA_VBGR,
NULL);
dialog->priv->font_groups = g_slist_prepend (dialog->priv->font_groups, group);
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
widget = WID ("render_details_vbox");
box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_widget_reparent (widget, box);
gtk_widget_show (widget);
g_object_unref (builder);
g_object_unref (client);
}
static GObject *
cc_font_details_dialog_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcFontDetailsDialog *dialog;
dialog = CC_FONT_DETAILS_DIALOG (G_OBJECT_CLASS (cc_font_details_dialog_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
setup_dialog (dialog);
return G_OBJECT (dialog);
}
static void
cc_font_details_dialog_class_init (CcFontDetailsDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_font_details_dialog_get_property;
object_class->set_property = cc_font_details_dialog_set_property;
object_class->constructor = cc_font_details_dialog_constructor;
object_class->finalize = cc_font_details_dialog_finalize;
g_type_class_add_private (klass, sizeof (CcFontDetailsDialogPrivate));
}
static void
cc_font_details_dialog_init (CcFontDetailsDialog *dialog)
{
dialog->priv = CC_FONT_DETAILS_DIALOG_GET_PRIVATE (dialog);
}
static void
cc_font_details_dialog_finalize (GObject *object)
{
CcFontDetailsDialog *dialog;
GConfClient *client;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_FONT_DETAILS_DIALOG (object));
dialog = CC_FONT_DETAILS_DIALOG (object);
g_return_if_fail (dialog->priv != NULL);
client = gconf_client_get_default ();
gconf_client_notify_remove (client, dialog->priv->dpi_notify_id);
g_object_unref (client);
g_slist_foreach (dialog->priv->font_groups,
(GFunc) enum_group_destroy,
NULL);
g_slist_free (dialog->priv->font_groups);
G_OBJECT_CLASS (cc_font_details_dialog_parent_class)->finalize (object);
}
GtkWidget *
cc_font_details_dialog_new (void)
{
GObject *object;
object = g_object_new (CC_TYPE_FONT_DETAILS_DIALOG,
"title", _("Font Rendering Details"),
"has-separator", FALSE,
NULL);
return GTK_WIDGET (object);
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 William Jon McCann
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_FONT_DETAILS_DIALOG_H
#define __CC_FONT_DETAILS_DIALOG_H
#include <glib-object.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define CC_TYPE_FONT_DETAILS_DIALOG (cc_font_details_dialog_get_type ())
#define CC_FONT_DETAILS_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_FONT_DETAILS_DIALOG, CcFontDetailsDialog))
#define CC_FONT_DETAILS_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_FONT_DETAILS_DIALOG, CcFontDetailsDialogClass))
#define CC_IS_FONT_DETAILS_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_FONT_DETAILS_DIALOG))
#define CC_IS_FONT_DETAILS_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_FONT_DETAILS_DIALOG))
#define CC_FONT_DETAILS_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_FONT_DETAILS_DIALOG, CcFontDetailsDialogClass))
typedef struct CcFontDetailsDialogPrivate CcFontDetailsDialogPrivate;
typedef struct
{
GtkDialog parent;
CcFontDetailsDialogPrivate *priv;
} CcFontDetailsDialog;
typedef struct
{
GtkDialogClass parent_class;
} CcFontDetailsDialogClass;
#define CC_FONT_DETAILS_DIALOG_ERROR (cc_font_details_dialog_error_quark ())
GType cc_font_details_dialog_get_type (void);
GQuark cc_font_details_dialog_error_quark (void);
GtkWidget * cc_font_details_dialog_new (void);
G_END_DECLS
#endif /* __CC_FONT_DETAILS_DIALOG_H */

View File

@@ -0,0 +1,691 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2002 Jonathan Blandford <jrb@gnome.org>
* Copyright (C) 2007 Jens Granseuer <jensgr@gmx.net>
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include "gconf-property-editor.h"
#include "cc-font-page.h"
#include "cc-font-details-dialog.h"
#include "cc-font-common.h"
#define CC_FONT_PAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_FONT_PAGE, CcFontPagePrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcFontPagePrivate
{
GtkWidget *window_title_font;
GtkWidget *desktop_font;
GtkWidget *document_font;
GtkWidget *monospace_font;
GtkWidget *application_font;
GtkWidget *font_details_dialog;
GSList *font_pairs;
gboolean in_change;
char *old_font;
guint metacity_font_notify_id;
guint font_render_notify_id;
};
enum {
PROP_0,
};
static void cc_font_page_class_init (CcFontPageClass *klass);
static void cc_font_page_init (CcFontPage *font_page);
static void cc_font_page_finalize (GObject *object);
G_DEFINE_TYPE (CcFontPage, cc_font_page, CC_TYPE_PAGE)
static GConfEnumStringPair antialias_enums[] = {
{ ANTIALIAS_NONE, "none" },
{ ANTIALIAS_GRAYSCALE, "grayscale" },
{ ANTIALIAS_RGBA, "rgba" },
{ -1, NULL }
};
static GConfEnumStringPair hint_enums[] = {
{ HINT_NONE, "none" },
{ HINT_SLIGHT, "slight" },
{ HINT_MEDIUM, "medium" },
{ HINT_FULL, "full" },
{ -1, NULL }
};
static void
cc_font_page_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_font_page_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*
* Code implementing a group of radio buttons with different Xft option combinations.
* If one of the buttons is matched by the GConf key, we pick it. Otherwise we
* show the group as inconsistent.
*/
static void
font_render_get_gconf (GConfClient *client,
Antialiasing *antialiasing,
Hinting *hinting)
{
char *antialias_str = gconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL);
char *hint_str = gconf_client_get_string (client, FONT_HINTING_KEY, NULL);
int val;
val = ANTIALIAS_GRAYSCALE;
if (antialias_str) {
gconf_string_to_enum (antialias_enums, antialias_str, &val);
g_free (antialias_str);
}
*antialiasing = val;
val = HINT_FULL;
if (hint_str) {
gconf_string_to_enum (hint_enums, hint_str, &val);
g_free (hint_str);
}
*hinting = val;
}
typedef struct {
Antialiasing antialiasing;
Hinting hinting;
GtkToggleButton *radio;
} FontPair;
static void
font_render_load (CcFontPage *page)
{
Antialiasing antialiasing;
Hinting hinting;
gboolean inconsistent = TRUE;
GSList *tmp_list;
GConfClient *client;
client = gconf_client_get_default ();
font_render_get_gconf (client, &antialiasing, &hinting);
g_object_unref (client);
page->priv->in_change = TRUE;
for (tmp_list = page->priv->font_pairs; tmp_list; tmp_list = tmp_list->next) {
FontPair *pair = tmp_list->data;
if (antialiasing == pair->antialiasing && hinting == pair->hinting) {
gtk_toggle_button_set_active (pair->radio, TRUE);
inconsistent = FALSE;
break;
}
}
for (tmp_list = page->priv->font_pairs; tmp_list; tmp_list = tmp_list->next) {
FontPair *pair = tmp_list->data;
gtk_toggle_button_set_inconsistent (pair->radio, inconsistent);
}
page->priv->in_change = FALSE;
}
static void
on_font_render_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
CcFontPage *page)
{
font_render_load (page);
}
static void
on_font_radio_toggled (GtkToggleButton *toggle_button,
CcFontPage *page)
{
GSList *l;
if (!page->priv->in_change) {
GConfClient *client = gconf_client_get_default ();
FontPair *pair;
pair = NULL;
for (l = page->priv->font_pairs; l != NULL; l = l->next) {
FontPair *p;
p = l->data;
if (p->radio == toggle_button) {
pair = p;
break;
}
}
g_assert (pair != NULL);
gconf_client_set_string (client,
FONT_ANTIALIASING_KEY,
gconf_enum_to_string (antialias_enums, pair->antialiasing),
NULL);
gconf_client_set_string (client,
FONT_HINTING_KEY,
gconf_enum_to_string (hint_enums, pair->hinting),
NULL);
/* Restore back to the previous state until we get notification */
font_render_load (page);
g_object_unref (client);
}
}
static void
setup_font_pair (CcFontPage *page,
GtkWidget *radio,
GtkWidget *darea,
Antialiasing antialiasing,
Hinting hinting)
{
FontPair *pair = g_new (FontPair, 1);
pair->antialiasing = antialiasing;
pair->hinting = hinting;
pair->radio = GTK_TOGGLE_BUTTON (radio);
setup_font_sample (darea, antialiasing, hinting);
page->priv->font_pairs = g_slist_prepend (page->priv->font_pairs, pair);
g_signal_connect (radio,
"toggled",
G_CALLBACK (on_font_radio_toggled),
page);
}
static void
metacity_titlebar_load_sensitivity (CcFontPage *page)
{
GConfClient *client;
client = gconf_client_get_default ();
gtk_widget_set_sensitive (page->priv->window_title_font,
!gconf_client_get_bool (client,
WINDOW_TITLE_USES_SYSTEM_KEY,
NULL));
g_object_unref (client);
}
static void
on_metacity_font_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
CcFontPage *page)
{
metacity_titlebar_load_sensitivity (page);
}
/* returns 0 if the font is safe, otherwise returns the size in points. */
static gint
font_dangerous (const char *font)
{
PangoFontDescription *pfd;
gboolean retval = 0;
pfd = pango_font_description_from_string (font);
if (pfd == NULL)
/* an invalid font was passed in. This isn't our problem. */
return 0;
if ((pango_font_description_get_set_fields (pfd) & PANGO_FONT_MASK_SIZE) &&
(pango_font_description_get_size (pfd) >= MAX_FONT_SIZE_WITHOUT_WARNING)) {
retval = pango_font_description_get_size (pfd)/1024;
}
pango_font_description_free (pfd);
return retval;
}
static GConfValue *
application_font_to_gconf (GConfPropertyEditor *peditor,
GConfValue *value)
{
GConfValue *new_value;
const char *new_font;
GtkWidget *font_button;
gint danger_level;
CcFontPage *page;
page = g_object_get_data (G_OBJECT (peditor), "page");
font_button = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
g_return_val_if_fail (font_button != NULL, NULL);
new_value = gconf_value_new (GCONF_VALUE_STRING);
new_font = gconf_value_get_string (value);
if (font_dangerous (page->priv->old_font)) {
/* If we're already too large, we don't warn again. */
gconf_value_set_string (new_value, new_font);
return new_value;
}
danger_level = font_dangerous (new_font);
if (danger_level) {
GtkWidget *warning_dialog, *apply_button;
const char *warning_label;
char *warning_label2;
warning_label = _("Font may be too large");
if (danger_level > MAX_FONT_POINT_WITHOUT_WARNING) {
warning_label2 = g_strdup_printf (ngettext (
"The font selected is %d point large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a size smaller than %d.",
"The font selected is %d points large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a size smaller than %d.",
danger_level),
danger_level,
MAX_FONT_POINT_WITHOUT_WARNING);
} else {
warning_label2 = g_strdup_printf (ngettext (
"The font selected is %d point large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a smaller sized font.",
"The font selected is %d points large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a smaller sized font.",
danger_level),
danger_level);
}
warning_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
"%s",
warning_label);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (warning_dialog),
"%s", warning_label2);
gtk_dialog_add_button (GTK_DIALOG (warning_dialog),
_("Use previous font"), GTK_RESPONSE_CLOSE);
apply_button = gtk_button_new_with_label (_("Use selected font"));
gtk_button_set_image (GTK_BUTTON (apply_button), gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON));
gtk_dialog_add_action_widget (GTK_DIALOG (warning_dialog), apply_button, GTK_RESPONSE_APPLY);
GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT);
gtk_widget_show (apply_button);
gtk_dialog_set_default_response (GTK_DIALOG (warning_dialog), GTK_RESPONSE_CLOSE);
g_free (warning_label2);
if (gtk_dialog_run (GTK_DIALOG (warning_dialog)) == GTK_RESPONSE_APPLY) {
gconf_value_set_string (new_value, new_font);
} else {
gconf_value_set_string (new_value, page->priv->old_font);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_button), page->priv->old_font);
}
gtk_widget_destroy (warning_dialog);
} else {
gconf_value_set_string (new_value, new_font);
}
return new_value;
}
static void
on_application_font_changed (CcFontPage *page)
{
const char *font;
font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (page->priv->application_font));
g_free (page->priv->old_font);
page->priv->old_font = g_strdup (font);
}
#ifdef HAVE_XFT2
static void
on_font_details_response (GtkDialog *dialog,
gint response_id,
CcFontPage *page)
{
if (page->priv->font_details_dialog != NULL) {
gtk_widget_destroy (page->priv->font_details_dialog);
page->priv->font_details_dialog = NULL;
}
}
static void
on_details_button_clicked (GtkWidget *button,
CcFontPage *page)
{
if (page->priv->font_details_dialog == NULL) {
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (page));
if (!GTK_WIDGET_TOPLEVEL (toplevel)) {
toplevel = NULL;
}
page->priv->font_details_dialog = cc_font_details_dialog_new ();
g_signal_connect (page->priv->font_details_dialog,
"response",
G_CALLBACK (on_font_details_response),
page);
gtk_window_set_transient_for (GTK_WINDOW (page->priv->font_details_dialog),
GTK_WINDOW (toplevel));
}
gtk_window_present (GTK_WINDOW (page->priv->font_details_dialog));
}
#endif /* HAVE_XFT2 */
static void
setup_page (CcFontPage *page)
{
GtkBuilder *builder;
GtkWidget *widget;
GError *error;
GConfClient *client;
GObject *peditor;
client = gconf_client_get_default ();
builder = gtk_builder_new ();
error = NULL;
gtk_builder_add_from_file (builder,
GNOMECC_UI_DIR
"/appearance.ui",
&error);
if (error != NULL) {
g_error (_("Could not load user interface file: %s"),
error->message);
g_error_free (error);
return;
}
page->priv->font_details_dialog = NULL;
gconf_client_add_dir (client,
"/desktop/gnome/interface",
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
gconf_client_add_dir (client,
"/apps/nautilus/preferences",
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
gconf_client_add_dir (client,
METACITY_DIR,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
#ifdef HAVE_XFT2
gconf_client_add_dir (client,
FONT_RENDER_DIR,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
#endif /* HAVE_XFT2 */
page->priv->window_title_font = WID ("window_title_font");
page->priv->application_font = WID ("application_font");
page->priv->desktop_font = WID ("desktop_font");
page->priv->document_font = WID ("document_font");
page->priv->monospace_font = WID ("monospace_font");
peditor = gconf_peditor_new_font (NULL,
GTK_FONT_KEY,
page->priv->application_font,
"conv-from-widget-cb",
application_font_to_gconf,
NULL);
g_object_set_data (peditor, "page", page);
g_signal_connect_swapped (peditor,
"value-changed",
G_CALLBACK (on_application_font_changed),
page);
on_application_font_changed (page);
peditor = gconf_peditor_new_font (NULL,
DOCUMENT_FONT_KEY,
page->priv->document_font,
NULL);
peditor = gconf_peditor_new_font (NULL,
DESKTOP_FONT_KEY,
page->priv->desktop_font,
NULL);
peditor = gconf_peditor_new_font (NULL,
WINDOW_TITLE_FONT_KEY,
page->priv->window_title_font,
NULL);
peditor = gconf_peditor_new_font (NULL,
MONOSPACE_FONT_KEY,
page->priv->monospace_font,
NULL);
page->priv->metacity_font_notify_id =
gconf_client_notify_add (client,
WINDOW_TITLE_USES_SYSTEM_KEY,
(GConfClientNotifyFunc) on_metacity_font_changed,
page,
NULL,
NULL);
metacity_titlebar_load_sensitivity (page);
#ifdef HAVE_XFT2
setup_font_pair (page,
WID ("monochrome_radio"),
WID ("monochrome_sample"),
ANTIALIAS_NONE, HINT_FULL);
setup_font_pair (page,
WID ("best_shapes_radio"),
WID ("best_shapes_sample"),
ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
setup_font_pair (page,
WID ("best_contrast_radio"),
WID ("best_contrast_sample"),
ANTIALIAS_GRAYSCALE, HINT_FULL);
setup_font_pair (page,
WID ("subpixel_radio"),
WID ("subpixel_sample"),
ANTIALIAS_RGBA, HINT_FULL);
font_render_load (page);
page->priv->font_render_notify_id =
gconf_client_notify_add (client,
FONT_RENDER_DIR,
(GConfClientNotifyFunc) on_font_render_changed,
page,
NULL,
NULL);
g_signal_connect (WID ("details_button"),
"clicked",
G_CALLBACK (on_details_button_clicked),
page);
#else /* !HAVE_XFT2 */
gtk_widget_hide (WID ("font_render_frame"));
#endif /* HAVE_XFT2 */
widget = WID ("font_vbox");
gtk_widget_reparent (widget, GTK_WIDGET (page));
gtk_widget_show (widget);
g_object_unref (client);
g_object_unref (builder);
}
static GObject *
cc_font_page_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcFontPage *font_page;
font_page = CC_FONT_PAGE (G_OBJECT_CLASS (cc_font_page_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (font_page,
"display-name", _("Font"),
"id", "font",
NULL);
setup_page (font_page);
return G_OBJECT (font_page);
}
static void
start_working (CcFontPage *page)
{
static gboolean once = FALSE;
if (!once) {
once = TRUE;
}
}
static void
stop_working (CcFontPage *page)
{
}
static void
cc_font_page_active_changed (CcPage *base_page,
gboolean is_active)
{
CcFontPage *page = CC_FONT_PAGE (base_page);
if (is_active)
start_working (page);
else
stop_working (page);
CC_PAGE_CLASS (cc_font_page_parent_class)->active_changed (base_page, is_active);
}
static void
cc_font_page_class_init (CcFontPageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CcPageClass *page_class = CC_PAGE_CLASS (klass);
object_class->get_property = cc_font_page_get_property;
object_class->set_property = cc_font_page_set_property;
object_class->constructor = cc_font_page_constructor;
object_class->finalize = cc_font_page_finalize;
page_class->active_changed = cc_font_page_active_changed;
g_type_class_add_private (klass, sizeof (CcFontPagePrivate));
}
static void
cc_font_page_init (CcFontPage *page)
{
page->priv = CC_FONT_PAGE_GET_PRIVATE (page);
}
static void
cc_font_page_finalize (GObject *object)
{
CcFontPage *page;
GConfClient *client;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_FONT_PAGE (object));
page = CC_FONT_PAGE (object);
g_return_if_fail (page->priv != NULL);
client = gconf_client_get_default ();
gconf_client_notify_remove (client, page->priv->metacity_font_notify_id);
gconf_client_notify_remove (client, page->priv->font_render_notify_id);
g_object_unref (client);
g_slist_foreach (page->priv->font_pairs,
(GFunc) g_free,
NULL);
g_slist_free (page->priv->font_pairs);
g_free (page->priv->old_font);
G_OBJECT_CLASS (cc_font_page_parent_class)->finalize (object);
}
CcPage *
cc_font_page_new (void)
{
GObject *object;
object = g_object_new (CC_TYPE_FONT_PAGE, NULL);
return CC_PAGE (object);
}

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_FONT_PAGE_H
#define __CC_FONT_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_FONT_PAGE (cc_font_page_get_type ())
#define CC_FONT_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_FONT_PAGE, CcFontPage))
#define CC_FONT_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_FONT_PAGE, CcFontPageClass))
#define CC_IS_FONT_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_FONT_PAGE))
#define CC_IS_FONT_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_FONT_PAGE))
#define CC_FONT_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_FONT_PAGE, CcFontPageClass))
typedef struct CcFontPagePrivate CcFontPagePrivate;
typedef struct
{
CcPage parent;
CcFontPagePrivate *priv;
} CcFontPage;
typedef struct
{
CcPageClass parent_class;
} CcFontPageClass;
GType cc_font_page_get_type (void);
CcPage * cc_font_page_new (void);
G_END_DECLS
#endif /* __CC_FONT_PAGE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 William Jon McCann
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_THEME_CUSTOMIZE_DIALOG_H
#define __CC_THEME_CUSTOMIZE_DIALOG_H
#include <glib-object.h>
#include <gtk/gtk.h>
#include "gnome-theme-info.h"
G_BEGIN_DECLS
#define CC_TYPE_THEME_CUSTOMIZE_DIALOG (cc_theme_customize_dialog_get_type ())
#define CC_THEME_CUSTOMIZE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_THEME_CUSTOMIZE_DIALOG, CcThemeCustomizeDialog))
#define CC_THEME_CUSTOMIZE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_THEME_CUSTOMIZE_DIALOG, CcThemeCustomizeDialogClass))
#define CC_IS_THEME_CUSTOMIZE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_THEME_CUSTOMIZE_DIALOG))
#define CC_IS_THEME_CUSTOMIZE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_THEME_CUSTOMIZE_DIALOG))
#define CC_THEME_CUSTOMIZE_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_THEME_CUSTOMIZE_DIALOG, CcThemeCustomizeDialogClass))
typedef struct CcThemeCustomizeDialogPrivate CcThemeCustomizeDialogPrivate;
typedef struct
{
GtkDialog parent;
CcThemeCustomizeDialogPrivate *priv;
} CcThemeCustomizeDialog;
typedef struct
{
GtkDialogClass parent_class;
} CcThemeCustomizeDialogClass;
#define CC_THEME_CUSTOMIZE_DIALOG_ERROR (cc_theme_customize_dialog_error_quark ())
GType cc_theme_customize_dialog_get_type (void);
GQuark cc_theme_customize_dialog_error_quark (void);
GtkWidget * cc_theme_customize_dialog_new (void);
G_END_DECLS
#endif /* __CC_THEME_CUSTOMIZE_DIALOG_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_THEME_PAGE_H
#define __CC_THEME_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_THEME_PAGE (cc_theme_page_get_type ())
#define CC_THEME_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_THEME_PAGE, CcThemePage))
#define CC_THEME_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_THEME_PAGE, CcThemePageClass))
#define CC_IS_THEME_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_THEME_PAGE))
#define CC_IS_THEME_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_THEME_PAGE))
#define CC_THEME_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_THEME_PAGE, CcThemePageClass))
typedef struct CcThemePagePrivate CcThemePagePrivate;
typedef struct
{
CcPage parent;
CcThemePagePrivate *priv;
} CcThemePage;
typedef struct
{
CcPageClass parent_class;
} CcThemePageClass;
GType cc_theme_page_get_type (void);
CcPage * cc_theme_page_new (void);
G_END_DECLS
#endif /* __CC_THEME_PAGE_H */

View File

@@ -0,0 +1,542 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 William Jon McCann
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <gconf/gconf-client.h>
#include "cc-theme-save-dialog.h"
#define CC_THEME_SAVE_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_THEME_SAVE_DIALOG, CcThemeSaveDialogPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
#define BACKGROUND_KEY "/desktop/gnome/background/picture_filename"
struct CcThemeSaveDialogPrivate
{
GtkWidget *entry;
GtkWidget *text_view;
GtkWidget *save_button;
GtkWidget *save_background_checkbutton;
GnomeThemeMetaInfo *info;
};
enum {
PROP_0,
};
static void cc_theme_save_dialog_class_init (CcThemeSaveDialogClass *klass);
static void cc_theme_save_dialog_init (CcThemeSaveDialog *theme_save_dialog);
static void cc_theme_save_dialog_finalize (GObject *object);
G_DEFINE_TYPE (CcThemeSaveDialog, cc_theme_save_dialog, GTK_TYPE_DIALOG)
enum {
INVALID_THEME_NAME
};
GQuark
cc_theme_save_dialog_error_quark (void)
{
static GQuark error_quark = 0;
if (error_quark == 0)
error_quark = g_quark_from_static_string ("cc-theme-save-dialog");
return error_quark;
}
void
cc_theme_save_dialog_set_theme_info (CcThemeSaveDialog *dialog,
GnomeThemeMetaInfo *info)
{
g_return_if_fail (CC_IS_THEME_SAVE_DIALOG (dialog));
dialog->priv->info = info;
}
static void
cc_theme_save_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
CcThemeSaveDialog *self;
self = CC_THEME_SAVE_DIALOG (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_theme_save_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/* taken from gnome-desktop-item.c */
static gchar *
escape_string_and_dup (const char *s)
{
char *return_value, *p;
const char *q;
int len = 0;
if (s == NULL)
return g_strdup("");
q = s;
while (*q) {
len++;
if (strchr ("\n\r\t\\", *q) != NULL)
len++;
q++;
}
return_value = p = (char *) g_malloc (len + 1);
do {
switch (*s) {
case '\t':
*p++ = '\\';
*p++ = 't';
break;
case '\n':
*p++ = '\\';
*p++ = 'n';
break;
case '\r':
*p++ = '\\';
*p++ = 'r';
break;
case '\\':
*p++ = '\\';
*p++ = '\\';
break;
default:
*p++ = *s;
}
}
while (*s++);
return return_value;
}
static gboolean
check_theme_name (const char *theme_name,
GError **error)
{
if (theme_name == NULL) {
g_set_error (error,
CC_THEME_SAVE_DIALOG_ERROR,
INVALID_THEME_NAME,
_("Theme name must be present"));
return FALSE;
}
return TRUE;
}
static char *
str_remove_slash (const char *src)
{
const char *i;
char *rtn;
gint len = 0;
i = src;
while (*i) {
if (*i != '/')
len++;
i++;
}
rtn = (char *) g_malloc (len + 1);
while (*src) {
if (*src != '/') {
*rtn = *src;
rtn++;
}
src++;
}
*rtn = '\0';
return rtn - len;
}
static gboolean
setup_directory_structure (CcThemeSaveDialog *dialog,
const char *theme_name,
GError **error)
{
char *dir;
char *theme_name_dir;
gboolean retval = TRUE;
theme_name_dir = str_remove_slash (theme_name);
dir = g_build_filename (g_get_home_dir (), ".themes", NULL);
if (!g_file_test (dir, G_FILE_TEST_EXISTS))
g_mkdir (dir, 0775);
g_free (dir);
dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL);
if (!g_file_test (dir, G_FILE_TEST_EXISTS))
g_mkdir (dir, 0775);
g_free (dir);
dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL);
g_free (theme_name_dir);
if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
GtkDialog *ask_dialog;
GtkWidget *button;
int response;
ask_dialog = (GtkDialog *) gtk_message_dialog_new (GTK_WINDOW (dialog),
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_CANCEL,
_("The theme already exists. Would you like to replace it?"));
button = gtk_dialog_add_button (ask_dialog,
_("_Overwrite"),
GTK_RESPONSE_ACCEPT);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_BUTTON));
response = gtk_dialog_run (ask_dialog);
gtk_widget_destroy (GTK_WIDGET (ask_dialog));
retval = (response != GTK_RESPONSE_CANCEL);
}
g_free (dir);
return retval;
}
static gboolean
write_theme_to_disk (CcThemeSaveDialog *dialog,
GnomeThemeMetaInfo *theme_info,
const char *theme_name,
const char *theme_description,
gboolean save_background,
GError **error)
{
char *dir;
char *theme_name_dir;
GFile *tmp_file;
GFile *target_file;
GOutputStream *output;
char *str;
char *current_background;
GConfClient *client;
const char *theme_header =
"[Desktop Entry]\n"
"Name=%s\n"
"Type=X-GNOME-Metatheme\n"
"Comment=%s\n"
"\n"
"[X-GNOME-Metatheme]\n"
"GtkTheme=%s\n"
"MetacityTheme=%s\n"
"IconTheme=%s\n";
theme_name_dir = str_remove_slash (theme_name);
dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL);
g_free (theme_name_dir);
tmp_file = g_file_new_for_path (dir);
dir [strlen (dir) - 1] = '\000';
target_file = g_file_new_for_path (dir);
g_free (dir);
/* start making the theme file */
str = g_strdup_printf (theme_header,
theme_name,
theme_description,
theme_info->gtk_theme_name,
theme_info->metacity_theme_name,
theme_info->icon_theme_name);
output = G_OUTPUT_STREAM (g_file_replace (tmp_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL));
g_output_stream_write (output, str, strlen (str), NULL, NULL);
g_free (str);
if (theme_info->gtk_color_scheme) {
char *a, *tmp;
tmp = g_strdup (theme_info->gtk_color_scheme);
for (a = tmp; *a != '\0'; a++)
if (*a == '\n')
*a = ',';
str = g_strdup_printf ("GtkColorScheme=%s\n", tmp);
g_output_stream_write (output, str, strlen (str), NULL, NULL);
g_free (str);
g_free (tmp);
}
if (theme_info->cursor_theme_name) {
#ifdef HAVE_XCURSOR
str = g_strdup_printf ("CursorTheme=%s\n"
"CursorSize=%i\n",
theme_info->cursor_theme_name,
theme_info->cursor_size);
#else
str = g_strdup_printf ("CursorFont=%s\n", theme_info->cursor_theme_name);
#endif
g_output_stream_write (output, str, strlen (str), NULL, NULL);
g_free (str);
}
if (theme_info->notification_theme_name) {
str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name);
g_output_stream_write (output, str, strlen (str), NULL, NULL);
g_free (str);
}
if (save_background) {
client = gconf_client_get_default ();
current_background = gconf_client_get_string (client, BACKGROUND_KEY, NULL);
if (current_background != NULL) {
str = g_strdup_printf ("BackgroundImage=%s\n", current_background);
g_output_stream_write (output, str, strlen (str), NULL, NULL);
g_free (current_background);
g_free (str);
}
g_object_unref (client);
}
g_file_move (tmp_file, target_file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
g_output_stream_close (output, NULL, NULL);
g_object_unref (tmp_file);
g_object_unref (target_file);
return TRUE;
}
static gboolean
save_theme_to_disk (CcThemeSaveDialog *dialog,
GnomeThemeMetaInfo *theme_info,
const char *theme_name,
const char *theme_description,
gboolean save_background,
GError **error)
{
if (!check_theme_name (theme_name, error))
return FALSE;
if (!setup_directory_structure (dialog, theme_name, error))
return FALSE;
if (!write_theme_to_disk (dialog, theme_info, theme_name, theme_description, save_background, error))
return FALSE;
return TRUE;
}
static gboolean
do_save (CcThemeSaveDialog *dialog)
{
GtkTextBuffer *buffer;
GtkTextIter start_iter;
GtkTextIter end_iter;
char *buffer_text;
char *theme_description = NULL;
char *theme_name = NULL;
gboolean save_background;
GError *error = NULL;
gboolean ret;
ret = FALSE;
theme_name = escape_string_and_dup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->priv->text_view));
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_end_iter (buffer, &end_iter);
buffer_text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
theme_description = escape_string_and_dup (buffer_text);
g_free (buffer_text);
save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->save_background_checkbutton));
ret = save_theme_to_disk (dialog, dialog->priv->info, theme_name, theme_description, save_background, &error);
g_free (theme_name);
g_free (theme_description);
g_clear_error (&error);
return ret;
}
static void
cc_theme_save_dialog_response (GtkDialog *dialog,
gint response_id)
{
switch (response_id) {
case GTK_RESPONSE_OK:
if (!do_save (CC_THEME_SAVE_DIALOG (dialog))) {
g_signal_stop_emission_by_name (dialog, "response");
gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
}
break;
default:
break;
}
}
static void
on_entry_text_changed (GtkEditable *editable,
CcThemeSaveDialog *dialog)
{
const char *text;
text = gtk_entry_get_text (GTK_ENTRY (editable));
gtk_widget_set_sensitive (dialog->priv->save_button,
text != NULL && text[0] != '\000');
}
static GObject *
cc_theme_save_dialog_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcThemeSaveDialog *dialog;
GtkBuilder *builder;
GtkWidget *widget;
GtkWidget *box;
GtkTextBuffer *text_buffer;
GError *error;
dialog = CC_THEME_SAVE_DIALOG (G_OBJECT_CLASS (cc_theme_save_dialog_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
builder = gtk_builder_new ();
error = NULL;
gtk_builder_add_from_file (builder,
GNOMECC_UI_DIR
"/appearance.ui",
&error);
if (error != NULL) {
g_error (_("Could not load user interface file: %s"),
error->message);
g_error_free (error);
return NULL;
}
dialog->priv->entry = WID ("save_dialog_entry");
dialog->priv->text_view = WID ("save_dialog_textview");
dialog->priv->save_background_checkbutton = WID ("save_background_checkbutton");
g_signal_connect (dialog->priv->entry,
"changed",
(GCallback) on_entry_text_changed,
dialog);
gtk_widget_set_size_request (dialog->priv->text_view, 300, 100);
text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->priv->text_view));
gtk_text_buffer_set_text (text_buffer, "", 0);
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
dialog->priv->save_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_SAVE, GTK_RESPONSE_OK);
gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry), "");
on_entry_text_changed (GTK_EDITABLE (dialog->priv->entry), dialog);
gtk_widget_grab_focus (dialog->priv->entry);
widget = WID ("save_dialog_table");
box = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_widget_reparent (widget, box);
gtk_widget_show (widget);
g_object_unref (builder);
return G_OBJECT (dialog);
}
static void
cc_theme_save_dialog_class_init (CcThemeSaveDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
object_class->get_property = cc_theme_save_dialog_get_property;
object_class->set_property = cc_theme_save_dialog_set_property;
object_class->constructor = cc_theme_save_dialog_constructor;
object_class->finalize = cc_theme_save_dialog_finalize;
dialog_class->response = cc_theme_save_dialog_response;
g_type_class_add_private (klass, sizeof (CcThemeSaveDialogPrivate));
}
static void
cc_theme_save_dialog_init (CcThemeSaveDialog *dialog)
{
dialog->priv = CC_THEME_SAVE_DIALOG_GET_PRIVATE (dialog);
}
static void
cc_theme_save_dialog_finalize (GObject *object)
{
CcThemeSaveDialog *theme_save_dialog;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_THEME_SAVE_DIALOG (object));
theme_save_dialog = CC_THEME_SAVE_DIALOG (object);
g_return_if_fail (theme_save_dialog->priv != NULL);
G_OBJECT_CLASS (cc_theme_save_dialog_parent_class)->finalize (object);
}
GtkWidget *
cc_theme_save_dialog_new (void)
{
GObject *object;
object = g_object_new (CC_TYPE_THEME_SAVE_DIALOG,
"title", _("Save Theme As..."),
"has-separator", FALSE,
NULL);
return GTK_WIDGET (object);
}

View File

@@ -0,0 +1,62 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 William Jon McCann
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_THEME_SAVE_DIALOG_H
#define __CC_THEME_SAVE_DIALOG_H
#include <glib-object.h>
#include <gtk/gtk.h>
#include "gnome-theme-info.h"
G_BEGIN_DECLS
#define CC_TYPE_THEME_SAVE_DIALOG (cc_theme_save_dialog_get_type ())
#define CC_THEME_SAVE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_THEME_SAVE_DIALOG, CcThemeSaveDialog))
#define CC_THEME_SAVE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_THEME_SAVE_DIALOG, CcThemeSaveDialogClass))
#define CC_IS_THEME_SAVE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_THEME_SAVE_DIALOG))
#define CC_IS_THEME_SAVE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_THEME_SAVE_DIALOG))
#define CC_THEME_SAVE_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_THEME_SAVE_DIALOG, CcThemeSaveDialogClass))
typedef struct CcThemeSaveDialogPrivate CcThemeSaveDialogPrivate;
typedef struct
{
GtkDialog parent;
CcThemeSaveDialogPrivate *priv;
} CcThemeSaveDialog;
typedef struct
{
GtkDialogClass parent_class;
} CcThemeSaveDialogClass;
#define CC_THEME_SAVE_DIALOG_ERROR (cc_theme_save_dialog_error_quark ())
GType cc_theme_save_dialog_get_type (void);
GQuark cc_theme_save_dialog_error_quark (void);
GtkWidget * cc_theme_save_dialog_new (void);
void cc_theme_save_dialog_set_theme_info (CcThemeSaveDialog *dialog,
GnomeThemeMetaInfo *info);
G_END_DECLS
#endif /* __CC_THEME_SAVE_DIALOG_H */

View File

@@ -14,7 +14,7 @@
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox7">
<object class="GtkVBox" id="render_details_vbox">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
@@ -1129,7 +1129,7 @@
</packing>
</child>
<child>
<object class="GtkVBox" id="fonts_vbox">
<object class="GtkVBox" id="font_vbox">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
@@ -1678,7 +1678,7 @@
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkNotebook" id="notebook2">
<object class="GtkNotebook" id="theme_details_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -1773,6 +1773,7 @@
<child>
<object class="GtkHBox" id="color_scheme_message_hbox">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="no_show_all">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="image2">
@@ -2299,7 +2300,10 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Small</property>
<property name="use_markup">True</property>
<attributes>
<attribute name="style" value="normal"/>
<attribute name="scale" value="0.833000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
@@ -2324,7 +2328,10 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Large</property>
<property name="use_markup">True</property>
<attributes>
<attribute name="style" value="normal"/>
<attribute name="scale" value="0.833000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
@@ -2451,7 +2458,7 @@
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkTable" id="table3">
<object class="GtkTable" id="save_dialog_table">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="n_rows">3</property>

View File

@@ -123,7 +123,6 @@ void gnome_wp_item_update (GnomeWPItem *item) {
}
GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GHashTable * wallpapers,
GnomeDesktopThumbnailFactory * thumbnails) {
GnomeWPItem *item = g_new0 (GnomeWPItem, 1);
@@ -143,8 +142,6 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
gnome_wp_item_update (item);
gnome_wp_item_ensure_gnome_bg (item);
gnome_wp_item_update_description (item);
g_hash_table_insert (wallpapers, item->filename, item);
} else {
gnome_wp_item_free (item);
item = NULL;

View File

@@ -66,7 +66,6 @@ struct _GnomeWPItem {
};
GnomeWPItem * gnome_wp_item_new (const gchar *filename,
GHashTable *wallpapers,
GnomeDesktopThumbnailFactory *thumbnails);
void gnome_wp_item_free (GnomeWPItem *item);

View File

@@ -83,7 +83,7 @@ static void gnome_wp_load_legacy (AppearanceData *data) {
continue;
}
item = gnome_wp_item_new (foo, data->wp_hash, data->thumb_factory);
item = gnome_wp_item_new (foo, data->thumb_factory);
if (item != NULL && item->fileinfo == NULL) {
gnome_wp_item_free (item);
}

View File

@@ -1,4 +1,5 @@
/*
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 The GNOME Foundation
* Written by Thomas Wood <thos@gnome.org>
* Jens Granseuer <jensgr@gmx.net>
@@ -32,229 +33,234 @@
gboolean
theme_is_writable (const gpointer theme)
{
GnomeThemeCommonInfo *info = theme;
GFile *file;
GFileInfo *file_info;
gboolean writable;
GnomeThemeCommonInfo *info = theme;
GFile *file;
GFileInfo *file_info;
gboolean writable;
if (info == NULL || info->path == NULL)
return FALSE;
if (info == NULL || info->path == NULL)
return FALSE;
file = g_file_new_for_path (info->path);
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
g_object_unref (file);
file = g_file_new_for_path (info->path);
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
g_object_unref (file);
if (file_info == NULL)
return FALSE;
if (file_info == NULL)
return FALSE;
writable = g_file_info_get_attribute_boolean (file_info,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
g_object_unref (file_info);
writable = g_file_info_get_attribute_boolean (file_info,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
g_object_unref (file_info);
return writable;
return writable;
}
gboolean
theme_delete (const gchar *name, ThemeType type)
theme_delete (const char *name,
ThemeType type)
{
gboolean rc;
GtkDialog *dialog;
gchar *theme_dir;
gint response;
GnomeThemeCommonInfo *theme;
GFile *dir;
gboolean del_empty_parent;
gboolean rc;
GtkDialog *dialog;
gchar *theme_dir;
gint response;
GnomeThemeCommonInfo *theme;
GFile *dir;
gboolean del_empty_parent;
dialog = (GtkDialog *) gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_CANCEL,
_("Would you like to delete this theme?"));
gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
response = gtk_dialog_run (dialog);
gtk_widget_destroy (GTK_WIDGET (dialog));
if (response != GTK_RESPONSE_ACCEPT)
return FALSE;
dialog = (GtkDialog *) gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_CANCEL,
_("Would you like to delete this theme?"));
gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
response = gtk_dialog_run (dialog);
gtk_widget_destroy (GTK_WIDGET (dialog));
if (response != GTK_RESPONSE_ACCEPT)
return FALSE;
/* Most theme types are put into separate subdirectories. For those
we want to delete those directories as well. */
del_empty_parent = TRUE;
/* Most theme types are put into separate subdirectories. For those
we want to delete those directories as well. */
del_empty_parent = TRUE;
switch (type) {
case THEME_TYPE_GTK:
theme = (GnomeThemeCommonInfo *) gnome_theme_info_find (name);
theme_dir = g_build_filename (theme->path, "gtk-2.0", NULL);
break;
switch (type) {
case THEME_TYPE_GTK:
theme = (GnomeThemeCommonInfo *) gnome_theme_info_find (name);
theme_dir = g_build_filename (theme->path, "gtk-2.0", NULL);
break;
case THEME_TYPE_ICON:
theme = (GnomeThemeCommonInfo *) gnome_theme_icon_info_find (name);
theme_dir = g_path_get_dirname (theme->path);
del_empty_parent = FALSE;
break;
case THEME_TYPE_ICON:
theme = (GnomeThemeCommonInfo *) gnome_theme_icon_info_find (name);
theme_dir = g_path_get_dirname (theme->path);
del_empty_parent = FALSE;
break;
case THEME_TYPE_WINDOW:
theme = (GnomeThemeCommonInfo *) gnome_theme_info_find (name);
theme_dir = g_build_filename (theme->path, "metacity-1", NULL);
break;
case THEME_TYPE_WINDOW:
theme = (GnomeThemeCommonInfo *) gnome_theme_info_find (name);
theme_dir = g_build_filename (theme->path, "metacity-1", NULL);
break;
case THEME_TYPE_META:
theme = (GnomeThemeCommonInfo *) gnome_theme_meta_info_find (name);
theme_dir = g_strdup (theme->path);
break;
case THEME_TYPE_META:
theme = (GnomeThemeCommonInfo *) gnome_theme_meta_info_find (name);
theme_dir = g_strdup (theme->path);
break;
case THEME_TYPE_CURSOR:
theme = (GnomeThemeCommonInfo *) gnome_theme_cursor_info_find (name);
theme_dir = g_build_filename (theme->path, "cursors", NULL);
break;
case THEME_TYPE_CURSOR:
theme = (GnomeThemeCommonInfo *) gnome_theme_cursor_info_find (name);
theme_dir = g_build_filename (theme->path, "cursors", NULL);
break;
default:
return FALSE;
}
default:
return FALSE;
}
dir = g_file_new_for_path (theme_dir);
g_free (theme_dir);
dir = g_file_new_for_path (theme_dir);
g_free (theme_dir);
if (!capplet_file_delete_recursive (dir, NULL)) {
GtkWidget *info_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Theme cannot be deleted"));
gtk_dialog_run (GTK_DIALOG (info_dialog));
gtk_widget_destroy (info_dialog);
rc = FALSE;
} else {
if (del_empty_parent) {
/* also delete empty parent directories */
GFile *parent = g_file_get_parent (dir);
g_file_delete (parent, NULL, NULL);
g_object_unref (parent);
}
rc = TRUE;
}
if (!capplet_file_delete_recursive (dir, NULL)) {
GtkWidget *info_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Theme cannot be deleted"));
gtk_dialog_run (GTK_DIALOG (info_dialog));
gtk_widget_destroy (info_dialog);
rc = FALSE;
} else {
if (del_empty_parent) {
/* also delete empty parent directories */
GFile *parent = g_file_get_parent (dir);
g_file_delete (parent, NULL, NULL);
g_object_unref (parent);
}
rc = TRUE;
}
g_object_unref (dir);
return rc;
g_object_unref (dir);
return rc;
}
gboolean
theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter)
theme_model_iter_last (GtkTreeModel *model,
GtkTreeIter *iter)
{
GtkTreeIter walk, prev;
gboolean valid;
GtkTreeIter walk, prev;
gboolean valid;
valid = gtk_tree_model_get_iter_first (model, &walk);
valid = gtk_tree_model_get_iter_first (model, &walk);
if (valid) {
do {
prev = walk;
valid = gtk_tree_model_iter_next (model, &walk);
} while (valid);
if (valid) {
do {
prev = walk;
valid = gtk_tree_model_iter_next (model, &walk);
} while (valid);
*iter = prev;
return TRUE;
}
return FALSE;
*iter = prev;
return TRUE;
}
return FALSE;
}
gboolean
theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
theme_find_in_model (GtkTreeModel *model,
const char *name,
GtkTreeIter *iter)
{
GtkTreeIter walk;
gboolean valid;
gchar *test;
GtkTreeIter walk;
gboolean valid;
gchar *test;
if (!name)
return FALSE;
if (!name)
return FALSE;
for (valid = gtk_tree_model_get_iter_first (model, &walk); valid;
valid = gtk_tree_model_iter_next (model, &walk))
{
gtk_tree_model_get (model, &walk, COL_NAME, &test, -1);
for (valid = gtk_tree_model_get_iter_first (model, &walk); valid;
valid = gtk_tree_model_iter_next (model, &walk))
{
gtk_tree_model_get (model, &walk, COL_NAME, &test, -1);
if (test) {
gint cmp = strcmp (test, name);
g_free (test);
if (test) {
gint cmp = strcmp (test, name);
g_free (test);
if (!cmp) {
if (iter)
*iter = walk;
return TRUE;
}
}
}
if (!cmp) {
if (iter)
*iter = walk;
return TRUE;
}
}
}
return FALSE;
return FALSE;
}
gboolean
packagekit_available (void)
{
DBusGConnection *connection;
DBusGProxy *proxy;
gboolean available = FALSE;
DBusGConnection *connection;
DBusGProxy *proxy;
gboolean available = FALSE;
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
if (connection == NULL) {
return FALSE;
}
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
if (connection == NULL) {
return FALSE;
}
proxy = dbus_g_proxy_new_for_name (connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
proxy = dbus_g_proxy_new_for_name (connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
org_freedesktop_DBus_name_has_owner (proxy,
"org.freedesktop.PackageKit",
&available,
NULL);
org_freedesktop_DBus_name_has_owner (proxy,
"org.freedesktop.PackageKit",
&available,
NULL);
g_object_unref (proxy);
dbus_g_connection_unref (connection);
g_object_unref (proxy);
dbus_g_connection_unref (connection);
return available;
return available;
}
void
theme_install_file (GtkWindow *parent, const gchar *path)
theme_install_file (GtkWindow *parent,
const char *path)
{
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
gboolean ret;
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
gboolean ret;
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
if (connection == NULL) {
g_warning ("Could not get session bus");
return;
}
connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
if (connection == NULL) {
g_warning ("Could not get session bus");
return;
}
proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit");
proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit");
ret = dbus_g_proxy_call (proxy, "InstallProvideFile", &error,
G_TYPE_STRING, path,
G_TYPE_INVALID, G_TYPE_INVALID);
ret = dbus_g_proxy_call (proxy, "InstallProvideFile", &error,
G_TYPE_STRING, path,
G_TYPE_INVALID, G_TYPE_INVALID);
g_object_unref (proxy);
g_object_unref (proxy);
if (!ret) {
GtkWidget *dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Could not install theme engine"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
if (!ret) {
GtkWidget *dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
_("Could not install theme engine"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_error_free (error);
}
dbus_g_connection_unref (connection);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_error_free (error);
}
dbus_g_connection_unref (connection);
}

View File

@@ -53,12 +53,17 @@ typedef enum {
THEME_TYPE_CURSOR
} ThemeType;
gboolean theme_is_writable (const gpointer theme);
gboolean theme_delete (const gchar *name, ThemeType type);
gboolean theme_is_writable (const gpointer theme);
gboolean theme_delete (const gchar *name,
ThemeType type);
gboolean theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter);
gboolean theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter);
gboolean theme_model_iter_last (GtkTreeModel *model,
GtkTreeIter *iter);
gboolean theme_find_in_model (GtkTreeModel *model,
const gchar *name,
GtkTreeIter *iter);
void theme_install_file (GtkWindow *parent, const gchar *path);
gboolean packagekit_available (void);
void theme_install_file (GtkWindow *parent,
const gchar *path);
gboolean packagekit_available (void);

View File

@@ -1,63 +0,0 @@
EXTRA_DIST =
INCLUDES = \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGTK_ENGINE_DIR="\"$(GTK_ENGINE_DIR)\"" \
-DG_LOG_DOMAIN=\"capplet-common\" \
-DINSTALL_PREFIX=\"$(prefix)\" \
-I$(top_srcdir) \
-I$(top_srcdir)/libwindow-settings \
-DPIXMAP_DIR=\""$(datadir)/gnome-control-center/pixmaps"\" \
$(CAPPLET_CFLAGS) \
$(DBUS_CFLAGS) \
$(GNOME_DESKTOP_CFLAGS) \
$(METACITY_CFLAGS) \
$(GSD_DBUS_CFLAGS) \
$(GIO_CFLAGS)
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \
activate-settings-daemon.c \
activate-settings-daemon.h \
capplet-stock-icons.c \
capplet-stock-icons.h \
capplet-util.c \
capplet-util.h \
file-transfer-dialog.c \
file-transfer-dialog.h \
gconf-property-editor.c \
gconf-property-editor.h \
gconf-property-editor-marshal.c \
gconf-property-editor-marshal.h \
gnome-theme-apply.c \
gnome-theme-apply.h \
gnome-theme-info.c \
gnome-theme-info.h \
gtkrc-utils.c \
gtkrc-utils.h \
theme-thumbnail.c \
theme-thumbnail.h \
wm-common.c \
wm-common.h
libcommon_la_LIBADD = \
$(top_builddir)/libwindow-settings/libgnome-window-settings.la \
$(METACITY_LIBS) \
$(DBUS_LIBS) \
$(GNOME_DESKTOP_LIBS) \
$(GIO_LIBS)
gnome_theme_test_SOURCES = \
gnome-theme-test.c
gnome_theme_test_LDADD = \
libcommon.la \
$(GNOMECC_CAPPLETS_LIBS)
noinst_PROGRAMS = \
gnome-theme-test
-include $(top_srcdir)/git.mk

View File

@@ -5,7 +5,10 @@ bin_PROGRAMS = gnome-default-applications-properties
bin_SCRIPTS = gnome-at-visual gnome-at-mobility
gnome_default_applications_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
gnome_default_applications_properties_LDADD = \
$(GNOMECC_CAPPLETS_LIBS) \
$(EXTENSION_LIBS)
gnome_default_applications_properties_SOURCES = \
gnome-da-capplet.c gnome-da-capplet.h \
gnome-da-xml.c gnome-da-xml.h \
@@ -40,6 +43,7 @@ xmldata_DATA = $(xmldata_in_files:.xml.in=.xml)
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(EXTENSION_CFLAGS) \
$(DEFAULT_APPLICATIONS_CAPPLET_CFLAGS) \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"\
-DGNOMECC_UI_DIR=\""$(uidir)"\" \

View File

@@ -729,8 +729,10 @@ show_dialog (GnomeDACapplet *capplet, const gchar *start_page)
exit (EXIT_FAILURE);
}
capplet->window = _gtk_builder_get_widget (builder,"preferred_apps_dialog");
g_signal_connect (capplet->window, "response", G_CALLBACK (close_cb), NULL);
capplet->window = _gtk_builder_get_widget (builder,
"preferred_apps_dialog");
g_signal_connect (capplet->window, "response", G_CALLBACK (close_cb),
NULL);
capplet->web_browser_command_entry = _gtk_builder_get_widget (builder, "web_browser_command_entry");
capplet->web_browser_command_label = _gtk_builder_get_widget (builder, "web_browser_command_label");
@@ -958,11 +960,13 @@ main (int argc, char **argv)
/* TRANSLATORS: don't translate the terms in brackets */
N_("Specify the name of the page to show (internet|multimedia|system|a11y)"),
N_("page") },
{ NULL }
{NULL}
};
context = g_option_context_new (_("- GNOME Default Applications"));
g_option_context_add_main_entries (context, option_entries, GETTEXT_PACKAGE);
g_option_context_add_main_entries (context, option_entries,
GETTEXT_PACKAGE);
capplet_init (context, &argc, &argv);

View File

@@ -1,22 +1,69 @@
NULL =
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = display
uidir = $(pkgdatadir)/ui
dist_ui_DATA = display-capplet.ui
INCLUDES = \
$(DISPLAY_CAPPLET_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
-I$(top_srcdir)/libgnome-control-center-extension \
-DUIDIR="\"$(uidir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
$(NULL)
bin_PROGRAMS = gnome-display-properties
gnome_display_properties_SOURCES = \
xrandr-capplet.c \
noinst_LTLIBRARIES = libdisplay-common.la
libdisplay_common_la_SOURCES = \
scrollarea.c \
foo-marshal.c \
scrollarea.h \
foo-marshal.h
foo-marshal.h \
$(NULL)
ccmodulesdir = $(EXTENSIONSDIR)
ccmodules_LTLIBRARIES = libdisplay.la
libdisplay_la_SOURCES = \
display-module.c \
cc-display-page.h \
cc-display-page.c \
cc-display-panel.h \
cc-display-panel.c \
$(NULL)
libdisplay_la_LDFLAGS = \
$(EXTENSION_LIBTOOL_FLAGS) \
$(NULL)
libdisplay_la_LIBADD = \
libdisplay-common.la \
$(EXTENSION_LIBS) \
$(EXTENSION_COMMON_LIBS) \
$(LIBGNOMEKBDUI_LIBS) \
$(NULL)
libdisplay_la_CFLAGS = \
$(EXTENSION_CFLAGS) \
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
libdisplay_la_LIBTOOLFLAGS = --tag=disable-static
gnome_display_properties_SOURCES = \
xrandr-capplet.c \
$(NULL)
gnome_display_properties_LDFLAGS = -export-dynamic
gnome_display_properties_LDADD = \
$(top_builddir)/capplets/common/libcommon.la \
$(DISPLAY_CAPPLET_LIBS)
gnome_display_properties_LDADD = \
libdisplay-common.la \
$(top_builddir)/libgnome-control-center-extension/libcommon.la \
$(DISPLAY_CAPPLET_LIBS) \
$(NULL)
@INTLTOOL_DESKTOP_RULE@
@@ -35,11 +82,8 @@ desktopdir = $(datadir)/applications
Desktop_in_files = display-properties.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
INCLUDES = $(DISPLAY_CAPPLET_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DUIDIR="\"$(uidir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""
uidir = $(pkgdatadir)/ui
dist_ui_DATA = display-capplet.ui
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_DISPLAY_PAGE_H
#define __CC_DISPLAY_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_DISPLAY_PAGE (cc_display_page_get_type ())
#define CC_DISPLAY_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_DISPLAY_PAGE, CcDisplayPage))
#define CC_DISPLAY_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_DISPLAY_PAGE, CcDisplayPageClass))
#define CC_IS_DISPLAY_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_DISPLAY_PAGE))
#define CC_IS_DISPLAY_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_DISPLAY_PAGE))
#define CC_DISPLAY_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_DISPLAY_PAGE, CcDisplayPageClass))
typedef struct CcDisplayPagePrivate CcDisplayPagePrivate;
typedef struct
{
CcPage parent;
CcDisplayPagePrivate *priv;
} CcDisplayPage;
typedef struct
{
CcPageClass parent_class;
} CcDisplayPageClass;
GType cc_display_page_get_type (void);
CcPage * cc_display_page_new (void);
G_END_DECLS
#endif /* __CC_DISPLAY_PAGE_H */

View File

@@ -0,0 +1,177 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include "cc-display-panel.h"
#include "cc-display-page.h"
#define CC_DISPLAY_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_DISPLAY_PANEL, CcDisplayPanelPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcDisplayPanelPrivate
{
GtkWidget *notebook;
CcPage *display_page;
};
enum {
PROP_0,
};
static void cc_display_panel_class_init (CcDisplayPanelClass *klass);
static void cc_display_panel_init (CcDisplayPanel *display_panel);
static void cc_display_panel_finalize (GObject *object);
G_DEFINE_DYNAMIC_TYPE (CcDisplayPanel, cc_display_panel, CC_TYPE_PANEL)
static void
cc_display_panel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_display_panel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
setup_panel (CcDisplayPanel *panel)
{
GtkWidget *label;
char *display_name;
panel->priv->notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (panel), panel->priv->notebook);
gtk_widget_show (panel->priv->notebook);
panel->priv->display_page = cc_display_page_new ();
g_object_get (panel->priv->display_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook),
GTK_WIDGET (panel->priv->display_page),
label);
gtk_widget_show (GTK_WIDGET (panel->priv->display_page));
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->priv->notebook),
FALSE);
g_object_set (panel,
"current-page", panel->priv->display_page,
NULL);
}
static GObject *
cc_display_panel_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcDisplayPanel *display_panel;
display_panel = CC_DISPLAY_PANEL (G_OBJECT_CLASS (cc_display_panel_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (display_panel,
"display-name", _("Display"),
"id", "display-properties.desktop",
NULL);
setup_panel (display_panel);
return G_OBJECT (display_panel);
}
static void
cc_display_panel_class_init (CcDisplayPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_display_panel_get_property;
object_class->set_property = cc_display_panel_set_property;
object_class->constructor = cc_display_panel_constructor;
object_class->finalize = cc_display_panel_finalize;
g_type_class_add_private (klass, sizeof (CcDisplayPanelPrivate));
}
static void
cc_display_panel_class_finalize (CcDisplayPanelClass *klass)
{
}
static void
cc_display_panel_init (CcDisplayPanel *panel)
{
panel->priv = CC_DISPLAY_PANEL_GET_PRIVATE (panel);
}
static void
cc_display_panel_finalize (GObject *object)
{
CcDisplayPanel *display_panel;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_DISPLAY_PANEL (object));
display_panel = CC_DISPLAY_PANEL (object);
g_return_if_fail (display_panel->priv != NULL);
G_OBJECT_CLASS (cc_display_panel_parent_class)->finalize (object);
}
void
cc_display_panel_register (GIOModule *module)
{
cc_display_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
CC_TYPE_DISPLAY_PANEL,
"display",
10);
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_DISPLAY_PANEL_H
#define __CC_DISPLAY_PANEL_H
#include <gtk/gtk.h>
#include "cc-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_DISPLAY_PANEL (cc_display_panel_get_type ())
#define CC_DISPLAY_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_DISPLAY_PANEL, CcDisplayPanel))
#define CC_DISPLAY_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_DISPLAY_PANEL, CcDisplayPanelClass))
#define CC_IS_DISPLAY_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_DISPLAY_PANEL))
#define CC_IS_DISPLAY_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_DISPLAY_PANEL))
#define CC_DISPLAY_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_DISPLAY_PANEL, CcDisplayPanelClass))
typedef struct CcDisplayPanelPrivate CcDisplayPanelPrivate;
typedef struct
{
CcPanel parent;
CcDisplayPanelPrivate *priv;
} CcDisplayPanel;
typedef struct
{
CcPanelClass parent_class;
} CcDisplayPanelClass;
GType cc_display_panel_get_type (void);
void cc_display_panel_register (GIOModule *module);
G_END_DECLS
#endif /* __CC_DISPLAY_PANEL_H */

View File

@@ -10,11 +10,13 @@
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox1">
<object class="GtkVBox" id="main_vbox">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label6">

View File

@@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>
#include "cc-display-panel.h"
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
cc_display_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -1,46 +0,0 @@
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = keybinding
bin_PROGRAMS = gnome-keybinding-properties
gnome_keybinding_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
gnome_keybinding_properties_SOURCES = \
gnome-keybinding-properties.c \
eggcellrendererkeys.c \
eggcellrendererkeys.h \
eggaccelerators.c \
eggaccelerators.h
@INTLTOOL_DESKTOP_RULE@
uidir = $(pkgdatadir)/ui
ui_DATA = gnome-keybinding-properties.ui
desktopdir = $(datadir)/applications
Desktop_in_files = keybinding.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_XML_NOMERGE_RULE@
xmldir = $(pkgdatadir)/keybindings
xml_in_files = 00-multimedia-key.xml.in 01-desktop-key.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA = gnome-keybindings.pc
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
-DGNOMECC_KEYBINDINGS_DIR="\"$(pkgdatadir)/keybindings\""
CLEANFILES = \
$(GNOMECC_CAPPLETS_CLEANFILES) \
$(Desktop_in_files) \
$(desktop_DATA) \
$(xml_DATA)
EXTRA_DIST = $(ui_DATA) $(xml_in_files) gnome-keybindings.pc.in
-include $(top_srcdir)/git.mk

File diff suppressed because it is too large Load Diff

View File

@@ -1,301 +0,0 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.14"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="gnome-keybinding-dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Keyboard Shortcuts</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="shortcut_dialog">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="shortcuts_vbox">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkScrolledWindow" id="actions_swindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="shortcut_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="rules_hint">True</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="yalign">0</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon-size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">To edit a shortcut key, click on the corresponding row and type a new key combination, or press backspace to clear.</property>
<property name="justify">fill</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="helpbutton1">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add-button">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove-button">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-11">helpbutton1</action-widget>
<action-widget response="0">add-button</action-widget>
<action-widget response="1">remove-button</action-widget>
<action-widget response="-7">button1</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="custom-shortcut-dialog">
<property name="title" translatable="yes">Custom Shortcut</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="spacing">6</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">custom-shortcut-name-entry</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">C_ommand:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">custom-shortcut-command-entry</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom-shortcut-name-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom-shortcut-command-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
<property name="activates_default">True</property>
</object>
<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"></property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="cancelbutton1">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="okbutton1">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">cancelbutton1</action-widget>
<action-widget response="-5">okbutton1</action-widget>
</action-widgets>
</object>
</interface>

View File

@@ -1,14 +0,0 @@
[Desktop Entry]
_Name=Keyboard Shortcuts
_Comment=Assign shortcut keys to commands
Exec=gnome-keybinding-properties
Icon=preferences-desktop-keyboard-shortcuts
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;
OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center
X-GNOME-Bugzilla-Component=Keybinding
X-GNOME-Bugzilla-Version=@VERSION@

View File

@@ -1,10 +1,53 @@
NULL =
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = keyboard
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(LIBGNOMEKBDUI_CFLAGS) \
-I$(top_srcdir)/libgnome-control-center-extension \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_KEYBINDINGS_DIR="\"$(pkgdatadir)/keybindings\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
bin_PROGRAMS = gnome-keyboard-properties
ccmodulesdir = $(EXTENSIONSDIR)
ccmodules_LTLIBRARIES = libkeyboard.la
libkeyboard_la_SOURCES = \
keyboard-module.c \
eggcellrendererkeys.c \
eggcellrendererkeys.h \
eggaccelerators.c \
eggaccelerators.h \
cc-shortcuts-page.h \
cc-shortcuts-page.c \
cc-keyboard-page.h \
cc-keyboard-page.c \
cc-keyboard-panel.h \
cc-keyboard-panel.c
libkeyboard_la_LDFLAGS = \
$(EXTENSION_LIBTOOL_FLAGS) \
$(NULL)
libkeyboard_la_LIBADD = \
$(EXTENSION_LIBS) \
$(EXTENSION_COMMON_LIBS) \
$(LIBGNOMEKBDUI_LIBS) \
$(NULL)
libkeyboard_la_CFLAGS = \
$(EXTENSION_CFLAGS) \
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
libkeyboard_la_LIBTOOLFLAGS = --tag=disable-static
gnome_keyboard_properties_SOURCES = \
gnome-keyboard-properties.c \
gnome-keyboard-properties-a11y.c \
gnome-keyboard-properties-a11y.h \
gnome-keyboard-properties-xkb.c \
@@ -13,9 +56,15 @@ gnome_keyboard_properties_SOURCES = \
gnome-keyboard-properties-xkbltadd.c \
gnome-keyboard-properties-xkbot.c \
gnome-keyboard-properties-xkbpv.c \
gnome-keyboard-properties-xkb.h
gnome-keyboard-properties-xkb.h \
gnome-keyboard-properties.c
gnome_keyboard_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(LIBGNOMEKBDUI_LIBS)
gnome_keyboard_properties_LDADD = \
$(top_builddir)/libgnome-control-center-extension/libcommon.la \
$(GNOMECC_CAPPLETS_LIBS) \
$(LIBGNOMEKBDUI_LIBS)
gnome_keyboard_properties_LDFLAGS = -export-dynamic
@INTLTOOL_DESKTOP_RULE@
@@ -30,13 +79,22 @@ desktopdir = $(datadir)/applications
Desktop_in_files = keyboard.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(LIBGNOMEKBDUI_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)
EXTRA_DIST = $(ui_DATA)
@INTLTOOL_XML_NOMERGE_RULE@
xmldir = $(pkgdatadir)/keybindings
xml_in_files = 00-multimedia-key.xml.in 01-desktop-key.xml.in
xml_DATA = $(xml_in_files:.xml.in=.xml)
pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA = gnome-keybindings.pc
CLEANFILES = \
$(GNOMECC_CAPPLETS_CLEANFILES) \
$(Desktop_in_files) \
$(desktop_DATA) \
$(xml_DATA) \
$(NULL)
EXTRA_DIST = $(ui_DATA) $(xml_in_files) gnome-keybindings.pc.in
-include $(top_srcdir)/git.mk

View File

@@ -0,0 +1,255 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include "gconf-property-editor.h"
#include "cc-keyboard-page.h"
#define CC_KEYBOARD_PAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_PAGE, CcKeyboardPagePrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcKeyboardPagePrivate
{
gpointer dummy;
};
enum {
PROP_0,
};
static void cc_keyboard_page_class_init (CcKeyboardPageClass *klass);
static void cc_keyboard_page_init (CcKeyboardPage *keyboard_page);
static void cc_keyboard_page_finalize (GObject *object);
G_DEFINE_TYPE (CcKeyboardPage, cc_keyboard_page, CC_TYPE_PAGE)
static void
cc_keyboard_page_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_keyboard_page_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GConfValue *
blink_from_widget (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_INT);
gconf_value_set_int (new_value,
2600 - gconf_value_get_int (value));
return new_value;
}
static GConfValue *
blink_to_widget (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
int current_rate;
current_rate = gconf_value_get_int (value);
new_value = gconf_value_new (GCONF_VALUE_INT);
gconf_value_set_int (new_value,
CLAMP (2600 - current_rate, 100, 2500));
return new_value;
}
static void
setup_page (CcKeyboardPage *page)
{
GtkBuilder *builder;
GtkWidget *widget;
GError *error;
GtkSizeGroup *size_group;
GObject *peditor;
GConfChangeSet *changeset;
changeset = NULL;
builder = gtk_builder_new ();
error = NULL;
gtk_builder_add_from_file (builder,
GNOMECC_UI_DIR
"/gnome-keyboard-properties-dialog.ui",
&error);
if (error != NULL) {
g_error (_("Could not load user interface file: %s"),
error->message);
g_error_free (error);
return;
}
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("repeat_slow_label"));
gtk_size_group_add_widget (size_group, WID ("delay_short_label"));
gtk_size_group_add_widget (size_group, WID ("blink_slow_label"));
g_object_unref (G_OBJECT (size_group));
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("repeat_fast_label"));
gtk_size_group_add_widget (size_group, WID ("delay_long_label"));
gtk_size_group_add_widget (size_group, WID ("blink_fast_label"));
g_object_unref (G_OBJECT (size_group));
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("repeat_delay_scale"));
gtk_size_group_add_widget (size_group, WID ("repeat_speed_scale"));
gtk_size_group_add_widget (size_group, WID ("cursor_blink_time_scale"));
g_object_unref (G_OBJECT (size_group));
peditor = gconf_peditor_new_boolean (changeset,
"/desktop/gnome/peripherals/keyboard/repeat",
WID ("repeat_toggle"),
NULL);
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
WID ("repeat_table"));
gconf_peditor_new_numeric_range (changeset,
"/desktop/gnome/peripherals/keyboard/delay",
WID ("repeat_delay_scale"),
NULL);
gconf_peditor_new_numeric_range (changeset,
"/desktop/gnome/peripherals/keyboard/rate",
WID ("repeat_speed_scale"),
NULL);
peditor = gconf_peditor_new_boolean (changeset,
"/desktop/gnome/interface/cursor_blink",
WID ("cursor_toggle"),
NULL);
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
WID ("cursor_hbox"));
gconf_peditor_new_numeric_range (changeset,
"/desktop/gnome/interface/cursor_blink_time",
WID ("cursor_blink_time_scale"),
"conv-to-widget-cb",
blink_to_widget,
"conv-from-widget-cb",
blink_from_widget, NULL);
widget = WID ("general_vbox");
gtk_widget_reparent (widget, GTK_WIDGET (page));
gtk_widget_show (widget);
}
static GObject *
cc_keyboard_page_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcKeyboardPage *keyboard_page;
keyboard_page = CC_KEYBOARD_PAGE (G_OBJECT_CLASS (cc_keyboard_page_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (keyboard_page,
"display-name", _("Keyboard"),
"id", "general",
NULL);
setup_page (keyboard_page);
return G_OBJECT (keyboard_page);
}
static void
cc_keyboard_page_class_init (CcKeyboardPageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_keyboard_page_get_property;
object_class->set_property = cc_keyboard_page_set_property;
object_class->constructor = cc_keyboard_page_constructor;
object_class->finalize = cc_keyboard_page_finalize;
g_type_class_add_private (klass, sizeof (CcKeyboardPagePrivate));
}
static void
cc_keyboard_page_init (CcKeyboardPage *page)
{
page->priv = CC_KEYBOARD_PAGE_GET_PRIVATE (page);
}
static void
cc_keyboard_page_finalize (GObject *object)
{
CcKeyboardPage *page;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_KEYBOARD_PAGE (object));
page = CC_KEYBOARD_PAGE (object);
g_return_if_fail (page->priv != NULL);
G_OBJECT_CLASS (cc_keyboard_page_parent_class)->finalize (object);
}
CcPage *
cc_keyboard_page_new (void)
{
GObject *object;
object = g_object_new (CC_TYPE_KEYBOARD_PAGE, NULL);
return CC_PAGE (object);
}

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_KEYBOARD_PAGE_H
#define __CC_KEYBOARD_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_PAGE (cc_keyboard_page_get_type ())
#define CC_KEYBOARD_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_KEYBOARD_PAGE, CcKeyboardPage))
#define CC_KEYBOARD_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_KEYBOARD_PAGE, CcKeyboardPageClass))
#define CC_IS_KEYBOARD_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_KEYBOARD_PAGE))
#define CC_IS_KEYBOARD_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_KEYBOARD_PAGE))
#define CC_KEYBOARD_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_KEYBOARD_PAGE, CcKeyboardPageClass))
typedef struct CcKeyboardPagePrivate CcKeyboardPagePrivate;
typedef struct
{
CcPage parent;
CcKeyboardPagePrivate *priv;
} CcKeyboardPage;
typedef struct
{
CcPageClass parent_class;
} CcKeyboardPageClass;
GType cc_keyboard_page_get_type (void);
CcPage * cc_keyboard_page_new (void);
G_END_DECLS
#endif /* __CC_KEYBOARD_PAGE_H */

View File

@@ -0,0 +1,232 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include "cc-keyboard-panel.h"
#include "cc-keyboard-page.h"
#include "cc-shortcuts-page.h"
#define CC_KEYBOARD_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcKeyboardPanelPrivate
{
GtkWidget *notebook;
CcPage *keyboard_page;
CcPage *shortcuts_page;
};
enum {
PROP_0,
};
static void cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass);
static void cc_keyboard_panel_init (CcKeyboardPanel *keyboard_panel);
static void cc_keyboard_panel_finalize (GObject *object);
G_DEFINE_DYNAMIC_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC_TYPE_PANEL)
static void
cc_keyboard_panel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_keyboard_panel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
on_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num,
CcKeyboardPanel *panel)
{
if (page_num == 0) {
g_object_set (panel,
"current-page",
panel->priv->keyboard_page,
NULL);
} else {
g_object_set (panel,
"current-page",
panel->priv->shortcuts_page,
NULL);
}
}
static void
setup_panel (CcKeyboardPanel *panel,
gboolean is_active)
{
static gboolean initialised = FALSE;
GtkWidget *label;
char *display_name;
if (initialised)
return;
initialised = TRUE;
panel->priv->notebook = gtk_notebook_new ();
g_signal_connect (panel->priv->notebook,
"switch-page",
G_CALLBACK (on_notebook_switch_page),
panel);
gtk_container_add (GTK_CONTAINER (panel), panel->priv->notebook);
gtk_widget_show (panel->priv->notebook);
panel->priv->keyboard_page = cc_keyboard_page_new ();
g_object_get (panel->priv->keyboard_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook),
GTK_WIDGET (panel->priv->keyboard_page),
label);
gtk_widget_show (GTK_WIDGET (panel->priv->keyboard_page));
panel->priv->shortcuts_page = cc_shortcuts_page_new ();
g_object_get (panel->priv->shortcuts_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook),
GTK_WIDGET (panel->priv->shortcuts_page),
label);
gtk_widget_show (GTK_WIDGET (panel->priv->shortcuts_page));
g_object_set (panel,
"current-page", panel->priv->keyboard_page,
NULL);
}
static GObject *
cc_keyboard_panel_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcKeyboardPanel *keyboard_panel;
keyboard_panel = CC_KEYBOARD_PANEL (G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (keyboard_panel,
"display-name", _("Keyboard"),
"id", "keyboard.desktop",
NULL);
return G_OBJECT (keyboard_panel);
}
static void
cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_keyboard_panel_get_property;
object_class->set_property = cc_keyboard_panel_set_property;
object_class->constructor = cc_keyboard_panel_constructor;
object_class->finalize = cc_keyboard_panel_finalize;
g_type_class_add_private (klass, sizeof (CcKeyboardPanelPrivate));
}
static void
cc_keyboard_panel_class_finalize (CcKeyboardPanelClass *klass)
{
}
static void
cc_keyboard_panel_init (CcKeyboardPanel *panel)
{
GConfClient *client;
panel->priv = CC_KEYBOARD_PANEL_GET_PRIVATE (panel);
client = gconf_client_get_default ();
gconf_client_add_dir (client,
"/desktop/gnome/peripherals/keyboard",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, "/desktop/gnome/interface",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
g_object_unref (client);
g_signal_connect (panel, "active-changed", G_CALLBACK (setup_panel),
NULL);
}
static void
cc_keyboard_panel_finalize (GObject *object)
{
CcKeyboardPanel *keyboard_panel;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_KEYBOARD_PANEL (object));
keyboard_panel = CC_KEYBOARD_PANEL (object);
g_return_if_fail (keyboard_panel->priv != NULL);
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->finalize (object);
}
void
cc_keyboard_panel_register (GIOModule *module)
{
cc_keyboard_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
CC_TYPE_KEYBOARD_PANEL,
"keyboard",
10);
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_KEYBOARD_PANEL_H
#define __CC_KEYBOARD_PANEL_H
#include <gtk/gtk.h>
#include "cc-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_PANEL (cc_keyboard_panel_get_type ())
#define CC_KEYBOARD_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanel))
#define CC_KEYBOARD_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelClass))
#define CC_IS_KEYBOARD_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_KEYBOARD_PANEL))
#define CC_IS_KEYBOARD_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_KEYBOARD_PANEL))
#define CC_KEYBOARD_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelClass))
typedef struct CcKeyboardPanelPrivate CcKeyboardPanelPrivate;
typedef struct
{
CcPanel parent;
CcKeyboardPanelPrivate *priv;
} CcKeyboardPanel;
typedef struct
{
CcPanelClass parent_class;
} CcKeyboardPanelClass;
GType cc_keyboard_panel_get_type (void);
void cc_keyboard_panel_register (GIOModule *module);
G_END_DECLS
#endif /* __CC_KEYBOARD_PANEL_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_SHORTCUTS_PAGE_H
#define __CC_SHORTCUTS_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_SHORTCUTS_PAGE (cc_shortcuts_page_get_type ())
#define CC_SHORTCUTS_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_SHORTCUTS_PAGE, CcShortcutsPage))
#define CC_SHORTCUTS_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_SHORTCUTS_PAGE, CcShortcutsPageClass))
#define CC_IS_SHORTCUTS_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_SHORTCUTS_PAGE))
#define CC_IS_SHORTCUTS_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_SHORTCUTS_PAGE))
#define CC_SHORTCUTS_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_SHORTCUTS_PAGE, CcShortcutsPageClass))
typedef struct CcShortcutsPagePrivate CcShortcutsPagePrivate;
typedef struct
{
CcPage parent;
CcShortcutsPagePrivate *priv;
} CcShortcutsPage;
typedef struct
{
CcPageClass parent_class;
} CcShortcutsPageClass;
GType cc_shortcuts_page_get_type (void);
CcPage * cc_shortcuts_page_new (void);
G_END_DECLS
#endif /* __CC_SHORTCUTS_PAGE_H */

View File

@@ -77,12 +77,12 @@
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<object class="GtkVBox" id="dialog-vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox1">
<object class="GtkVBox" id="main-vbox">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
@@ -93,7 +93,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkVBox" id="vbox2">
<object class="GtkVBox" id="general_vbox">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
@@ -1880,4 +1880,245 @@
<action-widget response="-1">button4</action-widget>
</action-widgets>
</object>
<object class="GtkWindow" id="window1">
<child>
<object class="GtkVBox" id="shortcuts_vbox">
<property name="visible">True</property>
<property name="border_width">10</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkScrolledWindow" id="actions_swindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="shortcut_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="rules_hint">True</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="shortcuts_hbuttonbox">
<property name="visible">True</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="add-button">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove-button">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="yalign">0</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon-size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">To edit a shortcut key, click on the corresponding row and type a new key combination, or press backspace to clear.</property>
<property name="justify">fill</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkDialog" id="custom-shortcut-dialog">
<property name="title" translatable="yes">Custom Shortcut</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkVBox" id="vbox44">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">custom-shortcut-name-entry</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">C_ommand:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">custom-shortcut-command-entry</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom-shortcut-name-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom-shortcut-command-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
<property name="activates_default">True</property>
</object>
<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"></property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="cancelbutton1">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="okbutton1">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">cancelbutton1</action-widget>
<action-widget response="-5">okbutton1</action-widget>
</action-widgets>
</object>
</interface>

View File

@@ -219,7 +219,6 @@ main (int argc, char **argv)
N_
("Start the page with the accessibility settings showing"),
NULL},
{NULL}
};
@@ -258,6 +257,7 @@ main (int argc, char **argv)
capplet_set_icon (WID ("keyboard_dialog"),
"preferences-desktop-keyboard");
gtk_widget_show (WID ("keyboard_dialog"));
gtk_main ();

View File

@@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>
#include "cc-keyboard-panel.h"
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
cc_keyboard_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -1,9 +1,53 @@
NULL =
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = mouse
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
-I$(top_srcdir)/libgnome-control-center-extension \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
$(NULL)
bin_PROGRAMS = gnome-mouse-properties
gnome_mouse_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
ccmodulesdir = $(EXTENSIONSDIR)
ccmodules_LTLIBRARIES = libpointer.la
libpointer_la_SOURCES = \
pointer-module.c \
cc-pointer-panel.h \
cc-pointer-panel.c \
gnome-mouse-properties.c \
gnome-mouse-properties.h \
gnome-mouse-accessibility.c \
gnome-mouse-accessibility.h \
$(NULL)
libpointer_la_LDFLAGS = \
$(EXTENSION_LIBTOOL_FLAGS) \
$(NULL)
libpointer_la_LIBADD = \
$(EXTENSION_LIBS) \
$(EXTENSION_COMMON_LIBS) \
$(GNOMECC_CAPPLETS_LIBS) \
$(NULL)
libpointer_la_CFLAGS = \
$(EXTENSION_CFLAGS) \
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
libpointer_la_LIBTOOLFLAGS = --tag=disable-static
gnome_mouse_properties_LDADD = \
$(top_builddir)/libgnome-control-center-extension/libcommon.la \
$(GNOMECC_CAPPLETS_LIBS) \
$(NULL)
gnome_mouse_properties_SOURCES = \
gnome-mouse-properties.c \
gnome-mouse-accessibility.c \
@@ -24,11 +68,6 @@ desktopdir = $(datadir)/applications
Desktop_in_files = gnome-settings-mouse.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)
EXTRA_DIST = $(ui_DATA) $(pixmap_DATA)

View File

@@ -0,0 +1,577 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include "gconf-property-editor.h"
#include "capplet-stock-icons.h"
#include "cc-mouse-page.h"
#define CC_MOUSE_PAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_MOUSE_PAGE, CcMousePagePrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcMousePagePrivate
{
GConfChangeSet *changeset;
GtkWidget *double_click_image;
int double_click_state;
guint32 double_click_timestamp;
guint test_maybe_timeout_id;
guint test_on_timeout_id;
};
enum {
PROP_0,
};
static void cc_mouse_page_class_init (CcMousePageClass *klass);
static void cc_mouse_page_init (CcMousePage *mouse_page);
static void cc_mouse_page_finalize (GObject *object);
G_DEFINE_TYPE (CcMousePage, cc_mouse_page, CC_TYPE_PAGE)
enum {
DOUBLE_CLICK_TEST_OFF = 0,
DOUBLE_CLICK_TEST_MAYBE,
DOUBLE_CLICK_TEST_ON
};
#define MOUSE_KEY_DIR "/desktop/gnome/peripherals/mouse"
#define MOUSE_DOUBLE_CLICK_KEY MOUSE_KEY_DIR "/double_click"
#define MOUSE_LEFT_HANDED_KEY MOUSE_KEY_DIR "/left_handed"
#define MOUSE_LOCATE_POINTER_KEY MOUSE_KEY_DIR "/locate_pointer"
#define MOUSE_MOTION_ACCELERATION_KEY MOUSE_KEY_DIR "/motion_acceleration"
#define MOUSE_MOTION_THRESHOLD_KEY MOUSE_KEY_DIR "/motion_threshold"
#define MOUSE_DRAG_THRESHOLD_KEY MOUSE_KEY_DIR "/drag_threshold"
static GConfValue *
double_click_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_INT);
gconf_value_set_int (new_value,
CLAMP ((int) floor ((gconf_value_get_int (value) + 50) / 100.0) * 100, 100, 1000));
return new_value;
}
static void
get_default_mouse_info (int *default_numerator,
int *default_denominator,
int *default_threshold)
{
int numerator, denominator;
int threshold;
int tmp_num, tmp_den, tmp_threshold;
/* Query X for the default value */
XGetPointerControl (GDK_DISPLAY (),
&numerator,
&denominator,
&threshold);
XChangePointerControl (GDK_DISPLAY (),
True,
True,
-1,
-1,
-1);
XGetPointerControl (GDK_DISPLAY (),
&tmp_num,
&tmp_den,
&tmp_threshold);
XChangePointerControl (GDK_DISPLAY (),
True,
True,
numerator,
denominator,
threshold);
if (default_numerator)
*default_numerator = tmp_num;
if (default_denominator)
*default_denominator = tmp_den;
if (default_threshold)
*default_threshold = tmp_threshold;
}
static GConfValue *
motion_acceleration_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
gfloat motion_acceleration;
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
if (gconf_value_get_float (value) == -1.0) {
int numerator, denominator;
get_default_mouse_info (&numerator,
&denominator,
NULL);
motion_acceleration = CLAMP ((gfloat)(numerator / denominator), 0.2, 6.0);
}
else {
motion_acceleration = CLAMP (gconf_value_get_float (value), 0.2, 6.0);
}
if (motion_acceleration >= 1)
gconf_value_set_float (new_value, motion_acceleration + 4);
else
gconf_value_set_float (new_value, motion_acceleration * 5);
return new_value;
}
static GConfValue *
motion_acceleration_to_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
gfloat motion_acceleration;
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
motion_acceleration = CLAMP (gconf_value_get_float (value), 1.0, 10.0);
if (motion_acceleration < 5)
gconf_value_set_float (new_value, motion_acceleration / 5.0);
else
gconf_value_set_float (new_value, motion_acceleration - 4);
return new_value;
}
static GConfValue *
threshold_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
if (gconf_value_get_int (value) == -1) {
int threshold;
get_default_mouse_info (NULL, NULL, &threshold);
gconf_value_set_float (new_value, CLAMP (threshold, 1, 10));
}
else {
gconf_value_set_float (new_value, CLAMP (gconf_value_get_int (value), 1, 10));
}
return new_value;
}
static GConfValue *
drag_threshold_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
gconf_value_set_float (new_value, CLAMP (gconf_value_get_int (value), 1, 10));
return new_value;
}
/* Timeout for the double click test */
static gboolean
test_maybe_timeout (CcMousePage *page)
{
page->priv->double_click_state = DOUBLE_CLICK_TEST_OFF;
gtk_image_set_from_stock (GTK_IMAGE (page->priv->double_click_image),
MOUSE_DBLCLCK_OFF,
mouse_capplet_dblclck_icon_get_size ());
page->priv->test_maybe_timeout_id = 0;
return FALSE;
}
static gboolean
test_on_timeout (CcMousePage *page)
{
page->priv->double_click_state = DOUBLE_CLICK_TEST_OFF;
gtk_image_set_from_stock (GTK_IMAGE (page->priv->double_click_image),
MOUSE_DBLCLCK_OFF,
mouse_capplet_dblclck_icon_get_size ());
page->priv->test_on_timeout_id = 0;
return FALSE;
}
/* Callback issued when the user clicks the double click testing area. */
static gboolean
on_event_box_button_press_event (GtkWidget *widget,
GdkEventButton *event,
CcMousePage *page)
{
gint double_click_time;
GConfValue *value;
GConfClient *client;
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
if (!(page->priv->changeset
&& gconf_change_set_check_value (page->priv->changeset,
MOUSE_DOUBLE_CLICK_KEY,
&value))) {
client = gconf_client_get_default ();
double_click_time = gconf_client_get_int (client,
MOUSE_DOUBLE_CLICK_KEY,
NULL);
g_object_unref (client);
} else {
double_click_time = gconf_value_get_int (value);
}
if (page->priv->test_maybe_timeout_id != 0) {
g_source_remove (page->priv->test_maybe_timeout_id);
page->priv->test_maybe_timeout_id = 0;
}
if (page->priv->test_on_timeout_id != 0) {
g_source_remove (page->priv->test_on_timeout_id);
page->priv->test_on_timeout_id = 0;
}
switch (page->priv->double_click_state) {
case DOUBLE_CLICK_TEST_OFF:
page->priv->double_click_state = DOUBLE_CLICK_TEST_MAYBE;
page->priv->test_maybe_timeout_id = g_timeout_add (double_click_time,
(GtkFunction) test_maybe_timeout,
page);
break;
case DOUBLE_CLICK_TEST_MAYBE:
if (event->time - page->priv->double_click_timestamp < double_click_time) {
page->priv->double_click_state = DOUBLE_CLICK_TEST_ON;
page->priv->test_on_timeout_id = g_timeout_add (2500,
(GtkFunction) test_on_timeout,
page);
}
break;
case DOUBLE_CLICK_TEST_ON:
page->priv->double_click_state = DOUBLE_CLICK_TEST_OFF;
break;
}
page->priv->double_click_timestamp = event->time;
switch (page->priv->double_click_state) {
case DOUBLE_CLICK_TEST_ON:
gtk_image_set_from_stock (GTK_IMAGE (page->priv->double_click_image),
MOUSE_DBLCLCK_ON,
mouse_capplet_dblclck_icon_get_size ());
break;
case DOUBLE_CLICK_TEST_MAYBE:
gtk_image_set_from_stock (GTK_IMAGE (page->priv->double_click_image),
MOUSE_DBLCLCK_MAYBE,
mouse_capplet_dblclck_icon_get_size ());
break;
case DOUBLE_CLICK_TEST_OFF:
gtk_image_set_from_stock (GTK_IMAGE (page->priv->double_click_image),
MOUSE_DBLCLCK_OFF,
mouse_capplet_dblclck_icon_get_size ());
break;
}
return TRUE;
}
static void
orientation_radio_button_release_event (GtkWidget *widget,
GdkEventButton *event)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
}
static GConfValue *
left_handed_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_INT);
gconf_value_set_int (new_value, gconf_value_get_bool (value));
return new_value;
}
static GConfValue *
left_handed_to_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_BOOL);
gconf_value_set_bool (new_value, gconf_value_get_int (value) == 1);
return new_value;
}
static void
cc_mouse_page_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_mouse_page_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
setup_page (CcMousePage *page)
{
GtkBuilder *builder;
GtkWidget *widget;
GError *error;
GtkSizeGroup *size_group;
GtkRadioButton *radio;
GObject *peditor;
builder = gtk_builder_new ();
error = NULL;
gtk_builder_add_from_file (builder,
GNOMECC_UI_DIR
"/gnome-mouse-properties.ui",
&error);
if (error != NULL) {
g_error (_("Could not load user interface file: %s"),
error->message);
g_error_free (error);
return;
}
page->priv->double_click_image = WID ("double_click_image");
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("acceleration_label"));
gtk_size_group_add_widget (size_group, WID ("sensitivity_label"));
gtk_size_group_add_widget (size_group, WID ("threshold_label"));
gtk_size_group_add_widget (size_group, WID ("timeout_label"));
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("acceleration_fast_label"));
gtk_size_group_add_widget (size_group, WID ("sensitivity_high_label"));
gtk_size_group_add_widget (size_group, WID ("threshold_large_label"));
gtk_size_group_add_widget (size_group, WID ("timeout_long_label"));
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("acceleration_slow_label"));
gtk_size_group_add_widget (size_group, WID ("sensitivity_low_label"));
gtk_size_group_add_widget (size_group, WID ("threshold_small_label"));
gtk_size_group_add_widget (size_group, WID ("timeout_short_label"));
#if 1
/* Orientation radio buttons */
radio = GTK_RADIO_BUTTON (WID ("left_handed_radio"));
peditor = gconf_peditor_new_select_radio (page->priv->changeset,
MOUSE_LEFT_HANDED_KEY,
gtk_radio_button_get_group (radio),
"conv-to-widget-cb",
left_handed_from_gconf,
"conv-from-widget-cb",
left_handed_to_gconf,
NULL);
/* explicitly connect to button-release so that you can change orientation with either button */
g_signal_connect (WID ("right_handed_radio"),
"button_release_event",
G_CALLBACK (orientation_radio_button_release_event),
NULL);
g_signal_connect (WID ("left_handed_radio"),
"button_release_event",
G_CALLBACK (orientation_radio_button_release_event),
NULL);
/* Locate pointer toggle */
peditor = gconf_peditor_new_boolean (page->priv->changeset,
MOUSE_LOCATE_POINTER_KEY,
WID ("locate_pointer_toggle"),
NULL);
/* Double-click time */
peditor = gconf_peditor_new_numeric_range (page->priv->changeset,
MOUSE_DOUBLE_CLICK_KEY,
WID ("delay_scale"),
"conv-to-widget-cb",
double_click_from_gconf,
NULL);
#endif
gtk_image_set_from_stock (GTK_IMAGE (page->priv->double_click_image),
MOUSE_DBLCLCK_OFF,
mouse_capplet_dblclck_icon_get_size ());
g_signal_connect (WID ("double_click_eventbox"),
"button_press_event",
G_CALLBACK (on_event_box_button_press_event),
page);
/* speed */
gconf_peditor_new_numeric_range (page->priv->changeset,
MOUSE_MOTION_ACCELERATION_KEY,
WID ("accel_scale"),
"conv-to-widget-cb",
motion_acceleration_from_gconf,
"conv-from-widget-cb",
motion_acceleration_to_gconf,
NULL);
gconf_peditor_new_numeric_range (page->priv->changeset,
MOUSE_MOTION_THRESHOLD_KEY,
WID ("sensitivity_scale"),
"conv-to-widget-cb",
threshold_from_gconf,
NULL);
/* DnD threshold */
gconf_peditor_new_numeric_range (page->priv->changeset,
MOUSE_DRAG_THRESHOLD_KEY,
WID ("drag_threshold_scale"),
"conv-to-widget-cb",
drag_threshold_from_gconf,
NULL);
widget = WID ("general_vbox");
gtk_widget_reparent (widget, GTK_WIDGET (page));
gtk_widget_show (widget);
}
static GObject *
cc_mouse_page_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcMousePage *mouse_page;
mouse_page = CC_MOUSE_PAGE (G_OBJECT_CLASS (cc_mouse_page_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (mouse_page,
"display-name", _("Mouse"),
"id", "general",
NULL);
setup_page (mouse_page);
return G_OBJECT (mouse_page);
}
static void
cc_mouse_page_class_init (CcMousePageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_mouse_page_get_property;
object_class->set_property = cc_mouse_page_set_property;
object_class->constructor = cc_mouse_page_constructor;
object_class->finalize = cc_mouse_page_finalize;
g_type_class_add_private (klass, sizeof (CcMousePagePrivate));
}
static void
cc_mouse_page_init (CcMousePage *page)
{
GConfClient *client;
page->priv = CC_MOUSE_PAGE_GET_PRIVATE (page);
client = gconf_client_get_default ();
gconf_client_add_dir (client,
MOUSE_KEY_DIR,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
g_object_unref (client);
capplet_init_stock_icons ();
}
static void
cc_mouse_page_finalize (GObject *object)
{
CcMousePage *page;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_MOUSE_PAGE (object));
page = CC_MOUSE_PAGE (object);
g_return_if_fail (page->priv != NULL);
G_OBJECT_CLASS (cc_mouse_page_parent_class)->finalize (object);
}
CcPage *
cc_mouse_page_new (void)
{
GObject *object;
object = g_object_new (CC_TYPE_MOUSE_PAGE, NULL);
return CC_PAGE (object);
}

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_MOUSE_PAGE_H
#define __CC_MOUSE_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_MOUSE_PAGE (cc_mouse_page_get_type ())
#define CC_MOUSE_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_MOUSE_PAGE, CcMousePage))
#define CC_MOUSE_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_MOUSE_PAGE, CcMousePageClass))
#define CC_IS_MOUSE_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_MOUSE_PAGE))
#define CC_IS_MOUSE_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_MOUSE_PAGE))
#define CC_MOUSE_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_MOUSE_PAGE, CcMousePageClass))
typedef struct CcMousePagePrivate CcMousePagePrivate;
typedef struct
{
CcPage parent;
CcMousePagePrivate *priv;
} CcMousePage;
typedef struct
{
CcPageClass parent_class;
} CcMousePageClass;
GType cc_mouse_page_get_type (void);
CcPage * cc_mouse_page_new (void);
G_END_DECLS
#endif /* __CC_MOUSE_PAGE_H */

View File

@@ -0,0 +1,172 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include "cc-mouse-panel.h"
#include "cc-mouse-page.h"
#define CC_MOUSE_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_MOUSE_PANEL, CcMousePanelPrivate))
struct CcMousePanelPrivate
{
GtkWidget *notebook;
CcPage *mouse_page;
};
enum {
PROP_0,
};
static void cc_mouse_panel_class_init (CcMousePanelClass *klass);
static void cc_mouse_panel_init (CcMousePanel *mouse_panel);
static void cc_mouse_panel_finalize (GObject *object);
G_DEFINE_DYNAMIC_TYPE (CcMousePanel, cc_mouse_panel, CC_TYPE_PANEL)
static void
cc_mouse_panel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_mouse_panel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
setup_panel (CcMousePanel *panel)
{
GtkWidget *label;
char *display_name;
panel->priv->notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (panel), panel->priv->notebook);
gtk_widget_show (panel->priv->notebook);
panel->priv->mouse_page = cc_mouse_page_new ();
g_object_get (panel->priv->mouse_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_notebook_append_page (GTK_NOTEBOOK (panel->priv->notebook),
GTK_WIDGET (panel->priv->mouse_page),
label);
gtk_widget_show (GTK_WIDGET (panel->priv->mouse_page));
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->priv->notebook),
FALSE);
g_object_set (panel,
"current-page", panel->priv->mouse_page,
NULL);
}
static GObject *
cc_mouse_panel_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcMousePanel *mouse_panel;
mouse_panel = CC_MOUSE_PANEL (G_OBJECT_CLASS (cc_mouse_panel_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (mouse_panel,
"display-name", _("Mouse"),
"id", "gnome-settings-mouse.desktop",
NULL);
setup_panel (mouse_panel);
return G_OBJECT (mouse_panel);
}
static void
cc_mouse_panel_class_init (CcMousePanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_mouse_panel_get_property;
object_class->set_property = cc_mouse_panel_set_property;
object_class->constructor = cc_mouse_panel_constructor;
object_class->finalize = cc_mouse_panel_finalize;
g_type_class_add_private (klass, sizeof (CcMousePanelPrivate));
}
static void
cc_mouse_panel_class_finalize (CcMousePanelClass *klass)
{
}
static void
cc_mouse_panel_init (CcMousePanel *panel)
{
panel->priv = CC_MOUSE_PANEL_GET_PRIVATE (panel);
}
static void
cc_mouse_panel_finalize (GObject *object)
{
CcMousePanel *mouse_panel;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_MOUSE_PANEL (object));
mouse_panel = CC_MOUSE_PANEL (object);
g_return_if_fail (mouse_panel->priv != NULL);
G_OBJECT_CLASS (cc_mouse_panel_parent_class)->finalize (object);
}
void
cc_mouse_panel_register (GIOModule *module)
{
cc_mouse_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
CC_TYPE_MOUSE_PANEL,
"mouse",
10);
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_MOUSE_PANEL_H
#define __CC_MOUSE_PANEL_H
#include <gtk/gtk.h>
#include "cc-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_MOUSE_PANEL (cc_mouse_panel_get_type ())
#define CC_MOUSE_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_MOUSE_PANEL, CcMousePanel))
#define CC_MOUSE_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_MOUSE_PANEL, CcMousePanelClass))
#define CC_IS_MOUSE_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_MOUSE_PANEL))
#define CC_IS_MOUSE_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_MOUSE_PANEL))
#define CC_MOUSE_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_MOUSE_PANEL, CcMousePanelClass))
typedef struct CcMousePanelPrivate CcMousePanelPrivate;
typedef struct
{
CcPanel parent;
CcMousePanelPrivate *priv;
} CcMousePanel;
typedef struct
{
CcPanelClass parent_class;
} CcMousePanelClass;
GType cc_mouse_panel_get_type (void);
void cc_mouse_panel_register (GIOModule *module);
G_END_DECLS
#endif /* __CC_MOUSE_PANEL_H */

View File

@@ -0,0 +1,161 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2010 Intel, Inc.
*
* 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 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.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#include "cc-pointer-panel.h"
#include "gnome-mouse-properties.h"
#include "gnome-mouse-accessibility.h"
#include <glib/gi18n.h>
G_DEFINE_DYNAMIC_TYPE (CcPointerPanel, cc_pointer_panel, CC_TYPE_PANEL)
#define POINTER_PANEL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_POINTER_PANEL, CcPointerPanelPrivate))
struct _CcPointerPanelPrivate
{
GConfClient *client;
};
static void
cc_pointer_panel_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_pointer_panel_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_pointer_panel_dispose (GObject *object)
{
CcPointerPanelPrivate *priv = CC_POINTER_PANEL (object)->priv;
if (priv->client)
{
g_object_unref (priv->client);
priv->client = NULL;
}
G_OBJECT_CLASS (cc_pointer_panel_parent_class)->dispose (object);
}
static void
cc_pointer_panel_finalize (GObject *object)
{
G_OBJECT_CLASS (cc_pointer_panel_parent_class)->finalize (object);
}
static GObject*
cc_pointer_panel_constructor (GType type,
guint n_properties,
GObjectConstructParam *properties)
{
CcPointerPanel *panel;
GObjectClass *parent_class;
parent_class = G_OBJECT_CLASS (cc_pointer_panel_parent_class);
panel = (CcPointerPanel*) parent_class->constructor (type, n_properties,
properties);
g_object_set (panel,
"id", "gnome-settings-mouse.desktop",
"display-name", _("Pointing Devices"),
NULL);
return (GObject *) panel;
}
static void
cc_pointer_panel_class_init (CcPointerPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcPointerPanelPrivate));
object_class->get_property = cc_pointer_panel_get_property;
object_class->set_property = cc_pointer_panel_set_property;
object_class->dispose = cc_pointer_panel_dispose;
object_class->finalize = cc_pointer_panel_finalize;
object_class->constructor = cc_pointer_panel_constructor;
}
static void
cc_pointer_panel_class_finalize (CcPointerPanelClass *klass)
{
}
static void
cc_pointer_panel_init (CcPointerPanel *self)
{
GtkBuilder *builder;
GtkWidget *prefs_widget;
self->priv = POINTER_PANEL_PRIVATE (self);
self->priv->client = mouse_properties_conf_init ();
builder = create_dialog ();
setup_accessibility (builder, self->priv->client);
prefs_widget = (GtkWidget*) gtk_builder_get_object (builder, "prefs_widget");
gtk_widget_reparent (prefs_widget, GTK_WIDGET (self));
}
CcPointerPanel *
cc_pointer_panel_new (void)
{
return g_object_new (CC_TYPE_POINTER_PANEL, NULL);
}
void
cc_pointer_panel_register (GIOModule *module)
{
cc_pointer_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
CC_TYPE_POINTER_PANEL,
"pointer",
10);
}

View File

@@ -0,0 +1,77 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2010 Intel, Inc.
*
* 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 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.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#ifndef _CC_POINTER_PANEL_H
#define _CC_POINTER_PANEL_H
#include <glib-object.h>
#include "cc-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_POINTER_PANEL cc_pointer_panel_get_type()
#define CC_POINTER_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CC_TYPE_POINTER_PANEL, CcPointerPanel))
#define CC_POINTER_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CC_TYPE_POINTER_PANEL, CcPointerPanelClass))
#define CC_IS_POINTER_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CC_TYPE_POINTER_PANEL))
#define CC_IS_POINTER_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CC_TYPE_POINTER_PANEL))
#define CC_POINTER_PANEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CC_TYPE_POINTER_PANEL, CcPointerPanelClass))
typedef struct _CcPointerPanel CcPointerPanel;
typedef struct _CcPointerPanelClass CcPointerPanelClass;
typedef struct _CcPointerPanelPrivate CcPointerPanelPrivate;
struct _CcPointerPanel
{
CcPanel parent;
CcPointerPanelPrivate *priv;
};
struct _CcPointerPanelClass
{
CcPanelClass parent_class;
};
GType cc_pointer_panel_get_type (void) G_GNUC_CONST;
CcPointerPanel *cc_pointer_panel_new (void);
void cc_pointer_panel_register (GIOModule *module);
G_END_DECLS
#endif /* _CC_POINTER_PANEL_H */

View File

@@ -25,6 +25,8 @@
#include <config.h>
#include "gnome-mouse-properties.h"
#include <glib/gi18n.h>
#include <string.h>
#include <gconf/gconf-client.h>
@@ -511,7 +513,7 @@ setup_dialog (GtkBuilder *dialog, GConfChangeSet *changeset)
/* Construct the dialog */
static GtkBuilder *
GtkBuilder *
create_dialog (void)
{
GtkBuilder *dialog;
@@ -558,6 +560,8 @@ create_dialog (void)
gtk_size_group_add_widget (size_group, WID ("dwell_delay_long_label"));
gtk_size_group_add_widget (size_group, WID ("dwell_threshold_large_label"));
setup_dialog (dialog, NULL);
return dialog;
}
@@ -573,13 +577,32 @@ dialog_response_cb (GtkDialog *dialog, gint response_id, GConfChangeSet *changes
gtk_main_quit ();
}
GConfClient *
mouse_properties_conf_init ()
{
GConfClient *client;
capplet_init_stock_icons ();
activate_settings_daemon ();
client = gconf_client_get_default ();
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, "/desktop/gnome/peripherals/touchpad",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
return client;
}
int
main (int argc, char **argv)
{
GConfClient *client;
GtkBuilder *dialog;
GtkWidget *dialog_win, *w;
gchar *start_page = NULL;
gchar *start_page = NULL;
GOptionContext *context;
GOptionEntry cap_options[] = {
@@ -600,14 +623,11 @@ main (int argc, char **argv)
activate_settings_daemon ();
client = gconf_client_get_default ();
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, "/desktop/gnome/peripherals/touchpad", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
client = mouse_properties_conf_init ();
dialog = create_dialog ();
if (dialog) {
setup_dialog (dialog, NULL);
setup_accessibility (dialog, client);
dialog_win = WID ("mouse_properties_dialog");

View File

@@ -0,0 +1,33 @@
/* mouse-properties-capplet.h
*
* Copyright (C) 2010 Intel, Inc
*
* 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, 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 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.
*
* Written by: Thomas Wood <thos@gnome.org>
*/
#ifndef __GNOME_MOUSE_PROPETIES_H__
#define __GNOME_MOUSE_PROPETIES_H__
#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
GtkBuilder* create_dialog (void);
GConfClient* mouse_properties_conf_init (void);
#endif /* __GNOME_MOUSE_PROPETIES_H__ */

View File

@@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>
#include "cc-mouse-panel.h"
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
cc_mouse_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -0,0 +1,42 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2010 Intel, Inc
*
* 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 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.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#include <config.h>
#include "cc-pointer-panel.h"
#include <glib/gi18n.h>
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
cc_pointer_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -1,10 +1,52 @@
NULL =
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = network
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
-I$(top_srcdir)/libgnome-control-center-extension \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
$(NULL)
bin_PROGRAMS = gnome-network-properties
gnome_network_properties_SOURCES = gnome-network-properties.c
gnome_network_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
ccmodulesdir = $(EXTENSIONSDIR)
ccmodules_LTLIBRARIES = libnetwork.la
libnetwork_la_SOURCES = \
network-module.c \
cc-network-panel.h \
cc-network-panel.c \
cc-network-proxy-page.h \
cc-network-proxy-page.c \
$(NULL)
libnetwork_la_LDFLAGS = \
$(EXTENSION_LIBTOOL_FLAGS) \
$(NULL)
libnetwork_la_LIBADD = \
$(EXTENSION_LIBS) \
$(EXTENSION_COMMON_LIBS) \
$(NULL)
libnetwork_la_CFLAGS = \
$(EXTENSION_CFLAGS) \
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
libnetwork_la_LIBTOOLFLAGS = --tag=disable-static
gnome_network_properties_SOURCES = \
gnome-network-properties.c \
$(NULL)
gnome_network_properties_LDADD = \
$(top_builddir)/libgnome-control-center-extension/libcommon.la \
$(GNOMECC_CAPPLETS_LIBS) \
$(NULL)
@INTLTOOL_DESKTOP_RULE@
@@ -28,11 +70,6 @@ desktopdir = $(datadir)/applications
desktop_in_files = gnome-network-properties.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
uninstall-hook: update-icon-cache
install-data-hook: update-icon-cache

View File

@@ -0,0 +1,170 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnomeui/gnome-desktop-thumbnail.h>
#include "cc-network-proxy-page.h"
#include "cc-network-panel.h"
#define CC_NETWORK_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_NETWORK_PANEL, CcNetworkPanelPrivate))
#define WID(s) GTK_WIDGET (gtk_builder_get_object (builder, s))
struct CcNetworkPanelPrivate
{
CcPage *proxy_page;
};
enum {
PROP_0,
};
static void cc_network_panel_class_init (CcNetworkPanelClass *klass);
static void cc_network_panel_init (CcNetworkPanel *network_panel);
static void cc_network_panel_finalize (GObject *object);
G_DEFINE_DYNAMIC_TYPE (CcNetworkPanel, cc_network_panel, CC_TYPE_PANEL)
static void
cc_network_panel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_network_panel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
setup_panel (CcNetworkPanel *panel)
{
GtkWidget *label;
char *display_name;
panel->priv->proxy_page = cc_network_proxy_page_new ();
g_object_get (panel->priv->proxy_page,
"display-name", &display_name,
NULL);
label = gtk_label_new (display_name);
g_free (display_name);
gtk_widget_show (GTK_WIDGET (panel->priv->proxy_page));
g_object_set (panel,
"current-page", panel->priv->proxy_page,
NULL);
gtk_container_add (GTK_CONTAINER (panel), panel->priv->proxy_page);
}
static GObject *
cc_network_panel_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcNetworkPanel *network_panel;
network_panel = CC_NETWORK_PANEL (G_OBJECT_CLASS (cc_network_panel_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
g_object_set (network_panel,
"display-name", _("Network"),
"id", "gnome-network-properties.desktop",
NULL);
setup_panel (network_panel);
return G_OBJECT (network_panel);
}
static void
cc_network_panel_class_init (CcNetworkPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_network_panel_get_property;
object_class->set_property = cc_network_panel_set_property;
object_class->constructor = cc_network_panel_constructor;
object_class->finalize = cc_network_panel_finalize;
g_type_class_add_private (klass, sizeof (CcNetworkPanelPrivate));
}
static void
cc_network_panel_class_finalize (CcNetworkPanelClass *klass)
{
}
static void
cc_network_panel_init (CcNetworkPanel *panel)
{
panel->priv = CC_NETWORK_PANEL_GET_PRIVATE (panel);
}
static void
cc_network_panel_finalize (GObject *object)
{
CcNetworkPanel *network_panel;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_NETWORK_PANEL (object));
network_panel = CC_NETWORK_PANEL (object);
g_return_if_fail (network_panel->priv != NULL);
G_OBJECT_CLASS (cc_network_panel_parent_class)->finalize (object);
}
void
cc_network_panel_register (GIOModule *module)
{
cc_network_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_PANEL_EXTENSION_POINT_NAME,
CC_TYPE_NETWORK_PANEL,
"network",
10);
}

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_NETWORK_PANEL_H
#define __CC_NETWORK_PANEL_H
#include <gtk/gtk.h>
#include "cc-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_NETWORK_PANEL (cc_network_panel_get_type ())
#define CC_NETWORK_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_NETWORK_PANEL, CcNetworkPanel))
#define CC_NETWORK_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_NETWORK_PANEL, CcNetworkPanelClass))
#define CC_IS_NETWORK_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_NETWORK_PANEL))
#define CC_IS_NETWORK_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_NETWORK_PANEL))
#define CC_NETWORK_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_NETWORK_PANEL, CcNetworkPanelClass))
typedef struct CcNetworkPanelPrivate CcNetworkPanelPrivate;
typedef struct
{
CcPanel parent;
CcNetworkPanelPrivate *priv;
} CcNetworkPanel;
typedef struct
{
CcPanelClass parent_class;
} CcNetworkPanelClass;
GType cc_network_panel_get_type (void);
void cc_network_panel_register (GIOModule *module);
G_END_DECLS
#endif /* __CC_NETWORK_PANEL_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_NETWORK_PROXY_PAGE_H
#define __CC_NETWORK_PROXY_PAGE_H
#include <gtk/gtk.h>
#include "cc-page.h"
G_BEGIN_DECLS
#define CC_TYPE_NETWORK_PROXY_PAGE (cc_network_proxy_page_get_type ())
#define CC_NETWORK_PROXY_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_NETWORK_PROXY_PAGE, CcNetworkProxyPage))
#define CC_NETWORK_PROXY_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_NETWORK_PROXY_PAGE, CcNetworkProxyPageClass))
#define CC_IS_NETWORK_PROXY_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_NETWORK_PROXY_PAGE))
#define CC_IS_NETWORK_PROXY_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_NETWORK_PROXY_PAGE))
#define CC_NETWORK_PROXY_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_NETWORK_PROXY_PAGE, CcNetworkProxyPageClass))
typedef struct CcNetworkProxyPagePrivate CcNetworkProxyPagePrivate;
typedef struct
{
CcPage parent;
CcNetworkProxyPagePrivate *priv;
} CcNetworkProxyPage;
typedef struct
{
CcPageClass parent_class;
} CcNetworkProxyPageClass;
GType cc_network_proxy_page_get_type (void);
CcPage * cc_network_proxy_page_new (void);
G_END_DECLS
#endif /* __CC_NETWORK_PROXY_PAGE_H */

View File

@@ -1368,11 +1368,7 @@ main (int argc, char **argv)
GConfClient *client;
GtkWidget *widget;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
gtk_init (&argc, &argv);
capplet_init (NULL, &argc, &argv);
client = gconf_client_get_default ();
gconf_client_add_dir (client, "/system/http_proxy",
@@ -1392,9 +1388,11 @@ main (int argc, char **argv)
}
setup_dialog (builder);
widget = _gtk_builder_get_widget (builder, "network_dialog");
capplet_set_icon (widget, "gnome-network-properties");
gtk_widget_show_all (widget);
gtk_main ();
g_object_unref (builder);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>
#include "cc-network-panel.h"
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
cc_network_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}

View File

@@ -18,15 +18,6 @@ AM_PROG_LIBTOOL
# Use the GNOME documentation framework
GNOME_DOC_INIT
changequote(,)dnl
if test "x$GCC" = "xyes"; then
case " $CFLAGS " in
*[\ \ ]-Wall[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wall" ;;
esac
fi
changequote([,])dnl
# Internationalization support
IT_PROG_INTLTOOL([0.37.1])
@@ -97,11 +88,10 @@ COMMON_MODULES="gtk+-2.0 >= 2.15.0 dnl
gnome-desktop-2.0 >= 2.27.91"
PKG_CHECK_MODULES(CAPPLET, $COMMON_MODULES)
PKG_CHECK_MODULES(GNOMECC, $COMMON_MODULES libgnome-menu >= 2.10.1)
PKG_CHECK_MODULES(GNOMECC_SHELL, $COMMON_MODULES libgnome-menu unique-1.0)
PKG_CHECK_MODULES(GNOMECC_SHELL, $COMMON_MODULES libgnome-menu unique-1.0 gio-unix-2.0)
PKG_CHECK_MODULES(DBUS, dbus-1 dbus-glib-1)
PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-2.0)
PKG_CHECK_MODULES(DEFAULT_APPLICATIONS_CAPPLET, libxml-2.0)
PKG_CHECK_MODULES(METACITY, libmetacity-private >= 2.23.1)
PKG_CHECK_MODULES(TYPING, glib-2.0 > 2.11 gconf-2.0 gtk+-2.0)
PKG_CHECK_MODULES(GSD_DBUS, gnome-settings-daemon)
PKG_CHECK_MODULES(GIO, gio-2.0)
@@ -111,31 +101,23 @@ gtk_binary_version=`$PKG_CONFIG --variable gtk_binary_version gtk+-2.0`
GTK_ENGINE_DIR="$gtk_lib_dir/gtk-2.0/$gtk_binary_version/engines"
AC_SUBST(GTK_ENGINE_DIR)
dnl
dnl Check dependencies of libslab
dnl
PKG_CHECK_MODULES(EXTERNAL_LIBSLAB, [libslab], have_libslab=yes, have_libslab=no)
dnl ================================================================
dnl Extensions
dnl ================================================================
if test $have_libslab = no; then
PKG_CHECK_MODULES(LIBSLAB, [
gio-2.0 gnome-desktop-2.0 librsvg-2.0 libgnome-menu pango gconf-2.0
],
have_libslab_deps=yes,
have_libslab_deps=no)
WARN_CFLAGS="-Wall"
else
have_libslab_deps=no
fi
PKG_CHECK_MODULES(EXTENSION_COMMON, $COMMON_MODULES)
AC_SUBST(EXTERNAL_LIBSLAB_CFLAGS)
AC_SUBST(EXTERNAL_LIBSLAB_LIBS)
AC_SUBST(LIBSLAB_CFLAGS)
AC_SUBST(LIBSLAB_LIBS)
AC_SUBST(WARN_CFLAGS)
EXTENSION_LIBTOOL_FLAGS="-export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload)'"
AC_SUBST(EXTENSION_LIBTOOL_FLAGS)
AM_CONDITIONAL(HAVE_LIBSLAB, [test $have_libslab = yes -o $have_libslab_deps = yes])
AM_CONDITIONAL(HAVE_LIBSLAB_DEPS, [test $have_libslab_deps = yes])
AM_CONDITIONAL(LIBSLAB_FOR_INTERNAL_USE, test "yes" = "yes")
EXTENSIONSDIR="${libdir}/control-center-1/extensions"
AC_SUBST(EXTENSIONSDIR)
EXTENSION_CFLAGS="-I\$(top_srcdir)/libgnome-control-center-extension"
AC_SUBST(EXTENSION_CFLAGS)
EXTENSION_LIBS="\$(top_builddir)/libgnome-control-center-extension/libgnome-control-center-extension.la"
AC_SUBST(EXTENSION_LIBS)
dnl
dnl Check for Xft version 2; we build in extra functionality to the font capplet
@@ -245,6 +227,43 @@ fi
AM_CONDITIONAL(BUILD_ABOUTME, test "x$enable_aboutme" = "xyes")
dnl ==============================================
dnl Check the window manager we need to work with
dnl ==============================================
AC_ARG_WITH([window_manager],
[AS_HELP_STRING([--with-window-manager],
[specify which window manager to support (metacity, mutter)])],
[with_window_manager=${withval}],
[with_window_manager=metacity])
AS_IF([test "x$with_window_manager" = "xmetacity"],
[WM_REQUIRES="libmetacity-private >= 2.23.1"
AC_DEFINE(HAVE_METACITY, 1, [defined if using metacity])],
[test "x$with_window_manager" = "xmutter"],
[WM_REQUIRES="libmutter-private >= 2.23.1"
AC_DEFINE(HAVE_MUTTER, 1, [defined if using mutter])],
[AC_MSG_FAILURE([Unsupported window manager: "$with_window_manager"])])
PKG_CHECK_MODULES(WINDOW_MANAGER, $WM_REQUIRES)
dnl ==============================================
dnl Allow "userpasswd" to be used in about-me
dnl ==============================================
AC_ARG_WITH([userpasswd],
[AS_HELP_STRING([--with-userpasswd],
[use the "userpasswd" utility to change passwords in about-me])],
[with_userpasswd=${withval}],
[with_userpasswd=no])
AS_IF([test "x$with_userpasswd" == "xyes"],
[AC_DEFINE(HAVE_USERPASSWD, 1, [defined if using userpasswd])],
[])
dnl ==============================================
dnl End: Check that we meet the dependencies
dnl ==============================================
@@ -272,8 +291,6 @@ AM_GCONF_SOURCE_2
dnl ==============================================
dnl Define the main variables
dnl ==============================================
COMMON_CFLAGS="-I\$(top_srcdir)/capplets/common"
COMMON_LIBS="\$(top_builddir)/capplets/common/libcommon.la"
EXTRA_CFLAGS="-I\$(top_srcdir)/ -DG_LOG_DOMAIN=\"\\\"\$(cappletname)-properties\\\"\""
@@ -300,6 +317,68 @@ AC_ARG_ENABLE(update-mimedb,
enable_update_mimedb=yes)
AM_CONDITIONAL(ENABLE_UPDATE_MIMEDB, test x$enable_update_mimedb = xyes)
dnl run in source tree
AC_ARG_ENABLE(run-in-source-tree,
AC_HELP_STRING([--disable-run-in-source-tree],[disable search for UI files and plugins in local directory ]),
[case "${enableval}" in
yes) ENABLE_RUN_IN_SOURCE_TREE=yes ;;
no) ENABLE_RUN_IN_SOURCE_TREE=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-run-in-source-tree) ;;
esac],
[ENABLE_RUN_IN_SOURCE_TREE=yes]) dnl Default value
if test x$ENABLE_RUN_IN_SOURCE_TREE = xyes; then
AC_DEFINE(RUN_IN_SOURCE_TREE, 1, [enable search for UI files and plugins in local directory])
fi
dnl =======================================
dnl Finish
dnl =======================================
# Turn on the additional warnings last
AC_ARG_ENABLE(more-warnings,
AS_HELP_STRING([--enable-more-warnings],
[Maximum compiler warnings]),
set_more_warnings="$enableval",[
if test -d $srcdir/.git; then
set_more_warnings=yes
else
set_more_warnings=no
fi])
AC_MSG_CHECKING(for more warnings)
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
AC_MSG_RESULT(yes)
CFLAGS="\
-Wall -Wclobbered -Wempty-body -Wignored-qualifiers \
-Wmissing-field-initializers -Wmissing-parameter-type \
-Wold-style-declaration -Woverride-init -Wtype-limits \
-Wuninitialized \
-Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
-Wnested-externs -Wpointer-arith \
-Wcast-align -Wsign-compare -Wp,-D_FORTIFY_SOURCE=2 \
$CFLAGS"
for option in -Wno-strict-aliasing -Wno-sign-compare; do
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $option"
AC_MSG_CHECKING([whether gcc understands $option])
AC_TRY_COMPILE([], [],
has_option=yes,
has_option=no,)
if test $has_option = no; then
CFLAGS="$SAVE_CFLAGS"
fi
AC_MSG_RESULT($has_option)
unset has_option
unset SAVE_CFLAGS
done
unset option
else
AC_MSG_RESULT(no)
fi
AC_CONFIG_FILES([
Makefile
@@ -314,7 +393,6 @@ capplets/appearance/Makefile
capplets/appearance/data/Makefile
capplets/appearance/data/gnome-appearance-properties.desktop.in
capplets/appearance/data/gnome-theme-installer.desktop.in
capplets/common/Makefile
capplets/default-applications/Makefile
capplets/default-applications/default-applications.desktop.in
capplets/default-applications/gnome-at-commandline.in
@@ -322,11 +400,9 @@ capplets/default-applications/gnome-at-session.desktop.in
capplets/default-applications/gnome-default-applications.pc
capplets/display/Makefile
capplets/display/display-properties.desktop.in
capplets/keybindings/Makefile
capplets/keybindings/gnome-keybindings.pc
capplets/keybindings/keybinding.desktop.in
capplets/keyboard/Makefile
capplets/keyboard/keyboard.desktop.in
capplets/keyboard/gnome-keybindings.pc
capplets/mouse/Makefile
capplets/mouse/gnome-settings-mouse.desktop.in
capplets/network/Makefile
@@ -338,10 +414,12 @@ font-viewer/gnome-font-viewer.desktop.in
help/Makefile
libwindow-settings/Makefile
libwindow-settings/gnome-window-settings-2.0.pc
libgnome-control-center-extension/Makefile
libgnome-control-center-extension/libgnome-control-center-extension.pc
libgnome-control-center-extension/libgnome-control-center-extension-uninstalled.pc
po/Makefile.in
libslab/Makefile
shell/Makefile
shell/gnomecc.desktop.in
shell/gnome-control-center.desktop.in
typing-break/Makefile
])

View File

@@ -0,0 +1,129 @@
NULL =
uidir = $(pkgdatadir)/ui
INCLUDES = \
-DEXTENSIONSDIR="\"$(EXTENSIONSDIR)\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DLIBEXECDIR="\"$(libexecdir)\"" \
-DGTK_ENGINE_DIR="\"$(GTK_ENGINE_DIR)\"" \
-DINSTALL_PREFIX=\"$(prefix)\" \
-I$(top_srcdir) \
-I$(top_srcdir)/libwindow-settings \
-DPIXMAP_DIR=\""$(datadir)/gnome-control-center/pixmaps"\" \
-DUIDIR="\"$(uidir)\"" \
$(CAPPLET_CFLAGS) \
$(DBUS_CFLAGS) \
$(GNOME_DESKTOP_CFLAGS) \
$(WINDOW_MANAGER_CFLAGS) \
$(GSD_DBUS_CFLAGS) \
$(GIO_CFLAGS)
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
lib_LTLIBRARIES = libgnome-control-center-extension.la
libgnome_control_center_extension_include_HEADERS = \
cc-page.h \
cc-panel.h \
cc-shell.h \
$(NULL)
libgnome_control_center_extension_la_SOURCES = \
cc-page.h \
cc-page.c \
cc-panel.h \
cc-panel.c \
cc-shell.c \
cc-shell.h \
$(NULL)
# -version-info @GNOME_CONTROL_CENTER_EXTENSION_VERSION_INFO@
libgnome_control_center_extension_la_LDFLAGS = \
-no-undefined \
$(NULL)
libgnome_control_center_extension_la_LIBADD = \
libcommon.la \
$(EXTENSION_COMMON_CFLAGS) \
$(NULL)
libgnome_control_center_extension_la_LIBTOOLFLAGS = --tag=disable-static
libgnome_control_center_extension_includedir = $(includedir)/gnome-control-center-1/libgnome-control-center-extension
libexec_PROGRAMS = cc-theme-thumbnailer-helper
cc_theme_thumbnailer_helper_SOURCES = \
cc-theme-thumbnailer-slave.c \
cc-theme-thumbnailer-slave.h \
cc-theme-thumbnailer-helper.c \
$(NULL)
cc_theme_thumbnailer_helper_LDADD = \
$(WINDOW_MANAGER_LIBS) \
$(GNOMECC_CAPPLETS_LIBS) \
$(NULL)
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \
activate-settings-daemon.c \
activate-settings-daemon.h \
capplet-stock-icons.c \
capplet-stock-icons.h \
capplet-util.c \
capplet-util.h \
file-transfer-dialog.c \
file-transfer-dialog.h \
gconf-property-editor.c \
gconf-property-editor.h \
gconf-property-editor-marshal.c \
gconf-property-editor-marshal.h \
gnome-theme-apply.c \
gnome-theme-apply.h \
gnome-theme-info.c \
gnome-theme-info.h \
gtkrc-utils.c \
gtkrc-utils.h \
cc-theme-thumbnailer.c \
cc-theme-thumbnailer.h \
theme-thumbnail.c \
theme-thumbnail.h \
wm-common.c \
wm-common.h
libcommon_la_LIBADD = \
$(top_builddir)/libwindow-settings/libgnome-window-settings.la \
$(WINDOW_MANAGER_LIBS) \
$(DBUS_LIBS) \
$(GNOME_DESKTOP_LIBS) \
$(GIO_LIBS)
libcommon_la_LDFLAGS = -export-dynamic -no-undefined -avoid-version
gnome_theme_test_SOURCES = \
gnome-theme-test.c
gnome_theme_test_LDADD = \
libcommon.la \
$(GNOMECC_CAPPLETS_LIBS)
noinst_PROGRAMS = \
gnome-theme-test
pkgconfigdir=$(libdir)/pkgconfig
pkgconfig_DATA=libgnome-control-center-extension.pc
EXTRA_DIST = \
libgnome-control-center-extension.pc.in \
$(NULL)
AM_CPPFLAGS = \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DEXTENSION_DIR="\"$(libdir)/control-center-1/extensions\"" \
-DUIDIR="\"$(uidir)\"" \
-DMENUDIR="\"$(menudir)\""
-include $(top_srcdir)/git.mk

View File

@@ -0,0 +1,231 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include "cc-page.h"
#define CC_PAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_PAGE, CcPagePrivate))
struct CcPagePrivate
{
char *id;
char *display_name;
gboolean is_active;
};
enum {
PROP_0,
PROP_ID,
PROP_DISPLAY_NAME,
};
enum {
ACTIVE_CHANGED,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
static void cc_page_class_init (CcPageClass *klass);
static void cc_page_init (CcPage *page);
static void cc_page_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (CcPage, cc_page, GTK_TYPE_ALIGNMENT)
static void
_cc_page_set_id (CcPage *page,
const char *id)
{
g_free (page->priv->id);
page->priv->id = g_strdup (id);
}
static void
_cc_page_set_display_name (CcPage *page,
const char *name)
{
g_free (page->priv->display_name);
page->priv->display_name = g_strdup (name);
}
static void
cc_page_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
CcPage *self;
self = CC_PAGE (object);
switch (prop_id) {
case PROP_ID:
_cc_page_set_id (self, g_value_get_string (value));
break;
case PROP_DISPLAY_NAME:
_cc_page_set_display_name (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_page_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
CcPage *self;
self = CC_PAGE (object);
switch (prop_id) {
case PROP_ID:
g_value_set_string (value, self->priv->id);
break;
case PROP_DISPLAY_NAME:
g_value_set_string (value, self->priv->display_name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_page_real_active_changed (CcPage *page,
gboolean is_active)
{
page->priv->is_active = is_active;
g_debug ("Page %s is %s",
page->priv->id,
page->priv->is_active ? "active" : "inactive");
}
void
cc_page_set_active (CcPage *page,
gboolean is_active)
{
g_return_if_fail (CC_IS_PAGE (page));
g_object_ref (page);
gtk_widget_queue_resize (GTK_WIDGET (page));
if (page->priv->is_active != is_active) {
g_signal_emit (page, signals [ACTIVE_CHANGED], 0, is_active);
}
g_object_unref (page);
}
gboolean
cc_page_is_active (CcPage *page)
{
g_return_val_if_fail (CC_IS_PAGE (page), FALSE);
return page->priv->is_active;
}
static GObject *
cc_page_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcPage *page;
page = CC_PAGE (G_OBJECT_CLASS (cc_page_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
return G_OBJECT (page);
}
static void
cc_page_class_init (CcPageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_page_get_property;
object_class->set_property = cc_page_set_property;
object_class->constructor = cc_page_constructor;
object_class->finalize = cc_page_finalize;
klass->active_changed = cc_page_real_active_changed;
g_type_class_add_private (klass, sizeof (CcPagePrivate));
signals [ACTIVE_CHANGED]
= g_signal_new ("active-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (CcPageClass, active_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_string ("id",
"id",
"id",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_DISPLAY_NAME,
g_param_spec_string ("display-name",
"display name",
"display name",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
cc_page_init (CcPage *page)
{
page->priv = CC_PAGE_GET_PRIVATE (page);
}
static void
cc_page_finalize (GObject *object)
{
CcPage *page;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_PAGE (object));
page = CC_PAGE (object);
g_return_if_fail (page->priv != NULL);
g_free (page->priv->id);
g_free (page->priv->display_name);
G_OBJECT_CLASS (cc_page_parent_class)->finalize (object);
}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_PAGE_H
#define __CC_PAGE_H
#include <glib-object.h>
G_BEGIN_DECLS
#define CC_TYPE_PAGE (cc_page_get_type ())
#define CC_PAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_PAGE, CcPage))
#define CC_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_PAGE, CcPageClass))
#define CC_IS_PAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_PAGE))
#define CC_IS_PAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_PAGE))
#define CC_PAGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_PAGE, CcPageClass))
typedef struct CcPagePrivate CcPagePrivate;
typedef struct
{
GtkAlignment parent;
CcPagePrivate *priv;
} CcPage;
typedef struct
{
GtkAlignmentClass parent_class;
void (* active_changed) (CcPage *page,
gboolean is_active);
} CcPageClass;
GType cc_page_get_type (void);
gboolean cc_page_is_active (CcPage *page);
void cc_page_set_active (CcPage *page,
gboolean is_active);
G_END_DECLS
#endif /* __CC_PAGE_H */

View File

@@ -0,0 +1,318 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include "cc-panel.h"
#include "cc-page.h"
#define CC_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_PANEL, CcPanelPrivate))
struct CcPanelPrivate
{
char *id;
char *display_name;
char *category;
char *current_location;
gboolean is_active;
CcPage *current_page;
CcShell *shell;
};
enum {
PROP_0,
PROP_ID,
PROP_DISPLAY_NAME,
PROP_CATEGORY,
PROP_CURRENT_LOCATION,
PROP_CURRENT_PAGE,
PROP_SHELL,
};
enum {
ACTIVE_CHANGED,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0, };
static void cc_panel_class_init (CcPanelClass *klass);
static void cc_panel_init (CcPanel *panel);
static void cc_panel_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_ALIGNMENT)
static void
_cc_panel_set_id (CcPanel *panel,
const char *id)
{
g_free (panel->priv->id);
panel->priv->id = g_strdup (id);
}
static void
_cc_panel_set_display_name (CcPanel *panel,
const char *name)
{
g_free (panel->priv->display_name);
panel->priv->display_name = g_strdup (name);
}
static void
_cc_panel_set_current_page (CcPanel *panel,
CcPage *page)
{
CcPage *old;
if (page == panel->priv->current_page)
return;
old = panel->priv->current_page;
panel->priv->current_page = page;
if (old != NULL) {
cc_page_set_active (old, FALSE);
}
if (panel->priv->current_page != NULL) {
g_object_ref (panel->priv->current_page);
cc_page_set_active (panel->priv->current_page,
panel->priv->is_active);
}
if (old != NULL) {
g_object_unref (old);
}
g_object_notify (G_OBJECT (panel), "current-page");
}
static void
_cc_panel_set_shell (CcPanel *panel,
CcShell *shell)
{
CcPanelPrivate *priv = panel->priv;
priv->shell = shell;
}
static void
cc_panel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
CcPanel *self;
self = CC_PANEL (object);
switch (prop_id) {
case PROP_ID:
_cc_panel_set_id (self, g_value_get_string (value));
break;
case PROP_DISPLAY_NAME:
_cc_panel_set_display_name (self, g_value_get_string (value));
break;
case PROP_CURRENT_PAGE:
_cc_panel_set_current_page (self, g_value_get_object (value));
break;
case PROP_SHELL:
_cc_panel_set_shell (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_panel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
CcPanel *self;
self = CC_PANEL (object);
switch (prop_id) {
case PROP_ID:
g_value_set_string (value, self->priv->id);
break;
case PROP_DISPLAY_NAME:
g_value_set_string (value, self->priv->display_name);
break;
case PROP_CURRENT_PAGE:
g_value_set_object (value, self->priv->current_page);
break;
case PROP_SHELL:
g_value_set_object (value, self->priv->shell);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
cc_panel_real_active_changed (CcPanel *panel,
gboolean is_active)
{
if (panel->priv->is_active == is_active)
return;
panel->priv->is_active = is_active;
if (panel->priv->current_page != NULL) {
cc_page_set_active (panel->priv->current_page, is_active);
}
g_debug ("Panel %s is %s",
panel->priv->id,
panel->priv->is_active ? "active" : "inactive");
}
void
cc_panel_set_active (CcPanel *panel,
gboolean is_active)
{
g_return_if_fail (CC_IS_PANEL (panel));
g_object_ref (panel);
gtk_widget_queue_resize (GTK_WIDGET (panel));
if (panel->priv->is_active != is_active) {
g_signal_emit (panel, signals [ACTIVE_CHANGED], 0, is_active);
}
g_object_unref (panel);
}
gboolean
cc_panel_is_active (CcPanel *panel)
{
g_return_val_if_fail (CC_IS_PANEL (panel), FALSE);
return panel->priv->is_active;
}
static GObject *
cc_panel_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
CcPanel *panel;
panel = CC_PANEL (G_OBJECT_CLASS (cc_panel_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
return G_OBJECT (panel);
}
static void
cc_panel_class_init (CcPanelClass *klass)
{
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = cc_panel_get_property;
object_class->set_property = cc_panel_set_property;
object_class->constructor = cc_panel_constructor;
object_class->finalize = cc_panel_finalize;
klass->active_changed = cc_panel_real_active_changed;
g_type_class_add_private (klass, sizeof (CcPanelPrivate));
signals [ACTIVE_CHANGED]
= g_signal_new ("active-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (CcPanelClass, active_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_string ("id",
"id",
"id",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_DISPLAY_NAME,
g_param_spec_string ("display-name",
"display name",
"display name",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_CURRENT_PAGE,
g_param_spec_object ("current-page",
"",
"",
CC_TYPE_PAGE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
pspec = g_param_spec_object ("shell",
"Shell",
"Shell",
CC_TYPE_SHELL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
| G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_SHELL, pspec);
}
static void
cc_panel_init (CcPanel *panel)
{
panel->priv = CC_PANEL_GET_PRIVATE (panel);
}
static void
cc_panel_finalize (GObject *object)
{
CcPanel *panel;
g_return_if_fail (object != NULL);
g_return_if_fail (CC_IS_PANEL (object));
panel = CC_PANEL (object);
g_return_if_fail (panel->priv != NULL);
g_free (panel->priv->id);
g_free (panel->priv->display_name);
G_OBJECT_CLASS (cc_panel_parent_class)->finalize (object);
}
CcShell *
cc_panel_get_shell (CcPanel *panel)
{
return panel->priv->shell;
}

View File

@@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __CC_PANEL_H
#define __CC_PANEL_H
#include <glib-object.h>
#include <gtk/gtk.h>
#include "cc-shell.h"
G_BEGIN_DECLS
#define CC_TYPE_PANEL (cc_panel_get_type ())
#define CC_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_PANEL, CcPanel))
#define CC_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_PANEL, CcPanelClass))
#define CC_IS_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_PANEL))
#define CC_IS_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_PANEL))
#define CC_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_PANEL, CcPanelClass))
#define CC_PANEL_EXTENSION_POINT_NAME "control-center-panel-1"
typedef struct CcPanelPrivate CcPanelPrivate;
typedef struct
{
GtkAlignment parent;
CcPanelPrivate *priv;
} CcPanel;
typedef struct
{
GtkAlignmentClass parent_class;
void (* active_changed) (CcPanel *panel,
gboolean is_active);
} CcPanelClass;
GType cc_panel_get_type (void);
gboolean cc_panel_is_active (CcPanel *panel);
void cc_panel_set_active (CcPanel *panel,
gboolean is_active);
CcShell* cc_panel_get_shell (CcPanel *panel);
G_END_DECLS
#endif /* __CC_PANEL_H */

View File

@@ -0,0 +1,275 @@
/*
* Copyright (c) 2010 Intel, Inc.
*
* The Control Center 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.
*
* The Control Center 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 General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the Control Center; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Thomas Wood <thos@gnome.org>
*/
#include "cc-shell.h"
#include "cc-panel.h"
G_DEFINE_TYPE (CcShell, cc_shell, GTK_TYPE_BUILDER)
#define SHELL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL, CcShellPrivate))
struct _CcShellPrivate
{
gchar *current_title;
CcPanel *current_panel;
GHashTable *panels;
};
static void
cc_shell_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_shell_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
cc_shell_dispose (GObject *object)
{
G_OBJECT_CLASS (cc_shell_parent_class)->dispose (object);
}
static void
cc_shell_finalize (GObject *object)
{
CcShellPrivate *priv = CC_SHELL (object)->priv;
if (priv->panels)
{
g_hash_table_destroy (priv->panels);
priv->panels = NULL;
}
G_OBJECT_CLASS (cc_shell_parent_class)->finalize (object);
}
static GObject*
cc_shell_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GError *err = NULL;
GObject *object;
object =
G_OBJECT_CLASS (cc_shell_parent_class)->constructor (type,
n_construct_properties,
construct_properties);
gtk_builder_add_from_file (GTK_BUILDER (object),
UIDIR "/shell.ui",
&err);
if (err)
{
g_warning ("Could not load UI file: %s", err->message);
g_error_free (err);
g_object_unref (object);
return NULL;
}
return object;
}
static void
cc_shell_class_init (CcShellClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcShellPrivate));
object_class->get_property = cc_shell_get_property;
object_class->set_property = cc_shell_set_property;
object_class->dispose = cc_shell_dispose;
object_class->finalize = cc_shell_finalize;
object_class->constructor = cc_shell_constructor;
}
static void
load_panel_plugins (CcShell *shell)
{
CcShellPrivate *priv = shell->priv;
static volatile GType panel_type = G_TYPE_INVALID;
static GIOExtensionPoint *ep = NULL;
GList *modules;
GList *panel_implementations;
GList *l;
GTimer *timer;
/* make sure base type is registered */
if (panel_type == G_TYPE_INVALID)
{
panel_type = g_type_from_name ("CcPanel");
}
priv->panels = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
g_object_unref);
if (ep == NULL)
{
g_debug ("Registering extension point");
ep = g_io_extension_point_register (CC_PANEL_EXTENSION_POINT_NAME);
}
/* load all modules */
g_debug ("Loading all modules in %s", EXTENSIONSDIR);
modules = g_io_modules_load_all_in_directory (EXTENSIONSDIR);
g_debug ("Loaded %d modules", g_list_length (modules));
#ifdef RUN_IN_SOURCE_TREE
if (g_list_length (modules) == 0)
modules = load_panel_plugins_from_source ();
#endif
/* find all extensions */
timer = g_timer_new ();
panel_implementations = g_io_extension_point_get_extensions (ep);
for (l = panel_implementations; l != NULL; l = l->next)
{
GIOExtension *extension;
CcPanel *panel;
char *id;
extension = l->data;
g_debug ("Found extension: %s %d", g_io_extension_get_name (extension),
g_io_extension_get_priority (extension));
panel = g_object_new (g_io_extension_get_type (extension),
"shell", shell,
NULL);
g_object_get (panel, "id", &id, NULL);
g_hash_table_insert (priv->panels, g_strdup (id), g_object_ref (panel));
g_debug ("id: '%s', loaded in %fsec", id, g_timer_elapsed (timer, NULL));
g_free (id);
g_timer_start (timer);
}
g_timer_destroy (timer);
timer = NULL;
/* unload all modules; the module our instantiated authority is in won't be unloaded because
* we've instantiated a reference to a type in this module
*/
g_list_foreach (modules, (GFunc) g_type_module_unuse, NULL);
g_list_free (modules);
}
static void
cc_shell_init (CcShell *self)
{
self->priv = SHELL_PRIVATE (self);
load_panel_plugins (self);
}
CcShell *
cc_shell_new (void)
{
return g_object_new (CC_TYPE_SHELL, NULL);
}
gboolean
cc_shell_set_panel (CcShell *shell,
const gchar *id)
{
CcPanel *panel;
CcShellPrivate *priv = shell->priv;
GtkBuilder *builder = GTK_BUILDER (shell);
GtkWidget *notebook;
notebook =
(GtkWidget*) gtk_builder_get_object (GTK_BUILDER (shell), "notebook");
if (!id)
{
if (priv->current_panel != NULL)
cc_panel_set_active (priv->current_panel, FALSE);
priv->current_panel = NULL;
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
OVERVIEW_PAGE);
return TRUE;
}
/* first look for a panel module */
panel = g_hash_table_lookup (priv->panels, id);
if (panel != NULL)
{
priv->current_panel = panel;
gtk_container_set_border_width (GTK_CONTAINER (panel), 12);
gtk_widget_show_all (GTK_WIDGET (panel));
cc_panel_set_active (panel, TRUE);
gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
GTK_WIDGET (panel), NULL, CAPPLET_PAGE);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
CAPPLET_PAGE);
gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder,
"label-title")),
priv->current_title);
gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder,
"title-alignment")));
return TRUE;
}
else
{
return FALSE;
}
}
void
cc_shell_set_title (CcShell *shell,
const gchar *title)
{
CcShellPrivate *priv = shell->priv;
g_free (priv->current_title);
priv->current_title = g_strdup (title);
}

Some files were not shown because too many files have changed in this diff Show More