Version bump (0.2-2) v0.2-2
authorRoman Moravcik <roman.moravcik@gmail.com>
Wed, 13 Oct 2010 14:57:28 +0000 (16:57 +0200)
committerRoman Moravcik <roman.moravcik@gmail.com>
Wed, 13 Oct 2010 14:57:28 +0000 (16:57 +0200)
20 files changed:
Makefile.am
TODO [deleted file]
configure.ac
data/Makefile.am [new file with mode: 0644]
data/cl-launcher.desktop [new file with mode: 0644]
debian/changelog
debian/cl-launcher.dirs
debian/cl-launcher.links
debian/cl-launcher.postinst
debian/cl-launcher.postrm
debian/cl-launcher.xsession
debian/control
debian/rules
po/POTFILES.in
po/sk.po
src/Makefile.am
src/cl-cpapplet.c [new file with mode: 0644]
src/cl-launcher.c
src/cl-utils.c
src/cl-utils.h

index f02b113..f59c90c 100644 (file)
@@ -17,4 +17,4 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-SUBDIRS = po src
+SUBDIRS = data po src
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index 64dfc4a..0000000
--- a/TODO
+++ /dev/null
@@ -1,4 +0,0 @@
-- running
-- problem of gconfs
-- not working shuter key
-- check of running applications
\ No newline at end of file
index d3f2a56..1a126e5 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT([cl-launcher], [0.1], [], [cl-launcher])
+AC_INIT([cl-launcher], [0.2], [], [cl-launcher])
 AC_PREREQ([2.58])
 
 AC_CONFIG_SRCDIR([src/cl-launcher.c])
@@ -25,7 +25,16 @@ PKG_CHECK_MODULES([HILDON], [libosso gtk+-2.0 hildon-1 hal gconf-2.0 >= 2.6.2])
 AC_SUBST([HILDON_CFLAGS])
 AC_SUBST([HILDON_LIBS])
 
+PKG_CHECK_MODULES([HILDON_CPA], [hildon-control-panel])
+CPA_PLUGINDIR=`pkg-config hildon-control-panel --variable=pluginlibdir`
+CPA_DESKTOPDIR=`pkg-config hildon-control-panel --variable=plugindesktopentrydir`
+AC_SUBST([HILDON_CPA_CFLAGS])
+AC_SUBST([HILDON_CPA_LIBS])
+AC_SUBST([CPA_DESKTOPDIR])
+AC_SUBST([CPA_PLUGINDIR])
+
 AC_CONFIG_FILES([Makefile]
+   [data/Makefile]
    [src/Makefile]
    [po/Makefile.in])
 AC_OUTPUT()
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644 (file)
index 0000000..c7a8262
--- /dev/null
@@ -0,0 +1,22 @@
+#
+#  Camera launcher for Maemo.
+#  Copyright (C) 2010 Roman Moravcik
+#
+#  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
+#
+
+desktop_DATA = cl-launcher.desktop
+desktopdir = $(CPA_DESKTOPDIR)
+EXTRA_DIST = $(desktop_DATA)
diff --git a/data/cl-launcher.desktop b/data/cl-launcher.desktop
new file mode 100644 (file)
index 0000000..1b72728
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=Camera Lens Launcher
+Comment=Control panel to configure cl-launcher
+Type=HildonControlPanelPlugin
+Icon=tasklaunch_camera
+X-Icon-path=/usr/share/pixmaps/
+X-control-panel-plugin=libcl-launcher.so
+X-Text-Domain=cl-launcher
+Categories=extras
index 1b47425..5ce477a 100644 (file)
@@ -1,3 +1,19 @@
+cl-launcher (0.2-2) fremantle; urgency=low
+
+  * Fixed copyright years.
+  * Added hildon-control-panel-dev to package dependancies.
+  * Fixed type in /etc/X11/Xsession.post/22cl-launcher script.
+  * Added optification of package.
+  * Fixed installion/upgrade of package if camera-ui is not running.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Fri, 10 Sep 2010 09:15:26 +0200
+
+cl-launcher (0.2-1) fremantle; urgency=low
+
+  * Added control panel applet.
+
+ -- Roman Moravcik <roman.moravcik@gmail.com>  Thu,  9 Sep 2010 20:48:54 +0200
+
 cl-launcher (0.1-0) fremantle; urgency=low
 
   * Initial release.
index 8af425c..535584f 100644 (file)
@@ -1,2 +1 @@
-usr/share/applications/cl-launcher
 etc/X11/Xsession.post
\ No newline at end of file
index 347b088..7accf75 100644 (file)
@@ -1,2 +1 @@
 usr/bin/maemo-invoker usr/bin/cl-launcher
-usr/share/applications/hildon/camera-ui.desktop usr/share/applications/cl-launcher/camera-ui.desktop
index 40ba6a1..55753d1 100755 (executable)
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-set -e
-
 if [ -f /etc/X11/Xsession.post/22camera-ui ]; then
        mv /etc/X11/Xsession.post/22camera-ui /etc/X11/Xsession.post/22camera-ui.removed
 fi
index 2780991..7ab0f1e 100755 (executable)
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-set -e
-
 if [ -f /etc/X11/Xsession.post/22camera-ui.removed ]; then
        mv /etc/X11/Xsession.post/22camera-ui.removed /etc/X11/Xsession.post/22camera-ui
 fi
index 617626c..3ceb8e0 100644 (file)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-/usr/sbin/dsmetool -t /usr/bin/camera-launcher
\ No newline at end of file
+/usr/sbin/dsmetool -t /usr/bin/cl-launcher
\ No newline at end of file
index fea5482..e3c2af2 100644 (file)
@@ -2,8 +2,7 @@ Source: cl-launcher
 Section: user/desktop
 Priority: optional
 Maintainer: Roman Moravcik <roman.moravcik@gmail.com>
-Build-Depends: cdbs (>= 0.4.48), libosso-dev, libgtk2.0-dev, libhildon1-dev, libhal-dev (>= 0.5.10), libgconf2-dev
-#Build-Depends: cdbs (>= 0.4.48), libosso-dev, libgtk2.0-dev, libhildon1-dev, libhal-dev (>= 0.5.10), libgconf2-dev, maemo-optify
+Build-Depends: cdbs (>= 0.4.48), libosso-dev, libgtk2.0-dev, libhildon1-dev, libhal-dev (>= 0.5.10), libgconf2-dev, hildon-control-panel-dev, maemo-optify
 Standards-Version: 3.7.2
 
 Package: cl-launcher
