From f8a5c56d73cdbca4c07485b108b0150948cb6f70 Mon Sep 17 00:00:00 2001 From: mishas Date: Wed, 4 Apr 2007 07:36:38 +0000 Subject: [PATCH] Major changes: * buttons are replaced with event boxes Minor changes: * all action areas should have same size git-svn-id: file:///svnroot/simple-launcher/trunk@148 3ba93dab-e023-0410-b42a-de7732cf370a --- debian/changelog | 12 ++++++++++-- simple-launcher.cc | 32 +++++++++++++++++++------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/debian/changelog b/debian/changelog index 549db69..1d58d32 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,18 @@ -simple-launcher (0.9.4~3) unstable; urgency=low +simple-launcher (0.9.4~6) unstable; urgency=low + * NOT RELEASED YET + * settings dialog is moved into a separate class + * added one tab with 'Items' + * fixed a small memory leak * trying different options for gtk buttons * removed top-level GtkFrame * enabled relief for buttons: let's see what happens + * removed extra space around buttons + * request all buttons to be of the same size + * replace buttons with eventboxes + * added proper signal handling for eventboxes - -- Mikhail Sobolev Tue, 3 Apr 2007 20:15:11 +0300 + -- Mikhail Sobolev Wed, 4 Apr 2007 10:33:19 +0300 simple-launcher (0.9.3) unstable; urgency=low diff --git a/simple-launcher.cc b/simple-launcher.cc index 021d8ad..74d561a 100644 --- a/simple-launcher.cc +++ b/simple-launcher.cc @@ -34,8 +34,6 @@ #define SL_APPLET_DBUS_NAME "simple-launcher" #define SL_APPLET_VERSION "0.0" #define SL_APPLET_ICON_SIZE 26 -#define SL_APPLET_BORDER_SIZE 14 -#define SL_APPLET_CANVAS_SIZE (SL_APPLET_BORDER_SIZE+SL_APPLET_BORDER_SIZE) class SimpleLauncherApplet { public: @@ -63,10 +61,10 @@ private: bool initWidget(); void updateWidget(); - void buttonClicked(GtkToolButton *); + void buttonPressed(GtkWidget *button, GdkEventButton *event); void runDialog(); - static void _button_clicked(GtkToolButton *, void *); + static void _button_pressed(GtkWidget *button, GdkEventButton *event, void *self); static void _run_dialog(GtkMenuItem *, void *); private: @@ -250,21 +248,27 @@ bool SimpleLauncherApplet::initWidget() { void SimpleLauncherApplet::updateWidget() { gtk_container_foreach(GTK_CONTAINER(myWidget), (GtkCallback)gtk_widget_destroy, NULL); + GtkSizeGroup *group = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); + int button_no = 0; for (size_t i = 0 ; i < myItems.size() ; ++i) { LauncherItem *item = myItems[i]; if (item != NULL && item->isEnabled()) { - GtkWidget *button = gtk_button_new(); + GtkWidget *button = gtk_event_box_new(); + + gtk_widget_set_events(button, GDK_BUTTON_PRESS_MASK); + g_signal_connect(button, "button-press-event", G_CALLBACK(_button_pressed), this); + gtk_event_box_set_visible_window(GTK_EVENT_BOX(button), false); // gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE); - gtk_button_set_focus_on_click(GTK_BUTTON(button),FALSE); gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_pixbuf(item->getIcon(SL_APPLET_ICON_SIZE))); gtk_object_set_user_data(GTK_OBJECT(button), item); - g_signal_connect(button, "clicked", G_CALLBACK(_button_clicked), this); + + gtk_size_group_add_widget(group, button); gtk_box_pack_start(GTK_BOX(myWidget), GTK_WIDGET(button), false, false, 0); @@ -272,21 +276,23 @@ void SimpleLauncherApplet::updateWidget() { } } + g_object_unref(G_OBJECT(group)); + if (button_no == 0) { - gtk_widget_set_size_request(myWidget, SL_APPLET_ICON_SIZE+SL_APPLET_CANVAS_SIZE, SL_APPLET_ICON_SIZE+SL_APPLET_CANVAS_SIZE); + gtk_widget_set_size_request(myWidget, SL_APPLET_ICON_SIZE, SL_APPLET_ICON_SIZE); } else { - gtk_widget_set_size_request(myWidget, button_no*(SL_APPLET_ICON_SIZE+SL_APPLET_CANVAS_SIZE), SL_APPLET_ICON_SIZE+SL_APPLET_CANVAS_SIZE); + gtk_widget_set_size_request(myWidget, button_no*SL_APPLET_ICON_SIZE, SL_APPLET_ICON_SIZE); } gtk_widget_show_all(myWidget); } -void SimpleLauncherApplet::_button_clicked(GtkToolButton *button, void *self) { - ((SimpleLauncherApplet *)self)->buttonClicked(button); +void SimpleLauncherApplet::_button_pressed(GtkWidget *button, GdkEventButton *event, void *self) { + ((SimpleLauncherApplet *)self)->buttonPressed(button, event); } -void SimpleLauncherApplet::buttonClicked(GtkToolButton *button) { - if (button != NULL) { +void SimpleLauncherApplet::buttonPressed(GtkWidget *button, GdkEventButton *event) { + if (button != NULL && event->button == 1) { LaunchableItem *item = (LaunchableItem *)gtk_object_get_user_data(GTK_OBJECT(button)); if (item != NULL) { -- 1.7.9.5