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
[Issue #1138] Added 'Rename' option to right-click menu for Documents tab #1140
Changes from all 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 |
---|---|---|
|
@@ -1273,7 +1273,6 @@ void document_show_tab(GeanyDocument *doc) | |
document_get_notebook_page(doc)); | ||
} | ||
|
||
|
||
/* To open a new file, set doc to NULL; filename should be locale encoded. | ||
* To reload a file, set the doc for the document to be reloaded; filename should be NULL. | ||
* pos is the cursor position, which can be overridden by --line and --column. | ||
|
@@ -1656,6 +1655,12 @@ gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc) | |
g_free(base_name); | ||
return result; | ||
} | ||
/* also used for reloading when forced_enc is NULL */ | ||
gboolean document_rename_prompt(GeanyDocument *doc) { | ||
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. I don't think this convenience function should be added. Not only it's very simple and only use "public" API, but it's also only used in one place. 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. Also the name is partially misleading, it's the same for save as/rename |
||
document_show_tab(doc); | ||
dialogs_show_save_as(); | ||
return FALSE; | ||
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. why return something if it's always |
||
} | ||
|
||
|
||
static void document_update_timestamp(GeanyDocument *doc, const gchar *locale_filename) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,8 @@ enum | |
{ | ||
OPENFILES_ACTION_REMOVE = 0, | ||
OPENFILES_ACTION_SAVE, | ||
OPENFILES_ACTION_RELOAD | ||
OPENFILES_ACTION_RELOAD, | ||
OPENFILES_ACTION_RENAME | ||
}; | ||
|
||
/* documents tree model columns */ | ||
|
@@ -724,6 +725,16 @@ static void create_openfiles_popup_menu(void) | |
G_CALLBACK(on_openfiles_document_action), GINT_TO_POINTER(OPENFILES_ACTION_RELOAD)); | ||
doc_items.reload = item; | ||
|
||
item = gtk_image_menu_item_new_with_mnemonic(_("R_ename or Save As...")); | ||
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. We use Save As alone in the rest of the UI, should we introduce Rename here? |
||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), | ||
gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)); | ||
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. …and it affects the icon too |
||
gtk_widget_show(item); | ||
gtk_container_add(GTK_CONTAINER(openfiles_popup_menu), item); | ||
g_signal_connect(item, "activate", | ||
G_CALLBACK(on_openfiles_document_action), GINT_TO_POINTER(OPENFILES_ACTION_RENAME)); | ||
doc_items.reload = item; | ||
|
||
|
||
item = gtk_separator_menu_item_new(); | ||
gtk_widget_show(item); | ||
gtk_container_add(GTK_CONTAINER(openfiles_popup_menu), item); | ||
|
@@ -830,6 +841,11 @@ static void document_action(GeanyDocument *doc, gint action) | |
document_reload_prompt(doc, NULL); | ||
break; | ||
} | ||
case OPENFILES_ACTION_RENAME: | ||
{ | ||
document_rename_prompt(doc); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
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.
don't remove this line (it's part of the style -- and in any case, don't introduce style-only changes in the middle of a commit)