[f-spot/FSPOT_0_6_0_STABLE] add a Tool extension to configure the screensaver
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [f-spot/FSPOT_0_6_0_STABLE] add a Tool extension to configure the screensaver
- Date: Fri, 21 Aug 2009 14:13:16 +0000 (UTC)
commit 09880ebbdb0f30e898c82a25e1b7af4369825c15
Author: Stephane Delcroix <stephane delcroix org>
Date: Fri Aug 21 15:30:21 2009 +0200
add a Tool extension to configure the screensaver
configure.ac | 1 +
extensions/Tools/Makefile.am | 1 +
extensions/Tools/ScreensaverConfig/Makefile.am | 54 +++++++
.../ScreensaverConfig/ScreensaverConfig.addin.xml | 16 ++
.../Tools/ScreensaverConfig/ScreensaverConfig.cs | 131 +++++++++++++++++
.../ScreensaverConfig/ScreensaverConfigDialog.ui | 153 ++++++++++++++++++++
6 files changed, 356 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0c14654..c2e9a08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -342,6 +342,7 @@ extensions/Tools/ChangePhotoPath/Makefile
extensions/Tools/HashJob/Makefile
extensions/Tools/DevelopInUFraw/Makefile
extensions/Tools/MergeDb/Makefile
+extensions/Tools/ScreensaverConfig/Makefile
extensions/Transitions/Makefile
extensions/Transitions/CoverTransition/Makefile
tests/Makefile
diff --git a/extensions/Tools/Makefile.am b/extensions/Tools/Makefile.am
index 6eeba59..0bf4399 100644
--- a/extensions/Tools/Makefile.am
+++ b/extensions/Tools/Makefile.am
@@ -3,4 +3,5 @@ SUBDIRS = \
DevelopInUFraw \
HashJob \
RawPlusJpeg \
+ ScreensaverConfig \
MergeDb
diff --git a/extensions/Tools/ScreensaverConfig/Makefile.am b/extensions/Tools/ScreensaverConfig/Makefile.am
new file mode 100644
index 0000000..f0044cd
--- /dev/null
+++ b/extensions/Tools/ScreensaverConfig/Makefile.am
@@ -0,0 +1,54 @@
+include $(top_srcdir)/Makefile.include
+
+PLUGIN_NAME = ScreensaverConfig
+
+PLUGIN_MANIFEST = $(PLUGIN_NAME).addin.xml
+
+PLUGIN_ASSEMBLY = $(PLUGIN_NAME).dll
+
+PLUGIN_SOURCES = \
+ $(srcdir)/ScreensaverConfig.cs
+
+REFS = \
+ -r:Mono.Posix \
+ -r:$(top_builddir)/src/f-spot.exe \
+ -r:$(top_builddir)/src/FSpot.Core.dll \
+ -r:$(top_builddir)/src/FSpot.Widgets.dll \
+ -r:$(top_builddir)/src/FSpot.Utils.dll \
+ -r:$(top_builddir)/src/FSpot.Query.dll \
+ $(LINK_GTKSHARPBEANS) \
+ $(LINK_GIOSHARP) \
+ $(LINK_SEMWEB) \
+ $(LINK_MONO_ADDINS) \
+ $(LINK_DBUS) \
+ $(LINK_GPHOTO2)
+
+PKGS = \
+ -pkg:gtk-sharp-2.0
+
+RESOURCES = \
+ -resource:$(srcdir)/ScreensaverConfigDialog.ui \
+ -resource:$(srcdir)/$(PLUGIN_MANIFEST)
+
+all: $(PLUGIN_ASSEMBLY)
+
+mpack: $(PLUGIN_ASSEMBLY)
+ mautil p $(PLUGIN_ASSEMBLY)
+
+$(PLUGIN_ASSEMBLY): $(PLUGIN_SOURCES) $(PLUGIN_MANIFEST)
+ $(CSC_LIB) -out:$@ $(PLUGIN_SOURCES) $(REFS) $(PKGS) $(ASSEMBLIES) $(RESOURCES)
+
+plugindir = $(pkglibdir)/extensions
+
+plugin_DATA = \
+ $(PLUGIN_ASSEMBLY)
+
+EXTRA_DIST = \
+ $(PLUGIN_SOURCES) \
+ $(srcdir)/ScreensaverConfigDialog.ui \
+ $(PLUGIN_MANIFEST)
+
+CLEANFILES = \
+ $(PLUGIN_ASSEMBLY) \
+ $(PLUGIN_ASSEMBLY).mdb \
+ *.mpack
diff --git a/extensions/Tools/ScreensaverConfig/ScreensaverConfig.addin.xml b/extensions/Tools/ScreensaverConfig/ScreensaverConfig.addin.xml
new file mode 100644
index 0000000..ab78012
--- /dev/null
+++ b/extensions/Tools/ScreensaverConfig/ScreensaverConfig.addin.xml
@@ -0,0 +1,16 @@
+<Addin namespace="FSpot"
+ id="ScreensaverConfig"
+ name="Screensaver Configuration"
+ version="0.6"
+ description="Screensaver options"
+ author="Stephane Delcroix"
+ url="http://f-spot.org/Extensions"
+ category="Tools"
+ defaultEnabled="true">
+ <Dependencies>
+ <Addin id="Core" version="0.6"/>
+ </Dependencies>
+ <Extension path = "/FSpot/Menus/Tools">
+ <Command id = "ScreensaverConfig" _label = "Configure Screensaver" command_type = "ScreensaverConfig.ScreensaverConfig" />
+ </Extension>
+</Addin>
diff --git a/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs b/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs
new file mode 100644
index 0000000..969fbfa
--- /dev/null
+++ b/extensions/Tools/ScreensaverConfig/ScreensaverConfig.cs
@@ -0,0 +1,131 @@
+//
+// ScreensaverConfig.ScreensaverConfig.cs
+//
+// Author(s):
+// Stephane Delcroix <stephane delcroix org>
+//
+// Copyright (c) 2009 Novell, Inc.
+//
+// This is open source software. See COPYING for details.
+//
+
+using System;
+using System.Reflection;
+
+using Gtk;
+
+using FSpot;
+using FSpot.UI.Dialog;
+using FSpot.Extensions;
+using FSpot.Widgets;
+
+namespace ScreensaverConfig
+{
+ public class ScreensaverConfig : ICommand
+ {
+ const string SaverCommand = "screensavers-f-spot-screensaver";
+ const string SaverMode = "single";
+ const string GNOME_SCREENSAVER_THEME = "/apps/gnome-screensaver/themes";
+ const string GNOME_SCREENSAVER_MODE = "/apps/gnome-screensaver/mode";
+ const string SCREENSAVER = "screensaver/";
+ const string SCREENSAVER_TAG = Preferences.APP_FSPOT + SCREENSAVER + "tag_id";
+ const string SCREENSAVER_DELAY = Preferences.APP_FSPOT + SCREENSAVER + "delay";
+ const double default_delay = 2.0;
+
+ public void Run (object o, EventArgs e)
+ {
+ var d = new ScreensaverConfigDialog ();
+ d.Run ();
+ d.Destroy ();
+ }
+
+ class ScreensaverConfigDialog : BuilderDialog
+ {
+ [GtkBeans.Builder.Object] Range delay_scale;
+ [GtkBeans.Builder.Object] Table table;
+ [GtkBeans.Builder.Object] RadioButton all_radio;
+ [GtkBeans.Builder.Object] RadioButton tagged_radio;
+ [GtkBeans.Builder.Object] Button do_button;
+ Adjustment delay_adjustment;
+ MenuButton tag_button;
+
+ public ScreensaverConfigDialog () : base (Assembly.GetExecutingAssembly (), "ScreensaverConfigDialog.ui", "screensaver-config-dialog")
+ {
+ delay_adjustment = new Adjustment (default_delay, 1.0, 20.0, .5, 5, 0);
+ LoadPreference (SCREENSAVER_DELAY);
+ delay_scale.Adjustment = delay_adjustment;
+ delay_adjustment.ValueChanged += HandleDelayChanged;
+
+ tag_button = new MenuButton ();
+ tag_button.SizeRequested += delegate (object sender, SizeRequestedArgs args) {
+ var req = args.Requisition;
+ req.Width += 100;
+ args.Requisition = req;
+ };
+ TagMenu menu = new TagMenu (null, MainWindow.Toplevel.Database.Tags);
+ menu.Populate (false);
+ menu.TagSelected += HandleTagSelected;
+ tag_button.Menu = menu;
+ tag_button.ShowAll ();
+ table.Attach (tag_button, 2, 3, 1, 2);
+ LoadPreference (SCREENSAVER_TAG);
+ all_radio.Toggled += HandleTagRadioToggled;
+
+ do_button.Clicked += HandleUseFSpot;
+ }
+
+ void LoadPreference (string key)
+ {
+ switch (key) {
+ case SCREENSAVER_DELAY:
+ var delay = Preferences.Get<double> (key);
+ if (delay == 0.0)
+ delay = default_delay;
+ if (delay < delay_adjustment.Lower)
+ delay = delay_adjustment.Lower;
+ if (delay > delay_adjustment.Upper)
+ delay = delay_adjustment.Upper;
+ delay_adjustment.Value = delay;
+ break;
+ case SCREENSAVER_TAG:
+ var screensaver_tag = Preferences.Get<int> (key);
+ Tag t = MainWindow.Toplevel.Database.Tags.GetTagById (screensaver_tag);
+ if (screensaver_tag == 0 || t == null) {
+ all_radio.Active = true;
+ tag_button.Sensitive = false;
+ } else {
+ tagged_radio.Active = true;
+ tag_button.Label = t.Name;
+ }
+ break;
+ }
+ }
+
+ void HandleDelayChanged (object sender, EventArgs e)
+ {
+ Preferences.Set (SCREENSAVER_DELAY, delay_adjustment.Value);
+ }
+
+ void HandleTagRadioToggled (object sender, EventArgs e)
+ {
+ tag_button.Sensitive = tagged_radio.Active;
+ if (all_radio.Active)
+ Preferences.Set (SCREENSAVER_TAG, 0);
+ else
+ HandleTagSelected (((tag_button.Menu as Menu).Active as TagMenu.TagMenuItem).Value);
+ }
+
+ void HandleTagSelected (Tag t)
+ {
+ tag_button.Label = t.Name;
+ Preferences.Set (SCREENSAVER_TAG, (int) t.Id);
+ }
+
+ void HandleUseFSpot (object sender, EventArgs e)
+ {
+ Preferences.Set (GNOME_SCREENSAVER_MODE, SaverMode);
+ Preferences.Set (GNOME_SCREENSAVER_THEME, new string [] { SaverCommand });
+ }
+ }
+ }
+}
diff --git a/extensions/Tools/ScreensaverConfig/ScreensaverConfigDialog.ui b/extensions/Tools/ScreensaverConfig/ScreensaverConfigDialog.ui
new file mode 100644
index 0000000..0f8d0e8
--- /dev/null
+++ b/extensions/Tools/ScreensaverConfig/ScreensaverConfigDialog.ui
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.14"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkDialog" id="screensaver-config-dialog">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Screensaver Configuration</property>
+ <property name="resizable">False</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <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="GtkTable" id="table">
+ <property name="visible">True</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">3</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Display:</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="all_radio">
+ <property name="label" translatable="yes">All Images</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="tagged_radio">
+ <property name="label" translatable="yes">Images tagged with:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">all_radio</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>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHScale" id="delay_scale">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="value_pos">left</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Delay:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="do_button">
+ <property name="label" translatable="yes">Make F-Spot my screensaver</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_padding">6</property>
+ <property name="y_padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <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="button1">
+ <property name="label" translatable="yes">gtk-close</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>
+ </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="0">button1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]