include new test program into cleaning target
[simple-launcher] / launcher-item.cc
index 28825a2..8863fc0 100644 (file)
@@ -1,12 +1,29 @@
+// This file is a part of Simple Launcher
+//
+// Copyright (C) 2006, Mikhail Sobolev
+//
+// Simple Launcher is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// 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., 51
+// Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 #include <string>
 
 #include <glib/gmem.h>
 #include <glib/gkeyfile.h>
 
-#include <gtk/gtkicontheme.h>
-
 #include "launcher-item.h"
 
+GtkIconTheme *LauncherItem::ourTheme = 0;
+
 static const char *DESKTOP_ENTRY_GROUP = "Desktop Entry",
                   *DESKTOP_ENTRY_TYPE_FIELD = "Type",
                   *DESKTOP_ENTRY_ICON_FIELD = "Icon",
@@ -19,7 +36,7 @@ inline std::string getStringWrapper(GKeyFile *keyFile, const gchar *group, const
   std::string result;
 
   if (tempo != 0) {
-    result = tempo;
+    result.assign(tempo);
 
     g_free(tempo);
   }
@@ -32,7 +49,7 @@ inline std::string getLocaleStringWrapper(GKeyFile *keyFile, const gchar *group,
   std::string result;
 
   if (tempo != 0) {
-    result = tempo;
+    result.assign(tempo);
 
     g_free(tempo);
   }
@@ -87,11 +104,13 @@ GdkPixbuf *LauncherItem::getIcon(int icon_size) const {
   GdkPixbuf *pixbuf = 0;
 
   if (!myIcon.empty()) {
-    GtkIconTheme *theme;
+    if (ourTheme == 0) {
+      ourTheme = gtk_icon_theme_get_default();
+    }
+
     GError *error = 0;
 
-    theme = gtk_icon_theme_get_default();
-    pixbuf = gtk_icon_theme_load_icon(theme, myIcon.c_str(), icon_size, GTK_ICON_LOOKUP_NO_SVG, &error);
+    pixbuf = gtk_icon_theme_load_icon(ourTheme, myIcon.c_str(), icon_size, GTK_ICON_LOOKUP_NO_SVG, &error);
 
     if (error != 0) {
       g_error_free(error);
@@ -101,3 +120,9 @@ GdkPixbuf *LauncherItem::getIcon(int icon_size) const {
 
   return pixbuf;
 }
+
+bool LauncherItem::activate(osso_context_t *context) {
+  return osso_application_top(context, myService.c_str(), 0) == OSSO_OK;
+}
+
+// vim:ts=2:sw=2:et