continue preparation of 0.6
[simple-launcher] / simple-launcher.cc
index d60f195..7e1dad1 100644 (file)
@@ -20,6 +20,9 @@ extern "C" {
 
 #define SLA_APPLET_DBUS_NAME  "simple-launcher"
 #define SLA_APPLET_VERSION    "0.0"
+#define SLA_APPLET_ICON_SIZE  26
+#define SLA_APPLET_BORDER_SIZE  14
+#define SLA_APPLET_CANVAS_SIZE  (SLA_APPLET_BORDER_SIZE+SLA_APPLET_BORDER_SIZE)
 
 class SimpleLauncherApplet {
 public:
@@ -94,11 +97,11 @@ int hildon_home_applet_lib_save_state (void *applet_data, void **state_data, int
 
 char *SimpleLauncherApplet::ourFiles[] = {
   "/usr/share/applications/hildon/FBReader.desktop",
+  "/usr/share/applications/hildon/mp_ui.desktop",
+  "/usr/share/applications/hildon/osso-xterm.desktop",
   "/usr/share/applications/hildon/filemanager.desktop",
-  "/usr/share/applications/hildon/hildon-control-panel.desktop",
   "/usr/share/applications/hildon/osso-application-installer.desktop",
-  "/usr/share/applications/hildon/osso-music-player.desktop",
-  "/usr/share/applications/hildon/osso-xterm.desktop",
+  "/usr/share/applications/hildon/hildon-control-panel.desktop",
   0
 };
 
@@ -106,7 +109,7 @@ SimpleLauncherApplet::SimpleLauncherApplet(): myContext(0), myWidget(0) {
 }
 
 bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) {
-  if ((myContext = osso_initialize(SLA_APPLET_DBUS_NAME, SLA_APPLET_VERSION, FALSE, NULL)) == 0) {
+  if ((myContext = osso_initialize(SLA_APPLET_DBUS_NAME, SLA_APPLET_VERSION, FALSE, 0)) == 0) {
     g_debug("sla-applet: failed to initialize the osso layer");
     return false;
   }
@@ -152,27 +155,31 @@ SimpleLauncherApplet::~SimpleLauncherApplet() {
 }
 
 bool SimpleLauncherApplet::initWidget() {
-  bool have_buttons = false;
+  int button_no = 0;
 
-  myWidget = gtk_toolbar_new();
+  GtkToolbar *toolbar = GTK_TOOLBAR(gtk_toolbar_new());
 
   for (std::vector<LauncherItem *>::const_iterator it = myItems.begin(); it != myItems.end(); ++it) {
-    GtkToolItem *button = gtk_tool_button_new(gtk_image_new_from_pixbuf((*it)->getIcon(26)), 0);
+    GtkToolItem *button = gtk_tool_button_new(gtk_image_new_from_pixbuf((*it)->getIcon(SLA_APPLET_ICON_SIZE)), 0);
 
     gtk_object_set_user_data(GTK_OBJECT(button), *it);
     g_signal_connect(button, "clicked", G_CALLBACK(_button_clicked), this);
 
-    gtk_toolbar_insert(GTK_TOOLBAR(myWidget), button, -1);
+    gtk_toolbar_insert(toolbar, button, -1);
 
-    have_buttons = true;
+    ++button_no;
   }
 
-  if (!have_buttons) {
-    gtk_widget_destroy(myWidget);
-    myWidget = 0;
+  if (button_no) {
+    myWidget = gtk_frame_new(0);
+    gtk_frame_set_shadow_type(GTK_FRAME(myWidget), GTK_SHADOW_ETCHED_IN);
+    gtk_widget_set_size_request(myWidget, button_no*(SLA_APPLET_ICON_SIZE+SLA_APPLET_CANVAS_SIZE), SLA_APPLET_ICON_SIZE+SLA_APPLET_CANVAS_SIZE);
+    gtk_container_add(GTK_CONTAINER(myWidget), GTK_WIDGET(toolbar));
+  } else {
+    gtk_widget_destroy(GTK_WIDGET(toolbar));
   }
 
-  return true;
+  return myWidget != 0;
 }
 
 void SimpleLauncherApplet::_button_clicked(GtkToolButton *button, void *self) {