added a configurable canvas around button icons
[simple-launcher] / simple-launcher.cc
index a78d422..1e68c26 100644 (file)
 #include "sla-list.h"
 #include "launchable-item.h"
 #include "settings-dialog.h"
-#include "gconf-wrapper.h"
 
 #define SL_APPLET_DBUS_NAME  "simple-launcher"
 #define SL_APPLET_VERSION    "0.0"
-#define SL_APPLET_ICON_SIZE  26
 
 #define SL_APPLET_GCONF_PATH  "/apps/simple-launcher"
 
@@ -71,8 +69,8 @@ private:
   static void _run_dialog(GtkMenuItem *, void *);
 
 private:
-  GConfClientWrapper myClient;
-  GConfKey myMainSettings;
+  // GConfClientWrapper myClient;
+  // GConfKey myMainSettings;
 
   osso_context_t *myContext;
 
@@ -81,6 +79,11 @@ private:
 
   LauncherItems myItems;
 
+  bool myTransparent;
+  // bool myShowInfobanner; // FIXME: to implement
+  int myIconSize;
+  int myCanvasSize;
+
   static char *ourDirs[];
 };
 
@@ -130,7 +133,8 @@ char *SimpleLauncherApplet::ourDirs[] = {
   NULL
 };
 
-SimpleLauncherApplet::SimpleLauncherApplet(): myMainSettings(myClient.getKey(SL_APPLET_GCONF_PATH)), myContext(NULL), myWidget(NULL), myParent(NULL) {
+// SimpleLauncherApplet::SimpleLauncherApplet() : myMainSettings(myClient.getKey(SL_APPLET_GCONF_PATH)), myContext(NULL), myWidget(NULL), myParent(NULL) {
+SimpleLauncherApplet::SimpleLauncherApplet() : myContext(NULL), myWidget(NULL), myParent(NULL), myTransparent(true), myIconSize(48), myCanvasSize(1) {
 }
 
 bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) {
@@ -268,10 +272,14 @@ void SimpleLauncherApplet::updateWidget() {
       gtk_widget_set_events(button, GDK_BUTTON_PRESS_MASK);
       g_signal_connect(button, "button-press-event", G_CALLBACK(_button_pressed), this);
 
-      gtk_event_box_set_visible_window(GTK_EVENT_BOX(button), false);
-      // gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE);
+      gtk_event_box_set_visible_window(GTK_EVENT_BOX(button), !myTransparent);
+      gtk_container_set_border_width(GTK_CONTAINER(button), myCanvasSize);
 
-      gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_pixbuf(item->getIcon(SL_APPLET_ICON_SIZE)));
+      {
+        GdkPixbuf *pixbuf = item->getIcon(myIconSize);
+        gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_pixbuf(pixbuf));
+        g_object_unref(G_OBJECT(pixbuf));
+      }
 
       gtk_object_set_user_data(GTK_OBJECT(button), item);
 
@@ -286,9 +294,9 @@ void SimpleLauncherApplet::updateWidget() {
   g_object_unref(G_OBJECT(group));
 
   if (button_no == 0) {
-    gtk_widget_set_size_request(myWidget, SL_APPLET_ICON_SIZE, SL_APPLET_ICON_SIZE);
+    gtk_widget_set_size_request(myWidget, myIconSize+myCanvasSize+myCanvasSize, myIconSize+myCanvasSize+myCanvasSize);
   } else {
-    gtk_widget_set_size_request(myWidget, button_no*SL_APPLET_ICON_SIZE, SL_APPLET_ICON_SIZE);
+    gtk_widget_set_size_request(myWidget, button_no*(myIconSize+myCanvasSize+myCanvasSize), myIconSize+myCanvasSize+myCanvasSize);
   }
 
   gtk_widget_show_all(myWidget);
@@ -341,7 +349,7 @@ void SimpleLauncherApplet::runDialog() {
 
   LauncherItems newItems = myItems;
 
-  SettingsDialog dialog(myParent, SL_APPLET_ICON_SIZE, newItems);
+  SettingsDialog dialog(myParent, newItems);
 
   switch (dialog.run()) {
     case GTK_RESPONSE_OK: