1
1

1999-06-14 Federico Mena Quintero <federico@nuclecu.unam.mx>

* gdesktop.c (icon_is_in_area): Fixed off-by-one error in
	intersection computation.

	* gdesktop-icon.c (desktop_icon_reshape): Set the correct values
	for dicon->text_x and dicon->text_y.
Этот коммит содержится в:
Miguel de Icaza 1999-06-14 22:50:45 +00:00
родитель 386c434f73
Коммит b24460e51c
3 изменённых файлов: 64 добавлений и 55 удалений

Просмотреть файл

@ -1,3 +1,11 @@
1999-06-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.c (icon_is_in_area): Fixed off-by-one error in
intersection computation.
* gdesktop-icon.c (desktop_icon_reshape): Set the correct values
for dicon->text_x and dicon->text_y.
1999-06-11 Federico Mena Quintero <federico@nuclecu.unam.mx> 1999-06-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gwidget.c (x_update_input): Unblock the changed signal *after* * gwidget.c (x_update_input): Unblock the changed signal *after*

Просмотреть файл

@ -417,6 +417,8 @@ desktop_icon_reshape (DesktopIcon *dicon)
dicon->icon_w = icon_width; dicon->icon_w = icon_width;
dicon->icon_h = icon_height; dicon->icon_h = icon_height;
gnome_canvas_item_get_bounds (dicon->text, &x1, &y1, &x2, &y2);
dicon->text_x = x1; dicon->text_x = x1;
dicon->text_y = y1; dicon->text_y = y1;
dicon->text_w = text_width; dicon->text_w = text_width;

Просмотреть файл

