Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor UI changes: Filename only, tooltip, and scrolling #73

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions dragon.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ GtkButton *add_button(char *label, struct draggable_thing *dragdata, int type) {
button = gtk_button_new_with_label(label);
}

// Show a tooltip with the filename. Should perhaps show the full path.
gtk_widget_set_tooltip_text(button, label);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea. I'd even argue that with the tooltip the "name only" option could become the default behavior, perhaps even the only one, but the option is cheap to implement anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you feel like it can become the default, that's good. The option was included as not to cause disruptions for longtime users. So it can be removed if unnecessary.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ideal default is probably something like "match name given on command line, if any", so that e.g. dragon */index.html preserves the relative path to distinguish items with the same basename, but wouldn't convert everything to absolute paths the way it does now; the architecture makes that tricky currently, I think. There could then be options for basename-only (this commit) and absolute paths-only (current default). This change is a good step for common cases now and it would be a reasonable default for as long as we don't have that middle point. The tooltip makes it possible to distinguish them in the cases where it matters.

Perhaps -f like this, -F/--full-path for the existing default, and switch by default to the -f behaviour for the moment?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made it do something like that, at least when the path is within the current directory. It could probably be smarter, but it's a start. Thanks for the PR! These were useful. The tooltip is a great idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapting to the working directory is a clever compromise and functions well.

When showing the filename only, the tooltip doesn't have access to the full path. Instead of setting the tooltip in add_file_button and add_uri_button, I've added a parameter to add_button to be able to set the tooltip to the path. Please see if it's an acceptable change 9c80b7e

It could probably be smarter, but it's a start.

When you say smarter, do you mean that it should show the basename and then resolve duplicates by showing the file's parent and its basename?

Consider the working directory /path/to/file/project-1

Before After
./file-a.txt file-a.txt
./file-b.txt project-1/docs/file-b.txt
/path/to/file/project-2/file-b.txt project-2/docs/file-b.txt
/tmp/file-b.txt /tmp/file-b.txt

Thanks for the PR!

You're welcome


GtkTargetList *targetlist = gtk_drag_source_get_target_list(GTK_WIDGET(button));
if (targetlist)
gtk_target_list_ref(targetlist);
Expand Down