Progress dialog for printing

This commit is contained in:
Yevgen Muntyan 2011-01-18 01:16:25 -08:00
parent 8356906d7e
commit caa61354ae
15 changed files with 378 additions and 314 deletions

View File

@ -48,6 +48,8 @@ moo_sources += \
mooedit/mooeditprefs.c \
mooedit/mooeditprefspage.c \
mooedit/mooedit-private.h \
mooedit/mooeditprogress.h \
mooedit/mooeditprogress.c \
mooedit/mooeditwindow.c \
mooedit/mooeditwindow-impl.h \
mooedit/mooeditwindow-priv.h \

View File

@ -1,66 +1,41 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
<property name="title">window1</property>
<child>
<widget class="GtkEventBox" id="ProgressDialog">
<property name="visible">True</property>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<widget class="GtkAlignment" id="ProgressWidget">
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">12</property>
<property name="bottom_padding">12</property>
<property name="left_padding">12</property>
<property name="right_padding">12</property>
<child>
<widget class="GtkTable" id="table1">
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="width_request">250</property>
<property name="height_request">70</property>
<property name="visible">True</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">12</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
<property name="fraction">0.5</property>
<property name="pulse_step">0.10000000149</property>
<property name="activity_mode">True</property>
<property name="show_text">True</property>
<property name="text" translatable="yes">Doing stuff</property>
</widget>
</child>
</widget>
<packing>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="xscale">0</property>
<child>
<widget class="GtkButton" id="cancel">
<property name="visible">True</property>
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
</child>
<property name="focus_on_click">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
@ -68,6 +43,4 @@
</widget>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -28,43 +28,51 @@ G_BEGIN_DECLS
extern MooEditList *_moo_edit_instances;
void _moo_edit_set_focused_view (MooEdit *doc,
MooEditView *view);
void _moo_edit_add_view (MooEdit *doc,
MooEditView *view);
void _moo_edit_remove_view (MooEdit *doc,
MooEditView *view);
void _moo_edit_set_focused_view (MooEdit *doc,
MooEditView *view);
void _moo_edit_add_view (MooEdit *doc,
MooEditView *view);
void _moo_edit_remove_view (MooEdit *doc,
MooEditView *view);
gboolean _moo_edit_is_busy (MooEdit *doc);
gboolean _moo_edit_is_busy (MooEdit *doc);
MooEditState _moo_edit_get_state (MooEdit *doc);
void _moo_edit_set_progress_text (MooEdit *doc,
const char *text);
void _moo_edit_set_state (MooEdit *doc,
MooEditState state,
const char *text,
GDestroyNotify cancel,
gpointer data);
char *_moo_file_get_normalized_name (GFile *file);
char *_moo_edit_get_normalized_name (MooEdit *edit);
char *_moo_file_get_normalized_name (GFile *file);
char *_moo_edit_get_normalized_name (MooEdit *edit);
char *_moo_edit_get_utf8_filename (MooEdit *edit);
char *_moo_edit_get_utf8_filename (MooEdit *edit);
void _moo_edit_add_class_actions (MooEdit *edit);
void _moo_edit_check_actions (MooEdit *edit,
MooEditView *view);
void _moo_edit_class_init_actions (MooEditClass *klass);
void _moo_edit_add_class_actions (MooEdit *edit);
void _moo_edit_check_actions (MooEdit *edit,
MooEditView *view);
void _moo_edit_class_init_actions (MooEditClass *klass);
void _moo_edit_status_changed (MooEdit *edit);
void _moo_edit_status_changed (MooEdit *edit);
gboolean _moo_edit_has_comments (MooEdit *edit,
gboolean *single_line,
gboolean *multi_line);
void _moo_edit_comment (MooEdit *edit);
void _moo_edit_uncomment (MooEdit *edit);
gboolean _moo_edit_has_comments (MooEdit *edit,
gboolean *single_line,
gboolean *multi_line);
void _moo_edit_comment (MooEdit *edit);
void _moo_edit_uncomment (MooEdit *edit);
#define MOO_EDIT_GOTO_BOOKMARK_ACTION "GoToBookmark"
void _moo_edit_delete_bookmarks (MooEdit *edit,
gboolean in_destroy);
void _moo_edit_line_mark_moved (MooEdit *edit,
MooLineMark *mark);
void _moo_edit_line_mark_deleted (MooEdit *edit,
MooLineMark *mark);
gboolean _moo_edit_line_mark_clicked (MooTextView *view,
int line);
void _moo_edit_update_bookmarks_style (MooEdit *edit);
void _moo_edit_delete_bookmarks (MooEdit *edit,
gboolean in_destroy);
void _moo_edit_line_mark_moved (MooEdit *edit,
MooLineMark *mark);
void _moo_edit_line_mark_deleted (MooEdit *edit,
MooLineMark *mark);
gboolean _moo_edit_line_mark_clicked (MooTextView *view,
int line);
void _moo_edit_update_bookmarks_style (MooEdit *edit);
/***********************************************************************/
/* Preferences

View File

@ -17,6 +17,7 @@
#define MOO_EDIT_PRIVATE_H
#include "mooedit/mooedit-impl.h"
#include "mooedit/mooeditprogress.h"
G_BEGIN_DECLS
@ -50,6 +51,9 @@ struct MooEditPrivate {
gboolean modified_on_disk;
gboolean deleted_from_disk;
MooEditState state;
MooEditProgress *progress;
/***********************************************************************/
/* Bookmarks
*/

View File

@ -30,6 +30,7 @@
#include "mooedit/mootextbuffer.h"
#include "mooedit/mooeditfiltersettings.h"
#include "mooedit/mooeditor-impl.h"
#include "mooedit/mooeditwindow-impl.h"
#include "mooedit/moolangmgr.h"
#include "marshals.h"
#include "mooutils/mooutils-fs.h"
@ -267,6 +268,8 @@ _moo_edit_closed (MooEdit *doc)
{
g_return_if_fail (MOO_IS_EDIT (doc));
moo_assert (doc->priv->state == MOO_EDIT_STATE_NORMAL);
_moo_edit_remove_untitled (doc);
_moo_edit_instances = moo_edit_list_remove (_moo_edit_instances, doc);
@ -713,6 +716,16 @@ moo_edit_get_editor (MooEdit *doc)
return doc->priv->editor;
}
/**
* moo_edit_get_tab:
**/
MooEditTab *
moo_edit_get_tab (MooEdit *doc)
{
g_return_val_if_fail (MOO_IS_EDIT (doc), NULL);
return moo_edit_view_get_tab (moo_edit_get_view (doc));
}
/**
* moo_edit_get_view:
**/
@ -1314,15 +1327,69 @@ moo_edit_save_copy (MooEdit *doc,
gboolean
_moo_edit_is_busy (MooEdit *doc)
{
guint i;
g_return_val_if_fail (MOO_IS_EDIT (doc), FALSE);
return _moo_edit_get_state (doc) != MOO_EDIT_STATE_NORMAL;
}
MooEditState
_moo_edit_get_state (MooEdit *doc)
{
g_return_val_if_fail (MOO_IS_EDIT (doc), MOO_EDIT_STATE_NORMAL);
return doc->priv->state;
}
void
_moo_edit_set_progress_text (MooEdit *doc,
const char *text)
{
g_return_if_fail (MOO_IS_EDIT (doc));
g_return_if_fail (doc->priv->state != MOO_EDIT_STATE_NORMAL);
g_return_if_fail (doc->priv->progress != NULL);
_moo_edit_progress_set_text (doc->priv->progress, text);
}
void
_moo_edit_set_state (MooEdit *doc,
MooEditState state,
const char *text,
GDestroyNotify cancel,
gpointer data)
{
guint i;
MooEditTab *tab;
g_return_if_fail (MOO_IS_EDIT (doc));
g_return_if_fail (state == MOO_EDIT_STATE_NORMAL ||
doc->priv->state == MOO_EDIT_STATE_NORMAL);
if (doc->priv->progress)
_moo_edit_progress_set_cancel_func (doc->priv->progress, cancel, data);
if (state == doc->priv->state)
return;
doc->priv->state = state;
for (i = 0; i < moo_edit_view_array_get_size (doc->priv->views); ++i)
if (_moo_edit_view_get_state (doc->priv->views->elms[i]) != MOO_EDIT_STATE_NORMAL)
return TRUE;
gtk_text_view_set_editable (GTK_TEXT_VIEW (doc->priv->views->elms[i]), !state);
return FALSE;
tab = moo_edit_get_tab (doc);
if (!tab)
return;
if (!state)
{
_moo_edit_tab_destroy_progress (tab);
g_object_unref (doc->priv->progress);
doc->priv->progress = NULL;
}
else
{
doc->priv->progress = _moo_edit_tab_create_progress (tab);
_moo_edit_progress_start (doc->priv->progress, text, cancel, data);
g_object_ref (doc->priv->progress);
}
}

View File

@ -65,7 +65,7 @@ GType moo_edit_get_type (void) G_GNUC_CONST;
MooEditor *moo_edit_get_editor (MooEdit *doc);
MooEditWindow *moo_edit_get_window (MooEdit *doc);
MooEditTab *moo_edit_get_tab (MooEdit *doc);
MooEditViewArray *moo_edit_get_views (MooEdit *doc);
MooEditView *moo_edit_get_view (MooEdit *doc);
int moo_edit_get_n_views (MooEdit *doc);

View File

@ -0,0 +1,161 @@
#include "mooedit/mooeditprogress.h"
#include "mooedit/mooeditprogress-gxml.h"
#include "mooutils/mooutils-script.h"
#define MOO_TYPE_EDIT_PROGRESS (moo_edit_progress_get_type ())
#define MOO_EDIT_PROGRESS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_EDIT_PROGRESS, MooEditProgress))
#define MOO_EDIT_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_EDIT_PROGRESS, MooEditProgressClass))
#define MOO_IS_EDIT_PROGRESS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_EDIT_PROGRESS))
#define MOO_IS_EDIT_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_EDIT_PROGRESS))
#define MOO_EDIT_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_EDIT_PROGRESS, MooEditProgressClass))
#define PROGRESS_TIMEOUT 100
#define INITIAL_TIMEOUT 500
typedef struct MooEditProgressClass MooEditProgressClass;
struct MooEditProgress
{
GtkAlignment base;
ProgressWidgetXml *xml;
guint timeout;
char *text;
GDestroyNotify cancel_op;
gpointer cancel_data;
};
struct MooEditProgressClass
{
GtkAlignmentClass base_class;
};
static void cancel_clicked (MooEditProgress *pr);
MOO_DEFINE_TYPE_STATIC (MooEditProgress, moo_edit_progress, GTK_TYPE_ALIGNMENT)
static void
moo_edit_progress_init (MooEditProgress *pr)
{
pr->xml = progress_widget_xml_new_with_root (GTK_WIDGET (pr));
g_signal_connect_swapped (pr->xml->cancel, "clicked", G_CALLBACK (cancel_clicked), pr);
}
static void
moo_edit_progress_dispose (GObject *object)
{
MooEditProgress *pr = MOO_EDIT_PROGRESS (object);
if (pr->timeout)
{
g_source_remove (pr->timeout);
pr->timeout = 0;
}
g_free (pr->text);
pr->text = NULL;
G_OBJECT_CLASS (moo_edit_progress_parent_class)->dispose (object);
}
static void
moo_edit_progress_class_init (MooEditProgressClass *klass)
{
G_OBJECT_CLASS (klass)->dispose = moo_edit_progress_dispose;
}
MooEditProgress *
_moo_edit_progress_new (void)
{
return g_object_new (MOO_TYPE_EDIT_PROGRESS, NULL);
}
static void
update_progress (MooEditProgress *progress)
{
g_return_if_fail (MOO_IS_EDIT_PROGRESS (progress));
g_return_if_fail (progress->text != NULL);
gtk_progress_bar_set_text (progress->xml->progressbar,
progress->text);
}
void
_moo_edit_progress_set_text (MooEditProgress *progress,
const char *text)
{
char *tmp;
g_return_if_fail (MOO_IS_EDIT_PROGRESS (progress));
tmp = progress->text;
progress->text = g_strdup (text);
g_free (tmp);
update_progress (progress);
}
static gboolean
pulse_progress (MooEditProgress *progress)
{
g_return_val_if_fail (MOO_IS_EDIT_PROGRESS (progress), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (progress->xml->progressbar), FALSE);
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (progress->xml->progressbar));
update_progress (progress);
return TRUE;
}
static void
cancel_clicked (MooEditProgress *progress)
{
g_return_if_fail (MOO_IS_EDIT_PROGRESS (progress));
if (progress->cancel_op)
progress->cancel_op (progress->cancel_data);
}
static gboolean
show_progress (MooEditProgress *progress)
{
g_source_remove (progress->timeout);
progress->timeout =
gdk_threads_add_timeout (PROGRESS_TIMEOUT,
(GSourceFunc) pulse_progress,
progress);
update_progress (progress);
gtk_widget_show (GTK_WIDGET (progress));
return FALSE;
}
void
_moo_edit_progress_set_cancel_func (MooEditProgress *progress,
GDestroyNotify cancel_func,
gpointer cancel_func_data)
{
g_return_if_fail (MOO_IS_EDIT_PROGRESS (progress));
progress->cancel_op = cancel_func;
progress->cancel_data = cancel_func_data;
gtk_widget_set_sensitive (GTK_WIDGET (progress->xml->cancel),
cancel_func != NULL);
}
void
_moo_edit_progress_start (MooEditProgress *progress,
const char *text,
GDestroyNotify cancel_func,
gpointer cancel_func_data)
{
g_return_if_fail (MOO_IS_EDIT_PROGRESS (progress));
g_return_if_fail (progress->timeout == 0);
progress->text = g_strdup (text);
_moo_edit_progress_set_cancel_func (progress, cancel_func, cancel_func_data);
progress->timeout =
gdk_threads_add_timeout (INITIAL_TIMEOUT,
(GSourceFunc) show_progress,
progress);
}