@ -287,7 +287,7 @@ desktop_icon_info_place (DesktopIconInfo *dii, int xpos, int ypos)
layout_slots[dii->slot].icons = g_list_append (layout_slots[dii->slot].icons, dii); layout_slots[dii->slot].icons = g_list_append (layout_slots[dii->slot].icons, dii);
/* Move the icon */ /* Move the icon */
dii->x = xpos; dii->x = xpos;
dii->y = ypos; dii->y = ypos;
gtk_widget_set_uposition (dii->dicon, xpos, ypos); gtk_widget_set_uposition (dii->dicon, xpos, ypos);
@ -377,7 +377,7 @@ update_url (DesktopIconInfo *dii)
char *caption = NULL; char *caption = NULL;
char *url = NULL; char *url = NULL;
int size; int size;
gnome_metadata_get (fullname, "icon-caption", &size, &caption); gnome_metadata_get (fullname, "icon-caption", &size, &caption);
if (caption){ if (caption){
desktop_icon_set_text (DESKTOP_ICON (dii->dicon), caption); desktop_icon_set_text (DESKTOP_ICON (dii->dicon), caption);
@ -390,7 +390,7 @@ update_url (DesktopIconInfo *dii)
g_free (dii->url); g_free (dii->url);
dii->url = url; dii->url = url;
} }
g_free (fullname); g_free (fullname);
} }
@ -438,7 +438,7 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
need_position_list = NULL; need_position_list = NULL;
all_icons = get_all_icons (); all_icons = get_all_icons ();
while ((dirent = mc_readdir (dir)) != NULL) { while ((dirent = mc_readdir (dir)) != NULL) {
/* Skip . and .. */ /* Skip . and .. */
@ -471,7 +471,7 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
/* Leave the icon in the desktop by removing it from the list */ /* Leave the icon in the desktop by removing it from the list */
all_icons = g_list_remove_link (all_icons, l); all_icons = g_list_remove_link (all_icons, l);
continue; continue;
} }
@ -483,7 +483,7 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
caption = NULL; caption = NULL;
gnome_metadata_get (full_name, "icon-caption", &size, &caption); gnome_metadata_get (full_name, "icon-caption", &size, &caption);
if (have_pos) { if (have_pos) {
dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, x, y); dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, x, y);
gtk_widget_show (dii->dicon); gtk_widget_show (dii->dicon);
@ -500,7 +500,7 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
} }
g_free (full_name); g_free (full_name);
if (desktop_url) if (desktop_url)
g_free (desktop_url); g_free (desktop_url);
@ -959,18 +959,18 @@ is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
{ {
char buffer [128], *p; char buffer [128], *p;
int len; int len;
if (point) if (point)
*point = NULL; *point = NULL;
if (!S_ISLNK (fe->buf.st_mode)) if (!S_ISLNK (fe->buf.st_mode))
return FALSE; return FALSE;
len = readlink (filename, buffer, sizeof (buffer)); len = readlink (filename, buffer, sizeof (buffer));
if (len == -1) if (len == -1)
return FALSE; return FALSE;
buffer [len] = 0; buffer [len] = 0;
p = is_block_device_mountable (buffer); p = is_block_device_mountable (buffer);
if (!p) if (!p)
return FALSE; return FALSE;
@ -979,9 +979,9 @@ is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
*point = p; *point = p;
else else
g_free (point); g_free (point);
*is_mounted = is_block_device_mounted (buffer); *is_mounted = is_block_device_mounted (buffer);
return TRUE; return TRUE;
} }
@ -992,7 +992,7 @@ do_mount_umount (char *filename, gboolean is_mount)
static char *umount_command; static char *umount_command;
char *op; char *op;
char *buffer; char *buffer;
if (is_mount){ if (is_mount){
if (!mount_command) if (!mount_command)
mount_command = find_command (mount_known_locations); mount_command = find_command (mount_known_locations);
@ -1006,21 +1006,21 @@ do_mount_umount (char *filename, gboolean is_mount)
buffer = g_readlink (filename); buffer = g_readlink (filename);
if (buffer == NULL) if (buffer == NULL)
return FALSE; return FALSE;
if (op){ if (op){
gboolean success = TRUE; gboolean success = TRUE;
char *command; char *command;
FILE *f; FILE *f;
command = g_strconcat (op, " ", buffer, NULL); command = g_strconcat (op, " ", buffer, NULL);
open_error_pipe (); open_error_pipe ();
f = popen (command, "r"); f = popen (command, "r");
if (f == NULL){ if (f == NULL){
success = !close_error_pipe (1, _("While running the mount/umount command")); success = !close_error_pipe (1, _("While running the mount/umount command"));
} else } else
success = !close_error_pipe (0, 0); success = !close_error_pipe (0, 0);
pclose (f); pclose (f);
g_free (buffer); g_free (buffer);
return success; return success;
} }
@ -1041,7 +1041,7 @@ static char *eject_known_locations [] = {
* Right now the test only checks if this system has the eject * Right now the test only checks if this system has the eject
* command * command
*/ */
gboolean gboolean
is_ejectable (char *filename) is_ejectable (char *filename)
{ {
char *buf; char *buf;
@ -1057,7 +1057,7 @@ is_ejectable (char *filename)
if (retval) if (retval)
return TRUE; return TRUE;
} }
if (find_command (eject_known_locations)) if (find_command (eject_known_locations))
return TRUE; return TRUE;
else else
@ -1098,7 +1098,7 @@ static gboolean
try_to_mount (char *filename, file_entry *fe) try_to_mount (char *filename, file_entry *fe)
{ {
int x; int x;
if (!is_mountable (filename, fe, &x, NULL)) if (!is_mountable (filename, fe, &x, NULL))
return FALSE; return FALSE;
@ -1201,7 +1201,7 @@ push_desktop_panel_hack (void)
{ {
WPanel *panel; WPanel *panel;
PanelContainer *container; PanelContainer *container;
panel = create_panel_from_desktop (); panel = create_panel_from_desktop ();
container = g_new (PanelContainer, 1); container = g_new (PanelContainer, 1);
container->splitted = FALSE; container->splitted = FALSE;
@ -1229,7 +1229,7 @@ free_panel_from_desktop (WPanel *panel)
for (i = 0; i < panel->count; i++) for (i = 0; i < panel->count; i++)
g_free (panel->dir.list[i].fname); g_free (panel->dir.list[i].fname);
if (panel->dir.list) if (panel->dir.list)
g_free (panel->dir.list); g_free (panel->dir.list);
@ -1239,7 +1239,7 @@ free_panel_from_desktop (WPanel *panel)
/** /**
* desktop_icon_info_open: * desktop_icon_info_open:
* @dii: The desktop icon to open. * @dii: The desktop icon to open.
* *
* Opens the specified desktop icon when the user double-clicks on it. * Opens the specified desktop icon when the user double-clicks on it.
**/ **/
void void
@ -1281,7 +1281,7 @@ desktop_icon_info_open (DesktopIconInfo *dii)
launch = FALSE; launch = FALSE;
} else } else
launch = TRUE; launch = TRUE;
if (launch) if (launch)
new_panel_at (point); new_panel_at (point);
g_free (point); g_free (point);
@ -1319,7 +1319,7 @@ desktop_icon_info_delete (DesktopIconInfo *dii)
ctx = file_op_context_new (); ctx = file_op_context_new ();
file_op_context_create_ui (ctx, OP_DELETE, TRUE); file_op_context_create_ui (ctx, OP_DELETE, TRUE);
x_flush_events (); x_flush_events ();
full_name = g_concat_dir_and_file (desktop_directory, dii->filename); full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
if (lstat (full_name, &s) != -1) { if (lstat (full_name, &s) != -1) {
@ -1346,7 +1346,7 @@ desktop_icon_info_delete (DesktopIconInfo *dii)
* desktop_icon_set_busy: * desktop_icon_set_busy:
* @dii: A desktop icon * @dii: A desktop icon
* @busy: TRUE to set a watch cursor, FALSE to reset the normal arrow cursor * @busy: TRUE to set a watch cursor, FALSE to reset the normal arrow cursor
* *
* Sets a wait/normal cursor for a desktop icon. * Sets a wait/normal cursor for a desktop icon.
**/ **/
void void
@ -1368,10 +1368,10 @@ desktop_icon_set_busy (DesktopIconInfo *dii, int busy)
/** /**
* desktop_icon_info_get_by_filename: * desktop_icon_info_get_by_filename:
* @filename: A filename relative to the desktop directory * @filename: A filename relative to the desktop directory
* *
* Returns the desktop icon structure that corresponds to the specified filename, * Returns the desktop icon structure that corresponds to the specified filename,
* which should be relative to the desktop directory. * which should be relative to the desktop directory.
* *
* Return value: The sought desktop icon, or NULL if it is not found. * Return value: The sought desktop icon, or NULL if it is not found.
**/ **/
DesktopIconInfo * DesktopIconInfo *
@ -1940,7 +1940,7 @@ desktop_icon_info_new (char *filename, char *url, char *caption, int xpos, int y
fe = file_entry_from_file (full_name); fe = file_entry_from_file (full_name);
if (!fe) if (!fe)
return NULL; return NULL;
dii = g_new (DesktopIconInfo, 1); dii = g_new (DesktopIconInfo, 1);
dii->x = 0; dii->x = 0;
dii->y = 0; dii->y = 0;
@ -1955,12 +1955,12 @@ desktop_icon_info_new (char *filename, char *url, char *caption, int xpos, int y
if (caption == NULL) if (caption == NULL)
caption = filename; caption = filename;
} }
icon_im = gicon_get_icon_for_file (desktop_directory, fe, FALSE); icon_im = gicon_get_icon_for_file (desktop_directory, fe, FALSE);
dii->dicon = desktop_icon_new (icon_im, caption); dii->dicon = desktop_icon_new (icon_im, caption);
dii->filename = g_strdup (filename); dii->filename = g_strdup (filename);
dii->selected = FALSE; dii->selected = FALSE;
file_entry_free (fe); file_entry_free (fe);
g_free (full_name); g_free (full_name);
@ -2073,7 +2073,7 @@ typedef struct {
} MotifDragReceiverInfo; } MotifDragReceiverInfo;
/* Sets up a proxy window for DnD on the specified X window. Courtesy of Owen Taylor */ /* Sets up a proxy window for DnD on the specified X window. Courtesy of Owen Taylor */
static gboolean static gboolean
setup_xdnd_proxy (guint32 xid, GdkWindow *proxy_window) setup_xdnd_proxy (guint32 xid, GdkWindow *proxy_window)
{ {
GdkAtom xdnd_proxy_atom; GdkAtom xdnd_proxy_atom;
@ -2116,10 +2116,10 @@ setup_xdnd_proxy (guint32 xid, GdkWindow *proxy_window)
* has a XdndProxy property pointing to itself. * has a XdndProxy property pointing to itself.
*/ */
if (proxy) { if (proxy) {
XGetWindowProperty (GDK_DISPLAY (), proxy, XGetWindowProperty (GDK_DISPLAY (), proxy,
xdnd_proxy_atom, 0, xdnd_proxy_atom, 0,
1, False, AnyPropertyType, 1, False, AnyPropertyType,
&type, &format, &nitems, &after, &type, &format, &nitems, &after,
(guchar **) &proxy_data); (guchar **) &proxy_data);
if (!gdk_error_code && type != None) { if (!gdk_error_code && type != None) {
@ -2143,7 +2143,7 @@ setup_xdnd_proxy (guint32 xid, GdkWindow *proxy_window)
gdk_error_code = 0; gdk_error_code = 0;
gdk_error_warnings = old_warnings; gdk_error_warnings = old_warnings;
XUngrabServer (GDK_DISPLAY ()); XUngrabServer (GDK_DISPLAY ());
gdk_flush (); gdk_flush ();
@ -2471,7 +2471,7 @@ desktop_popup (GdkEventButton *event)
panel = push_desktop_panel_hack (); panel = push_desktop_panel_hack ();
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, NULL); gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, NULL);
layout_panel_gone (panel); layout_panel_gone (panel);
free_panel_from_desktop (panel); free_panel_from_desktop (panel);
gtk_widget_destroy (popup); gtk_widget_destroy (popup);
desktop_reload_icons (FALSE, 0, 0); desktop_reload_icons (FALSE, 0, 0);
@ -2498,7 +2498,7 @@ draw_rubberband (int x, int y)
y1 = y; y1 = y;
y2 = click_start_y; y2 = click_start_y;
} }
gdk_draw_rectangle (GDK_ROOT_PARENT (), click_gc, FALSE, x1, y1, x2 - x1, y2 - y1); gdk_draw_rectangle (GDK_ROOT_PARENT (), click_gc, FALSE, x1, y1, x2 - x1, y2 - y1);
} }
@ -2524,7 +2524,7 @@ store_temp_selection (void)
/** /**
* icon_is_in_area: * icon_is_in_area:
* @dii: the desktop icon information * @dii: the desktop icon information
* *
* Returns TRUE if the specified icon is at least partially inside the specified * Returns TRUE if the specified icon is at least partially inside the specified
* area, or FALSE otherwise. * area, or FALSE otherwise.
*/ */
@ -2543,16 +2543,16 @@ icon_is_in_area (DesktopIconInfo *dii, int x1, int y1, int x2, int y2)
if (x1 == x2 && y1 == y2) if (x1 == x2 && y1 == y2)
return FALSE; return FALSE;
if (x1 < dicon->icon_x + dicon->icon_w - 1 if (x1 < dicon->icon_x + dicon->icon_w
&& x2 > dicon->icon_x && x2 >= dicon->icon_x
&& y1 < dicon->icon_y + dicon->icon_h - 1 && y1 < dicon->icon_y + dicon->icon_h
&& y2 > dicon->icon_y) && y2 >= dicon->icon_y)
return TRUE; return TRUE;
if (x1 < dicon->text_x + dicon->text_w - 1 if (x1 < dicon->text_x + dicon->text_w
&& x2 > dicon->text_x && x2 >= dicon->text_x
&& y1 < dicon->text_y + dicon->text_h - 1 && y1 < dicon->text_y + dicon->text_h
&& y2 > dicon->text_y) && y2 >= dicon->text_y)
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -2600,7 +2600,8 @@ update_drag_selection (int x, int y)
if (in_area) { if (in_area) {
if (invert) { if (invert) {
if (dii->selected == dii->tmp_selected) { if (dii->selected == dii->tmp_selected) {
desktop_icon_select (DESKTOP_ICON (dii->dicon), !dii->selected); desktop_icon_select (DESKTOP_ICON (dii->dicon),
!dii->selected);
dii->selected = !dii->selected; dii->selected = !dii->selected;
} }
} else if (additive) { } else if (additive) {
@ -2785,7 +2786,7 @@ setup_desktop_click_proxy_window (void)
g_warning ("Root window clicks will not work as no GNOME-compliant window manager could be found!"); g_warning ("Root window clicks will not work as no GNOME-compliant window manager could be found!");
return; return;
} }
desktop_wm_is_gnome_compliant = 1; desktop_wm_is_gnome_compliant = 1;
/* Make the proxy window send events to the invisible proxy widget */ /* Make the proxy window send events to the invisible proxy widget */
gdk_window_set_user_data (click_proxy_gdk_window, proxy_invisible); gdk_window_set_user_data (click_proxy_gdk_window, proxy_invisible);
@ -2955,17 +2956,15 @@ desktop_create_url (const char *filename, const char *title, const char *url, co
f = fopen (filename, "w"); f = fopen (filename, "w");
if (f) { if (f) {
fprintf (f, "URL: %s\n", url); fprintf (f, "URL: %s\n", url);
fclose (f); fclose (f);
gnome_metadata_set (filename, "desktop-url", gnome_metadata_set (filename, "desktop-url",
strlen (url) + 1, url); strlen (url) + 1, url);
gnome_metadata_set (filename, "icon-caption", gnome_metadata_set (filename, "icon-caption",
strlen (title) + 1, title); strlen (title) + 1, title);
gnome_metadata_set (filename, "icon-filename", strlen (icon) + 1, icon); gnome_metadata_set (filename, "icon-filename", strlen (icon) + 1, icon);
} }
} }