xed-commands-file: Clean up code styling
This commit is contained in:
parent
71306fa224
commit
c50299ec32
|
@ -73,7 +73,8 @@ _xed_cmd_file_new (GtkAction *action,
|
||||||
}
|
}
|
||||||
|
|
||||||
static XedTab *
|
static XedTab *
|
||||||
get_tab_from_file (GList *docs, GFile *file)
|
get_tab_from_file (GList *docs,
|
||||||
|
GFile *file)
|
||||||
{
|
{
|
||||||
XedTab *tab = NULL;
|
XedTab *tab = NULL;
|
||||||
|
|
||||||
|
@ -104,12 +105,15 @@ get_tab_from_file (GList *docs, GFile *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_duplicated_file (GSList *files, GFile *file)
|
is_duplicated_file (GSList *files,
|
||||||
|
GFile *file)
|
||||||
{
|
{
|
||||||
while (files != NULL)
|
while (files != NULL)
|
||||||
{
|
{
|
||||||
if (g_file_equal (files->data, file))
|
if (g_file_equal (files->data, file))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
files = g_slist_next (files);
|
files = g_slist_next (files);
|
||||||
}
|
}
|
||||||
|
@ -177,7 +181,9 @@ load_file_list (XedWindow *window,
|
||||||
g_list_free (win_docs);
|
g_list_free (win_docs);
|
||||||
|
|
||||||
if (files_to_load == NULL)
|
if (files_to_load == NULL)
|
||||||
|
{
|
||||||
return loaded_files;
|
return loaded_files;
|
||||||
|
}
|
||||||
|
|
||||||
files_to_load = g_slist_reverse (files_to_load);
|
files_to_load = g_slist_reverse (files_to_load);
|
||||||
l = files_to_load;
|
l = files_to_load;
|
||||||
|
@ -189,18 +195,13 @@ load_file_list (XedWindow *window,
|
||||||
|
|
||||||
doc = xed_tab_get_document (tab);
|
doc = xed_tab_get_document (tab);
|
||||||
|
|
||||||
if (xed_document_is_untouched (doc) &&
|
if (xed_document_is_untouched (doc) && (xed_tab_get_state (tab) == XED_TAB_STATE_NORMAL))
|
||||||
(xed_tab_get_state (tab) == XED_TAB_STATE_NORMAL))
|
|
||||||
{
|
{
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
// FIXME: pass the GFile to tab when api is there
|
// FIXME: pass the GFile to tab when api is there
|
||||||
uri = g_file_get_uri (l->data);
|
uri = g_file_get_uri (l->data);
|
||||||
_xed_tab_load (tab,
|
_xed_tab_load (tab, uri, encoding, line_pos, create);
|
||||||
uri,
|
|
||||||
encoding,
|
|
||||||
line_pos,
|
|
||||||
create);
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
||||||
l = g_slist_next (l);
|
l = g_slist_next (l);
|
||||||
|
@ -218,12 +219,7 @@ load_file_list (XedWindow *window,
|
||||||
|
|
||||||
// FIXME: pass the GFile to tab when api is there
|
// FIXME: pass the GFile to tab when api is there
|
||||||
uri = g_file_get_uri (l->data);
|
uri = g_file_get_uri (l->data);
|
||||||
tab = xed_window_create_tab_from_uri (window,
|
tab = xed_window_create_tab_from_uri (window, uri, encoding, line_pos, create, jump_to);
|
||||||
uri,
|
|
||||||
encoding,
|
|
||||||
line_pos,
|
|
||||||
create,
|
|
||||||
jump_to);
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
||||||
if (tab != NULL)
|
if (tab != NULL)
|
||||||
|
@ -288,10 +284,14 @@ load_uri_list (XedWindow *window,
|
||||||
gchar *uri = u->data;
|
gchar *uri = u->data;
|
||||||
|
|
||||||
if (xed_utils_is_valid_uri (uri))
|
if (xed_utils_is_valid_uri (uri))
|
||||||
|
{
|
||||||
files = g_slist_prepend (files, g_file_new_for_uri (uri));
|
files = g_slist_prepend (files, g_file_new_for_uri (uri));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
g_warning ("invalid uri: %s", uri);
|
g_warning ("invalid uri: %s", uri);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
files = g_slist_reverse (files);
|
files = g_slist_reverse (files);
|
||||||
|
|
||||||
ret = load_file_list (window, files, encoding, line_pos, create);
|
ret = load_file_list (window, files, encoding, line_pos, create);
|
||||||
|
@ -398,9 +398,7 @@ open_dialog_destroyed (XedWindow *window,
|
||||||
{
|
{
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_OPEN_DIALOG_KEY, NULL);
|
||||||
XED_OPEN_DIALOG_KEY,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -430,10 +428,7 @@ open_dialog_response_cb (XedFileChooserDialog *dialog,
|
||||||
/* Remember the folder we navigated to */
|
/* Remember the folder we navigated to */
|
||||||
_xed_window_set_default_location (window, files->data);
|
_xed_window_set_default_location (window, files->data);
|
||||||
|
|
||||||
xed_commands_load_files (window,
|
xed_commands_load_files (window, files, encoding, 0);
|
||||||
files,
|
|
||||||
encoding,
|
|
||||||
0);
|
|
||||||
|
|
||||||
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
|
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
|
||||||
g_slist_free (files);
|
g_slist_free (files);
|
||||||
|
@ -470,13 +465,9 @@ _xed_cmd_file_open (GtkAction *action,
|
||||||
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
|
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_OPEN_DIALOG_KEY, open_dialog);
|
||||||
XED_OPEN_DIALOG_KEY,
|
|
||||||
open_dialog);
|
|
||||||
|
|
||||||
g_object_weak_ref (G_OBJECT (open_dialog),
|
g_object_weak_ref (G_OBJECT (open_dialog), (GWeakNotify) open_dialog_destroyed, window);
|
||||||
(GWeakNotify) open_dialog_destroyed,
|
|
||||||
window);
|
|
||||||
|
|
||||||
/* Set the curret folder uri */
|
/* Set the curret folder uri */
|
||||||
doc = xed_window_get_active_document (window);
|
doc = xed_window_get_active_document (window);
|
||||||
|
@ -494,24 +485,22 @@ _xed_cmd_file_open (GtkAction *action,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_path == NULL)
|
if (default_path == NULL)
|
||||||
|
{
|
||||||
default_path = _xed_window_get_default_location (window);
|
default_path = _xed_window_get_default_location (window);
|
||||||
|
}
|
||||||
|
|
||||||
if (default_path != NULL)
|
if (default_path != NULL)
|
||||||
{
|
{
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
uri = g_file_get_uri (default_path);
|
uri = g_file_get_uri (default_path);
|
||||||
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (open_dialog),
|
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (open_dialog), uri);
|
||||||
uri);
|
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
g_object_unref (default_path);
|
g_object_unref (default_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect (open_dialog,
|
g_signal_connect (open_dialog, "response", G_CALLBACK (open_dialog_response_cb), window);
|
||||||
"response",
|
|
||||||
G_CALLBACK (open_dialog_response_cb),
|
|
||||||
window);
|
|
||||||
|
|
||||||
gtk_widget_show (open_dialog);
|
gtk_widget_show (open_dialog);
|
||||||
}
|
}
|
||||||
|
@ -535,11 +524,9 @@ is_read_only (GFile *location)
|
||||||
|
|
||||||
if (info != NULL)
|
if (info != NULL)
|
||||||
{
|
{
|
||||||
if (g_file_info_has_attribute (info,
|
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
|
||||||
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
|
|
||||||
{
|
{
|
||||||
ret = !g_file_info_get_attribute_boolean (info,
|
ret = !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
|
||||||
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (info);
|
g_object_unref (info);
|
||||||
|
@ -551,7 +538,8 @@ is_read_only (GFile *location)
|
||||||
/* FIXME: modify this dialog to be similar to the one provided by gtk+ for
|
/* FIXME: modify this dialog to be similar to the one provided by gtk+ for
|
||||||
* already existing files - Paolo (Oct. 11, 2005) */
|
* already existing files - Paolo (Oct. 11, 2005) */
|
||||||
static gboolean
|
static gboolean
|
||||||
replace_read_only_file (GtkWindow *parent, GFile *file)
|
replace_read_only_file (GtkWindow *parent,
|
||||||
|
GFile *file)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
gint ret;
|
gint ret;
|
||||||
|
@ -581,17 +569,11 @@ replace_read_only_file (GtkWindow *parent, GFile *file)
|
||||||
_("Do you want to try to replace it "
|
_("Do you want to try to replace it "
|
||||||
"with the one you are saving?"));
|
"with the one you are saving?"));
|
||||||
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||||
GTK_STOCK_CANCEL,
|
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
|
|
||||||
xed_dialog_add_button (GTK_DIALOG (dialog),
|
xed_dialog_add_button (GTK_DIALOG (dialog), _("_Replace"), GTK_STOCK_SAVE_AS, GTK_RESPONSE_YES);
|
||||||
_("_Replace"),
|
|
||||||
GTK_STOCK_SAVE_AS,
|
|
||||||
GTK_RESPONSE_YES);
|
|
||||||
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||||
|
|
||||||
|
@ -616,8 +598,7 @@ save_dialog_response_cb (XedFileChooserDialog *dialog,
|
||||||
|
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
tab = XED_TAB (g_object_get_data (G_OBJECT (dialog),
|
tab = XED_TAB (g_object_get_data (G_OBJECT (dialog), XED_TAB_TO_SAVE_AS));
|
||||||
XED_TAB_TO_SAVE_AS));
|
|
||||||
|
|
||||||
if (response_id != GTK_RESPONSE_OK)
|
if (response_id != GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
|
@ -666,39 +647,31 @@ save_dialog_response_cb (XedFileChooserDialog *dialog,
|
||||||
|
|
||||||
save_next_tab:
|
save_next_tab:
|
||||||
|
|
||||||
data = g_object_get_data (G_OBJECT (window),
|
data = g_object_get_data (G_OBJECT (window), XED_LIST_OF_TABS_TO_SAVE_AS);
|
||||||
XED_LIST_OF_TABS_TO_SAVE_AS);
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Save As the next tab of the list (we are Saving All files) */
|
/* Save As the next tab of the list (we are Saving All files) */
|
||||||
tabs_to_save_as = (GSList *)data;
|
tabs_to_save_as = (GSList *)data;
|
||||||
g_return_if_fail (tab == XED_TAB (tabs_to_save_as->data));
|
g_return_if_fail (tab == XED_TAB (tabs_to_save_as->data));
|
||||||
|
|
||||||
/* Remove the first item of the list */
|
/* Remove the first item of the list */
|
||||||
tabs_to_save_as = g_slist_delete_link (tabs_to_save_as,
|
tabs_to_save_as = g_slist_delete_link (tabs_to_save_as, tabs_to_save_as);
|
||||||
tabs_to_save_as);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_LIST_OF_TABS_TO_SAVE_AS, tabs_to_save_as);
|
||||||
XED_LIST_OF_TABS_TO_SAVE_AS,
|
|
||||||
tabs_to_save_as);
|
|
||||||
|
|
||||||
if (tabs_to_save_as != NULL)
|
if (tabs_to_save_as != NULL)
|
||||||
{
|
{
|
||||||
tab = XED_TAB (tabs_to_save_as->data);
|
tab = XED_TAB (tabs_to_save_as->data);
|
||||||
|
|
||||||
if (GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (tab),
|
if (GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (tab), XED_IS_CLOSING_TAB)) == TRUE)
|
||||||
XED_IS_CLOSING_TAB)) == TRUE)
|
|
||||||
{
|
{
|
||||||
g_object_set_data (G_OBJECT (tab),
|
g_object_set_data (G_OBJECT (tab), XED_IS_CLOSING_TAB, NULL);
|
||||||
XED_IS_CLOSING_TAB,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Trace tab state changes */
|
/* Trace tab state changes */
|
||||||
g_signal_connect (tab,
|
g_signal_connect (tab, "notify::state", G_CALLBACK (tab_state_changed_while_saving), window);
|
||||||
"notify::state",
|
|
||||||
G_CALLBACK (tab_state_changed_while_saving),
|
|
||||||
window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xed_window_set_active_tab (window, tab);
|
xed_window_set_active_tab (window, tab);
|
||||||
|
@ -723,10 +696,14 @@ confirm_overwrite_callback (GtkFileChooser *dialog,
|
||||||
if (is_read_only (file))
|
if (is_read_only (file))
|
||||||
{
|
{
|
||||||
if (replace_read_only_file (GTK_WINDOW (dialog), file))
|
if (replace_read_only_file (GTK_WINDOW (dialog), file))
|
||||||
|
{
|
||||||
res = GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
|
res = GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
res = GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
|
res = GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* fall back to the default confirmation dialog */
|
/* fall back to the default confirmation dialog */
|
||||||
|
@ -763,17 +740,12 @@ file_save_as (XedTab *tab,
|
||||||
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (save_dialog),
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (save_dialog), TRUE);
|
||||||
TRUE);
|
g_signal_connect (save_dialog, "confirm-overwrite", G_CALLBACK (confirm_overwrite_callback), NULL);
|
||||||
g_signal_connect (save_dialog,
|
|
||||||
"confirm-overwrite",
|
|
||||||
G_CALLBACK (confirm_overwrite_callback),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
wg = xed_window_get_group (window);
|
wg = xed_window_get_group (window);
|
||||||
|
|
||||||
gtk_window_group_add_window (wg,
|
gtk_window_group_add_window (wg, GTK_WINDOW (save_dialog));
|
||||||
GTK_WINDOW (save_dialog));
|
|
||||||
|
|
||||||
/* Save As dialog is modal to its main window */
|
/* Save As dialog is modal to its main window */
|
||||||
gtk_window_set_modal (GTK_WINDOW (save_dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (save_dialog), TRUE);
|
||||||
|
@ -784,9 +756,7 @@ file_save_as (XedTab *tab,
|
||||||
|
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
uri_set = gtk_file_chooser_set_file (GTK_FILE_CHOOSER (save_dialog),
|
uri_set = gtk_file_chooser_set_file (GTK_FILE_CHOOSER (save_dialog), file, NULL);
|
||||||
file,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
@ -805,15 +775,13 @@ file_save_as (XedTab *tab,
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
|
||||||
uri = g_file_get_uri (default_path);
|
uri = g_file_get_uri (default_path);
|
||||||
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (save_dialog),
|
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (save_dialog), uri);
|
||||||
uri);
|
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
g_object_unref (default_path);
|
g_object_unref (default_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (save_dialog),
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (save_dialog), docname);
|
||||||
docname);
|
|
||||||
|
|
||||||
g_free (docname);
|
g_free (docname);
|
||||||
}
|
}
|
||||||
|
@ -824,20 +792,13 @@ file_save_as (XedTab *tab,
|
||||||
|
|
||||||
newline_type = xed_document_get_newline_type (doc);
|
newline_type = xed_document_get_newline_type (doc);
|
||||||
|
|
||||||
xed_file_chooser_dialog_set_encoding (XED_FILE_CHOOSER_DIALOG (save_dialog),
|
xed_file_chooser_dialog_set_encoding (XED_FILE_CHOOSER_DIALOG (save_dialog), encoding);
|
||||||
encoding);
|
|
||||||
|
|
||||||
xed_file_chooser_dialog_set_newline_type (XED_FILE_CHOOSER_DIALOG (save_dialog),
|
xed_file_chooser_dialog_set_newline_type (XED_FILE_CHOOSER_DIALOG (save_dialog), newline_type);
|
||||||
newline_type);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (save_dialog),
|
g_object_set_data (G_OBJECT (save_dialog), XED_TAB_TO_SAVE_AS, tab);
|
||||||
XED_TAB_TO_SAVE_AS,
|
|
||||||
tab);
|
|
||||||
|
|
||||||
g_signal_connect (save_dialog,
|
g_signal_connect (save_dialog, "response", G_CALLBACK (save_dialog_response_cb), window);
|
||||||
"response",
|
|
||||||
G_CALLBACK (save_dialog_response_cb),
|
|
||||||
window);
|
|
||||||
|
|
||||||
gtk_widget_show (save_dialog);
|
gtk_widget_show (save_dialog);
|
||||||
}
|
}
|
||||||
|
@ -888,7 +849,9 @@ _xed_cmd_file_save (GtkAction *action,
|
||||||
|
|
||||||
tab = xed_window_get_active_tab (window);
|
tab = xed_window_get_active_tab (window);
|
||||||
if (tab == NULL)
|
if (tab == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
file_save (tab, window);
|
file_save (tab, window);
|
||||||
}
|
}
|
||||||
|
@ -903,7 +866,9 @@ _xed_cmd_file_save_as (GtkAction *action,
|
||||||
|
|
||||||
tab = xed_window_get_active_tab (window);
|
tab = xed_window_get_active_tab (window);
|
||||||
if (tab == NULL)
|
if (tab == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
file_save_as (tab, window);
|
file_save_as (tab, window);
|
||||||
}
|
}
|
||||||
|
@ -912,12 +877,16 @@ static gboolean
|
||||||
document_needs_saving (XedDocument *doc)
|
document_needs_saving (XedDocument *doc)
|
||||||
{
|
{
|
||||||
if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
|
if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* we check if it was deleted only for local files
|
/* we check if it was deleted only for local files
|
||||||
* since for remote files it may hang */
|
* since for remote files it may hang */
|
||||||
if (xed_document_is_local (doc) && xed_document_get_deleted (doc))
|
if (xed_document_is_local (doc) && xed_document_get_deleted (doc))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -934,9 +903,7 @@ _xed_cmd_file_save_documents_list (XedWindow *window,
|
||||||
|
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
g_return_if_fail (!(xed_window_get_state (window) &
|
g_return_if_fail (!(xed_window_get_state (window) & (XED_WINDOW_STATE_PRINTING | XED_WINDOW_STATE_SAVING_SESSION)));
|
||||||
(XED_WINDOW_STATE_PRINTING |
|
|
||||||
XED_WINDOW_STATE_SAVING_SESSION)));
|
|
||||||
|
|
||||||
l = docs;
|
l = docs;
|
||||||
while (l != NULL)
|
while (l != NULL)
|
||||||
|
@ -961,13 +928,11 @@ _xed_cmd_file_save_documents_list (XedWindow *window,
|
||||||
{
|
{
|
||||||
/* FIXME: manage the case of local readonly files owned by the
|
/* FIXME: manage the case of local readonly files owned by the
|
||||||
user is running xed - Paolo (Dec. 8, 2005) */
|
user is running xed - Paolo (Dec. 8, 2005) */
|
||||||
if (xed_document_is_untitled (doc) ||
|
if (xed_document_is_untitled (doc) || xed_document_get_readonly (doc))
|
||||||
xed_document_get_readonly (doc))
|
|
||||||
{
|
{
|
||||||
if (document_needs_saving (doc))
|
if (document_needs_saving (doc))
|
||||||
{
|
{
|
||||||
tabs_to_save_as = g_slist_prepend (tabs_to_save_as,
|
tabs_to_save_as = g_slist_prepend (tabs_to_save_as, t);
|
||||||
t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1017,12 +982,9 @@ _xed_cmd_file_save_documents_list (XedWindow *window,
|
||||||
|
|
||||||
tabs_to_save_as = g_slist_reverse (tabs_to_save_as );
|
tabs_to_save_as = g_slist_reverse (tabs_to_save_as );
|
||||||
|
|
||||||
g_return_if_fail (g_object_get_data (G_OBJECT (window),
|
g_return_if_fail (g_object_get_data (G_OBJECT (window), XED_LIST_OF_TABS_TO_SAVE_AS) == NULL);
|
||||||
XED_LIST_OF_TABS_TO_SAVE_AS) == NULL);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_LIST_OF_TABS_TO_SAVE_AS, tabs_to_save_as);
|
||||||
XED_LIST_OF_TABS_TO_SAVE_AS,
|
|
||||||
tabs_to_save_as);
|
|
||||||
|
|
||||||
tab = XED_TAB (tabs_to_save_as->data);
|
tab = XED_TAB (tabs_to_save_as->data);
|
||||||
|
|
||||||
|
@ -1106,7 +1068,9 @@ revert_dialog_response_cb (GtkDialog *dialog,
|
||||||
not very nice - Paolo (Oct 11, 2005) */
|
not very nice - Paolo (Oct 11, 2005) */
|
||||||
tab = xed_window_get_active_tab (window);
|
tab = xed_window_get_active_tab (window);
|
||||||
if (tab == NULL)
|
if (tab == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
|
||||||
|
@ -1129,16 +1093,14 @@ revert_dialog (XedWindow *window,
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
docname = xed_document_get_short_name_for_display (doc);
|
docname = xed_document_get_short_name_for_display (doc);
|
||||||
primary_msg = g_strdup_printf (_("Revert unsaved changes to document '%s'?"),
|
primary_msg = g_strdup_printf (_("Revert unsaved changes to document '%s'?"), docname);
|
||||||
docname);
|
|
||||||
g_free (docname);
|
g_free (docname);
|
||||||
|
|
||||||
seconds = MAX (1, _xed_document_get_seconds_since_last_save_or_load (doc));
|
seconds = MAX (1, _xed_document_get_seconds_since_last_save_or_load (doc));
|
||||||
|
|
||||||
if (seconds < 55)
|
if (seconds < 55)
|
||||||
{
|
{
|
||||||
secondary_msg = g_strdup_printf (
|
secondary_msg = g_strdup_printf (ngettext ("Changes made to the document in the last %ld second "
|
||||||
ngettext ("Changes made to the document in the last %ld second "
|
|
||||||
"will be permanently lost.",
|
"will be permanently lost.",
|
||||||
"Changes made to the document in the last %ld seconds "
|
"Changes made to the document in the last %ld seconds "
|
||||||
"will be permanently lost.",
|
"will be permanently lost.",
|
||||||
|
@ -1152,8 +1114,7 @@ revert_dialog (XedWindow *window,
|
||||||
}
|
}
|
||||||
else if (seconds < 110) /* 75 <= seconds < 110 */
|
else if (seconds < 110) /* 75 <= seconds < 110 */
|
||||||
{
|
{
|
||||||
secondary_msg = g_strdup_printf (
|
secondary_msg = g_strdup_printf (ngettext ("Changes made to the document in the last minute and "
|
||||||
ngettext ("Changes made to the document in the last minute and "
|
|
||||||
"%ld second will be permanently lost.",
|
"%ld second will be permanently lost.",
|
||||||
"Changes made to the document in the last minute and "
|
"Changes made to the document in the last minute and "
|
||||||
"%ld seconds will be permanently lost.",
|
"%ld seconds will be permanently lost.",
|
||||||
|
@ -1162,8 +1123,7 @@ revert_dialog (XedWindow *window,
|
||||||
}
|
}
|
||||||
else if (seconds < 3600)
|
else if (seconds < 3600)
|
||||||
{
|
{
|
||||||
secondary_msg = g_strdup_printf (
|
secondary_msg = g_strdup_printf (ngettext ("Changes made to the document in the last %ld minute "
|
||||||
ngettext ("Changes made to the document in the last %ld minute "
|
|
||||||
"will be permanently lost.",
|
"will be permanently lost.",
|
||||||
"Changes made to the document in the last %ld minutes "
|
"Changes made to the document in the last %ld minutes "
|
||||||
"will be permanently lost.",
|
"will be permanently lost.",
|
||||||
|
@ -1183,8 +1143,7 @@ revert_dialog (XedWindow *window,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
secondary_msg = g_strdup_printf (
|
secondary_msg = g_strdup_printf (ngettext ("Changes made to the document in the last hour and "
|
||||||
ngettext ("Changes made to the document in the last hour and "
|
|
||||||
"%d minute will be permanently lost.",
|
"%d minute will be permanently lost.",
|
||||||
"Changes made to the document in the last hour and "
|
"Changes made to the document in the last hour and "
|
||||||
"%d minutes will be permanently lost.",
|
"%d minutes will be permanently lost.",
|
||||||
|
@ -1198,8 +1157,7 @@ revert_dialog (XedWindow *window,
|
||||||
|
|
||||||
hours = seconds / 3600;
|
hours = seconds / 3600;
|
||||||
|
|
||||||
secondary_msg = g_strdup_printf (
|
secondary_msg = g_strdup_printf (ngettext ("Changes made to the document in the last %d hour "
|
||||||
ngettext ("Changes made to the document in the last %d hour "
|
|
||||||
"will be permanently lost.",
|
"will be permanently lost.",
|
||||||
"Changes made to the document in the last %d hours "
|
"Changes made to the document in the last %d hours "
|
||||||
"will be permanently lost.",
|
"will be permanently lost.",
|
||||||
|
@ -1213,24 +1171,17 @@ revert_dialog (XedWindow *window,
|
||||||
GTK_BUTTONS_NONE,
|
GTK_BUTTONS_NONE,
|
||||||
"%s", primary_msg);
|
"%s", primary_msg);
|
||||||
|
|
||||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_msg);
|
||||||
"%s", secondary_msg);
|
|
||||||
g_free (primary_msg);
|
g_free (primary_msg);
|
||||||
g_free (secondary_msg);
|
g_free (secondary_msg);
|
||||||
|
|
||||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||||
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||||
GTK_STOCK_CANCEL,
|
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
|
|
||||||
xed_dialog_add_button (GTK_DIALOG (dialog),
|
xed_dialog_add_button (GTK_DIALOG (dialog), _("_Revert"), GTK_STOCK_REVERT_TO_SAVED, GTK_RESPONSE_OK);
|
||||||
_("_Revert"),
|
|
||||||
GTK_STOCK_REVERT_TO_SAVED,
|
|
||||||
GTK_RESPONSE_OK);
|
|
||||||
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
|
||||||
GTK_RESPONSE_CANCEL);
|
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
@ -1270,10 +1221,7 @@ _xed_cmd_file_revert (GtkAction *action,
|
||||||
|
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
g_signal_connect (dialog,
|
g_signal_connect (dialog, "response", G_CALLBACK (revert_dialog_response_cb), window);
|
||||||
"response",
|
|
||||||
G_CALLBACK (revert_dialog_response_cb),
|
|
||||||
window);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
@ -1287,8 +1235,7 @@ really_close_tab (XedTab *tab)
|
||||||
|
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
g_return_val_if_fail (xed_tab_get_state (tab) == XED_TAB_STATE_CLOSING,
|
g_return_val_if_fail (xed_tab_get_state (tab) == XED_TAB_STATE_CLOSING, FALSE);
|
||||||
FALSE);
|
|
||||||
|
|
||||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (tab));
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (tab));
|
||||||
g_return_val_if_fail (XED_IS_WINDOW (toplevel), FALSE);
|
g_return_val_if_fail (XED_IS_WINDOW (toplevel), FALSE);
|
||||||
|
@ -1301,12 +1248,13 @@ really_close_tab (XedTab *tab)
|
||||||
{
|
{
|
||||||
gboolean is_quitting;
|
gboolean is_quitting;
|
||||||
|
|
||||||
is_quitting = GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (window),
|
is_quitting = GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (window), XED_IS_QUITTING));
|
||||||
XED_IS_QUITTING));
|
|
||||||
|
|
||||||
if (is_quitting)
|
if (is_quitting)
|
||||||
|
{
|
||||||
gtk_widget_destroy (GTK_WIDGET (window));
|
gtk_widget_destroy (GTK_WIDGET (window));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1328,9 +1276,7 @@ tab_state_changed_while_saving (XedTab *tab,
|
||||||
{
|
{
|
||||||
XedDocument *doc;
|
XedDocument *doc;
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (tab,
|
g_signal_handlers_disconnect_by_func (tab, G_CALLBACK (tab_state_changed_while_saving), window);
|
||||||
G_CALLBACK (tab_state_changed_while_saving),
|
|
||||||
window);
|
|
||||||
|
|
||||||
doc = xed_tab_get_document (tab);
|
doc = xed_tab_get_document (tab);
|
||||||
g_return_if_fail (doc != NULL);
|
g_return_if_fail (doc != NULL);
|
||||||
|
@ -1338,17 +1284,16 @@ tab_state_changed_while_saving (XedTab *tab,
|
||||||
/* If the saving operation failed or was interrupted, then the
|
/* If the saving operation failed or was interrupted, then the
|
||||||
document is still "modified" -> do not close the tab */
|
document is still "modified" -> do not close the tab */
|
||||||
if (document_needs_saving (doc))
|
if (document_needs_saving (doc))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Close the document only if it has been succesfully saved.
|
/* Close the document only if it has been succesfully saved.
|
||||||
Tab state is set to CLOSING (it is a state without exiting
|
Tab state is set to CLOSING (it is a state without exiting
|
||||||
transitions) and the tab is closed in a idle handler */
|
transitions) and the tab is closed in a idle handler */
|
||||||
_xed_tab_mark_for_closing (tab);
|
_xed_tab_mark_for_closing (tab);
|
||||||
|
|
||||||
g_idle_add_full (G_PRIORITY_HIGH_IDLE,
|
g_idle_add_full (G_PRIORITY_HIGH_IDLE, (GSourceFunc)really_close_tab, tab, NULL);
|
||||||
(GSourceFunc)really_close_tab,
|
|
||||||
tab,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1359,10 +1304,7 @@ save_and_close (XedTab *tab,
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
/* Trace tab state changes */
|
/* Trace tab state changes */
|
||||||
g_signal_connect (tab,
|
g_signal_connect (tab, "notify::state", G_CALLBACK (tab_state_changed_while_saving), window);
|
||||||
"notify::state",
|
|
||||||
G_CALLBACK (tab_state_changed_while_saving),
|
|
||||||
window);
|
|
||||||
|
|
||||||
file_save (tab, window);
|
file_save (tab, window);
|
||||||
}
|
}
|
||||||
|
@ -1373,15 +1315,10 @@ save_as_and_close (XedTab *tab,
|
||||||
{
|
{
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (tab),
|
g_object_set_data (G_OBJECT (tab), XED_IS_CLOSING_TAB, NULL);
|
||||||
XED_IS_CLOSING_TAB,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Trace tab state changes */
|
/* Trace tab state changes */
|
||||||
g_signal_connect (tab,
|
g_signal_connect (tab, "notify::state", G_CALLBACK (tab_state_changed_while_saving), window);
|
||||||
"notify::state",
|
|
||||||
G_CALLBACK (tab_state_changed_while_saving),
|
|
||||||
window);
|
|
||||||
|
|
||||||
xed_window_set_active_tab (window, tab);
|
xed_window_set_active_tab (window, tab);
|
||||||
file_save_as (tab, window);
|
file_save_as (tab, window);
|
||||||
|
@ -1402,8 +1339,7 @@ save_and_close_all_documents (const GList *docs,
|
||||||
|
|
||||||
g_return_if_fail (!(xed_window_get_state (window) & XED_WINDOW_STATE_PRINTING));
|
g_return_if_fail (!(xed_window_get_state (window) & XED_WINDOW_STATE_PRINTING));
|
||||||
|
|
||||||
tabs = gtk_container_get_children (
|
tabs = gtk_container_get_children (GTK_CONTAINER (_xed_window_get_notebook (window)));
|
||||||
GTK_CONTAINER (_xed_window_get_notebook (window)));
|
|
||||||
|
|
||||||
tabs_to_save_as = NULL;
|
tabs_to_save_as = NULL;
|
||||||
tabs_to_save_and_close = NULL;
|
tabs_to_save_and_close = NULL;
|
||||||
|
@ -1464,27 +1400,21 @@ save_and_close_all_documents (const GList *docs,
|
||||||
|
|
||||||
/* FIXME: manage the case of local readonly files owned by the
|
/* FIXME: manage the case of local readonly files owned by the
|
||||||
user is running xed - Paolo (Dec. 8, 2005) */
|
user is running xed - Paolo (Dec. 8, 2005) */
|
||||||
if (xed_document_is_untitled (doc) ||
|
if (xed_document_is_untitled (doc) || xed_document_get_readonly (doc))
|
||||||
xed_document_get_readonly (doc))
|
|
||||||
{
|
{
|
||||||
g_object_set_data (G_OBJECT (t),
|
g_object_set_data (G_OBJECT (t), XED_IS_CLOSING_TAB, GBOOLEAN_TO_POINTER (TRUE));
|
||||||
XED_IS_CLOSING_TAB,
|
|
||||||
GBOOLEAN_TO_POINTER (TRUE));
|
|
||||||
|
|
||||||
tabs_to_save_as = g_slist_prepend (tabs_to_save_as,
|
tabs_to_save_as = g_slist_prepend (tabs_to_save_as, t);
|
||||||
t);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tabs_to_save_and_close = g_slist_prepend (tabs_to_save_and_close,
|
tabs_to_save_and_close = g_slist_prepend (tabs_to_save_and_close, t);
|
||||||
t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The document must be closed without saving */
|
/* The document must be closed without saving */
|
||||||
tabs_to_close = g_list_prepend (tabs_to_close,
|
tabs_to_close = g_list_prepend (tabs_to_close, t);
|
||||||
t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,8 +1431,7 @@ save_and_close_all_documents (const GList *docs,
|
||||||
sl = tabs_to_save_and_close;
|
sl = tabs_to_save_and_close;
|
||||||
while (sl != NULL)
|
while (sl != NULL)
|
||||||
{
|
{
|
||||||
save_and_close (XED_TAB (sl->data),
|
save_and_close (XED_TAB (sl->data), window);
|
||||||
window);
|
|
||||||
sl = g_slist_next (sl);
|
sl = g_slist_next (sl);
|
||||||
}
|
}
|
||||||
g_slist_free (tabs_to_save_and_close);
|
g_slist_free (tabs_to_save_and_close);
|
||||||
|
@ -1514,12 +1443,9 @@ save_and_close_all_documents (const GList *docs,
|
||||||
|
|
||||||
tabs_to_save_as = g_slist_reverse (tabs_to_save_as );
|
tabs_to_save_as = g_slist_reverse (tabs_to_save_as );
|
||||||
|
|
||||||
g_return_if_fail (g_object_get_data (G_OBJECT (window),
|
g_return_if_fail (g_object_get_data (G_OBJECT (window), XED_LIST_OF_TABS_TO_SAVE_AS) == NULL);
|
||||||
XED_LIST_OF_TABS_TO_SAVE_AS) == NULL);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_LIST_OF_TABS_TO_SAVE_AS, tabs_to_save_as);
|
||||||
XED_LIST_OF_TABS_TO_SAVE_AS,
|
|
||||||
tabs_to_save_as);
|
|
||||||
|
|
||||||
tab = XED_TAB (tabs_to_save_as->data);
|
tab = XED_TAB (tabs_to_save_as->data);
|
||||||
|
|
||||||
|
@ -1553,11 +1479,12 @@ close_all_tabs (XedWindow *window)
|
||||||
/* There is no document to save -> close all tabs */
|
/* There is no document to save -> close all tabs */
|
||||||
xed_window_close_all_tabs (window);
|
xed_window_close_all_tabs (window);
|
||||||
|
|
||||||
is_quitting = GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (window),
|
is_quitting = GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (window), XED_IS_QUITTING));
|
||||||
XED_IS_QUITTING));
|
|
||||||
|
|
||||||
if (is_quitting)
|
if (is_quitting)
|
||||||
|
{
|
||||||
gtk_widget_destroy (GTK_WIDGET (window));
|
gtk_widget_destroy (GTK_WIDGET (window));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1586,8 +1513,7 @@ close_confirmation_dialog_response_handler (XedCloseConfirmationDialog *dlg,
|
||||||
|
|
||||||
xed_debug (DEBUG_COMMANDS);
|
xed_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
is_closing_all = GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (window),
|
is_closing_all = GPOINTER_TO_BOOLEAN (g_object_get_data (G_OBJECT (window), XED_IS_CLOSING_ALL));
|
||||||
XED_IS_CLOSING_ALL));
|
|
||||||
|
|
||||||
gtk_widget_hide (GTK_WIDGET (dlg));
|
gtk_widget_hide (GTK_WIDGET (dlg));
|
||||||
|
|
||||||
|
@ -1615,13 +1541,11 @@ close_confirmation_dialog_response_handler (XedCloseConfirmationDialog *dlg,
|
||||||
{
|
{
|
||||||
if (is_closing_all)
|
if (is_closing_all)
|
||||||
{
|
{
|
||||||
save_and_close_all_documents (selected_documents,
|
save_and_close_all_documents (selected_documents, window);
|
||||||
window);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
save_and_close_document (selected_documents,
|
save_and_close_document (selected_documents, window);
|
||||||
window);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1647,17 +1571,14 @@ close_confirmation_dialog_response_handler (XedCloseConfirmationDialog *dlg,
|
||||||
unsaved_documents = xed_close_confirmation_dialog_get_unsaved_documents (dlg);
|
unsaved_documents = xed_close_confirmation_dialog_get_unsaved_documents (dlg);
|
||||||
g_return_if_fail (unsaved_documents->next == NULL);
|
g_return_if_fail (unsaved_documents->next == NULL);
|
||||||
|
|
||||||
close_document (window,
|
close_document (window, XED_DOCUMENT (unsaved_documents->data));
|
||||||
XED_DOCUMENT (unsaved_documents->data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default: /* Do not close */
|
default: /* Do not close */
|
||||||
|
|
||||||
/* Reset is_quitting flag */
|
/* Reset is_quitting flag */
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_IS_QUITTING, GBOOLEAN_TO_POINTER (FALSE));
|
||||||
XED_IS_QUITTING,
|
|
||||||
GBOOLEAN_TO_POINTER (FALSE));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1680,15 +1601,10 @@ tab_can_close (XedTab *tab,
|
||||||
{
|
{
|
||||||
GtkWidget *dlg;
|
GtkWidget *dlg;
|
||||||
|
|
||||||
dlg = xed_close_confirmation_dialog_new_single (
|
dlg = xed_close_confirmation_dialog_new_single (window, doc, FALSE);
|
||||||
window,
|
|
||||||
doc,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
g_signal_connect (dlg,
|
g_signal_connect (dlg, "response",
|
||||||
"response",
|
G_CALLBACK (close_confirmation_dialog_response_handler), window);
|
||||||
G_CALLBACK (close_confirmation_dialog_response_handler),
|
|
||||||
window);
|
|
||||||
|
|
||||||
gtk_widget_show (dlg);
|
gtk_widget_show (dlg);
|
||||||
|
|
||||||
|
@ -1712,22 +1628,16 @@ _xed_cmd_file_close_tab (XedTab *tab,
|
||||||
|
|
||||||
g_return_if_fail (GTK_WIDGET (window) == gtk_widget_get_toplevel (GTK_WIDGET (tab)));
|
g_return_if_fail (GTK_WIDGET (window) == gtk_widget_get_toplevel (GTK_WIDGET (tab)));
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_IS_CLOSING_ALL, GBOOLEAN_TO_POINTER (FALSE));
|
||||||
XED_IS_CLOSING_ALL,
|
g_object_set_data (G_OBJECT (window), XED_IS_QUITTING, GBOOLEAN_TO_POINTER (FALSE));
|
||||||
GBOOLEAN_TO_POINTER (FALSE));
|
g_object_set_data (G_OBJECT (window), XED_IS_QUITTING_ALL, GINT_TO_POINTER (FALSE));
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
|
||||||
XED_IS_QUITTING,
|
|
||||||
GBOOLEAN_TO_POINTER (FALSE));
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
|
||||||
XED_IS_QUITTING_ALL,
|
|
||||||
GINT_TO_POINTER (FALSE));
|
|
||||||
|
|
||||||
|
|
||||||
if (tab_can_close (tab, GTK_WINDOW (window)))
|
if (tab_can_close (tab, GTK_WINDOW (window)))
|
||||||
|
{
|
||||||
xed_window_close_tab (window, tab);
|
xed_window_close_tab (window, tab);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_xed_cmd_file_close (GtkAction *action,
|
_xed_cmd_file_close (GtkAction *action,
|
||||||
|
@ -1762,13 +1672,8 @@ file_close_all (XedWindow *window,
|
||||||
XED_WINDOW_STATE_PRINTING |
|
XED_WINDOW_STATE_PRINTING |
|
||||||
XED_WINDOW_STATE_SAVING_SESSION)));
|
XED_WINDOW_STATE_SAVING_SESSION)));
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
g_object_set_data (G_OBJECT (window), XED_IS_CLOSING_ALL, GBOOLEAN_TO_POINTER (TRUE));
|
||||||
XED_IS_CLOSING_ALL,
|
g_object_set_data (G_OBJECT (window), XED_IS_QUITTING, GBOOLEAN_TO_POINTER (is_quitting));
|
||||||
GBOOLEAN_TO_POINTER (TRUE));
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (window),
|
|
||||||
XED_IS_QUITTING,
|
|
||||||
GBOOLEAN_TO_POINTER (is_quitting));
|
|
||||||
|
|
||||||
unsaved_docs = xed_window_get_unsaved_documents (window);
|
unsaved_docs = xed_window_get_unsaved_documents (window);
|
||||||
|
|
||||||
|
@ -1778,7 +1683,9 @@ file_close_all (XedWindow *window,
|
||||||
xed_window_close_all_tabs (window);
|
xed_window_close_all_tabs (window);
|
||||||
|
|
||||||
if (is_quitting)
|
if (is_quitting)
|
||||||
|
{
|
||||||
gtk_widget_destroy (GTK_WIDGET (window));
|
gtk_widget_destroy (GTK_WIDGET (window));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1796,24 +1703,17 @@ file_close_all (XedWindow *window,
|
||||||
|
|
||||||
xed_window_set_active_tab (window, tab);
|
xed_window_set_active_tab (window, tab);
|
||||||
|
|
||||||
dlg = xed_close_confirmation_dialog_new_single (
|
dlg = xed_close_confirmation_dialog_new_single (GTK_WINDOW (window), doc, FALSE);
|
||||||
GTK_WINDOW (window),
|
|
||||||
doc,
|
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dlg = xed_close_confirmation_dialog_new (GTK_WINDOW (window),
|
dlg = xed_close_confirmation_dialog_new (GTK_WINDOW (window), unsaved_docs, FALSE);
|
||||||
unsaved_docs,
|
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free (unsaved_docs);
|
g_list_free (unsaved_docs);
|
||||||
|
|
||||||
g_signal_connect (dlg,
|
g_signal_connect (dlg, "response",
|
||||||
"response",
|
G_CALLBACK (close_confirmation_dialog_response_handler), window);
|
||||||
G_CALLBACK (close_confirmation_dialog_response_handler),
|
|
||||||
window);
|
|
||||||
|
|
||||||
gtk_widget_show (dlg);
|
gtk_widget_show (dlg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue