#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:
GtkWidget *getWidget() { return myWidget; }
- bool startApplication(const std::string& application);
+ static void _button_clicked(GtkToolButton *, void *);
+
+private:
+ bool initWidget();
+
+ void buttonClicked(GtkToolButton *);
private:
osso_context_t *myContext;
// Hildon home applet interface functions
-void *hildon_home_applet_lib_initialize (void *state_data, int *state_size, GtkWidget **widget) {
+void *hildon_home_applet_lib_initialize(void *state_data, int *state_size, GtkWidget **widget) {
SimpleLauncherApplet *applet = new SimpleLauncherApplet();
if (applet != 0) {
// SimpleLauncherApplet implementation
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/osso-application-installer.desktop",
+ "/usr/share/applications/hildon/hildon-control-panel.desktop",
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;
}
- // myWidget = mis_widget_new_with_engines_and_history();
- if (myWidget == 0) {
- return false;
- }
-
for (int i = 0 ; ourFiles[i] != 0 ; ++i) {
LauncherItem *item = new LauncherItem();
}
}
- // g_signal_connect (applet->myWidget, "do_search", G_CALLBACK (mis_applet_do_search), (gpointer)applet);
+ if (!initWidget()) {
+ return false;
+ }
gtk_widget_show_all(myWidget);
}
}
+bool SimpleLauncherApplet::initWidget() {
+ int button_no = 0;
+
+ 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(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(toolbar, button, -1);
+
+ ++button_no;
+ }
+
+ if (button_no) {
+ myWidget = gtk_frame_new(0);
+#if 1
+ gtk_container_set_border_width(GTK_CONTAINER(myWidget), 0);
+ gtk_widget_set_name(myWidget, "osso-speeddial");
+#else
+ gtk_frame_set_shadow_type(GTK_FRAME(myWidget), GTK_SHADOW_ETCHED_IN);
+#endif
+ 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 myWidget != 0;
+}
+
+void SimpleLauncherApplet::_button_clicked(GtkToolButton *button, void *self) {
+ ((SimpleLauncherApplet *)self)->buttonClicked(button);
+}
+
+void SimpleLauncherApplet::buttonClicked(GtkToolButton *button) {
+ if (button != 0) {
+ LauncherItem *item = (LauncherItem *)gtk_object_get_user_data(GTK_OBJECT(button));
+
+ if (item != 0) {
+ item->activate(myContext);
+ }
+ }
+}
+
int SimpleLauncherApplet::saveState(void **state_data, int *state_size) {
if (state_data != 0) {
*state_data = 0;
// corresponding dialog appears.
return 0;
}
-
-bool SimpleLauncherApplet::startApplication(const std::string& application) {
- return osso_application_top(myContext, application.c_str(), 0) == OSSO_OK;
-}