[gtranslator/gtk4: 44/52] Use AdwPreferencesWindow for preferences dialog
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/gtk4: 44/52] Use AdwPreferencesWindow for preferences dialog
- Date: Mon, 5 Sep 2022 15:17:52 +0000 (UTC)
commit 68c0f143968dbe1f2da91f9dcf7dbf6b8ac96854
Author: Daniel García Moreno <dani danigm net>
Date: Fri Aug 12 08:10:37 2022 +0200
Use AdwPreferencesWindow for preferences dialog
This patch modernizes the interface in the preferences dialog using the
new AdwPreferencesWindow, AdwPreferencesGroup and AdwActionRow.
src/gtr-preferences-dialog-old.ui | 699 --------------------------------------
src/gtr-preferences-dialog.c | 661 +++++++++++++----------------------
src/gtr-preferences-dialog.h | 39 +--
src/gtr-preferences-dialog.ui | 517 ++++++++--------------------
src/gtr-profile-manager.c | 19 ++
src/gtr-profile-manager.h | 3 +
6 files changed, 409 insertions(+), 1529 deletions(-)
---
diff --git a/src/gtr-preferences-dialog.c b/src/gtr-preferences-dialog.c
index eb55fe5e..44f75294 100644
--- a/src/gtr-preferences-dialog.c
+++ b/src/gtr-preferences-dialog.c
@@ -2,17 +2,18 @@
* Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
* 2008 Pablo Sanxiao <psanxiao gmail com>
* Igalia
- *
+ * 2022 Daniel Garcia <danigm gnome org>
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
@@ -54,14 +55,13 @@ typedef struct
GtkWidget *notebook;
/* Files->General */
- GtkWidget *warn_if_contains_fuzzy_checkbutton;
- GtkCheckButton *remove_obsolete_entries;
+ GtkSwitch *warn_if_contains_fuzzy;
+ GtkSwitch *remove_obsolete_entries;
/* Files->Autosave */
GtkWidget *autosave_checkbutton;
GtkWidget *autosave_interval_spinbutton;
- GtkWidget *autosave_grid;
- GtkWidget *create_backup_checkbutton;
+ GtkWidget *create_backup;
/* Editor->Text display */
GtkWidget *highlight_syntax_checkbutton;
@@ -73,23 +73,23 @@ typedef struct
GtkWidget *spellcheck_checkbutton;
/*Profiles */
- GtkWidget *profile_treeview;
- GtkWidget *add_button;
- GtkWidget *edit_button;
- GtkWidget *delete_button;
-} GtrPreferencesDialogPrivate;
-
+ GtkWidget *check_group;
+ GtkWidget *profiles;
+ GtkWidget *add_profile;
-G_DEFINE_TYPE_WITH_PRIVATE (GtrPreferencesDialog, gtr_preferences_dialog, GTK_TYPE_DIALOG)
+ GtrProfile *editing_profile;
+} GtrPreferencesDialogPrivate;
-enum
+struct _GtrPreferencesDialog
{
- PROFILE_NAME_COLUMN,
- ACTIVE_PROFILE_COLUMN,
- PROFILE_COLUMN,
- PROFILE_N_COLUMNS
+ AdwPreferencesWindow parent_instance;
};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrPreferencesDialog, gtr_preferences_dialog, ADW_TYPE_PREFERENCES_WINDOW)
+
+static void fill_profile_listbox (GtrPreferencesDialog *dlg);
+
/***************Files pages****************/
static void
@@ -98,7 +98,7 @@ setup_files_general_page (GtrPreferencesDialog * dlg)
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
g_settings_bind (priv->files_settings,
GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY,
- priv->warn_if_contains_fuzzy_checkbutton,
+ priv->warn_if_contains_fuzzy,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
g_settings_bind (priv->files_settings,
@@ -108,16 +108,6 @@ setup_files_general_page (GtrPreferencesDialog * dlg)
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
-static void
-on_auto_save_changed (GSettings *settings,
- const gchar *key,
- GtrPreferencesDialog *dlg)
-{
- GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- gtk_widget_set_sensitive (priv->autosave_interval_spinbutton,
- g_settings_get_boolean (settings, key));
-}
-
static void
setup_files_autosave_page (GtrPreferencesDialog * dlg)
{
@@ -133,23 +123,20 @@ setup_files_autosave_page (GtrPreferencesDialog * dlg)
priv->autosave_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_signal_connect (priv->files_settings,
- "changed::" GTR_SETTINGS_AUTO_SAVE,
- G_CALLBACK (on_auto_save_changed),
- dlg);
- /*Set sensitive */
- on_auto_save_changed (priv->files_settings,
- GTR_SETTINGS_AUTO_SAVE,
- dlg);
+ g_settings_bind (priv->files_settings,
+ GTR_SETTINGS_AUTO_SAVE,
+ priv->autosave_interval_spinbutton,
+ "sensitive",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
g_settings_bind (priv->files_settings,
GTR_SETTINGS_CREATE_BACKUP,
- priv->create_backup_checkbutton,
+ priv->create_backup,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
-int
+int
gtr_prefs_get_remove_obsolete ()
{
GSettings *files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
@@ -234,6 +221,82 @@ get_default_font () {
return font;
}
+static void
+on_profile_selection_change (GtkCheckButton *button, GtrProfile *profile)
+{
+ GtrProfileManager *prof_manager = gtr_profile_manager_get_default ();
+
+ if (gtk_check_button_get_active (button))
+ {
+ gtr_profile_manager_set_active_profile (prof_manager, profile);
+ }
+ // TODO: check if there's only one profile and it's unchecked
+
+ g_object_unref (prof_manager);
+}
+
+static GtkWidget *
+create_profile_row (GtrPreferencesDialog *dlg,
+ GtrProfile *profile,
+ GtrProfile *active_profile)
+{
+ const gchar *profile_name;
+ GtkWidget *row = NULL;
+ GtkWidget *check = NULL;
+ GtkWidget *menu = NULL;
+ GMenu *gmenu = NULL;
+ GMenuItem *gitem = NULL;
+
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
+
+ // Profile row widget creation
+ // CheckButton, label, menu -> [edit, delete]
+ profile_name = gtr_profile_get_name (profile);
+ row = adw_action_row_new ();
+ adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), profile_name);
+
+ // CheckButton
+ check = gtk_check_button_new ();
+ gtk_widget_set_valign (check, GTK_ALIGN_CENTER);
+ gtk_widget_add_css_class (check, "selection-mode");
+ adw_action_row_add_prefix (ADW_ACTION_ROW (row), check);
+
+ // MenuButton
+ gmenu = g_menu_new ();
+ gitem = g_menu_item_new (_("edit"), "profile.edit");
+ g_menu_item_set_action_and_target (gitem, "profile.edit", "s", profile_name);
+ g_menu_append_item (gmenu, gitem);
+ gitem = g_menu_item_new (_("delete"), "profile.delete");
+ g_menu_item_set_action_and_target (gitem, "profile.delete", "s", profile_name);
+ g_menu_append_item (gmenu, gitem);
+
+ menu = gtk_menu_button_new ();
+ gtk_widget_set_valign (menu, GTK_ALIGN_CENTER);
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu), G_MENU_MODEL (gmenu));
+ gtk_menu_button_set_icon_name (GTK_MENU_BUTTON (menu), "view-more-symbolic");
+ adw_action_row_add_suffix (ADW_ACTION_ROW (row), menu);
+
+ adw_action_row_set_activatable_widget (ADW_ACTION_ROW (row), check);
+
+ if (profile == active_profile)
+ {
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (check), true);
+ }
+
+ if (!priv->check_group)
+ priv->check_group = check;
+ else
+ {
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (check),
+ GTK_CHECK_BUTTON (priv->check_group));
+ }
+
+ g_signal_connect (check, "toggled",
+ G_CALLBACK (on_profile_selection_change), profile);
+
+
+ return row;
+}
/***************Profile pages****************/
static void
@@ -242,58 +305,30 @@ on_profile_dialog_response_cb (GtrProfileDialog *profile_dialog,
GtrPreferencesDialog *dlg)
{
GtrProfileManager *prof_manager;
- GtkTreeModel *model;
GtrProfile *profile;
GtrProfile *active_profile;
- GtkTreeIter iter;
+ GSList *profiles = NULL;
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->profile_treeview));
- g_return_if_fail (model != NULL);
-
prof_manager = gtr_profile_manager_get_default ();
profile = gtr_profile_dialog_get_profile (profile_dialog);
+ profiles = gtr_profile_manager_get_profiles (prof_manager);
+ active_profile = gtr_profile_manager_get_active_profile (prof_manager);
/* add new profile */
if (response_id == GTK_RESPONSE_ACCEPT)
{
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ unsigned int n = g_slist_length (profiles);
+ GtkWidget *row = create_profile_row (dlg, profile, active_profile);
+ gtk_list_box_insert (GTK_LIST_BOX (priv->profiles), row, n);
gtr_profile_manager_add_profile (prof_manager, profile);
-
- active_profile = gtr_profile_manager_get_active_profile (prof_manager);
-
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- PROFILE_NAME_COLUMN, gtr_profile_get_name (profile),
- ACTIVE_PROFILE_COLUMN, (profile == active_profile),
- PROFILE_COLUMN, profile,
- -1);
}
/* modify profile */
else if (response_id == GTK_RESPONSE_YES)
{
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- GtrProfile *old;
-
- gtk_tree_model_get (model, &iter,
- PROFILE_COLUMN, &old,
- -1);
-
- gtr_profile_manager_modify_profile (prof_manager, old, profile);
- active_profile = gtr_profile_manager_get_active_profile (prof_manager);
-
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- PROFILE_NAME_COLUMN, gtr_profile_get_name (profile),
- ACTIVE_PROFILE_COLUMN, (profile == active_profile),
- PROFILE_COLUMN, profile,
- -1);
- }
+ gtr_profile_manager_modify_profile (prof_manager, priv->editing_profile, profile);
+ priv->editing_profile = NULL;
+ fill_profile_listbox (dlg);
}
g_object_unref (prof_manager);
@@ -301,436 +336,202 @@ on_profile_dialog_response_cb (GtrProfileDialog *profile_dialog,
}
static void
-update_profile_buttons (GtkTreeSelection *selection, GtrPreferencesDialog *dlg)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->profile_treeview));
- g_return_if_fail (model != NULL);
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_widget_set_sensitive (priv->edit_button, TRUE);
- gtk_widget_set_sensitive (priv->delete_button, TRUE);
- }
- else
- {
- gtk_widget_set_sensitive (priv->edit_button, FALSE);
- gtk_widget_set_sensitive (priv->delete_button, FALSE);
- }
-}
-
-
-static void
-add_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
+add_button_clicked (GtrPreferencesDialog *dlg)
{
GtrProfileDialog *profile_dialog;
profile_dialog = gtr_profile_dialog_new (GTK_WIDGET (dlg), NULL);
-
g_signal_connect (profile_dialog, "response",
G_CALLBACK (on_profile_dialog_response_cb), dlg);
-
- gtk_widget_show (GTK_WIDGET (profile_dialog));
gtk_window_present (GTK_WINDOW (profile_dialog));
}
static void
-edit_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
+on_profile_row_cb (GtkListBox *profiles, GtkListBoxRow *row, GtrPreferencesDialog *dlg)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtrProfile *profile;
+ const char *name = gtk_widget_get_name (GTK_WIDGET (row));
+ if (g_strcmp0 (name, "add_profile") == 0)
+ {
+ add_button_clicked (dlg);
+ }
+}
+
+static void
+edit_button_clicked (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ char *profile_name = NULL;
+ GtrProfileManager *prof_manager;
+ GtrProfile *profile = NULL;
+ GtrPreferencesDialog *dlg = GTR_PREFERENCES_DIALOG (widget);
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->profile_treeview));
- g_return_if_fail (model != NULL);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
+ prof_manager = gtr_profile_manager_get_default ();
+ profile_name = (char *) g_variant_get_string (parameter, NULL);
+ profile = gtr_profile_manager_get_profile (prof_manager, profile_name);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ if (profile)
{
+ priv->editing_profile = profile;
GtrProfileDialog *profile_dialog;
-
- gtk_tree_model_get (model, &iter, PROFILE_COLUMN, &profile, -1);
-
profile_dialog = gtr_profile_dialog_new (GTK_WIDGET (dlg), profile);
-
g_signal_connect (profile_dialog, "response",
G_CALLBACK (on_profile_dialog_response_cb), dlg);
-
- gtk_widget_show (GTK_WIDGET (profile_dialog));
gtk_window_present (GTK_WINDOW (profile_dialog));
}
+
+ g_object_unref (prof_manager);
}
static void
-delete_confirm_dialog_cb (GtkWidget *dialog,
- gint response_id, GtrPreferencesDialog *dlg)
+delete_confirm_dialog_cb (GtkWidget *dialog, char *response, GtrPreferencesDialog *dlg)
{
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- if (response_id == GTK_RESPONSE_YES)
- {
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->profile_treeview));
- g_return_if_fail (model != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- GtrProfileManager *prof_manager;
- GtrProfile *profile;
+ GtrProfileManager *prof_manager;
+ GtrProfile *profile = priv->editing_profile;
- gtk_tree_model_get (model, &iter, PROFILE_COLUMN, &profile,
- -1);
+ priv->editing_profile = NULL;
+ gtk_window_destroy (GTK_WINDOW (dialog));
- if (profile != NULL)
- {
- prof_manager = gtr_profile_manager_get_default ();
- gtr_profile_manager_remove_profile (prof_manager, profile);
- g_object_unref (prof_manager);
+ if (g_strcmp0 (response, "cancel") == 0)
+ return;
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
- }
- }
- }
+ prof_manager = gtr_profile_manager_get_default ();
+ gtr_profile_manager_remove_profile (prof_manager, profile);
+ g_object_unref (prof_manager);
- gtk_window_destroy (GTK_WINDOW(dialog));
+ fill_profile_listbox (dlg);
}
static void
-delete_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
+delete_button_clicked (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- gboolean active;
- GtkWidget *dialog;
- gchar *markup;
+ char *profile_name = NULL;
+ GtrProfileManager *prof_manager;
+ GtrProfile *profile = NULL;
+ GtrProfile *active_profile = NULL;
+ GtrPreferencesDialog *dlg = GTR_PREFERENCES_DIALOG (widget);
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->profile_treeview));
- g_return_if_fail (model != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
+ prof_manager = gtr_profile_manager_get_default ();
+ profile_name = (char *) g_variant_get_string (parameter, NULL);
+ profile = gtr_profile_manager_get_profile (prof_manager, profile_name);
+ active_profile = gtr_profile_manager_get_active_profile (prof_manager);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ if (profile)
{
- gtk_tree_model_get (model, &iter, ACTIVE_PROFILE_COLUMN, &active, -1);
-
- if (active)
+ if (active_profile == profile)
{
- dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE, NULL);
+ GtkWidget *dialog = adw_message_dialog_new (
+ GTK_WINDOW (dlg),
+ _("Impossible to remove the active profile"),
+ _("Another profile should be selected as active before")
+ );
- markup = g_strdup_printf("<span weight=\"bold\" size=\"large\">%s</span>",
- _("Impossible to remove the active profile"));
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
- g_free(markup);
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG
- (dialog),
- _("Another profile should be selected as active
before"));
+ adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
+ "ok", _("_Ok"),
+ NULL);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
}
else
{
- dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE, NULL);
-
- markup = g_strdup_printf("<span weight=\"bold\" size=\"large\">%s</span>",
- _("Are you sure you want to delete this profile?"));
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
- g_free(markup);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Delete"), GTK_RESPONSE_YES);
-
+ GtkWidget *dialog = adw_message_dialog_new (
+ GTK_WINDOW (dlg),
+ _("Are you sure you want to delete this profile?"),
+ NULL
+ );
+
+ adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
+ "cancel", _("_Cancel"),
+ "delete", _("_Delete"),
+ NULL);
+
+ priv->editing_profile = profile;
g_signal_connect (GTK_DIALOG (dialog), "response",
G_CALLBACK (delete_confirm_dialog_cb), dlg);
gtk_window_present (GTK_WINDOW (dialog));
}
}
+
+ g_object_unref (prof_manager);
}
static void
-active_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path_str, GtrPreferencesDialog *dlg)
+clear_profile_listbox (GtrPreferencesDialog *dlg)
{
- GtkTreeIter iter, first;
- GtkTreePath *path;
- GtkTreeModel *model;
- GtrProfile *active_profile;
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
-
- path = gtk_tree_path_new_from_string (path_str);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->profile_treeview));
- g_return_if_fail (model != NULL);
-
- gtk_tree_model_get_iter (model, &iter, path);
-
- gtk_tree_model_get (model, &iter, PROFILE_COLUMN, &active_profile, -1);
-
-
- if (active_profile != NULL)
+ GtkWidget *widget = GTK_WIDGET (gtk_list_box_get_row_at_index (GTK_LIST_BOX (priv->profiles), 0));
+ const char *name = gtk_widget_get_name (GTK_WIDGET (widget));
+ while (g_strcmp0 (name, "add_profile") != 0)
{
- GtrProfileManager *prof_manager;
-
- prof_manager = gtr_profile_manager_get_default ();
-
- if (gtr_profile_manager_get_active_profile (prof_manager) != active_profile)
- {
- gtr_profile_manager_set_active_profile (prof_manager, active_profile);
-
- gtk_tree_model_get_iter_first (model, &first);
-
- do
- {
- gtk_list_store_set (GTK_LIST_STORE (model),
- &first,
- ACTIVE_PROFILE_COLUMN, FALSE,
- -1);
- } while (gtk_tree_model_iter_next (model, &first));
-
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- ACTIVE_PROFILE_COLUMN, TRUE,
- -1);
- }
-
- g_object_unref (prof_manager);
+ gtk_list_box_remove (GTK_LIST_BOX (priv->profiles), widget);
+ widget = GTK_WIDGET (gtk_list_box_get_row_at_index (GTK_LIST_BOX (priv->profiles), 0));
+ name = gtk_widget_get_name (GTK_WIDGET (widget));
}
-
- gtk_tree_path_free (path);
}
static void
-fill_profile_treeview (GtrPreferencesDialog *dlg, GtkTreeModel *model)
+fill_profile_listbox (GtrPreferencesDialog *dlg)
{
GtrProfileManager *prof_manager;
- GtkTreeIter iter;
GtrProfile *active_profile;
GSList *l, *profiles;
-
- gtk_list_store_clear (GTK_LIST_STORE (model));
+ unsigned int n = 0;
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
prof_manager = gtr_profile_manager_get_default ();
profiles = gtr_profile_manager_get_profiles (prof_manager);
active_profile = gtr_profile_manager_get_active_profile (prof_manager);
- for (l = profiles; l != NULL; l = g_slist_next (l))
+ clear_profile_listbox (dlg);
+
+ priv->check_group = NULL;
+ for (l = profiles; l != NULL; l = g_slist_next (l), n++)
{
GtrProfile *profile = GTR_PROFILE (l->data);
- const gchar *profile_name;
-
- profile_name = gtr_profile_get_name (profile);
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- PROFILE_NAME_COLUMN, profile_name,
- ACTIVE_PROFILE_COLUMN, (profile == active_profile),
- PROFILE_COLUMN, profile,
- -1);
+ GtkWidget *row = create_profile_row (dlg, profile, active_profile);
+ gtk_list_box_insert (GTK_LIST_BOX (priv->profiles), row, n);
}
-
g_object_unref (prof_manager);
}
static void
setup_profile_pages (GtrPreferencesDialog *dlg)
{
-
- GtkTreeViewColumn *name_column, *toggle_column;
- GtkCellRenderer *text_renderer, *toggle_renderer;
- GtkListStore *model;
- GtkTreeSelection *selection;
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
+ fill_profile_listbox (dlg);
- model = gtk_list_store_new (PROFILE_N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_POINTER);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->profile_treeview),
- GTK_TREE_MODEL (model));
-
- g_object_unref (model);
-
- text_renderer = gtk_cell_renderer_text_new ();
- toggle_renderer = gtk_cell_renderer_toggle_new ();
-
- g_signal_connect (toggle_renderer,
- "toggled", G_CALLBACK (active_toggled_cb), dlg);
-
- gtk_cell_renderer_toggle_set_activatable (GTK_CELL_RENDERER_TOGGLE (toggle_renderer),
- TRUE);
- gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE (toggle_renderer),
- TRUE);
-
- name_column = gtk_tree_view_column_new_with_attributes (_("Profile"),
- text_renderer,
- "text",
- PROFILE_NAME_COLUMN,
- NULL);
-
- toggle_column = gtk_tree_view_column_new_with_attributes (_("Active"),
- toggle_renderer,
- "active",
- ACTIVE_PROFILE_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_resizable (toggle_column, TRUE);
- gtk_tree_view_column_set_resizable (name_column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->profile_treeview),
- name_column);
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->profile_treeview),
- toggle_column);
-
- gtk_tree_view_column_set_expand (name_column, TRUE);
-
- fill_profile_treeview (dlg, GTK_TREE_MODEL (model));
-
- /* Connect the signals */
- g_signal_connect (priv->add_button,
- "clicked", G_CALLBACK (add_button_clicked), dlg);
-
- g_signal_connect (priv->delete_button,
- "clicked", G_CALLBACK (delete_button_clicked), dlg);
-
- g_signal_connect (priv->edit_button,
- "clicked", G_CALLBACK (edit_button_clicked), dlg);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
- g_signal_connect (selection, "changed", G_CALLBACK (update_profile_buttons), dlg);
-
- update_profile_buttons (selection, dlg);
-}
-
-static void
-dialog_response_handler (GtkDialog * dlg, gint res_id)
-{
- switch (res_id)
- {
- case GTK_RESPONSE_HELP:
- gtr_show_help (GTK_WINDOW (dlg));
- break;
- default:
- gtk_window_destroy (GTK_WINDOW (dlg));
- }
+ g_signal_connect (priv->profiles, "row-activated", G_CALLBACK (on_profile_row_cb), dlg);
}
static void
gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
{
- GtkWidget *profiles_toolbar;
- GtkWidget *profiles_scrolled_window;
- GtkBuilder *builder;
- GtkBox *content_area;
- //GtkStyleContext *context;
- const gchar *root_objects[] = {
- "notebook",
- "adjustment1",
- "adjustment2",
- "adjustment3",
- "model1",
- NULL
- };
GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
g_autofree char *font = NULL;
+ gtk_widget_init_template (GTK_WIDGET (dlg));
+
+ priv->editing_profile = NULL;
priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui");
priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor");
priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- _("_Close"), GTK_RESPONSE_CLOSE,
- _("Help"), GTK_RESPONSE_HELP, NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Translation Editor Preferences"));
- /*gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);*/
-
- content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
-
- gtk_box_set_spacing (content_area, 6);
-
- g_signal_connect (dlg,
- "response", G_CALLBACK (dialog_response_handler), NULL);
-
- builder = gtk_builder_new ();
- GError *error = NULL;
- gtk_builder_add_objects_from_resource (builder, "/org/gnome/translator/gtr-preferences-dialog.ui",
- root_objects, &error);
- if (error)
-{
- g_debug("%s \n",error->message);
- g_free(error);
-}
- priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
- g_object_ref (priv->notebook);
- priv->warn_if_contains_fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"warn_if_fuzzy_checkbutton"));
- priv->remove_obsolete_entries = GTK_CHECK_BUTTON (gtk_builder_get_object (builder,
"remove_obsolete_entries"));
- priv->autosave_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_checkbutton"));
- priv->autosave_interval_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"autosave_interval_spinbutton"));
- priv->autosave_grid = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_grid"));
- priv->create_backup_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"create_backup_checkbutton"));
- priv->highlight_syntax_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"highlight_checkbutton"));
- priv->visible_whitespace_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"visible_whitespace_checkbutton"));
- priv->font_button = GTK_WIDGET (gtk_builder_get_object (builder, "font_button"));
- priv->unmark_fuzzy_when_changed_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"unmark_fuzzy_checkbutton"));
- priv->spellcheck_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "spellcheck_checkbutton"));
- priv->profile_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "profile_treeview"));
- priv->add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add-button"));
- priv->edit_button = GTK_WIDGET (gtk_builder_get_object (builder, "edit-button"));
- priv->delete_button = GTK_WIDGET (gtk_builder_get_object (builder, "delete-button"));
- profiles_toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-toolbar"));
- profiles_scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-scrolledwindow"));
- g_object_unref (builder);
-
- gtk_box_append (content_area, priv->notebook);
-
- /*gtk_widget_set_margin_start (priv->notebook, 6);
- gtk_widget_set_margin_end (priv->notebook, 6);
- gtk_widget_set_margin_top (priv->notebook, 6);
- gtk_widget_set_margin_bottom (priv->notebook, 6);*/
-
- //context = gtk_widget_get_style_context (GTK_WIDGET(profiles_scrolled_window));
- //gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); not in gtk4
-
- //context = gtk_widget_get_style_context (GTK_WIDGET(profiles_toolbar));
- //gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); not in gtk4
-
- g_debug("init ran but after mapping\n");
+ setup_profile_pages (dlg);
setup_files_pages (dlg);
setup_editor_pages (dlg);
- setup_profile_pages (dlg);
font = g_settings_get_string (priv->editor_settings, GTR_SETTINGS_FONT);
if (!strlen (font))
font = get_default_font ();
-
gtk_font_chooser_set_font (GTK_FONT_CHOOSER (priv->font_button), font);
-
g_signal_connect (priv->font_button, "font-set", G_CALLBACK (on_font_set), dlg);
- g_free(error);
}
static void
@@ -743,8 +544,6 @@ gtr_preferences_dialog_dispose (GObject * object)
g_clear_object (&priv->editor_settings);
g_clear_object (&priv->files_settings);
- /*g_free(&dlg);*/
-
G_OBJECT_CLASS (gtr_preferences_dialog_parent_class)->dispose (object);
}
@@ -752,39 +551,39 @@ static void
gtr_preferences_dialog_class_init (GtrPreferencesDialogClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = gtr_preferences_dialog_dispose;
- g_debug("class_init ran\n");
-}
-static void
-gtr_destroy_preferences_dialog (GtkWidget *dlg , GtkWidget **dlg_ptr)
-{
- gtk_window_destroy(GTK_WINDOW(dlg));
- *dlg_ptr = NULL;
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/translator/gtr-preferences-dialog.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, warn_if_contains_fuzzy);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, remove_obsolete_entries);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, create_backup);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, autosave_checkbutton);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog,
autosave_interval_spinbutton);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog,
highlight_syntax_checkbutton);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog,
visible_whitespace_checkbutton);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, font_button);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog,
unmark_fuzzy_when_changed_checkbutton);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, spellcheck_checkbutton);
+
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, profiles);
+ gtk_widget_class_bind_template_child_private (widget_class, GtrPreferencesDialog, add_profile);
+
+ gtk_widget_class_install_action (widget_class, "profile.edit", "s", edit_button_clicked);
+ gtk_widget_class_install_action (widget_class, "profile.delete", "s", delete_button_clicked);
}
void
gtr_show_preferences_dialog (GtrWindow * window)
{
- static GtkWidget *dlg = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
+ GtkWidget *dlg = NULL;
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG,
+ NULL));
- if (dlg == NULL)
- {
- dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG,
- "use-header-bar", TRUE, NULL));
- g_signal_connect (dlg,
- "destroy", G_CALLBACK (gtr_destroy_preferences_dialog), &dlg);
- gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
- gtk_window_present (GTK_WINDOW(dlg));
- }
-
- //gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
-
gtk_window_present (GTK_WINDOW (dlg));
-
- /*g_free(dlg);*/
}
diff --git a/src/gtr-preferences-dialog.h b/src/gtr-preferences-dialog.h
index ec9cd35e..010c02a1 100644
--- a/src/gtr-preferences-dialog.h
+++ b/src/gtr-preferences-dialog.h
@@ -1,55 +1,34 @@
/*
* Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
- *
+ * Copyright (C) 2022 Daniel Garcia <danigm gnome org>
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-#ifndef __PREFERENCES_DIALOG_H__
-#define __PREFERENCES_DIALOG_H__
+#pragma once
-#include <glib.h>
-#include <glib-object.h>
#include <gtk/gtk.h>
+#include <adwaita.h>
#include "gtr-window.h"
G_BEGIN_DECLS
-/* Type checking and casting macros */
-#define GTR_TYPE_PREFERENCES_DIALOG (gtr_preferences_dialog_get_type ())
-#define GTR_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
GTR_TYPE_PREFERENCES_DIALOG, GtrPreferencesDialog))
-#define GTR_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k),
GTR_TYPE_PREFERENCES_DIALOG, GtrPreferencesDialogClass))
-#define GTR_IS_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
GTR_TYPE_PREFERENCES_DIALOG))
-#define GTR_IS_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PREFERENCES_DIALOG))
-#define GTR_PREFERENCES_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PREFERENCES_DIALOG,
GtrPreferencesDialogClass))
-
-/* Main object structure */
-typedef struct _GtrPreferencesDialog GtrPreferencesDialog;
+#define GTR_TYPE_PREFERENCES_DIALOG (gtr_preferences_dialog_get_type ())
-struct _GtrPreferencesDialog
-{
- GtkDialog parent_instance;
-};
-
-/* Class definition */
-typedef struct _GtrPreferencesDialogClass GtrPreferencesDialogClass;
-
-struct _GtrPreferencesDialogClass
-{
- GtkDialogClass parent_class;
-};
+G_DECLARE_FINAL_TYPE (GtrPreferencesDialog, gtr_preferences_dialog, GTR, PREFERENCES_DIALOG,
AdwPreferencesWindow)
/* Public methods */
GType gtr_preferences_dialog_get_type (void)G_GNUC_CONST;
@@ -58,5 +37,3 @@ void gtr_show_preferences_dialog (GtrWindow *window);
int gtr_prefs_get_remove_obsolete (void);
G_END_DECLS
-
-#endif /* __PREFERENCES_DIALOG_H__ */
diff --git a/src/gtr-preferences-dialog.ui b/src/gtr-preferences-dialog.ui
index 0dc4f1ae..6dac42bc 100644
--- a/src/gtr-preferences-dialog.ui
+++ b/src/gtr-preferences-dialog.ui
@@ -1,418 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
- <object class="GtkAdjustment" id="adjustment1">
- <property name="lower">1</property>
- <property name="upper">30</property>
- <property name="value">4</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkAdjustment" id="adjustment2">
- <property name="upper">100</property>
- <property name="value">2</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkAdjustment" id="adjustment3">
- <property name="upper">100</property>
- <property name="value">2</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
- <object class="GtkListStore" id="model1">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0">Text</col>
- </row>
- <row>
- <col id="0">Icons</col>
- </row>
- <row>
- <col id="0">Text + Icons</col>
- </row>
- <row>
- <col id="0">Gnome toolbar setting</col>
- </row>
- <row>
- <col id="0">Tabs</col>
- </row>
- </data>
- </object>
-
- <!-- preferences_dialog -->
- <object class="GtkDialog" id="preferences_dialog">
- <property name="margin_start">0</property>
- <property name="margin_end">0</property>
- <property name="margin_top">0</property>
- <property name="margin_bottom">0</property>-->
- <property name="title" translatable="1">Translation Editor Preferences</property>
- <property name="resizable">0</property>
- <property name="destroy_with_parent">1</property>
- <child internal-child="content_area">
- <object class="GtkBox" id="dialog-vbox">
- <property name="orientation">vertical</property>
-
+ <requires lib="libadwaita" version="1.0"/>
+ <template class="GtrPreferencesDialog" parent="AdwPreferencesWindow">
+ <property name="can-navigate-back">True</property>
+ <child>
+ <object class="AdwPreferencesPage">
+ <property name="icon_name">emblem-documents-symbolic</property>
+ <property name="title">F_iles</property>
+ <property name="use-underline">True</property>
<child>
- <object class="GtkNotebook" id="notebook">
- <property name="focusable">1</property>
- <property name="vexpand">1</property>
- <property name="margin_start">6</property>
- <property name="margin_end">6</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
-
- <!-- page1 -->
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">General</property>
<child>
- <object class="GtkGrid" id="grid1">
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="row_spacing">6</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="xalign">0</property>
- <property name="label" translatable="1"><b>General</b></property>
- <property name="use_markup">1</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">_Warn if PO file contains fuzzy
translations</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkCheckButton" id="warn_if_fuzzy_checkbutton">
- <property name="label" translatable="1">_Warn if PO file contains fuzzy
translations</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- <layout>
- <property name="column">0</property>
- <property name="row">1</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkCheckButton" id="remove_obsolete_entries">
- <property name="label" translatable="1">_Remove obsolete entries on save</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- <layout>
- <property name="column">0</property>
- <property name="row">2</property>
- </layout>
+ <object class="GtkSwitch" id="warn_if_contains_fuzzy">
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">_Remove obsolete entries on save</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkSeparator">
- <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
- <layout>
- <property name="column">0</property>
- <property name="row">3</property>
- </layout>
+ <object class="GtkSwitch" id="remove_obsolete_entries">
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Autosave</property>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">_Activate auto save</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkLabel" id="label8">
- <property name="xalign">0</property>
- <property name="use_markup">1</property>
- <property name="label" translatable="1"><b>Autosave</b></property>
- <layout>
- <property name="column">0</property>
- <property name="row">4</property>
- </layout>
+ <object class="GtkSwitch" id="autosave_checkbutton">
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Autosave _interval</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkGrid" id="grid2">
- <property name="row_spacing">6</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkCheckButton" id="create_backup_checkbutton">
- <property name="label" translatable="1">Create a _backup copy of files before
saving</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- <layout>
- <property name="column">0</property>
- <property name="row">1</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="grid3">
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="autosave_checkbutton">
- <property name="label" translatable="1">_Autosave files every</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="autosave_grid">
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkLabel" id="label6">
- <property name="label" translatable="1">_minutes</property>
- <property name="use_underline">1</property>
- <property name="mnemonic_widget">autosave_interval_spinbutton</property>
- <layout>
- <property name="column">1</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkSpinButton" id="autosave_interval_spinbutton">
- <property name="focusable">1</property>
- <!--<property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>-->
- <property name="adjustment">adjustment1</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <layout>
- <property name="column">1</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
+ <object class="GtkSpinButton" id="autosave_interval_spinbutton">
+ <property name="valign">center</property>
+ <property name="adjustment">
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="lower">1</property>
+ <property name="upper">30</property>
+ <property name="value">4</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
</object>
- </child>
- <layout>
- <property name="column">0</property>
- <property name="row">5</property>
- </layout>
+ </property>
</object>
</child>
</object>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label1">
- <property name="label" translatable="1">Files</property>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Create a _backup copy of files before
saving</property>
+ <property name="use_underline">True</property>
+ <child>
+ <object class="GtkSwitch" id="create_backup">
+ <property name="valign">center</property>
+ </object>
+ </child>
</object>
</child>
+ </object>
+ </child>
+ </object>
+ </child>
- <!-- page2 -->
+ <!-- Second page Editor -->
+ <child>
+ <object class="AdwPreferencesPage">
+ <property name="icon_name">applications-system-symbolic</property>
+ <property name="title">_Editor</property>
+ <property name="use-underline">True</property>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Text Display</property>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">_Highlight message syntax</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkBox" id="vbox16">
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkBox" id="vbox17">
- <property name="valign">center</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label16">
- <property name="valign">center</property>
- <property name="xalign">0</property>
- <property name="label" translatable="1"><b>Text
Display</b></property>
- <property name="use_markup">1</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="vbox18">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkCheckButton" id="highlight_checkbutton">
- <property name="valign">center</property>
- <property name="label" translatable="1">_Highlight message syntax</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkCheckButton" id="visible_whitespace_checkbutton">
- <property name="valign">center</property>
- <property name="label" translatable="1">Make _whitespace visible</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="valign">center</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="halign">center</property>
- <property name="xalign">0</property>
- <property name="label" translatable="1">Font:</property>
- </object>
- </child>
- <child>
- <object class="GtkFontButton" id="font_button">
- <property name="halign">center</property>
- <property name="focusable">1</property>
- <property name="title" translatable="1">Choose the editor font</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
-
- <child>
- <object class="GtkSeparator">
- <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
- </object>
- </child>
-
- <child>
- <object class="GtkBox" id="vbox19">
- <property name="valign">center</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label18">
- <property name="valign">center</property>
- <property name="xalign">0</property>
- <property name="label" translatable="1"><b>Contents</b></property>
- <property name="use_markup">1</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="vbox20">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkCheckButton" id="unmark_fuzzy_checkbutton">
- <property name="vexpand">1</property>
- <property name="label" translatable="1">_Remove fuzzy status if message is
changed</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- </object>
- </child>
- <child>
- <object class="GtkCheckButton" id="spellcheck_checkbutton">
- <property name="vexpand">1</property>
- <property name="label" translatable="1">Check _spelling</property>
- <property name="focusable">1</property>
- <property name="use_underline">1</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
+ <object class="GtkSwitch" id="highlight_syntax_checkbutton">
+ <property name="valign">center</property>
</object>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label2">
- <property name="label" translatable="1">Editor</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Make _whitespace visible</property>
+ <property name="use_underline">True</property>
+ <child>
+ <object class="GtkSwitch" id="visible_whitespace_checkbutton">
+ <property name="valign">center</property>
</object>
</child>
-
- <!-- page3 -->
+ </object>
+ </child>
<child>
- <object class="GtkBox" id="vbox8">
- <property name="orientation">vertical</property>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">_Font</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkScrolledWindow" id="profiles-scrolledwindow">
- <property name="focusable">1</property>
- <property name="vexpand">1</property>
- <property name="has_frame">1</property>
- <property name="child">
- <object class="GtkTreeView" id="profile_treeview">
- <property name="focusable">1</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection"/>
- </child>
- </object>
- </property>
+ <object class="GtkFontButton" id="font_button">
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Contents</property>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">_Remove fuzzy status if message is
changed</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkBox" id="profiles-toolbar">
- <property name="css-classes">toolbar</property>
- <property name="can_focus">0</property>
- <property name="halign">GTK_ALIGN_END</property>
- <!--<property name="icon_size">1</property>-->
- <style>
- <class name="inline-toolbar"/>
- </style>
- <child>
- <object class="GtkBox" id="box1">
- <child type="end">
- <object class="GtkButton" id="add-button">
- <property name="focusable">1</property>
- <property name="receives_default">1</property>
- <property name="icon_name">list-add-symbolic</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkButton" id="delete-button">
- <property name="receives_default">1</property>
- <property name="icon_name">list-remove-symbolic</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkButton" id="edit-button">
- <property name="label" translatable="1">Edit Profile</property>
- <property name="focusable">1</property>
- <property name="receives_default">1</property>
- </object>
- </child>
- </object>
- </child>
+ <object class="GtkSwitch" id="unmark_fuzzy_when_changed_checkbutton">
+ <property name="valign">center</property>
</object>
</child>
</object>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label3">
- <property name="label" translatable="1">Profiles</property>
+ <child>
+ <object class="AdwActionRow">
+ <!-- Hide this until we've the check spelling library -->
+ <property name="visible">false</property>
+ <property name="title" translatable="yes">Check _spelling</property>
+ <property name="use_underline">True</property>
+ <child>
+ <object class="GtkSwitch" id="spellcheck_checkbutton">
+ <property name="valign">center</property>
+ </object>
+ </child>
</object>
</child>
-
</object>
</child>
</object>
</child>
- <!--<action-widgets> already adding action button in init() func
- <action-widget response="0">help_button</action-widget>
- <action-widget response="0">close_button</action-widget>
- </action-widgets>-->
- <!--<child internal-child="action_area">
- <object class="Gtk" id="dialog-action_area">
- <child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="focusable">1</property>
- <property name="receives_default">1</property>
- </object>
- </child>
+ <!-- Third page Profile -->
+ <child>
+ <object class="AdwPreferencesPage">
+ <property name="icon_name">system-users-symbolic</property>
+ <property name="title">_Profiles</property>
+ <property name="use-underline">True</property>
<child>
- <object class="GtkButton" id="close_button">
- <property name="label">gtk-close</property>
- <property name="focusable">1</property>
- <property name="receives_default">1</property>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Profiles</property>
+ <child>
+ <object class="GtkListBox" id="profiles">
+ <property name="selection-mode">none</property>
+ <style>
+ <class name="boxed-list"/>
+ </style>
+ <child>
+ <object class="GtkListBoxRow" id="add_profile">
+ <property name="name">add_profile</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">list-add-symbolic</property>
+ <property name="height-request">50</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
- </child>-->
- </object>
+ </child>
+ </template>
</interface>
diff --git a/src/gtr-profile-manager.c b/src/gtr-profile-manager.c
index 7c7b8399..cead98a0 100644
--- a/src/gtr-profile-manager.c
+++ b/src/gtr-profile-manager.c
@@ -448,3 +448,22 @@ gtr_profile_manager_modify_profile (GtrProfileManager *manager,
save_profiles (manager);
}
+
+GtrProfile *
+gtr_profile_manager_get_profile (GtrProfileManager *manager,
+ const char *name)
+{
+ GSList *l = NULL;
+
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
+
+ for (l = priv->profiles; l != NULL; l = g_slist_next (l))
+ {
+ GtrProfile *p = GTR_PROFILE (l->data);
+ const char *pname = gtr_profile_get_name (p);
+ if (g_strcmp0 (name, pname) == 0)
+ return p;
+ }
+
+ return NULL;
+}
diff --git a/src/gtr-profile-manager.h b/src/gtr-profile-manager.h
index c269e4b2..90c394b9 100644
--- a/src/gtr-profile-manager.h
+++ b/src/gtr-profile-manager.h
@@ -79,6 +79,9 @@ void gtr_profile_manager_modify_profile (GtrProfileManager
GtrProfile *old_profile,
GtrProfile *new_profile);
+GtrProfile *gtr_profile_manager_get_profile (GtrProfileManager *manager,
+ const char *name);
+
G_END_DECLS
#endif /* __GTR_PROFILE_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]