From d971b902636d3fd65336502667d966512d0f3358 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 23 Jul 2000 14:01:05 +0000 Subject: [PATCH] r336: Added an option to control the spring-loading feature. Added tooltips to some of the options. Improved the rule for deciding whether to open a new window when you click on the toolbar buttons. --- ROX-Filer/Help/Changes | 6 ++++++ ROX-Filer/src/dnd.c | 54 +++++++++++++++++++++++++++++++++++++++---------- ROX-Filer/src/filer.c | 22 ++++++++++++++++++++ ROX-Filer/src/menu.c | 4 +++- ROX-Filer/src/menu.h | 1 + ROX-Filer/src/options.c | 5 +++++ ROX-Filer/src/options.h | 6 ++++++ ROX-Filer/src/toolbar.c | 13 +++++++----- 8 files changed, 94 insertions(+), 17 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 5cad9440..52e2b651 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,12 @@ A RISC OS-like filer for X by Thomas Leonard +23-Jul-2000 +~~~~~~~~~~~ +Added an option to control the spring-loading feature. Added tooltips +to some of the options. Improved the rule for deciding whether to open +a new window when you click on the toolbar buttons. + 22-Jul-2000 ~~~~~~~~~~~ Added 'spring-loaded' directories. If you drag a file over a directory and diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index e448cc82..a750dd01 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -88,6 +88,7 @@ static void set_options(); static void save_options(); static char *load_no_hostnames(char *data); static char *drag_to_icons(char *data); +static char *spring_open(char *data); static void drag_end(GtkWidget *widget, GdkDragContext *context, FilerWindow *filer_window); @@ -149,41 +150,56 @@ void dnd_init() options_sections = g_slist_prepend(options_sections, &options); option_register("dnd_no_hostnames", load_no_hostnames); option_register("dnd_drag_to_icons", drag_to_icons); + option_register("dnd_spring_open", spring_open); } /* OPTIONS */ gboolean o_no_hostnames = FALSE; static gboolean o_drag_to_icons = TRUE; +static gboolean o_spring_open = TRUE; + static GtkWidget *toggle_no_hostnames; static GtkWidget *toggle_drag_to_icons; +static GtkWidget *toggle_spring_open; /* Build up some option widgets to go in the options dialog, but don't * fill them in yet. */ static GtkWidget *create_options() { - GtkWidget *vbox, *label; + GtkWidget *vbox; vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); - label = gtk_label_new(_("Some older applications don't support XDND " - "fully and may need to have this option turned on. " - "Use this if dragging files to an application shows " - "a + sign on the pointer but the drop doesn't work.")); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); - toggle_no_hostnames = gtk_check_button_new_with_label(_("Don't use hostnames")); + OPTION_TIP(toggle_no_hostnames, + "Some older applications don't support XDND " + "fully and may need to have this option turned on. " + "Use this if dragging files to an application shows " + "a + sign on the pointer but the drop doesn't work."); gtk_box_pack_start(GTK_BOX(vbox), toggle_no_hostnames, FALSE, TRUE, 0); toggle_drag_to_icons = gtk_check_button_new_with_label(_("Allow dragging to icons in " "filer windows")); + OPTION_TIP(toggle_drag_to_icons, + "When this is on you can drag a file over a sub-directory " + "or program in a filer window. The item will highlight when " + "you do this and dropping the file will put it into that " + "directory, or load it into the program."); gtk_box_pack_start(GTK_BOX(vbox), toggle_drag_to_icons, FALSE, TRUE, 0); + toggle_spring_open = + gtk_check_button_new_with_label(_("Directories spring open")); + OPTION_TIP(toggle_spring_open, + "This option, which requires the above option to be turned " + "on too, causes the highlighted directory to 'spring open' " + "after the file is held over it for a short while."); + gtk_box_pack_start(GTK_BOX(vbox), toggle_spring_open, FALSE, TRUE, 0); + return vbox; } @@ -193,6 +209,8 @@ static void update_options() o_no_hostnames); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_drag_to_icons), o_drag_to_icons); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_spring_open), + o_spring_open); } static void set_options() @@ -201,12 +219,15 @@ static void set_options() GTK_TOGGLE_BUTTON(toggle_no_hostnames)); o_drag_to_icons = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggle_drag_to_icons)); + o_spring_open = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(toggle_spring_open)); } static void save_options() { option_write("dnd_no_hostnames", o_no_hostnames ? "1" : "0"); option_write("dnd_drag_to_icons", o_drag_to_icons ? "1" : "0"); + option_write("dnd_spring_open", o_spring_open ? "1" : "0"); } static char *load_no_hostnames(char *data) @@ -221,6 +242,12 @@ static char *drag_to_icons(char *data) return NULL; } +static char *spring_open(char *data) +{ + o_spring_open = atoi(data) != 0; + return NULL; +} + /* SUPPORT FUNCTIONS */ /* Set the XdndDirectSave0 property on the source window for this context */ @@ -1165,6 +1192,9 @@ void dnd_spring_load(GdkDragContext *context) { g_return_if_fail(context != NULL); + if (!o_spring_open) + return; + if (spring_context) dnd_spring_abort(); @@ -1195,6 +1225,7 @@ static gboolean spring_check_idle(gpointer data) if (!get_pointer_xy(&p_x, &p_y)) { + /* GdkWindow *win = spring_window->window->window; int x, y; int w, h; @@ -1204,9 +1235,10 @@ static gboolean spring_check_idle(gpointer data) if (p_x < x || p_x > x + w || p_y < y || p_y > y + h) { - gtk_widget_destroy(spring_window->window); - return FALSE; /* Got it! */ - } + */ + + gtk_widget_destroy(spring_window->window); + return FALSE; /* Got it! */ } return TRUE; /* Try again later */ diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 0bc298b5..441859c3 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -280,8 +280,13 @@ static void filer_window_destroyed(GtkWidget *widget, if (window_with_selection == filer_window) window_with_selection = NULL; + if (window_with_focus == filer_window) + { + if (popup_menu) + gtk_menu_popdown(GTK_MENU(popup_menu)); window_with_focus = NULL; + } if (filer_window->directory) detach(filer_window); @@ -1033,20 +1038,37 @@ static GtkWidget *create_options(void) toggle_new_window_on_1 = gtk_check_button_new_with_label( _("New window on button 1 (RISC OS style)")); + OPTION_TIP(toggle_new_window_on_1, + "Clicking with mouse button 1 (usually the " + "left button) opens a directory in a new window " + "with this turned on. Clicking with the button-2 " + "(middle) will reuse the current window."); gtk_box_pack_start(GTK_BOX(vbox), toggle_new_window_on_1, FALSE, TRUE, 0); toggle_menu_on_2 = gtk_check_button_new_with_label( _("Menu on button 2 (RISC OS style)")); + OPTION_TIP(toggle_menu_on_2, + "Use button 2, the middle button (click both buttons " + "at once on two button mice), to pop up the menu. " + "If off, use button 3 (right) instead."); gtk_box_pack_start(GTK_BOX(vbox), toggle_menu_on_2, FALSE, TRUE, 0); toggle_single_click = gtk_check_button_new_with_label(_("Single-click nagivation")); + OPTION_TIP(toggle_single_click, + "Clicking on an item opens it with this on. Hold down " + "Control to select the item instead. If off, clicking " + "once selects an item; double click to open things."); gtk_box_pack_start(GTK_BOX(vbox), toggle_single_click, FALSE, TRUE, 0); toggle_unique_filer_windows = gtk_check_button_new_with_label(_("Unique windows")); + OPTION_TIP(toggle_unique_filer_windows, + "If you open a directory and that directory is " + "already displayed in another window, then this " + "option causes the other window to be closed."); gtk_box_pack_start(GTK_BOX(vbox), toggle_unique_filer_windows, FALSE, TRUE, 0); diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 908f49cb..462ecb24 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -58,7 +58,7 @@ GtkAccelGroup *filer_keys; GtkAccelGroup *panel_keys; GtkAccelGroup *pinboard_keys; -static GtkWidget *popup_menu = NULL; /* Currently open menu */ +GtkWidget *popup_menu = NULL; /* Currently open menu */ static gint updating_menu = 0; /* Non-zero => ignore activations */ @@ -611,6 +611,8 @@ static void menu_closed(GtkWidget *widget) if (window_with_focus == NULL || widget != popup_menu) return; /* Close panel item chosen? */ + popup_menu = NULL; + if (window_with_focus->temp_item_selected) { collection_clear_selection(window_with_focus->collection); diff --git a/ROX-Filer/src/menu.h b/ROX-Filer/src/menu.h index 3bbcb1d0..86de288d 100644 --- a/ROX-Filer/src/menu.h +++ b/ROX-Filer/src/menu.h @@ -12,6 +12,7 @@ #include "pinboard.h" extern GtkAccelGroup *filer_keys; +extern GtkWidget *popup_menu; void menu_init(void); diff --git a/ROX-Filer/src/options.c b/ROX-Filer/src/options.c index 284fb2a2..bbad76b6 100644 --- a/ROX-Filer/src/options.c +++ b/ROX-Filer/src/options.c @@ -36,6 +36,9 @@ /* Add OptionsSection structs to this list in your _init() functions */ GSList *options_sections = NULL; +/* Add all option tooltips to this group */ +GtkTooltips *option_tooltips = NULL; + static GtkWidget *window, *sections_vbox; static FILE *save_file = NULL; static GHashTable *option_hash = NULL; @@ -52,6 +55,8 @@ void options_init() GtkWidget *border, *label; GtkWidget *actions, *button; char *string, *save_path; + + option_tooltips = gtk_tooltips_new(); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); diff --git a/ROX-Filer/src/options.h b/ROX-Filer/src/options.h index 1fe693f4..70f2532e 100644 --- a/ROX-Filer/src/options.h +++ b/ROX-Filer/src/options.h @@ -8,6 +8,11 @@ #ifndef _OPTIONS_H #define _OPTIONS_H +#include + +#define OPTION_TIP(widget, tip) \ + gtk_tooltips_set_tip(option_tooltips, widget, _(tip), NULL) + typedef char *OptionFunc(char *value); typedef struct _OptionsSection OptionsSection; @@ -22,6 +27,7 @@ struct _OptionsSection }; extern GSList *options_sections; +extern GtkTooltips *option_tooltips; /* Prototypes */ diff --git a/ROX-Filer/src/toolbar.c b/ROX-Filer/src/toolbar.c index ede452f3..3b62af49 100644 --- a/ROX-Filer/src/toolbar.c +++ b/ROX-Filer/src/toolbar.c @@ -51,7 +51,12 @@ ToolbarType o_toolbar = TOOLBAR_NORMAL; static GtkWidget *menu_toolbar; static GtkTooltips *tooltips = NULL; -#define NEW_WIN_BUTTON() (o_new_window_on_1 ? 1 : 5 - collection_menu_button) +/* TRUE if the button presses (or released) should open a new window, + * rather than reusing the existing one. + */ +#define NEW_WIN_BUTTON(button_event) \ + (o_new_window_on_1 ? ((GdkEventButton *) button_event)->button == 1 \ + : ((GdkEventButton *) button_event)->button != 1) /* Static prototypes */ static void toolbar_up_clicked(GtkWidget *widget, FilerWindow *filer_window); @@ -119,8 +124,7 @@ static void toolbar_home_clicked(GtkWidget *widget, FilerWindow *filer_window) GdkEvent *event; event = gtk_get_current_event(); - if (event->type == GDK_BUTTON_RELEASE && - ((GdkEventButton *) event)->button == NEW_WIN_BUTTON()) + if (event->type == GDK_BUTTON_RELEASE && NEW_WIN_BUTTON(event)) { filer_opendir(home_dir, PANEL_NO); } @@ -133,8 +137,7 @@ static void toolbar_up_clicked(GtkWidget *widget, FilerWindow *filer_window) GdkEvent *event; event = gtk_get_current_event(); - if (event->type == GDK_BUTTON_RELEASE && - ((GdkEventButton *) event)->button == NEW_WIN_BUTTON()) + if (event->type == GDK_BUTTON_RELEASE && NEW_WIN_BUTTON(event)) { filer_open_parent(filer_window); } -- 2.11.4.GIT