View File

@ -0,0 +1,24 @@
#ifndef MOO_EDIT_PROGRESS_H
#define MOO_EDIT_PROGRESS_H
#include "mooedit.h"
#include "mooeditwindow.h"
G_BEGIN_DECLS
typedef struct MooEditProgress MooEditProgress;
MooEditProgress *_moo_edit_progress_new (void);
void _moo_edit_progress_start (MooEditProgress *progress,
const char *text,
GDestroyNotify cancel_func,
gpointer cancel_func_data);
void _moo_edit_progress_set_cancel_func (MooEditProgress *progress,
GDestroyNotify cancel_func,
gpointer cancel_func_data);
void _moo_edit_progress_set_text (MooEditProgress *progress,
const char *text);
G_END_DECLS
#endif /* MOO_EDIT_PROGRESS_H */

View File

@ -13,15 +13,6 @@ void _moo_edit_view_set_tab (MooEditView *view,
void _moo_edit_view_apply_prefs (MooEditView *view);
void _moo_edit_view_apply_config (MooEditView *view);
MooEditState _moo_edit_view_get_state (MooEditView *view);
void _moo_edit_view_set_progress_text (MooEditView *view,
const char *text);
void _moo_edit_view_set_state (MooEditView *view,
MooEditState state,
const char *text,
GDestroyNotify cancel,
gpointer data);
void _moo_edit_view_ui_set_line_wrap (MooEditView *view,
gboolean enabled);
void _moo_edit_view_ui_set_show_line_numbers (MooEditView *view,

View File

@ -5,23 +5,11 @@
G_BEGIN_DECLS
#define PROGRESS_TIMEOUT 100
#define PROGRESS_WIDTH 300
#define PROGRESS_HEIGHT 100
struct MooEditViewPrivate
{
MooEdit *doc;
MooEditor *editor;
MooEditTab *tab;
MooEditState state;
guint progress_timeout;
GtkWidget *progress;
GtkWidget *progressbar;
char *progress_text;
GDestroyNotify cancel_op;
gpointer cancel_data;
};
G_END_DECLS

View File

@ -11,11 +11,9 @@
#include "mooedit/mooeditprefs.h"
#include "mooutils/mooutils.h"
#include "mooutils/moocompat.h"
#include "mooedit/mooeditprogress-gxml.h"
MOO_DEFINE_OBJECT_ARRAY (MooEditView, moo_edit_view)
static void moo_edit_view_finalize (GObject *object);
static void moo_edit_view_dispose (GObject *object);
static gboolean moo_edit_view_focus_in (GtkWidget *widget,
@ -47,7 +45,6 @@ moo_edit_view_class_init (MooEditViewClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
MooTextViewClass *textview_class = MOO_TEXT_VIEW_CLASS (klass);
gobject_class->finalize = moo_edit_view_finalize;
gobject_class->dispose = moo_edit_view_dispose;
widget_class->popup_menu = moo_edit_view_popup_menu;
@ -69,18 +66,6 @@ moo_edit_view_init (MooEditView *view)
view->priv = G_TYPE_INSTANCE_GET_PRIVATE (view, MOO_TYPE_EDIT_VIEW, MooEditViewPrivate);
}
static void
moo_edit_view_finalize (GObject *object)
{
G_GNUC_UNUSED MooEditView *view = MOO_EDIT_VIEW (object);
moo_assert (view->priv->state == MOO_EDIT_STATE_NORMAL);
G_OBJECT_CLASS (moo_edit_view_parent_class)->finalize (object);
}
void
_moo_edit_view_unset_doc (MooEditView *view)
{
@ -93,8 +78,6 @@ moo_edit_view_dispose (GObject *object)
{
MooEditView *view = MOO_EDIT_VIEW (object);
moo_assert (!view->priv->progress);
if (view->priv->doc)
{
_moo_edit_remove_view (view->priv->doc, view);
@ -102,19 +85,6 @@ moo_edit_view_dispose (GObject *object)
view->priv->doc = NULL;
}
view->priv->progress = NULL;
view->priv->progressbar = NULL;
if (view->priv->progress_timeout)
{
moo_assert_not_reached ();
g_source_remove (view->priv->progress_timeout);
view->priv->progress_timeout = 0;
}
g_free (view->priv->progress_text);
view->priv->progress_text = NULL;
G_OBJECT_CLASS (moo_edit_view_parent_class)->dispose (object);
}
@ -440,163 +410,6 @@ moo_edit_view_popup_menu (GtkWidget *widget)
}
/*****************************************************************************/
/* progress dialogs and stuff
*/
MooEditState
_moo_edit_view_get_state (MooEditView *view)
{
g_return_val_if_fail (MOO_IS_EDIT_VIEW (view), MOO_EDIT_STATE_NORMAL);
return view->priv->state;
}
static void
position_progress (MooEditView *view)
{
GtkAllocation *allocation;
int x, y;
g_return_if_fail (MOO_IS_EDIT_VIEW (view));
g_return_if_fail (GTK_IS_WIDGET (view->priv->progress));
if (!GTK_WIDGET_REALIZED (view))
return;
allocation = &GTK_WIDGET(view)->allocation;
x = allocation->width/2 - PROGRESS_WIDTH/2;
y = allocation->height/2 - PROGRESS_HEIGHT/2;
gtk_text_view_move_child (GTK_TEXT_VIEW (view),
view->priv->progress,
x, y);
}
static void
update_progress (MooEditView *view)
{
g_return_if_fail (MOO_IS_EDIT_VIEW (view));
g_return_if_fail (view->priv->progress_text != NULL);
g_return_if_fail (view->priv->state != MOO_EDIT_STATE_NORMAL);
if (view->priv->progressbar)
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (view->priv->progressbar),
view->priv->progress_text);
}
void
_moo_edit_view_set_progress_text (MooEditView *view,
const char *text)
{
g_return_if_fail (MOO_IS_EDIT_VIEW (view));
g_free (view->priv->progress_text);
view->priv->progress_text = g_strdup (text);
update_progress (view);
}
static gboolean
pulse_progress (MooEditView *view)
{
g_return_val_if_fail (MOO_IS_EDIT_VIEW (view), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (view->priv->progressbar), FALSE);
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (view->priv->progressbar));
update_progress (view);
return TRUE;
}
static void
progress_cancel_clicked (MooEditView *view)
{
g_return_if_fail (MOO_IS_EDIT_VIEW (view));
if (view->priv->state && view->priv->cancel_op)
view->priv->cancel_op (view->priv->cancel_data);
}
static gboolean
show_progress (MooEditView *view)
{
ProgressDialogXml *xml;
view->priv->progress_timeout = 0;
g_return_val_if_fail (!view->priv->progress, FALSE);
xml = progress_dialog_xml_new ();
view->priv->progress = GTK_WIDGET (xml->ProgressDialog);
view->priv->progressbar = GTK_WIDGET (xml->progressbar);
g_assert (GTK_IS_WIDGET (view->priv->progressbar));
g_signal_connect_swapped (xml->cancel, "clicked",
G_CALLBACK (progress_cancel_clicked),
view);
gtk_text_view_add_child_in_window (GTK_TEXT_VIEW (view),
view->priv->progress,
GTK_TEXT_WINDOW_WIDGET,
0, 0);
position_progress (view);
update_progress (view);
view->priv->progress_timeout =
gdk_threads_add_timeout (PROGRESS_TIMEOUT,
(GSourceFunc) pulse_progress,
view);
return FALSE;
}
void
_moo_edit_view_set_state (MooEditView *view,
MooEditState state,
const char *text,
GDestroyNotify cancel,
gpointer data)
{
g_return_if_fail (MOO_IS_EDIT_VIEW (view));
g_return_if_fail (state == MOO_EDIT_STATE_NORMAL ||
view->priv->state == MOO_EDIT_STATE_NORMAL);
view->priv->cancel_op = cancel;
view->priv->cancel_data = data;
if (state == view->priv->state)
return;
view->priv->state = state;
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !state);
if (!state)
{
if (view->priv->progress)
{
GtkWidget *tmp = view->priv->progress;
view->priv->progress = NULL;
view->priv->progressbar = NULL;
gtk_widget_destroy (tmp);
}
g_free (view->priv->progress_text);
view->priv->progress_text = NULL;
if (view->priv->progress_timeout)
g_source_remove (view->priv->progress_timeout);
view->priv->progress_timeout = 0;
}
else
{
if (!view->priv->progress_timeout)
view->priv->progress_timeout =
gdk_threads_add_timeout (PROGRESS_TIMEOUT,
(GSourceFunc) show_progress,
view);
view->priv->progress_text = g_strdup (text);
}
}
void
_moo_edit_view_ui_set_line_wrap (MooEditView *view,
gboolean enabled)

View File

@ -2,6 +2,7 @@
#define MOO_EDIT_WINDOW_IMPL_H
#include "mooedit/mooeditwindow.h"
#include "mooedit/mooeditprogress.h"
G_BEGIN_DECLS
@ -21,6 +22,9 @@ void _moo_edit_window_set_use_tabs (void);
void _moo_edit_tab_set_focused_view (MooEditTab *tab,
MooEditView *view);
MooEditProgress *_moo_edit_tab_create_progress (MooEditTab *tab);
void _moo_edit_tab_destroy_progress (MooEditTab *tab);
G_END_DECLS
#endif /* MOO_EDIT_WINDOW_IMPL_H */

View File

@ -9,6 +9,8 @@ struct MooEditTab
{
GtkVBox base;
MooEditProgress *progress;
GtkWidget *hpaned;
GtkWidget *vpaned1;
GtkWidget *vpaned2;

View File

@ -1863,18 +1863,18 @@ action_page_setup (MooEditWindow *window)
static void
action_print (MooEditWindow *window)
{
gpointer doc = ACTIVE_DOC (window);
g_return_if_fail (doc != NULL);
_moo_edit_print (doc, GTK_WIDGET (window));
MooEditView *view = ACTIVE_VIEW (window);
g_return_if_fail (view != NULL);
_moo_edit_print (GTK_TEXT_VIEW (view), GTK_WIDGET (window));
}
static void
action_print_preview (MooEditWindow *window)
{
gpointer doc = ACTIVE_DOC (window);
g_return_if_fail (doc != NULL);
_moo_edit_print_preview (doc, GTK_WIDGET (window));
MooEditView *view = ACTIVE_VIEW (window);
g_return_if_fail (view != NULL);
_moo_edit_print_preview (GTK_TEXT_VIEW (view), GTK_WIDGET (window));
}
@ -1884,7 +1884,10 @@ action_print_pdf (MooEditWindow *window)
char *start_name;
const char *doc_name, *dot;
const char *filename;
gpointer doc = ACTIVE_DOC (window);
MooEditView *view = ACTIVE_VIEW (window);
MooEdit *doc = view ? moo_edit_view_get_doc (view) : NULL;
g_return_if_fail (view != NULL);
doc_name = doc ? moo_edit_get_display_basename (doc) : "output";
dot = strrchr (doc_name, '.');
@ -1900,9 +1903,6 @@ action_print_pdf (MooEditWindow *window)
start_name = g_strdup_printf ("%s.pdf", doc_name);
}
doc = ACTIVE_DOC (window);
g_return_if_fail (doc != NULL);
filename = moo_file_dialogp (GTK_WIDGET (window),
MOO_FILE_DIALOG_SAVE,
start_name,
@ -1911,7 +1911,7 @@ action_print_pdf (MooEditWindow *window)
NULL);
if (filename)
_moo_edit_export_pdf (doc, filename);
_moo_edit_export_pdf (GTK_TEXT_VIEW (view), filename);
g_free (start_name);
}
@ -2465,7 +2465,7 @@ view_wrap_mode_changed (MooEditWindow *window,
G_GNUC_UNUSED GParamSpec *pspec,
MooEditView *view)
{
gpointer action;
GtkAction *action;
GtkWrapMode mode;
if (view != ACTIVE_VIEW (window))
@ -2475,7 +2475,7 @@ view_wrap_mode_changed (MooEditWindow *window,
g_return_if_fail (action != NULL);
g_object_get (view, "wrap-mode", &mode, NULL);
gtk_toggle_action_set_active (action, mode != GTK_WRAP_NONE);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), mode != GTK_WRAP_NONE);
/* XXX menu item and action go out of sync for some reason */
sync_proxies (action);
@ -2487,7 +2487,7 @@ view_show_line_numbers_changed (MooEditWindow *window,
G_GNUC_UNUSED GParamSpec *pspec,
MooEditView *view)
{
gpointer action;
GtkAction *action;
gboolean show;
if (view != ACTIVE_VIEW (window))
@ -2497,7 +2497,7 @@ view_show_line_numbers_changed (MooEditWindow *window,
g_return_if_fail (action != NULL);
g_object_get (view, "show-line-numbers", &show, NULL);
gtk_toggle_action_set_active (action, show);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show);
/* XXX menu item and action go out of sync for some reason */
sync_proxies (action);
@ -5084,3 +5084,26 @@ update_split_view_actions (MooEditWindow *window)
sync_proxies (action_split_horizontal);
sync_proxies (action_split_vertical);
}
MooEditProgress *
_moo_edit_tab_create_progress (MooEditTab *tab)
{
g_return_val_if_fail (MOO_IS_EDIT_TAB (tab), NULL);
g_return_val_if_fail (!tab->progress, tab->progress);
tab->progress = _moo_edit_progress_new ();
gtk_box_pack_start (GTK_BOX (tab), GTK_WIDGET (tab->progress), FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (tab), GTK_WIDGET (tab->progress), 0);
return tab->progress;
}
void
_moo_edit_tab_destroy_progress (MooEditTab *tab)
{
g_return_if_fail (MOO_IS_EDIT_TAB (tab));
g_return_if_fail (tab->progress != NULL);
gtk_widget_destroy (GTK_WIDGET (tab->progress));
tab->progress = NULL;
}

