[Xfce4-commits] [panel-plugins/xfce4-stopwatch-plugin] 01/01: Switch to gtk3 and modernize

noreply at xfce.org noreply at xfce.org
Wed Oct 17 10:58:51 CEST 2018


This is an automated email from the git hooks/post-receive script.

n   c   o   p   a       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-stopwatch-plugin.

commit 5df1017ad654329119a66499c8e8b7cd26019707
Author: Natanael Copa <ncopa at alpinelinux.org>
Date:   Tue Oct 16 19:40:15 2018 +0200

    Switch to gtk3 and modernize
    
    - rename configure.in to configure.ac
    - replace libxfcegui4 with libxfce4ui
    - switch to gtk3
    - remove xfce4-vala dependency. We can use the vapi from libxfce4ui,
      libxfce4util and libxfce4panel
    - make the plugin an internal plugin instead of external
---
 configure.in.in => configure.ac.in                |  9 +--
 panel-plugin/Makefile.am                          | 18 ++---
 panel-plugin/stopwatch.vala                       | 80 +++++++++++------------
 panel-plugin/xfce4-stopwatch-plugin.desktop.in.in |  3 +-
 4 files changed, 51 insertions(+), 59 deletions(-)

diff --git a/configure.in.in b/configure.ac.in
similarity index 86%
rename from configure.in.in
rename to configure.ac.in
index f5d2784..153f50c 100644
--- a/configure.in.in
+++ b/configure.ac.in
@@ -36,17 +36,14 @@ AC_PROG_INTLTOOL()
 
 dnl check for required packages
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.6.0])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.6.0])
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.6.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.13.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.13.0])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.13.0])
 
 dnl Check for valac
 valac_minimum_version=0.7.5
 AC_PATH_PROG([VALAC], [valac], [valac])
 AC_SUBST(VALAC)
-if test "x$USE_MAINTAINER_MODE" = "xyes" ; then
-	XDT_CHECK_PACKAGE([XFCE4VALA], [xfce4-vala], [4.6])
-fi
 
 dnl check for i18n support
 XDT_I18N([@LINGUAS@])
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index bcb9e81..ae9a0c0 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -20,7 +20,7 @@ if MAINTAINER_MODE
 BUILT_SOURCES = vala.stamp
 $(stopwatch_VALABUILTSOURCES): vala.stamp
 vala.stamp: $(stopwatch_VALASOURCES)
-	$(VALAC) --vapidir=$(srcdir) --pkg=libxfce4panel-1.0 $^ -C
+	$(VALAC) --vapidir=$(srcdir) --pkg=libxfce4panel-2.0 $^ -C
 	touch $@
 endif
 
@@ -28,21 +28,21 @@ endif
 # Plugin
 #
 
-plugindir = $(libexecdir)/xfce4/panel-plugins
-plugin_PROGRAMS = xfce4-stopwatch-plugin
+plugindir = $(libexecdir)/xfce4/panel/plugins
+plugin_LTLIBRARIES = libstopwatch.la
 
-xfce4_stopwatch_plugin_SOURCES =					\
+libstopwatch_la_SOURCES =					\
 	$(stopwatch_VALABUILTSOURCES)
 
-xfce4_stopwatch_plugin_CFLAGS =						\
+libstopwatch_la_CFLAGS =						\
 	@LIBXFCE4PANEL_CFLAGS@						\
 	@LIBXFCE4UTIL_CFLAGS@						\
-	@LIBXFCEGUI4_CFLAGS@
+	@LIBXFCE4UI_CFLAGS@
 
-xfce4_stopwatch_plugin_LDADD =						\
+libstopwatch_la_LIBADD =						\
 	@LIBXFCE4PANEL_LIBS@						\
 	@LIBXFCE4UTIL_LIBS@						\
-	@LIBXFCEGUI4_LIBS@
+	@LIBXFCE4UI_LIBS@
 
 #
 # Plugin desktop file
@@ -52,7 +52,7 @@ desktop_in_in_files =							\
 	xfce4-stopwatch-plugin.desktop.in.in
 desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
 
-desktopdir = $(datadir)/xfce4/panel-plugins
+desktopdir = $(datadir)/xfce4/panel/plugins
 desktop_DATA = xfce4-stopwatch-plugin.desktop
 @INTLTOOL_DESKTOP_RULE@
 
diff --git a/panel-plugin/stopwatch.vala b/panel-plugin/stopwatch.vala
index 078cf08..f87b617 100644
--- a/panel-plugin/stopwatch.vala
+++ b/panel-plugin/stopwatch.vala
@@ -153,16 +153,16 @@ private class TimerButton : Gtk.ToggleButton {
 
 		this.updateDisplay (this.timer.elapsed);
 
-		this.toggled += (s) => {
+		this.toggled.connect((s) => {
 			if (this.active)
 				this.start ();
 			else
 				this.stop ();
-		};
+		});
 
-		this.timer.changed += (s) => {
+		this.timer.changed.connect((s) => {
 			this.updateDisplay (this.timer.elapsed);
-		};
+		});
 	}
 
 	public void start () {
@@ -181,41 +181,36 @@ private class TimerButton : Gtk.ToggleButton {
 	}
 }
 
