summaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
authorMathieu Lacage <mathieu@eazel.com>2000-11-01 06:13:42 +0000
committerMathieu Lacage <mathieu@src.gnome.org>2000-11-01 06:13:42 +0000
commit8b2d11a4d52ba8bd858c82531e9866fda80fe4e3 (patch)
tree1b5f358ea20032bb1ad32e793fffdd7a30dd31d8 /applets
parent706a8bd5183026a30ed2d4107b78b873f157c902 (diff)
downloadnautilus-8b2d11a4d52ba8bd858c82531e9866fda80fe4e3.tar.gz
This is completely useless but I needed a break from "usefull" bugs. Add
2000-11-01 Mathieu Lacage <mathieu@eazel.com> This is completely useless but I needed a break from "usefull" bugs. * applets/launcher/nautilus-launcher-applet.c: (image_leave_event), (image_button_press_event), (image_button_release_event), (main): Add an event handler for release event to make sure we launch nautilus only if you release the cursor without leaving the icon. Add an offset when you click to give the user feedback about what he is doing. * libnautilus-extensions/nautilus-image.c: (render_buffer_pixbuf): Fix offset problem when drawing image: the offset was not taken into account in the calculation of the x and y coordinates.
Diffstat (limited to 'applets')
-rw-r--r--applets/launcher/nautilus-launcher-applet.c53
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);