-
Notifications
You must be signed in to change notification settings - Fork 48
Feature request for a "shelf" option ( #51) #52
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| dragon | ||
|
|
||
| # clangd | ||
| compile_commands.json | ||
| .cache/ | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,7 @@ bool verbose = false; | |||||||
| int mode = 0; | ||||||||
| int thumb_size = 96; | ||||||||
| bool and_exit; | ||||||||
| bool individual_exit; // TODO docs ; man | ||||||||
| bool keep; | ||||||||
| bool print_path = false; | ||||||||
| bool icons_only = false; | ||||||||
|
|
@@ -67,6 +68,7 @@ GtkWidget *all_button; | |||||||
| // --- | ||||||||
|
|
||||||||
| void add_target_button(); | ||||||||
| GtkWidget* find_child(GtkWidget* parent, const gchar* name); | ||||||||
|
|
||||||||
| void do_quit(GtkWidget *widget, gpointer data) { | ||||||||
| exit(0); | ||||||||
|
|
@@ -115,6 +117,8 @@ void drag_data_get(GtkWidget *widget, | |||||||
| } | ||||||||
|
|
||||||||
| void drag_end(GtkWidget *widget, GdkDragContext *context, gpointer user_data) { | ||||||||
| uri_count--; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will break target mode together with shelf mode (or 'drag once mode') and cause URIs to be overridden as that uses the And finally, what if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so you mean i should decrement |
||||||||
| struct draggable_thing *dd = (struct draggable_thing *)user_data; | ||||||||
| if (verbose) { | ||||||||
| gboolean succeeded = gdk_drag_drop_succeeded(context); | ||||||||
| GdkDragAction action = gdk_drag_context_get_selected_action (context); | ||||||||
|
|
@@ -137,10 +141,58 @@ void drag_end(GtkWidget *widget, GdkDragContext *context, gpointer user_data) { | |||||||
| if (action_str[0] == 'i') | ||||||||
| free(action_str); | ||||||||
| } | ||||||||
| if (and_exit) | ||||||||
|
|
||||||||
| if (and_exit){ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens when user invokes both Instead of using two bools, I'd use a single enum
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should do the trick. Though the names could be better. diff --git a/dragon.c b/dragon.c
index ae3bac0..4c253f6 100644
--- a/dragon.c
+++ b/dragon.c
@@ -35,13 +35,12 @@ char *progname;
bool verbose = false;
int mode = 0;
int thumb_size = 96;
-bool and_exit;
-bool individual_exit; // TODO docs ; man
bool keep;
bool print_path = false;
bool icons_only = false;
bool always_on_top = false;
+static enum { QUIT_NONE, QUIT_ALL, QUIT_ITEM } quit_mode;
static char *stdin_files;
#define MODE_HELP 1
@@ -142,11 +141,9 @@ void drag_end(GtkWidget *widget, GdkDragContext *context, gpointer user_data) {
free(action_str);
}
- if (and_exit){
+ if (quit_mode == QUIT_ALL) {
gtk_main_quit();
- }
-
- if(individual_exit) {
+ } else if (quit_mode == QUIT_ITEM) {
if (uri_count == 0) {
gtk_main_quit();
return;
@@ -412,7 +409,7 @@ drag_data_received (GtkWidget *widget,
} else if (verbose)
fputs("Received nothing\n", stderr);
gtk_drag_finish (context, TRUE, FALSE, time);
- if (and_exit)
+ if (quit_mode == QUIT_ALL)
gtk_main_quit();
}
@@ -538,10 +535,10 @@ int main (int argc, char **argv) {
mode = MODE_TARGET;
} else if (strcmp(argv[i], "-x") == 0
|| strcmp(argv[i], "--and-exit") == 0) {
- and_exit = true;
+ quit_mode = QUIT_ALL;
} else if (strcmp(argv[i], "-X") == 0
|| strcmp(argv[i], "--individual-exit") == 0) {
- individual_exit = true;
+ quit_mode = QUIT_ITEM;
} else if (strcmp(argv[i], "-k") == 0
|| strcmp(argv[i], "--keep") == 0) {
keep = true; |
||||||||
| gtk_main_quit(); | ||||||||
| } | ||||||||
|
|
||||||||
| if(individual_exit) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use spaces before and after the parens. e.g |
||||||||
| if (uri_count == 0) { | ||||||||
| gtk_main_quit(); | ||||||||
| return; | ||||||||
| } | ||||||||
|
|
||||||||
| GtkWidget* button = find_child(vbox,dd->text); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space after the comma.
Suggested change
|
||||||||
| if(button != NULL) { | ||||||||
| gtk_container_remove(GTK_CONTAINER(vbox), button); | ||||||||
| } else { | ||||||||
| fprintf(stderr, "Could not find button with label: %s",dd->text); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // https://stackoverflow.com/a/23497087 | ||||||||
| GtkWidget* | ||||||||
| find_child(GtkWidget* parent, const gchar* name) | ||||||||
| { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation of this entire function is severely off. |
||||||||
|
|
||||||||
| if (GTK_IS_BUTTON(parent)) { | ||||||||
|
|
||||||||
| if (g_ascii_strcasecmp(gtk_button_get_label(GTK_BUTTON(parent)), (gchar*)name) == 0) { | ||||||||
| return parent; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| if (GTK_IS_BIN(parent)) { | ||||||||
| GtkWidget *child = gtk_bin_get_child(GTK_BIN(parent)); | ||||||||
| return find_child(child, name); | ||||||||
| } | ||||||||
|
|
||||||||
| if (GTK_IS_CONTAINER(parent)) { | ||||||||
| GList *children = gtk_container_get_children(GTK_CONTAINER(parent)); | ||||||||
| do { | ||||||||
| GtkWidget* widget = find_child(children->data, name); | ||||||||
| if (widget != NULL) { | ||||||||
| return widget; | ||||||||
| } | ||||||||
| } | ||||||||
| while ((children = g_list_next(children)) != NULL); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| return NULL; | ||||||||
| } | ||||||||
|
|
||||||||
| void add_uri(char *uri) { | ||||||||
| if (uri_count < MAX_SIZE) { | ||||||||
| uri_collection[uri_count] = uri; | ||||||||
|
|
@@ -151,6 +203,7 @@ void add_uri(char *uri) { | |||||||
| } | ||||||||
|
|
||||||||
| GtkButton *add_button(char *label, struct draggable_thing *dragdata, int type) { | ||||||||
|
|
||||||||
| GtkWidget *button; | ||||||||
|
|
||||||||
| if (icons_only) { | ||||||||
|
|
@@ -486,6 +539,9 @@ int main (int argc, char **argv) { | |||||||
| } else if (strcmp(argv[i], "-x") == 0 | ||||||||
| || strcmp(argv[i], "--and-exit") == 0) { | ||||||||
| and_exit = true; | ||||||||
| } else if (strcmp(argv[i], "-X") == 0 | ||||||||
| || strcmp(argv[i], "--individual-exit") == 0) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of a long name for a cli arg, something simpler might be better. But I guess not that big of a deal since there's the short form
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming isn't exactly intuitive to me. I wouldn't expect this option to cause the application to exit once all the individual items have been dragged out of it. How about naming it
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||||||||
| individual_exit = true; | ||||||||
| } else if (strcmp(argv[i], "-k") == 0 | ||||||||
| || strcmp(argv[i], "--keep") == 0) { | ||||||||
| keep = true; | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO these should go into user's global ignore file rather than on the project's one.