Example #1
0
static void configure_ok_cb()
{
    char *cmd, *cmd_after, *cmd_end, *cmd_ttc;
    cmd = g_strdup(config.cmd);
    cmd_after = g_strdup(config.cmd_after);
    cmd_end = g_strdup(config.cmd_end);
    cmd_ttc = g_strdup(config.cmd_ttc);

    if (check_command(cmd) < 0 || check_command(cmd_after) < 0 ||
            check_command(cmd_end) < 0 || check_command(cmd_ttc) < 0)
    {
        gtk_widget_show(cmd_warn_img);
        gtk_widget_show(cmd_warn_label);
    }
    else
    {
        gtk_widget_hide(cmd_warn_img);
        gtk_widget_hide(cmd_warn_label);
        save_and_close(cmd, cmd_after, cmd_end, cmd_ttc);
    }

    g_free(cmd);
    g_free(cmd_after);
    g_free(cmd_end);
    g_free(cmd_ttc);
}
Example #2
0
static void configure_ok_cb(GtkWidget *w, gpointer data)
{
	char *cmd, *cmd_after, *cmd_end;

	cmd = gtk_entry_get_text(GTK_ENTRY(cmd_entry));
	cmd_after = gtk_entry_get_text(GTK_ENTRY(cmd_after_entry));
	cmd_end = gtk_entry_get_text(GTK_ENTRY(cmd_end_entry));

	if (check_command(cmd) < 0 || check_command(cmd_after) < 0
	                           || check_command(cmd_end) < 0)
		warn_user();
	else
		save_and_close(NULL, NULL);
}
Example #3
0
static void
save_and_close_document (const GList  *docs,
			 CeditWindow  *window)
{
	CeditTab *tab;

	cedit_debug (DEBUG_COMMANDS);

	g_return_if_fail (docs->next == NULL);

	tab = cedit_tab_get_from_document (CEDIT_DOCUMENT (docs->data));
	g_return_if_fail (tab != NULL);

	save_and_close (tab, window);
}
Example #4
0
static void
save_and_close_all_documents (const GList  *docs,
			      CeditWindow  *window)
{
	GList  *tabs;
	GList  *l;
	GSList *sl;
	GSList *tabs_to_save_as;
	GSList *tabs_to_save_and_close;
	GList  *tabs_to_close;

	cedit_debug (DEBUG_COMMANDS);

	g_return_if_fail (!(cedit_window_get_state (window) & CEDIT_WINDOW_STATE_PRINTING));

	tabs = gtk_container_get_children (
			GTK_CONTAINER (_cedit_window_get_notebook (window)));

	tabs_to_save_as = NULL;
	tabs_to_save_and_close = NULL;
	tabs_to_close = NULL;

	l = tabs;
	while (l != NULL)
	{
		CeditTab *t;
		CeditTabState state;
		CeditDocument *doc;

		t = CEDIT_TAB (l->data);

		state = cedit_tab_get_state (t);
		doc = cedit_tab_get_document (t);

		/* If the state is: ([*] invalid states)
		   - CEDIT_TAB_STATE_NORMAL: close (and if needed save)
		   - CEDIT_TAB_STATE_LOADING: close, we are sure the file is unmodified
		   - CEDIT_TAB_STATE_REVERTING: since the user wants
		     to return back to the version of the file she previously saved, we can close
		     without saving (CHECK: are we sure this is the right behavior, suppose the case 
		     the original file has been deleted)
		   - [*] CEDIT_TAB_STATE_SAVING: invalid, ClosAll
		     and Quit are unsensitive if the window state is SAVING.
		   - [*] CEDIT_TAB_STATE_PRINTING, CEDIT_TAB_STATE_PRINT_PREVIEWING: there is not a
		     real reason for not closing in this case, we do not save to avoid to run
		     two operations using the message area at the same time (may be we can remove
		     this limitation in the future). Note that ClosAll
		     and Quit are unsensitive if the window state is PRINTING.
		   - CEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW: close (and if needed save)
		   - CEDIT_TAB_STATE_LOADING_ERROR: close without saving (if the state is LOADING_ERROR then the
		     document is not modified)
		   - CEDIT_TAB_STATE_REVERTING_ERROR: we do not close since the document contains errors
		   - CEDIT_TAB_STATE_SAVING_ERROR: we do not close since the document contains errors
		   - CEDIT_TAB_STATE_GENERIC_ERROR: we do not close since the document contains
		     errors (CHECK: we should problably remove this state)
		   - [*] CEDIT_TAB_STATE_CLOSING: this state is invalid in this case
		*/

		g_return_if_fail (state != CEDIT_TAB_STATE_PRINTING);
		g_return_if_fail (state != CEDIT_TAB_STATE_PRINT_PREVIEWING);
		g_return_if_fail (state != CEDIT_TAB_STATE_CLOSING);
		g_return_if_fail (state != CEDIT_TAB_STATE_SAVING);

		if ((state != CEDIT_TAB_STATE_SAVING_ERROR) &&
		    (state != CEDIT_TAB_STATE_GENERIC_ERROR) &&
		    (state != CEDIT_TAB_STATE_REVERTING_ERROR))
		{
			if ((g_list_index ((GList *)docs, doc) >= 0) &&
			    (state != CEDIT_TAB_STATE_LOADING) &&
			    (state != CEDIT_TAB_STATE_LOADING_ERROR) &&			    
			    (state != CEDIT_TAB_STATE_REVERTING)) /* CHECK: is this the right behavior with REVERTING ?*/
			{			
				/* The document must be saved before closing */
				g_return_if_fail (document_needs_saving (doc));
				
				/* FIXME: manage the case of local readonly files owned by the
				   user is running cedit - Paolo (Dec. 8, 2005) */
				if (cedit_document_is_untitled (doc) ||
				    cedit_document_get_readonly (doc))
				{
					g_object_set_data (G_OBJECT (t),
							   CEDIT_IS_CLOSING_TAB,
							   GBOOLEAN_TO_POINTER (TRUE));

					tabs_to_save_as = g_slist_prepend (tabs_to_save_as,
									   t);
				}
				else
				{
					tabs_to_save_and_close = g_slist_prepend (tabs_to_save_and_close,
										  t);
				}
			}
			else
			{
				/* The document must be closed without saving */
				tabs_to_close = g_list_prepend (tabs_to_close,
								t);
			}
		}

		l = g_list_next (l);
	}

	g_list_free (tabs);

	/* Close all tabs to close (in a sync way) */
	cedit_window_close_tabs (window, tabs_to_close);
	g_list_free (tabs_to_close);

	/* Save and close all the files in tabs_to_save_and_close */
	sl = tabs_to_save_and_close;
	while (sl != NULL)
	{
		save_and_close (CEDIT_TAB (sl->data),
				window);
		sl = g_slist_next (sl);
	}
	g_slist_free (tabs_to_save_and_close);

	/* Save As and close all the files in tabs_to_save_as  */
	if (tabs_to_save_as != NULL)
	{
		CeditTab *tab;

		tabs_to_save_as = g_slist_reverse (tabs_to_save_as );

		g_return_if_fail (g_object_get_data (G_OBJECT (window),
						     CEDIT_LIST_OF_TABS_TO_SAVE_AS) == NULL);

		g_object_set_data (G_OBJECT (window),
				   CEDIT_LIST_OF_TABS_TO_SAVE_AS,
				   tabs_to_save_as);

		tab = CEDIT_TAB (tabs_to_save_as->data);

		save_as_and_close (tab, window);
	}
}