Created new background properties capplet, under new-background-properties
This commit is contained in:
parent
9888a8794e
commit
818c4291c1
11 changed files with 3226 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
always_built_SUBDIRS = desktop-links mouse-properties \
|
||||
new-screensaver-properties background-properties \
|
||||
new-screensaver-properties new-background-properties \
|
||||
theme-switcher sound-properties bell-properties \
|
||||
ui-properties url-properties gnome-edit-properties \
|
||||
session-properties wm-properties keyboard-properties \
|
||||
|
|
39
capplets/background/Makefile.am
Normal file
39
capplets/background/Makefile.am
Normal file
|
@ -0,0 +1,39 @@
|
|||
Applicationsdir = $(datadir)/control-center/Desktop
|
||||
Applications_DATA = \
|
||||
background-properties.desktop
|
||||
|
||||
Gladedir = $(datadir)/control-center-data
|
||||
Glade_DATA = \
|
||||
background-properties.glade
|
||||
|
||||
EXTRA_DIST = ChangeLog $(Applications_DATA) $(Glade_DATA)
|
||||
|
||||
INCLUDES = \
|
||||
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
||||
-DGNOME_ICONDIR=\""${prefix}/share/pixmaps"\" \
|
||||
-DG_LOG_DOMAIN=\"background-properties\" \
|
||||
-DGLADE_DATADIR=\""$(Gladedir)"\" \
|
||||
$(GNOME_INCLUDEDIR) \
|
||||
$(LIBGLADE_CFLAGS) \
|
||||
$(XML_CFLAGS) \
|
||||
-I$(top_srcdir)/ \
|
||||
-I$(top_srcdir)/intl \
|
||||
-I$(top_srcdir)/libcapplet
|
||||
|
||||
bin_PROGRAMS = background-properties-capplet
|
||||
|
||||
background_properties_capplet_SOURCES = \
|
||||
prefs-widget.c prefs-widget.h \
|
||||
preferences.c preferences.h \
|
||||
applier.c applier.h \
|
||||
main.c
|
||||
|
||||
background_properties_capplet_LDADD = \
|
||||
$(GNOME_LIBDIR) \
|
||||
$(GNOMEUI_LIBS) \
|
||||
$(ORBIT_LIBS) \
|
||||
$(GNOME_XML_LIB) \
|
||||
$(LIBGLADE_LIBS) \
|
||||
-lgdk_pixbuf \
|
||||
-lgdk_pixbuf_xlib \
|
||||
../../libcapplet/libcapplet.la
|
1097
capplets/background/applier.c
Normal file
1097
capplets/background/applier.c
Normal file
File diff suppressed because it is too large
Load diff
64
capplets/background/applier.h
Normal file
64
capplets/background/applier.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* applier.h
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __APPLIER_H
|
||||
#define __APPLIER_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "preferences.h"
|
||||
|
||||
#define APPLIER(obj) GTK_CHECK_CAST (obj, applier_get_type (), Applier)
|
||||
#define APPLIER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, applier_get_type (), ApplierClass)
|
||||
#define IS_APPLIER(obj) GTK_CHECK_TYPE (obj, applier_get_type ())
|
||||
|
||||
typedef struct _Applier Applier;
|
||||
typedef struct _ApplierClass ApplierClass;
|
||||
|
||||
typedef struct _ApplierPrivate ApplierPrivate;
|
||||
|
||||
struct _Applier
|
||||
{
|
||||
GtkObject object;
|
||||
ApplierPrivate *private;
|
||||
};
|
||||
|
||||
struct _ApplierClass
|
||||
{
|
||||
GtkObjectClass klass;
|
||||
};
|
||||
|
||||
guint applier_get_type (void);
|
||||
|
||||
GtkObject *applier_new (void);
|
||||
void applier_destroy (GtkObject *object);
|
||||
|
||||
void applier_apply_prefs (Applier *applier, Preferences *prefs,
|
||||
gboolean do_root, gboolean do_preview);
|
||||
|
||||
GtkWidget *applier_class_get_preview_widget (void);
|
||||
|
||||
#endif /* __APPLIER_H */
|
51
capplets/background/background-properties.desktop
Normal file
51
capplets/background/background-properties.desktop
Normal file
|
@ -0,0 +1,51 @@
|
|||
[Desktop Entry]
|
||||
Name=Background
|
||||
Name[da]=Baggrund
|
||||
Name[ca]=Propietats del fons
|
||||
Name[cs]=Vlastnosti pozadí
|
||||
Name[de]=Hintergrund
|
||||
Name[es]=Propiedades del tapiz
|
||||
Name[et]=Taust
|
||||
Name[fi]=Tausta
|
||||
Name[fr]=Propriètés de l'Arrière-plan
|
||||
Name[gl]=Propiedades do tapiz
|
||||
Name[hu]=Háttér
|
||||
Name[it]=Sfondo
|
||||
Name[ja]=¥Ð¥Ã¥¯¥°¥é¥¦¥ó¥É
|
||||
Name[ko]=¹è°æ
|
||||
Name[lt]=Fonas
|
||||
Name[no]=Bakgrunn
|
||||
Name[pl]=T³o
|
||||
Name[pt]=Propriedades do Fundo
|
||||
Name[pt_BR]=Propriedades do Fundo
|
||||
Name[ru]=æÏÎ
|
||||
Name[sl]=Ozadje
|
||||
Name[sv]=Bakgrund
|
||||
Name[uk]=ôÌÏ
|
||||
Name[wa]=Fond do scribanne
|
||||
Name[zh_TW.Big5]=®à±I´º
|
||||
Name[zh_CN.GB2312]=×ÀÃæ±³¾°
|
||||
Comment=Configuration of the desktop's background
|
||||
Comment[cs]=Zmìna pozadí pracovní plochy (obrázek)
|
||||
Comment[da]=Indstil din skrivebordsbaggrund
|
||||
Comment[de]=Konfiguration des Desktophintergrundes
|
||||
Comment[es]=Configuración del tapiz del escritorio
|
||||
Comment[et]=Töölaua tausta häälestus
|
||||
Comment[fi]=Taustan asetukset
|
||||
Comment[gl]=Configuración do tapiz do escritorio
|
||||
Comment[it]=Impostazioni dello sfondo del desktop
|
||||
Comment[ja]=¥Ç¥¹¥¯¥È¥Ã¥×ÇطʤÎÀßÄê
|
||||
Comment[lt]=Darbalaukio fono nustatymas
|
||||
Comment[no]=Konfigurasjon av skrivebordsbakgrunn
|
||||
Comment[pl]=Konfiguracja t³a
|
||||
Comment[pt_BR]=Configuração do fundo da área de trabalho
|
||||
Comment[sl]=Nastavitev ozadja namizja
|
||||
Comment[sv]=Konfiguration av skrivbordsbakgrund
|
||||
Comment[uk]=ëÏÎƦÇÕÒÕ×ÁÎÎÑ ÔÌÁ
|
||||
Comment[wa]=Apontiaedje do fond do scribanne
|
||||
Comment[zh_TW.Big5]=³]©w®à±I´º¼Ë¦¡
|
||||
Comment[zh_CN.GB2312]=É趨×ÀÃæ±³¾°Ñùʽ
|
||||
Exec=background-properties-capplet
|
||||
Icon=gnome-ccbackground.png
|
||||
Terminal=0
|
||||
Type=Application
|
525
capplets/background/background-properties.glade
Normal file
525
capplets/background/background-properties.glade
Normal file
|
@ -0,0 +1,525 @@
|
|||
<?xml version="1.0"?>
|
||||
<GTK-Interface>
|
||||
|
||||
<project>
|
||||
<name>New-background-properties</name>
|
||||
<program_name>new-background-properties</program_name>
|
||||
<directory></directory>
|
||||
<source_directory>src</source_directory>
|
||||
<pixmaps_directory>pixmaps</pixmaps_directory>
|
||||
<language>C</language>
|
||||
<gnome_support>True</gnome_support>
|
||||
<gettext_support>True</gettext_support>
|
||||
</project>
|
||||
|
||||
<widget>
|
||||
<class>GtkWindow</class>
|
||||
<name>window1</name>
|
||||
<title>window1</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
|
||||
<widget>
|
||||
<class>GtkTable</class>
|
||||
<name>prefs_widget</name>
|
||||
<border_width>5</border_width>
|
||||
<rows>3</rows>
|
||||
<columns>2</columns>
|
||||
<homogeneous>False</homogeneous>
|
||||
<row_spacing>5</row_spacing>
|
||||
<column_spacing>5</column_spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>color_frame</name>
|
||||
<label>Color</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>True</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkTable</class>
|
||||
<name>table2</name>
|
||||
<border_width>5</border_width>
|
||||
<rows>5</rows>
|
||||
<columns>3</columns>
|
||||
<homogeneous>False</homogeneous>
|
||||
<row_spacing>5</row_spacing>
|
||||
<column_spacing>5</column_spacing>
|
||||
|
||||
<widget>
|
||||
<class>GtkVSeparator</class>
|
||||
<name>vseparator1</name>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>5</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>True</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label2</name>
|
||||
<label>Color 1</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>False</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>color2_label</name>
|
||||
<label>Color 2</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>3</top_attach>
|
||||
<bottom_attach>4</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>False</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GnomeColorPicker</class>
|
||||
<name>color1_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>color_set</name>
|
||||
<handler>color1_select_color_set_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:13:53 GMT</last_modification_time>
|
||||
</signal>
|
||||
<dither>True</dither>
|
||||
<use_alpha>False</use_alpha>
|
||||
<title>Pick a color</title>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>False</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GnomeColorPicker</class>
|
||||
<name>color2_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>color_set</name>
|
||||
<handler>color2_select_color_set_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:14:05 GMT</last_modification_time>
|
||||
</signal>
|
||||
<dither>True</dither>
|
||||
<use_alpha>False</use_alpha>
|
||||
<title>Pick a color</title>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>4</top_attach>
|
||||
<bottom_attach>5</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>False</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>solid_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>solid_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:13:09 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Solid</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>gradient_group</group>
|
||||
<child>
|
||||
<left_attach>2</left_attach>
|
||||
<right_attach>3</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>gradient_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>gradient_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:13:19 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Gradient</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>gradient_group</group>
|
||||
<child>
|
||||
<left_attach>2</left_attach>
|
||||
<right_attach>3</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>vertical_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>vertical_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:13:28 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Vertical</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>orientation_group</group>
|
||||
<child>
|
||||
<left_attach>2</left_attach>
|
||||
<right_attach>3</right_attach>
|
||||
<top_attach>3</top_attach>
|
||||
<bottom_attach>4</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>horizontal_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>horizontal_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:13:39 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Horizontal</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>orientation_group</group>
|
||||
<child>
|
||||
<left_attach>2</left_attach>
|
||||
<right_attach>3</right_attach>
|
||||
<top_attach>4</top_attach>
|
||||
<bottom_attach>5</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHSeparator</class>
|
||||
<name>hseparator1</name>
|
||||
<child>
|
||||
<left_attach>2</left_attach>
|
||||
<right_attach>3</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>wallpaper_frame</name>
|
||||
<label>Wallpaper</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>1</top_attach>
|
||||
<bottom_attach>2</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox3</name>
|
||||
<border_width>5</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>5</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GnomeFileEntry</class>
|
||||
<name>wallpaper_entry</name>
|
||||
<max_saved>10</max_saved>
|
||||
<directory>False</directory>
|
||||
<modal>False</modal>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
<child_name>GnomeEntry:entry</child_name>
|
||||
<name>combo-entry1</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>wallpaper_entry_changed_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:14:44 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>tiled_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>tiled_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:15:01 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Tiled</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>wallpaper_type_group</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>centered_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>centered_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:15:10 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Centered</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>wallpaper_type_group</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>scaled_aspect_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>scaled_aspect_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:15:18 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Scaled (keep aspect)</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>wallpaper_type_group</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkRadioButton</class>
|
||||
<name>scaled_select</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>scaled_select_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:15:28 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Scaled</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<group>wallpaper_type_group</group>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>disable_toggle</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>disable_toggled_cb</handler>
|
||||
<last_modification_time>Wed, 06 Sep 2000 00:15:45 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Disable background selection</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>True</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>monitor_frame</name>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_NONE</shadow_type>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>0</top_attach>
|
||||
<bottom_attach>1</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>True</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>True</yfill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
</GTK-Interface>
|
187
capplets/background/main.c
Normal file
187
capplets/background/main.c
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* main.c
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen (hovinen@helixcode.com)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gnome.h>
|
||||
#include <libgnomeui/gnome-window-icon.h>
|
||||
#include <tree.h>
|
||||
#include <parser.h>
|
||||
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include <capplet-widget.h>
|
||||
|
||||
#include "preferences.h"
|
||||
#include "prefs-widget.h"
|
||||
|
||||
static Preferences *prefs;
|
||||
static Preferences *old_prefs;
|
||||
static PrefsWidget *prefs_widget;
|
||||
|
||||
static void
|
||||
ok_cb (GtkWidget *widget)
|
||||
{
|
||||
preferences_save (prefs);
|
||||
preferences_apply_now (prefs);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_cb (GtkWidget *widget)
|
||||
{
|
||||
preferences_save (old_prefs);
|
||||
preferences_apply_now (old_prefs);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_capplet_widget (void)
|
||||
{
|
||||
preferences_freeze (prefs);
|
||||
|
||||
prefs_widget = PREFS_WIDGET (prefs_widget_new (prefs));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok",
|
||||
GTK_SIGNAL_FUNC (ok_cb), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel",
|
||||
GTK_SIGNAL_FUNC (cancel_cb), NULL);
|
||||
|
||||
/* FIXME */
|
||||
gtk_widget_show_all (GTK_WIDGET
|
||||
(CAPPLET_WIDGET (prefs_widget)->dialog));
|
||||
|
||||
preferences_thaw (prefs);
|
||||
}
|
||||
|
||||
static void
|
||||
do_get_xml (void)
|
||||
{
|
||||
Preferences *prefs;
|
||||
xmlDocPtr doc;
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
preferences_load (prefs);
|
||||
doc = preferences_write_xml (prefs);
|
||||
xmlDocDump (stdout, doc);
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
}
|
||||
|
||||
static void
|
||||
do_set_xml (void)
|
||||
{
|
||||
Preferences *prefs;
|
||||
xmlDocPtr doc;
|
||||
char *buffer;
|
||||
int len = 0;
|
||||
|
||||
while (!feof (stdin)) {
|
||||
if (!len) buffer = g_new (char, 16384);
|
||||
else buffer = g_renew (char, buffer, len + 16384);
|
||||
fread (buffer + len, 1, 16384, stdin);
|
||||
len += 16384;
|
||||
}
|
||||
|
||||
doc = xmlParseMemory (buffer, strlen (buffer));
|
||||
|
||||
prefs = preferences_read_xml (doc);
|
||||
|
||||
if (prefs)
|
||||
preferences_save (prefs);
|
||||
else
|
||||
g_warning ("Error while reading the screensaver config file");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GnomeClient *client;
|
||||
GnomeClientFlags flags;
|
||||
gint token, res;
|
||||
gchar *restart_args[3];
|
||||
|
||||
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
glade_gnome_init ();
|
||||
res = gnome_capplet_init ("background-properties-capplet",
|
||||
VERSION, argc, argv, NULL,
|
||||
0, NULL);
|
||||
|
||||
if (res < 0) {
|
||||
g_error ("Could not initialize the capplet.");
|
||||
}
|
||||
else if (res == 3) {
|
||||
do_get_xml ();
|
||||
return 0;
|
||||
}
|
||||
else if (res == 4) {
|
||||
do_set_xml ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
client = gnome_master_client ();
|
||||
flags = gnome_client_get_flags (client);
|
||||
|
||||
if (flags & GNOME_CLIENT_IS_CONNECTED) {
|
||||
token = gnome_startup_acquire_token
|
||||
("GNOME_BACKGROUND_PROPERTIES",
|
||||
gnome_client_get_id (client));
|
||||
|
||||
if (token) {
|
||||
gnome_client_set_priority (client, 20);
|
||||
gnome_client_set_restart_style (client,
|
||||
GNOME_RESTART_ANYWAY);
|
||||
restart_args[0] = argv[0];
|
||||
restart_args[1] = "--init-session-settings";
|
||||
restart_args[2] = NULL;
|
||||
gnome_client_set_restart_command (client, 2,
|
||||
restart_args);
|
||||
} else {
|
||||
gnome_client_set_restart_style (client,
|
||||
GNOME_RESTART_NEVER);
|
||||
}
|
||||
} else {
|
||||
token = 1;
|
||||
}
|
||||
|
||||
gnome_window_icon_set_default_from_file
|
||||
(GNOME_ICONDIR"/gnome-ccbackground.png");
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
preferences_load (prefs);
|
||||
|
||||
if (token) {
|
||||
preferences_apply_now (prefs);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
old_prefs = PREFERENCES (preferences_clone (prefs));
|
||||
setup_capplet_widget ();
|
||||
|
||||
capplet_gtk_main ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
492
capplets/background/preferences.c
Normal file
492
capplets/background/preferences.c
Normal file
|
@ -0,0 +1,492 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* preferences.c
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gnome.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
|
||||
|
||||
#include "preferences.h"
|
||||
#include "applier.h"
|
||||
|
||||
static GtkObjectClass *parent_class;
|
||||
static Applier *applier = NULL;
|
||||
|
||||
static void preferences_init (Preferences *prefs);
|
||||
static void preferences_class_init (PreferencesClass *class);
|
||||
|
||||
static gint xml_read_int (xmlNodePtr node,
|
||||
gchar *propname);
|
||||
static xmlNodePtr xml_write_int (gchar *name,
|
||||
gchar *propname,
|
||||
gint number);
|
||||
|
||||
static gint apply_timeout_cb (Preferences *prefs);
|
||||
|
||||
static GdkColor *read_color_from_string (gchar *string);
|
||||
|
||||
guint
|
||||
preferences_get_type (void)
|
||||
{
|
||||
static guint preferences_type = 0;
|
||||
|
||||
if (!preferences_type) {
|
||||
GtkTypeInfo preferences_info = {
|
||||
"Preferences",
|
||||
sizeof (Preferences),
|
||||
sizeof (PreferencesClass),
|
||||
(GtkClassInitFunc) preferences_class_init,
|
||||
(GtkObjectInitFunc) preferences_init,
|
||||
(GtkArgSetFunc) NULL,
|
||||
(GtkArgGetFunc) NULL
|
||||
};
|
||||
|
||||
preferences_type =
|
||||
gtk_type_unique (gtk_object_get_type (),
|
||||
&preferences_info);
|
||||
}
|
||||
|
||||
return preferences_type;
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_init (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = FALSE;
|
||||
|
||||
prefs->color1 = NULL;
|
||||
prefs->color2 = NULL;
|
||||
prefs->wallpaper_filename = NULL;
|
||||
prefs->wallpaper_sel_path = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_class_init (PreferencesClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) class;
|
||||
object_class->destroy = preferences_destroy;
|
||||
|
||||
parent_class =
|
||||
GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ()));
|
||||
|
||||
if (applier == NULL)
|
||||
applier = APPLIER (applier_new ());
|
||||
}
|
||||
|
||||
GtkObject *
|
||||
preferences_new (void)
|
||||
{
|
||||
GtkObject *object;
|
||||
|
||||
object = gtk_type_new (preferences_get_type ());
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
GtkObject *
|
||||
preferences_clone (Preferences *prefs)
|
||||
{
|
||||
GtkObject *object;
|
||||
Preferences *new_prefs;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, NULL);
|
||||
g_return_val_if_fail (IS_PREFERENCES (prefs), NULL);
|
||||
|
||||
object = preferences_new ();
|
||||
|
||||
new_prefs = PREFERENCES (object);
|
||||
|
||||
new_prefs->enabled = prefs->enabled;
|
||||
new_prefs->gradient_enabled = prefs->gradient_enabled;
|
||||
new_prefs->wallpaper_enabled = prefs->wallpaper_enabled;
|
||||
new_prefs->orientation = prefs->orientation;
|
||||
new_prefs->wallpaper_type = prefs->wallpaper_type;
|
||||
|
||||
if (prefs->color1)
|
||||
new_prefs->color1 = gdk_color_copy (prefs->color1);
|
||||
if (prefs->color2)
|
||||
new_prefs->color2 = gdk_color_copy (prefs->color2);
|
||||
|
||||
if (prefs->wallpaper_filename)
|
||||
new_prefs->wallpaper_filename =
|
||||
g_strdup (prefs->wallpaper_filename);
|
||||
if (prefs->wallpaper_sel_path)
|
||||
new_prefs->wallpaper_sel_path =
|
||||
g_strdup (prefs->wallpaper_sel_path);;
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
preferences_destroy (GtkObject *object)
|
||||
{
|
||||
Preferences *prefs;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (object));
|
||||
|
||||
prefs = PREFERENCES (object);
|
||||
|
||||
if (prefs->wallpaper_filename)
|
||||
g_free (prefs->wallpaper_filename);
|
||||
if (prefs->wallpaper_sel_path)
|
||||
g_free (prefs->wallpaper_sel_path);
|
||||
|
||||
parent_class->destroy (object);
|
||||
}
|
||||
|
||||
void
|
||||
preferences_load (Preferences *prefs)
|
||||
{
|
||||
gchar *string;
|
||||
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
if (prefs->color1) g_free (prefs->color1);
|
||||
string = gnome_config_get_string
|
||||
("/Background/Default/color1=#005060");
|
||||
prefs->color1 = read_color_from_string (string);
|
||||
g_free (string);
|
||||
|
||||
if (prefs->color2) g_free (prefs->color2);
|
||||
string = gnome_config_get_string
|
||||
("/Background/Default/color2=#0000ff");
|
||||
prefs->color2 = read_color_from_string (string);
|
||||
g_free (string);
|
||||
|
||||
string = gnome_config_get_string ("/Background/Default/Enabled=True");
|
||||
prefs->enabled = !(g_strcasecmp (string, "True"));
|
||||
g_free (string);
|
||||
|
||||
string = gnome_config_get_string ("/Background/Default/type=simple");
|
||||
if (!g_strcasecmp (string, "wallpaper"))
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
else if (g_strcasecmp (string, "simple"))
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
g_free (string);
|
||||
|
||||
string = gnome_config_get_string ("/Background/Default/simple=solid");
|
||||
if (!g_strcasecmp (string, "gradient"))
|
||||
prefs->gradient_enabled = TRUE;
|
||||
else if (g_strcasecmp (string, "solid"))
|
||||
prefs->gradient_enabled = FALSE;
|
||||
g_free (string);
|
||||
|
||||
string = gnome_config_get_string
|
||||
("/Background/Default/gradient=vertical");
|
||||
if (!g_strcasecmp (string, "vertical"))
|
||||
prefs->orientation = ORIENTATION_VERT;
|
||||
else if (!g_strcasecmp (string, "horizontal"))
|
||||
prefs->orientation = ORIENTATION_HORIZ;
|
||||
g_free (string);
|
||||
|
||||
prefs->wallpaper_type =
|
||||
gnome_config_get_int ("/Background/Default/wallpaperAlign=0");
|
||||
|
||||
prefs->wallpaper_filename =
|
||||
gnome_config_get_string ("/Background/Default/wallpaper=none");
|
||||
prefs->wallpaper_sel_path =
|
||||
gnome_config_get_string
|
||||
("/Background/Default/wallpapers_dir=./");
|
||||
|
||||
if (!g_strcasecmp (prefs->wallpaper_filename, "none")) {
|
||||
g_free(prefs->wallpaper_filename);
|
||||
prefs->wallpaper_filename = NULL;
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
} else {
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
preferences_save (Preferences *prefs)
|
||||
{
|
||||
char buffer[16];
|
||||
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
snprintf (buffer, sizeof(buffer), "#%02x%02x%02x",
|
||||
prefs->color1->red >> 8,
|
||||
prefs->color1->green >> 8,
|
||||
prefs->color1->blue >> 8);
|
||||
gnome_config_set_string ("/Background/Default/color1", buffer);
|
||||
snprintf (buffer, sizeof(buffer), "#%02x%02x%02x",
|
||||
prefs->color2->red >> 8,
|
||||
prefs->color2->green >> 8,
|
||||
prefs->color2->blue >> 8);
|
||||
gnome_config_set_string ("/Background/Default/color2", buffer);
|
||||
|
||||
gnome_config_set_string ("/Background/Default/Enabled",
|
||||
(prefs->enabled) ? "True" : "False");
|
||||
|
||||
gnome_config_set_string ("/Background/Default/simple",
|
||||
(prefs->gradient_enabled) ?
|
||||
"gradient" : "solid");
|
||||
gnome_config_set_string ("/Background/Default/gradient",
|
||||
(prefs->orientation == ORIENTATION_VERT) ?
|
||||
"vertical" : "horizontal");
|
||||
|
||||
gnome_config_set_string ("/Background/Default/wallpaper",
|
||||
(prefs->wallpaper_enabled) ?
|
||||
prefs->wallpaper_filename : "none");
|
||||
gnome_config_set_int ("/Background/Default/wallpaperAlign",
|
||||
prefs->wallpaper_type);
|
||||
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
void
|
||||
preferences_changed (Preferences *prefs)
|
||||
{
|
||||
if (prefs->frozen) return;
|
||||
|
||||
if (prefs->timeout_id)
|
||||
gtk_timeout_remove (prefs->timeout_id);
|
||||
|
||||
prefs->timeout_id = gtk_timeout_add (1000,
|
||||
(GtkFunction) apply_timeout_cb,
|
||||
prefs);
|
||||
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
preferences_apply_now (Preferences *prefs)
|
||||
{
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
if (prefs->timeout_id)
|
||||
gtk_timeout_remove (prefs->timeout_id);
|
||||
|
||||
prefs->timeout_id = 0;
|
||||
|
||||
applier_apply_prefs (applier, prefs, TRUE, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
preferences_apply_preview (Preferences *prefs)
|
||||
{
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
preferences_freeze (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
preferences_thaw (Preferences *prefs)
|
||||
{
|
||||
prefs->frozen = FALSE;
|
||||
}
|
||||
|
||||
Preferences *
|
||||
preferences_read_xml (xmlDocPtr xml_doc)
|
||||
{
|
||||
Preferences *prefs;
|
||||
xmlNodePtr root_node, node;
|
||||
char *str;
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
|
||||
root_node = xmlDocGetRootElement (xml_doc);
|
||||
|
||||
if (strcmp (root_node->name, "background-properties"))
|
||||
return NULL;
|
||||
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
prefs->gradient_enabled = FALSE;
|
||||
prefs->orientation = ORIENTATION_VERT;
|
||||
|
||||
if (prefs->color1) {
|
||||
gdk_color_free (prefs->color1);
|
||||
prefs->color1 = NULL;
|
||||
}
|
||||
|
||||
if (prefs->color2) {
|
||||
gdk_color_free (prefs->color2);
|
||||
prefs->color2 = NULL;
|
||||
}
|
||||
|
||||
for (node = root_node->childs; node; node = node->next) {
|
||||
if (!strcmp (node->name, "bg-color1"))
|
||||
prefs->color1 = read_color_from_string
|
||||
(xmlNodeGetContent (node));
|
||||
else if (!strcmp (node->name, "bg-color2"))
|
||||
prefs->color2 = read_color_from_string
|
||||
(xmlNodeGetContent (node));
|
||||
else if (!strcmp (node->name, "enabled"))
|
||||
prefs->enabled = TRUE;
|
||||
else if (!strcmp (node->name, "wallpaper"))
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
else if (!strcmp (node->name, "gradient"))
|
||||
prefs->gradient_enabled = TRUE;
|
||||
else if (!strcmp (node->name, "orientation")) {
|
||||
str = xmlNodeGetContent (node);
|
||||
|
||||
if (!g_strcasecmp (str, "horizontal"))
|
||||
prefs->orientation = ORIENTATION_HORIZ;
|
||||
else if (!g_strcasecmp (str, "vertical"))
|
||||
prefs->orientation = ORIENTATION_VERT;
|
||||
}
|
||||
else if (!strcmp (node->name, "wallpaper-type"))
|
||||
prefs->wallpaper_type = xml_read_int (node, NULL);
|
||||
else if (!strcmp (node->name, "wallpaper-filename"))
|
||||
prefs->wallpaper_filename =
|
||||
g_strdup (xmlNodeGetContent (node));
|
||||
else if (!strcmp (node->name, "wallpaper-sel-path"))
|
||||
prefs->wallpaper_sel_path =
|
||||
g_strdup (xmlNodeGetContent (node));
|
||||
}
|
||||
|
||||
return prefs;
|
||||
}
|
||||
|
||||
xmlDocPtr
|
||||
preferences_write_xml (Preferences *prefs)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr node;
|
||||
char tmp[16];
|
||||
|
||||
doc = xmlNewDoc ("1.0");
|
||||
|
||||
node = xmlNewDocNode (doc, NULL, "background-properties", NULL);
|
||||
|
||||
snprintf (tmp, sizeof (tmp), "#%02x%02x%02x",
|
||||
prefs->color1->red >> 8,
|
||||
prefs->color1->green >> 8,
|
||||
prefs->color1->blue >> 8);
|
||||
xmlNewChild (node, NULL, "bg-color1", tmp);
|
||||
|
||||
snprintf (tmp, sizeof (tmp), "#%02x%02x%02x",
|
||||
prefs->color2->red >> 8,
|
||||
prefs->color2->green >> 8,
|
||||
prefs->color2->blue >> 8);
|
||||
xmlNewChild (node, NULL, "bg-color2", tmp);
|
||||
|
||||
if (prefs->enabled)
|
||||
xmlNewChild (node, NULL, "enabled", NULL);
|
||||
|
||||
if (prefs->wallpaper_enabled)
|
||||
xmlNewChild (node, NULL, "wallpaper", NULL);
|
||||
|
||||
if (prefs->gradient_enabled)
|
||||
xmlNewChild (node, NULL, "gradient", NULL);
|
||||
|
||||
xmlNewChild (node, NULL, "orientation",
|
||||
(prefs->orientation == ORIENTATION_VERT) ?
|
||||
"vertical" : "horizontal");
|
||||
|
||||
xmlAddChild (node, xml_write_int ("wallpaper-type", NULL,
|
||||
prefs->wallpaper_type));
|
||||
|
||||
xmlNewChild (node, NULL, "wallpaper-filename",
|
||||
prefs->wallpaper_filename);
|
||||
xmlNewChild (node, NULL, "wallpaper-sel-path",
|
||||
prefs->wallpaper_sel_path);
|
||||
|
||||
xmlDocSetRootElement (doc, node);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
/* Read a numeric value from a node */
|
||||
|
||||
static gint
|
||||
xml_read_int (xmlNodePtr node, char *propname)
|
||||
{
|
||||
char *text;
|
||||
|
||||
if (propname == NULL)
|
||||
text = xmlNodeGetContent (node);
|
||||
else
|
||||
text = xmlGetProp (node, propname);
|
||||
|
||||
if (text == NULL)
|
||||
return 0;
|
||||
else
|
||||
return atoi (text);
|
||||
}
|
||||
|
||||
/* Write out a numeric value in a node */
|
||||
|
||||
static xmlNodePtr
|
||||
xml_write_int (gchar *name, gchar *propname, gint number)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
gchar *str;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
str = g_strdup_printf ("%d", number);
|
||||
|
||||
node = xmlNewNode (NULL, name);
|
||||
|
||||
if (propname == NULL)
|
||||
xmlNodeSetContent (node, str);
|
||||
else
|
||||
xmlSetProp (node, propname, str);
|
||||
|
||||
g_free (str);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static gint
|
||||
apply_timeout_cb (Preferences *prefs)
|
||||
{
|
||||
preferences_apply_now (prefs);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkColor *
|
||||
read_color_from_string (gchar *string)
|
||||
{
|
||||
GdkColor *color;
|
||||
gint32 rgb;
|
||||
|
||||
color = g_new0 (GdkColor, 1);
|
||||
|
||||
gdk_color_parse (string, color);
|
||||
rgb = ((color->red >> 8) << 16) ||
|
||||
((color->green >> 8) << 8) ||
|
||||
(color->blue >> 8);
|
||||
color->pixel = xlib_rgb_xpixel_from_rgb (rgb);
|
||||
|
||||
return color;
|
||||
}
|
90
capplets/background/preferences.h
Normal file
90
capplets/background/preferences.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* preferences.h
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __PREFERENCES_H
|
||||
#define __PREFERENCES_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <tree.h>
|
||||
|
||||
#define PREFERENCES(obj) GTK_CHECK_CAST (obj, preferences_get_type (), Preferences)
|
||||
#define PREFERENCES_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, preferences_get_type (), PreferencesClass)
|
||||
#define IS_PREFERENCES(obj) GTK_CHECK_TYPE (obj, preferences_get_type ())
|
||||
|
||||
typedef struct _Preferences Preferences;
|
||||
typedef struct _PreferencesClass PreferencesClass;
|
||||
|
||||
typedef enum _orientation_t {
|
||||
ORIENTATION_HORIZ, ORIENTATION_VERT
|
||||
} orientation_t;
|
||||
|
||||
typedef enum _wallpaper_type_t {
|
||||
WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED_ASPECT,
|
||||
WPTYPE_SCALED, WPTYPE_EMBOSSED
|
||||
} wallpaper_type_t;
|
||||
|
||||
struct _Preferences
|
||||
{
|
||||
GtkObject object;
|
||||
|
||||
gboolean frozen;
|
||||
guint timeout_id;
|
||||
|
||||
gboolean enabled;
|
||||
gboolean gradient_enabled;
|
||||
gboolean wallpaper_enabled;
|
||||
orientation_t orientation;
|
||||
wallpaper_type_t wallpaper_type;
|
||||
|
||||
GdkColor *color1;
|
||||
GdkColor *color2;
|
||||
|
||||
gchar *wallpaper_filename;
|
||||
gchar *wallpaper_sel_path;
|
||||
};
|
||||
|
||||
struct _PreferencesClass
|
||||
{
|
||||
GtkObjectClass klass;
|
||||
};
|
||||
|
||||
guint preferences_get_type (void);
|
||||
|
||||
GtkObject *preferences_new (void);
|
||||
GtkObject *preferences_clone (Preferences *prefs);
|
||||
void preferences_destroy (GtkObject *object);
|
||||
|
||||
void preferences_load (Preferences *prefs);
|
||||
void preferences_save (Preferences *prefs);
|
||||
void preferences_changed (Preferences *prefs);
|
||||
void preferences_apply_now (Preferences *prefs);
|
||||
void preferences_apply_preview (Preferences *prefs);
|
||||
|
||||
void preferences_freeze (Preferences *prefs);
|
||||
void preferences_thaw (Preferences *prefs);
|
||||
|
||||
Preferences *preferences_read_xml (xmlDocPtr xml_doc);
|
||||
xmlDocPtr preferences_write_xml (Preferences *prefs);
|
||||
|
||||
#endif /* __PREFERENCES_H */
|
619
capplets/background/prefs-widget.c
Normal file
619
capplets/background/prefs-widget.c
Normal file
|
@ -0,0 +1,619 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* prefs-widget.c
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "prefs-widget.h"
|
||||
#include "applier.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
|
||||
|
||||
#define WID(str) (glade_xml_get_widget (prefs_widget->dialog_data, str))
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_PREFERENCES
|
||||
};
|
||||
|
||||
static CappletWidgetClass *parent_class;
|
||||
|
||||
static void prefs_widget_init (PrefsWidget *prefs_widget);
|
||||
static void prefs_widget_class_init (PrefsWidgetClass *class);
|
||||
|
||||
static void prefs_widget_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void prefs_widget_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
|
||||
static void read_preferences (PrefsWidget *prefs_widget,
|
||||
Preferences *prefs);
|
||||
|
||||
static void color1_select_color_set_cb (GnomeColorPicker *cp,
|
||||
guint r,
|
||||
guint g,
|
||||
guint b,
|
||||
guint a,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void color2_select_color_set_cb (GnomeColorPicker *cp,
|
||||
guint r,
|
||||
guint g,
|
||||
guint b,
|
||||
guint a,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void solid_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void gradient_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void vertical_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void horizontal_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void wallpaper_entry_changed_cb (GtkEntry *e,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void tiled_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void centered_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void scaled_aspect_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
|
||||
static void scaled_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
static void disable_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget);
|
||||
|
||||
static void set_gradient_controls_sensitive (PrefsWidget *prefs_widget,
|
||||
gboolean s);
|
||||
static void set_wallpaper_controls_sensitive (PrefsWidget *prefs_widget,
|
||||
gboolean s);
|
||||
static void set_background_controls_sensitive (PrefsWidget *prefs_widget,
|
||||
gboolean s);
|
||||
|
||||
guint
|
||||
prefs_widget_get_type (void)
|
||||
{
|
||||
static guint prefs_widget_type = 0;
|
||||
|
||||
if (!prefs_widget_type) {
|
||||
GtkTypeInfo prefs_widget_info = {
|
||||
"PrefsWidget",
|
||||
sizeof (PrefsWidget),
|
||||
sizeof (PrefsWidgetClass),
|
||||
(GtkClassInitFunc) prefs_widget_class_init,
|
||||
(GtkObjectInitFunc) prefs_widget_init,
|
||||
(GtkArgSetFunc) NULL,
|
||||
(GtkArgGetFunc) NULL
|
||||
};
|
||||
|
||||
prefs_widget_type =
|
||||
gtk_type_unique (capplet_widget_get_type (),
|
||||
&prefs_widget_info);
|
||||
}
|
||||
|
||||
return prefs_widget_type;
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_widget_init (PrefsWidget *prefs_widget)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
prefs_widget->dialog_data =
|
||||
glade_xml_new (GLADE_DATADIR "/background-properties.glade",
|
||||
"prefs_widget");
|
||||
|
||||
widget = glade_xml_get_widget (prefs_widget->dialog_data,
|
||||
"prefs_widget");
|
||||
gtk_container_add (GTK_CONTAINER (prefs_widget), widget);
|
||||
|
||||
widget = glade_xml_get_widget (prefs_widget->dialog_data,
|
||||
"monitor_frame");
|
||||
prefs_widget->preview = applier_class_get_preview_widget ();
|
||||
gtk_container_add (GTK_CONTAINER (widget), prefs_widget->preview);
|
||||
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"color1_select_color_set_cb",
|
||||
color1_select_color_set_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"color2_select_color_set_cb",
|
||||
color2_select_color_set_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"solid_select_toggled_cb",
|
||||
solid_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"gradient_select_toggled_cb",
|
||||
gradient_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"vertical_select_toggled_cb",
|
||||
vertical_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"horizontal_select_toggled_cb",
|
||||
horizontal_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"wallpaper_entry_changed_cb",
|
||||
wallpaper_entry_changed_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"tiled_select_toggled_cb",
|
||||
tiled_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"centered_select_toggled_cb",
|
||||
centered_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"scaled_aspect_select_toggled_cb",
|
||||
scaled_aspect_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"scaled_select_toggled_cb",
|
||||
scaled_select_toggled_cb,
|
||||
prefs_widget);
|
||||
glade_xml_signal_connect_data (prefs_widget->dialog_data,
|
||||
"disable_toggled_cb",
|
||||
disable_toggled_cb,
|
||||
prefs_widget);
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_widget_class_init (PrefsWidgetClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
gtk_object_add_arg_type ("PrefsWidget::preferences",
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_ARG_READWRITE,
|
||||
ARG_PREFERENCES);
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (class);
|
||||
object_class->set_arg = prefs_widget_set_arg;
|
||||
object_class->get_arg = prefs_widget_get_arg;
|
||||
|
||||
parent_class = CAPPLET_WIDGET_CLASS
|
||||
(gtk_type_class (capplet_widget_get_type ()));
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_widget_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
{
|
||||
PrefsWidget *prefs_widget;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (object));
|
||||
|
||||
prefs_widget = PREFS_WIDGET (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_PREFERENCES:
|
||||
if (prefs_widget->prefs)
|
||||
gtk_object_unref (GTK_OBJECT (prefs_widget->prefs));
|
||||
|
||||
prefs_widget->prefs = GTK_VALUE_POINTER (*arg);
|
||||
|
||||
if (prefs_widget->prefs) {
|
||||
gtk_object_ref (GTK_OBJECT (prefs_widget->prefs));
|
||||
read_preferences (prefs_widget, prefs_widget->prefs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Bad argument set");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_widget_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
{
|
||||
PrefsWidget *prefs_widget;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (object));
|
||||
|
||||
prefs_widget = PREFS_WIDGET (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_PREFERENCES:
|
||||
GTK_VALUE_POINTER (*arg) = prefs_widget->prefs;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Bad argument get");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
prefs_widget_new (Preferences *prefs)
|
||||
{
|
||||
g_return_val_if_fail (prefs == NULL || IS_PREFERENCES (prefs), NULL);
|
||||
|
||||
return gtk_widget_new (prefs_widget_get_type (),
|
||||
"preferences", prefs,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
prefs_widget_set_preferences (PrefsWidget *prefs_widget, Preferences *prefs)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
gtk_object_set (GTK_OBJECT (prefs_widget), "preferences", prefs, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
read_preferences (PrefsWidget *prefs_widget, Preferences *prefs)
|
||||
{
|
||||
GtkWidget *widget, *entry;
|
||||
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
gnome_color_picker_set_i16
|
||||
(GNOME_COLOR_PICKER (WID ("color1_select")),
|
||||
prefs->color1->red, prefs->color1->green,
|
||||
prefs->color1->blue, 0xffff);
|
||||
gnome_color_picker_set_i16
|
||||
(GNOME_COLOR_PICKER (WID ("color2_select")),
|
||||
prefs->color2->red, prefs->color2->green,
|
||||
prefs->color2->blue, 0xffff);
|
||||
|
||||
if (prefs->gradient_enabled)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("gradient_select")),
|
||||
TRUE);
|
||||
else
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("solid_select")),
|
||||
TRUE);
|
||||
|
||||
if (prefs->orientation == ORIENTATION_VERT)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("vertical_select")),
|
||||
TRUE);
|
||||
else if (prefs->orientation == ORIENTATION_HORIZ)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("horizontal_select")),
|
||||
TRUE);
|
||||
|
||||
widget = WID ("wallpaper_entry");
|
||||
|
||||
if (prefs->wallpaper_sel_path)
|
||||
gnome_file_entry_set_default_path
|
||||
(GNOME_FILE_ENTRY (widget),
|
||||
prefs->wallpaper_sel_path);
|
||||
|
||||
if (prefs->wallpaper_filename) {
|
||||
entry = gnome_file_entry_gtk_entry
|
||||
(GNOME_FILE_ENTRY (widget));
|
||||
gtk_entry_set_text (GTK_ENTRY (entry),
|
||||
prefs->wallpaper_filename);
|
||||
}
|
||||
|
||||
switch (prefs->wallpaper_type) {
|
||||
case WPTYPE_TILED:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("tiled_select")),
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
case WPTYPE_CENTERED:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("centered_select")),
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
case WPTYPE_SCALED_ASPECT:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("scaled_aspect_select")),
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
case WPTYPE_SCALED:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("scaled_select")),
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_error ("Bad wallpaper type");
|
||||
break;
|
||||
}
|
||||
|
||||
if (prefs->enabled)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("disable_toggle")),
|
||||
FALSE);
|
||||
else
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(WID ("disable_toggle")),
|
||||
TRUE);
|
||||
|
||||
preferences_apply_preview (prefs);
|
||||
}
|
||||
|
||||
static void
|
||||
color1_select_color_set_cb (GnomeColorPicker *cp, guint r, guint g,
|
||||
guint b, guint a, PrefsWidget *prefs_widget)
|
||||
{
|
||||
guint32 rgb;
|
||||
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
prefs_widget->prefs->color1->red = r;
|
||||
prefs_widget->prefs->color1->green = g;
|
||||
prefs_widget->prefs->color1->blue = b;
|
||||
rgb = ((r >> 8) << 16) || ((g >> 8) << 8) || (b >> 8);
|
||||
prefs_widget->prefs->color1->pixel = xlib_rgb_xpixel_from_rgb (rgb);
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
color2_select_color_set_cb (GnomeColorPicker *cp, guint r, guint g,
|
||||
guint b, guint a, PrefsWidget *prefs_widget)
|
||||
{
|
||||
guint32 rgb;
|
||||
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
prefs_widget->prefs->color2->red = r;
|
||||
prefs_widget->prefs->color2->green = g;
|
||||
prefs_widget->prefs->color2->blue = b;
|
||||
rgb = ((r >> 8) << 16) || ((g >> 8) << 8) || (b >> 8);
|
||||
prefs_widget->prefs->color2->pixel = xlib_rgb_xpixel_from_rgb (rgb);
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
solid_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->gradient_enabled = FALSE;
|
||||
set_gradient_controls_sensitive (prefs_widget, FALSE);
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gradient_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->gradient_enabled = TRUE;
|
||||
set_gradient_controls_sensitive (prefs_widget, TRUE);
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
vertical_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->orientation = ORIENTATION_VERT;
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
horizontal_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->orientation = ORIENTATION_HORIZ;
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
wallpaper_entry_changed_cb (GtkEntry *e, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (prefs_widget->prefs->wallpaper_filename)
|
||||
g_free (prefs_widget->prefs->wallpaper_filename);
|
||||
|
||||
prefs_widget->prefs->wallpaper_filename =
|
||||
gnome_file_entry_get_full_path
|
||||
(GNOME_FILE_ENTRY (WID ("wallpaper_entry")), TRUE);
|
||||
|
||||
if (prefs_widget->prefs->wallpaper_filename &&
|
||||
strlen (prefs_widget->prefs->wallpaper_filename) &&
|
||||
g_strcasecmp (prefs_widget->prefs->wallpaper_filename, "none")) {
|
||||
set_wallpaper_controls_sensitive (prefs_widget, TRUE);
|
||||
prefs_widget->prefs->wallpaper_enabled = TRUE;
|
||||
} else {
|
||||
set_wallpaper_controls_sensitive (prefs_widget, FALSE);
|
||||
prefs_widget->prefs->wallpaper_enabled = FALSE;
|
||||
}
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
tiled_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->wallpaper_type = WPTYPE_TILED;
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
centered_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->wallpaper_type = WPTYPE_CENTERED;
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
scaled_aspect_select_toggled_cb (GtkToggleButton *tb,
|
||||
PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->wallpaper_type = WPTYPE_SCALED_ASPECT;
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
scaled_select_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb)) {
|
||||
prefs_widget->prefs->wallpaper_type = WPTYPE_SCALED;
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
}
|
||||
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
disable_toggled_cb (GtkToggleButton *tb, PrefsWidget *prefs_widget)
|
||||
{
|
||||
g_return_if_fail (prefs_widget != NULL);
|
||||
g_return_if_fail (IS_PREFS_WIDGET (prefs_widget));
|
||||
g_return_if_fail (prefs_widget->prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs_widget->prefs));
|
||||
|
||||
if (gtk_toggle_button_get_active (tb))
|
||||
prefs_widget->prefs->enabled = FALSE;
|
||||
else
|
||||
prefs_widget->prefs->enabled = TRUE;
|
||||
|
||||
set_background_controls_sensitive (prefs_widget,
|
||||
prefs_widget->prefs->enabled);
|
||||
|
||||
preferences_changed (prefs_widget->prefs);
|
||||
capplet_widget_state_changed (CAPPLET_WIDGET (prefs_widget), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
set_gradient_controls_sensitive (PrefsWidget *prefs_widget, gboolean s)
|
||||
{
|
||||
gtk_widget_set_sensitive (WID ("vertical_select"), s);
|
||||
gtk_widget_set_sensitive (WID ("horizontal_select"), s);
|
||||
gtk_widget_set_sensitive (WID ("color2_label"), s);
|
||||
gtk_widget_set_sensitive (WID ("color2_select"), s);
|
||||
}
|
||||
|
||||
static void
|
||||
set_wallpaper_controls_sensitive (PrefsWidget *prefs_widget, gboolean s)
|
||||
{
|
||||
gtk_widget_set_sensitive (WID ("tiled_select"), s);
|
||||
gtk_widget_set_sensitive (WID ("centered_select"), s);
|
||||
gtk_widget_set_sensitive (WID ("scaled_aspect_select"), s);
|
||||
gtk_widget_set_sensitive (WID ("scaled_select"), s);
|
||||
}
|
||||
|
||||
static void
|
||||
set_background_controls_sensitive (PrefsWidget *prefs_widget, gboolean s)
|
||||
{
|
||||
gtk_widget_set_sensitive (WID ("color_frame"), s);
|
||||
gtk_widget_set_sensitive (WID ("wallpaper_frame"), s);
|
||||
}
|
||||
|
61
capplets/background/prefs-widget.h
Normal file
61
capplets/background/prefs-widget.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* prefs-widget.h
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@helixcode.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __PREFS_WIDGET_H
|
||||
#define __PREFS_WIDGET_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
#include <capplet-widget.h>
|
||||
|
||||
#include "preferences.h"
|
||||
|
||||
#define PREFS_WIDGET(obj) GTK_CHECK_CAST (obj, prefs_widget_get_type (), PrefsWidget)
|
||||
#define PREFS_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_get_type (), PrefsWidgetClass)
|
||||
#define IS_PREFS_WIDGET(obj) GTK_CHECK_TYPE (obj, prefs_widget_get_type ())
|
||||
|
||||
typedef struct _PrefsWidget PrefsWidget;
|
||||
typedef struct _PrefsWidgetClass PrefsWidgetClass;
|
||||
|
||||
struct _PrefsWidget
|
||||
{
|
||||
CappletWidget capplet_widget;
|
||||
|
||||
Preferences *prefs;
|
||||
GladeXML *dialog_data;
|
||||
GtkWidget *preview;
|
||||
};
|
||||
|
||||
struct _PrefsWidgetClass
|
||||
{
|
||||
CappletWidgetClass parent_class;
|
||||
};
|
||||
|
||||
guint prefs_widget_get_type (void);
|
||||
|
||||
GtkWidget *prefs_widget_new (Preferences *prefs);
|
||||
|
||||
void prefs_widget_set_preferences (PrefsWidget *prefs_widget,
|
||||
Preferences *prefs);
|
||||
|
||||
#endif /* __PREFS_WIDGET_H */
|
Loading…
Add table
Reference in a new issue