From b226d70d48daa29ec7a045bb5cb5a47efde1f11a Mon Sep 17 00:00:00 2001 From: mss Date: Wed, 6 Dec 2006 09:46:51 +0000 Subject: [PATCH] * #define-ed icon size instead of using a constant * count buttons we managed to create * request applet size to be set based on the amount of found buttons * decorated frame with some border (let's see how it looks) git-svn-id: file:///svnroot/simple-launcher/trunk@24 3ba93dab-e023-0410-b42a-de7732cf370a --- simple-launcher.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/simple-launcher.cc b/simple-launcher.cc index bee53a4..0a0e04a 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -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 4 +#define SLA_APPLET_CANVAS_SIZE (SLA_APPLET_BORDER_SIZE+SLA_APPLET_BORDER_SIZE) class SimpleLauncherApplet { public: @@ -152,24 +155,30 @@ SimpleLauncherApplet::~SimpleLauncherApplet() { } bool SimpleLauncherApplet::initWidget() { - bool have_buttons = false; + int button_no = 0; GtkToolbar *toolbar = GTK_TOOLBAR(gtk_toolbar_new()); for (std::vector::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(toolbar, button, -1); - have_buttons = true; + ++button_no; } - if (have_buttons) { + if (button_no) { myWidget = gtk_frame_new(0); - +#if 0 + 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)); -- 1.7.9.5