-public class StopwatchPlugin : GLib.Object {
+public class StopwatchPlugin : Xfce.PanelPlugin {
 
 	private Timer timer;
 	private TimerButton timerButton;
-	private Xfce.HVBox box;
+	private Gtk.Box box;
 
-	private void save (Xfce.PanelPlugin panel_plugin) {
-		var rc = new Xfce.Rc (panel_plugin.save_location (true), false);
-		var elapsed = timer.elapsed;
-		rc.write_entry ("elapsed_sec",  "%ld".printf (elapsed.tv_sec));
-		rc.write_entry ("elapsed_usec", "%ld".printf (elapsed.tv_usec));
-	}
-
-	private void load (Xfce.PanelPlugin panel_plugin) {
-		var rc = new Xfce.Rc (panel_plugin.lookup_rc_file (), true);
+	private void load_rc () {
+		var rc = new Xfce.Rc (lookup_rc_file (), true);
 		var elapsed = MyTimeVal.zero ();
 		rc.read_entry ("elapsed_sec",  "0").scanf ("%ld", out elapsed.tv_sec);
 		rc.read_entry ("elapsed_usec", "0").scanf ("%ld", out elapsed.tv_usec);
 		timer.elapsed = elapsed;
 	}
 
-	public StopwatchPlugin (Xfce.PanelPlugin panel_plugin) {
+
+
+	public override void @construct() {
 
 		this.timer = new Timer ();
-		this.load (panel_plugin);
+		this.load_rc ();
 
-		var orientation = panel_plugin.get_orientation ();
+		var orientation = this.get_orientation ();
 
-		box = new Xfce.HVBox (orientation, false, 0);
-		panel_plugin.orientation_changed += (s, orientation) => {
+		box = new Gtk.Box (orientation, 0);
+		this.orientation_changed.connect((s, orientation) => {
 			box.set_orientation (orientation);
-		};
+		});
 
 		timerButton = new TimerButton (timer);
-		panel_plugin.add_action_widget (timerButton);
+		this.add_action_widget (timerButton);
 		box.add (timerButton);
 
 		var resetButton = new Gtk.Button ();
@@ -226,34 +221,33 @@ public class StopwatchPlugin : GLib.Object {
 		resetButton.focus_on_click = false;
 		resetButton.set_relief (Gtk.ReliefStyle.NONE);
 
-		var refreshImage = new Gtk.Image.from_stock (Gtk.STOCK_REFRESH,
-		                                             Gtk.IconSize.BUTTON);
+		var refreshImage = new Gtk.Image.from_icon_name ("view-refresh",
+		                                                 Gtk.IconSize.BUTTON);
 		resetButton.set_image (refreshImage);
-		resetButton.clicked += (s) => {
+		resetButton.clicked.connect ((s) => {
+			this.save();
 			timerButton.reset ();
-		};
-		panel_plugin.add_action_widget (resetButton);
+		});
+		add_action_widget (resetButton);
 		box.add (resetButton);
 
-		panel_plugin.add (box);
-		panel_plugin.show_all ();
+		add (box);
+		show_all ();
 
-		panel_plugin.size_changed += (p, size) => {
+		size_changed.connect ((p, size) => {
 			return true;
-		};
-
-		panel_plugin.save += this.save;
-	}
-
-
-	static StopwatchPlugin plugin;
+		});
 
-	public static void register (Xfce.PanelPlugin panel_plugin) {
-		plugin = new StopwatchPlugin (panel_plugin);
+		this.save.connect (() => {
+			var rc = new Xfce.Rc(save_location (true), false);
+			var elapsed = timer.elapsed;
+			rc.write_entry ("elapsed_sec",  "%ld".printf (elapsed.tv_sec));
+			rc.write_entry ("elapsed_usec", "%ld".printf (elapsed.tv_usec));
+		});
 	}
+}
 
-	public static int main (string[] args) {
-		return Xfce.PanelPluginRegisterExternal (ref args,
-		                                         StopwatchPlugin.register);
-	}
+[ModuleInit]
+public Type xfce_panel_module_init (TypeModule module) {
+	return typeof (StopwatchPlugin);
 }
diff --git a/panel-plugin/xfce4-stopwatch-plugin.desktop.in.in b/panel-plugin/xfce4-stopwatch-plugin.desktop.in.in
index 1289432..467f8d1 100644
--- a/panel-plugin/xfce4-stopwatch-plugin.desktop.in.in
+++ b/panel-plugin/xfce4-stopwatch-plugin.desktop.in.in
@@ -3,5 +3,6 @@ Type=X-XFCE-PanelPlugin
 _Name=Stopwatch
 _Comment=Time yourself
 Icon=xfce4-stopwatch-plugin
-X-XFCE-Exec=@EXTERNAL_PLUGIN_PATH@/xfce4-stopwatch-plugin
+X-XFCE-Module=stopwatch
 X-XFCE-Unique=false
+X-XFCE-Internal=TRUE

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list