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

[Issue #1138] Added 'Rename' option to right-click menu for Documents tab #1140

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/document.c
Expand Up @@ -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.
Copy link
Member

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)

* 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.
Expand Down Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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;
Copy link
Member

Choose a reason for hiding this comment

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

why return something if it's always FALSE? if anything, it should be return dialogs_show_save_as();

}


static void document_update_timestamp(GeanyDocument *doc, const gchar *locale_filename)
Expand Down
1 change: 1 addition & 0 deletions src/document.h
Expand Up @@ -240,6 +240,7 @@ extern GPtrArray *documents_array;
GeanyDocument* document_new_file_if_non_open(void);

gboolean document_reload_prompt(GeanyDocument *doc, const gchar *forced_enc);
gboolean document_rename_prompt(GeanyDocument *doc);

void document_reload_config(GeanyDocument *doc);

Expand Down
18 changes: 17 additions & 1 deletion src/sidebar.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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..."));
Copy link
Member

Choose a reason for hiding this comment

The 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));
Copy link
Member

Choose a reason for hiding this comment

The 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);
Expand Down Expand Up @@ -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;
}
}
}

Expand Down