View File

@ -925,16 +925,18 @@ moo_print_operation_begin_print (GtkPrintOperation *operation,
if (MOO_IS_EDIT_VIEW (op->priv->doc))
{
MooEdit *doc = moo_edit_view_get_doc (MOO_EDIT_VIEW (op->priv->doc));
if (!op->priv->preview)
_moo_edit_view_set_state (MOO_EDIT_VIEW (op->priv->doc),
MOO_EDIT_STATE_PRINTING,
"Printing",
(GDestroyNotify) gtk_print_operation_cancel,
op);
_moo_edit_set_state (doc,
MOO_EDIT_STATE_PRINTING,
"Printing",
(GDestroyNotify) gtk_print_operation_cancel,
op);
else
_moo_edit_view_set_state (MOO_EDIT_VIEW (op->priv->doc),
MOO_EDIT_STATE_NORMAL,
NULL, NULL, NULL);
_moo_edit_set_state (doc,
MOO_EDIT_STATE_NORMAL,
NULL, NULL, NULL);
}
if (op->priv->last_line < 0)
@ -1504,9 +1506,9 @@ moo_print_operation_end_print (GtkPrintOperation *operation,
moo_dmsg ("moo_print_operation_end_print");
if (MOO_IS_EDIT_VIEW (op->priv->doc))
_moo_edit_view_set_state (MOO_EDIT_VIEW (op->priv->doc),
MOO_EDIT_STATE_NORMAL,
NULL, NULL, NULL);
_moo_edit_set_state (moo_edit_view_get_doc (MOO_EDIT_VIEW (op->priv->doc)),
MOO_EDIT_STATE_NORMAL,
NULL, NULL, NULL);
g_object_unref (op->priv->layout);
op->priv->layout = NULL;
@ -1524,11 +1526,13 @@ update_progress (GtkPrintOperation *operation,
GtkPrintStatus status;
MooEditWindow *window;
MooEditView *view;
MooEdit *doc;
if (!MOO_IS_EDIT_VIEW (op->priv->doc))
return;
view = MOO_EDIT_VIEW (op->priv->doc);
doc = moo_edit_view_get_doc (view);
window = moo_edit_view_get_window (view);
status = gtk_print_operation_get_status (operation);
@ -1550,8 +1554,8 @@ update_progress (GtkPrintOperation *operation,
if (window)
moo_window_message (MOO_WINDOW (window), NULL);
if (_moo_edit_view_get_state (view) == MOO_EDIT_STATE_PRINTING)
_moo_edit_view_set_progress_text (view, text);
if (_moo_edit_get_state (doc) == MOO_EDIT_STATE_PRINTING)
_moo_edit_set_progress_text (doc, text);
else if (window)
moo_window_message (MOO_WINDOW (window), text);