From: mishas Date: Mon, 2 Apr 2007 16:01:09 +0000 (+0000) Subject: Settings dialog implementaton moved into a separate class: this way it X-Git-Url: http://vcs.maemo.org/git/?p=simple-launcher;a=commitdiff_plain;h=a53241819e0eaba3cb06cf9f07c4a310e3a72677 Settings dialog implementaton moved into a separate class: this way it should be possible to implement better settings dialog without making main code look too heavy or something. git-svn-id: file:///svnroot/simple-launcher/trunk@138 3ba93dab-e023-0410-b42a-de7732cf370a --- diff --git a/settings-dialog.cc b/settings-dialog.cc index 608be50..283bc1b 100644 --- a/settings-dialog.cc +++ b/settings-dialog.cc @@ -15,3 +15,20 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#include "settings-dialog.h" + +SettingsDialog::SettingsDialog(GtkWindow *parent, int size, LauncherItems& items) : myList(size, items) { + myDialog = GTK_DIALOG(gtk_dialog_new_with_buttons("Launcher Settings", parent, (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), "OK", GTK_RESPONSE_OK, "Cancel", GTK_RESPONSE_CANCEL, NULL)); + + gtk_container_add(GTK_CONTAINER(myDialog->vbox), myList.getWidget()); + + gtk_widget_set_size_request(GTK_WIDGET(myDialog), 540, 257); +} + +SettingsDialog::~SettingsDialog() { + gtk_widget_destroy(GTK_WIDGET(myDialog)); +} + +gint SettingsDialog::run() { + return gtk_dialog_run(myDialog); +} diff --git a/settings-dialog.h b/settings-dialog.h index 2aace19..7a0333a 100644 --- a/settings-dialog.h +++ b/settings-dialog.h @@ -18,4 +18,22 @@ #ifndef __SETTINGS_DIALOG_H_ #define __SETTINGS_DIALOG_H_ +#include + +#include "sla-list.h" +#include "launcher-item.h" + +class SettingsDialog { +public: + SettingsDialog(GtkWindow *, int, LauncherItems&); + ~SettingsDialog(); + + gint run(); + +private: + SLAList myList; + + GtkDialog *myDialog; +}; + #endif diff --git a/simple-launcher.cc b/simple-launcher.cc index 355c181..bc211a4 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -29,6 +29,7 @@ #include "launcher-item.h" #include "sla-list.h" #include "launchable-item.h" +#include "settings-dialog.h" #define SL_APPLET_DBUS_NAME "simple-launcher" #define SL_APPLET_VERSION "0.0" @@ -332,19 +333,9 @@ void SimpleLauncherApplet::runDialog() { LauncherItems newItems = myItems; - SLAList list(SL_APPLET_ICON_SIZE, newItems); + SettingsDialog dialog(myParent, SL_APPLET_ICON_SIZE, newItems); - 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, NULL)); - - gtk_container_add(GTK_CONTAINER(dialog->vbox), list.getWidget()); - - gtk_widget_set_size_request(GTK_WIDGET(dialog), 540, 257); - - int response = gtk_dialog_run(dialog); - - gtk_widget_destroy(GTK_WIDGET(dialog)); - - switch (response) { + switch (dialog.run()) { case GTK_RESPONSE_OK: myItems = newItems; saveConfig(); // save it immediately!