@@ -13,7 +12,7 @@ Depends: ${shlibs:Depends}
 XB-Description: Camera's lens cover launcher
  .
  WARNING: Startup of 'Camera' application should be slower using this launcher.
-XB-Maemo-Display-Name: Camera Launcher
+XB-Maemo-Display-Name: Camera Lens Launcher
 XB-Maemo-Icon-26:
  iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0
  d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA6ZJREFUeNrsmUtLW0EUx8/N
index 7fbc0b1..8d3d07d 100755 (executable)
@@ -24,7 +24,7 @@ configure-stamp:
        dh_testdir
 
        ./autogen.sh
-       ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
+       ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --disable-static
 
        touch $@
 
@@ -71,7 +71,7 @@ binary-arch: build install
        dh_installdeb
        dh_shlibdeps
        dh_gencontrol
-#      maemo-optify
+       maemo-optify
        dh_md5sums
        dh_builddeb
 
index afe5234..8838576 100644 (file)
@@ -1,3 +1,6 @@
 # List of source files containing translatable strings.
 
-src/cl_launcher.c
+src/cl-cpapplet.c
+src/cl-launcher.c
+src/cl-utils.c
+src/cl-utils.h
index 5049060..166bac7 100644 (file)
--- a/po/sk.po
+++ b/po/sk.po
@@ -8,44 +8,47 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-03-16 13:55+0100\n"
-"PO-Revision-Date: 2010-03-16 13:56+0100\n"
+"POT-Creation-Date: 2010-09-09 16:45+0200\n"
+"PO-Revision-Date: 2010-04-02 19:06+0200\n"
 "Last-Translator: Roman Moravčík <roman.moravcik@gmail.com>\n"
-"Language-Team: sk_SK <>\n"
+"Language-Team: Slovak <sk-i18n@lists.linux.sk>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2\n"
 
-#: ../src/birthday.c:189
-msgid "No search results"
-msgstr "Žiadne výsledky hľadania"
-
-#: ../src/birthday.c:433
-#, c-format
-msgid "next birthday in %d day"
-msgid_plural "next birthday in %d days"
-msgstr[0] "nasledujúce narodeniny za %d deň"
-msgstr[1] "nasledujúce narodeniny za %d dní"
-msgstr[2] "nasledujúce narodeniny za %d dní"
-
-#: ../src/birthday.c:517
-msgid "Name"
-msgstr "Meno"
-
-#: ../src/birthday.c:523
-msgid "Date"
-msgstr "Dátum"
-
-#: ../src/birthday.c:530
-msgid "Search"
-msgstr "Hľadať"
-
-#: ../src/birthday.c:552
-msgid "Birthday"
-msgstr "Narodeniny"
-
-#. no_search_result label
-#: ../src/birthday.c:572
-msgid "No contacts with birthday"
-msgstr "Žiadne kontakty s nastavenými narodeninami"
+#: ../src/cl-cpapplet.c:45
+msgid "Automatically run prefered application"
+msgstr "Automatické spustenie predvolenej aplikácie"
+
+#: ../src/cl-cpapplet.c:46
+msgid "Show application selector pop-up window"
+msgstr "Zobrazenie pop-up okna výberu aplikácie"
+
+#: ../src/cl-cpapplet.c:47
+msgid "Do nothing"
+msgstr "Nič"
+
+#: ../src/cl-cpapplet.c:205
+msgid "Opening of lens cover will"
+msgstr "Otvorenie krytu kamery spôsobí"
+
+#: ../src/cl-cpapplet.c:237
+msgid "Prefered application"
+msgstr "Predvolená aplikácia"
+
+#: ../src/cl-cpapplet.c:286
+msgid "Application selector pop-up window"
+msgstr "Pop-up okno výberu aplikácie"
+
+#: ../src/cl-cpapplet.c:485
+msgid "Camera Lens Launcher"
+msgstr "Spúšťač krytu kamery"
+
+#: ../src/cl-launcher.c:158
+msgid "Select application"
+msgstr "Zvoľte aplikáciu"
+
+#: ../src/cl-launcher.c:207
+msgid "No applications"
+msgstr "Žiadne aplikácie"
index 1ed27ae..f1deb6d 100644 (file)
@@ -28,4 +28,15 @@ localedir = $(datadir)/locale
 
 INCLUDES = @HILDON_CFLAGS@ -I$(top_builddir)
 
