]> git.llucax.com Git - software/sadba.git/commitdiff
Initial commit v0.1
authorLeandro Lucarella <llucax@gmail.com>
Tue, 10 Jul 2012 11:57:40 +0000 (13:57 +0200)
committerLeandro Lucarella <llucax@gmail.com>
Sun, 15 Jul 2012 18:51:02 +0000 (20:51 +0200)
The status-area-displayblanking-applet is a Maemo status menu applet to
easily change the display blanking mode without having to go through the
settings.

18 files changed:
Makefile [new file with mode: 0644]
data/display-blanking-icon.0.png [new file with mode: 0644]
data/display-blanking-icon.1.png [new file with mode: 0644]
data/display-blanking-icon.2.png [new file with mode: 0644]
data/display-blanking-icon.3.png [new file with mode: 0644]
data/display-blanking-icon.4.png [new file with mode: 0644]
data/status-area-displayblanking-applet.desktop [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/install [new file with mode: 0644]
debian/rules [new file with mode: 0755]
po/Makefile [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
po/es_AR.po [new file with mode: 0644]
po/status-area-displayblanking-applet.pot [new file with mode: 0644]
src/Makefile [new file with mode: 0644]
src/lib-display-blanking-status-menu-widget.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..b6fe518
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+SUBDIRS=src po
+BUILDDIR=build
+
+all: subdirs
+
+subdirs: $(SUBDIRS)
+
+$(SUBDIRS):
+       $(MAKE) -C $@
+
+.PHONY: all clean install $(SUBDIRS)
+
+clean:
+       for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean); done
+
+install:
+       for d in $(SUBDIRS); do (cd $$d; $(MAKE) install); done
+
+
diff --git a/data/display-blanking-icon.0.png b/data/display-blanking-icon.0.png
new file mode 100644 (file)
index 0000000..77c43dc
Binary files /dev/null and b/data/display-blanking-icon.0.png differ
diff --git a/data/display-blanking-icon.1.png b/data/display-blanking-icon.1.png
new file mode 100644 (file)
index 0000000..686e4fc
Binary files /dev/null and b/data/display-blanking-icon.1.png differ
diff --git a/data/display-blanking-icon.2.png b/data/display-blanking-icon.2.png
new file mode 100644 (file)
index 0000000..d9adce4
Binary files /dev/null and b/data/display-blanking-icon.2.png differ
diff --git a/data/display-blanking-icon.3.png b/data/display-blanking-icon.3.png
new file mode 100644 (file)
index 0000000..6850b9a
Binary files /dev/null and b/data/display-blanking-icon.3.png differ
diff --git a/data/display-blanking-icon.4.png b/data/display-blanking-icon.4.png
new file mode 100644 (file)
index 0000000..bd3bc59
Binary files /dev/null and b/data/display-blanking-icon.4.png differ
diff --git a/data/status-area-displayblanking-applet.desktop b/data/status-area-displayblanking-applet.desktop
new file mode 100644 (file)
index 0000000..c9d506c
--- /dev/null
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=Display Blanking
+Comment=Display blanking mode changing applet
+Category=permanent
+Type=default
+X-Path=lib-displayblanking-status-menu.so
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..f0b37f4
--- /dev/null
@@ -0,0 +1,5 @@
+status-area-displayblanking-applet (0.1) unstable; urgency=low
+
+  * Initial release.
+
+ -- Leandro Lucarella <luca@llucax.com.ar>  Tue, 10 Jul 2012 19:52:11 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..2bec831
--- /dev/null
@@ -0,0 +1,13 @@
+Source: status-area-displayblanking-applet
+Section: user/desktop
+Priority: optional
+Maintainer: Leandro Lucarella <luca@llucax.com.ar>
+Build-Depends: debhelper (>= 5), libgtk2.0-dev, libglib2.0-dev, libhildon1-dev, libhildondesktop1-dev, gettext
+
+Package: status-area-displayblanking-applet
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, hildon-desktop (>= 1:2.2.142-11)
+XSBC-Maemo-Display-Name: Display Blanking Applet
+Description: Hildon Status Menu plugin to control the display blanking mode.
+ This status menu applet let you easily change the display blanking mode right
+ from the status menu, without having to go through the settings.
diff --git a/debian/install b/debian/install
new file mode 100644 (file)
index 0000000..5d7fa8c
--- /dev/null
@@ -0,0 +1,7 @@
+data/display-blanking-icon.0.png               usr/share/icons/hicolor/48x48/hildon
+data/display-blanking-icon.1.png               usr/share/icons/hicolor/48x48/hildon
+data/display-blanking-icon.2.png               usr/share/icons/hicolor/48x48/hildon
+data/display-blanking-icon.3.png               usr/share/icons/hicolor/48x48/hildon
+data/display-blanking-icon.4.png               usr/share/icons/hicolor/48x48/hildon
+src/lib-displayblanking-status-menu.so         usr/lib/hildon-desktop
+data/status-area-displayblanking-applet.desktop        usr/share/applications/hildon-status-menu
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..185125a
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/make -f
+# Uncomment this to turn on verbose mode.
+# export DH_VERBOSE=1
+
+build: build-stamp
+
+build-stamp:
+       dh_testdir
+       $(MAKE)
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+       $(MAKE) clean
+       rm -f build-stamp install-stamp
+       # Add here commands to clean up after the build process.
+       dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+       $(MAKE) DESTDIR=$(CURDIR)/debian/status-area-displayblanking-applet install
+
+       touch install-stamp
+
+# Build architecture-independent files here.
+binary-indep: build install
+       dh_testdir
+       dh_testroot
+       dh_install
+       #dh_installdocs
+       #dh_installchangelogs
+       #dh_compress
+       dh_fixperms
+       dh_shlibdeps
+       dh_makeshlibs
+       dh_installdeb
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary-arch:
+
+binary: binary-indep
+.PHONY: build clean binary-arch binary-indep binary install
diff --git a/po/Makefile b/po/Makefile
new file mode 100644 (file)
index 0000000..e2423bf
--- /dev/null
@@ -0,0 +1,76 @@
+
+
+GETTEXT_PACKAGE = status-area-displayblanking-applet
+PACKAGE = status-area-displayblanking-applet
+
+SHELL = /bin/sh
+
+prefix = /usr
+DATADIRNAME = share
+itlocaledir = $(prefix)/$(DATADIRNAME)/locale
+
+INSTALL = install -c
+INSTALL_DATA = ${INSTALL} -m 644
+
+GMSGFMT = msgfmt
+MSGFMT = msgfmt
+XGETTEXT = xgettext
+MSGMERGE = msgmerge
+
+PO_LINGUAS= es_AR
+
+USE_LINGUAS= es_AR
+
+POFILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
+
+DISTFILES = Makefile POTFILES.in $(POFILES)
+EXTRA_DISTFILES = ChangeLog POTFILES.skip Makevars LINGUAS
+
+POTFILES = ../src/lib-display-blanking-status-menu-widget.c
+# This comment gets stripped out
+
+CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done)
+
+.SUFFIXES:
+.SUFFIXES: .po .gmo .mo
+
+.po.mo:
+       $(MSGFMT) -o $@ $<
+
+.po.gmo:
+       file=`echo $* | sed 's,.*/,,'`.gmo \
+         && rm -f $$file && $(GMSGFMT) -o $$file $<
+
+all: compile
+
+compile: $(CATALOGS)
+
+$(GETTEXT_PACKAGE).pot: $(POTFILES)
+       $(XGETTEXT) --package-name=$(PACKAGE) -o $(GETTEXT_PACKAGE).pot $(POTFILES)
+
+install: all
+       @linguas="$(USE_LINGUAS)"; \
+       for lang in $$linguas; do \
+         dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \
+         mkdir -p $$dir; \
+         if test -r $$lang.gmo; then \
+           $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
+           echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \
+         fi; \
+       done
+
+clean:
+       rm -f *.mo *.gmo
+
+update-po:
+       $(MAKE) $(GETTEXT_PACKAGE).pot
+       @linguas="$(USE_LINGUAS)"; \
+       for lang in $$linguas; do \
+         echo "$$lang:"; \
+         if test -r $$lang.po; then \
+           $(MSGMERGE) -U $$lang.po $(GETTEXT_PACKAGE).pot; \
+         else \
+           cp $(GETTEXT_PACKAGE).pot $$lang.po; \
+         fi; \
+       done
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..c4b19e2
--- /dev/null
@@ -0,0 +1 @@
+src/lib-display-blanking-status-menu-widget.c
diff --git a/po/es_AR.po b/po/es_AR.po
new file mode 100644 (file)
index 0000000..2a06e76
--- /dev/null
@@ -0,0 +1,44 @@
+# .pot file for display blanking applet.
+# Copyright (C) 2012
+# This file is distributed under the same license as the status-area-displayblanking-applet package.
+# Leandro Lucarella <luca@llucax.com.ar>, 2012.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: status-area-displayblanking-applet\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-07-10 03:19+0200\n"
+"PO-Revision-Date: 2012-07-10 02:14+0200\n"
+"Last-Translator: Leandro Lucarella <luca@llucax.com.ar>\n"
+"Language-Team: Leandro Lucarella <luca@llucax.com.ar>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:45
+msgid "Enabled"
+msgstr "Activado"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:46
+msgid "Only on battery"
+msgstr "Sólo con batería"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:47
+msgid "Blanking only on battery"
+msgstr "Apagar sólo con batería"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:48
+msgid "Disabled"
+msgstr "Desactivado"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:49
+msgid "Only dimming"
+msgstr "Sólo ahorro de energía"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:95
+msgid "Changed display blanking mode to: %s"
+msgstr "Modo de apagado de pantalla cambiado a: %s"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:117
+msgid "Display blanking mode"
+msgstr "Apagado de pantalla"
diff --git a/po/status-area-displayblanking-applet.pot b/po/status-area-displayblanking-applet.pot
new file mode 100644 (file)
index 0000000..dd6f043
--- /dev/null
@@ -0,0 +1,44 @@
+# .pot file for display blanking applet.
+# Copyright (C) 2012
+# This file is distributed under the same license as the status-area-displayblanking-applet package.
+# Leandro Lucarella <luca@llucax.com.ar>, 2012.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: status-area-displayblanking-applet\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-07-10 03:19+0200\n"
+"PO-Revision-Date: 2012-07-10 02:14+0200\n"
+"Last-Translator: Leandro Lucarella <luca@llucax.com.ar>\n"
+"Language-Team: Leandro Lucarella <luca@llucax.com.ar>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../src/lib-display-blanking-status-menu-widget.c:45
+msgid "Enabled"
+msgstr ""
+
+#: ../src/lib-display-blanking-status-menu-widget.c:46
+msgid "Only on battery"
+msgstr ""
+
+#: ../src/lib-display-blanking-status-menu-widget.c:47
+msgid "Blanking only on battery"
+msgstr ""
+
+#: ../src/lib-display-blanking-status-menu-widget.c:48
+msgid "Disabled"
+msgstr ""
+
+#: ../src/lib-display-blanking-status-menu-widget.c:49
+msgid "Only dimming"
+msgstr ""
+
+#: ../src/lib-display-blanking-status-menu-widget.c:95
+msgid "Changed display blanking mode to: %s"
+msgstr ""
+
+#: ../src/lib-display-blanking-status-menu-widget.c:117
+msgid "Display blanking mode"
+msgstr ""
diff --git a/src/Makefile b/src/Makefile
new file mode 100644 (file)
index 0000000..20c4ad3
--- /dev/null
@@ -0,0 +1,19 @@
+OBJS=lib-display-blanking-status-menu-widget.o
+SOURCES=lib-display-blanking-status-menu-widget.c
+LIB=lib-displayblanking-status-menu.so
+PKG_FLAGS=$(shell pkg-config hildon-1 libhildondesktop-1 --libs --cflags)
+CCFLAGS=-shared
+CC=gcc
+
+all:$(LIB)
+
+$(LIB):$(OBJS)
+       $(CC) $(CCFLAGS) $(PKG_FLAGS) $(OBJS) -o $(LIB)
+
+.c.o:
+       $(CC) $(CCFLAGS) $(PKG_FLAGS) -c $< -o $@
+
+.PHONE: clean all
+
+clean:
+       rm -f $(OBJS) $(LIB)
diff --git a/src/lib-display-blanking-status-menu-widget.c b/src/lib-display-blanking-status-menu-widget.c
new file mode 100644 (file)
index 0000000..1d7227e
--- /dev/null
@@ -0,0 +1,186 @@
+ /***********************************************************************************
+ *  Display blanking status area plugin
+ *  Copyright (C) 2012 Leandro Lucarella
+ *  Based on status-area-orientationlock-applet by Mohammad Abu-Garbeyyeh.
+ *
+ *  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 <stdio.h>
+#include <stdlib.h>
+#include <libintl.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+#include <libhildondesktop/libhildondesktop.h>
+#include <gconf/gconf-client.h>
+
+
+#define TYPE_DISPLAY_BLANKING_STATUS_PLUGIN (display_blanking_status_plugin_get_type ())
+
+#define DISPLAY_BLANKING_STATUS_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+                                    TYPE_DISPLAY_BLANKING_STATUS_PLUGIN, DisplayBlankingStatusPlugin))
+
+#define DISPLAY_BLANKING_STATUS_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), \
+                                TYPE_DISPLAY_BLANKING_STATUS_PLUGIN, DisplayBlankingStatusPluginClass))
+
+#define IS_DISPLAY_BLANKING_STATUS_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+                                                    TYPE_DISPLAY_BLANKING_STATUS_PLUGIN))
+
+#define IS_DISPLAY_BLANKING_STATUS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+                                                    TYPE_DISPLAY_BLANKING_STATUS_PLUGIN))
+
+#define DISPLAY_BLANKING_STATUS_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+                            TYPE_DISPLAY_BLANKING_STATUS_PLUGIN, DisplayBlankingStatusPluginClass))
+
+#define STATUS_AREA_DISPLAY_BLANKING_ICON_SIZE 18
+
+typedef struct _DisplayBlankingStatusPlugin        DisplayBlankingStatusPlugin;
+typedef struct _DisplayBlankingStatusPluginClass   DisplayBlankingStatusPluginClass;
+typedef struct _DisplayBlankingStatusPluginPrivate DisplayBlankingStatusPluginPrivate;
+
+struct _DisplayBlankingStatusPlugin
+{
+    HDStatusMenuItem parent;
+
+    DisplayBlankingStatusPluginPrivate *priv;
+};
+
+struct _DisplayBlankingStatusPluginClass
+{
+    HDStatusMenuItemClass parent;
+};
+
+GType display_blanking_status_plugin_get_type (void);
+
+#define DISPLAY_BLANKING_STATUS_PLUGIN_GET_PRIVATE(obj) \
+        (G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+                TYPE_DISPLAY_BLANKING_STATUS_PLUGIN, \
+                DisplayBlankingStatusPluginPrivate))
+
+#define GCONF_KEY_DISPLAY_BLANKING "/system/osso/dsm/display/inhibit_blank_mode"
+
+// Shoud contain one, and only one "%d"
+#define DISPLAY_BLANKING_ICON_TEMPLATE "display-blanking-icon.%d"
+
+#define GETTEXT_DOM "status-area-displayblanking-applet"
+#define gettext_noop(str) (str)
+
+#define DISPLAY_BLANKING_MODES 5
+static const char *_DisplayBlankingDescription[DISPLAY_BLANKING_MODES] =
+{
+    gettext_noop ("Both enabled"),
+    gettext_noop ("Both only on battery"),
+    gettext_noop ("Blanking only on battery"),
+    gettext_noop ("Both disabled"),
+    gettext_noop ("Only dimming")
+};
+
+struct _DisplayBlankingStatusPluginPrivate
+{
+    GtkWidget *button;
+    GConfClient *gconf_client;
+    gpointer data;
+};
+
+HD_DEFINE_PLUGIN_MODULE (DisplayBlankingStatusPlugin,
+        display_blanking_status_plugin, HD_TYPE_STATUS_MENU_ITEM);
+
+static void
+display_blanking_status_plugin_class_finalize (
+        DisplayBlankingStatusPluginClass *klass)
+{
+}
+
+static void
+display_blanking_status_plugin_class_init (DisplayBlankingStatusPluginClass *c)
+{
+    g_type_class_add_private (c, sizeof (DisplayBlankingStatusPluginPrivate));
+}
+
+static void
+display_blanking_status_plugin_mode_set (DisplayBlankingStatusPluginPrivate *priv,
+        gboolean update)
+{
+    // Should be enough if DISPLAY_BLANKING_MODES stays in 1 digit, "%d"
+    // provides space for that digit and '\0'
+    static char icon_name[sizeof (DISPLAY_BLANKING_ICON_TEMPLATE)];
+
+    // Get the mode to set
+    gint mode = gconf_client_get_int (priv->gconf_client,
+            GCONF_KEY_DISPLAY_BLANKING, NULL);
+    if (update)
+        mode = (mode + 1) % DISPLAY_BLANKING_MODES;
+
+    // Toggle display blanking
+    gconf_client_set_int (priv->gconf_client, GCONF_KEY_DISPLAY_BLANKING,
+            mode, NULL);
+
+    // Update button text and status bar icon
+    hildon_button_set_value (HILDON_BUTTON (priv->button),
+            dgettext (GETTEXT_DOM, _DisplayBlankingDescription[mode]));
+    int r = snprintf (icon_name, sizeof (icon_name),
+            DISPLAY_BLANKING_ICON_TEMPLATE, mode);
+    g_assert(r < sizeof (icon_name)); // otherwise it was truncated
+    GtkWidget *icon = gtk_image_new_from_icon_name (icon_name,
+            GTK_ICON_SIZE_DIALOG);
+    hildon_button_set_image (HILDON_BUTTON (priv->button), icon);
+
+    // Show a notification banner (only if updating)
+    if (update) {
+        GtkWidget *banner = hildon_banner_show_informationf (priv->button, NULL,
+                dgettext (GETTEXT_DOM, "Changed display blanking mode to: %s"),
+                _DisplayBlankingDescription[mode]);
+        hildon_banner_set_timeout (HILDON_BANNER (banner), 5000);
+    }
+}
+
+static void
+display_blanking_status_plugin_on_button_clicked (GtkWidget *button,
+        DisplayBlankingStatusPlugin *plugin)
+{
+    display_blanking_status_plugin_mode_set (
+            DISPLAY_BLANKING_STATUS_PLUGIN_GET_PRIVATE (plugin), TRUE);
+}
+
+static void
+display_blanking_status_plugin_init (DisplayBlankingStatusPlugin *plugin)
+{
+    plugin->priv = DISPLAY_BLANKING_STATUS_PLUGIN_GET_PRIVATE (plugin);
+
+    plugin->priv->gconf_client = gconf_client_get_default();
+    g_assert(GCONF_IS_CLIENT(plugin->priv->gconf_client));
+
+    plugin->priv->button = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT |
+                HILDON_SIZE_AUTO_WIDTH, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+    gtk_button_set_alignment (GTK_BUTTON (plugin->priv->button), 0, 0);
+    hildon_button_set_style (HILDON_BUTTON (plugin->priv->button),
+            HILDON_BUTTON_STYLE_PICKER);
+    hildon_button_set_title (HILDON_BUTTON (plugin->priv->button),
+            dgettext (GETTEXT_DOM, "Display blanking mode"));
+
+    display_blanking_status_plugin_mode_set (plugin->priv, FALSE);
+
+    g_signal_connect (plugin->priv->button, "clicked",
+            G_CALLBACK (display_blanking_status_plugin_on_button_clicked),
+            plugin);
+
+    gtk_container_add (GTK_CONTAINER (plugin), plugin->priv->button);
+
+    gtk_widget_show_all (plugin->priv->button);
+
+    gtk_widget_show (GTK_WIDGET (plugin));
+}
+