1
0
mirror of https://github.com/GNOME/gedit synced 2024-07-02 15:58:48 +00:00

Use tepl_file_get_short_name()

This commit is contained in:
Sébastien Wilmet 2022-11-29 16:00:00 +01:00
parent c26d1b559d
commit 95858891aa
10 changed files with 23 additions and 44 deletions

View File

@ -41,6 +41,14 @@
instead.
</para>
</listitem>
<listitem>
<para>
The <code>gedit_document_get_short_name_for_display()</code> function has been
removed, use
<link linkend="tepl-file-get-short-name">tepl_file_get_short_name()</link>
instead.
</para>
</listitem>
</itemizedlist>
</refsect1>

View File

@ -52,7 +52,6 @@ gedit_commands_save_all_documents
GeditDocument
gedit_document_new
gedit_document_get_file
gedit_document_get_short_name_for_display
gedit_document_get_mime_type
gedit_document_is_untitled
gedit_document_set_language

View File

@ -395,11 +395,8 @@ build_single_doc_dialog (GeditCloseConfirmationDialog *dlg)
add_buttons (dlg);
/* Primary message */
doc_name = gedit_document_get_short_name_for_display (doc);
str = g_markup_printf_escaped (_("Save changes to document “%s” before closing?"),
doc_name);
doc_name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
str = g_markup_printf_escaped (_("Save changes to document “%s” before closing?"), doc_name);
g_free (doc_name);
markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
@ -429,7 +426,7 @@ create_list_box (GeditCloseConfirmationDialog *dlg)
GtkWidget *check_button;
GtkWidget *row;
name = gedit_document_get_short_name_for_display (doc);
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
check_button = gtk_check_button_new_with_label (name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
gtk_widget_set_halign (check_button, GTK_ALIGN_START);

View File

@ -849,7 +849,7 @@ save_as_tab_async (GeditTab *tab,
gedit_file_chooser_dialog_set_current_folder (save_dialog, default_folder);
g_object_unref (default_folder);
docname = gedit_document_get_short_name_for_display (doc);
docname = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
gedit_file_chooser_dialog_set_current_name (save_dialog, docname);
g_free (docname);
}
@ -1376,7 +1376,7 @@ do_revert (GeditWindow *window,
gedit_debug (DEBUG_COMMANDS);
doc = gedit_tab_get_document (tab);
docname = gedit_document_get_short_name_for_display (doc);
docname = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
statusbar = GEDIT_STATUSBAR (gedit_window_get_statusbar (window));
gedit_statusbar_flash_message (statusbar,
@ -1427,7 +1427,7 @@ revert_dialog (GeditWindow *window,
gedit_debug (DEBUG_COMMANDS);
docname = gedit_document_get_short_name_for_display (doc);
docname = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
primary_msg = g_strdup_printf (_("Revert unsaved changes to document “%s”?"),
docname);
g_free (docname);

View File

@ -734,23 +734,6 @@ set_content_type (GeditDocument *doc,
}
}
/**
* gedit_document_get_short_name_for_display:
* @doc: a #GeditDocument.
*
* Note: this never returns %NULL.
**/
gchar *
gedit_document_get_short_name_for_display (GeditDocument *doc)
{
TeplFile *file;
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), g_strdup (""));
file = tepl_buffer_get_file (TEPL_BUFFER (doc));
return tepl_file_get_short_name (file);
}
gchar *
gedit_document_get_content_type (GeditDocument *doc)
{

View File

@ -51,8 +51,6 @@ GeditDocument *gedit_document_new (void);
GtkSourceFile *gedit_document_get_file (GeditDocument *doc);
gchar *gedit_document_get_short_name_for_display (GeditDocument *doc);
gchar *gedit_document_get_content_type (GeditDocument *doc);
gchar *gedit_document_get_mime_type (GeditDocument *doc);

View File

@ -444,7 +444,7 @@ doc_get_name (GeditDocument *doc)
gchar *name;
gchar *docname;
name = gedit_document_get_short_name_for_display (doc);
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
/* Truncate the name so it doesn't get insanely wide. */
docname = tepl_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);

View File

@ -26,7 +26,6 @@
#include <tepl/tepl.h>
#include "gedit-debug.h"
#include "gedit-document-private.h"
#include "gedit-print-preview.h"
#include "gedit-utils.h"
#include "gedit-dirs.h"
@ -699,7 +698,7 @@ gedit_print_job_print (GeditPrintJob *job,
GtkWindow *parent,
GError **error)
{
GeditDocument *doc;
TeplBuffer *buffer;
gchar *job_name;
g_return_val_if_fail (job->operation == NULL, GTK_PRINT_OPERATION_RESULT_ERROR);
@ -721,8 +720,8 @@ gedit_print_job_print (GeditPrintJob *job,
page_setup);
}
doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (job->view)));
job_name = gedit_document_get_short_name_for_display (doc);
buffer = TEPL_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (job->view)));
job_name = tepl_file_get_short_name (tepl_buffer_get_file (buffer));
gtk_print_operation_set_job_name (job->operation, job_name);
g_free (job_name);

View File

@ -757,7 +757,7 @@ show_loading_info_bar (GTask *loading_task)
doc = gedit_tab_get_document (data->tab);
name = gedit_document_get_short_name_for_display (doc);
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
len = g_utf8_strlen (name, -1);
/* if the name is awfully long, truncate it and be done with it,
@ -871,9 +871,7 @@ show_saving_info_bar (GTask *saving_task)
gedit_debug (DEBUG_TAB);
doc = gedit_tab_get_document (tab);
short_name = gedit_document_get_short_name_for_display (doc);
short_name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
len = g_utf8_strlen (short_name, -1);
/* if the name is awfully long, truncate it and be done with it,
@ -1434,8 +1432,7 @@ _gedit_tab_get_name (GeditTab *tab)
g_return_val_if_fail (GEDIT_IS_TAB (tab), NULL);
doc = gedit_tab_get_document (tab);
name = gedit_document_get_short_name_for_display (doc);
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
/* Truncate the name so it doesn't get insanely wide. */
docname = tepl_utils_str_middle_truncate (name, MAX_DOC_NAME_LENGTH);
@ -2695,9 +2692,8 @@ get_print_settings (GeditTab *tab)
*/
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_URI, NULL);
name = gedit_document_get_short_name_for_display (doc);
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME, name);
g_free (name);
return settings;

View File

@ -1033,8 +1033,7 @@ set_title (GeditWindow *window)
file = gedit_document_get_file (doc);
name = gedit_document_get_short_name_for_display (doc);
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
len = g_utf8_strlen (name, -1);
/* if the name is awfully long, truncate it and be done with it,