-DEFS=-DLOCALEDIR=\"$(localedir)\" @DEFS@
\ No newline at end of file
+lib_LTLIBRARIES = libcl-launcher.la
+libcl_launcher_la_SOURCES = \
+                           cl-cpapplet.c \
+                           cl-utils.c \
+                           cl-utils.h
+libcl_launcher_la_LIBADD = @HILDON_LIBS@ @HILDON_CPA_LIBS@
+libcl_launcher_la_CPPFLAGS = @HILDON_CFLAGS@ @HILDON_CPA_CFLAGS@
+libcl_launcher_la_LDFLAGS = module -avoid-version
+
+libdir = $(CPA_PLUGINDIR)
+
+DEFS=-DLOCALEDIR=\"$(localedir)\" @DEFS@
diff --git a/src/cl-cpapplet.c b/src/cl-cpapplet.c
new file mode 100644 (file)
index 0000000..6fc9c44
--- /dev/null
@@ -0,0 +1,528 @@
+/*
+ *  Camera Launcher for Maemo.
+ *  Copyright (C) 2010 Roman Moravcik
+ *
+ *  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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+#include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
+
+#include <gconf/gconf-client.h>
+
+#include "cl-utils.h"
+
+#define _HL(str) dgettext("hildon-libs",str)
+
+typedef struct {
+       int index;
+       const char *text;
+} Action;
+
+static Action actions[] = {
+       {CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION,   N_("Automatically run prefered application")},
+       {CL_LAUNCHER_ACTION_SHOW_SELECTOR_POPUP,        N_("Show application selector pop-up window")},
+       {CL_LAUNCHER_ACTION_DO_NOTHING,                 N_("Do nothing")}
+};
+
+typedef struct _CLLauncherAppletData CLLauncherAppletData;
+struct _CLLauncherAppletData {
+       GtkWidget *action;
+       GtkWidget *prefered_application;
+       GtkWidget *application_list;
+
+
+       GConfClient *gconf_client;
+};
+
+static gboolean
+gconf_get_bool (GConfClient *client,
+               const gchar *key)
+{
+       gboolean value = FALSE;
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       value = gconf_client_get_bool (client, tmp, NULL);
+
+       if (tmp)
+               g_free (tmp);
+
+       return value;
+}
+
+static void
+gconf_set_bool (GConfClient *client,
+               const gchar *key,
+               gboolean value)
+{
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       gconf_client_set_bool (client, tmp, value, NULL);
+
+       if (tmp)
+               g_free (tmp);
+}
+
+static gint
+gconf_get_int (GConfClient *client,
+               const gchar *key)
+{
+       gint value = 0;
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       value = gconf_client_get_int (client, tmp, NULL);
+
+       if (tmp)
+               g_free (tmp);
+
+       return value;
+}
+
+static void
+gconf_set_int (GConfClient *client,
+               const gchar *key,
+               gint value)
+{
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       gconf_client_set_int (client, tmp, value, NULL);
+
+       if (tmp)
+               g_free (tmp);
+}
+
+static gchar *
+gconf_get_string (GConfClient *client,
+                 gchar *key)
+{
+       gchar *value = NULL;
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       value = gconf_client_get_string (client, tmp, NULL);
+
+       if (tmp)
+               g_free (tmp);
+
+       return value;
+}
+
+static void
+gconf_set_string (GConfClient *client,
+               gchar *key,
+               const gchar *value)
+{
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       if (value)
+               gconf_client_set_string (client, tmp, value, NULL);
+       else
+               gconf_client_unset (client, tmp, NULL);
+
+       if (tmp)
+               g_free (tmp);
+}
+
+static GSList *
+gconf_get_string_list (GConfClient *client,
+                 gchar *key)
+{
+       GSList *value = NULL;
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       value = gconf_client_get_list (client, tmp, GCONF_VALUE_STRING, NULL);
+
+       if (tmp)
+               g_free (tmp);
+
+       return value;
+}
+
+static void
+gconf_set_string_list (GConfClient *client,
+               gchar *key,
+               GSList *value)
+{
+       gchar *tmp = NULL;
+
+       tmp = g_strdup_printf ("%s/%s", GCONF_CL_LAUNCHER, key);
+
+       if (value)
+               gconf_client_set_list (client, tmp, GCONF_VALUE_STRING, value, NULL);
+       else
+               gconf_client_unset (client, tmp, NULL);
+
+       if (tmp)
+               g_free (tmp);
+}
+
+static GtkWidget *
+create_action_selector (CLLauncherAppletData *data)
+{
+       GtkWidget *button, *selector;
+       CLLauncherAction action;
+       gint index = 0;
+
+       g_return_val_if_fail (data, NULL);
+
+       button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT,
+                                          HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+       hildon_button_set_title (HILDON_BUTTON (button), _("Opening of lens cover will"));
+       hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
+       hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
+       hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+
+       selector = hildon_touch_selector_new_text ();
+       while (index < CL_LAUNCHER_ACTION_LAST) {
+               hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector),
+                                                  actions[index].index,
+                                                  _(actions[index].text));
+               index++;
+       }
+
+       hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                          HILDON_TOUCH_SELECTOR (selector));
+
+       return button;
+}
+
+static GtkWidget *
+create_prefered_application_selector (CLLauncherAppletData *data)
+{
+       GtkWidget *button, *selector;
+       GtkCellRenderer *renderer;
+       HildonTouchSelectorColumn *column;
+       GtkListStore *application_list;
+       gint index = 0;
+
+       g_return_val_if_fail (data, NULL);
+
+       button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT,
+                                          HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+       hildon_button_set_title (HILDON_BUTTON (button), _("Prefered application"));
+       hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
+       hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
+       hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+
+       application_list = gtk_list_store_new (NUM_COLS,
+                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_FILENAME */
+                                              GDK_TYPE_PIXBUF, /* SELECTOR_COLUMN_ICON */
+                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_NAME */
+                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_OSSO_SERVICE */
+                                              G_TYPE_STRING);  /* SELECTOR_COLUMN_EXEC */
+       get_application_list (application_list);
+
+       /* sort list of applications */
+       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (application_list),
+                                             SELECTOR_COLUMN_NAME, GTK_SORT_ASCENDING);
+
+       /* create selector */
+       selector = hildon_touch_selector_new ();
+
+       renderer = gtk_cell_renderer_text_new ();
+       column = hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector),
+                                                    GTK_TREE_MODEL (application_list),
+                                                    renderer,
+                                                    "text", SELECTOR_COLUMN_NAME,
+                                                    NULL);
+       hildon_touch_selector_column_set_text_column (column, SELECTOR_COLUMN_NAME);
+
+       g_object_unref (application_list);
+
+       hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                          HILDON_TOUCH_SELECTOR (selector));
+
+       return button;
+}
+
+static GtkWidget *
+create_application_list_selector (CLLauncherAppletData *data)
+{
+       GtkWidget *button, *selector;
+       GtkCellRenderer *renderer;
+       HildonTouchSelectorColumn *column;
+       GtkListStore *application_list;
+       gint index = 0;
+
+       g_return_val_if_fail (data, NULL);
+
+       button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT,
+                                          HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+       hildon_button_set_title (HILDON_BUTTON (button), _("Application selector pop-up window"));
+       hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
+       hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
+       hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+
+       application_list = gtk_list_store_new (NUM_COLS,
+                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_FILENAME */
+                                              GDK_TYPE_PIXBUF, /* SELECTOR_COLUMN_ICON */
+                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_NAME */
+                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_OSSO_SERVICE */
+                                              G_TYPE_STRING);  /* SELECTOR_COLUMN_EXEC */
+       get_application_list (application_list);
+
+       /* sort list of applications */
+       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (application_list),
+                                             SELECTOR_COLUMN_NAME, GTK_SORT_ASCENDING);
+
+       /* create selector */
+       selector = hildon_touch_selector_new ();
+
+       renderer = gtk_cell_renderer_text_new ();
+       column = hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector),
+                                                    GTK_TREE_MODEL (application_list),
+                                                    renderer,
+                                                    "text", SELECTOR_COLUMN_NAME,
+                                                    NULL);
+       hildon_touch_selector_column_set_text_column (column, SELECTOR_COLUMN_NAME);
+       hildon_touch_selector_set_column_selection_mode (HILDON_TOUCH_SELECTOR (selector),
+                                                        HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE);
+
+       g_object_unref (application_list);
+
+       hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
+                                          HILDON_TOUCH_SELECTOR (selector));
+
+       return button;
+}
+
+static void
+load_configuration (CLLauncherAppletData *data)
+{
+       HildonTouchSelector *selector;
+       CLLauncherAction action;
+       gchar *prefered_application = NULL;
+       GSList *application_list = NULL, *entry = NULL;
+       GtkTreeModel *tree_model;
+       GtkTreeIter iter;
+       gboolean iter_valid = TRUE;
+
+       g_return_if_fail (data);
+
+       /* read action from gconf */
+       action = gconf_get_int (data->gconf_client, "action");
+
+       if ((action < CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION) ||
+           (action > CL_LAUNCHER_ACTION_DO_NOTHING))
+               action = CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION;
+
+       hildon_picker_button_set_active (HILDON_PICKER_BUTTON (data->action),
+                                        action);
+
+       /* read prefered application from gconf */
+       prefered_application = gconf_get_string (data->gconf_client, "prefered_application");
+       if (prefered_application == NULL)
+               prefered_application = g_strdup (CAMERA_APPLICATION_DESKTOP_FILE);
+
+       selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (data->prefered_application));
+       tree_model = hildon_touch_selector_get_model (selector, SELECTOR_COLUMN_NAME);
+       for (iter_valid = gtk_tree_model_get_iter_first (tree_model, &iter); iter_valid;
+            iter_valid = gtk_tree_model_iter_next (tree_model, &iter)) {
+               const gchar *filename;
+
+               gtk_tree_model_get (tree_model, &iter, SELECTOR_COLUMN_FILENAME, &filename, -1);
+               if (!strcmp (prefered_application, filename)) {
+                       hildon_touch_selector_select_iter(selector, SELECTOR_COLUMN_NAME, &iter, FALSE);
+                       break;
+               }
+       }
+
+       /* read aplication list from gconf */
+       application_list = gconf_get_string_list (data->gconf_client, "application_list");
+       if (application_list == NULL) {
+               application_list = g_slist_append (application_list, CAMERA_APPLICATION_DESKTOP_FILE);
+               application_list = g_slist_append (application_list, FLASHLIGHT_APPLET_DESKTOP_FILE);
+       }
+
+       for (entry = application_list; entry; entry = entry->next) {
+               selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (data->application_list));
+               tree_model = hildon_touch_selector_get_model (selector, SELECTOR_COLUMN_NAME);
+               for (iter_valid = gtk_tree_model_get_iter_first (tree_model, &iter); iter_valid;
+                    iter_valid = gtk_tree_model_iter_next (tree_model, &iter)) {
+                       const gchar *filename;
+
+                       gtk_tree_model_get (tree_model, &iter, SELECTOR_COLUMN_FILENAME, &filename, -1);
+                       if (!strcmp (entry->data, filename)) {
+                               hildon_touch_selector_select_iter(selector, SELECTOR_COLUMN_NAME, &iter, FALSE);
+                               break;
+                       }
+               }
+       }
+
+       /* free prefered application */
+       if (prefered_application)
+               g_free (prefered_application);
+
+       /* free list of applications */
+       if (application_list) {
+               g_slist_foreach (application_list, (GFunc) g_free, NULL);
+               g_slist_free (application_list);
+       }
+}
+
+static void
+save_configuration (CLLauncherAppletData *data)
+{
+       HildonTouchSelector *selector;
+       CLLauncherAction action;
+       gchar *prefered_application = NULL;
+       GSList *application_list = NULL;
+       GList *selected_rows = NULL, *entry = NULL;
+       GtkTreeIter iter;
+
+       g_return_if_fail (data);
+
+       /* action */
+       action = hildon_picker_button_get_active (HILDON_PICKER_BUTTON (data->action));
+
+       /* if nothing was selected, set action to CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION */
+       if (action == -1)
+               action = CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION;
+
+       /* prefered application */
+       if (hildon_picker_button_get_active (HILDON_PICKER_BUTTON (data->prefered_application)) > -1) {
+               selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (data->prefered_application));
+               if (hildon_touch_selector_get_selected (selector, SELECTOR_COLUMN_NAME, &iter)) {
+                       gtk_tree_model_get (hildon_touch_selector_get_model (selector, SELECTOR_COLUMN_NAME),
+                                           &iter, SELECTOR_COLUMN_FILENAME, &prefered_application, -1);
+               }
+       }
+
+       /* if nothing was selected, set prefered application to CAMERA_APPLICATION_DESKTOP_FILE */
+       if (prefered_application == NULL)
+               prefered_application = g_strdup (CAMERA_APPLICATION_DESKTOP_FILE);
+
+       /* application list */
+       selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (data->application_list));
+       selected_rows = hildon_touch_selector_get_selected_rows (selector, SELECTOR_COLUMN_NAME);
+       if (selected_rows) {
+               for (entry = selected_rows; entry; entry = entry->next) {
+                       const gchar *filename;
+
+                       gtk_tree_model_get_iter (hildon_touch_selector_get_model (selector, SELECTOR_COLUMN_NAME),
+                                                &iter, (GtkTreePath *) (entry->data));
+
+                       gtk_tree_model_get (hildon_touch_selector_get_model (selector, SELECTOR_COLUMN_NAME),
+                                           &iter, SELECTOR_COLUMN_FILENAME, &filename, -1);
+
+                       application_list = g_slist_append (application_list, g_strdup (filename));
+               }
+               g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
+               g_list_free (selected_rows);
+       }
+
+       gconf_set_int (data->gconf_client, "action", action);
+       gconf_set_string (data->gconf_client, "prefered_application", prefered_application);
+       gconf_set_string_list (data->gconf_client, "application_list", application_list);
+
+       /* free prefered application */
+       if (prefered_application)
+               g_free (prefered_application);
+
+       /* free list of applications */
+       if (application_list) {
+               g_slist_foreach (application_list, (GFunc) g_free, NULL);
+               g_slist_free (application_list);
+       }
+}
+
+osso_return_t
+execute (osso_context_t *osso,
+        gpointer data,
+        gboolean user_activated)
+{
+       CLLauncherAppletData *priv;
+       GtkWidget *dialog, *vbox;
+
+       /* allocate cllauncherappletdata */
+       priv = g_new0 (CLLauncherAppletData, 1);
+
+       /* initialize gconf */
+       priv->gconf_client = gconf_client_get_default ();
+       if (priv->gconf_client == NULL) {
+               return OSSO_ERROR;
+       }
+
+       /* main dialog */
+       dialog = gtk_dialog_new ();
+       gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+       gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data));
+       gtk_window_set_title (GTK_WINDOW (dialog), _("Camera Lens Launcher"));
+       gtk_dialog_add_button(GTK_DIALOG (dialog), _HL("wdgt_bd_save"), GTK_RESPONSE_ACCEPT);
+
+       vbox = gtk_vbox_new (FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
+
+       /* action selector button */
+       priv->action = create_action_selector (priv);
+       gtk_box_pack_start (GTK_BOX (vbox), priv->action, TRUE, TRUE, 0);
+
+       /* prefered application selector */
+       priv->prefered_application = create_prefered_application_selector (priv);
+       gtk_box_pack_start (GTK_BOX (vbox), priv->prefered_application, TRUE, TRUE, 0);
+
+       /* application list selector */
+       priv->application_list = create_application_list_selector (priv);
+       gtk_box_pack_start (GTK_BOX (vbox), priv->application_list, TRUE, TRUE, 0);
+
+       /* load configuration */
+       load_configuration (priv);
+
+       /* Run the dialog */
+       gtk_widget_show_all (GTK_WIDGET (dialog));
+       if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
+               /* save configuration */
+               save_configuration (priv);
+       }
+       gtk_widget_destroy (GTK_WIDGET (dialog));
+
+       /* free cllauncherdata */
+       if (priv) {
+               g_free (priv);
+       }
+
+       return OSSO_OK;
+}
+
+osso_return_t
+save_state (osso_context_t *osso,
+           gpointer data)
+{
+       return OSSO_OK;
+}
+
index 4d735bc..516e93c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Camera Launcher for Maemo.
- *  Copyright (C) 2009 Roman Moravcik
+ *  Copyright (C) 2010 Roman Moravcik
  *
  *  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
 #define CAM_FOCUS_UDI "/org/freedesktop/Hal/devices/platform_cam_focus"
 #define CAM_COVER_STATE "button.state.value"
 
