diff --git a/configure.ac b/configure.ac
index 90d461b..aaf0017 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,6 +153,7 @@ PKG_CHECK_MODULES(XED, [
gtksourceview-3.0 >= 3.19.0
libpeas-1.0 >= 1.12.0
libpeas-gtk-1.0 >= 1.12.0
+ xapp
])
PKG_CHECK_MODULES(X11, [x11])
diff --git a/debian/control b/debian/control
index b7544aa..493e733 100644
--- a/debian/control
+++ b/debian/control
@@ -14,6 +14,7 @@ Build-Depends: autotools-dev,
libgtk-3-dev,
libgtksourceview-3.0-dev,
libpeas-dev,
+ libxapp-dev,
libsm-dev,
libx11-dev,
libxml2-dev,
@@ -145,4 +146,4 @@ Description: Text editor (documentation files)
includes support for spell checking, comparing files, viewing CVS
ChangeLogs, and adjusting indentation levels.
.
- This package contains the documentation files.
\ No newline at end of file
+ This package contains the documentation files.
diff --git a/xed/resources/ui/xed-preferences-dialog.ui b/xed/resources/ui/xed-preferences-dialog.ui
index 5975d36..00bf20d 100755
--- a/xed/resources/ui/xed-preferences-dialog.ui
+++ b/xed/resources/ui/xed-preferences-dialog.ui
@@ -1,260 +1,121 @@
-
+
+
-
-
diff --git a/xed/xed-preferences-dialog.c b/xed/xed-preferences-dialog.c
index 2e3ad43..32faf6f 100755
--- a/xed/xed-preferences-dialog.c
+++ b/xed/xed-preferences-dialog.c
@@ -62,95 +62,86 @@
static GtkWidget *preferences_dialog = NULL;
-enum
+#define XED_TYPE_PREFERENCES_DIALOG (xed_preferences_dialog_get_type ())
+
+G_DECLARE_FINAL_TYPE (XedPreferencesDialog, xed_preferences_dialog, XED, PREFERENCES_DIALOG, XAppPreferencesWindow)
+
+struct _XedPreferencesDialog
{
- ID_COLUMN = 0,
- NAME_COLUMN,
- DESC_COLUMN,
- NUM_COLUMNS
-};
+ XAppPreferencesWindow parent_instance;
+ GSettings *editor_settings;
+ GSettings *ui_settings;
-#define XED_PREFERENCES_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- XED_TYPE_PREFERENCES_DIALOG, \
- XedPreferencesDialogPrivate))
-
-struct _XedPreferencesDialogPrivate
-{
- GSettings *editor;
- GSettings *ui;
-
- GtkWidget *notebook;
-
- /* Font */
- GtkWidget *default_font_checkbutton;
- GtkWidget *font_button;
- GtkWidget *font_hbox;
-
- /* Style Scheme */
- GtkWidget *prefer_dark_theme_checkbutton;
- GtkListStore *schemes_treeview_model;
- GtkWidget *schemes_treeview;
- GtkWidget *install_scheme_button;
- GtkWidget *uninstall_scheme_button;
-
- GtkWidget *install_scheme_file_schooser;
-
- /* Tabs */
- GtkWidget *tabs_width_spinbutton;
- GtkWidget *insert_spaces_checkbutton;
- GtkWidget *tabs_width_hbox;
-
- /* Auto indentation */
- GtkWidget *auto_indent_checkbutton;
-
- /* Text Wrapping */
- GtkWidget *wrap_text_checkbutton;
- GtkWidget *split_checkbutton;
+ /* Main pages */
+ GtkWidget *editor_page;
+ GtkWidget *save_page;
+ GtkWidget *theme_page;
+ GtkWidget *plugins_page;
/* File Saving */
- GtkWidget *backup_copy_checkbutton;
- GtkWidget *auto_save_checkbutton;
- GtkWidget *auto_save_spinbutton;
- GtkWidget *autosave_hbox;
+ GtkWidget *backup_copy_switch;
+ GtkWidget *auto_save_switch;
+ GtkWidget *auto_save_spin;
+ GtkWidget *auto_save_revealer;
- /* Line numbers */
- GtkWidget *display_line_numbers_checkbutton;
+ /* Font */
+ GtkWidget *fixed_width_font_label;
+ GtkWidget *fixed_width_font_switch;
+ GtkWidget *font_button_revealer;
+ GtkWidget *font_button;
- /* Highlight current line */
- GtkWidget *highlight_current_line_checkbutton;
-
- /* Highlight matching bracket */
- GtkWidget *bracket_matching_checkbutton;
+ /* Display */
+ GtkWidget *display_line_numbers_switch;
/* Minimap */
- GtkWidget *mini_map_checkbutton;
+ GtkWidget *minimap_switch;
/* Right margin */
- GtkWidget *right_margin_checkbutton;
- GtkWidget *right_margin_position_spinbutton;
- GtkWidget *right_margin_position_hbox;
+ GtkWidget *display_right_margin_switch;
+ GtkWidget *right_margin_spin;
+ GtkWidget *right_margin_revealer;
+
+ /* Highlight current line */
+ GtkWidget *highlight_current_line_switch;
+
+ /* Highlight matching bracket */
+ GtkWidget *highlight_matching_bracket_switch;
+
+ /* Tabs */
+ GtkWidget *tab_width_spin;
+ GtkWidget *use_spaces_switch;
+ GtkWidget *automatic_indentation_switch;
+
+ /* Word wrap */
+ GtkWidget *word_wrap_switch;
+ GtkWidget *split_words_revealer;
+ GtkWidget *split_words_switch;
/* Tab scrolling */
- GtkWidget *tab_scrolling_checkbutton;
+ GtkWidget *tab_scrolling_switch;
+
+ /* Style scheme */
+ GtkWidget *prefer_dark_theme_switch;
+ GtkWidget *schemes_list;
+ GtkWidget *install_scheme_button;
+ GtkWidget *uninstall_scheme_button;
+ GtkWidget *install_scheme_file_schooser;
/* Plugins manager */
- GtkWidget *plugin_manager_place_holder;
-
- /* Style Scheme editor dialog */
- GtkWidget *style_scheme_dialog;
+ GtkWidget *plugin_manager_place_holder;
};
-G_DEFINE_TYPE(XedPreferencesDialog, xed_preferences_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE(XedPreferencesDialog, xed_preferences_dialog, XAPP_TYPE_PREFERENCES_WINDOW)
static void
xed_preferences_dialog_dispose (GObject *object)
{
XedPreferencesDialog *dlg = XED_PREFERENCES_DIALOG (object);
- g_clear_object (&dlg->priv->editor);
- g_clear_object (&dlg->priv->ui);
+ g_clear_object (&dlg->editor_settings);
+ g_clear_object (&dlg->ui_settings);
G_OBJECT_CLASS (xed_preferences_dialog_parent_class)->dispose (object);
}
@@ -159,291 +150,302 @@ static void
xed_preferences_dialog_class_init (XedPreferencesDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = xed_preferences_dialog_dispose;
- g_type_class_add_private (object_class, sizeof (XedPreferencesDialogPrivate));
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/x/editor/ui/xed-preferences-dialog.ui");
+
+ /* Pages */
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, editor_page);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, save_page);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, theme_page);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, plugins_page);
+
+ /* Editor Page widgets */
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, fixed_width_font_label);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, fixed_width_font_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, font_button_revealer);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, font_button);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, display_line_numbers_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, minimap_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, display_right_margin_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, right_margin_spin);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, right_margin_revealer);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, highlight_current_line_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, highlight_matching_bracket_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, tab_width_spin);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, use_spaces_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, automatic_indentation_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, word_wrap_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, split_words_revealer);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, split_words_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, tab_scrolling_switch);
+
+ /* Save page widgets */
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, backup_copy_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, auto_save_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, auto_save_spin);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, auto_save_revealer);
+
+ /* Theme page widgets */
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, prefer_dark_theme_switch);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, schemes_list);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, install_scheme_button);
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, uninstall_scheme_button);
+
+ /* Plugin page widgets */
+ gtk_widget_class_bind_template_child (widget_class, XedPreferencesDialog, plugin_manager_place_holder);
}
static void
-dialog_response_handler (GtkDialog *dlg,
- gint res_id)
+close_button_clicked (GtkButton *button,
+ gpointer data)
{
+ XedPreferencesDialog *dlg = XED_PREFERENCES_DIALOG (data);
+
xed_debug (DEBUG_PREFS);
- switch (res_id)
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+}
+
+static void
+help_button_clicked (GtkButton *button,
+ gpointer data)
+{
+ XedPreferencesDialog *dlg = XED_PREFERENCES_DIALOG (data);
+
+ xed_debug (DEBUG_PREFS);
+
+ xed_app_show_help (XED_APP (g_application_get_default ()), GTK_WINDOW (dlg), NULL, "xed-prefs");
+}
+
+static void
+word_wrap_switch_toggled (GObject *toggle_switch,
+ GParamSpec *pspec,
+ gpointer data)
+{
+ XedPreferencesDialog *dlg = XED_PREFERENCES_DIALOG (data);
+ GtkWrapMode mode;
+
+ if (!gtk_switch_get_active (GTK_SWITCH (dlg->word_wrap_switch)))
{
- case GTK_RESPONSE_HELP:
- xed_app_show_help (XED_APP (g_application_get_default ()), GTK_WINDOW (dlg), NULL, "xed-prefs");
- g_signal_stop_emission_by_name (dlg, "response");
- break;
- default:
- gtk_widget_destroy (GTK_WIDGET (dlg));
+ mode = GTK_WRAP_NONE;
+
+ gtk_revealer_set_reveal_child (GTK_REVEALER (dlg->split_words_revealer), FALSE);
}
-}
+ else
+ {
+ gtk_revealer_set_reveal_child (GTK_REVEALER (dlg->split_words_revealer), TRUE);
-static void
-on_auto_save_changed (GSettings *settings,
- const gchar *key,
- XedPreferencesDialog *dlg)
-{
- gboolean value;
+ if (gtk_switch_get_active (GTK_SWITCH (dlg->split_words_switch)))
+ {
+ mode = GTK_WRAP_CHAR;
+ }
+ else
+ {
+ mode = GTK_WRAP_WORD;
+ }
+ }
- xed_debug (DEBUG_PREFS);
-
- value = g_settings_get_boolean (settings, key);
-
- gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, value);
+ g_settings_set_enum (dlg->editor_settings, XED_SETTINGS_WRAP_MODE, mode);
}
static void
setup_editor_page (XedPreferencesDialog *dlg)
{
- gboolean auto_save;
-
- xed_debug (DEBUG_PREFS);
-
- /* Get values */
- auto_save = g_settings_get_boolean (dlg->priv->editor, XED_SETTINGS_AUTO_SAVE);
-
- /* Set widget sensitivity */
- gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, auto_save);
-
- /* Connect signal */
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_TABS_SIZE,
- dlg->priv->tabs_width_spinbutton,
- "value",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_INSERT_SPACES,
- dlg->priv->insert_spaces_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_AUTO_INDENT,
- dlg->priv->auto_indent_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_CREATE_BACKUP_COPY,
- dlg->priv->backup_copy_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_BRACKET_MATCHING,
- dlg->priv->bracket_matching_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_AUTO_SAVE_INTERVAL,
- dlg->priv->auto_save_spinbutton,
- "value",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_signal_connect (dlg->priv->editor, "changed::auto_save",
- G_CALLBACK (on_auto_save_changed), dlg);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_AUTO_SAVE,
- dlg->priv->auto_save_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->ui,
- XED_SETTINGS_ENABLE_TAB_SCROLLING,
- dlg->priv->tab_scrolling_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-}
-
-static gboolean split_button_state = TRUE;
-
-static void
-wrap_mode_checkbutton_toggled (GtkToggleButton *button,
- XedPreferencesDialog *dlg)
-{
- GtkWrapMode mode;
-
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton)))
- {
- mode = GTK_WRAP_NONE;
-
- gtk_widget_set_sensitive (dlg->priv->split_checkbutton, FALSE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
- }
- else
- {
- gtk_widget_set_sensitive (dlg->priv->split_checkbutton, TRUE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
-
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton)))
- {
- split_button_state = TRUE;
- mode = GTK_WRAP_WORD;
- }
- else
- {
- split_button_state = FALSE;
- mode = GTK_WRAP_CHAR;
- }
- }
-
- g_settings_set_enum (dlg->priv->editor, XED_SETTINGS_WRAP_MODE, mode);
-}
-
-static void
-right_margin_checkbutton_toggled (GtkToggleButton *button,
- XedPreferencesDialog *dlg)
-{
- gboolean active;
-
- g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton));
-
- active = gtk_toggle_button_get_active (button);
-
- g_settings_set_boolean (dlg->priv->editor, XED_SETTINGS_DISPLAY_RIGHT_MARGIN, active);
-
- gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox, active);
-}
-
-static void
-setup_view_page (XedPreferencesDialog *dlg)
-{
+ XedSettings *settings;
+ gchar *system_font = NULL;
+ gchar *label_text;
GtkWrapMode wrap_mode;
- gboolean display_right_margin;
xed_debug (DEBUG_PREFS);
- /* Get values */
- display_right_margin = g_settings_get_boolean (dlg->priv->editor, XED_SETTINGS_DISPLAY_RIGHT_MARGIN);
+ /* Fonts */
+ settings = _xed_app_get_settings (XED_APP (g_application_get_default ()));
+ system_font = xed_settings_get_system_font (settings);
- /* Set initial state */
- wrap_mode = g_settings_get_enum (dlg->priv->editor, XED_SETTINGS_WRAP_MODE);
+ label_text = g_strdup_printf(_("Use the system fixed width font (%s)"), system_font);
+ gtk_label_set_text (GTK_LABEL (dlg->fixed_width_font_label), label_text);
+ g_free (system_font);
+ g_free (label_text);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_USE_DEFAULT_FONT,
+ dlg->fixed_width_font_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_object_bind_property (dlg->fixed_width_font_switch,
+ "active",
+ dlg->font_button_revealer,
+ "reveal-child",
+ G_BINDING_SYNC_CREATE | G_BINDING_DEFAULT | G_BINDING_INVERT_BOOLEAN);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_EDITOR_FONT,
+ dlg->font_button,
+ "font-name",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Display */
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_DISPLAY_RIGHT_MARGIN,
+ dlg->display_right_margin_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_object_bind_property (dlg->display_right_margin_switch,
+ "active",
+ dlg->right_margin_revealer,
+ "reveal-child",
+ G_BINDING_SYNC_CREATE | G_BINDING_DEFAULT);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_DISPLAY_LINE_NUMBERS,
+ dlg->display_line_numbers_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->ui_settings,
+ XED_SETTINGS_MINIMAP_VISIBLE,
+ dlg->minimap_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_RIGHT_MARGIN_POSITION,
+ dlg->right_margin_spin,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Highlighting */
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_HIGHLIGHT_CURRENT_LINE,
+ dlg->highlight_current_line_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_BRACKET_MATCHING,
+ dlg->highlight_matching_bracket_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Indentation */
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_TABS_SIZE,
+ dlg->tab_width_spin,
+ "value",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_INSERT_SPACES,
+ dlg->use_spaces_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_AUTO_INDENT,
+ dlg->automatic_indentation_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Word wrap */
+ wrap_mode = g_settings_get_enum (dlg->editor_settings, XED_SETTINGS_WRAP_MODE);
switch (wrap_mode)
{
case GTK_WRAP_WORD:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
+ gtk_switch_set_active (GTK_SWITCH (dlg->word_wrap_switch), TRUE);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (dlg->split_words_revealer), TRUE);
+ gtk_switch_set_active (GTK_SWITCH (dlg->split_words_switch), FALSE);
break;
case GTK_WRAP_CHAR:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
+ gtk_switch_set_active (GTK_SWITCH (dlg->word_wrap_switch), TRUE);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (dlg->split_words_revealer), TRUE);
+ gtk_switch_set_active (GTK_SWITCH (dlg->split_words_switch), TRUE);
break;
default:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), split_button_state);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
-
+ gtk_switch_set_active (GTK_SWITCH (dlg->word_wrap_switch), FALSE);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (dlg->split_words_revealer), FALSE);
}
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->right_margin_checkbutton), display_right_margin);
+ g_signal_connect (dlg->word_wrap_switch, "notify::active",
+ G_CALLBACK (word_wrap_switch_toggled), dlg);
+ g_signal_connect (dlg->split_words_switch, "notify::active",
+ G_CALLBACK (word_wrap_switch_toggled), dlg);
- /* Set widgets sensitivity */
- gtk_widget_set_sensitive (dlg->priv->split_checkbutton, (wrap_mode != GTK_WRAP_NONE));
- gtk_widget_set_sensitive (dlg->priv->right_margin_position_hbox, display_right_margin);
-
- /* Connect signals */
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_DISPLAY_LINE_NUMBERS,
- dlg->priv->display_line_numbers_checkbutton,
+ /* Tab scrolling */
+ g_settings_bind (dlg->ui_settings,
+ XED_SETTINGS_ENABLE_TAB_SCROLLING,
+ dlg->tab_scrolling_switch,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_HIGHLIGHT_CURRENT_LINE,
- dlg->priv->highlight_current_line_checkbutton,
+
+ xapp_preferences_window_add_page (XAPP_PREFERENCES_WINDOW (dlg), dlg->editor_page, "editor", _("Editor"));
+}
+
+static void
+setup_save_page (XedPreferencesDialog *dlg)
+{
+ xed_debug (DEBUG_PREFS);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_CREATE_BACKUP_COPY,
+ dlg->backup_copy_switch,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_RIGHT_MARGIN_POSITION,
- dlg->priv->right_margin_position_spinbutton,
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_AUTO_SAVE,
+ dlg->auto_save_switch,
+ "active",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ g_object_bind_property (dlg->auto_save_switch,
+ "active",
+ dlg->auto_save_revealer,
+ "reveal-child",
+ G_BINDING_SYNC_CREATE | G_BINDING_DEFAULT);
+
+ g_settings_bind (dlg->editor_settings,
+ XED_SETTINGS_AUTO_SAVE_INTERVAL,
+ dlg->auto_save_spin,
"value",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->ui,
- XED_SETTINGS_MINIMAP_VISIBLE,
- dlg->priv->mini_map_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_signal_connect (dlg->priv->wrap_text_checkbutton, "toggled",
- G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->split_checkbutton, "toggled",
- G_CALLBACK (wrap_mode_checkbutton_toggled), dlg);
- g_signal_connect (dlg->priv->right_margin_checkbutton, "toggled",
- G_CALLBACK (right_margin_checkbutton_toggled), dlg);
+
+ xapp_preferences_window_add_page (XAPP_PREFERENCES_WINDOW (dlg), dlg->save_page, "save", _("Save"));
}
-static void
-on_use_default_font_changed (GSettings *settings,
- const gchar *key,
- XedPreferencesDialog *dlg)
-{
- gboolean value;
-
- xed_debug (DEBUG_PREFS);
-
- value = g_settings_get_boolean (settings, key);
- gtk_widget_set_sensitive (dlg->priv->font_hbox, !value);
-}
-
-static void
-setup_font_colors_page_font_section (XedPreferencesDialog *dlg)
-{
- GObject *settings;
- gboolean use_default_font;
- gchar *system_font = NULL;
- gchar *label;
-
- xed_debug (DEBUG_PREFS);
-
- gtk_widget_set_tooltip_text (dlg->priv->font_button,
- _("Click on this button to select the font to be used by the editor"));
-
- xed_utils_set_atk_relation (dlg->priv->font_button,
- dlg->priv->default_font_checkbutton,
- ATK_RELATION_CONTROLLED_BY);
- xed_utils_set_atk_relation (dlg->priv->default_font_checkbutton,
- dlg->priv->font_button,
- ATK_RELATION_CONTROLLER_FOR);
-
- /* Get values */
- settings = _xed_app_get_settings (XED_APP (g_application_get_default ()));
- system_font = xed_settings_get_system_font (XED_SETTINGS (settings));
- use_default_font = g_settings_get_boolean (dlg->priv->editor, XED_SETTINGS_USE_DEFAULT_FONT);
-
- label = g_strdup_printf(_("_Use the system fixed width font (%s)"), system_font);
- gtk_button_set_label (GTK_BUTTON (dlg->priv->default_font_checkbutton), label);
- g_free (system_font);
- g_free (label);
-
- /* read current config and setup initial state */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton), use_default_font);
-
- /* Connect signals */
- g_signal_connect (dlg->priv->editor, "changed::use-default-font",
- G_CALLBACK (on_use_default_font_changed), dlg);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_USE_DEFAULT_FONT,
- dlg->priv->default_font_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor,
- XED_SETTINGS_EDITOR_FONT,
- dlg->priv->font_button,
- "font-name",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-
- /* Set initial widget sensitivity */
- gtk_widget_set_sensitive (dlg->priv->font_hbox, !use_default_font);
-}
-
-static gboolean
-is_xed_user_style_scheme (const gchar *scheme_id)
+static GtkSourceStyleScheme *
+get_default_color_scheme (XedPreferencesDialog *dlg)
{
GtkSourceStyleSchemeManager *manager;
- GtkSourceStyleScheme *scheme;
- gboolean res = FALSE;
+ GtkSourceStyleScheme *scheme = NULL;
+ gchar *pref_id;
manager = gtk_source_style_scheme_manager_get_default ();
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
+ pref_id = g_settings_get_string (dlg->editor_settings, XED_SETTINGS_SCHEME);
+ scheme = gtk_source_style_scheme_manager_get_scheme (manager, pref_id);
+
+ g_free (pref_id);
+
+ if (scheme == NULL)
+ {
+ /* Fallback to classic style scheme */
+ scheme = gtk_source_style_scheme_manager_get_scheme (manager, "classic");
+ }
+
+ return scheme;
+}
+
+static void
+set_buttons_sensisitivity_according_to_scheme (XedPreferencesDialog *dlg,
+ GtkSourceStyleScheme *scheme)
+{
+ gboolean editable = FALSE;
+
if (scheme != NULL)
{
const gchar *filename;
@@ -451,135 +453,26 @@ is_xed_user_style_scheme (const gchar *scheme_id)
filename = gtk_source_style_scheme_get_filename (scheme);
if (filename != NULL)
{
- res = g_str_has_prefix (filename, xed_dirs_get_user_styles_dir ());
+ editable = g_str_has_prefix (filename, xed_dirs_get_user_styles_dir ());
}
}
- return res;
+ gtk_widget_set_sensitive (dlg->uninstall_scheme_button, editable);
}
static void
-set_buttons_sensisitivity_according_to_scheme (XedPreferencesDialog *dlg,
- const gchar *scheme_id)
+style_scheme_changed (GtkSourceStyleSchemeChooser *chooser,
+ GParamSpec *pspec,
+ XedPreferencesDialog *dlg)
{
- gboolean editable;
+ GtkSourceStyleScheme *scheme;
+ const gchar *id;
- editable = ((scheme_id != NULL) && is_xed_user_style_scheme (scheme_id));
+ scheme = gtk_source_style_scheme_chooser_get_style_scheme (chooser);
+ id = gtk_source_style_scheme_get_id (scheme);
- gtk_widget_set_sensitive (dlg->priv->uninstall_scheme_button, editable);
-}
-
-static void
-style_scheme_changed (GtkWidget *treeview,
- XedPreferencesDialog *dlg)
-{
- GtkTreePath *path;
-
- gtk_tree_view_get_cursor (GTK_TREE_VIEW (dlg->priv->schemes_treeview), &path, NULL);
-
- if (path != NULL)
- {
- GtkTreeIter iter;
- gchar *id;
-
- gtk_tree_model_get_iter (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model), &iter, path);
- gtk_tree_path_free (path);
- gtk_tree_model_get (GTK_TREE_MODEL (dlg->priv->schemes_treeview_model), &iter, ID_COLUMN, &id, -1);
-
- g_settings_set_string (dlg->priv->editor, XED_SETTINGS_SCHEME, id);
-
- set_buttons_sensisitivity_according_to_scheme (dlg, id);
-
- g_free (id);
- }
-}
-
-static const gchar *
-ensure_color_scheme_id (XedPreferencesDialog *dlg,
- const gchar *id)
-{
- GtkSourceStyleSchemeManager *manager;
- GtkSourceStyleScheme *scheme = NULL;
-
- manager = gtk_source_style_scheme_manager_get_default ();
- if (id == NULL)
- {
- gchar *pref_id;
-
- pref_id = g_settings_get_string (dlg->priv->editor, XED_SETTINGS_SCHEME);
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, pref_id);
- g_free (pref_id);
- }
- else
- {
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, id);
- }
-
- if (scheme == NULL)
- {
- /* Fall-back to classic style scheme */
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, "classic");
- }
-
- if (scheme == NULL)
- {
- /* Cannot determine default style scheme -> broken GtkSourceView installation */
- return NULL;
- }
-
- return gtk_source_style_scheme_get_id (scheme);
-}
-
-static const gchar *
-populate_color_scheme_list (XedPreferencesDialog *dlg,
- const gchar *def_id)
-{
- GtkSourceStyleSchemeManager *manager;
- const gchar * const *ids;
- gint i;
-
- gtk_list_store_clear (dlg->priv->schemes_treeview_model);
-
- def_id = ensure_color_scheme_id (dlg, def_id);
- if (def_id == NULL)
- {
- g_warning ("Cannot build the list of available color schemes.\n"
- "Please check your GtkSourceView installation.");
- return NULL;
- }
-
- manager = gtk_source_style_scheme_manager_get_default ();
- ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
- for (i = 0; ids[i] != NULL; i++)
- {
- GtkSourceStyleScheme *scheme;
- const gchar *name;
- const gchar *description;
- GtkTreeIter iter;
-
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, ids[i]);
- name = gtk_source_style_scheme_get_name (scheme);
- description = gtk_source_style_scheme_get_description (scheme);
-
- gtk_list_store_append (dlg->priv->schemes_treeview_model, &iter);
- gtk_list_store_set (dlg->priv->schemes_treeview_model,
- &iter,
- ID_COLUMN, ids[i],
- NAME_COLUMN, name,
- DESC_COLUMN, description,
- -1);
-
- g_return_val_if_fail (def_id != NULL, NULL);
- if (strcmp (ids[i], def_id) == 0)
- {
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->schemes_treeview));
- gtk_tree_selection_select_iter (selection, &iter);
- }
- }
-
- return def_id;
+ g_settings_set_string (dlg->editor_settings, XED_SETTINGS_SCHEME, id);
+ set_buttons_sensisitivity_according_to_scheme (dlg, scheme);
}
/*
@@ -654,6 +547,7 @@ file_copy (const gchar *name,
if (!g_file_set_contents (dest_name, contents, length, error))
{
+ g_free (contents);
return FALSE;
}
@@ -677,7 +571,7 @@ file_copy (const gchar *name,
*
* Return value: the id of the installed scheme, %NULL otherwise.
*/
-static const gchar *
+static GtkSourceStyleScheme *
install_style_scheme (const gchar *fname)
{
GtkSourceStyleSchemeManager *manager;
@@ -686,7 +580,7 @@ install_style_scheme (const gchar *fname)
const gchar *styles_dir;
GError *error = NULL;
gboolean copied = FALSE;
- const gchar* const *ids;
+ const gchar * const *ids;
g_return_val_if_fail (fname != NULL, NULL);
@@ -703,13 +597,16 @@ install_style_scheme (const gchar *fname)
new_file_name = g_build_filename (styles_dir, basename, NULL);
g_free (basename);
- /* Copy the style scheme file into GEDIT_STYLES_DIR */
+ /* Copy the style scheme file into XED_STYLES_DIR */
if (!file_copy (fname, new_file_name, &error))
{
g_free (new_file_name);
+ g_free (dirname);
g_message ("Cannot install style scheme:\n%s", error->message);
+ g_error_free (error);
+
return NULL;
}
@@ -742,7 +639,7 @@ install_style_scheme (const gchar *fname)
/* The style scheme has been correctly installed */
g_free (new_file_name);
- return gtk_source_style_scheme_get_id (scheme);
+ return scheme;
}
++ids;
}
@@ -758,59 +655,13 @@ install_style_scheme (const gchar *fname)
return NULL;
}
-/**
- * uninstall_style_scheme:
- * @manager: a #GtkSourceStyleSchemeManager
- * @id: the id of the style scheme to be uninstalled
- *
- * Uninstall a user scheme.
- *
- * If the call was succesful, it returns %TRUE
- * otherwise %FALSE.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-static gboolean
-uninstall_style_scheme (const gchar *id)
-{
- GtkSourceStyleSchemeManager *manager;
- GtkSourceStyleScheme *scheme;
- const gchar *filename;
-
- g_return_val_if_fail (id != NULL, FALSE);
-
- manager = gtk_source_style_scheme_manager_get_default ();
-
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, id);
- if (scheme == NULL)
- {
- return FALSE;
- }
-
- filename = gtk_source_style_scheme_get_filename (scheme);
- if (filename == NULL)
- {
- return FALSE;
- }
-
- if (g_unlink (filename) == -1)
- {
- return FALSE;
- }
-
- /* Reload the available style schemes */
- gtk_source_style_scheme_manager_force_rescan (manager);
-
- return TRUE;
-}
-
static void
add_scheme_chooser_response_cb (GtkDialog *chooser,
gint res_id,
XedPreferencesDialog *dlg)
{
gchar* filename;
- const gchar *scheme_id;
+ GtkSourceStyleScheme *scheme;
if (res_id != GTK_RESPONSE_ACCEPT)
{
@@ -826,20 +677,18 @@ add_scheme_chooser_response_cb (GtkDialog *chooser,
gtk_widget_hide (GTK_WIDGET (chooser));
- scheme_id = install_style_scheme (filename);
+ scheme = install_style_scheme (filename);
g_free (filename);
- if (scheme_id == NULL)
+ if (scheme == NULL)
{
xed_warning (GTK_WINDOW (dlg), _("The selected color scheme cannot be installed."));
return;
}
- g_settings_set_string (dlg->priv->editor, XED_SETTINGS_SCHEME, scheme_id);
+ g_settings_set_string (dlg->editor_settings, XED_SETTINGS_SCHEME, gtk_source_style_scheme_get_id (scheme));
- scheme_id = populate_color_scheme_list (dlg, scheme_id);
-
- set_buttons_sensisitivity_according_to_scheme (dlg, scheme_id);
+ set_buttons_sensisitivity_according_to_scheme (dlg, scheme);
}
static void
@@ -849,10 +698,10 @@ install_scheme_clicked (GtkButton *button,
GtkWidget *chooser;
GtkFileFilter *filter;
- if (dlg->priv->install_scheme_file_schooser != NULL)
+ if (dlg->install_scheme_file_schooser != NULL)
{
- gtk_window_present (GTK_WINDOW (dlg->priv->install_scheme_file_schooser));
- gtk_widget_grab_focus (dlg->priv->install_scheme_file_schooser);
+ gtk_window_present (GTK_WINDOW (dlg->install_scheme_file_schooser));
+ gtk_widget_grab_focus (dlg->install_scheme_file_schooser);
return;
}
@@ -884,191 +733,95 @@ install_scheme_clicked (GtkButton *button,
g_signal_connect (chooser, "response",
G_CALLBACK (add_scheme_chooser_response_cb), dlg);
- dlg->priv->install_scheme_file_schooser = chooser;
+ dlg->install_scheme_file_schooser = chooser;
- g_object_add_weak_pointer (G_OBJECT (chooser), (gpointer) &dlg->priv->install_scheme_file_schooser);
+ g_object_add_weak_pointer (G_OBJECT (chooser), (gpointer) &dlg->install_scheme_file_schooser);
gtk_widget_show (chooser);
}
+/**
+ * uninstall_style_scheme:
+ * @manager: a #GtkSourceStyleSchemeManager
+ * @scheme: a #GtkSourceStyleScheme
+ *
+ * Uninstall a user scheme.
+ *
+ * If the call was succesful, it returns %TRUE
+ * otherwise %FALSE.
+ *
+ * Return value: %TRUE on success, %FALSE otherwise.
+ */
+static gboolean
+uninstall_style_scheme (GtkSourceStyleScheme *scheme)
+{
+ GtkSourceStyleSchemeManager *manager;
+ const gchar *filename;
+
+ g_return_val_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (scheme), FALSE);
+
+ manager = gtk_source_style_scheme_manager_get_default ();
+
+ filename = gtk_source_style_scheme_get_filename (scheme);
+ if (filename == NULL)
+ {
+ return FALSE;
+ }
+
+ if (g_unlink (filename) == -1)
+ {
+ return FALSE;
+ }
+
+ /* Reload the available style schemes */
+ gtk_source_style_scheme_manager_force_rescan (manager);
+
+ return TRUE;
+}
+
static void
uninstall_scheme_clicked (GtkButton *button,
XedPreferencesDialog *dlg)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkSourceStyleScheme *scheme;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->schemes_treeview));
- model = GTK_TREE_MODEL (dlg->priv->schemes_treeview_model);
+ scheme = gtk_source_style_scheme_chooser_get_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list));
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ if (!uninstall_style_scheme (scheme))
{
- gchar *id;
- gchar *name;
-
- gtk_tree_model_get (model, &iter, ID_COLUMN, &id, NAME_COLUMN, &name, -1);
-
- if (!uninstall_style_scheme (id))
- {
- xed_warning (GTK_WINDOW (dlg), _("Could not remove color scheme \"%s\"."), name);
- }
- else
- {
- const gchar *real_new_id;
- gchar *new_id = NULL;
- GtkTreePath *path;
- GtkTreeIter new_iter;
- gboolean new_iter_set = FALSE;
-
- /* If the removed style scheme is the last of the list,
- * set as new default style scheme the previous one,
- * otherwise set the next one.
- * To make this possible, we need to get the id of the
- * new default style scheme before re-populating the list.
- * Fall back to "classic" if it is not possible to get
- * the id
- */
- path = gtk_tree_model_get_path (model, &iter);
-
- /* Try to move to the next path */
- gtk_tree_path_next (path);
- if (!gtk_tree_model_get_iter (model, &new_iter, path))
- {
- /* It seems the removed style scheme was the
- * last of the list. Try to move to the
- * previous one */
- gtk_tree_path_free (path);
-
- path = gtk_tree_model_get_path (model, &iter);
-
- gtk_tree_path_prev (path);
- if (gtk_tree_model_get_iter (model, &new_iter, path))
- {
- new_iter_set = TRUE;
- }
- }
- else
- {
- new_iter_set = TRUE;
- }
-
- gtk_tree_path_free (path);
-
- if (new_iter_set)
- {
- gtk_tree_model_get (model, &new_iter, ID_COLUMN, &new_id, -1);
- }
-
- real_new_id = populate_color_scheme_list (dlg, new_id);
- g_free (new_id);
-
- set_buttons_sensisitivity_according_to_scheme (dlg, real_new_id);
-
- if (real_new_id != NULL)
- {
- g_settings_set_string (dlg->priv->editor, XED_SETTINGS_SCHEME, real_new_id);
- }
- }
-
- g_free (id);
- g_free (name);
+ xed_warning (GTK_WINDOW (dlg), _("Could not remove color scheme \"%s\"."),
+ gtk_source_style_scheme_get_name (scheme));
}
}
static void
-scheme_description_cell_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer data)
+setup_theme_page (XedPreferencesDialog *dlg)
{
- gchar *name;
- gchar *desc;
- gchar *text;
-
- gtk_tree_model_get (model, iter, NAME_COLUMN, &name, DESC_COLUMN, &desc, -1);
-
- if (desc != NULL)
- {
- text = g_markup_printf_escaped ("%s - %s", name, desc);
- }
- else
- {
- text = g_markup_printf_escaped ("%s", name);
- }
-
- g_free (name);
- g_free (desc);
-
- g_object_set (G_OBJECT (renderer), "markup", text, NULL);
-
- g_free (text);
-}
-
-static void
-setup_font_colors_page_style_scheme_section (XedPreferencesDialog *dlg)
-{
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkTreeSelection *selection;
- const gchar *def_id;
+ GtkSourceStyleScheme *scheme;
xed_debug (DEBUG_PREFS);
- /* Create GtkListStore for styles & setup treeview. */
- dlg->priv->schemes_treeview_model = gtk_list_store_new (NUM_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dlg->priv->schemes_treeview_model),
- 0, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->schemes_treeview),
- GTK_TREE_MODEL (dlg->priv->schemes_treeview_model));
-
- column = gtk_tree_view_column_new ();
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_column_set_cell_data_func (column,
- renderer,
- scheme_description_cell_data_func,
- dlg,
- NULL);
-
- gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->schemes_treeview), column);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->schemes_treeview));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
-
- def_id = populate_color_scheme_list (dlg, NULL);
-
- /* Connect signals */
- g_signal_connect (dlg->priv->schemes_treeview, "cursor-changed",
- G_CALLBACK (style_scheme_changed), dlg);
- g_signal_connect (dlg->priv->install_scheme_button, "clicked",
- G_CALLBACK (install_scheme_clicked), dlg);
- g_signal_connect (dlg->priv->uninstall_scheme_button, "clicked",
- G_CALLBACK (uninstall_scheme_clicked), dlg);
-
- /* Set initial widget sensitivity */
- set_buttons_sensisitivity_according_to_scheme (dlg, def_id);
-}
-
-static void
-setup_font_colors_page (XedPreferencesDialog *dlg)
-{
- setup_font_colors_page_font_section (dlg);
- setup_font_colors_page_style_scheme_section (dlg);
-
- g_settings_bind (dlg->priv->editor,
+ /* Prefer dark theme */
+ g_settings_bind (dlg->editor_settings,
XED_SETTINGS_PREFER_DARK_THEME,
- dlg->priv->prefer_dark_theme_checkbutton,
+ dlg->prefer_dark_theme_switch,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Style scheme */
+ scheme = get_default_color_scheme (dlg);
+
+ g_signal_connect (dlg->schemes_list, "notify::style-scheme",
+ G_CALLBACK (style_scheme_changed), dlg);
+ g_signal_connect (dlg->install_scheme_button, "clicked",
+ G_CALLBACK (install_scheme_clicked), dlg);
+ g_signal_connect (dlg->uninstall_scheme_button, "clicked",
+ G_CALLBACK (uninstall_scheme_clicked), dlg);
+
+ gtk_source_style_scheme_chooser_set_style_scheme (GTK_SOURCE_STYLE_SCHEME_CHOOSER (dlg->schemes_list), scheme);
+ set_buttons_sensisitivity_according_to_scheme (dlg, scheme);
+
+ xapp_preferences_window_add_page (XAPP_PREFERENCES_WINDOW (dlg), dlg->theme_page, "theme", _("Theme"));
}
static void
@@ -1081,87 +834,48 @@ setup_plugins_page (XedPreferencesDialog *dlg)
page_content = peas_gtk_plugin_manager_new (NULL);
g_return_if_fail (page_content != NULL);
- gtk_box_pack_start (GTK_BOX (dlg->priv->plugin_manager_place_holder), page_content, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (dlg->plugin_manager_place_holder), page_content, TRUE, TRUE, 0);
gtk_widget_show_all (page_content);
+
+ xapp_preferences_window_add_page (XAPP_PREFERENCES_WINDOW (dlg), dlg->plugins_page, "plugins", _("Plugins"));
+}
+
+static void
+setup_buttons (XedPreferencesDialog *dlg)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_with_label (_("Help"));
+ xapp_preferences_window_add_button (XAPP_PREFERENCES_WINDOW (dlg), button, GTK_PACK_START);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (help_button_clicked), dlg);
+
+ button = gtk_button_new_with_label (_("Close"));
+ xapp_preferences_window_add_button (XAPP_PREFERENCES_WINDOW (dlg), button, GTK_PACK_END);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (close_button_clicked), dlg);
}
static void
xed_preferences_dialog_init (XedPreferencesDialog *dlg)
{
- GtkBuilder *builder;
- gchar *root_objects[] = {
- "notebook",
- "adjustment1",
- "adjustment2",
- "adjustment3",
- NULL
- };
-
xed_debug (DEBUG_PREFS);
- dlg->priv = XED_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
- dlg->priv->editor = g_settings_new ("org.x.editor.preferences.editor");
- dlg->priv->ui = g_settings_new ("org.x.editor.preferences.ui");
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- _("Close"), GTK_RESPONSE_CLOSE,
- _("Help"), GTK_RESPONSE_HELP,
- NULL);
+ dlg->editor_settings = g_settings_new ("org.x.editor.preferences.editor");
+ dlg->ui_settings = g_settings_new ("org.x.editor.preferences.ui");
gtk_window_set_title (GTK_WINDOW (dlg), _("Xed Preferences"));
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 6);
+ gtk_widget_init_template (GTK_WIDGET (dlg));
- g_signal_connect (dlg, "response",
- G_CALLBACK (dialog_response_handler), NULL);
-
- 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->mini_map_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "mini_map_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->prefer_dark_theme_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "prefer_dark_theme_checkbutton"));
- 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);
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+ setup_buttons (dlg);
setup_editor_page (dlg);
- setup_view_page (dlg);
- setup_font_colors_page (dlg);
+ setup_save_page (dlg);
+ setup_theme_page (dlg);
setup_plugins_page (dlg);
+ gtk_widget_show_all (GTK_WIDGET (dlg));
}
void
diff --git a/xed/xed-preferences-dialog.h b/xed/xed-preferences-dialog.h
index 40cc03e..f7e8685 100755
--- a/xed/xed-preferences-dialog.h
+++ b/xed/xed-preferences-dialog.h
@@ -3,7 +3,7 @@
* xed-preferences-dialog.c
* This file is part of xed
*
- * Copyright (C) 2001-2005 Paolo Maggi
+ * Copyright (C) 2001-2005 Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,14 +17,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/*
- * Modified by the xed Team, 2003. See the AUTHORS file for a
- * list of people on the xed Team.
- * See the ChangeLog files for a list of changes.
+ * Modified by the xed Team, 2003. See the AUTHORS file for a
+ * list of people on the xed Team.
+ * See the ChangeLog files for a list of changes.
*
* $Id$
*/
@@ -32,54 +32,13 @@
#ifndef __XED_PREFERENCES_DIALOG_H__
#define __XED_PREFERENCES_DIALOG_H__
+#include
+
#include "xed-window.h"
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
-#define XED_TYPE_PREFERENCES_DIALOG (xed_preferences_dialog_get_type())
-#define XED_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PREFERENCES_DIALOG, XedPreferencesDialog))
-#define XED_PREFERENCES_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PREFERENCES_DIALOG, XedPreferencesDialog const))
-#define XED_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_PREFERENCES_DIALOG, XedPreferencesDialogClass))
-#define XED_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_PREFERENCES_DIALOG))
-#define XED_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PREFERENCES_DIALOG))
-#define XED_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_PREFERENCES_DIALOG, XedPreferencesDialogClass))
-
-
-/* Private structure type */
-typedef struct _XedPreferencesDialogPrivate XedPreferencesDialogPrivate;
-
-/*
- * Main object structure
- */
-typedef struct _XedPreferencesDialog XedPreferencesDialog;
-
-struct _XedPreferencesDialog
-{
- GtkDialog dialog;
-
- /*< private > */
- XedPreferencesDialogPrivate *priv;
-};
-
-/*
- * Class definition
- */
-typedef struct _XedPreferencesDialogClass XedPreferencesDialogClass;
-
-struct _XedPreferencesDialogClass
-{
- GtkDialogClass parent_class;
-};
-
-/*
- * Public methods
- */
-GType xed_preferences_dialog_get_type (void) G_GNUC_CONST;
-
-void xed_show_preferences_dialog (XedWindow *parent);
+void xed_show_preferences_dialog (XedWindow *parent);
G_END_DECLS