[project @ 2004-07-11 23:14:24 by rjw]

Hotlist folder/entry creation.

svn path=/import/netsurf/; revision=1072
This commit is contained in:
Richard Wilson 2004-07-11 23:14:24 +00:00
parent 6e3995cc65
commit eb8f6921f5
7 changed files with 130 additions and 5 deletions

View File

@ -76,7 +76,7 @@ Collapse:Collapse
All:All
Folders:Folders
Folder:Folder
Links:Hotlist
Links:Addresses
Link:Address
SaveSelect:Save
Launch:Launch
@ -133,6 +133,8 @@ FileError:File does not exist:
HotlistSaveError:The hotlist was unable to be correctly saved.
HotlistLoadError:The hotlist was unable to be correctly loaded.
NoPathError:To save, drag the icon to a directory display
NoNameError:Please enter a name
NoURLError:Please enter a URL
# Some general purpose words and phrases
Bytes: B

Binary file not shown.

View File

@ -76,7 +76,7 @@ Collapse:Collapse
All:All
Folders:Folders
Folder:Folder
Links:Hotlist
Links:Addresses
Link:Address
SaveSelect:Save
Launch:Launch
@ -133,6 +133,8 @@ FileError:Le fichier n'existe pas:
HotlistSaveError:The hotlist was unable to be correctly saved.
HotlistLoadError:The hotlist was unable to be correctly loaded.
NoPathError:To save, drag the icon to a directory display
NoNameError:Please enter a name
NoURLError:Please enter a URL
# Some general purpose words and phrases
Bytes: O

Binary file not shown.

View File

@ -303,12 +303,20 @@ void ro_gui_dialog_close_persistant(wimp_w parent) {
bool ro_gui_dialog_keypress(wimp_key *key)
{
wimp_pointer pointer;
if (key->c == wimp_KEY_ESCAPE) {
ro_gui_dialog_close(key->w);
return true;
}
if (key->c == wimp_KEY_RETURN) {
if ((key->w == dialog_folder) || (key->w == dialog_entry)) {
pointer.w = key->w;
pointer.i = (key->w == dialog_folder) ? 3 : 5;
pointer.buttons = wimp_CLICK_SELECT;
ro_gui_hotlist_dialog_click(&pointer);
return true;
}
}
#ifdef WITH_AUTH
if (key->w == dialog_401li)
return ro_gui_401login_keypress(key);
@ -343,6 +351,8 @@ void ro_gui_dialog_click(wimp_pointer *pointer)
ro_gui_dialog_click_zoom(pointer);
else if (pointer->w == dialog_warning)
ro_gui_dialog_click_warning(pointer);
else if ((pointer->w == dialog_folder) || (pointer->w == dialog_entry))
ro_gui_hotlist_dialog_click(pointer);
}

View File

@ -199,7 +199,6 @@ void ro_gui_hotlist_move_drag_end(wimp_dragged *drag);
bool ro_gui_hotlist_keypress(int key);
void ro_gui_hotlist_menu_closed(void);
void ro_gui_hotlist_toolbar_click(wimp_pointer* pointer);
int ro_gui_hotlist_get_selected(bool folders);
void ro_gui_hotlist_reset_statistics(void);
void ro_gui_hotlist_set_selected(bool selected);
@ -208,6 +207,7 @@ void ro_gui_hotlist_delete_selected(void);
void ro_gui_hotlist_save_as(const char *file);
void ro_gui_hotlist_prepare_folder_dialog(bool selected);
void ro_gui_hotlist_prepare_entry_dialog(bool selected);
void ro_gui_hotlist_dialog_click(wimp_pointer *pointer);
/* in save.c */
void ro_gui_save_open(gui_save_type save_type, struct content *c,

View File

@ -282,6 +282,10 @@ void ro_gui_hotlist_init(void) {
*/
title = messages_get("Hotlist");
new_title = malloc(strlen(title + 1));
if (!new_title) {
warn_user("NoMemory", 0);
return;
}
strcpy(new_title, title);
hotlist_window_definition.title_data.indirected_text.text = new_title;
hotlist_window_definition.title_data.indirected_text.validation = null_text_string;
@ -2244,3 +2248,110 @@ void ro_gui_hotlist_delete_selected(void) {
ro_gui_hotlist_delete_entry(entry, false);
}
}
void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) {
struct hotlist_entry *entry = NULL;
char *title = NULL;
char *url = NULL;
char *old_value;
int icon = pointer->i;
int close_icon, ok_icon;
bool folder;
bool add;
/* Get our data
*/
if (pointer->w == dialog_entry) {
title = strip(ro_gui_get_icon_string(pointer->w, 1));
url = strip(ro_gui_get_icon_string(pointer->w, 3));
close_icon = 4;
ok_icon = 5;
folder = false;
add = !dialog_entry_add;
} else {
title = strip(ro_gui_get_icon_string(pointer->w, 1));
close_icon = 2;
ok_icon = 3;
folder = true;
add = !dialog_folder_add;
}
/* Check for cancelling
*/
if (icon == close_icon) {
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_close(pointer->w);
xwimp_create_menu((wimp_menu *)-1, 0, 0);
return;
}
if (folder) {
ro_gui_hotlist_prepare_folder_dialog(dialog_folder_add);
} else {
ro_gui_hotlist_prepare_entry_dialog(dialog_entry_add);
}
return;
}
/* Check for ok
*/
if (icon != ok_icon) return;
/* Check we have valid values
*/
if ((title != NULL) && (strlen(title) == 0)) {
warn_user("NoNameError", 0);
return;
}
if ((url != NULL) && (strlen(url) == 0)) {
warn_user("NoURLError", 0);
return;
}
/* Update/insert our data
*/
if (add) {
/* todo: insert at the selection place if hotlist_insert is set */
ro_gui_hotlist_create_entry(title, url, folder ? 0 : 0xfaf, &root);
} else {
entry = ro_gui_hotlist_first_selection(root.child_entry);
if (entry == NULL) return;
if (url) {
old_value = entry->url;
entry->url = url_normalize(url);
if (!entry->url) {
warn_user("NoMemory", 0);
entry->url = old_value;
return;
}
if (old_value) free(old_value);
}
if (title) {
old_value = entry->title;
entry->title = malloc(strlen(title) + 1);
if (!entry->title) {
warn_user("NoMemory", 0);
entry->title = old_value;
return;
}
strcpy(entry->title, title);
if (old_value) free(old_value);
}
ro_gui_hotlist_update_entry_size(entry);
}
/* Close if we should
*/
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_close(pointer->w);
xwimp_create_menu((wimp_menu *)-1, 0, 0);
return;
}
/* Update our display
*/
if (folder) {
ro_gui_hotlist_prepare_folder_dialog(dialog_folder_add);
} else {
ro_gui_hotlist_prepare_entry_dialog(dialog_entry_add);
}
}