diff options
Diffstat (limited to 'applets')
-rw-r--r-- | applets/launcher/nautilus-launcher-applet.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/applets/launcher/nautilus-launcher-applet.c b/applets/launcher/nautilus-launcher-applet.c index 520739915..277eaeeb7 100644 --- a/applets/launcher/nautilus-launcher-applet.c +++ b/applets/launcher/nautilus-launcher-applet.c @@ -21,6 +21,7 @@ #include <config.h> #include <applet-widget.h> #include <libnautilus-extensions/nautilus-image.h> +#include <libnautilus-extensions/nautilus-buffered-widget.h> #include <libnautilus-extensions/nautilus-graphic-effects.h> #include <libgnome/gnome-exec.h> #include <gtk/gtkobject.h> @@ -29,6 +30,8 @@ #include <gdk/gdkprivate.h> #define ICON_NAME "nautilus-launch-icon.png" +#define VERTICAL_OFFSET 2 +#define HORIZONTAL_OFFSET 2 static GdkPixbuf *icon_pixbuf = NULL; static GdkPixbuf *icon_prelight_pixbuf = NULL; @@ -78,6 +81,9 @@ image_leave_event (GtkWidget *event_box, g_return_val_if_fail (NAUTILUS_IS_IMAGE (client_data), TRUE); nautilus_image_set_pixbuf (NAUTILUS_IMAGE (client_data), icon_pixbuf); + gtk_object_set_data (GTK_OBJECT (event_box), "was-pressed", FALSE); + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (client_data), 0); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (client_data), 0); return TRUE; } @@ -120,25 +126,52 @@ image_button_press_event (GtkWidget *event_box, GdkEventButton *event, gpointer client_data) { + GtkWidget *icon = GTK_WIDGET (client_data); + + g_return_val_if_fail (GTK_IS_EVENT_BOX (event_box), TRUE); + g_return_val_if_fail (NAUTILUS_IS_IMAGE (icon), TRUE); + + gtk_object_set_data (GTK_OBJECT (event_box), "was-pressed", GINT_TO_POINTER (TRUE)); + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (icon), VERTICAL_OFFSET); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (icon), HORIZONTAL_OFFSET); + + return TRUE; +} + +static gint +image_button_release_event (GtkWidget *event_box, + GdkEventButton *event, + gpointer client_data) +{ char *path; gint pid; + GtkWidget *icon = GTK_WIDGET (client_data); + gboolean was_pressed; g_return_val_if_fail (GTK_IS_EVENT_BOX (event_box), TRUE); - g_return_val_if_fail (NAUTILUS_IS_IMAGE (client_data), TRUE); + g_return_val_if_fail (NAUTILUS_IS_IMAGE (icon), TRUE); - path = g_strdup_printf ("%s/%s", BINDIR, "run-nautilus"); + was_pressed = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (event_box), "was-pressed")); + if (was_pressed) { + gtk_object_set_data (GTK_OBJECT (event_box), "was-pressed", FALSE); + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (icon), 0); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (icon), 0); - pid = gnome_execute_async (NULL, 1, &path); + path = g_strdup_printf ("%s/%s", BINDIR, "run-nautilus"); + + pid = gnome_execute_async (NULL, 1, &path); + + if (pid != 0) { + //root_window_set_busy (); + } - if (pid != 0) { - //root_window_set_busy (); + g_free (path); } - g_free (path); - return TRUE; } + int main (int argc, char **argv) { @@ -160,12 +193,18 @@ main (int argc, char **argv) create_pixbufs (); event_box = gtk_event_box_new (); + gtk_object_set_data (GTK_OBJECT (event_box), "was-pressed", FALSE); icon = nautilus_image_new (); + gtk_misc_set_padding (GTK_MISC (icon), 2, 2); + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (icon), 0); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (icon), 0); + gtk_signal_connect (GTK_OBJECT (event_box), "enter_notify_event", GTK_SIGNAL_FUNC (image_enter_event), icon); gtk_signal_connect (GTK_OBJECT (event_box), "leave_notify_event", GTK_SIGNAL_FUNC (image_leave_event), icon); gtk_signal_connect (GTK_OBJECT (event_box), "button_press_event", GTK_SIGNAL_FUNC (image_button_press_event), icon); + gtk_signal_connect (GTK_OBJECT (event_box), "button_release_event", GTK_SIGNAL_FUNC (image_button_release_event), icon); nautilus_image_set_pixbuf (NAUTILUS_IMAGE (icon), icon_pixbuf); //nautilus_image_set_pixbuf (NAUTILUS_IMAGE (icon), icon_prelight_pixbuf); |