tests: test test1 test2
-$(TARGET): simple-launcher.o launchable-item.o launcher-item.o sla-list.o utils.o settings-dialog.o gconf-wrapper.o dialog-entry.o
+$(TARGET): simple-launcher.o launchable-item.o launcher-item.o sla-list.o utils.o settings-dialog.o gconf-wrapper.o dialog-entry.o settings-page-entries.o
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
test: test.o launcher-item.o
-simple-launcher (0.9.4~14) unstable; urgency=low
+simple-launcher (0.9.4~15) unstable; urgency=low
* NOT RELEASED YET
* settings dialog is moved into a separate class
* added dummy checkboxes and UI settings page
* added a configurable canvas around button icons
* added GConf*Options to SimpleLauncherApplet
+ * major refactoring of the settings dialog
+ * SLAList class is renamed to SettingsPageWithItems (file names will follow)
- -- Mikhail Sobolev <mss@mawhrin.net> Thu, 12 Apr 2007 15:54:04 +0300
+ -- Mikhail Sobolev <mss@mawhrin.net> Sat, 14 Apr 2007 20:05:45 +0300
simple-launcher (0.9.3) unstable; urgency=low
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#include <gtk/gtkcheckbutton.h>
+
#include "dialog-entry.h"
+SettingsDialogBooleanEntry::SettingsDialogBooleanEntry(GConfBooleanOption& option, const std::string& name): SettingsDialogEntry(option, name) {
+ myWidget = gtk_check_button_new();
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(myWidget), option.value());
+}
+
+void SettingsDialogBooleanEntry::updateValue() {
+ ((GConfBooleanOption&)myOption).setValue(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(myWidget)));
+}
+
+SettingsDialogIntegerEntry::SettingsDialogIntegerEntry(GConfIntegerOption& option, const std::string& name, int minValue, int maxValue): SettingsDialogEntry(option, name) {
+ mySpinBox = HILDON_NUMBER_EDITOR(hildon_number_editor_new(minValue, maxValue));
+ hildon_number_editor_set_value(mySpinBox, option.value());
+}
+void SettingsDialogIntegerEntry::updateValue() {
+ ((GConfIntegerOption&)myOption).setValue(hildon_number_editor_get_value(mySpinBox));
+}
#ifndef _DIALOG_ENTRY_H_
#define _DIALOG_ENTRY_H_
+#include <gtk/gtkwidget.h>
+
+#include <hildon-widgets/hildon-number-editor.h>
+
#include "gconf-wrapper.h"
class SettingsDialogEntry {
public:
virtual ~SettingsDialogEntry() {}
-protected:
- SettingsDialogEntry(GConfOption& option, const std::string& name): myOption(option), myName(name) {}
-
const std::string& name() const { return myName; }
+ virtual GtkWidget *getWidget() const = 0;
virtual void updateValue() = 0;
protected:
+ SettingsDialogEntry(GConfOption& option, const std::string& name): myOption(option), myName(name) {}
+
+protected:
GConfOption& myOption;
const std::string myName;
};
SettingsDialogStringEntry(GConfStringOption& option, const std::string& name): SettingsDialogEntry(option, name) {}
void updateValue();
+ GtkWidget *getWidget() const;
};
class SettingsDialogBooleanEntry : public SettingsDialogEntry {
public:
- SettingsDialogBooleanEntry(GConfBooleanOption& option, const std::string& name): SettingsDialogEntry(option, name) {}
+ SettingsDialogBooleanEntry(GConfBooleanOption& option, const std::string& name);
+
+ void updateValue();
+ GtkWidget *getWidget() const { return myWidget; }
- void updateValue() {}
+private:
+ GtkWidget *myWidget;
};
class SettingsDialogIntegerEntry : public SettingsDialogEntry {
public:
- SettingsDialogIntegerEntry(GConfIntegerOption& option, const std::string& name): SettingsDialogEntry(option, name) {}
+ SettingsDialogIntegerEntry(GConfIntegerOption& option, const std::string& name, int minValue, int maxValue);
+
+ void updateValue();
+ GtkWidget *getWidget() const { return GTK_WIDGET(mySpinBox); }
- void updateValue() {}
+private:
+ HildonNumberEditor *mySpinBox;
};
#endif
// this program; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtksizegroup.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtklabel.h>
-#include <gtk/gtkcheckbutton.h>
#include "settings-dialog.h"
+#include "settings-page-entries.h"
#define SL_APPLET_SETTINGS_ICON_SIZE 26
-// FIXME: UGLY!!!!
+SettingsDialog::SettingsDialog(GtkWindow *parent, LauncherItems& items, GConfBooleanOption& transparent, GConfIntegerOption& icon_size):
+ myTransparent(transparent, "Transparent background:"),
+ myIconSize(icon_size, "Icon Size:", 26, 64) {
+ 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));
-inline void addPage(GtkNotebook *notebook, const std::string& name, GtkWidget *widget) {
- GtkWidget *label = gtk_label_new(name.c_str());
+ myNotebook = GTK_NOTEBOOK(gtk_notebook_new());
- gtk_notebook_append_page(notebook, widget, label);
-}
+ gtk_container_add(GTK_CONTAINER(myDialog->vbox), GTK_WIDGET(myNotebook));
-inline GtkWidget *packItTogether(GtkBox *parent, GtkSizeGroup *group, const std::string& name, GtkWidget *content) {
- GtkWidget *box = gtk_hbox_new(false, 0);
- GtkWidget *label = gtk_label_new(name.c_str());
+ SettingsPageWithEntries *uiPage = new SettingsPageWithEntries();
+ uiPage->addEntry(&myTransparent);
+ uiPage->addEntry(&myIconSize);
- gtk_size_group_add_widget(group, label);
- gtk_box_pack_start(GTK_BOX(box), label, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), content, true, true, 0);
+ SettingsPageWithItems *itemsPage = new SettingsPageWithItems(SL_APPLET_SETTINGS_ICON_SIZE, items);
- gtk_box_pack_start(parent, box, false, false, 0);
+ addPage("UI", uiPage);
+ addPage("Items", itemsPage);
- return box;
+ gtk_widget_set_size_request(GTK_WIDGET(myDialog), 540, 324);
}
-inline GtkWidget *createUIPage() {
- GtkSizeGroup *group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- GtkWidget *vbox = gtk_vbox_new(true, 0);
-
- // packItTogether(group, "Button Size:", <small/big>);
- packItTogether(GTK_BOX(vbox), group, "Transparent background:", gtk_check_button_new());
- packItTogether(GTK_BOX(vbox), group, "Show Infobanner:", gtk_check_button_new());
+SettingsDialog::~SettingsDialog() {
+ for (std::vector<SettingsPage *>::iterator it = myPages.begin(); it != myPages.end() ; ++it) {
+ delete *it;
+ }
- g_object_unref(G_OBJECT(group));
+ myPages.resize(0);
- return vbox;
+ gtk_widget_destroy(GTK_WIDGET(myDialog));
}
-SettingsDialog::SettingsDialog(GtkWindow *parent, LauncherItems& items, GConfBooleanOption& transparent, GConfIntegerOption& icon_size):
- myList(SL_APPLET_SETTINGS_ICON_SIZE, items),
- myTransparent(transparent, "Transparent background:"), myIconSize(icon_size, "Icon Size:") {
- 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));
-
- GtkNotebook *notebook = GTK_NOTEBOOK(gtk_notebook_new());
-
- gtk_container_add(GTK_CONTAINER(myDialog->vbox), GTK_WIDGET(notebook));
-
- addPage(notebook, "UI", createUIPage());
- addPage(notebook, "Items", myList.getWidget());
-
- gtk_widget_set_size_request(GTK_WIDGET(myDialog), 540, 324);
+void SettingsDialog::addPage(const std::string& name, SettingsPage *page) {
+ myPages.push_back(page);
- gtk_widget_show_all(GTK_WIDGET(notebook));
- gtk_notebook_set_current_page(notebook, 0);
-}
+ GtkWidget *label = gtk_label_new(name.c_str());
-SettingsDialog::~SettingsDialog() {
- gtk_widget_destroy(GTK_WIDGET(myDialog));
+ gtk_notebook_append_page(myNotebook, page->getWidget(), label);
}
gint SettingsDialog::run() {
gtk_widget_show_all(GTK_WIDGET(myDialog));
+ gtk_notebook_set_current_page(myNotebook, 0);
return gtk_dialog_run(myDialog);
}
#ifndef __SETTINGS_DIALOG_H_
#define __SETTINGS_DIALOG_H_
+#include <vector>
+
#include <gtk/gtkdialog.h>
#include "gconf-wrapper.h"
#include "sla-list.h"
#include "launcher-item.h"
#include "dialog-entry.h"
+#include "settings-page.h"
class SettingsDialog {
public:
void updateValues();
+ void addPage(const std::string&, SettingsPage *);
+
private:
- SLAList myList;
+ std::vector<SettingsPage *> myPages;
GtkDialog *myDialog;
+ GtkNotebook *myNotebook;
SettingsDialogBooleanEntry myTransparent;
SettingsDialogIntegerEntry myIconSize;
--- /dev/null
+// This file is a part of Simple Launcher
+//
+// Copyright (C) 2006, 2007, 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 <gtk/gtkvbox.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+
+#include "settings-page-entries.h"
+
+SettingsPageWithEntries::SettingsPageWithEntries() {
+ myBox = gtk_vbox_new(false, 0);
+ myGroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+}
+
+SettingsPageWithEntries::~SettingsPageWithEntries() {
+ if (myGroup != NULL) {
+ g_object_unref(G_OBJECT(myGroup));
+ myGroup = NULL;
+ }
+}
+
+void SettingsPageWithEntries::addEntry(SettingsDialogEntry *entry) {
+ GtkWidget *box = gtk_hbox_new(false, 0);
+ GtkWidget *label = gtk_label_new(entry->name().c_str());
+
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
+
+ gtk_size_group_add_widget(myGroup, label);
+ gtk_box_pack_start(GTK_BOX(box), label, false, false, 0);
+ gtk_box_pack_start(GTK_BOX(box), entry->getWidget(), false, false, 2);
+
+ gtk_box_pack_start(GTK_BOX(myBox), box, false, false, 0);
+}
--- /dev/null
+// This file is a part of Simple Launcher
+//
+// Copyright (C) 2006, 2007, 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
+
+#ifndef _SETTINGS_PAGE_ENTRIES_H_
+#define _SETTINGS_PAGE_ENTRIES_H_
+
+#include <gtk/gtksizegroup.h>
+
+#include "dialog-entry.h"
+#include "settings-page.h"
+
+class SettingsPageWithEntries : public SettingsPage {
+public:
+ SettingsPageWithEntries();
+ ~SettingsPageWithEntries();
+
+ GtkWidget *getWidget() const { return myBox; }
+
+ void addEntry(SettingsDialogEntry *);
+
+private:
+ GtkWidget *myBox;
+ GtkSizeGroup *myGroup;
+};
+
+#endif
+
+// vim:ts=2:sw=2:et
--- /dev/null
+// This file is a part of Simple Launcher
+//
+// Copyright (C) 2006, 2007, 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
+
+#ifndef _SETTINGS_PAGE_H_
+#define _SETTINGS_PAGE_H_
+
+#include <gtk/gtkwidget.h>
+
+class SettingsPage {
+public:
+ virtual ~SettingsPage() {}
+
+ virtual GtkWidget *getWidget() const = 0;
+};
+
+#endif
+
+// vim:ts=2:sw=2:et
return button;
}
-SLAList::SLAList(int icon_size, LauncherItems& items): myWidget(NULL), myStore(NULL), myView(NULL), mySelection(NULL), myLastSelection(NULL), myItems(items) {
+SettingsPageWithItems::SettingsPageWithItems(int icon_size, LauncherItems& items): myWidget(NULL), myStore(NULL), myView(NULL), mySelection(NULL), myLastSelection(NULL), myItems(items) {
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
}
}
-SLAList::~SLAList() {
+SettingsPageWithItems::~SettingsPageWithItems() {
// FIXME: do something! :)
}
-void SLAList::_selectionChanged(GtkTreeSelection *selection, void *self) {
- ((SLAList *)self)->selectionChanged(selection);
+void SettingsPageWithItems::_selectionChanged(GtkTreeSelection *selection, void *self) {
+ ((SettingsPageWithItems *)self)->selectionChanged(selection);
}
-void SLAList::selectionChanged(GtkTreeSelection *) {
+void SettingsPageWithItems::selectionChanged(GtkTreeSelection *) {
if (myLastSelection != NULL) {
kickIt(myLastSelection);
gtk_tree_iter_free(myLastSelection);
}
}
-void SLAList::kickIt(GtkTreeIter *iter) {
+void SettingsPageWithItems::kickIt(GtkTreeIter *iter) {
GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(myStore), iter);
if (path != NULL) {
}
}
-void SLAList::_renderText(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer self) {
- ((SLAList *)self)->renderText(column, cell, model, iter);
+void SettingsPageWithItems::_renderText(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer self) {
+ ((SettingsPageWithItems *)self)->renderText(column, cell, model, iter);
}
-void SLAList::_renderBool(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer self) {
- ((SLAList *)self)->renderBool(column, cell, model, iter);
+void SettingsPageWithItems::_renderBool(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer self) {
+ ((SettingsPageWithItems *)self)->renderBool(column, cell, model, iter);
}
-void SLAList::_toggleBool(GtkCellRendererToggle *renderer, const gchar *path, void *self) {
- ((SLAList *)self)->toggleBool(renderer, path);
+void SettingsPageWithItems::_toggleBool(GtkCellRendererToggle *renderer, const gchar *path, void *self) {
+ ((SettingsPageWithItems *)self)->toggleBool(renderer, path);
}
-void SLAList::_moveUp(GtkButton *button, void *self) {
- ((SLAList *)self)->moveUp(button);
+void SettingsPageWithItems::_moveUp(GtkButton *button, void *self) {
+ ((SettingsPageWithItems *)self)->moveUp(button);
}
-void SLAList::_moveDown(GtkButton *button, void *self) {
- ((SLAList *)self)->moveDown(button);
+void SettingsPageWithItems::_moveDown(GtkButton *button, void *self) {
+ ((SettingsPageWithItems *)self)->moveDown(button);
}
-void SLAList::renderText(GtkTreeViewColumn *, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter) {
+void SettingsPageWithItems::renderText(GtkTreeViewColumn *, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter) {
int index;
gtk_tree_model_get(GTK_TREE_MODEL(myStore), iter, SLA_STORE_COLUMN_INDEX, &index, -1);
}
}
-void SLAList::renderBool(GtkTreeViewColumn *, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter) {
+void SettingsPageWithItems::renderBool(GtkTreeViewColumn *, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter) {
int index;
gtk_tree_model_get(GTK_TREE_MODEL(myStore), iter, SLA_STORE_COLUMN_INDEX, &index, -1);
g_object_set(cell, "active", myItems[index]->isEnabled(), NULL);
}
-void SLAList::toggleBool(GtkCellRendererToggle *renderer, const gchar *spath) {
+void SettingsPageWithItems::toggleBool(GtkCellRendererToggle *renderer, const gchar *spath) {
GtkTreeIter iter;
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(myStore), &iter, spath)) {
}
}
-void SLAList::moveUp(GtkButton *) {
+void SettingsPageWithItems::moveUp(GtkButton *) {
GtkTreeModel *dummy;
GtkTreeIter current;
}
}
-void SLAList::moveDown(GtkButton *) {
+void SettingsPageWithItems::moveDown(GtkButton *) {
GtkTreeModel *dummy;
GtkTreeIter current;
}
}
-void SLAList::swap(GtkTreeIter& a, GtkTreeIter& b) {
+void SettingsPageWithItems::swap(GtkTreeIter& a, GtkTreeIter& b) {
int i1, i2;
gtk_tree_model_get(GTK_TREE_MODEL(myStore), &a, SLA_STORE_COLUMN_INDEX, &i1, -1);
#include <gtk/gtkcellrenderertoggle.h>
#include "launcher-item.h"
+#include "settings-page.h"
-class SLAList {
+class SettingsPageWithItems : public SettingsPage {
public:
- SLAList(int, LauncherItems&);
- ~SLAList();
+ SettingsPageWithItems(int, LauncherItems&);
+ ~SettingsPageWithItems();
- GtkWidget *getWidget() { return myWidget; }
+ GtkWidget *getWidget() const { return myWidget; }
+
+ void updateValues();
private:
static void _selectionChanged(GtkTreeSelection *, gpointer);