X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=simple-launcher.cc;h=6cb34b7b7cc595b523066aefbe9d9cc55d22c313;hb=80e9721da579a7f9c25b1213a08bf22de6a81a50;hp=1e06ac70873995ba171d13c88b29dc5ade95bc28;hpb=616f1f9e6fa9037e19454f918e49e5c06cb19d67;p=simple-launcher diff --git a/simple-launcher.cc b/simple-launcher.cc index 1e06ac7..6cb34b7 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -1,3 +1,19 @@ +// 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 #include @@ -9,15 +25,6 @@ #include "launcher-item.h" -extern "C" { - void *hildon_home_applet_lib_initialize (void *state_data, int *state_size, GtkWidget **widget); - void hildon_home_applet_lib_deinitialize (void *applet_data); - void hildon_home_applet_lib_background (void *applet_data); - void hildon_home_applet_lib_foreground(void *applet_data); - int hildon_home_applet_lib_save_state(void *applet_data, void **state_data, int *state_size); - GtkWidget *hildon_home_applet_lib_settings(void *applet_data, GtkWindow *parent); -}; - #define SLA_APPLET_DBUS_NAME "simple-launcher" #define SLA_APPLET_VERSION "0.0" #define SLA_APPLET_ICON_SIZE 26 @@ -38,16 +45,19 @@ public: GtkWidget *getWidget() { return myWidget; } - static void _button_clicked(GtkToolButton *, void *); - private: bool initWidget(); void buttonClicked(GtkToolButton *); + void runDialog(); + + static void _button_clicked(GtkToolButton *, void *); + static void _run_dialog(GtkMenuItem *, void *); private: osso_context_t *myContext; GtkWidget *myWidget; + GtkWindow *myParent; std::vector myItems; @@ -105,7 +115,7 @@ char *SimpleLauncherApplet::ourFiles[] = { 0 }; -SimpleLauncherApplet::SimpleLauncherApplet(): myContext(0), myWidget(0) { +SimpleLauncherApplet::SimpleLauncherApplet(): myContext(0), myWidget(0), myParent(0) { } bool SimpleLauncherApplet::doInit(void *state_data, int *state_size) { @@ -172,12 +182,7 @@ bool SimpleLauncherApplet::initWidget() { 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 { @@ -218,5 +223,36 @@ GtkWidget *SimpleLauncherApplet::settings(GtkWindow *parent) { // should return a gtk_menu_item that would be included in home settings // menu. Method should make sure that when we activate that item, a // corresponding dialog appears. - return 0; + myParent = parent; // FIXME: Ugly piece of code :( + + GtkWidget *menuItem = gtk_menu_item_new_with_label("Launcher Settings..."); + + g_signal_connect(menuItem, "activate", G_CALLBACK(_run_dialog), this); + + return menuItem; +} + +void SimpleLauncherApplet::_run_dialog(GtkMenuItem *, void *self) { + ((SimpleLauncherApplet *)self)->runDialog(); +} + +void SimpleLauncherApplet::runDialog() { + GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("Launcher Settings", myParent, (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_OK, "Cancel", GTK_RESPONSE_CANCEL, 0)); + + int response = gtk_dialog_run(dialog); + + gtk_widget_destroy(GTK_WIDGET(dialog)); + + switch (response) { + case GTK_RESPONSE_OK: + break; + + case GTK_RESPONSE_CANCEL: + break; + + default: + ; // FIXME: do I want to do anything in here? + } } + +// vim:ts=2:sw=2:et