diff --git a/configure.ac b/configure.ac
index dcacfec..29e9783 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,7 @@ GLIB_GSETTINGS
dnl ================================================================
dnl Misc
dnl ================================================================
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
diff --git a/debian/rules b/debian/rules
index dc10b29..b6118b3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,7 @@ DHFLAGS=--parallel
override_dh_install:
rm -rfv debian/tmp/usr/lib/*/xed/plugins/*.la
+ rm -rfv debian/tmp/usr/lib/*/xed/*.la
dh_install --fail-missing
override_dh_auto_configure:
diff --git a/debian/xed-common.install b/debian/xed-common.install
index 361f4b2..75d4ae1 100644
--- a/debian/xed-common.install
+++ b/debian/xed-common.install
@@ -4,4 +4,3 @@ usr/share/glib-2.0
usr/share/help
usr/share/locale
usr/share/xed/icons
-usr/share/xed/ui/
diff --git a/debian/xed.install b/debian/xed.install
index 755fad6..664190c 100644
--- a/debian/xed.install
+++ b/debian/xed.install
@@ -3,6 +3,7 @@ usr/lib/*/xed/girepository-1.0/
usr/lib/xed/xed-bugreport.sh
usr/lib/*/xed/plugins/*.plugin
usr/lib/*/xed/plugins/*.so
+usr/lib/*/xed/*.so
usr/share/applications/xed.desktop
usr/share/dbus-1/
usr/share/man/
diff --git a/xed/Makefile.am b/xed/Makefile.am
index 4df6419..0720e42 100644
--- a/xed/Makefile.am
+++ b/xed/Makefile.am
@@ -2,7 +2,7 @@
bin_PROGRAMS = xed
-noinst_LTLIBRARIES = libxed.la
+pkglib_LTLIBRARIES = libxed.la
AM_CPPFLAGS = \
-I$(top_srcdir) \
@@ -24,7 +24,7 @@ xed_LDADD = \
xed_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
-libxed_la_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
+libxed_la_LDFLAGS = -avoid-version -export-dynamic -no-undefined -export-symbols-regex "^[^_].*"
# XED_LIBS must be the last to ensure correct order on some platforms
libxed_la_LIBADD = $(XED_LIBS)
@@ -87,10 +87,15 @@ headerdir = $(prefix)/include/xed
header_DATA = \
$(INST_H_FILES)
+BUILT_SOURCES_PRIVATE = \
+ xed-resources.c
libxed_c_files = \
- xed-app.c \
+ xed-app.c \
xed-app-activatable.c \
+ xed-view-activatable.c \
+ xed-window-activatable.c \
+ xed-resources.c \
xed-close-button.c \
xed-close-confirmation-dialog.c \
xed-commands-documents.c \
@@ -127,10 +132,8 @@ libxed_c_files = \
xed-tab-label.c \
xed-utils.c \
xed-view.c \
- xed-view-activatable.c \
xed-view-frame.c \
- xed-window.c \
- xed-window-activatable.c
+ xed-window.c
libxed_la_SOURCES = \
$(BUILT_SOURCES) \
@@ -156,29 +159,28 @@ xed-marshal.c: xed-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN) echo "#include \"xed-marshal.h\"" > $@ && \
$(GLIB_GENMARSHAL) $< --body --prefix=xed_marshal >> $@
-uidir = $(datadir)/xed/ui/
-ui_DATA = \
- xed-ui.xml \
- xed-searchbar.ui \
- xed-print-preferences.ui \
- xed-encodings-dialog.ui \
- xed-preferences-dialog.ui
+xed-resources.c: resources/xed.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/resources --generate-dependencies $(srcdir)/resources/xed.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/resources --generate-source $(srcdir)/resources/xed.gresource.xml
-EXTRA_DIST = \
- $(ui_DATA) \
- xed-enum-types.h.template \
- xed-enum-types.c.template \
- xed-marshal.list \
- xed.rc
+EXTRA_DIST = \
+ xed-enum-types.h.template \
+ xed-enum-types.c.template \
+ xed-marshal.list \
+ xed.rc \
+ resources/xed.gresource.xml \
+ resources/ui/xed-ui.xml \
+ resources/ui/xed-encodings-dialog.ui \
+ resources/ui/xed-preferences-dialog.ui \
+ resources/ui/xed-print-preferences.ui \
+ resources/ui/xed-searchbar.ui \
+ resources/ui/xed-view-frame.ui
-CLEANFILES = $(BUILT_SOURCES)
+CLEANFILES = $(BUILT_SOURCES) $(BUILT_SOURCES_PRIVATE)
if HAVE_INTROSPECTION
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS = Xed-1.0.gir
-
-
Xed-1.0.gir: xed
INTROSPECTION_SCANNER_ARGS = -I$(top_srcdir) --warn-all
Xed_1_0_gir_NAMESPACE = Xed
@@ -199,6 +201,6 @@ CLEANFILES += \
endif
dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
+ cd $(distdir); rm -f $(BUILT_SOURCES) $(BUILT_SOURCES_PRIVATE)
-include $(top_srcdir)/git.mk
diff --git a/xed/xed-encodings-dialog.ui b/xed/resources/ui/xed-encodings-dialog.ui
similarity index 100%
rename from xed/xed-encodings-dialog.ui
rename to xed/resources/ui/xed-encodings-dialog.ui
diff --git a/xed/xed-preferences-dialog.ui b/xed/resources/ui/xed-preferences-dialog.ui
similarity index 100%
rename from xed/xed-preferences-dialog.ui
rename to xed/resources/ui/xed-preferences-dialog.ui
diff --git a/xed/xed-print-preferences.ui b/xed/resources/ui/xed-print-preferences.ui
similarity index 100%
rename from xed/xed-print-preferences.ui
rename to xed/resources/ui/xed-print-preferences.ui
diff --git a/xed/xed-searchbar.ui b/xed/resources/ui/xed-searchbar.ui
similarity index 100%
rename from xed/xed-searchbar.ui
rename to xed/resources/ui/xed-searchbar.ui
diff --git a/xed/xed-ui.xml b/xed/resources/ui/xed-ui.xml
similarity index 100%
rename from xed/xed-ui.xml
rename to xed/resources/ui/xed-ui.xml
diff --git a/xed/resources/ui/xed-view-frame.ui b/xed/resources/ui/xed-view-frame.ui
new file mode 100644
index 0000000..81fe13e
--- /dev/null
+++ b/xed/resources/ui/xed-view-frame.ui
@@ -0,0 +1,56 @@
+
+
+
+
+ True
+ False
+ False
+ False
+
+
+
+
+
+ True
+ False
+ end
+ start
+
+
+ True
+ False
+
+
+
+ True
+ False
+ horizontal
+
+
+ True
+ True
+ 25
+
+
+
+
+
+
+
+
+
+
diff --git a/xed/resources/xed.gresource.xml b/xed/resources/xed.gresource.xml
new file mode 100644
index 0000000..f960a0d
--- /dev/null
+++ b/xed/resources/xed.gresource.xml
@@ -0,0 +1,11 @@
+
+
+
+ ui/xed-ui.xml
+ ui/xed-encodings-dialog.ui
+ ui/xed-preferences-dialog.ui
+ ui/xed-print-preferences.ui
+ ui/xed-searchbar.ui
+ ui/xed-view-frame.ui
+
+
\ No newline at end of file
diff --git a/xed/xed-encodings-dialog.c b/xed/xed-encodings-dialog.c
index 1be461c..babc2f0 100755
--- a/xed/xed-encodings-dialog.c
+++ b/xed/xed-encodings-dialog.c
@@ -322,14 +322,12 @@ init_liststore_available (XedEncodingsDialog *dialog)
static void
xed_encodings_dialog_init (XedEncodingsDialog *dlg)
{
+ GtkBuilder *builder;
GtkWidget *content;
GtkCellRenderer *cell_renderer;
GtkTreeModel *sort_model;
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
- GtkWidget *error_widget;
- gboolean ret;
- gchar *file;
gchar *root_objects[] = {
"encodings-dialog-contents",
NULL
@@ -355,27 +353,16 @@ xed_encodings_dialog_init (XedEncodingsDialog *dlg)
g_signal_connect (dlg, "response", G_CALLBACK (response_handler), dlg);
- file = xed_dirs_get_ui_file ("xed-encodings-dialog.ui");
- ret = xed_utils_get_ui_objects (file,
- root_objects,
- &error_widget,
- "encodings-dialog-contents", &content,
- "add-button", &dlg->priv->add_button,
- "remove-button", &dlg->priv->remove_button,
- "available-treeview", &dlg->priv->available_treeview,
- "displayed-treeview", &dlg->priv->displayed_treeview,
- NULL);
- g_free (file);
-
- if (!ret)
- {
- gtk_widget_show (error_widget);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), error_widget, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (error_widget), 5);
-
- return;
- }
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_resource (builder, "/org/x/editor/ui/xed-encodings-dialog.ui",
+ root_objects, NULL);
+ content = GTK_WIDGET (gtk_builder_get_object (builder, "encodings-dialog-contents"));
+ g_object_ref (content);
+ dlg->priv->add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add-button"));
+ dlg->priv->remove_button = GTK_WIDGET (gtk_builder_get_object (builder, "remove-button"));
+ dlg->priv->available_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "available-treeview"));
+ dlg->priv->displayed_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "displayed-treeview"));
+ g_object_unref (builder);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), content, TRUE, TRUE, 0);
g_object_unref (content);
diff --git a/xed/xed-preferences-dialog.c b/xed/xed-preferences-dialog.c
index 1038d8c..0046c4a 100755
--- a/xed/xed-preferences-dialog.c
+++ b/xed/xed-preferences-dialog.c
@@ -1070,15 +1070,12 @@ setup_plugins_page (XedPreferencesDialog *dlg)
static void
xed_preferences_dialog_init (XedPreferencesDialog *dlg)
{
- GtkWidget *error_widget;
- gboolean ret;
- gchar *file;
+ GtkBuilder *builder;
gchar *root_objects[] = {
"notebook",
"adjustment1",
"adjustment2",
"adjustment3",
- "install_scheme_image",
NULL
};
@@ -1106,52 +1103,35 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
g_signal_connect (dlg, "response",
G_CALLBACK (dialog_response_handler), NULL);
- file = xed_dirs_get_ui_file ("xed-preferences-dialog.ui");
- ret = xed_utils_get_ui_objects (file, root_objects, &error_widget,
- "notebook", &dlg->priv->notebook,
-
- "display_line_numbers_checkbutton", &dlg->priv->display_line_numbers_checkbutton,
- "highlight_current_line_checkbutton", &dlg->priv->highlight_current_line_checkbutton,
- "bracket_matching_checkbutton", &dlg->priv->bracket_matching_checkbutton,
- "wrap_text_checkbutton", &dlg->priv->wrap_text_checkbutton,
- "split_checkbutton", &dlg->priv->split_checkbutton,
-
- "right_margin_checkbutton", &dlg->priv->right_margin_checkbutton,
- "right_margin_position_spinbutton", &dlg->priv->right_margin_position_spinbutton,
- "right_margin_position_hbox", &dlg->priv->right_margin_position_hbox,
-
- "tabs_width_spinbutton", &dlg->priv->tabs_width_spinbutton,
- "tabs_width_hbox", &dlg->priv->tabs_width_hbox,
- "insert_spaces_checkbutton", &dlg->priv->insert_spaces_checkbutton,
-
- "auto_indent_checkbutton", &dlg->priv->auto_indent_checkbutton,
-
- "autosave_hbox", &dlg->priv->autosave_hbox,
- "backup_copy_checkbutton", &dlg->priv->backup_copy_checkbutton,
- "auto_save_checkbutton", &dlg->priv->auto_save_checkbutton,
- "auto_save_spinbutton", &dlg->priv->auto_save_spinbutton,
-
- "tab_scrolling_checkbutton", &dlg->priv->tab_scrolling_checkbutton,
-
- "default_font_checkbutton", &dlg->priv->default_font_checkbutton,
- "font_button", &dlg->priv->font_button,
- "font_hbox", &dlg->priv->font_hbox,
-
- "schemes_treeview", &dlg->priv->schemes_treeview,
- "install_scheme_button", &dlg->priv->install_scheme_button,
- "uninstall_scheme_button", &dlg->priv->uninstall_scheme_button,
-
- "plugin_manager_place_holder", &dlg->priv->plugin_manager_place_holder,
-
- NULL);
- g_free (file);
-
- if (!ret)
- {
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), error_widget, TRUE, TRUE, 0);
- return;
- }
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_resource (builder, "/org/x/editor/ui/xed-preferences-dialog.ui", root_objects, NULL);
+ dlg->priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+ g_object_ref (dlg->priv->notebook);
+ dlg->priv->display_line_numbers_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "display_line_numbers_checkbutton"));
+ dlg->priv->highlight_current_line_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "highlight_current_line_checkbutton"));
+ dlg->priv->bracket_matching_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "bracket_matching_checkbutton"));
+ dlg->priv->wrap_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_text_checkbutton"));
+ dlg->priv->split_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "split_checkbutton"));
+ dlg->priv->right_margin_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "right_margin_checkbutton"));
+ dlg->priv->right_margin_position_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "right_margin_position_spinbutton"));
+ dlg->priv->right_margin_position_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "right_margin_position_hbox"));
+ dlg->priv->tabs_width_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "tabs_width_spinbutton"));
+ dlg->priv->tabs_width_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "tabs_width_hbox"));
+ dlg->priv->insert_spaces_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "insert_spaces_checkbutton"));
+ dlg->priv->auto_indent_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "auto_indent_checkbutton"));
+ dlg->priv->autosave_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_hbox"));
+ dlg->priv->backup_copy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "backup_copy_checkbutton"));
+ dlg->priv->auto_save_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "auto_save_checkbutton"));
+ dlg->priv->auto_save_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "auto_save_spinbutton"));
+ dlg->priv->tab_scrolling_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "tab_scrolling_checkbutton"));
+ dlg->priv->default_font_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "default_font_checkbutton"));
+ dlg->priv->font_button = GTK_WIDGET (gtk_builder_get_object (builder, "font_button"));
+ dlg->priv->font_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "font_hbox"));
+ dlg->priv->schemes_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "schemes_treeview"));
+ dlg->priv->install_scheme_button = GTK_WIDGET (gtk_builder_get_object (builder, "install_scheme_button"));
+ dlg->priv->uninstall_scheme_button = GTK_WIDGET (gtk_builder_get_object (builder, "uninstall_scheme_button"));
+ dlg->priv->plugin_manager_place_holder = GTK_WIDGET (gtk_builder_get_object (builder, "plugin_manager_place_holder"));
+ g_object_unref (builder);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), dlg->priv->notebook, FALSE, FALSE, 0);
g_object_unref (dlg->priv->notebook);
diff --git a/xed/xed-print-job.c b/xed/xed-print-job.c
index 5963b2b..e76d0d8 100644
--- a/xed/xed-print-job.c
+++ b/xed/xed-print-job.c
@@ -46,62 +46,62 @@
#define XED_PRINT_JOB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- XED_TYPE_PRINT_JOB, \
- XedPrintJobPrivate))
+ XED_TYPE_PRINT_JOB, \
+ XedPrintJobPrivate))
struct _XedPrintJobPrivate
{
- GSettings *print_settings;
+ GSettings *print_settings;
- XedView *view;
- XedDocument *doc;
+ XedView *view;
+ XedDocument *doc;
- GtkPrintOperation *operation;
- GtkSourcePrintCompositor *compositor;
+ GtkPrintOperation *operation;
+ GtkSourcePrintCompositor *compositor;
- GtkPrintSettings *settings;
+ GtkPrintSettings *settings;
- GtkWidget *preview;
+ GtkWidget *preview;
- XedPrintJobStatus status;
+ XedPrintJobStatus status;
- gchar *status_string;
+ gchar *status_string;
- gdouble progress;
+ gdouble progress;
- gboolean is_preview;
+ gboolean is_preview;
- /* widgets part of the custom print preferences widget.
- * These pointers are valid just when the dialog is displayed */
- GtkWidget *syntax_checkbutton;
- GtkWidget *page_header_checkbutton;
- GtkWidget *line_numbers_checkbutton;
- GtkWidget *line_numbers_hbox;
- GtkWidget *line_numbers_spinbutton;
- GtkWidget *text_wrapping_checkbutton;
- GtkWidget *do_not_split_checkbutton;
- GtkWidget *fonts_table;
- GtkWidget *body_font_label;
- GtkWidget *headers_font_label;
- GtkWidget *numbers_font_label;
- GtkWidget *body_fontbutton;
- GtkWidget *headers_fontbutton;
- GtkWidget *numbers_fontbutton;
- GtkWidget *restore_button;
+ /* widgets part of the custom print preferences widget.
+ * These pointers are valid just when the dialog is displayed */
+ GtkWidget *syntax_checkbutton;
+ GtkWidget *page_header_checkbutton;
+ GtkWidget *line_numbers_checkbutton;
+ GtkWidget *line_numbers_hbox;
+ GtkWidget *line_numbers_spinbutton;
+ GtkWidget *text_wrapping_checkbutton;
+ GtkWidget *do_not_split_checkbutton;
+ GtkWidget *fonts_table;
+ GtkWidget *body_font_label;
+ GtkWidget *headers_font_label;
+ GtkWidget *numbers_font_label;
+ GtkWidget *body_fontbutton;
+ GtkWidget *headers_fontbutton;
+ GtkWidget *numbers_fontbutton;
+ GtkWidget *restore_button;
};
enum
{
- PROP_0,
- PROP_VIEW
+ PROP_0,
+ PROP_VIEW
};
enum
{
- PRINTING,
- SHOW_PREVIEW,
- DONE,
- LAST_SIGNAL
+ PRINTING,
+ SHOW_PREVIEW,
+ DONE,
+ LAST_SIGNAL
};
static guint print_job_signals[LAST_SIGNAL] = { 0 };
@@ -109,64 +109,69 @@ static guint print_job_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (XedPrintJob, xed_print_job, G_TYPE_OBJECT)
static void
-set_view (XedPrintJob *job, XedView *view)
+set_view (XedPrintJob *job,
+ XedView *view)
{
- job->priv->view = view;
- job->priv->doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+ job->priv->view = view;
+ job->priv->doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
}
static void
xed_print_job_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- XedPrintJob *job = XED_PRINT_JOB (object);
+ XedPrintJob *job = XED_PRINT_JOB (object);
- switch (prop_id)
- {
- case PROP_VIEW:
- g_value_set_object (value, job->priv->view);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_VIEW:
+ g_value_set_object (value, job->priv->view);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
xed_print_job_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- XedPrintJob *job = XED_PRINT_JOB (object);
+ XedPrintJob *job = XED_PRINT_JOB (object);
- switch (prop_id)
- {
- case PROP_VIEW:
- set_view (job, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_VIEW:
+ set_view (job, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
xed_print_job_finalize (GObject *object)
{
- XedPrintJob *job = XED_PRINT_JOB (object);
+ XedPrintJob *job = XED_PRINT_JOB (object);
- g_free (job->priv->status_string);
+ g_free (job->priv->status_string);
- if (job->priv->compositor != NULL)
- g_object_unref (job->priv->compositor);
+ if (job->priv->compositor != NULL)
+ {
+ g_object_unref (job->priv->compositor);
+ }
- if (job->priv->operation != NULL)
- g_object_unref (job->priv->operation);
+ if (job->priv->operation != NULL)
+ {
+ g_object_unref (job->priv->operation);
+ }
- G_OBJECT_CLASS (xed_print_job_parent_class)->finalize (object);
+ G_OBJECT_CLASS (xed_print_job_parent_class)->finalize (object);
}
static void
@@ -182,101 +187,95 @@ xed_print_job_dispose (GObject *object)
static void
xed_print_job_class_init (XedPrintJobClass *klass)
{
- GObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = xed_print_job_get_property;
- object_class->set_property = xed_print_job_set_property;
- object_class->finalize = xed_print_job_finalize;
+ object_class->get_property = xed_print_job_get_property;
+ object_class->set_property = xed_print_job_set_property;
+ object_class->finalize = xed_print_job_finalize;
object_class->dispose = xed_print_job_dispose;
- g_object_class_install_property (object_class,
- PROP_VIEW,
- g_param_spec_object ("view",
- "Xed View",
- "Xed View to print",
- XED_TYPE_VIEW,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS |
- G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_VIEW,
+ g_param_spec_object ("view",
+ "Xed View",
+ "Xed View to print",
+ XED_TYPE_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_CONSTRUCT_ONLY));
- print_job_signals[PRINTING] =
- g_signal_new ("printing",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (XedPrintJobClass, printing),
- NULL, NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE,
- 1,
- G_TYPE_UINT);
+ print_job_signals[PRINTING] =
+ g_signal_new ("printing",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (XedPrintJobClass, printing),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_UINT);
- print_job_signals[SHOW_PREVIEW] =
- g_signal_new ("show-preview",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (XedPrintJobClass, show_preview),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_WIDGET);
+ print_job_signals[SHOW_PREVIEW] =
+ g_signal_new ("show-preview",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (XedPrintJobClass, show_preview),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_WIDGET);
- print_job_signals[DONE] =
- g_signal_new ("done",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (XedPrintJobClass, done),
- NULL, NULL,
- xed_marshal_VOID__UINT_POINTER,
- G_TYPE_NONE,
- 2,
- G_TYPE_UINT,
- G_TYPE_POINTER);
+ print_job_signals[DONE] =
+ g_signal_new ("done",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (XedPrintJobClass, done),
+ NULL, NULL,
+ xed_marshal_VOID__UINT_POINTER,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_UINT,
+ G_TYPE_POINTER);
- g_type_class_add_private (object_class, sizeof (XedPrintJobPrivate));
+ g_type_class_add_private (object_class, sizeof (XedPrintJobPrivate));
}
static void
line_numbers_checkbutton_toggled (GtkToggleButton *button,
- XedPrintJob *job)
+ XedPrintJob *job)
{
- gtk_widget_set_sensitive (job->priv->line_numbers_hbox, gtk_toggle_button_get_active (button));
+ gtk_widget_set_sensitive (job->priv->line_numbers_hbox, gtk_toggle_button_get_active (button));
}
static void
wrap_mode_checkbutton_toggled (GtkToggleButton *button,
- XedPrintJob *job)
+ XedPrintJob *job)
{
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
- {
- gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton,
- FALSE);
- gtk_toggle_button_set_inconsistent (
- GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton),
- TRUE);
- }
- else
- {
- gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton,
- TRUE);
- gtk_toggle_button_set_inconsistent (
- GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton),
- FALSE);
- }
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
+ {
+ gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton, FALSE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton, TRUE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), FALSE);
+ }
}
static void
-restore_button_clicked (GtkButton *button,
- XedPrintJob *job)
+restore_button_clicked (GtkButton *button,
+ XedPrintJob *job)
{
- gchar *body;
+ gchar *body;
gchar *header;
gchar *numbers;
- body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
+ body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
header = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO);
numbers = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO);
@@ -291,50 +290,41 @@ restore_button_clicked (GtkButton *button,
static GObject *
create_custom_widget_cb (GtkPrintOperation *operation,
- XedPrintJob *job)
+ XedPrintJob *job)
{
- gboolean ret;
- GtkWidget *widget;
- GtkWidget *error_widget;
- guint line_numbers;
- GtkWrapMode wrap_mode;
- gchar *file;
+ GtkBuilder *builder;
+ GtkWidget *contents;
+ guint line_numbers;
+ GtkWrapMode wrap_mode;
gboolean syntax_hl;
gboolean print_header;
gchar *font_body, *font_header, *font_numbers;
- gchar *root_objects[] = {
- "adjustment1",
- "contents",
- NULL
- };
+ gchar *root_objects[] = {
+ "adjustment1",
+ "contents",
+ NULL
+ };
- file = xed_dirs_get_ui_file ("xed-print-preferences.ui");
- ret = xed_utils_get_ui_objects (file,
- root_objects,
- &error_widget,
- "contents", &widget,
- "syntax_checkbutton", &job->priv->syntax_checkbutton,
- "line_numbers_checkbutton", &job->priv->line_numbers_checkbutton,
- "line_numbers_hbox", &job->priv->line_numbers_hbox,
- "line_numbers_spinbutton", &job->priv->line_numbers_spinbutton,
- "page_header_checkbutton", &job->priv->page_header_checkbutton,
- "text_wrapping_checkbutton", &job->priv->text_wrapping_checkbutton,
- "do_not_split_checkbutton", &job->priv->do_not_split_checkbutton,
- "fonts_table", &job->priv->fonts_table,
- "body_font_label", &job->priv->body_font_label,
- "body_fontbutton", &job->priv->body_fontbutton,
- "headers_font_label", &job->priv->headers_font_label,
- "headers_fontbutton", &job->priv->headers_fontbutton,
- "numbers_font_label", &job->priv->numbers_font_label,
- "numbers_fontbutton", &job->priv->numbers_fontbutton,
- "restore_button", &job->priv->restore_button,
- NULL);
- g_free (file);
-
- if (!ret)
- {
- return G_OBJECT (error_widget);
- }
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_resource (builder, "/org/x/editor/ui/xed-print-preferences.ui", root_objects, NULL);
+ contents = GTK_WIDGET (gtk_builder_get_object (builder, "contents"));
+ g_object_ref (contents);
+ job->priv->syntax_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "syntax_checkbutton"));
+ job->priv->line_numbers_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "line_numbers_checkbutton"));
+ job->priv->line_numbers_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "line_numbers_hbox"));
+ job->priv->line_numbers_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "line_numbers_spinbutton"));
+ job->priv->page_header_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "page_header_checkbutton"));
+ job->priv->text_wrapping_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "text_wrapping_checkbutton"));
+ job->priv->do_not_split_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "do_not_split_checkbutton"));
+ job->priv->fonts_table = GTK_WIDGET (gtk_builder_get_object (builder, "fonts_table"));
+ job->priv->body_font_label = GTK_WIDGET (gtk_builder_get_object (builder, "body_font_label"));
+ job->priv->body_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "body_fontbutton"));
+ job->priv->headers_font_label = GTK_WIDGET (gtk_builder_get_object (builder, "headers_font_label"));
+ job->priv->headers_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "headers_fontbutton"));
+ job->priv->numbers_font_label = GTK_WIDGET (gtk_builder_get_object (builder, "numbers_font_label"));
+ job->priv->numbers_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "numbers_fontbutton"));
+ job->priv->restore_button = GTK_WIDGET (gtk_builder_get_object (builder, "restore_button"));
+ g_object_unref (builder);
/* Get all settings values */
syntax_hl = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING);
@@ -344,89 +334,74 @@ create_custom_widget_cb (GtkPrintOperation *operation,
font_header = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO);
font_numbers = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO);
- /* Print syntax */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->syntax_checkbutton), syntax_hl);
+ /* Print syntax */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->syntax_checkbutton), syntax_hl);
- /* Print page headers */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->page_header_checkbutton), print_header);
+ /* Print page headers */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->page_header_checkbutton), print_header);
- /* Line numbers */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton), line_numbers > 0);
+ /* Line numbers */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton), line_numbers > 0);
- if (line_numbers > 0)
- {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton), (guint) line_numbers);
- gtk_widget_set_sensitive (job->priv->line_numbers_hbox, TRUE);
- }
- else
- {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton),
- 1);
- gtk_widget_set_sensitive (job->priv->line_numbers_hbox, FALSE);
- }
+ if (line_numbers > 0)
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton), (guint) line_numbers);
+ gtk_widget_set_sensitive (job->priv->line_numbers_hbox, TRUE);
+ }
+ else
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton), 1);
+ gtk_widget_set_sensitive (job->priv->line_numbers_hbox, FALSE);
+ }
- /* Text wrapping */
- wrap_mode = g_settings_get_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE);
+ /* Text wrapping */
+ wrap_mode = g_settings_get_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE);
- switch (wrap_mode)
- {
- case GTK_WRAP_WORD:
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton), TRUE);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
- break;
- case GTK_WRAP_CHAR:
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton), TRUE);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), FALSE);
- break;
- default:
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton), FALSE);
- gtk_toggle_button_set_inconsistent (
- GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
- }
+ switch (wrap_mode)
+ {
+ case GTK_WRAP_WORD:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
+ break;
+ case GTK_WRAP_CHAR:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), FALSE);
+ break;
+ default:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton), FALSE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton), TRUE);
+ }
- gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton, wrap_mode != GTK_WRAP_NONE);
+ gtk_widget_set_sensitive (job->priv->do_not_split_checkbutton, wrap_mode != GTK_WRAP_NONE);
- /* Set initial values */
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton), font_body);
- g_free (font_body);
+ /* Set initial values */
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->body_fontbutton), font_body);
+ g_free (font_body);
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton), font_header);
- g_free (font_header);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->headers_fontbutton), font_header);
+ g_free (font_header);
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton), font_numbers);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (job->priv->numbers_fontbutton), font_numbers);
g_free (font_numbers);
- g_signal_connect (job->priv->line_numbers_checkbutton,
- "toggled",
- G_CALLBACK (line_numbers_checkbutton_toggled),
- job);
- g_signal_connect (job->priv->text_wrapping_checkbutton,
- "toggled",
- G_CALLBACK (wrap_mode_checkbutton_toggled),
- job);
- g_signal_connect (job->priv->do_not_split_checkbutton,
- "toggled",
- G_CALLBACK (wrap_mode_checkbutton_toggled),
- job);
- g_signal_connect (job->priv->restore_button,
- "clicked",
- G_CALLBACK (restore_button_clicked),
- job);
+ g_signal_connect (job->priv->line_numbers_checkbutton, "toggled",
+ G_CALLBACK (line_numbers_checkbutton_toggled), job);
+ g_signal_connect (job->priv->text_wrapping_checkbutton, "toggled",
+ G_CALLBACK (wrap_mode_checkbutton_toggled), job);
+ g_signal_connect (job->priv->do_not_split_checkbutton, "toggled",
+ G_CALLBACK (wrap_mode_checkbutton_toggled), job);
+ g_signal_connect (job->priv->restore_button, "clicked",
+ G_CALLBACK (restore_button_clicked), job);
- return G_OBJECT (widget);
+ return G_OBJECT (contents);
}
static void
custom_widget_apply_cb (GtkPrintOperation *operation,
- GtkWidget *widget,
- XedPrintJob *job)
+ GtkWidget *widget,
+ XedPrintJob *job)
{
- gboolean syntax, page_header;
+ gboolean syntax, page_header;
const gchar *body, *header, *numbers;
GtkWrapMode wrap_mode;
@@ -442,31 +417,31 @@ custom_widget_apply_cb (GtkPrintOperation *operation,
g_settings_set_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO, header);
g_settings_set_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO, numbers);
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton)))
- {
- g_settings_set_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS,
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->line_numbers_checkbutton)))
+ {
+ g_settings_set_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS,
MAX (1, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (job->priv->line_numbers_spinbutton))));
- }
- else
- {
- g_settings_set_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS, 0);
- }
+ }
+ else
+ {
+ g_settings_set_uint (job->priv->print_settings, XED_SETTINGS_PRINT_LINE_NUMBERS, 0);
+ }
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
- {
- wrap_mode = GTK_WRAP_NONE;
- }
- else
- {
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton)))
- {
- wrap_mode = GTK_WRAP_WORD;
- }
- else
- {
- wrap_mode = GTK_WRAP_CHAR;
- }
- }
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->text_wrapping_checkbutton)))
+ {
+ wrap_mode = GTK_WRAP_NONE;
+ }
+ else
+ {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (job->priv->do_not_split_checkbutton)))
+ {
+ wrap_mode = GTK_WRAP_WORD;
+ }
+ else
+ {
+ wrap_mode = GTK_WRAP_CHAR;
+ }
+ }
g_settings_set_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE, wrap_mode);
}
@@ -474,16 +449,16 @@ custom_widget_apply_cb (GtkPrintOperation *operation,
static void
create_compositor (XedPrintJob *job)
{
- gchar *print_font_body;
- gchar *print_font_header;
- gchar *print_font_numbers;
+ gchar *print_font_body;
+ gchar *print_font_header;
+ gchar *print_font_numbers;
gboolean syntax_hl;
GtkWrapMode wrap_mode;
guint print_line_numbers;
gboolean print_header;
- /* Create and initialize print compositor */
- print_font_body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
+ /* Create and initialize print compositor */
+ print_font_body = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_BODY_PANGO);
print_font_header = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_HEADER_PANGO);
print_font_numbers = g_settings_get_string (job->priv->print_settings, XED_SETTINGS_PRINT_FONT_NUMBERS_PANGO);
syntax_hl = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_SYNTAX_HIGHLIGHTING);
@@ -491,356 +466,332 @@ create_compositor (XedPrintJob *job)
print_header = g_settings_get_boolean (job->priv->print_settings, XED_SETTINGS_PRINT_HEADER);
wrap_mode = g_settings_get_enum (job->priv->print_settings, XED_SETTINGS_PRINT_WRAP_MODE);
- job->priv->compositor = GTK_SOURCE_PRINT_COMPOSITOR (
- g_object_new (GTK_SOURCE_TYPE_PRINT_COMPOSITOR,
- "buffer", GTK_SOURCE_BUFFER (job->priv->doc),
- "tab-width", gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (job->priv->view)),
- "highlight-syntax", gtk_source_buffer_get_highlight_syntax (GTK_SOURCE_BUFFER (job->priv->doc)) &&
- syntax_hl,
- "wrap-mode", wrap_mode,
- "print-line-numbers", print_line_numbers,
- "print-header", print_header,
- "print-footer", FALSE,
- "body-font-name", print_font_body,
- "line-numbers-font-name", print_font_numbers,
- "header-font-name", print_font_header,
- NULL));
+ job->priv->compositor = GTK_SOURCE_PRINT_COMPOSITOR (
+ g_object_new (GTK_SOURCE_TYPE_PRINT_COMPOSITOR,
+ "buffer", GTK_SOURCE_BUFFER (job->priv->doc),
+ "tab-width", gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (job->priv->view)),
+ "highlight-syntax", gtk_source_buffer_get_highlight_syntax (GTK_SOURCE_BUFFER (job->priv->doc)) &&
+ syntax_hl,
+ "wrap-mode", wrap_mode,
+ "print-line-numbers", print_line_numbers,
+ "print-header", print_header,
+ "print-footer", FALSE,
+ "body-font-name", print_font_body,
+ "line-numbers-font-name", print_font_numbers,
+ "header-font-name", print_font_header,
+ NULL));
- g_free (print_font_body);
- g_free (print_font_header);
- g_free (print_font_numbers);
+ g_free (print_font_body);
+ g_free (print_font_header);
+ g_free (print_font_numbers);
- if (print_header)
- {
- gchar *doc_name;
- gchar *name_to_display;
- gchar *left;
+ if (print_header)
+ {
+ gchar *doc_name;
+ gchar *name_to_display;
+ gchar *left;
- doc_name = xed_document_get_uri_for_display (job->priv->doc);
- name_to_display = xed_utils_str_middle_truncate (doc_name, 60);
+ doc_name = xed_document_get_uri_for_display (job->priv->doc);
+ name_to_display = xed_utils_str_middle_truncate (doc_name, 60);
- left = g_strdup_printf (_("File: %s"), name_to_display);
+ left = g_strdup_printf (_("File: %s"), name_to_display);
- /* Translators: %N is the current page number, %Q is the total
- * number of pages (ex. Page 2 of 10)
- */
- gtk_source_print_compositor_set_header_format (job->priv->compositor,
- TRUE,
- left,
- NULL,
- _("Page %N of %Q"));
+ /* Translators: %N is the current page number, %Q is the total
+ * number of pages (ex. Page 2 of 10)
+ */
+ gtk_source_print_compositor_set_header_format (job->priv->compositor,
+ TRUE,
+ left,
+ NULL,
+ _("Page %N of %Q"));
- g_free (doc_name);
- g_free (name_to_display);
- g_free (left);
- }
+ g_free (doc_name);
+ g_free (name_to_display);
+ g_free (left);
+ }
}
static void
begin_print_cb (GtkPrintOperation *operation,
- GtkPrintContext *context,
- XedPrintJob *job)
+ GtkPrintContext *context,
+ XedPrintJob *job)
{
- create_compositor (job);
+ create_compositor (job);
- job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
+ job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
- job->priv->progress = 0.0;
+ job->priv->progress = 0.0;
- g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
+ g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
}
static void
preview_ready (GtkPrintOperationPreview *gtk_preview,
- GtkPrintContext *context,
- XedPrintJob *job)
+ GtkPrintContext *context,
+ XedPrintJob *job)
{
- job->priv->is_preview = TRUE;
+ job->priv->is_preview = TRUE;
- g_signal_emit (job, print_job_signals[SHOW_PREVIEW], 0, job->priv->preview);
+ g_signal_emit (job, print_job_signals[SHOW_PREVIEW], 0, job->priv->preview);
}
static void
preview_destroyed (GtkWidget *preview,
- GtkPrintOperationPreview *gtk_preview)
+ GtkPrintOperationPreview *gtk_preview)
{
- gtk_print_operation_preview_end_preview (gtk_preview);
+ gtk_print_operation_preview_end_preview (gtk_preview);
}
static gboolean
preview_cb (GtkPrintOperation *op,
- GtkPrintOperationPreview *gtk_preview,
- GtkPrintContext *context,
- GtkWindow *parent,
- XedPrintJob *job)
+ GtkPrintOperationPreview *gtk_preview,
+ GtkPrintContext *context,
+ GtkWindow *parent,
+ XedPrintJob *job)
{
- job->priv->preview = xed_print_preview_new (op, gtk_preview, context);
+ job->priv->preview = xed_print_preview_new (op, gtk_preview, context);
- g_signal_connect_after (gtk_preview,
- "ready",
- G_CALLBACK (preview_ready),
- job);
+ g_signal_connect_after (gtk_preview, "ready",
+ G_CALLBACK (preview_ready), job);
- /* FIXME: should this go in the preview widget itself? */
- g_signal_connect (job->priv->preview,
- "destroy",
- G_CALLBACK (preview_destroyed),
- gtk_preview);
+ /* FIXME: should this go in the preview widget itself? */
+ g_signal_connect (job->priv->preview, "destroy",
+ G_CALLBACK (preview_destroyed), gtk_preview);
- return TRUE;
+ return TRUE;
}
static gboolean
paginate_cb (GtkPrintOperation *operation,
- GtkPrintContext *context,
- XedPrintJob *job)
+ GtkPrintContext *context,
+ XedPrintJob *job)
{
- gboolean res;
+ gboolean res;
- job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
+ job->priv->status = XED_PRINT_JOB_STATUS_PAGINATING;
- res = gtk_source_print_compositor_paginate (job->priv->compositor, context);
+ res = gtk_source_print_compositor_paginate (job->priv->compositor, context);
- if (res)
- {
- gint n_pages;
+ if (res)
+ {
+ gint n_pages;
- n_pages = gtk_source_print_compositor_get_n_pages (job->priv->compositor);
- gtk_print_operation_set_n_pages (job->priv->operation, n_pages);
- }
+ n_pages = gtk_source_print_compositor_get_n_pages (job->priv->compositor);
+ gtk_print_operation_set_n_pages (job->priv->operation, n_pages);
+ }
- job->priv->progress = gtk_source_print_compositor_get_pagination_progress (job->priv->compositor);
+ job->priv->progress = gtk_source_print_compositor_get_pagination_progress (job->priv->compositor);
- /* When previewing, the progress is just for pagination, when printing
- * it's split between pagination and rendering */
- if (!job->priv->is_preview)
- job->priv->progress /= 2.0;
+ /* When previewing, the progress is just for pagination, when printing
+ * it's split between pagination and rendering */
+ if (!job->priv->is_preview)
+ {
+ job->priv->progress /= 2.0;
+ }
- g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
+ g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
- return res;
+ return res;
}
static void
draw_page_cb (GtkPrintOperation *operation,
- GtkPrintContext *context,
- gint page_nr,
- XedPrintJob *job)
+ GtkPrintContext *context,
+ gint page_nr,
+ XedPrintJob *job)
{
- gint n_pages;
+ gint n_pages;
- /* In preview, pages are drawn on the fly, so rendering is
- * not part of the progress */
- if (!job->priv->is_preview)
- {
- g_free (job->priv->status_string);
+ /* In preview, pages are drawn on the fly, so rendering is
+ * not part of the progress */
+ if (!job->priv->is_preview)
+ {
+ g_free (job->priv->status_string);
- n_pages = gtk_source_print_compositor_get_n_pages (job->priv->compositor);
+ n_pages = gtk_source_print_compositor_get_n_pages (job->priv->compositor);
- job->priv->status = XED_PRINT_JOB_STATUS_DRAWING;
+ job->priv->status = XED_PRINT_JOB_STATUS_DRAWING;
- job->priv->status_string = g_strdup_printf ("Rendering page %d of %d...",
- page_nr + 1,
- n_pages);
+ job->priv->status_string = g_strdup_printf ("Rendering page %d of %d...", page_nr + 1, n_pages);
- job->priv->progress = page_nr / (2.0 * n_pages) + 0.5;
+ job->priv->progress = page_nr / (2.0 * n_pages) + 0.5;
- g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
- }
+ g_signal_emit (job, print_job_signals[PRINTING], 0, job->priv->status);
+ }
- gtk_source_print_compositor_draw_page (job->priv->compositor, context, page_nr);
+ gtk_source_print_compositor_draw_page (job->priv->compositor, context, page_nr);
}
static void
end_print_cb (GtkPrintOperation *operation,
- GtkPrintContext *context,
- XedPrintJob *job)
+ GtkPrintContext *context,
+ XedPrintJob *job)
{
- g_object_unref (job->priv->compositor);
- job->priv->compositor = NULL;
+ g_object_unref (job->priv->compositor);
+ job->priv->compositor = NULL;
}
static void
done_cb (GtkPrintOperation *operation,
- GtkPrintOperationResult result,
- XedPrintJob *job)
+ GtkPrintOperationResult result,
+ XedPrintJob *job)
{
- GError *error = NULL;
- XedPrintJobResult print_result;
+ GError *error = NULL;
+ XedPrintJobResult print_result;
- switch (result)
- {
- case GTK_PRINT_OPERATION_RESULT_CANCEL:
- print_result = XED_PRINT_JOB_RESULT_CANCEL;
- break;
+ switch (result)
+ {
+ case GTK_PRINT_OPERATION_RESULT_CANCEL:
+ print_result = XED_PRINT_JOB_RESULT_CANCEL;
+ break;
- case GTK_PRINT_OPERATION_RESULT_APPLY:
- print_result = XED_PRINT_JOB_RESULT_OK;
- break;
+ case GTK_PRINT_OPERATION_RESULT_APPLY:
+ print_result = XED_PRINT_JOB_RESULT_OK;
+ break;
- case GTK_PRINT_OPERATION_RESULT_ERROR:
- print_result = XED_PRINT_JOB_RESULT_ERROR;
- gtk_print_operation_get_error (operation, &error);
- break;
+ case GTK_PRINT_OPERATION_RESULT_ERROR:
+ print_result = XED_PRINT_JOB_RESULT_ERROR;
+ gtk_print_operation_get_error (operation, &error);
+ break;
- default:
- g_return_if_reached ();
- }
+ default:
+ g_return_if_reached ();
+ }
- /* Avoid job is destroyed in the handler of the "done" message */
- g_object_ref (job);
+ /* Avoid job is destroyed in the handler of the "done" message */
+ g_object_ref (job);
- g_signal_emit (job, print_job_signals[DONE], 0, print_result, error);
+ g_signal_emit (job, print_job_signals[DONE], 0, print_result, error);
- g_object_unref (operation);
- job->priv->operation = NULL;
+ g_object_unref (operation);
+ job->priv->operation = NULL;
- g_object_unref (job);
+ g_object_unref (job);
}
/* Note that xed_print_job_print can can only be called once on a given XedPrintJob */
GtkPrintOperationResult
-xed_print_job_print (XedPrintJob *job,
- GtkPrintOperationAction action,
- GtkPageSetup *page_setup,
- GtkPrintSettings *settings,
- GtkWindow *parent,
- GError **error)
+xed_print_job_print (XedPrintJob *job,
+ GtkPrintOperationAction action,
+ GtkPageSetup *page_setup,
+ GtkPrintSettings *settings,
+ GtkWindow *parent,
+ GError **error)
{
- XedPrintJobPrivate *priv;
- gchar *job_name;
+ XedPrintJobPrivate *priv;
+ gchar *job_name;
- g_return_val_if_fail (job->priv->compositor == NULL, GTK_PRINT_OPERATION_RESULT_ERROR);
+ g_return_val_if_fail (job->priv->compositor == NULL, GTK_PRINT_OPERATION_RESULT_ERROR);
- priv = job->priv;
+ priv = job->priv;
- /* Check if we are previewing */
- priv->is_preview = (action == GTK_PRINT_OPERATION_ACTION_PREVIEW);
+ /* Check if we are previewing */
+ priv->is_preview = (action == GTK_PRINT_OPERATION_ACTION_PREVIEW);
- /* Create print operation */
- job->priv->operation = gtk_print_operation_new ();
+ /* Create print operation */
+ job->priv->operation = gtk_print_operation_new ();
- if (settings)
- gtk_print_operation_set_print_settings (priv->operation,
- settings);
+ if (settings)
+ {
+ gtk_print_operation_set_print_settings (priv->operation, settings);
+ }
- if (page_setup != NULL)
- gtk_print_operation_set_default_page_setup (priv->operation,
- page_setup);
+ if (page_setup != NULL)
+ {
+ gtk_print_operation_set_default_page_setup (priv->operation, page_setup);
+ }
- job_name = xed_document_get_short_name_for_display (priv->doc);
- gtk_print_operation_set_job_name (priv->operation, job_name);
- g_free (job_name);
+ job_name = xed_document_get_short_name_for_display (priv->doc);
+ gtk_print_operation_set_job_name (priv->operation, job_name);
+ g_free (job_name);
- gtk_print_operation_set_embed_page_setup (priv->operation, TRUE);
+ gtk_print_operation_set_embed_page_setup (priv->operation, TRUE);
- gtk_print_operation_set_custom_tab_label (priv->operation,
- _("Text Editor"));
+ gtk_print_operation_set_custom_tab_label (priv->operation, _("Text Editor"));
- gtk_print_operation_set_allow_async (priv->operation, TRUE);
+ gtk_print_operation_set_allow_async (priv->operation, TRUE);
- g_signal_connect (priv->operation,
- "create-custom-widget",
- G_CALLBACK (create_custom_widget_cb),
- job);
- g_signal_connect (priv->operation,
- "custom-widget-apply",
- G_CALLBACK (custom_widget_apply_cb),
- job);
- g_signal_connect (priv->operation,
- "begin-print",
- G_CALLBACK (begin_print_cb),
- job);
- g_signal_connect (priv->operation,
- "preview",
- G_CALLBACK (preview_cb),
- job);
- g_signal_connect (priv->operation,
- "paginate",
- G_CALLBACK (paginate_cb),
- job);
- g_signal_connect (priv->operation,
- "draw-page",
- G_CALLBACK (draw_page_cb),
- job);
- g_signal_connect (priv->operation,
- "end-print",
- G_CALLBACK (end_print_cb),
- job);
- g_signal_connect (priv->operation,
- "done",
- G_CALLBACK (done_cb),
- job);
+ g_signal_connect (priv->operation, "create-custom-widget",
+ G_CALLBACK (create_custom_widget_cb), job);
+ g_signal_connect (priv->operation, "custom-widget-apply",
+ G_CALLBACK (custom_widget_apply_cb), job);
+ g_signal_connect (priv->operation, "begin-print",
+ G_CALLBACK (begin_print_cb), job);
+ g_signal_connect (priv->operation, "preview",
+ G_CALLBACK (preview_cb), job);
+ g_signal_connect (priv->operation, "paginate",
+ G_CALLBACK (paginate_cb), job);
+ g_signal_connect (priv->operation, "draw-page",
+ G_CALLBACK (draw_page_cb), job);
+ g_signal_connect (priv->operation, "end-print",
+ G_CALLBACK (end_print_cb), job);
+ g_signal_connect (priv->operation, "done",
+ G_CALLBACK (done_cb), job);
- return gtk_print_operation_run (priv->operation,
- action,
- parent,
- error);
+ return gtk_print_operation_run (priv->operation, action, parent, error);
}
static void
xed_print_job_init (XedPrintJob *job)
{
- job->priv = XED_PRINT_JOB_GET_PRIVATE (job);
+ job->priv = XED_PRINT_JOB_GET_PRIVATE (job);
job->priv->print_settings = g_settings_new ("org.x.editor.preferences.print");
- job->priv->status = XED_PRINT_JOB_STATUS_INIT;
+ job->priv->status = XED_PRINT_JOB_STATUS_INIT;
- job->priv->status_string = g_strdup (_("Preparing..."));
+ job->priv->status_string = g_strdup (_("Preparing..."));
}
XedPrintJob *
xed_print_job_new (XedView *view)
{
- XedPrintJob *job;
+ XedPrintJob *job;
- g_return_val_if_fail (XED_IS_VIEW (view), NULL);
+ g_return_val_if_fail (XED_IS_VIEW (view), NULL);
- job = XED_PRINT_JOB (g_object_new (XED_TYPE_PRINT_JOB,
- "view", view,
- NULL));
+ job = XED_PRINT_JOB (g_object_new (XED_TYPE_PRINT_JOB, "view", view, NULL));
- return job;
+ return job;
}
void
xed_print_job_cancel (XedPrintJob *job)
{
- g_return_if_fail (XED_IS_PRINT_JOB (job));
+ g_return_if_fail (XED_IS_PRINT_JOB (job));
- gtk_print_operation_cancel (job->priv->operation);
+ gtk_print_operation_cancel (job->priv->operation);
}
const gchar *
xed_print_job_get_status_string (XedPrintJob *job)
{
- g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
- g_return_val_if_fail (job->priv->status_string != NULL, NULL);
+ g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
+ g_return_val_if_fail (job->priv->status_string != NULL, NULL);
- return job->priv->status_string;
+ return job->priv->status_string;
}
gdouble
xed_print_job_get_progress (XedPrintJob *job)
{
- g_return_val_if_fail (XED_IS_PRINT_JOB (job), 0.0);
+ g_return_val_if_fail (XED_IS_PRINT_JOB (job), 0.0);
- return job->priv->progress;
+ return job->priv->progress;
}
GtkPrintSettings *
xed_print_job_get_print_settings (XedPrintJob *job)
{
- g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
+ g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
- return gtk_print_operation_get_print_settings (job->priv->operation);
+ return gtk_print_operation_get_print_settings (job->priv->operation);
}
GtkPageSetup *
xed_print_job_get_page_setup (XedPrintJob *job)
{
- g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
+ g_return_val_if_fail (XED_IS_PRINT_JOB (job), NULL);
- return gtk_print_operation_get_default_page_setup (job->priv->operation);
+ return gtk_print_operation_get_default_page_setup (job->priv->operation);
}
diff --git a/xed/xed-searchbar.c b/xed/xed-searchbar.c
index 474c0e2..94b33c2 100755
--- a/xed/xed-searchbar.c
+++ b/xed/xed-searchbar.c
@@ -18,13 +18,6 @@
#define XED_SEARCHBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_SEARCHBAR, XedSearchbarPrivate))
-// typedef enum
-// {
-// SEARCH,
-// REPLACE
-// } SearchMode;
-
-
enum
{
SHOW_REPLACE,
@@ -666,35 +659,32 @@ xed_searchbar_init (XedSearchbar *searchbar)
{
GtkWidget *content;
GtkSizeGroup *size_group;
- GtkWidget *error_widget;
GtkStyleContext *context;
GtkCssProvider *provider;
- gchar *file;
+ GtkBuilder *builder;
gchar *root_objects[] = { "searchbar_content", NULL };
const gchar *data = ".button {padding: 0;}";
searchbar->priv = XED_SEARCHBAR_GET_PRIVATE (searchbar);
- file = xed_dirs_get_ui_file ("xed-searchbar.ui");
- xed_utils_get_ui_objects (file,
- root_objects,
- &error_widget,
- "searchbar_content", &content,
- "revealer", &searchbar->priv->revealer,
- "grid", &searchbar->priv->grid,
- "search_label", &searchbar->priv->search_label,
- "replace_with_label", &searchbar->priv->replace_label,
- "regex_checkbutton", &searchbar->priv->regex_checkbutton,
- "match_case_checkbutton", &searchbar->priv->match_case_checkbutton,
- "entire_word_checkbutton", &searchbar->priv->entire_word_checkbutton,
- "wrap_around_checkbutton", &searchbar->priv->wrap_around_checkbutton,
- "find_button", &searchbar->priv->find_button,
- "find_prev_button", &searchbar->priv->find_prev_button,
- "replace_button", &searchbar->priv->replace_button,
- "replace_all_button", &searchbar->priv->replace_all_button,
- "close_button", &searchbar->priv->close_button,
- NULL);
- g_free (file);
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_resource (builder, "/org/x/editor/ui/xed-searchbar.ui", root_objects, NULL);
+ content = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar_content"));
+ g_object_ref (content);
+ searchbar->priv->revealer = GTK_WIDGET (gtk_builder_get_object (builder, "revealer"));
+ searchbar->priv->grid = GTK_WIDGET (gtk_builder_get_object (builder, "grid"));
+ searchbar->priv->search_label = GTK_WIDGET (gtk_builder_get_object (builder, "search_label"));
+ searchbar->priv->replace_label = GTK_WIDGET (gtk_builder_get_object (builder, "replace_with_label"));
+ searchbar->priv->regex_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "regex_checkbutton"));
+ searchbar->priv->match_case_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "match_case_checkbutton"));
+ searchbar->priv->entire_word_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "entire_word_checkbutton"));
+ searchbar->priv->wrap_around_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_around_checkbutton"));
+ searchbar->priv->find_button = GTK_WIDGET (gtk_builder_get_object (builder, "find_button"));
+ searchbar->priv->find_prev_button = GTK_WIDGET (gtk_builder_get_object (builder, "find_prev_button"));
+ searchbar->priv->replace_button = GTK_WIDGET (gtk_builder_get_object (builder, "replace_button"));
+ searchbar->priv->replace_all_button = GTK_WIDGET (gtk_builder_get_object (builder, "replace_all_button"));
+ searchbar->priv->close_button = GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
+ g_object_unref (builder);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (searchbar)), "xed-searchbar");
diff --git a/xed/xed-view-frame.c b/xed/xed-view-frame.c
index 60f0582..eba0299 100644
--- a/xed/xed-view-frame.c
+++ b/xed/xed-view-frame.c
@@ -37,12 +37,9 @@
#define SEARCH_POPUP_MARGIN 12
-#define XED_VIEW_FRAME_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), XED_TYPE_VIEW_FRAME, XedViewFramePrivate))
-
struct _XedViewFramePrivate
{
GtkWidget *view;
- GtkWidget *overlay;
GtkTextMark *start_mark;
@@ -68,7 +65,7 @@ typedef enum
SEARCH_STATE_NOT_FOUND
} SearchState;
-G_DEFINE_TYPE (XedViewFrame, xed_view_frame, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (XedViewFrame, xed_view_frame, GTK_TYPE_OVERLAY)
static void
xed_view_frame_finalize (GObject *object)
@@ -389,32 +386,18 @@ search_entry_populate_popup (GtkEntry *entry,
G_CALLBACK (search_enable_popdown), frame);
}
-static GtkWidget *
-create_search_widget (XedViewFrame *frame)
+static void
+setup_search_widget (XedViewFrame *frame)
{
- GtkWidget *search_widget;
- GtkWidget *hbox;
- GtkStyleContext *context;
-
- /* wrap it in a frame, so we can specify borders etc */
- search_widget = gtk_frame_new (NULL);
- context = gtk_widget_get_style_context (search_widget);
- gtk_style_context_add_class (context, "xed-goto-line-box");
- gtk_widget_show (search_widget);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add (GTK_CONTAINER (search_widget), hbox);
- gtk_widget_show (hbox);
-
- g_signal_connect (hbox, "key-press-event",
+ g_signal_connect (frame->priv->revealer, "key-press-event",
G_CALLBACK (search_widget_key_press_event), frame);
/* add entry */
- frame->priv->search_entry = gtk_entry_new ();
- gtk_widget_set_tooltip_text (frame->priv->search_entry, _("Line you want to move the cursor to"));
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (frame->priv->search_entry),
- GTK_ENTRY_ICON_PRIMARY, "go-jump-symbolic");
- gtk_widget_show (frame->priv->search_entry);
+ // frame->priv->search_entry = gtk_entry_new ();
+ // gtk_widget_set_tooltip_text (frame->priv->search_entry, _("Line you want to move the cursor to"));
+ // gtk_entry_set_icon_from_icon_name (GTK_ENTRY (frame->priv->search_entry),
+ // GTK_ENTRY_ICON_PRIMARY, "go-jump-symbolic");
+ // gtk_widget_show (frame->priv->search_entry);
g_signal_connect (frame->priv->search_entry, "activate",
G_CALLBACK (search_entry_activate), frame);
@@ -426,10 +409,6 @@ create_search_widget (XedViewFrame *frame)
G_CALLBACK (search_init), frame);
frame->priv->search_entry_focus_out_id = g_signal_connect (frame->priv->search_entry, "focus-out-event",
G_CALLBACK (search_entry_focus_out_event), frame);
-
- gtk_container_add (GTK_CONTAINER (hbox), frame->priv->search_entry);
-
- return search_widget;
}
static void
@@ -496,6 +475,7 @@ static void
xed_view_frame_class_init (XedViewFrameClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = xed_view_frame_finalize;
object_class->dispose = xed_view_frame_dispose;
@@ -517,7 +497,10 @@ xed_view_frame_class_init (XedViewFrameClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
- g_type_class_add_private (object_class, sizeof (XedViewFramePrivate));
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/x/editor/ui/xed-view-frame.ui");
+ gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, view);
+ gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, revealer);
+ gtk_widget_class_bind_template_child_private (widget_class, XedViewFrame, search_entry);
}
static GMountOperation *
@@ -535,47 +518,23 @@ xed_view_frame_init (XedViewFrame *frame)
{
XedDocument *doc;
GtkSourceFile *file;
- GtkWidget *sw;
GdkRGBA transparent = {0, 0, 0, 0};
- frame->priv = XED_VIEW_FRAME_GET_PRIVATE (frame);
+ frame->priv = xed_view_frame_get_instance_private (frame);
- gtk_orientable_set_orientation (GTK_ORIENTABLE (frame), GTK_ORIENTATION_VERTICAL);
+ gtk_widget_init_template (GTK_WIDGET (frame));
- doc = xed_document_new ();
+ gtk_widget_override_background_color (GTK_WIDGET (frame), 0, &transparent);
+
+ doc = xed_view_frame_get_document (frame);
file = xed_document_get_file (doc);
gtk_source_file_set_mount_operation_factory (file, view_frame_mount_operation_factory, frame, NULL);
- frame->priv->view = xed_view_new (doc);
- gtk_widget_set_vexpand (frame->priv->view, TRUE);
- gtk_widget_show (frame->priv->view);
+ setup_search_widget (frame);
- g_object_unref (doc);
-
- /* Create the scrolled window */
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (sw), frame->priv->view);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_widget_show (sw);
-
- frame->priv->overlay = gtk_overlay_new ();
- gtk_container_add (GTK_CONTAINER (frame->priv->overlay), sw);
- gtk_widget_override_background_color (frame->priv->overlay, 0, &transparent);
- gtk_widget_show (frame->priv->overlay);
-
- gtk_box_pack_start (GTK_BOX (frame), frame->priv->overlay, TRUE, TRUE, 0);
-
- /* Add revealer */
- frame->priv->revealer = gtk_revealer_new ();
- gtk_container_add (GTK_CONTAINER (frame->priv->revealer), create_search_widget (frame));
- gtk_widget_show (frame->priv->revealer);
- gtk_widget_set_halign (frame->priv->revealer, GTK_ALIGN_END);
- gtk_widget_set_valign (frame->priv->revealer, GTK_ALIGN_START);
gtk_widget_set_margin_end (frame->priv->revealer, SEARCH_POPUP_MARGIN);
gtk_widget_set_margin_start (frame->priv->revealer, SEARCH_POPUP_MARGIN);
-
- gtk_overlay_add_overlay (GTK_OVERLAY (frame->priv->overlay), frame->priv->revealer);
}
XedViewFrame *
diff --git a/xed/xed-view-frame.h b/xed/xed-view-frame.h
index 1383fbe..1cb6d12 100644
--- a/xed/xed-view-frame.h
+++ b/xed/xed-view-frame.h
@@ -43,14 +43,14 @@ typedef struct _XedViewFramePrivate XedViewFramePrivate;
struct _XedViewFrame
{
- GtkBox parent;
+ GtkOverlay parent;
XedViewFramePrivate *priv;
};
struct _XedViewFrameClass
{
- GtkBoxClass parent_class;
+ GtkOverlayClass parent_class;
};
GType xed_view_frame_get_type (void) G_GNUC_CONST;
diff --git a/xed/xed-view.c b/xed/xed-view.c
index 61f49ac..01040cb 100644
--- a/xed/xed-view.c
+++ b/xed/xed-view.c
@@ -528,12 +528,18 @@ xed_view_delete_from_cursor (GtkTextView *text_view,
}
}
+static GtkTextBuffer *
+xed_view_create_buffer (GtkTextView *text_view)
+{
+ return GTK_TEXT_BUFFER (xed_document_new ());
+}
+
static void
xed_view_class_init (XedViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- GtkTextViewClass *text_view_class = GTK_TEXT_VIEW_CLASS(klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkTextViewClass *text_view_class = GTK_TEXT_VIEW_CLASS (klass);
GtkBindingSet *binding_set;
object_class->dispose = xed_view_dispose;
@@ -562,6 +568,7 @@ xed_view_class_init (XedViewClass *klass)
widget_class->realize = xed_view_realize;
text_view_class->delete_from_cursor = xed_view_delete_from_cursor;
+ text_view_class->create_buffer = xed_view_create_buffer;
/* A new signal DROP_URIS has been added to allow plugins to intercept
* the default dnd behaviour of 'text/uri-list'. XedView now handles
diff --git a/xed/xed-window.c b/xed/xed-window.c
index a402c95..293d51b 100644
--- a/xed/xed-window.c
+++ b/xed/xed-window.c
@@ -30,7 +30,6 @@
#include "xed-settings.h"
#define LANGUAGE_NONE (const gchar *)"LangNone"
-#define XED_UIFILE "xed-ui.xml"
#define TAB_WIDTH_DATA "XedWindowTabWidthData"
#define LANGUAGE_DATA "XedWindowLanguageData"
@@ -1263,15 +1262,12 @@ create_menu_bar_and_toolbar (XedWindow *window,
g_object_unref (action_group);
window->priv->panes_action_group = action_group;
- /* now load the UI definition */
- ui_file = xed_dirs_get_ui_file (XED_UIFILE);
- gtk_ui_manager_add_ui_from_file (manager, ui_file, &error);
+ gtk_ui_manager_add_ui_from_resource (manager, "/org/x/editor/ui/xed-ui.xml", &error);
if (error != NULL)
{
- g_warning("Could not merge %s: %s", ui_file, error->message);
+ g_warning ("Could not add ui definition: %s", error->message);
g_error_free (error);
}
- g_free (ui_file);
/* show tooltips in the statusbar */
g_signal_connect(manager, "connect_proxy", G_CALLBACK (connect_proxy_cb), window);