-#define CAMERA_APPLICATION "camera-ui.desktop"
-
 typedef struct _CLLauncherData CLLauncherData;
 struct _CLLauncherData {
        GtkWidget *dialog;
 
        CLLauncherAction action;
-       gchar *application;
+       gchar *prefered_application;
+       GtkListStore *application_list;
+       gboolean application_list_empty;
 
        osso_context_t *osso_context;
        GConfClient *gconf_client;
@@ -64,6 +64,7 @@ static void
 run_application (CLLauncherData *data, DesktopFileInfo *application)
 {
        g_return_if_fail (data);
+       g_return_if_fail (data->osso_context);
 
        if (application->osso_service) {
                if (strcmp (application->osso_service, "")) {
@@ -123,6 +124,7 @@ launcher_popup_response (GtkDialog *dialog,
        CLLauncherData *data = (CLLauncherData *) user_data;
 
        g_return_if_fail (data);
+       g_return_if_fail (data->dialog);
 
        gtk_widget_hide_all (data->dialog);
        gtk_widget_destroy (data->dialog);
@@ -145,7 +147,6 @@ static void
 launcher_popup_show (CLLauncherData *data)
 {
        GtkWidget *label, *alignment, *pannable, *tree_view;
-       GtkListStore *application_list;
        GtkTreeViewColumn *column;
        GtkCellRenderer *renderer;
        GtkTreeSelection *selection;
@@ -155,22 +156,16 @@ launcher_popup_show (CLLauncherData *data)
        /* popup dialog */
        data->dialog = gtk_dialog_new ();
        gtk_window_set_title (GTK_WINDOW (data->dialog), _("Select application"));
-       gtk_widget_set_size_request (GTK_WIDGET (GTK_DIALOG (data->dialog)->vbox), -1, 270);
+       gtk_widget_set_size_request (GTK_WIDGET (GTK_DIALOG (data->dialog)->vbox), -1, 292);
+       hildon_gtk_window_set_portrait_flags (GTK_WINDOW (data->dialog), HILDON_PORTRAIT_MODE_SUPPORT);
        g_signal_connect (G_OBJECT (data->dialog), "response", G_CALLBACK (launcher_popup_response), data);
 
-       /* create application list */
-       application_list = gtk_list_store_new (NUM_COLS,
-                                              GDK_TYPE_PIXBUF, /* SELECTOR_COLUMN_ICON */
-                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_NAME */
-                                              G_TYPE_STRING,   /* SELECTOR_COLUMN_OSSO_SERVICE */
-                                              G_TYPE_STRING);  /* SELECTOR_COLUMN_EXEC */
-
-       /* get application list */
-       if (get_application_list (application_list)) {
+       /* check if application list is empty */
+       if (!data->application_list_empty) {
                GtkTreeSelection *selection;
 
-               /* sort list of calendars */
-               gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (application_list),
+               /* sort list of applications */
+               gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->application_list),
                                                      SELECTOR_COLUMN_NAME, GTK_SORT_ASCENDING);
 
                /* alignment */
@@ -185,7 +180,7 @@ launcher_popup_show (CLLauncherData *data)
 
                /* tree view */
                tree_view = hildon_gtk_tree_view_new_with_model (HILDON_UI_MODE_EDIT,
-                                                                GTK_TREE_MODEL (application_list));
+                                                                GTK_TREE_MODEL (data->application_list));
                gtk_container_add (GTK_CONTAINER (pannable), tree_view);
 
                /* application icon */
@@ -211,12 +206,12 @@ launcher_popup_show (CLLauncherData *data)
                gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
        } else {
                label = gtk_label_new (_("No applications"));
+               hildon_helper_set_logical_color (label, GTK_RC_FG, GTK_STATE_NORMAL,
+                                                "SecondaryTextColor");
+               hildon_helper_set_logical_font (label, "LargeSystemFont");
                gtk_container_add (GTK_CONTAINER (GTK_DIALOG (data->dialog)->vbox), label);
        }
 
-       /* unref application list */
-       g_object_unref (application_list);
-
        /* show selector popup */
        gtk_widget_show_all (data->dialog);
 
@@ -238,11 +233,13 @@ camera_launcher_on_gconf_changed (GConfClient *client,
        GConfValue *value;
        CLLauncherAction action;
        const gchar *application;
+       const GSList *application_list;
+
+       g_return_if_fail (data);
 
        key = gconf_entry_get_key (entry);
        value = gconf_entry_get_value (entry);
 
-       g_return_if_fail (data);
        g_return_if_fail (value);
 
        /* Only key without absolute path is required */
@@ -250,27 +247,41 @@ camera_launcher_on_gconf_changed (GConfClient *client,
 
        if (!strcmp (key, "action")) {
                action = gconf_value_get_int (value);
-               if ((action < CL_LAUNCHER_ACTION_DO_NOTHING) ||
-                   (action > CL_LAUNCHER_ACTION_SHOW_SELECTOR_POPUP)) {
-                       g_warning("camera_launcher_on_gconf_changed: Wrong value %d of key %s/%s", action, GCONF_CL_LAUNCHER, key);
+               if ((action < CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION) ||
+                   (action > CL_LAUNCHER_ACTION_DO_NOTHING)) {
+                       g_warning("camera_launcher_on_gconf_changed: Wrong value %d of key %s/%s", action,
+                                 GCONF_CL_LAUNCHER, key);
                } else {
                        data->action = action;
                }
-       } else if (!strcmp (key, "application")) {
+       } else if (!strcmp (key, "prefered_application")) {
                application = gconf_value_get_string (value);
                if (strcmp (application, "") &&
                    g_str_has_suffix (application, ".desktop"))
                {
-                       if (data->application)
-                               g_free (data->application);
-                       data->application = g_strdup (application);
+                       if (data->prefered_application)
+                               g_free (data->prefered_application);
+                       data->prefered_application = g_strdup (application);
                } else {
-                       g_warning("camera_launcher_on_gconf_changed: Wrong value %s of key %s/%s", application, GCONF_CL_LAUNCHER, key);
+                       g_warning("camera_launcher_on_gconf_changed: Wrong value %s of key %s/%s", application,
+                                 GCONF_CL_LAUNCHER, key);
+               }
+       } else if (!strcmp (key, "application_list")) {
+               if (data->application_list) {
+                       if (gconf_value_get_list_type (value) == GCONF_VALUE_STRING) {
+                               application_list = gconf_value_get_list (value);
+
+                               /* clear previous application list */
+                               gtk_list_store_clear (data->application_list);
+
+                               /* fill application list */
+                               data->application_list_empty = get_application_list_from_list (data->application_list,
+                                                                                              application_list);
+                       }
                }
        } else {
                g_warning("camera_launcher_on_gconf_changed: Wrong %s key, %s", GCONF_CL_LAUNCHER, key);
        }
-       gconf_value_free (value);
 }
 
 static void
@@ -301,11 +312,11 @@ camera_launcher_on_hal_property_modified (LibHalContext *ctx,
 
                                case CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION:
                                        /* kill camera application only if it's not selected as prefered */
-                                       if (strcmp (data->application, CAMERA_APPLICATION))
+                                       if (strcmp (data->prefered_application, CAMERA_APPLICATION_DESKTOP_FILE))
                                                kill_camera_application ();
 
                                        /* run prefered application */
-                                       application = get_desktop_file_info (data->application);
+                                       application = get_desktop_file_info (data->prefered_application);
                                        if (application) {
                                                run_application (data, application);
                                                g_free (application);
@@ -336,7 +347,7 @@ camera_launcher_on_hal_property_modified (LibHalContext *ctx,
        } else if (!strcmp (udi, CAM_FOCUS_UDI)) {
                if (state) {
                        /* run camera application when focus key was pressed */
-                       application = get_desktop_file_info (CAMERA_APPLICATION);
+                       application = get_desktop_file_info (CAMERA_APPLICATION_DESKTOP_FILE);
                        if (application) {
                                run_application (data, application);
                                g_free (application);
@@ -356,12 +367,18 @@ main (int argc, char **argv)
 
        hildon_gtk_init (&argc, &argv);
 
-       /* create CLLauncherData */
+       /* allocate cllauncherdata */
        data = g_new0 (CLLauncherData, 1);
        data->dialog = NULL;
-//     data->action = CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION;
-       data->action = CL_LAUNCHER_ACTION_SHOW_SELECTOR_POPUP;
-       data->application = g_strdup (CAMERA_APPLICATION);
+       data->action = CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION;
+       data->prefered_application = g_strdup (CAMERA_APPLICATION_DESKTOP_FILE);
+       data->application_list = gtk_list_store_new (NUM_COLS,
+                                                    G_TYPE_STRING,     /* SELECTOR_COLUMN_FILENAME */
+                                                    GDK_TYPE_PIXBUF,   /* SELECTOR_COLUMN_ICON */
+                                                    G_TYPE_STRING,     /* SELECTOR_COLUMN_NAME */
+                                                    G_TYPE_STRING,     /* SELECTOR_COLUMN_OSSO_SERVICE */
+                                                    G_TYPE_STRING);    /* SELECTOR_COLUMN_EXEC */
+       data->application_list_empty = TRUE;
 
        /* initialize osso */
        data->osso_context = osso_initialize (PACKAGE, VERSION, TRUE, NULL);
@@ -383,7 +400,8 @@ main (int argc, char **argv)
        }
 
        gconf_client_notify (data->gconf_client, GCONF_CL_LAUNCHER "/action");
-       gconf_client_notify (data->gconf_client, GCONF_CL_LAUNCHER "/application");
+       gconf_client_notify (data->gconf_client, GCONF_CL_LAUNCHER "/prefered_application");
+       gconf_client_notify (data->gconf_client, GCONF_CL_LAUNCHER "/application_list");
 
        /* initialize dbus */
        dbus_error_init (&dbus_error);
@@ -419,25 +437,41 @@ main (int argc, char **argv)
        }
 
        libhal_device_add_property_watch (hal, CAM_COVER_UDI, NULL);
-       libhal_device_add_property_watch (hal, CAM_FOCUS_UDI, NULL);
+       /* libhal_device_add_property_watch (hal, CAM_FOCUS_UDI, NULL); */
 
        gtk_main ();
 
        /* deinitialize hal */
        if (hal) {
                libhal_device_remove_property_watch (hal, CAM_COVER_UDI, NULL);
-               libhal_device_remove_property_watch (hal, CAM_FOCUS_UDI, NULL);
+               /* libhal_device_remove_property_watch (hal, CAM_FOCUS_UDI, NULL); */
 hal_error:
                libhal_ctx_set_user_data (hal, NULL);
                libhal_ctx_shutdown (hal, NULL);
                libhal_ctx_free (hal);
        }
 
+       /* unreference dbus connection */
+       if (dbus_connection)
+               dbus_connection_unref (dbus_connection);
+
 osso_error:
        /* deinitialize osso */
        if (data->osso_context) {
                osso_deinitialize (data->osso_context);
        }
 
+       /* free cllauncherdata */
+       if (data) {
+               if (data->prefered_application)
+                       g_free (data->prefered_application);
+
+               /* unref application list */
+               g_object_unref (data->application_list);
+
+               g_free (data);
+       }
+
+
        return 0;
 }
index 799ef5a..4abeba3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Camera Launcher for Maemo.
- *  Copyright (C) 2009 Roman Moravcik
+ *  Copyright (C) 2010 Roman Moravcik
  *
  *  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
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <gconf/gconf-client.h>
+
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
@@ -38,46 +40,58 @@ get_desktop_file_info (const gchar *desktop_file)
 {
        DesktopFileInfo *dfinfo = NULL;
        GKeyFile *key_file;
-       gchar *filename = NULL;
-       GError *error;
 
-       filename = g_strdup_printf ("%s/%s", CL_LAUNCHER_DESKTOP_DATADIR, desktop_file);
-       if (filename) {
+       if (desktop_file) {
                key_file = g_key_file_new ();
-               if (g_key_file_load_from_file (key_file, filename, 0, NULL)) {
+               if (g_key_file_load_from_file (key_file, desktop_file, 0, NULL)) {
+                       gchar *type = NULL;
+
+                       /* exclude non application desktop files */
+                       if (g_key_file_has_key (key_file, "Desktop Entry", "Type", NULL)) {
+                               type = g_key_file_get_string (key_file, "Desktop Entry", "Type", NULL);
+                               if (type) {
+                                       if (strcmp (type, "Application")) {
+                                               g_free (type);
+                                               return NULL;
+                                       }
+                                       g_free (type);
+                               }
+                       }
+
                        dfinfo = g_new0 (DesktopFileInfo, 1);
 
                        /* get application icon */
-                       if (g_key_file_has_key (key_file, "Desktop Entry", "Icon", &error)) {
-                               dfinfo->icon = g_key_file_get_string (key_file, "Desktop Entry", "Icon", &error);
+                       if (g_key_file_has_key (key_file, "Desktop Entry", "Icon", NULL)) {
+                               dfinfo->icon = g_key_file_get_string (key_file, "Desktop Entry", "Icon", NULL);
                        } else {
                                dfinfo->icon = NULL;
                        }
 
                        /* get application name */
-                       if (g_key_file_has_key (key_file, "Desktop Entry", "X-Text-Domain", &error)) {
-                               textdomain (g_key_file_get_string (key_file, "Desktop Entry", "X-Text-Domain", &error));
-                               dfinfo->name = gettext (g_key_file_get_string (key_file, "Desktop Entry", "Name", &error));
-                       } else if (g_key_file_has_key (key_file, "Desktop Entry", "Name", &error)) {
-                               dfinfo->name = g_key_file_get_string (key_file, "Desktop Entry", "Name", &error);
+                       if (g_key_file_has_key (key_file, "Desktop Entry", "X-Text-Domain", NULL)) {
+                               textdomain (g_key_file_get_string (key_file, "Desktop Entry", "X-Text-Domain", NULL));
+                               dfinfo->name = gettext (g_key_file_get_string (key_file, "Desktop Entry", "Name", NULL));
+                       } else if (g_key_file_has_key (key_file, "Desktop Entry", "Name", NULL)) {
+                               textdomain ("maemo-af-desktop");
+                               dfinfo->name = gettext (g_key_file_get_string (key_file, "Desktop Entry", "Name", NULL));
                        } else {
                                dfinfo->name = NULL;
                        }
-               }
 
                        /* get application osso_service */
-                       if (g_key_file_has_key (key_file, "Desktop Entry", "X-Osso-Service", &error)) {
-                               dfinfo->osso_service = g_key_file_get_string (key_file, "Desktop Entry", "X-Osso-Service", &error);
+                       if (g_key_file_has_key (key_file, "Desktop Entry", "X-Osso-Service", NULL)) {
+                               dfinfo->osso_service = g_key_file_get_string (key_file, "Desktop Entry", "X-Osso-Service", NULL);
                        } else {
                                dfinfo->osso_service = NULL;
                        }
 
                        /* get application exec */
-                       if (g_key_file_has_key (key_file, "Desktop Entry", "Exec", &error)) {
-                               dfinfo->exec = g_key_file_get_string (key_file, "Desktop Entry", "Exec", &error);
+                       if (g_key_file_has_key (key_file, "Desktop Entry", "Exec", NULL)) {
+                               dfinfo->exec = g_key_file_get_string (key_file, "Desktop Entry", "Exec", NULL);
                        } else {
                                dfinfo->exec = NULL;
                        }
+               }
 
                if (key_file)
                        g_key_file_free (key_file);
@@ -86,9 +100,9 @@ get_desktop_file_info (const gchar *desktop_file)
 }
 
 gboolean
-get_application_list (GtkListStore *list)
+get_application_list (GtkListStore *store)
 {
-       gboolean found = FALSE;
+       gboolean is_empty = TRUE;
        GtkIconTheme *icon_theme;
        GtkTreeIter iter;
        GDir *dir;
@@ -104,41 +118,111 @@ get_application_list (GtkListStore *list)
                                DesktopFileInfo *dfinfo = NULL;
                                GtkIconInfo *icon_info;
                                GdkPixbuf *icon_pixbuf = NULL;
+                               gchar *desktop_file = NULL;
+
+                               desktop_file = g_strdup_printf ("%s/%s", CL_LAUNCHER_DESKTOP_DATADIR, filename);
+                               if (desktop_file) {
+                                       dfinfo = get_desktop_file_info (desktop_file);
+                                       if (dfinfo) {
+                                               if (!dfinfo->icon) {
+                                                       dfinfo->icon = g_strdup ("tasklaunch_default_application");
+                                               }
+
+                                               icon_info = gtk_icon_theme_lookup_icon (icon_theme, dfinfo->icon, 48,
+                                                                                       GTK_ICON_LOOKUP_NO_SVG);
+                                               if (icon_info) {
+                                                       const gchar *fname = gtk_icon_info_get_filename (icon_info);
+                                                       icon_pixbuf = gdk_pixbuf_new_from_file_at_size (fname, 48, 48, 0);
+                                                       gtk_icon_info_free (icon_info);
+                                               }
+
+                                               /* fill application store */
+                                               gtk_list_store_append (store, &iter);
+                                               gtk_list_store_set (store, &iter,
+                                                                   SELECTOR_COLUMN_NAME, dfinfo->name,
+                                                                   SELECTOR_COLUMN_ICON, icon_pixbuf,
+                                                                   SELECTOR_COLUMN_FILENAME, filename,
+                                                                   SELECTOR_COLUMN_OSSO_SERVICE, dfinfo->osso_service,
+                                                                   SELECTOR_COLUMN_EXEC, dfinfo->exec,
+                                                                   -1);
+
+                                               if (is_empty == TRUE)
+                                                       is_empty = FALSE;
+
+                                               if (icon_pixbuf)
+                                                       g_object_unref (icon_pixbuf);
+
+                                               g_free (dfinfo);
+                                       }
+                                       g_free (desktop_file);
+                               }
+                       }
+               }
+               g_dir_close (dir);
+       }
+
+       return is_empty;
+}
 
-                               dfinfo = get_desktop_file_info (filename);
+gboolean
+get_application_list_from_list (GtkListStore *store, const GSList *list)
+{
+       const GSList *application;
+       gboolean is_empty = TRUE;
+       GtkIconTheme *icon_theme;
+       GtkTreeIter iter;
+
+       icon_theme = gtk_icon_theme_get_default ();
+
+       for (application = list; application != NULL; application = application->next) {
+               const gchar *filename;
+
+               filename = gconf_value_get_string (application->data);
+
+               if (g_str_has_suffix (filename, ".desktop")) {
+                       DesktopFileInfo *dfinfo = NULL;
+                       GtkIconInfo *icon_info;
+                       GdkPixbuf *icon_pixbuf = NULL;
+                       gchar *desktop_file = NULL;
+
+                       desktop_file = g_strdup_printf ("%s/%s", CL_LAUNCHER_DESKTOP_DATADIR, filename);
+                       if (desktop_file) {
+                               dfinfo = get_desktop_file_info (desktop_file);
                                if (dfinfo) {
                                        if (!dfinfo->icon) {
                                                dfinfo->icon = g_strdup ("tasklaunch_default_application");
                                        }
 
-                                       icon_info = gtk_icon_theme_lookup_icon (icon_theme, dfinfo->icon, 48, GTK_ICON_LOOKUP_NO_SVG);
+                                       icon_info = gtk_icon_theme_lookup_icon (icon_theme, dfinfo->icon, 48,
+                                                                               GTK_ICON_LOOKUP_NO_SVG);
                                        if (icon_info) {
                                                const gchar *fname = gtk_icon_info_get_filename (icon_info);
                                                icon_pixbuf = gdk_pixbuf_new_from_file_at_size (fname, 48, 48, 0);
                                                gtk_icon_info_free (icon_info);
                                        }
 
-                                       /* fill application list */
-                                       gtk_list_store_append (list, &iter);
-                                       gtk_list_store_set (list, &iter,
-                                                           SELECTOR_COLUMN_ICON, icon_pixbuf,
+                                       /* fill application store */
+                                       gtk_list_store_append (store, &iter);
+                                       gtk_list_store_set (store, &iter,
                                                            SELECTOR_COLUMN_NAME, dfinfo->name,
+                                                           SELECTOR_COLUMN_ICON, icon_pixbuf,
+                                                           SELECTOR_COLUMN_FILENAME, filename,
                                                            SELECTOR_COLUMN_OSSO_SERVICE, dfinfo->osso_service,
                                                            SELECTOR_COLUMN_EXEC, dfinfo->exec,
                                                            -1);
 
-                                       if (found == FALSE)
-                                               found = TRUE;
+                                       if (is_empty == TRUE)
+                                               is_empty = FALSE;
 
                                        if (icon_pixbuf)
                                                g_object_unref (icon_pixbuf);
 
                                        g_free (dfinfo);
                                }
+                               g_free (desktop_file);
                        }
                }
-               g_dir_close (dir);
        }
 
-       return found;
+       return is_empty;
 }
index aabb3ab..17833c2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Camera Launcher for Maemo.
- *  Copyright (C) 2009 Roman Moravcik
+ *  Copyright (C) 2010 Roman Moravcik
  *
  *  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
 #include <gtk/gtk.h>
 #include <hildon/hildon.h>
 
+#define CAMERA_APPLICATION_DESKTOP_FILE "camera-ui.desktop"
+#define FLASHLIGHT_APPLET_DESKTOP_FILE "flashlight-applet-launcher.desktop"
+
 #define GCONF_CL_LAUNCHER "/apps/maemo/cl-launcher"
-#define CL_LAUNCHER_DESKTOP_DATADIR "/usr/share/applications/cl-launcher"
+#define CL_LAUNCHER_DESKTOP_DATADIR "/usr/share/applications/hildon"
 
 typedef enum {
-       CL_LAUNCHER_ACTION_DO_NOTHING = 0,
-       CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION,
-       CL_LAUNCHER_ACTION_SHOW_SELECTOR_POPUP
+       CL_LAUNCHER_ACTION_RUN_PREFERED_APPLICATION = 0,
+       CL_LAUNCHER_ACTION_SHOW_SELECTOR_POPUP,
+       CL_LAUNCHER_ACTION_DO_NOTHING,
+       CL_LAUNCHER_ACTION_LAST
 } CLLauncherAction;
 
 enum {
-       SELECTOR_COLUMN_ICON = 0,
-       SELECTOR_COLUMN_NAME,
+       SELECTOR_COLUMN_NAME = 0,
+       SELECTOR_COLUMN_ICON,
+       SELECTOR_COLUMN_FILENAME,
        SELECTOR_COLUMN_OSSO_SERVICE,
        SELECTOR_COLUMN_EXEC,
        NUM_COLS
@@ -58,7 +63,8 @@ typedef struct {
        gchar *exec;
 } DesktopFileInfo;
 
-gboolean get_application_list (GtkListStore *list);
+gboolean get_application_list (GtkListStore *store);
+gboolean get_application_list_from_list (GtkListStore *store, const GSList *list);
 
 DesktopFileInfo *get_desktop_file_info (const gchar *desktop_file);