[gtranslator] Remove all deprecated code
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Remove all deprecated code
- Date: Thu, 13 Sep 2018 11:41:00 +0000 (UTC)
commit 33b70e00465a706513f0b506fd83f91487af88d0
Author: Daniel GarcĂa Moreno <danigm wadobo com>
Date: Thu Sep 13 13:31:11 2018 +0200
Remove all deprecated code
data/org.gnome.Gtranslator.gschema.xml.in | 14 --
src/gtr-actions-file.c | 5 -
src/gtr-close-confirmation-dialog.c | 3 -
src/gtr-header-dialog.c | 184 +++++++-------
src/gtr-header-dialog.h | 11 -
src/gtr-header.c | 84 ++++---
src/gtr-header.h | 11 -
src/gtr-history-entry.c | 98 ++++----
src/gtr-history-entry.h | 9 +-
src/gtr-io-error-info-bar.c | 16 +-
src/gtr-jump-dialog.c | 51 ++--
src/gtr-jump-dialog.h | 10 -
src/gtr-language.c | 4 +-
src/gtr-languages-fetcher.c | 102 ++++----
src/gtr-languages-fetcher.h | 8 -
src/gtr-msg.c | 90 ++++---
src/gtr-msg.h | 4 -
src/gtr-po.c | 198 ++++++++-------
src/gtr-po.h | 6 -
src/gtr-preferences-dialog.c | 165 +++++-------
src/gtr-preferences-dialog.h | 6 -
src/gtr-preferences-dialog.ui | 59 +----
src/gtr-profile-dialog.c | 69 +++--
src/gtr-profile-dialog.h | 6 -
src/gtr-profile-manager.c | 58 +++--
src/gtr-profile-manager.h | 3 -
src/gtr-profile.c | 109 ++++----
src/gtr-profile.h | 5 -
src/gtr-progress.c | 2 +-
src/gtr-search-dialog.c | 277 +++++++++++----------
src/gtr-search-dialog.h | 5 -
src/gtr-settings.c | 149 ++---------
src/gtr-settings.h | 7 -
src/gtr-status-combo-box.c | 160 +++++-------
src/gtr-status-combo-box.h | 3 -
src/gtr-statusbar.c | 125 +++++-----
src/gtr-statusbar.h | 4 -
src/gtr-tab-label.c | 85 ++++---
src/gtr-tab-label.h | 3 -
src/gtr-tab.c | 2 +-
src/gtr-utils.c | 12 +-
src/gtr-utils.h | 4 +-
src/gtr-view.c | 70 +-----
src/gtr-view.h | 3 -
src/gtr-window.c | 2 +
src/translation-memory/gda/gtr-gda.c | 247 +++++++++---------
src/translation-memory/gda/gtr-gda.h | 4 -
.../gtr-translation-memory-dialog.c | 57 +++--
.../gtr-translation-memory-dialog.h | 3 -
src/translation-memory/gtr-translation-memory-ui.c | 141 +++++------
src/translation-memory/gtr-translation-memory-ui.h | 4 -
51 files changed, 1213 insertions(+), 1544 deletions(-)
---
diff --git a/data/org.gnome.Gtranslator.gschema.xml.in b/data/org.gnome.Gtranslator.gschema.xml.in
index 563925dc..d054a866 100644
--- a/data/org.gnome.Gtranslator.gschema.xml.in
+++ b/data/org.gnome.Gtranslator.gschema.xml.in
@@ -72,20 +72,6 @@
If true, display whitespace in strings as representative symbols.
</description>
</key>
- <key name="use-custom-font" type="b">
- <default>false</default>
- <summary>Use custom font</summary>
- <description>
- If true, use a custom font for edit fields.
- </description>
- </key>
- <key name="editor-font" type="s">
- <default>'Sans 10'</default>
- <summary>Editor font</summary>
- <description>
- Custom font to use for edit fields.
- </description>
- </key>
<key name="unmark-fuzzy-when-changed" type="b">
<default>true</default>
<summary>Remove fuzzy status when message is changed</summary>
diff --git a/src/gtr-actions-file.c b/src/gtr-actions-file.c
index 1285160f..d58efc18 100644
--- a/src/gtr-actions-file.c
+++ b/src/gtr-actions-file.c
@@ -59,8 +59,6 @@ gtr_open (GFile * location, GtrWindow * window, GError ** error)
GtrTab *tab;
GList *current;
GtrView *active_view;
- GtrHeader *header;
- const gchar *project_id;
/*
* If the filename can't be opened, pass the error back to the caller
@@ -80,9 +78,6 @@ gtr_open (GFile * location, GtrWindow * window, GError ** error)
return FALSE;
}
- header = gtr_po_get_header (po);
- project_id = gtr_header_get_prj_id_version (header);
-
/*
* Create a page to add to our list of open files
*/
diff --git a/src/gtr-close-confirmation-dialog.c b/src/gtr-close-confirmation-dialog.c
index 03c2b58f..a17930b0 100644
--- a/src/gtr-close-confirmation-dialog.c
+++ b/src/gtr-close-confirmation-dialog.c
@@ -135,9 +135,6 @@ gtr_close_confirmation_dialog_init (GtrCloseConfirmationDialog * dlg)
{
AtkObject *atk_obj;
- GtrCloseConfirmationDialogPrivate *priv;
- priv = gtr_close_confirmation_dialog_get_instance_private (dlg);
-
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), 14);
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
diff --git a/src/gtr-header-dialog.c b/src/gtr-header-dialog.c
index 9ff87cfd..39f3770d 100644
--- a/src/gtr-header-dialog.c
+++ b/src/gtr-header-dialog.c
@@ -34,14 +34,7 @@
#include "gtr-settings.h"
#include "gtr-po.h"
-#define GTR_HEADER_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_HEADER_DIALOG, \
- GtrHeaderDialogPrivate))
-
-G_DEFINE_TYPE (GtrHeaderDialog, gtr_header_dialog, GTK_TYPE_DIALOG)
-
-struct _GtrHeaderDialogPrivate
+typedef struct
{
GSettings *settings;
@@ -67,14 +60,22 @@ struct _GtrHeaderDialogPrivate
GtkWidget *encoding;
GtrPo *po;
+} GtrHeaderDialogPrivate;
+
+struct _GtrHeaderDialog
+{
+ GtkDialog parent_instance;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GtrHeaderDialog, gtr_header_dialog, GTK_TYPE_DIALOG)
+
static void
gtr_header_dialog_dispose (GObject * object)
{
GtrHeaderDialog *dlg = GTR_HEADER_DIALOG (object);
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
- g_clear_object (&dlg->priv->settings);
+ g_clear_object (&priv->settings);
G_OBJECT_CLASS (gtr_header_dialog_parent_class)->dispose (object);
}
@@ -84,8 +85,6 @@ gtr_header_dialog_class_init (GtrHeaderDialogClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrHeaderDialogPrivate));
-
object_class->dispose = gtr_header_dialog_dispose;
}
@@ -94,19 +93,20 @@ take_my_options_checkbutton_toggled (GtkToggleButton * button,
GtrHeaderDialog * dlg)
{
gboolean active;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
- g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->take_my_options));
+ g_return_if_fail (button == GTK_TOGGLE_BUTTON (priv->take_my_options));
active = gtk_toggle_button_get_active (button);
- g_settings_set_boolean (dlg->priv->settings, GTR_SETTINGS_USE_PROFILE_VALUES,
+ g_settings_set_boolean (priv->settings, GTR_SETTINGS_USE_PROFILE_VALUES,
active);
- gtk_widget_set_sensitive (dlg->priv->translator, !active);
- gtk_widget_set_sensitive (dlg->priv->tr_email, !active);
- gtk_widget_set_sensitive (dlg->priv->language, !active);
- gtk_widget_set_sensitive (dlg->priv->lg_email, !active);
- gtk_widget_set_sensitive (dlg->priv->encoding, !active);
+ gtk_widget_set_sensitive (priv->translator, !active);
+ gtk_widget_set_sensitive (priv->tr_email, !active);
+ gtk_widget_set_sensitive (priv->language, !active);
+ gtk_widget_set_sensitive (priv->lg_email, !active);
+ gtk_widget_set_sensitive (priv->encoding, !active);
}
static void
@@ -121,15 +121,16 @@ prj_comment_changed (GtkTextBuffer * buffer, GtrHeaderDialog * dlg)
{
GtkTextIter start, end;
gchar *text;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
if (text)
{
- gtr_header_set_comments (gtr_po_get_header (dlg->priv->po), text);
+ gtr_header_set_comments (gtr_po_get_header (priv->po), text);
g_free (text);
- po_state_set_modified (dlg->priv->po);
+ po_state_set_modified (priv->po);
}
}
@@ -137,13 +138,14 @@ static void
prj_id_version_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
{
const gchar *text;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
text = gtk_entry_get_text (GTK_ENTRY (widget));
if (text)
{
- gtr_header_set_prj_id_version (gtr_po_get_header (dlg->priv->po), text);
- po_state_set_modified (dlg->priv->po);
+ gtr_header_set_prj_id_version (gtr_po_get_header (priv->po), text);
+ po_state_set_modified (priv->po);
}
}
@@ -151,13 +153,14 @@ static void
rmbt_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
{
const gchar *text;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
text = gtk_entry_get_text (GTK_ENTRY (widget));
if (text)
{
- gtr_header_set_rmbt (gtr_po_get_header (dlg->priv->po), text);
- po_state_set_modified (dlg->priv->po);
+ gtr_header_set_rmbt (gtr_po_get_header (priv->po), text);
+ po_state_set_modified (priv->po);
}
}
@@ -165,14 +168,15 @@ static void
translator_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
{
const gchar *name, *email;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
- name = gtk_entry_get_text (GTK_ENTRY (dlg->priv->translator));
- email = gtk_entry_get_text (GTK_ENTRY (dlg->priv->tr_email));
+ name = gtk_entry_get_text (GTK_ENTRY (priv->translator));
+ email = gtk_entry_get_text (GTK_ENTRY (priv->tr_email));
if (name && email)
{
- gtr_header_set_translator (gtr_po_get_header (dlg->priv->po), name, email);
- po_state_set_modified (dlg->priv->po);
+ gtr_header_set_translator (gtr_po_get_header (priv->po), name, email);
+ po_state_set_modified (priv->po);
}
}
@@ -180,14 +184,15 @@ static void
language_changed (GtkWidget * widget, GtrHeaderDialog * dlg)
{
const gchar *language, *lg_email;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
- language = gtk_entry_get_text (GTK_ENTRY (dlg->priv->language));
- lg_email = gtk_entry_get_text (GTK_ENTRY (dlg->priv->lg_email));
+ language = gtk_entry_get_text (GTK_ENTRY (priv->language));
+ lg_email = gtk_entry_get_text (GTK_ENTRY (priv->lg_email));
if (language && lg_email)
{
- gtr_header_set_language (gtr_po_get_header (dlg->priv->po), language, lg_email);
- po_state_set_modified (dlg->priv->po);
+ gtr_header_set_language (gtr_po_get_header (priv->po), language, lg_email);
+ po_state_set_modified (priv->po);
}
}
@@ -197,60 +202,60 @@ gtr_header_dialog_fill_from_header (GtrHeaderDialog * dlg)
GtrHeader *header;
GtkTextBuffer *buffer;
gchar *text;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
- header = gtr_po_get_header (dlg->priv->po);
+ header = gtr_po_get_header (priv->po);
/* Project Information */
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->prj_comment));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->prj_comment));
gtk_text_buffer_set_text (buffer, gtr_header_get_comments (header), -1);
text = gtr_header_get_prj_id_version (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->prj_id_version), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->prj_id_version), text);
g_free (text);
text = gtr_header_get_pot_date (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->pot_date), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->pot_date), text);
g_free (text);
text = gtr_header_get_po_date (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->po_date), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->po_date), text);
g_free (text);
text = gtr_header_get_rmbt (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->rmbt), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->rmbt), text);
g_free (text);
/* Translator and Language Information */
text = gtr_header_get_translator (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->translator), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->translator), text);
g_free (text);
text = gtr_header_get_tr_email (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->tr_email), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->tr_email), text);
g_free (text);
text = gtr_header_get_language (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->language), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->language), text);
g_free (text);
text = gtr_header_get_lg_email (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->lg_email), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->lg_email), text);
g_free (text);
text = gtr_header_get_charset (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->charset), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->charset), text);
g_free (text);
text = gtr_header_get_encoding (header);
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->encoding), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->encoding), text);
g_free (text);
}
static void
gtr_header_dialog_init (GtrHeaderDialog * dlg)
{
- GtrHeaderDialogPrivate *priv;
- GtkWidget *action_area;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
GtkBox *content_area;
GtkBuilder *builder;
gchar *root_objects[] = {
@@ -258,25 +263,19 @@ gtr_header_dialog_init (GtrHeaderDialog * dlg)
NULL
};
- dlg->priv = GTR_HEADER_DIALOG_GET_PRIVATE (dlg);
- priv = dlg->priv;
-
- dlg->priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+ priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ _("_Close"), GTK_RESPONSE_CLOSE, NULL);
gtk_window_set_title (GTK_WINDOW (dlg), _("Edit Header"));
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (content_area, 2);
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 4);
g_signal_connect (dlg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
@@ -286,50 +285,50 @@ gtr_header_dialog_init (GtrHeaderDialog * dlg)
priv->main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
g_object_ref (priv->main_box);
- dlg->priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
- dlg->priv->lang_vbox = GTK_WIDGET (gtk_builder_get_object (builder, "lang_vbox"));
- dlg->priv->prj_id_version = GTK_WIDGET (gtk_builder_get_object (builder, "prj_id_version"));
- dlg->priv->rmbt = GTK_WIDGET (gtk_builder_get_object (builder, "rmbt"));
- dlg->priv->prj_comment = GTK_WIDGET (gtk_builder_get_object (builder, "prj_comment"));
- dlg->priv->take_my_options = GTK_WIDGET (gtk_builder_get_object (builder, "take_my_options"));
- dlg->priv->translator = GTK_WIDGET (gtk_builder_get_object (builder, "tr_name"));
- dlg->priv->tr_email = GTK_WIDGET (gtk_builder_get_object (builder, "tr_email"));
- dlg->priv->pot_date = GTK_WIDGET (gtk_builder_get_object (builder, "pot_date"));
- dlg->priv->po_date = GTK_WIDGET (gtk_builder_get_object (builder, "po_date"));
- dlg->priv->language = GTK_WIDGET (gtk_builder_get_object (builder, "language_entry"));
- dlg->priv->lg_email = GTK_WIDGET (gtk_builder_get_object (builder, "lg_email_entry"));
- dlg->priv->charset = GTK_WIDGET (gtk_builder_get_object (builder, "charset_entry"));
- dlg->priv->encoding = GTK_WIDGET (gtk_builder_get_object (builder, "encoding_entry"));
+ priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+ priv->lang_vbox = GTK_WIDGET (gtk_builder_get_object (builder, "lang_vbox"));
+ priv->prj_id_version = GTK_WIDGET (gtk_builder_get_object (builder, "prj_id_version"));
+ priv->rmbt = GTK_WIDGET (gtk_builder_get_object (builder, "rmbt"));
+ priv->prj_comment = GTK_WIDGET (gtk_builder_get_object (builder, "prj_comment"));
+ priv->take_my_options = GTK_WIDGET (gtk_builder_get_object (builder, "take_my_options"));
+ priv->translator = GTK_WIDGET (gtk_builder_get_object (builder, "tr_name"));
+ priv->tr_email = GTK_WIDGET (gtk_builder_get_object (builder, "tr_email"));
+ priv->pot_date = GTK_WIDGET (gtk_builder_get_object (builder, "pot_date"));
+ priv->po_date = GTK_WIDGET (gtk_builder_get_object (builder, "po_date"));
+ priv->language = GTK_WIDGET (gtk_builder_get_object (builder, "language_entry"));
+ priv->lg_email = GTK_WIDGET (gtk_builder_get_object (builder, "lg_email_entry"));
+ priv->charset = GTK_WIDGET (gtk_builder_get_object (builder, "charset_entry"));
+ priv->encoding = GTK_WIDGET (gtk_builder_get_object (builder, "encoding_entry"));
g_object_unref (builder);
- gtk_box_pack_start (content_area, dlg->priv->main_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (content_area, priv->main_box, FALSE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 5);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->take_my_options),
- g_settings_get_boolean (dlg->priv->settings,
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->take_my_options),
+ g_settings_get_boolean (priv->settings,
GTR_SETTINGS_USE_PROFILE_VALUES));
- gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->priv->prj_comment), TRUE);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->prj_comment), TRUE);
- gtk_widget_set_sensitive (dlg->priv->pot_date, FALSE);
- gtk_widget_set_sensitive (dlg->priv->po_date, FALSE);
- gtk_widget_set_sensitive (dlg->priv->charset, FALSE);
+ gtk_widget_set_sensitive (priv->pot_date, FALSE);
+ gtk_widget_set_sensitive (priv->po_date, FALSE);
+ gtk_widget_set_sensitive (priv->charset, FALSE);
if (gtk_toggle_button_get_active
- (GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)))
+ (GTK_TOGGLE_BUTTON (priv->take_my_options)))
{
gboolean active;
active =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dlg->priv->take_my_options));
+ (priv->take_my_options));
- gtk_widget_set_sensitive (dlg->priv->translator, !active);
- gtk_widget_set_sensitive (dlg->priv->tr_email, !active);
- gtk_widget_set_sensitive (dlg->priv->language, !active);
- gtk_widget_set_sensitive (dlg->priv->lg_email, !active);
- gtk_widget_set_sensitive (dlg->priv->encoding, !active);
+ gtk_widget_set_sensitive (priv->translator, !active);
+ gtk_widget_set_sensitive (priv->tr_email, !active);
+ gtk_widget_set_sensitive (priv->language, !active);
+ gtk_widget_set_sensitive (priv->lg_email, !active);
+ gtk_widget_set_sensitive (priv->encoding, !active);
}
}
@@ -338,38 +337,39 @@ set_default_values (GtrHeaderDialog * dlg, GtrWindow * window)
{
GtkTextBuffer *buffer;
GtrTab *tab;
+ GtrHeaderDialogPrivate *priv = gtr_header_dialog_get_instance_private (dlg);
/* Write header's values on Header dialog */
tab = gtr_window_get_active_tab (window);
- dlg->priv->po = gtr_tab_get_po (tab);
+ priv->po = gtr_tab_get_po (tab);
gtr_header_dialog_fill_from_header (GTR_HEADER_DIALOG (dlg));
/*Connect signals */
- g_signal_connect (dlg->priv->take_my_options, "toggled",
+ g_signal_connect (priv->take_my_options, "toggled",
G_CALLBACK (take_my_options_checkbutton_toggled), dlg);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->prj_comment));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->prj_comment));
g_signal_connect (buffer, "changed", G_CALLBACK (prj_comment_changed), dlg);
/* Connect signals to edit Project information on Header dialog */
- g_signal_connect (dlg->priv->prj_id_version, "changed",
+ g_signal_connect (priv->prj_id_version, "changed",
G_CALLBACK (prj_id_version_changed), dlg);
- g_signal_connect (dlg->priv->rmbt, "changed",
+ g_signal_connect (priv->rmbt, "changed",
G_CALLBACK (rmbt_changed), dlg);
/* Connect signals to edit Translator and Language information on Header dialog */
- g_signal_connect (dlg->priv->translator, "changed",
+ g_signal_connect (priv->translator, "changed",
G_CALLBACK (translator_changed), dlg);
- g_signal_connect (dlg->priv->tr_email, "changed",
+ g_signal_connect (priv->tr_email, "changed",
G_CALLBACK (translator_changed), dlg);
- g_signal_connect (dlg->priv->language, "changed",
+ g_signal_connect (priv->language, "changed",
G_CALLBACK (language_changed), dlg);
- g_signal_connect (dlg->priv->lg_email, "changed",
+ g_signal_connect (priv->lg_email, "changed",
G_CALLBACK (language_changed), dlg);
}
diff --git a/src/gtr-header-dialog.h b/src/gtr-header-dialog.h
index 28deea00..6aa1e3de 100644
--- a/src/gtr-header-dialog.h
+++ b/src/gtr-header-dialog.h
@@ -36,22 +36,11 @@
#define GTR_IS_HEADER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_HEADER_DIALOG))
#define GTR_HEADER_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_HEADER_DIALOG,
GtrHeaderDialogClass))
-/* Private structure type */
-typedef struct _GtrHeaderDialogPrivate GtrHeaderDialogPrivate;
-
/*
* Main object structure
*/
typedef struct _GtrHeaderDialog GtrHeaderDialog;
-struct _GtrHeaderDialog
-{
- GtkDialog parent_instance;
-
- /*< private > */
- GtrHeaderDialogPrivate *priv;
-};
-
/*
* Class definition
*/
diff --git a/src/gtr-header.c b/src/gtr-header.c
index 858344a8..9813448e 100644
--- a/src/gtr-header.c
+++ b/src/gtr-header.c
@@ -36,22 +36,22 @@
#include <glib-object.h>
#include <string.h>
-#define GTR_HEADER_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_HEADER, \
- GtrHeaderPrivate))
-
-G_DEFINE_TYPE (GtrHeader, gtr_header, GTR_TYPE_MSG)
-
-struct _GtrHeaderPrivate
+typedef struct
{
GSettings *settings;
GtrProfileManager *prof_manager;
GtrProfile *profile;
gint nplurals;
+} GtrHeaderPrivate;
+
+struct _GtrHeader
+{
+ GtrMsg parent_instance;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GtrHeader, gtr_header, GTR_TYPE_MSG)
+
static void
gtr_header_set_field (GtrHeader * header,
const gchar * field, const gchar * data)
@@ -74,10 +74,11 @@ parse_nplurals (GtrHeader * header)
{
gchar *pointer, *plural_forms;
gboolean use_profile_values;
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
plural_forms = gtr_header_get_plural_forms (header);
- header->priv->nplurals = -1;
- use_profile_values = g_settings_get_boolean (header->priv->settings,
+ priv->nplurals = -1;
+ use_profile_values = g_settings_get_boolean (priv->settings,
GTR_SETTINGS_USE_PROFILE_VALUES);
if (use_profile_values || !plural_forms)
@@ -85,8 +86,8 @@ parse_nplurals (GtrHeader * header)
const gchar *plural_form = NULL;
GtrProfile *profile;
- if (header->priv->profile != NULL)
- profile = header->priv->profile;
+ if (priv->profile != NULL)
+ profile = priv->profile;
else
{
GtrProfileManager *prof_manager;
@@ -129,10 +130,10 @@ parse_nplurals (GtrHeader * header)
else
return;
- header->priv->nplurals = g_ascii_digit_value (*pointer);
+ priv->nplurals = g_ascii_digit_value (*pointer);
}
- /*g_message ("nplurals: %d", header->priv->nplurals); */
+ /*g_message ("nplurals: %d", priv->nplurals); */
g_free (plural_forms);
}
@@ -142,22 +143,23 @@ profile_removed_cb (GtrProfileManager *prof_manager,
GtrProfile *profile,
GtrHeader *header)
{
- if (profile == header->priv->profile)
- header->priv->profile = NULL;
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
+ if (profile == priv->profile)
+ priv->profile = NULL;
}
static void
gtr_header_init (GtrHeader * header)
{
- header->priv = GTR_HEADER_GET_PRIVATE (header);
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
- header->priv->nplurals = -1;
- header->priv->profile = NULL;
+ priv->nplurals = -1;
+ priv->profile = NULL;
- header->priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
- header->priv->prof_manager = gtr_profile_manager_get_default ();
+ priv->settings = g_settings_new ("org.gnome.gtranslator.preferences.files");
+ priv->prof_manager = gtr_profile_manager_get_default ();
- g_signal_connect (header->priv->prof_manager, "profile-removed",
+ g_signal_connect (priv->prof_manager, "profile-removed",
G_CALLBACK (profile_removed_cb), header);
}
@@ -165,10 +167,11 @@ static void
gtr_header_dispose (GObject * object)
{
GtrHeader *header = GTR_HEADER (object);
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
- g_clear_object (&header->priv->settings);
- g_clear_object (&header->priv->prof_manager);
- g_clear_object (&header->priv->profile);
+ g_clear_object (&priv->settings);
+ g_clear_object (&priv->prof_manager);
+ g_clear_object (&priv->profile);
G_OBJECT_CLASS (gtr_header_parent_class)->dispose (object);
}
@@ -178,8 +181,6 @@ gtr_header_class_init (GtrHeaderClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrHeaderPrivate));
-
object_class->dispose = gtr_header_dispose;
}
@@ -536,10 +537,11 @@ gtr_header_set_plural_forms (GtrHeader * header, const gchar * plural_forms)
gint
gtr_header_get_nplurals (GtrHeader * header)
{
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
g_return_val_if_fail (GTR_IS_HEADER (header), 1);
- if (header->priv->nplurals > -1)
- return header->priv->nplurals;
+ if (priv->nplurals > -1)
+ return priv->nplurals;
else
return 1;
}
@@ -549,13 +551,14 @@ set_profile_values (GtrHeader *header)
{
GtrProfile *active_profile;
gboolean use_profile_values;
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
- if (header->priv->profile != NULL)
- active_profile = header->priv->profile;
+ if (priv->profile != NULL)
+ active_profile = priv->profile;
else
- active_profile = gtr_profile_manager_get_active_profile (header->priv->prof_manager);
+ active_profile = gtr_profile_manager_get_active_profile (priv->prof_manager);
- use_profile_values = g_settings_get_boolean (header->priv->settings,
+ use_profile_values = g_settings_get_boolean (priv->settings,
GTR_SETTINGS_USE_PROFILE_VALUES);
if (use_profile_values && active_profile != NULL)
@@ -608,15 +611,16 @@ update_comments (GtrHeader *header, const gchar *comments)
gchar *current_year;
gboolean use_profile_values;
gint i;
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
- if (header->priv->profile != NULL)
- active_profile = header->priv->profile;
+ if (priv->profile != NULL)
+ active_profile = priv->profile;
else
- active_profile = gtr_profile_manager_get_active_profile (header->priv->prof_manager);
+ active_profile = gtr_profile_manager_get_active_profile (priv->prof_manager);
current_year = gtr_utils_get_current_year ();
- use_profile_values = g_settings_get_boolean (header->priv->settings,
+ use_profile_values = g_settings_get_boolean (priv->settings,
GTR_SETTINGS_USE_PROFILE_VALUES);
/* Save the previous translator to update the header's comment */
@@ -732,9 +736,10 @@ void
gtr_header_set_profile (GtrHeader *header,
GtrProfile *profile)
{
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
g_return_if_fail (GTR_IS_HEADER (header));
- header->priv->profile = g_object_ref (profile);
+ priv->profile = g_object_ref (profile);
}
/**
@@ -748,7 +753,8 @@ gtr_header_set_profile (GtrHeader *header,
GtrProfile *
gtr_header_get_profile (GtrHeader *header)
{
+ GtrHeaderPrivate *priv = gtr_header_get_instance_private (header);
g_return_val_if_fail (GTR_IS_HEADER (header), NULL);
- return header->priv->profile;
+ return priv->profile;
}
diff --git a/src/gtr-header.h b/src/gtr-header.h
index 490ca03d..6495bf74 100644
--- a/src/gtr-header.h
+++ b/src/gtr-header.h
@@ -40,20 +40,9 @@ G_BEGIN_DECLS
#define GTR_IS_HEADER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_HEADER))
#define GTR_HEADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_HEADER,
GtrHeaderClass))
-/* Private structure type */
-typedef struct _GtrHeaderPrivate GtrHeaderPrivate;
-
/* Main object structure */
typedef struct _GtrHeader GtrHeader;
-struct _GtrHeader
-{
- GtrMsg parent_instance;
-
- /*< private > */
- GtrHeaderPrivate *priv;
-};
-
/* Class definition */
typedef struct _GtrHeaderClass GtrHeaderClass;
diff --git a/src/gtr-history-entry.c b/src/gtr-history-entry.c
index cbbe6517..1a85ac06 100644
--- a/src/gtr-history-entry.c
+++ b/src/gtr-history-entry.c
@@ -49,11 +49,7 @@ enum
#define GTR_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT 10
-#define GTR_HISTORY_ENTRY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- GTR_TYPE_HISTORY_ENTRY, \
- GtrHistoryEntryPrivate))
-
-struct _GtrHistoryEntryPrivate
+typedef struct
{
gchar *history_id;
guint history_length;
@@ -61,16 +57,23 @@ struct _GtrHistoryEntryPrivate
GtkEntryCompletion *completion;
GSettings *settings;
+} GtrHistoryEntryPrivate;
+
+struct _GtrHistoryEntry
+{
+ GtkComboBoxText parent_instance;
};
-G_DEFINE_TYPE (GtrHistoryEntry, gtr_history_entry, GTK_TYPE_COMBO_BOX_TEXT)
- static void
- gtr_history_entry_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * spec)
+G_DEFINE_TYPE_WITH_PRIVATE (GtrHistoryEntry, gtr_history_entry, GTK_TYPE_COMBO_BOX_TEXT)
+
+static void
+gtr_history_entry_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * spec)
{
- GtrHistoryEntry *entry;
+ GtrHistoryEntry *entry = GTR_HISTORY_ENTRY (object);
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_if_fail (GTR_IS_HISTORY_ENTRY (object));
@@ -79,7 +82,7 @@ G_DEFINE_TYPE (GtrHistoryEntry, gtr_history_entry, GTK_TYPE_COMBO_BOX_TEXT)
switch (prop_id)
{
case PROP_HISTORY_ID:
- entry->priv->history_id = g_value_dup_string (value);
+ priv->history_id = g_value_dup_string (value);
break;
case PROP_HISTORY_LENGTH:
gtr_history_entry_set_history_length (entry, g_value_get_uint (value));
@@ -98,12 +101,11 @@ gtr_history_entry_get_property (GObject * object,
guint prop_id,
GValue * value, GParamSpec * spec)
{
- GtrHistoryEntryPrivate *priv;
+ GtrHistoryEntry *entry = GTR_HISTORY_ENTRY (object);
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_if_fail (GTR_IS_HISTORY_ENTRY (object));
- priv = GTR_HISTORY_ENTRY (object)->priv;
-
switch (prop_id)
{
case PROP_HISTORY_ID:
@@ -125,9 +127,8 @@ gtr_history_entry_get_property (GObject * object,
static void
gtr_history_entry_dispose (GObject * object)
{
- GtrHistoryEntryPrivate *priv;
-
- priv = GTR_HISTORY_ENTRY (object)->priv;
+ GtrHistoryEntry *entry = GTR_HISTORY_ENTRY (object);
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
gtr_history_entry_set_enable_completion (GTR_HISTORY_ENTRY (object), FALSE);
@@ -139,9 +140,8 @@ gtr_history_entry_dispose (GObject * object)
static void
gtr_history_entry_finalize (GObject * object)
{
- GtrHistoryEntryPrivate *priv;
-
- priv = GTR_HISTORY_ENTRY (object)->priv;
+ GtrHistoryEntry *entry = GTR_HISTORY_ENTRY (object);
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_free (priv->history_id);
@@ -153,9 +153,10 @@ gtr_history_entry_load_history (GtrHistoryEntry * entry)
{
gchar **items;
gsize i;
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
- items = g_settings_get_strv (entry->priv->settings,
- entry->priv->history_id);
+ items = g_settings_get_strv (priv->settings,
+ priv->history_id);
i = 0;
gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (entry));
@@ -163,7 +164,7 @@ gtr_history_entry_load_history (GtrHistoryEntry * entry)
/* Now the default value is an empty string so we have to take care
of it to not add the empty string in the search list */
while (items[i] != NULL && *items[i] != '\0' &&
- i < entry->priv->history_length)
+ i < priv->history_length)
{
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), items[i]);
i++;
@@ -212,8 +213,6 @@ gtr_history_entry_class_init (GtrHistoryEntryClass * klass)
TRUE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
-
- g_type_class_add_private (object_class, sizeof (GtrHistoryEntryPrivate));
}
static GtkListStore *
@@ -266,13 +265,14 @@ static void
gtr_history_entry_save_history (GtrHistoryEntry * entry)
{
gchar **items;
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
items = get_history_items (entry);
- g_settings_set_strv (entry->priv->settings,
- entry->priv->history_id,
+ g_settings_set_strv (priv->settings,
+ priv->history_id,
(const gchar * const *) items);
g_strfreev (items);
@@ -341,6 +341,7 @@ insert_history_item (GtrHistoryEntry * entry,
const gchar * text, gboolean prepend)
{
GtkListStore *store;
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
if (g_utf8_strlen (text, -1) <= MIN_ITEM_LEN)
return;
@@ -353,7 +354,7 @@ insert_history_item (GtrHistoryEntry * entry,
* would not work */
if (!remove_item (entry, text))
- clamp_list_store (store, entry->priv->history_length - 1);
+ clamp_list_store (store, priv->history_length - 1);
if (prepend)
gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), text);
@@ -394,10 +395,7 @@ gtr_history_entry_clear (GtrHistoryEntry * entry)
static void
gtr_history_entry_init (GtrHistoryEntry * entry)
{
- GtrHistoryEntryPrivate *priv;
-
- priv = GTR_HISTORY_ENTRY_GET_PRIVATE (entry);
- entry->priv = priv;
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
priv->history_id = NULL;
priv->history_length = GTR_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT;
@@ -411,10 +409,11 @@ void
gtr_history_entry_set_history_length (GtrHistoryEntry * entry,
guint history_length)
{
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
g_return_if_fail (history_length > 0);
- entry->priv->history_length = history_length;
+ priv->history_length = history_length;
/* TODO: update if we currently have more items than max */
}
@@ -422,63 +421,66 @@ gtr_history_entry_set_history_length (GtrHistoryEntry * entry,
guint
gtr_history_entry_get_history_length (GtrHistoryEntry * entry)
{
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), 0);
- return entry->priv->history_length;
+ return priv->history_length;
}
void
gtr_history_entry_set_enable_completion (GtrHistoryEntry * entry,
gboolean enable)
{
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
if (enable)
{
- if (entry->priv->completion != NULL)
+ if (priv->completion != NULL)
return;
- entry->priv->completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (entry->priv->completion,
+ priv->completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (priv->completion,
GTK_TREE_MODEL (get_history_store
(entry)));
/* Use model column 0 as the text column */
- gtk_entry_completion_set_text_column (entry->priv->completion, 0);
+ gtk_entry_completion_set_text_column (priv->completion, 0);
- gtk_entry_completion_set_minimum_key_length (entry->priv->completion,
+ gtk_entry_completion_set_minimum_key_length (priv->completion,
MIN_ITEM_LEN);
- gtk_entry_completion_set_popup_completion (entry->priv->completion,
+ gtk_entry_completion_set_popup_completion (priv->completion,
FALSE);
- gtk_entry_completion_set_inline_completion (entry->priv->completion,
+ gtk_entry_completion_set_inline_completion (priv->completion,
TRUE);
/* Assign the completion to the entry */
gtk_entry_set_completion (GTK_ENTRY
(gtr_history_entry_get_entry (entry)),
- entry->priv->completion);
+ priv->completion);
}
else
{
- if (entry->priv->completion == NULL)
+ if (priv->completion == NULL)
return;
gtk_entry_set_completion (GTK_ENTRY
(gtr_history_entry_get_entry (entry)), NULL);
- g_object_unref (entry->priv->completion);
+ g_object_unref (priv->completion);
- entry->priv->completion = NULL;
+ priv->completion = NULL;
}
}
gboolean
gtr_history_entry_get_enable_completion (GtrHistoryEntry * entry)
{
+ GtrHistoryEntryPrivate *priv = gtr_history_entry_get_instance_private (entry);
g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), FALSE);
- return entry->priv->completion != NULL;
+ return priv->completion != NULL;
}
GtkWidget *
diff --git a/src/gtr-history-entry.h b/src/gtr-history-entry.h
index c9ae1b55..852e43fb 100644
--- a/src/gtr-history-entry.h
+++ b/src/gtr-history-entry.h
@@ -38,22 +38,15 @@ G_BEGIN_DECLS
#define GTR_IS_HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_HISTORY_ENTRY))
#define GTR_IS_HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_HISTORY_ENTRY))
#define GTR_HISTORY_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_HISTORY_ENTRY,
GtrHistoryEntryClass))
+
typedef struct _GtrHistoryEntry GtrHistoryEntry;
typedef struct _GtrHistoryEntryClass GtrHistoryEntryClass;
-typedef struct _GtrHistoryEntryPrivate GtrHistoryEntryPrivate;
struct _GtrHistoryEntryClass
{
GtkComboBoxTextClass parent_class;
};
-struct _GtrHistoryEntry
-{
- GtkComboBoxText parent_instance;
-
- GtrHistoryEntryPrivate *priv;
-};
-
GType
gtr_history_entry_get_type (void)
G_GNUC_CONST;
diff --git a/src/gtr-io-error-info-bar.c b/src/gtr-io-error-info-bar.c
index 9067c202..5b3f8c2b 100644
--- a/src/gtr-io-error-info-bar.c
+++ b/src/gtr-io-error-info-bar.c
@@ -21,6 +21,7 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include <glib/gi18n.h>
static void
set_contents (GtkInfoBar * infobar, GtkWidget * contents)
@@ -51,10 +52,11 @@ set_info_bar_text_and_icon (GtkInfoBar * infobar,
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
gtk_widget_show (hbox_content);
- image = gtk_image_new_from_stock (icon_stock_id, GTK_ICON_SIZE_DIALOG);
+ image = gtk_image_new_from_icon_name (icon_stock_id, GTK_ICON_SIZE_DIALOG);
gtk_widget_show (image);
gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
+ gtk_widget_set_halign (image, 0.5);
+ gtk_widget_set_valign (image, 0.0);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_show (vbox);
@@ -69,7 +71,8 @@ set_info_bar_text_and_icon (GtkInfoBar * infobar,
gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0);
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
gtk_label_set_line_wrap (GTK_LABEL (primary_label), FALSE);
- gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5);
+ gtk_label_set_xalign (GTK_LABEL (primary_label), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (primary_label), 0.5);
gtk_widget_set_can_focus (primary_label, TRUE);
@@ -91,7 +94,8 @@ set_info_bar_text_and_icon (GtkInfoBar * infobar,
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
+ gtk_label_set_xalign (GTK_LABEL (secondary_label), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (secondary_label), 0.5);
}
set_contents (infobar, hbox_content);
@@ -116,13 +120,13 @@ create_error_info_bar (const gchar * primary_text,
{
GtkWidget *infobar;
- infobar = gtk_info_bar_new_with_buttons (GTK_STOCK_CLOSE,
+ infobar = gtk_info_bar_new_with_buttons (_("_Close"),
GTK_RESPONSE_CLOSE, NULL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_WARNING);
set_info_bar_text_and_icon (GTK_INFO_BAR (infobar),
- GTK_STOCK_DIALOG_ERROR,
+ "dialog-error-symbolic",
primary_text, secondary_text);
g_signal_connect (G_OBJECT (infobar), "response",
diff --git a/src/gtr-jump-dialog.c b/src/gtr-jump-dialog.c
index e082e74c..980a08e0 100644
--- a/src/gtr-jump-dialog.c
+++ b/src/gtr-jump-dialog.c
@@ -32,34 +32,37 @@
#include <gtk/gtk.h>
-#define GTR_JUMP_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_JUMP_DIALOG, \
- GtrJumpDialogPrivate))
+typedef struct
+{
+ GtkWidget *main_box;
+ GtkWidget *jump;
+
+ GtrWindow *window;
+} GtrJumpDialogPrivate;
+struct _GtrJumpDialog
+{
+ GtkDialog parent_instance;
+};
-G_DEFINE_TYPE (GtrJumpDialog, gtr_jump_dialog, GTK_TYPE_DIALOG)
- struct _GtrJumpDialogPrivate
- {
- GtkWidget *main_box;
- GtkWidget *jump;
+G_DEFINE_TYPE_WITH_PRIVATE (GtrJumpDialog, gtr_jump_dialog, GTK_TYPE_DIALOG)
- GtrWindow *window;
- };
- static void dialog_response_handler (GtkDialog * dlg, gint res_id)
+static void
+dialog_response_handler (GtkDialog * dlg, gint res_id)
{
GtrJumpDialog *dialog = GTR_JUMP_DIALOG (dlg);
GtrTab *tab;
gint number;
+ GtrJumpDialogPrivate *priv = gtr_jump_dialog_get_instance_private (dialog);
switch (res_id)
{
case GTK_RESPONSE_OK:
number =
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
- (dialog->priv->jump));
- tab = gtr_window_get_active_tab (dialog->priv->window);
+ (priv->jump));
+ tab = gtr_window_get_active_tab (priv->window);
gtr_tab_go_to_number (tab, number - 1);
gtk_widget_destroy (GTK_WIDGET (dlg));
break;
@@ -72,8 +75,7 @@ G_DEFINE_TYPE (GtrJumpDialog, gtr_jump_dialog, GTK_TYPE_DIALOG)
static void
gtr_jump_dialog_init (GtrJumpDialog * dlg)
{
- GtrJumpDialogPrivate *priv;
- GtkWidget *action_area;
+ GtrJumpDialogPrivate *priv = gtr_jump_dialog_get_instance_private (dlg);
GtkBox *content_area;
GtkBuilder *builder;
gchar *root_objects[] = {
@@ -82,27 +84,21 @@ gtr_jump_dialog_init (GtrJumpDialog * dlg)
NULL
};
- dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
- priv = dlg->priv;
-
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_OK,
+ _("_OK"),
GTK_RESPONSE_OK,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+ _("_Cancel"), GTK_RESPONSE_CANCEL, NULL);
gtk_window_set_title (GTK_WINDOW (dlg), _("Go to Message"));
gtk_window_set_default_size (GTK_WINDOW (dlg), 300, 100);
gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (content_area, 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 4);
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
@@ -133,8 +129,6 @@ gtr_jump_dialog_class_init (GtrJumpDialogClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrJumpDialogPrivate));
-
object_class->finalize = gtr_jump_dialog_finalize;
}
@@ -142,6 +136,7 @@ void
gtr_show_jump_dialog (GtrWindow * window)
{
static GtrJumpDialog *dlg = NULL;
+ GtrJumpDialogPrivate *priv = gtr_jump_dialog_get_instance_private (dlg);
g_return_if_fail (GTR_IS_WINDOW (window));
@@ -156,13 +151,13 @@ gtr_show_jump_dialog (GtrWindow * window)
g_signal_connect (dlg,
"destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
- dlg->priv->window = window;
+ priv->window = window;
/* Set the maximum number of the spin button */
tab = gtr_window_get_active_tab (window);
po = gtr_tab_get_po (tab);
messages = gtr_po_get_messages_count (po);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (dlg->priv->jump),
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->jump),
1.0, (gdouble) messages);
gtk_widget_show (GTK_WIDGET (dlg));
diff --git a/src/gtr-jump-dialog.h b/src/gtr-jump-dialog.h
index 2444bb1d..9cdc9270 100644
--- a/src/gtr-jump-dialog.h
+++ b/src/gtr-jump-dialog.h
@@ -35,22 +35,12 @@ G_BEGIN_DECLS
#define GTR_IS_JUMP_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_JUMP_DIALOG))
#define GTR_IS_JUMP_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_JUMP_DIALOG))
#define GTR_JUMP_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_JUMP_DIALOG,
GtrJumpDialogClass))
-/* Private structure type */
-typedef struct _GtrJumpDialogPrivate GtrJumpDialogPrivate;
/*
* Main object structure
*/
typedef struct _GtrJumpDialog GtrJumpDialog;
-struct _GtrJumpDialog
-{
- GtkDialog parent_instance;
-
- /*< private > */
- GtrJumpDialogPrivate *priv;
-};
-
/*
* Class definition
*/
diff --git a/src/gtr-language.c b/src/gtr-language.c
index 0d3f1a25..7a08db79 100644
--- a/src/gtr-language.c
+++ b/src/gtr-language.c
@@ -146,8 +146,8 @@ load_iso_entries (int iso,
if (reader == NULL)
goto out;
- xmlStrPrintf (iso_entries, sizeof (iso_entries), (const xmlChar *)"iso_%d_entries", iso);
- xmlStrPrintf (iso_entry, sizeof (iso_entry), (const xmlChar *)"iso_%d_entry", iso);
+ xmlStrPrintf (iso_entries, sizeof (iso_entries), (const char *)"iso_%d_entries", iso);
+ xmlStrPrintf (iso_entry, sizeof (iso_entry), (const char *)"iso_%d_entry", iso);
ret = xmlTextReaderRead (reader);
diff --git a/src/gtr-languages-fetcher.c b/src/gtr-languages-fetcher.c
index 5439f789..8fb52d1b 100644
--- a/src/gtr-languages-fetcher.c
+++ b/src/gtr-languages-fetcher.c
@@ -24,9 +24,7 @@
#include "gtr-utils.h"
#include <string.h>
-#define GTR_LANGUAGES_FETCHER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object),
GTR_TYPE_LANGUAGES_FETCHER, GtrLanguagesFetcherPrivate))
-
-struct _GtrLanguagesFetcherPrivate
+typedef struct
{
GtkWidget *language;
GtkWidget *language_code;
@@ -37,6 +35,11 @@ struct _GtrLanguagesFetcherPrivate
GtkListStore *language_store;
GtkListStore *code_store;
+} GtrLanguagesFetcherPrivate;
+
+struct _GtrLanguagesFetcher
+{
+ GtkBox parent;
};
/* Signals */
@@ -46,7 +49,7 @@ enum
LAST_SIGNAL
};
-G_DEFINE_TYPE (GtrLanguagesFetcher, gtr_languages_fetcher, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GtrLanguagesFetcher, gtr_languages_fetcher, GTK_TYPE_BOX)
static guint signals[LAST_SIGNAL] = { 0 };
@@ -72,8 +75,6 @@ gtr_languages_fetcher_class_init (GtrLanguagesFetcherClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
-
- g_type_class_add_private (object_class, sizeof (GtrLanguagesFetcherPrivate));
}
static gint
@@ -113,25 +114,26 @@ append_from_languages (GtrLanguagesFetcher *fetcher)
{
const GSList *languages, *l;
GHashTable *plurals;
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
plurals = g_hash_table_new (g_str_hash, g_int_equal);
languages = gtr_language_get_languages ();
- languages = g_slist_sort (languages, compare_languages_name);
+ languages = g_slist_sort ((GSList *)languages, compare_languages_name);
for (l = languages; l != NULL; l = g_slist_next (l))
{
GtrLanguage *lang = (GtrLanguage *)l->data;
GtkTreeIter iter1;
- gtk_list_store_append (fetcher->priv->language_store, &iter1);
- gtk_list_store_set (fetcher->priv->language_store, &iter1,
+ gtk_list_store_append (priv->language_store, &iter1);
+ gtk_list_store_set (priv->language_store, &iter1,
0, gtr_language_get_name (lang),
1, lang,
-1);
}
- languages = g_slist_sort (languages, compare_languages_code);
+ languages = g_slist_sort ((GSList *)languages, compare_languages_code);
for (l = languages; l != NULL; l = g_slist_next (l))
{
@@ -139,8 +141,8 @@ append_from_languages (GtrLanguagesFetcher *fetcher)
GtkTreeIter iter2;
const gchar *plural_form;
- gtk_list_store_append (fetcher->priv->code_store, &iter2);
- gtk_list_store_set (fetcher->priv->code_store, &iter2,
+ gtk_list_store_append (priv->code_store, &iter2);
+ gtk_list_store_set (priv->code_store, &iter2,
0, gtr_language_get_code (lang),
1, lang,
-1);
@@ -154,7 +156,7 @@ append_from_languages (GtrLanguagesFetcher *fetcher)
if (value == NULL)
{
g_hash_table_insert (plurals, (gchar *)plural_form, GINT_TO_POINTER (1));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (fetcher->priv->plural_forms),
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->plural_forms),
plural_form);
}
}
@@ -167,16 +169,17 @@ static void
fill_encoding_and_charset (GtrLanguagesFetcher *fetcher)
{
const gchar *text;
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
- text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->charset))));
+ text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->charset))));
if (text == NULL || *text == '\0')
- gtk_combo_box_set_active (GTK_COMBO_BOX (fetcher->priv->charset), 0);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->charset), 0);
- text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->encoding))));
+ text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->encoding))));
if (text == NULL || *text == '\0')
- gtk_combo_box_set_active (GTK_COMBO_BOX (fetcher->priv->encoding), 0);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->encoding), 0);
}
static void
@@ -184,10 +187,11 @@ fill_from_language_entry (GtrLanguagesFetcher *fetcher,
GtrLanguage *lang)
{
const gchar *entry_text;
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
fill_encoding_and_charset (fetcher);
- entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))));
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language_code))));
if (*entry_text == '\0')
{
@@ -196,10 +200,10 @@ fill_from_language_entry (GtrLanguagesFetcher *fetcher,
code = gtr_language_get_code (lang);
if (code != NULL && *code != '\0')
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))), code);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language_code))), code);
}
- entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))));
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))));
if (*entry_text == '\0')
{
@@ -208,7 +212,7 @@ fill_from_language_entry (GtrLanguagesFetcher *fetcher,
plural_form = gtr_language_get_plural_form (lang);
if (plural_form != NULL && *plural_form != '\0')
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))),
plural_form);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))), plural_form);
}
}
@@ -217,10 +221,11 @@ fill_from_language_code_entry (GtrLanguagesFetcher *fetcher,
GtrLanguage *lang)
{
const gchar *entry_text;
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
fill_encoding_and_charset (fetcher);
- entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))));
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language))));
if (*entry_text == '\0')
{
@@ -229,10 +234,10 @@ fill_from_language_code_entry (GtrLanguagesFetcher *fetcher,
name = gtr_language_get_name (lang);
if (name != NULL && *name != '\0')
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))), name);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language))), name);
}
- entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))));
+ entry_text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))));
if (*entry_text == '\0')
{
@@ -241,7 +246,7 @@ fill_from_language_code_entry (GtrLanguagesFetcher *fetcher,
plural_form = gtr_language_get_plural_form (lang);
if (plural_form != NULL && *plural_form != '\0')
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))),
plural_form);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))), plural_form);
}
}
@@ -296,7 +301,8 @@ static void
on_language_activate (GtkEntry *entry,
GtrLanguagesFetcher *fetcher)
{
- fill_boxes (fetcher, entry, GTK_TREE_MODEL (fetcher->priv->language_store),
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
+ fill_boxes (fetcher, entry, GTK_TREE_MODEL (priv->language_store),
fill_from_language_entry);
}
@@ -314,7 +320,8 @@ static void
on_language_code_activate (GtkEntry *entry,
GtrLanguagesFetcher *fetcher)
{
- fill_boxes (fetcher, entry, GTK_TREE_MODEL (fetcher->priv->code_store),
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
+ fill_boxes (fetcher, entry, GTK_TREE_MODEL (priv->code_store),
fill_from_language_code_entry);
}
@@ -338,7 +345,6 @@ on_combo_box_changed (GtkWidget *widget,
static void
gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
{
- GtrLanguagesFetcherPrivate *priv;
GtkWidget *content;
GtkBuilder *builder;
gchar *root_objects[] = {
@@ -347,9 +353,7 @@ gtr_languages_fetcher_init (GtrLanguagesFetcher *fetcher)
"code_store",
NULL
};
-
- fetcher->priv = GTR_LANGUAGES_FETCHER_GET_PRIVATE (fetcher);
- priv = fetcher->priv;
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
gtk_orientable_set_orientation (GTK_ORIENTABLE (fetcher),
GTK_ORIENTATION_VERTICAL);
@@ -421,107 +425,119 @@ gtr_languages_fetcher_new ()
const gchar *
gtr_languages_fetcher_get_language_name (GtrLanguagesFetcher *fetcher)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
- return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))));
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language))));
}
void
gtr_languages_fetcher_set_language_name (GtrLanguagesFetcher *fetcher,
const gchar *name)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
g_return_if_fail (name != NULL);
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language))), name);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language))), name);
}
const gchar *
gtr_languages_fetcher_get_language_code (GtrLanguagesFetcher *fetcher)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
- return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))));
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language_code))));
}
void
gtr_languages_fetcher_set_language_code (GtrLanguagesFetcher *fetcher,
const gchar *code)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
g_return_if_fail (code != NULL);
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->language_code))), code);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->language_code))), code);
}
const gchar *
gtr_languages_fetcher_get_charset (GtrLanguagesFetcher *fetcher)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
- return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->charset))));
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->charset))));
}
void
gtr_languages_fetcher_set_charset (GtrLanguagesFetcher *fetcher,
const gchar *charset)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
g_return_if_fail (charset != NULL);
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->charset))), charset);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->charset))), charset);
}
const gchar *
gtr_languages_fetcher_get_encoding (GtrLanguagesFetcher *fetcher)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
- return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->encoding))));
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->encoding))));
}
void
gtr_languages_fetcher_set_encoding (GtrLanguagesFetcher *fetcher,
const gchar *enc)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
g_return_if_fail (enc != NULL);
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->encoding))), enc);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->encoding))), enc);
}
const gchar *
gtr_languages_fetcher_get_team_email (GtrLanguagesFetcher *fetcher)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
- return gtk_entry_get_text (GTK_ENTRY (fetcher->priv->team_email));
+ return gtk_entry_get_text (GTK_ENTRY (priv->team_email));
}
void
gtr_languages_fetcher_set_team_email (GtrLanguagesFetcher *fetcher,
const gchar *email)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
g_return_if_fail (email != NULL);
- gtk_entry_set_text (GTK_ENTRY (fetcher->priv->team_email), email);
+ gtk_entry_set_text (GTK_ENTRY (priv->team_email), email);
}
const gchar *
gtr_languages_fetcher_get_plural_form (GtrLanguagesFetcher *fetcher)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_val_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher), NULL);
- return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))));
+ return gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))));
}
void
gtr_languages_fetcher_set_plural_form (GtrLanguagesFetcher *fetcher,
const gchar *plural_form)
{
+ GtrLanguagesFetcherPrivate *priv = gtr_languages_fetcher_get_instance_private (fetcher);
g_return_if_fail (GTR_IS_LANGUAGES_FETCHER (fetcher));
g_return_if_fail (plural_form != NULL);
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (fetcher->priv->plural_forms))), plural_form);
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->plural_forms))), plural_form);
}
diff --git a/src/gtr-languages-fetcher.h b/src/gtr-languages-fetcher.h
index 88de267d..108954d4 100644
--- a/src/gtr-languages-fetcher.h
+++ b/src/gtr-languages-fetcher.h
@@ -35,14 +35,6 @@ G_BEGIN_DECLS
typedef struct _GtrLanguagesFetcher GtrLanguagesFetcher;
typedef struct _GtrLanguagesFetcherClass GtrLanguagesFetcherClass;
-typedef struct _GtrLanguagesFetcherPrivate GtrLanguagesFetcherPrivate;
-
-struct _GtrLanguagesFetcher
-{
- GtkBox parent;
-
- GtrLanguagesFetcherPrivate *priv;
-};
struct _GtrLanguagesFetcherClass
{
diff --git a/src/gtr-msg.c b/src/gtr-msg.c
index 08fb34b6..02be5ca5 100644
--- a/src/gtr-msg.c
+++ b/src/gtr-msg.c
@@ -32,15 +32,7 @@
#include <gtk/gtk.h>
#include <gettext-po.h>
-#define GTR_MSG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_MSG, \
- GtrMsgPrivate))
-
-
-G_DEFINE_TYPE (GtrMsg, gtr_msg, G_TYPE_OBJECT)
-
-struct _GtrMsgPrivate
+typedef struct
{
po_message_iterator_t iterator;
@@ -49,14 +41,16 @@ struct _GtrMsgPrivate
GtrMsgStatus status;
gint po_position;
-};
+} GtrMsgPrivate;
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrMsg, gtr_msg, G_TYPE_OBJECT)
static gchar *message_error = NULL;
static void
gtr_msg_init (GtrMsg * msg)
{
- msg->priv = GTR_MSG_GET_PRIVATE (msg);
}
static void
@@ -70,8 +64,6 @@ gtr_msg_class_init (GtrMsgClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrMsgPrivate));
-
object_class->finalize = gtr_msg_finalize;
}
@@ -118,9 +110,10 @@ _gtr_msg_new (po_message_iterator_t iter, po_message_t message)
po_message_iterator_t
_gtr_msg_get_iterator (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return msg->priv->iterator;
+ return priv->iterator;
}
/**
@@ -133,9 +126,10 @@ _gtr_msg_get_iterator (GtrMsg * msg)
void
_gtr_msg_set_iterator (GtrMsg * msg, po_message_iterator_t iter)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
- msg->priv->iterator = iter;
+ priv->iterator = iter;
}
/**
@@ -147,9 +141,10 @@ _gtr_msg_set_iterator (GtrMsg * msg, po_message_iterator_t iter)
po_message_t
_gtr_msg_get_message (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return msg->priv->message;
+ return priv->message;
}
/**
@@ -162,10 +157,11 @@ _gtr_msg_get_message (GtrMsg * msg)
void
_gtr_msg_set_message (GtrMsg * msg, po_message_t message)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
g_return_if_fail (message != NULL);
- msg->priv->message = message;
+ priv->message = message;
}
/**
@@ -211,9 +207,10 @@ gtr_msg_is_translated (GtrMsg *msg)
gboolean
gtr_msg_is_fuzzy (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), FALSE);
- return po_message_is_fuzzy (msg->priv->message);
+ return po_message_is_fuzzy (priv->message);
}
@@ -227,9 +224,10 @@ gtr_msg_is_fuzzy (GtrMsg * msg)
void
gtr_msg_set_fuzzy (GtrMsg * msg, gboolean fuzzy)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
- po_message_set_fuzzy (msg->priv->message, fuzzy);
+ po_message_set_fuzzy (priv->message, fuzzy);
}
/**
@@ -242,9 +240,10 @@ gtr_msg_set_fuzzy (GtrMsg * msg, gboolean fuzzy)
void
gtr_msg_set_status (GtrMsg * msg, GtrMsgStatus status)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
- msg->priv->status = status;
+ priv->status = status;
}
/**
@@ -256,9 +255,10 @@ gtr_msg_set_status (GtrMsg * msg, GtrMsgStatus status)
GtrMsgStatus
gtr_msg_get_status (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), 0);
- return msg->priv->status;
+ return priv->status;
}
/**
@@ -270,9 +270,10 @@ gtr_msg_get_status (GtrMsg * msg)
const gchar *
gtr_msg_get_msgid (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_msgid (msg->priv->message);
+ return po_message_msgid (priv->message);
}
@@ -286,7 +287,8 @@ gtr_msg_get_msgid (GtrMsg * msg)
const gchar *
gtr_msg_get_msgid_plural (GtrMsg * msg)
{
- return po_message_msgid_plural (msg->priv->message);
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
+ return po_message_msgid_plural (priv->message);
}
@@ -300,9 +302,10 @@ gtr_msg_get_msgid_plural (GtrMsg * msg)
const gchar *
gtr_msg_get_msgstr (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_msgstr (msg->priv->message);
+ return po_message_msgstr (priv->message);
}
@@ -317,10 +320,11 @@ gtr_msg_get_msgstr (GtrMsg * msg)
void
gtr_msg_set_msgstr (GtrMsg * msg, const gchar * msgstr)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
g_return_if_fail (msgstr != NULL);
- po_message_set_msgstr (msg->priv->message, msgstr);
+ po_message_set_msgstr (priv->message, msgstr);
}
@@ -336,9 +340,10 @@ gtr_msg_set_msgstr (GtrMsg * msg, const gchar * msgstr)
const gchar *
gtr_msg_get_msgstr_plural (GtrMsg * msg, gint index)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_msgstr_plural (msg->priv->message, index);
+ return po_message_msgstr_plural (priv->message, index);
}
/**
@@ -353,10 +358,11 @@ gtr_msg_get_msgstr_plural (GtrMsg * msg, gint index)
void
gtr_msg_set_msgstr_plural (GtrMsg * msg, gint index, const gchar * msgstr)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
g_return_if_fail (msgstr != NULL);
- po_message_set_msgstr_plural (msg->priv->message, index, msgstr);
+ po_message_set_msgstr_plural (priv->message, index, msgstr);
}
@@ -369,9 +375,10 @@ gtr_msg_set_msgstr_plural (GtrMsg * msg, gint index, const gchar * msgstr)
const gchar *
gtr_msg_get_comment (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_comments (msg->priv->message);
+ return po_message_comments (priv->message);
}
/**
@@ -386,10 +393,11 @@ gtr_msg_get_comment (GtrMsg * msg)
void
gtr_msg_set_comment (GtrMsg * msg, const gchar * comment)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
g_return_if_fail (comment != NULL);
- po_message_set_comments (msg->priv->message, comment);
+ po_message_set_comments (priv->message, comment);
}
/**
@@ -404,9 +412,10 @@ gtr_msg_set_comment (GtrMsg * msg, const gchar * comment)
gint
gtr_msg_get_po_position (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), 0);
- return msg->priv->po_position;
+ return priv->po_position;
}
/**
@@ -419,9 +428,10 @@ gtr_msg_get_po_position (GtrMsg * msg)
void
gtr_msg_set_po_position (GtrMsg * msg, gint po_position)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_if_fail (GTR_IS_MSG (msg));
- msg->priv->po_position = po_position;
+ priv->po_position = po_position;
}
/**
@@ -433,9 +443,10 @@ gtr_msg_set_po_position (GtrMsg * msg, gint po_position)
const gchar *
gtr_msg_get_extracted_comments (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_extracted_comments (msg->priv->message);
+ return po_message_extracted_comments (priv->message);
}
/**
@@ -449,11 +460,12 @@ gtr_msg_get_extracted_comments (GtrMsg * msg)
const gchar *
gtr_msg_get_filename (GtrMsg * msg, gint i)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
po_filepos_t filepos;
- filepos = po_message_filepos (msg->priv->message, i);
+ filepos = po_message_filepos (priv->message, i);
if (filepos == NULL)
return NULL;
@@ -472,11 +484,12 @@ gtr_msg_get_filename (GtrMsg * msg, gint i)
gint *
gtr_msg_get_file_line (GtrMsg * msg, gint i)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), (gint *) 0);
po_filepos_t filepos;
- filepos = po_message_filepos (msg->priv->message, i);
+ filepos = po_message_filepos (priv->message, i);
if (filepos == NULL)
return NULL;
@@ -494,9 +507,10 @@ gtr_msg_get_file_line (GtrMsg * msg, gint i)
const gchar *
gtr_msg_get_msgctxt (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_msgctxt (msg->priv->message);
+ return po_message_msgctxt (priv->message);
}
/**
@@ -513,6 +527,7 @@ gtr_msg_get_msgctxt (GtrMsg * msg)
const gchar *
gtr_msg_get_format (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
const gchar *const *format_list;
gint i;
@@ -522,7 +537,7 @@ gtr_msg_get_format (GtrMsg * msg)
for (i = 0; format_list[i] != NULL; i++)
{
- if (po_message_is_format (msg->priv->message, format_list[i]))
+ if (po_message_is_format (priv->message, format_list[i]))
return po_format_pretty_name (format_list[i]);
}
@@ -570,6 +585,7 @@ on_gettext_po_xerror2 (gint severity,
gchar *
gtr_msg_check (GtrMsg * msg)
{
+ GtrMsgPrivate *priv = gtr_msg_get_instance_private (msg);
struct po_xerror_handler handler;
g_return_val_if_fail (msg != NULL, NULL);
@@ -582,7 +598,7 @@ gtr_msg_check (GtrMsg * msg)
handler.xerror = &on_gettext_po_xerror;
handler.xerror2 = &on_gettext_po_xerror2;
- po_message_check_all (msg->priv->message, msg->priv->iterator, &handler);
+ po_message_check_all (priv->message, priv->iterator, &handler);
if (gtr_msg_is_fuzzy (msg) || !gtr_msg_is_translated (msg))
{
diff --git a/src/gtr-msg.h b/src/gtr-msg.h
index 9183fc12..53d1e7d1 100644
--- a/src/gtr-msg.h
+++ b/src/gtr-msg.h
@@ -39,14 +39,10 @@ G_BEGIN_DECLS
typedef struct _GtrMsg GtrMsg;
typedef struct _GtrMsgClass GtrMsgClass;
-typedef struct _GtrMsgPrivate GtrMsgPrivate;
struct _GtrMsg
{
GObject parent_instance;
-
- /*< private > */
- GtrMsgPrivate *priv;
};
struct _GtrMsgClass
diff --git a/src/gtr-po.c b/src/gtr-po.c
index 73955075..ac4fa21c 100644
--- a/src/gtr-po.c
+++ b/src/gtr-po.c
@@ -53,17 +53,7 @@
static void gtr_po_message_container_init (GtrMessageContainerInterface *iface);
-#define GTR_PO_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_PO, \
- GtrPoPrivate))
-
-
-G_DEFINE_TYPE_WITH_CODE (GtrPo, gtr_po, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (GTR_TYPE_MESSAGE_CONTAINER,
- gtr_po_message_container_init))
-
-struct _GtrPoPrivate
+typedef struct
{
/* The location of the file to open */
GFile *location;
@@ -105,7 +95,13 @@ struct _GtrPoPrivate
/* Marks if the file was changed; */
guint file_changed : 1;
-};
+} GtrPoPrivate;
+
+
+G_DEFINE_TYPE_WITH_CODE (GtrPo, gtr_po, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtrPo)
+ G_IMPLEMENT_INTERFACE (GTR_TYPE_MESSAGE_CONTAINER,
+ gtr_po_message_container_init))
enum
{
@@ -162,10 +158,11 @@ gtr_po_get_property (GObject * object,
static void
determine_translation_status (GtrMsg * msg, GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
if (gtr_msg_is_fuzzy (msg))
- po->priv->fuzzy++;
+ priv->fuzzy++;
else if (gtr_msg_is_translated (msg))
- po->priv->translated++;
+ priv->translated++;
}
/*
@@ -174,32 +171,34 @@ determine_translation_status (GtrMsg * msg, GtrPo * po)
static void
gtr_po_update_translated_count (GtrPo * po)
{
- po->priv->translated = 0;
- po->priv->fuzzy = 0;
- g_list_foreach (po->priv->messages,
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
+ priv->translated = 0;
+ priv->fuzzy = 0;
+ g_list_foreach (priv->messages,
(GFunc) determine_translation_status, po);
}
static void
gtr_po_init (GtrPo * po)
{
- po->priv = GTR_PO_GET_PRIVATE (po);
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- po->priv->location = NULL;
- po->priv->gettext_po_file = NULL;
+ priv->location = NULL;
+ priv->gettext_po_file = NULL;
}
static void
gtr_po_finalize (GObject * object)
{
GtrPo *po = GTR_PO (object);
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- g_list_free_full (po->priv->messages, g_object_unref);
- g_list_free_full (po->priv->domains, g_free);
- g_free (po->priv->obsolete);
+ g_list_free_full (priv->messages, g_object_unref);
+ g_list_free_full (priv->domains, g_free);
+ g_free (priv->obsolete);
- if (po->priv->gettext_po_file)
- po_file_free (po->priv->gettext_po_file);
+ if (priv->gettext_po_file)
+ po_file_free (priv->gettext_po_file);
G_OBJECT_CLASS (gtr_po_parent_class)->finalize (object);
}
@@ -208,8 +207,9 @@ static void
gtr_po_dispose (GObject * object)
{
GtrPo *po = GTR_PO (object);
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- g_clear_object (&po->priv->location);
+ g_clear_object (&priv->location);
G_OBJECT_CLASS (gtr_po_parent_class)->dispose (object);
}
@@ -219,8 +219,9 @@ gtr_po_message_container_get_message (GtrMessageContainer *container,
gint number)
{
GtrPo *po = GTR_PO (container);
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- return g_list_nth_data (po->priv->messages, number);
+ return g_list_nth_data (priv->messages, number);
}
static gint
@@ -229,17 +230,19 @@ gtr_po_message_container_get_message_number (GtrMessageContainer * container,
{
GtrPo *po = GTR_PO (container);
GList *list;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- list = g_list_find (po->priv->messages, msg);
- return g_list_position (po->priv->messages, list);
+ list = g_list_find (priv->messages, msg);
+ return g_list_position (priv->messages, list);
}
static gint
gtr_po_message_container_get_count (GtrMessageContainer * container)
{
GtrPo *po = GTR_PO (container);
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- return g_list_length (po->priv->messages);
+ return g_list_length (priv->messages);
}
static void
@@ -255,8 +258,6 @@ gtr_po_class_init (GtrPoClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrPoPrivate));
-
object_class->finalize = gtr_po_finalize;
object_class->dispose = gtr_po_dispose;
object_class->get_property = gtr_po_get_property;
@@ -393,12 +394,12 @@ gtr_po_new (void)
static gboolean
_gtr_po_load (GtrPo * po, GFile * location, GError ** error)
{
- GtrPoPrivate *priv = po->priv;
struct po_xerror_handler handler;
po_message_iterator_t iter;
po_message_t message;
const gchar *msgid;
gchar *filename;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
/*
* Initialize the handler error.
@@ -414,8 +415,8 @@ _gtr_po_load (GtrPo * po, GFile * location, GError ** error)
filename = g_file_get_path (location);
- if (po->priv->gettext_po_file)
- po_file_free (po->priv->gettext_po_file);
+ if (priv->gettext_po_file)
+ po_file_free (priv->gettext_po_file);
if (priv->header)
{
@@ -440,7 +441,7 @@ _gtr_po_load (GtrPo * po, GFile * location, GError ** error)
return FALSE;
}
- if (!po->priv->gettext_po_file)
+ if (!priv->gettext_po_file)
{
g_set_error (error,
GTR_PO_ERROR,
@@ -477,8 +478,9 @@ _gtr_po_load_ensure_utf8 (GtrPo * po, GError ** error)
gboolean utf8_valid;
gchar *filename;
gsize size;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- filename = g_file_get_path (po->priv->location);
+ filename = g_file_get_path (priv->location);
mapped = g_mapped_file_new (filename, FALSE, error);
g_free (filename);
@@ -490,19 +492,19 @@ _gtr_po_load_ensure_utf8 (GtrPo * po, GError ** error)
utf8_valid = g_utf8_validate (content, size, NULL);
- if (!_gtr_po_load (po, po->priv->location, error))
+ if (!_gtr_po_load (po, priv->location, error))
{
g_mapped_file_unref (mapped);
return FALSE;
}
if (!utf8_valid &&
- po->priv->header)
+ priv->header)
{
gchar *charset = NULL;
- if (po->priv->header)
- charset = gtr_header_get_charset (po->priv->header);
+ if (priv->header)
+ charset = gtr_header_get_charset (priv->header);
if (charset && *charset && strcmp (charset, "UTF-8") != 0)
{
@@ -579,8 +581,8 @@ _gtr_po_load_ensure_utf8 (GtrPo * po, GError ** error)
/* Ensure Content-Type is set correctly
* in the header as per the content
*/
- if (po->priv->header)
- gtr_header_set_charset (po->priv->header, "UTF-8");
+ if (priv->header)
+ gtr_header_set_charset (priv->header, "UTF-8");
utf8_valid = TRUE;
}
@@ -614,13 +616,13 @@ _gtr_po_load_ensure_utf8 (GtrPo * po, GError ** error)
gboolean
gtr_po_parse (GtrPo * po, GFile * location, GError ** error)
{
- GtrPoPrivate *priv = po->priv;
GtrMsg *msg;
po_message_t message;
po_message_iterator_t iter;
const gchar *const *domains;
gint i = 0;
gint pos = 1;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), FALSE);
g_return_val_if_fail (location != NULL, FALSE);
@@ -634,7 +636,7 @@ gtr_po_parse (GtrPo * po, GFile * location, GError ** error)
/*
* Get filename path.
*/
- po->priv->location = g_file_dup (location);
+ priv->location = g_file_dup (location);
if (!_gtr_po_load_ensure_utf8 (po, error))
{
@@ -721,7 +723,7 @@ gtr_po_parse (GtrPo * po, GFile * location, GError ** error)
gtr_po_update_translated_count (po);
/* Initialize Tab state */
- po->priv->state = GTR_PO_STATE_SAVED;
+ priv->state = GTR_PO_STATE_SAVED;
return TRUE;
}
@@ -739,6 +741,7 @@ gtr_po_save_file (GtrPo * po, GError ** error)
struct po_xerror_handler handler;
gchar *filename;
GtrHeader *header;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
/*
* Initialice the handler error.
@@ -746,7 +749,7 @@ gtr_po_save_file (GtrPo * po, GError ** error)
handler.xerror = &on_gettext_po_xerror;
handler.xerror2 = &on_gettext_po_xerror2;
- filename = g_file_get_path (po->priv->location);
+ filename = g_file_get_path (priv->location);
if (g_str_has_suffix (filename, ".pot"))
{
@@ -813,15 +816,15 @@ gtr_po_save_file (GtrPo * po, GError ** error)
/*
* If the warn if fuzzy option is enabled we have to show an error
*/
- /*if (gtr_prefs_manager_get_warn_if_fuzzy () && po->priv->fuzzy)
+ /*if (gtr_prefs_manager_get_warn_if_fuzzy () && priv->fuzzy)
{
g_set_error (error,
GTR_PO_ERROR,
GTR_PO_ERROR_OTHER,
ngettext ("File %s\ncontains %d fuzzy message",
"File %s\ncontains %d fuzzy messages",
- po->priv->fuzzy),
- po->priv->fuzzy);
+ priv->fuzzy),
+ priv->fuzzy);
} */
}
@@ -837,9 +840,10 @@ gtr_po_save_file (GtrPo * po, GError ** error)
GFile *
gtr_po_get_location (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return g_file_dup (po->priv->location);
+ return g_file_dup (priv->location);
}
/**
@@ -852,16 +856,17 @@ gtr_po_get_location (GtrPo * po)
void
gtr_po_set_location (GtrPo * po, GFile * location)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_if_fail (GTR_IS_PO (po));
- if (po->priv->location)
+ if (priv->location)
{
- if (g_file_equal (po->priv->location, location))
+ if (g_file_equal (priv->location, location))
return;
- g_object_unref (po->priv->location);
+ g_object_unref (priv->location);
}
- po->priv->location = g_file_dup (location);
+ priv->location = g_file_dup (location);
g_object_notify (G_OBJECT (po), "location");
}
@@ -875,9 +880,10 @@ gtr_po_set_location (GtrPo * po, GFile * location)
GtrPoState
gtr_po_get_state (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), 0);
- return po->priv->state;
+ return priv->state;
}
/**
@@ -890,9 +896,10 @@ gtr_po_get_state (GtrPo * po)
void
gtr_po_set_state (GtrPo * po, GtrPoState state)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_if_fail (GTR_IS_PO (po));
- po->priv->state = state;
+ priv->state = state;
g_object_notify (G_OBJECT (po), "state");
}
@@ -903,7 +910,8 @@ gtr_po_set_state (GtrPo * po, GtrPoState state)
gboolean
gtr_po_get_write_perms (GtrPo * po)
{
- return po->priv->no_write_perms;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
+ return priv->no_write_perms;
}
/**
@@ -916,9 +924,10 @@ gtr_po_get_write_perms (GtrPo * po)
GList *
gtr_po_get_messages (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return po->priv->messages;
+ return priv->messages;
}
/* FIXME: this is hack, we should fix it */
@@ -932,9 +941,10 @@ gtr_po_get_messages (GtrPo * po)
void
gtr_po_set_messages (GtrPo * po, GList * messages)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_if_fail (GTR_IS_PO (po));
- po->priv->messages = messages;
+ priv->messages = messages;
}
/**
@@ -947,7 +957,8 @@ gtr_po_set_messages (GtrPo * po, GList * messages)
GList *
gtr_po_get_current_message (GtrPo * po)
{
- return po->priv->current;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
+ return priv->current;
}
/**
@@ -962,8 +973,9 @@ void
gtr_po_update_current_message (GtrPo * po, GtrMsg * msg)
{
gint i;
- i = g_list_index (po->priv->messages, msg);
- po->priv->current = g_list_nth (po->priv->messages, i);
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
+ i = g_list_index (priv->messages, msg);
+ priv->current = g_list_nth (priv->messages, i);
}
/**
@@ -976,7 +988,8 @@ gtr_po_update_current_message (GtrPo * po, GtrMsg * msg)
GList *
gtr_po_get_domains (GtrPo * po)
{
- return po->priv->domains;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
+ return priv->domains;
}
/**
@@ -990,7 +1003,8 @@ gtr_po_get_domains (GtrPo * po)
po_file_t
gtr_po_get_po_file (GtrPo * po)
{
- return po->priv->gettext_po_file;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
+ return priv->gettext_po_file;
}
/**
@@ -1004,8 +1018,9 @@ GList *
gtr_po_get_next_fuzzy (GtrPo * po)
{
GList *msg;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- msg = po->priv->current;
+ msg = priv->current;
while ((msg = g_list_next (msg)))
{
if (gtr_msg_is_fuzzy (msg->data))
@@ -1027,8 +1042,9 @@ GList *
gtr_po_get_prev_fuzzy (GtrPo * po)
{
GList *msg;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- msg = po->priv->current;
+ msg = priv->current;
while ((msg = g_list_previous (msg)))
{
if (gtr_msg_is_fuzzy (msg->data))
@@ -1050,8 +1066,9 @@ GList *
gtr_po_get_next_untrans (GtrPo * po)
{
GList *msg;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- msg = po->priv->current;
+ msg = priv->current;
while ((msg = g_list_next (msg)))
{
if (!gtr_msg_is_translated (msg->data))
@@ -1075,8 +1092,9 @@ GList *
gtr_po_get_prev_untrans (GtrPo * po)
{
GList *msg;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- msg = po->priv->current;
+ msg = priv->current;
while ((msg = g_list_previous (msg)))
{
if (!gtr_msg_is_translated (msg->data))
@@ -1099,8 +1117,9 @@ GList *
gtr_po_get_next_fuzzy_or_untrans (GtrPo * po)
{
GList *msg;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- msg = po->priv->current;
+ msg = priv->current;
while ((msg = g_list_next (msg)))
{
if (gtr_msg_is_fuzzy (msg->data) || !gtr_msg_is_translated (msg->data))
@@ -1123,8 +1142,9 @@ GList *
gtr_po_get_prev_fuzzy_or_untrans (GtrPo * po)
{
GList *msg;
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
- msg = po->priv->current;
+ msg = priv->current;
while ((msg = g_list_previous (msg)))
{
if (gtr_msg_is_fuzzy (msg->data) || !gtr_msg_is_translated (msg->data))
@@ -1147,9 +1167,10 @@ gtr_po_get_prev_fuzzy_or_untrans (GtrPo * po)
GList *
gtr_po_get_msg_from_number (GtrPo * po, gint number)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return g_list_nth (po->priv->messages, number);
+ return g_list_nth (priv->messages, number);
}
/**
@@ -1161,9 +1182,10 @@ gtr_po_get_msg_from_number (GtrPo * po, gint number)
GtrHeader *
gtr_po_get_header (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return po->priv->header;
+ return priv->header;
}
/**
@@ -1175,9 +1197,10 @@ gtr_po_get_header (GtrPo * po)
gint
gtr_po_get_translated_count (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), -1);
- return po->priv->translated;
+ return priv->translated;
}
/*
@@ -1188,12 +1211,13 @@ gtr_po_get_translated_count (GtrPo * po)
void
_gtr_po_increase_decrease_translated (GtrPo * po, gboolean increase)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_if_fail (GTR_IS_PO (po));
if (increase)
- po->priv->translated++;
+ priv->translated++;
else
- po->priv->translated--;
+ priv->translated--;
}
/**
@@ -1205,9 +1229,10 @@ _gtr_po_increase_decrease_translated (GtrPo * po, gboolean increase)
gint
gtr_po_get_fuzzy_count (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), -1);
- return po->priv->fuzzy;
+ return priv->fuzzy;
}
/*
@@ -1218,12 +1243,13 @@ gtr_po_get_fuzzy_count (GtrPo * po)
void
_gtr_po_increase_decrease_fuzzy (GtrPo * po, gboolean increase)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_if_fail (GTR_IS_PO (po));
if (increase)
- po->priv->fuzzy++;
+ priv->fuzzy++;
else
- po->priv->fuzzy--;
+ priv->fuzzy--;
}
/**
@@ -1235,10 +1261,11 @@ _gtr_po_increase_decrease_fuzzy (GtrPo * po, gboolean increase)
gint
gtr_po_get_untranslated_count (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), -1);
- return (g_list_length (po->priv->messages) - po->priv->translated -
- po->priv->fuzzy);
+ return (g_list_length (priv->messages) - priv->translated -
+ priv->fuzzy);
}
/**
@@ -1250,9 +1277,10 @@ gtr_po_get_untranslated_count (GtrPo * po)
gint
gtr_po_get_messages_count (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), -1);
- return g_list_length (po->priv->messages);
+ return g_list_length (priv->messages);
}
/**
@@ -1264,9 +1292,10 @@ gtr_po_get_messages_count (GtrPo * po)
gint
gtr_po_get_message_position (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
g_return_val_if_fail (GTR_IS_PO (po), -1);
- return gtr_msg_get_po_position (GTR_MSG (po->priv->current->data));
+ return gtr_msg_get_po_position (GTR_MSG (priv->current->data));
}
/**
@@ -1280,6 +1309,7 @@ gtr_po_get_message_position (GtrPo * po)
gchar *
gtr_po_check_po_file (GtrPo * po)
{
+ GtrPoPrivate *priv = gtr_po_get_instance_private (po);
struct po_xerror_handler handler;
g_return_val_if_fail (po != NULL, NULL);
@@ -1288,7 +1318,7 @@ gtr_po_check_po_file (GtrPo * po)
handler.xerror2 = &on_gettext_po_xerror2;
message_error = NULL;
- po_file_check_all (po->priv->gettext_po_file, &handler);
+ po_file_check_all (priv->gettext_po_file, &handler);
return message_error;
}
diff --git a/src/gtr-po.h b/src/gtr-po.h
index 22cdad82..bb260067 100644
--- a/src/gtr-po.h
+++ b/src/gtr-po.h
@@ -42,9 +42,6 @@ G_BEGIN_DECLS
#define GTR_IS_PO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_PO))
#define GTR_IS_PO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PO))
#define GTR_PO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PO, GtrPoClass))
-/* Private structure type */
-typedef struct _GtrPoPrivate GtrPoPrivate;
-
/*
* Main object structure
*/
@@ -53,9 +50,6 @@ typedef struct _GtrPo GtrPo;
struct _GtrPo
{
GObject parent_instance;
-
- /*< private > */
- GtrPoPrivate *priv;
};
/*
diff --git a/src/gtr-preferences-dialog.c b/src/gtr-preferences-dialog.c
index 9c68a224..010b2e61 100644
--- a/src/gtr-preferences-dialog.c
+++ b/src/gtr-preferences-dialog.c
@@ -44,15 +44,7 @@
#include <string.h>
#include <gtksourceview/gtksource.h>
-#define GTR_PREFERENCES_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_PREFERENCES_DIALOG, \
- GtrPreferencesDialogPrivate))
-
-
-G_DEFINE_TYPE (GtrPreferencesDialog, gtr_preferences_dialog, GTK_TYPE_DIALOG)
-
-struct _GtrPreferencesDialogPrivate
+typedef struct
{
GSettings *ui_settings;
GSettings *editor_settings;
@@ -72,9 +64,6 @@ struct _GtrPreferencesDialogPrivate
/* Editor->Text display */
GtkWidget *highlight_syntax_checkbutton;
GtkWidget *visible_whitespace_checkbutton;
- GtkWidget *use_custom_font_checkbutton;
- GtkWidget *editor_font_fontbutton;
- GtkWidget *editor_font_hbox;
/* Editor->Contents */
GtkWidget *unmark_fuzzy_when_changed_checkbutton;
@@ -85,7 +74,10 @@ struct _GtrPreferencesDialogPrivate
GtkWidget *add_button;
GtkWidget *edit_button;
GtkWidget *delete_button;
-};
+} GtrPreferencesDialogPrivate;
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrPreferencesDialog, gtr_preferences_dialog, GTK_TYPE_DIALOG)
enum
{
@@ -100,9 +92,10 @@ enum
static void
setup_files_general_page (GtrPreferencesDialog * dlg)
{
- g_settings_bind (dlg->priv->files_settings,
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
+ g_settings_bind (priv->files_settings,
GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY,
- dlg->priv->warn_if_contains_fuzzy_checkbutton,
+ priv->warn_if_contains_fuzzy_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
@@ -112,36 +105,38 @@ on_auto_save_changed (GSettings *settings,
const gchar *key,
GtrPreferencesDialog *dlg)
{
- gtk_widget_set_sensitive (dlg->priv->autosave_interval_spinbutton,
+ 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)
{
- g_settings_bind (dlg->priv->files_settings,
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
+ g_settings_bind (priv->files_settings,
GTR_SETTINGS_AUTO_SAVE_INTERVAL,
- dlg->priv->autosave_interval_spinbutton,
+ priv->autosave_interval_spinbutton,
"value",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->files_settings,
+ g_settings_bind (priv->files_settings,
GTR_SETTINGS_AUTO_SAVE,
- dlg->priv->autosave_checkbutton,
+ priv->autosave_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_signal_connect (dlg->priv->files_settings,
+ g_signal_connect (priv->files_settings,
"changed::" GTR_SETTINGS_AUTO_SAVE,
G_CALLBACK (on_auto_save_changed),
dlg);
/*Set sensitive */
- on_auto_save_changed (dlg->priv->files_settings,
+ on_auto_save_changed (priv->files_settings,
GTR_SETTINGS_AUTO_SAVE,
dlg);
- g_settings_bind (dlg->priv->files_settings,
+ g_settings_bind (priv->files_settings,
GTR_SETTINGS_CREATE_BACKUP,
- dlg->priv->create_backup_checkbutton,
+ priv->create_backup_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
@@ -157,60 +152,34 @@ setup_files_pages (GtrPreferencesDialog * dlg)
/***************Editor pages****************/
-static void
-use_custom_font_changed (GSettings *settings,
- const gchar *key,
- GtrPreferencesDialog *dlg)
-{
- gtk_widget_set_sensitive (dlg->priv->editor_font_hbox,
- g_settings_get_boolean (settings, key));
-}
-
static void
setup_editor_text_display_page (GtrPreferencesDialog * dlg)
{
- g_settings_bind (dlg->priv->editor_settings,
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
+ g_settings_bind (priv->editor_settings,
GTR_SETTINGS_HIGHLIGHT_SYNTAX,
- dlg->priv->highlight_syntax_checkbutton,
+ priv->highlight_syntax_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor_settings,
+ g_settings_bind (priv->editor_settings,
GTR_SETTINGS_VISIBLE_WHITESPACE,
- dlg->priv->visible_whitespace_checkbutton,
+ priv->visible_whitespace_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
-
- g_settings_bind (dlg->priv->editor_settings,
- GTR_SETTINGS_USE_CUSTOM_FONT,
- dlg->priv->use_custom_font_checkbutton,
- "active",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_signal_connect (dlg->priv->editor_settings,
- "changed::" GTR_SETTINGS_USE_CUSTOM_FONT,
- G_CALLBACK (use_custom_font_changed), dlg);
- /*Set sensitive */
- use_custom_font_changed (dlg->priv->editor_settings,
- GTR_SETTINGS_USE_CUSTOM_FONT,
- dlg);
-
- g_settings_bind (dlg->priv->editor_settings,
- GTR_SETTINGS_EDITOR_FONT,
- dlg->priv->editor_font_fontbutton,
- "font-name",
- G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
static void
setup_editor_contents (GtrPreferencesDialog * dlg)
{
- g_settings_bind (dlg->priv->editor_settings,
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
+ g_settings_bind (priv->editor_settings,
GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED,
- dlg->priv->unmark_fuzzy_when_changed_checkbutton,
+ priv->unmark_fuzzy_when_changed_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
- g_settings_bind (dlg->priv->editor_settings,
+ g_settings_bind (priv->editor_settings,
GTR_SETTINGS_SPELLCHECK,
- dlg->priv->spellcheck_checkbutton,
+ priv->spellcheck_checkbutton,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
}
@@ -234,8 +203,9 @@ on_profile_dialog_response_cb (GtrProfileDialog *profile_dialog,
GtrProfile *profile;
GtrProfile *active_profile;
GtkTreeIter iter;
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ 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 ();
@@ -261,7 +231,7 @@ on_profile_dialog_response_cb (GtrProfileDialog *profile_dialog,
{
GtkTreeSelection *selection;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
@@ -308,11 +278,12 @@ edit_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
GtkTreeModel *model;
GtkTreeSelection *selection;
GtrProfile *profile;
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ 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 (dlg->priv->profile_treeview));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
@@ -334,16 +305,17 @@ static void
delete_confirm_dialog_cb (GtkWidget *dialog,
gint response_id, 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 (dlg->priv->profile_treeview));
+ 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 (dlg->priv->profile_treeview));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
@@ -376,11 +348,12 @@ delete_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
gboolean active;
GtkWidget *dialog;
gchar *markup;
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ 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 (dlg->priv->profile_treeview));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->profile_treeview));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
@@ -418,10 +391,10 @@ delete_button_clicked (GtkWidget *button, GtrPreferencesDialog *dlg)
g_free(markup);
gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ _("_Cancel"), GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_DELETE, GTK_RESPONSE_YES);
+ _("_Delete"), GTK_RESPONSE_YES);
gtk_dialog_run (GTK_DIALOG (dialog));
@@ -439,10 +412,11 @@ active_toggled_cb (GtkCellRendererToggle *cell_renderer,
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 (dlg->priv->profile_treeview));
+ 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);
@@ -521,13 +495,14 @@ setup_profile_pages (GtrPreferencesDialog *dlg)
GtkTreeViewColumn *name_column, *toggle_column;
GtkCellRenderer *text_renderer, *toggle_renderer;
GtkListStore *model;
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (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 (dlg->priv->profile_treeview),
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->profile_treeview),
GTK_TREE_MODEL (model));
g_object_unref (model);
@@ -557,9 +532,9 @@ setup_profile_pages (GtrPreferencesDialog *dlg)
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 (dlg->priv->profile_treeview),
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->profile_treeview),
name_column);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview),
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->profile_treeview),
toggle_column);
gtk_tree_view_column_set_expand (name_column, TRUE);
@@ -567,13 +542,13 @@ setup_profile_pages (GtrPreferencesDialog *dlg)
fill_profile_treeview (dlg, GTK_TREE_MODEL (model));
/* Connect the signals */
- g_signal_connect (dlg->priv->add_button,
+ g_signal_connect (priv->add_button,
"clicked", G_CALLBACK (add_button_clicked), dlg);
- g_signal_connect (dlg->priv->delete_button,
+ g_signal_connect (priv->delete_button,
"clicked", G_CALLBACK (delete_button_clicked), dlg);
- g_signal_connect (dlg->priv->edit_button,
+ g_signal_connect (priv->edit_button,
"clicked", G_CALLBACK (edit_button_clicked), dlg);
}
@@ -590,8 +565,6 @@ dialog_response_handler (GtkDialog * dlg, gint res_id)
static void
gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
{
- GtrPreferencesDialogPrivate *priv;
- GtkWidget *action_area;
GtkWidget *profiles_toolbar;
GtkWidget *profiles_scrolled_window;
GtkBuilder *builder;
@@ -605,31 +578,25 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
"model1",
NULL
};
-
- dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
- priv = dlg->priv;
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
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),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
+ _("_Close"), GTK_RESPONSE_CLOSE,
+ _("Help"), GTK_RESPONSE_HELP, NULL);
gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Preferences"));
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (content_area, 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 4);
g_signal_connect (dlg,
"response", G_CALLBACK (dialog_response_handler), NULL);
@@ -646,9 +613,6 @@ gtr_preferences_dialog_init (GtrPreferencesDialog * dlg)
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->use_custom_font_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"use_custom_font_checkbutton"));
- priv->editor_font_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_fontbutton"));
- priv->editor_font_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_hbox"));
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"));
@@ -678,10 +642,11 @@ static void
gtr_preferences_dialog_dispose (GObject * object)
{
GtrPreferencesDialog *dlg = GTR_PREFERENCES_DIALOG (object);
+ GtrPreferencesDialogPrivate *priv = gtr_preferences_dialog_get_instance_private (dlg);
- g_clear_object (&dlg->priv->ui_settings);
- g_clear_object (&dlg->priv->editor_settings);
- g_clear_object (&dlg->priv->files_settings);
+ g_clear_object (&priv->ui_settings);
+ g_clear_object (&priv->editor_settings);
+ g_clear_object (&priv->files_settings);
G_OBJECT_CLASS (gtr_preferences_dialog_parent_class)->dispose (object);
}
@@ -691,8 +656,6 @@ gtr_preferences_dialog_class_init (GtrPreferencesDialogClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrPreferencesDialogPrivate));
-
object_class->dispose = gtr_preferences_dialog_dispose;
}
@@ -705,16 +668,16 @@ gtr_show_preferences_dialog (GtrWindow * window)
if (dlg == NULL)
{
- dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG, NULL));
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG,
+ "use-header-bar", TRUE, NULL));
g_signal_connect (dlg,
"destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
gtk_widget_show_all (dlg);
}
- if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
- }
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
+ gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
gtk_window_present (GTK_WINDOW (dlg));
}
diff --git a/src/gtr-preferences-dialog.h b/src/gtr-preferences-dialog.h
index edbcceca..1440e2de 100644
--- a/src/gtr-preferences-dialog.h
+++ b/src/gtr-preferences-dialog.h
@@ -35,18 +35,12 @@ G_BEGIN_DECLS
#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))
-/* Private structure type */
-typedef struct _GtrPreferencesDialogPrivate GtrPreferencesDialogPrivate;
-
/* Main object structure */
typedef struct _GtrPreferencesDialog GtrPreferencesDialog;
struct _GtrPreferencesDialog
{
GtkDialog parent_instance;
-
- /*< private > */
- GtrPreferencesDialogPrivate *priv;
};
/* Class definition */
diff --git a/src/gtr-preferences-dialog.ui b/src/gtr-preferences-dialog.ui
index 22584068..10ffaeeb 100644
--- a/src/gtr-preferences-dialog.ui
+++ b/src/gtr-preferences-dialog.ui
@@ -362,64 +362,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkCheckButton" id="use_custom_font_checkbutton">
- <property name="label" translatable="yes">Use _custom font</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="editor_font_hbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="editor_font_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Editor _font:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">editor_font_fontbutton</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFontButton" id="editor_font_fontbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="font">Sans 12</property>
- <property name="preview_text"/>
- <property name="show_preview_entry">False</property>
- <property name="use_font">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
</object>
</child>
</object>
@@ -683,3 +625,4 @@
</action-widgets>
</object>
</interface>
+
diff --git a/src/gtr-profile-dialog.c b/src/gtr-profile-dialog.c
index 38c07289..b77d9324 100644
--- a/src/gtr-profile-dialog.c
+++ b/src/gtr-profile-dialog.c
@@ -35,14 +35,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#define GTR_PROFILE_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_PROFILE_DIALOG, \
- GtrProfileDialogPrivate))
-
-G_DEFINE_TYPE (GtrProfileDialog, gtr_profile_dialog, GTK_TYPE_DIALOG)
-
-struct _GtrProfileDialogPrivate
+typedef struct
{
GtkWidget *main_box;
@@ -52,19 +45,19 @@ struct _GtrProfileDialogPrivate
GtkWidget *author_email;
GtkWidget *languages_fetcher;
-};
+} GtrProfileDialogPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrProfileDialog, gtr_profile_dialog, GTK_TYPE_DIALOG)
static void
gtr_profile_dialog_class_init (GtrProfileDialogClass *klass)
{
- g_type_class_add_private (klass, sizeof (GtrProfileDialogPrivate));
}
static void
gtr_profile_dialog_init (GtrProfileDialog *dlg)
{
- GtrProfileDialogPrivate *priv;
- GtkWidget *action_area;
+ GtrProfileDialogPrivate *priv = gtr_profile_dialog_get_instance_private (dlg);
GtkBox *content_area;
GtkWidget *fetcher_box;
GtkBuilder *builder;
@@ -73,25 +66,19 @@ gtr_profile_dialog_init (GtrProfileDialog *dlg)
NULL
};
- dlg->priv = GTR_PROFILE_DIALOG_GET_PRIVATE (dlg);
- priv = dlg->priv;
-
gtk_dialog_add_button (GTK_DIALOG (dlg),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ _("_Cancel"), GTK_RESPONSE_CANCEL);
gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Profile"));
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (content_area, 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 4);
builder = gtk_builder_new ();
GError *error = NULL;
@@ -111,7 +98,7 @@ gtr_profile_dialog_init (GtrProfileDialog *dlg)
gtk_box_pack_start (content_area, priv->main_box, FALSE, FALSE, 0);
- dlg->priv->languages_fetcher = gtr_languages_fetcher_new ();
+ priv->languages_fetcher = gtr_languages_fetcher_new ();
gtk_widget_show (priv->languages_fetcher);
gtk_box_pack_start (GTK_BOX (fetcher_box), priv->languages_fetcher,
TRUE, TRUE, 0);
@@ -120,40 +107,41 @@ gtr_profile_dialog_init (GtrProfileDialog *dlg)
static void
fill_entries (GtrProfileDialog *dlg, GtrProfile *profile)
{
+ GtrProfileDialogPrivate *priv = gtr_profile_dialog_get_instance_private (dlg);
if (gtr_profile_get_name (profile) != NULL)
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->profile_name),
+ gtk_entry_set_text (GTK_ENTRY (priv->profile_name),
gtr_profile_get_name (profile));
if (gtr_profile_get_author_name (profile) != NULL)
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->author_name),
+ gtk_entry_set_text (GTK_ENTRY (priv->author_name),
gtr_profile_get_author_name (profile));
if (gtr_profile_get_author_email (profile) != NULL)
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->author_email),
+ gtk_entry_set_text (GTK_ENTRY (priv->author_email),
gtr_profile_get_author_email (profile));
if (gtr_profile_get_language_name (profile) != NULL)
- gtr_languages_fetcher_set_language_name (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_languages_fetcher_set_language_name (GTR_LANGUAGES_FETCHER (priv->languages_fetcher),
gtr_profile_get_language_name (profile));
if (gtr_profile_get_language_code (profile) != NULL)
- gtr_languages_fetcher_set_language_code (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_languages_fetcher_set_language_code (GTR_LANGUAGES_FETCHER (priv->languages_fetcher),
gtr_profile_get_language_code (profile));
if (gtr_profile_get_charset (profile) != NULL)
- gtr_languages_fetcher_set_charset (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_languages_fetcher_set_charset (GTR_LANGUAGES_FETCHER (priv->languages_fetcher),
gtr_profile_get_charset (profile));
if (gtr_profile_get_encoding (profile) != NULL)
- gtr_languages_fetcher_set_encoding (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_languages_fetcher_set_encoding (GTR_LANGUAGES_FETCHER (priv->languages_fetcher),
gtr_profile_get_encoding (profile));
if (gtr_profile_get_group_email (profile) != NULL)
- gtr_languages_fetcher_set_team_email (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_languages_fetcher_set_team_email (GTR_LANGUAGES_FETCHER (priv->languages_fetcher),
gtr_profile_get_group_email (profile));
if (gtr_profile_get_plural_forms (profile) != NULL)
- gtr_languages_fetcher_set_plural_form (GTR_LANGUAGES_FETCHER (dlg->priv->languages_fetcher),
+ gtr_languages_fetcher_set_plural_form (GTR_LANGUAGES_FETCHER (priv->languages_fetcher),
gtr_profile_get_plural_forms (profile));
}
@@ -172,12 +160,12 @@ gtr_profile_dialog_new (GtkWidget *parent,
/* We distinguish in the preferences dialog if we are modifying
or adding a new profile depending on the response */
gtk_dialog_add_button (GTK_DIALOG (dlg),
- GTK_STOCK_OK, GTK_RESPONSE_YES);
+ _("_OK"), GTK_RESPONSE_YES);
}
else
{
gtk_dialog_add_button (GTK_DIALOG (dlg),
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+ _("_OK"), GTK_RESPONSE_ACCEPT);
}
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
@@ -192,37 +180,38 @@ GtrProfile *
gtr_profile_dialog_get_profile (GtrProfileDialog *dlg)
{
GtrProfile *profile;
+ GtrProfileDialogPrivate *priv = gtr_profile_dialog_get_instance_private (dlg);
g_return_val_if_fail (GTR_IS_PROFILE_DIALOG (dlg), NULL);
profile = gtr_profile_new ();
gtr_profile_set_name (profile,
- gtk_entry_get_text (GTK_ENTRY (dlg->priv->profile_name)));
+ gtk_entry_get_text (GTK_ENTRY (priv->profile_name)));
gtr_profile_set_author_name (profile,
- gtk_entry_get_text (GTK_ENTRY (dlg->priv->author_name)));
+ gtk_entry_get_text (GTK_ENTRY (priv->author_name)));
gtr_profile_set_author_email (profile,
- gtk_entry_get_text (GTK_ENTRY (dlg->priv->author_email)));
+ gtk_entry_get_text (GTK_ENTRY (priv->author_email)));
gtr_profile_set_language_name (profile,
- gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER
(dlg->priv->languages_fetcher)));
+ gtr_languages_fetcher_get_language_name (GTR_LANGUAGES_FETCHER
(priv->languages_fetcher)));
gtr_profile_set_language_code (profile,
- gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER
(dlg->priv->languages_fetcher)));
+ gtr_languages_fetcher_get_language_code (GTR_LANGUAGES_FETCHER
(priv->languages_fetcher)));
gtr_profile_set_charset (profile,
- gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER
(dlg->priv->languages_fetcher)));
+ gtr_languages_fetcher_get_charset (GTR_LANGUAGES_FETCHER
(priv->languages_fetcher)));
gtr_profile_set_encoding (profile,
- gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER
(dlg->priv->languages_fetcher)));
+ gtr_languages_fetcher_get_encoding (GTR_LANGUAGES_FETCHER
(priv->languages_fetcher)));
gtr_profile_set_group_email (profile,
- gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER
(dlg->priv->languages_fetcher)));
+ gtr_languages_fetcher_get_team_email (GTR_LANGUAGES_FETCHER
(priv->languages_fetcher)));
gtr_profile_set_plural_forms (profile,
- gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER
(dlg->priv->languages_fetcher)));
+ gtr_languages_fetcher_get_plural_form (GTR_LANGUAGES_FETCHER
(priv->languages_fetcher)));
return profile;
}
diff --git a/src/gtr-profile-dialog.h b/src/gtr-profile-dialog.h
index 0b25ce69..2ba135ea 100644
--- a/src/gtr-profile-dialog.h
+++ b/src/gtr-profile-dialog.h
@@ -40,9 +40,6 @@ G_BEGIN_DECLS
#define GTR_IS_PROFILE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PROFILE_DIALOG))
#define GTR_PROFILE_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PROFILE_DIALOG,
GtrProfileDialogClass))
-/* Private structure type */
-typedef struct _GtrProfileDialogPrivate GtrProfileDialogPrivate;
-
/*
* Main object structure
*/
@@ -51,9 +48,6 @@ typedef struct _GtrProfileDialog GtrProfileDialog;
struct _GtrProfileDialog
{
GtkDialog parent_instance;
-
- /*< private > */
- GtrProfileDialogPrivate *priv;
};
/*
diff --git a/src/gtr-profile-manager.c b/src/gtr-profile-manager.c
index 103ff8af..79c11fe4 100644
--- a/src/gtr-profile-manager.c
+++ b/src/gtr-profile-manager.c
@@ -26,15 +26,11 @@
#include <libxml/xmlreader.h>
#include <libxml/tree.h>
-#define GTR_PROFILE_MANAGER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
- GTR_TYPE_PROFILE_MANAGER, \
- GtrProfileManagerPrivate))
-
-struct _GtrProfileManagerPrivate
+typedef struct
{
GSList *profiles;
GtrProfile *active_profile;
-};
+} GtrProfileManagerPrivate;
enum
{
@@ -45,7 +41,7 @@ enum
LAST_SIGNAL
};
-G_DEFINE_TYPE (GtrProfileManager, gtr_profile_manager, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GtrProfileManager, gtr_profile_manager, G_TYPE_OBJECT)
static guint signals[LAST_SIGNAL];
@@ -65,8 +61,9 @@ static void
gtr_profile_manager_finalize (GObject *object)
{
GtrProfileManager *manager = GTR_PROFILE_MANAGER (object);
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
- g_slist_free_full (manager->priv->profiles, g_object_unref);
+ g_slist_free_full (priv->profiles, g_object_unref);
G_OBJECT_CLASS (gtr_profile_manager_parent_class)->finalize (object);
}
@@ -78,8 +75,6 @@ gtr_profile_manager_class_init (GtrProfileManagerClass *klass)
object_class->finalize = gtr_profile_manager_finalize;
- g_type_class_add_private (object_class, sizeof (GtrProfileManagerPrivate));
-
/* Signals */
signals[ACTIVE_PROFILE_CHANGED] =
g_signal_new ("active-profile-changed",
@@ -122,6 +117,7 @@ parse_profile (GtrProfileManager *manager,
xmlNodePtr cur)
{
GtrProfile *profile;
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
if (xmlStrcmp (cur->name, (const xmlChar *)"profile") != 0)
return;
@@ -129,7 +125,7 @@ parse_profile (GtrProfileManager *manager,
profile = gtr_profile_new ();
if (xmlHasProp (cur, (const xmlChar *)"active"))
- manager->priv->active_profile = profile;
+ priv->active_profile = profile;
cur = cur->xmlChildrenNode;
@@ -189,7 +185,7 @@ parse_profile (GtrProfileManager *manager,
cur = cur->next;
}
- manager->priv->profiles = g_slist_append (manager->priv->profiles,
+ priv->profiles = g_slist_append (priv->profiles,
profile);
}
@@ -256,10 +252,11 @@ save_profile (GtrProfileManager *manager,
xmlNodePtr parent)
{
xmlNodePtr profile_node;
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
profile_node = xmlNewChild (parent, NULL, (const xmlChar *)"profile", NULL);
- if (manager->priv->active_profile == profile)
+ if (priv->active_profile == profile)
xmlSetProp (profile_node, (const xmlChar *)"active", (const xmlChar *)"TRUE");
xmlNewTextChild (profile_node, NULL, (const xmlChar *)"profile_name",
@@ -289,6 +286,7 @@ save_profiles (GtrProfileManager *manager)
xmlNodePtr root;
gchar *file_name;
GSList *l;
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
g_return_if_fail (GTR_IS_PROFILE_MANAGER (manager));
@@ -302,7 +300,7 @@ save_profiles (GtrProfileManager *manager)
root = xmlNewDocNode (doc, NULL, (const xmlChar *)"profiles", NULL);
xmlDocSetRootElement (doc, root);
- for (l = manager->priv->profiles; l != NULL; l = g_slist_next (l))
+ for (l = priv->profiles; l != NULL; l = g_slist_next (l))
save_profile (manager, GTR_PROFILE (l->data), root);
file_name = get_profile_filename ();
@@ -326,10 +324,10 @@ save_profiles (GtrProfileManager *manager)
static void
gtr_profile_manager_init (GtrProfileManager *manager)
{
- manager->priv = GTR_PROFILE_MANAGER_GET_PRIVATE (manager);
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
- manager->priv->profiles = NULL;
- manager->priv->active_profile = NULL;
+ priv->profiles = NULL;
+ priv->active_profile = NULL;
load_profiles (manager);
}
@@ -351,27 +349,30 @@ gtr_profile_manager_get_default ()
GSList *
gtr_profile_manager_get_profiles (GtrProfileManager *manager)
{
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
g_return_val_if_fail (GTR_IS_PROFILE_MANAGER (manager), NULL);
- return manager->priv->profiles;
+ return priv->profiles;
}
GtrProfile *
gtr_profile_manager_get_active_profile (GtrProfileManager *manager)
{
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
g_return_val_if_fail (GTR_IS_PROFILE_MANAGER (manager), NULL);
- return manager->priv->active_profile;
+ return priv->active_profile;
}
void
gtr_profile_manager_set_active_profile (GtrProfileManager *manager,
GtrProfile *profile)
{
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
g_return_if_fail (GTR_IS_PROFILE_MANAGER (manager));
g_return_if_fail (GTR_IS_PROFILE (profile));
- manager->priv->active_profile = profile;
+ priv->active_profile = profile;
g_signal_emit (G_OBJECT (manager), signals[ACTIVE_PROFILE_CHANGED], 0, profile);
@@ -382,13 +383,14 @@ void
gtr_profile_manager_add_profile (GtrProfileManager *manager,
GtrProfile *profile)
{
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
g_return_if_fail (GTR_IS_PROFILE_MANAGER (manager));
g_return_if_fail (profile != NULL);
- if (manager->priv->profiles == NULL)
- manager->priv->active_profile = profile;
+ if (priv->profiles == NULL)
+ priv->active_profile = profile;
- manager->priv->profiles = g_slist_append (manager->priv->profiles,
+ priv->profiles = g_slist_append (priv->profiles,
profile);
g_signal_emit (G_OBJECT (manager), signals[PROFILE_ADDED], 0, profile);
@@ -400,10 +402,11 @@ void
gtr_profile_manager_remove_profile (GtrProfileManager *manager,
GtrProfile *profile)
{
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
g_return_if_fail (GTR_IS_PROFILE_MANAGER (manager));
g_return_if_fail (profile != NULL);
- manager->priv->profiles = g_slist_remove (manager->priv->profiles,
+ priv->profiles = g_slist_remove (priv->profiles,
profile);
g_signal_emit (G_OBJECT (manager), signals[PROFILE_REMOVED], 0, profile);
@@ -417,19 +420,20 @@ gtr_profile_manager_modify_profile (GtrProfileManager *manager,
GtrProfile *old_profile,
GtrProfile *new_profile)
{
+ GtrProfileManagerPrivate *priv = gtr_profile_manager_get_instance_private (manager);
GSList *p;
g_return_if_fail (GTR_IS_PROFILE_MANAGER (manager));
g_return_if_fail (old_profile != NULL);
g_return_if_fail (new_profile != NULL);
- p = g_slist_find (manager->priv->profiles,
+ p = g_slist_find (priv->profiles,
old_profile);
p->data = new_profile;
- if (manager->priv->active_profile == old_profile)
- manager->priv->active_profile = new_profile;
+ if (priv->active_profile == old_profile)
+ priv->active_profile = new_profile;
g_signal_emit (G_OBJECT (manager), signals[PROFILE_MODIFIED], 0,
old_profile, new_profile);
diff --git a/src/gtr-profile-manager.h b/src/gtr-profile-manager.h
index 72d5cae2..c269e4b2 100644
--- a/src/gtr-profile-manager.h
+++ b/src/gtr-profile-manager.h
@@ -37,13 +37,10 @@ G_BEGIN_DECLS
typedef struct _GtrProfileManager GtrProfileManager;
typedef struct _GtrProfileManagerClass GtrProfileManagerClass;
-typedef struct _GtrProfileManagerPrivate GtrProfileManagerPrivate;
struct _GtrProfileManager
{
GObject parent;
-
- GtrProfileManagerPrivate *priv;
};
struct _GtrProfileManagerClass
diff --git a/src/gtr-profile.c b/src/gtr-profile.c
index 4fbdd836..6e13fc59 100644
--- a/src/gtr-profile.c
+++ b/src/gtr-profile.c
@@ -27,14 +27,7 @@
#include <glib.h>
-#define GTR_PROFILE_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_PROFILE, \
- GtrProfilePrivate))
-
-G_DEFINE_TYPE (GtrProfile, gtr_profile, G_TYPE_OBJECT)
-
-struct _GtrProfilePrivate
+typedef struct
{
/* Identify the profile */
gchar *name;
@@ -60,28 +53,30 @@ struct _GtrProfilePrivate
/* Plural forms */
gchar *plural_forms;
-};
+} GtrProfilePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrProfile, gtr_profile, G_TYPE_OBJECT)
static void
gtr_profile_init (GtrProfile *profile)
{
- profile->priv = GTR_PROFILE_GET_PRIVATE (profile);
}
static void
gtr_profile_finalize (GObject *object)
{
GtrProfile *profile = GTR_PROFILE (object);
-
- g_free (profile->priv->name);
- g_free (profile->priv->author_name);
- g_free (profile->priv->author_email);
- g_free (profile->priv->language_name);
- g_free (profile->priv->language_code);
- g_free (profile->priv->charset);
- g_free (profile->priv->encoding);
- g_free (profile->priv->group_email);
- g_free (profile->priv->plural_forms);
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
+
+ g_free (priv->name);
+ g_free (priv->author_name);
+ g_free (priv->author_email);
+ g_free (priv->language_name);
+ g_free (priv->language_code);
+ g_free (priv->charset);
+ g_free (priv->encoding);
+ g_free (priv->group_email);
+ g_free (priv->plural_forms);
G_OBJECT_CLASS (gtr_profile_parent_class)->finalize (object);
}
@@ -91,8 +86,6 @@ gtr_profile_class_init (GtrProfileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrProfilePrivate));
-
object_class->finalize = gtr_profile_finalize;
}
@@ -109,170 +102,188 @@ gtr_profile_new (void)
const gchar *
gtr_profile_get_name (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->name;
+ return priv->name;
}
void
gtr_profile_set_name (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->name);
- profile->priv->name = g_strdup (data);
+ g_free (priv->name);
+ priv->name = g_strdup (data);
}
const gchar *
gtr_profile_get_author_name (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->author_name;
+ return priv->author_name;
}
void
gtr_profile_set_author_name (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->author_name);
- profile->priv->author_name = g_strdup (data);
+ g_free (priv->author_name);
+ priv->author_name = g_strdup (data);
}
const gchar *
gtr_profile_get_author_email (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->author_email;
+ return priv->author_email;
}
void
gtr_profile_set_author_email (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->author_email);
- profile->priv->author_email = g_strdup (data);
+ g_free (priv->author_email);
+ priv->author_email = g_strdup (data);
}
const gchar *
gtr_profile_get_language_name (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->language_name;
+ return priv->language_name;
}
void
gtr_profile_set_language_name (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->language_name);
- profile->priv->language_name = g_strdup (data);
+ g_free (priv->language_name);
+ priv->language_name = g_strdup (data);
}
const gchar *
gtr_profile_get_language_code (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->language_code;
+ return priv->language_code;
}
void
gtr_profile_set_language_code (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->language_code);
- profile->priv->language_code = g_strdup (data);
+ g_free (priv->language_code);
+ priv->language_code = g_strdup (data);
}
const gchar *
gtr_profile_get_charset (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->charset;
+ return priv->charset;
}
void
gtr_profile_set_charset (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->charset);
- profile->priv->charset = g_strdup (data);
+ g_free (priv->charset);
+ priv->charset = g_strdup (data);
}
const gchar *
gtr_profile_get_encoding (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->encoding;
+ return priv->encoding;
}
void
gtr_profile_set_encoding (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->encoding);
- profile->priv->encoding = g_strdup (data);
+ g_free (priv->encoding);
+ priv->encoding = g_strdup (data);
}
const gchar *
gtr_profile_get_group_email (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->group_email;
+ return priv->group_email;
}
void
gtr_profile_set_group_email (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->group_email);
- profile->priv->group_email = g_strdup (data);
+ g_free (priv->group_email);
+ priv->group_email = g_strdup (data);
}
const gchar *
gtr_profile_get_plural_forms (GtrProfile *profile)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_val_if_fail (GTR_IS_PROFILE (profile), NULL);
- return profile->priv->plural_forms;
+ return priv->plural_forms;
}
void
gtr_profile_set_plural_forms (GtrProfile *profile,
const gchar *data)
{
+ GtrProfilePrivate *priv = gtr_profile_get_instance_private (profile);
g_return_if_fail (GTR_IS_PROFILE (profile));
g_return_if_fail (data != NULL);
- g_free (profile->priv->plural_forms);
- profile->priv->plural_forms = g_strdup (data);
+ g_free (priv->plural_forms);
+ priv->plural_forms = g_strdup (data);
}
diff --git a/src/gtr-profile.h b/src/gtr-profile.h
index ee2cad56..e7da567a 100644
--- a/src/gtr-profile.h
+++ b/src/gtr-profile.h
@@ -36,9 +36,6 @@
#define GTR_IS_PROFILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PROFILE))
#define GTR_PROFILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PROFILE, GtrProfileClass))
-/* Private structure type */
-typedef struct _GtrProfilePrivate GtrProfilePrivate;
-
/*
* Main object structure
*/
@@ -47,8 +44,6 @@ typedef struct _GtrProfile GtrProfile;
struct _GtrProfile
{
GObject parent_instance;
- /*< private > */
- GtrProfilePrivate *priv;
};
/*
diff --git a/src/gtr-progress.c b/src/gtr-progress.c
index 710daf9e..7510d98d 100644
--- a/src/gtr-progress.c
+++ b/src/gtr-progress.c
@@ -246,7 +246,7 @@ gtr_progress_set (GtrProgress *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FUZZY]);
}
- gtk_widget_queue_draw (self);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
}
gint
diff --git a/src/gtr-search-dialog.c b/src/gtr-search-dialog.c
index 55175e4e..5cb97920 100644
--- a/src/gtr-search-dialog.c
+++ b/src/gtr-search-dialog.c
@@ -42,10 +42,6 @@
#include "gtr-utils.h"
#include "gtr-marshal.h"
-#define GTR_SEARCH_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- GTR_TYPE_SEARCH_DIALOG, \
- GtrSearchDialogPrivate))
-
/* Signals */
enum
{
@@ -55,7 +51,7 @@ enum
static guint dialog_signals[LAST_SIGNAL] = { 0 };
-struct _GtrSearchDialogPrivate
+typedef struct
{
gboolean show_replace;
@@ -78,20 +74,21 @@ struct _GtrSearchDialogPrivate
GtkWidget *replace_all_button;
gboolean glade_error;
-};
+} GtrSearchDialogPrivate;
-G_DEFINE_TYPE (GtrSearchDialog, gtr_search_dialog, GTK_TYPE_DIALOG)
- enum
- {
- PROP_0,
- PROP_SHOW_REPLACE
- };
+G_DEFINE_TYPE_WITH_PRIVATE (GtrSearchDialog, gtr_search_dialog, GTK_TYPE_DIALOG)
- static void
- gtr_search_dialog_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec)
+enum
+{
+ PROP_0,
+ PROP_SHOW_REPLACE
+};
+
+static void
+gtr_search_dialog_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec)
{
GtrSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
@@ -112,11 +109,12 @@ gtr_search_dialog_get_property (GObject * object,
GValue * value, GParamSpec * pspec)
{
GtrSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dlg);
switch (prop_id)
{
case PROP_SHOW_REPLACE:
- g_value_set_boolean (value, dlg->priv->show_replace);
+ g_value_set_boolean (value, priv->show_replace);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -158,8 +156,6 @@ gtr_search_dialog_class_init (GtrSearchDialogClass * klass)
FALSE,
G_PARAM_READWRITE));
- g_type_class_add_private (object_class, sizeof (GtrSearchDialogPrivate));
-
binding_set = gtk_binding_set_by_class (klass);
/* Note: we cannot use the keyval/modifier associated with the
@@ -248,19 +244,21 @@ translated_checkbutton_toggled (GtkToggleButton * button,
{
gboolean original_text;
gboolean translated_text;
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
+
original_text =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->original_text_checkbutton));
+ (priv->original_text_checkbutton));
translated_text =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->
+ (
priv->translated_text_checkbutton));
if (!original_text && !translated_text)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->original_text_checkbutton),
+ (priv->original_text_checkbutton),
TRUE);
}
}
@@ -271,19 +269,20 @@ original_checkbutton_toggled (GtkToggleButton * button,
{
gboolean original_text;
gboolean translated_text;
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
original_text =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->original_text_checkbutton));
+ (priv->original_text_checkbutton));
translated_text =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->
+ (
priv->translated_text_checkbutton));
if (!original_text && !translated_text)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->translated_text_checkbutton),
+ (priv->translated_text_checkbutton),
TRUE);
}
}
@@ -292,32 +291,33 @@ static void
response_handler (GtrSearchDialog * dialog, gint response_id, gpointer data)
{
const gchar *str;
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
switch (response_id)
{
case GTR_SEARCH_DIALOG_REPLACE_RESPONSE:
case GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
- str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
+ str = gtk_entry_get_text (GTK_ENTRY (priv->replace_text_entry));
if (*str != '\0')
{
gchar *text;
text = gtr_utils_unescape_search_text (str);
gtr_history_entry_prepend_text
- (GTR_HISTORY_ENTRY (dialog->priv->replace_entry), text);
+ (GTR_HISTORY_ENTRY (priv->replace_entry), text);
g_free (text);
}
/* fall through, so that we also save the find entry */
case GTR_SEARCH_DIALOG_FIND_RESPONSE:
- str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
+ str = gtk_entry_get_text (GTK_ENTRY (priv->search_text_entry));
if (*str != '\0')
{
gchar *text;
text = gtr_utils_unescape_search_text (str);
gtr_history_entry_prepend_text
- (GTR_HISTORY_ENTRY (dialog->priv->search_entry), text);
+ (GTR_HISTORY_ENTRY (priv->search_entry), text);
g_free (text);
}
@@ -327,149 +327,145 @@ response_handler (GtrSearchDialog * dialog, gint response_id, gpointer data)
static void
show_replace_widgets (GtrSearchDialog * dlg, gboolean show_replace)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dlg);
if (show_replace)
{
- gtk_widget_hide (dlg->priv->original_text_checkbutton);
- gtk_widget_hide (dlg->priv->translated_text_checkbutton);
+ gtk_widget_hide (priv->original_text_checkbutton);
+ gtk_widget_hide (priv->translated_text_checkbutton);
/*
* Set the default value of checkbutton
*/
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->translated_text_checkbutton),
+ (priv->translated_text_checkbutton),
TRUE);
- gtk_widget_show (dlg->priv->replace_label);
- gtk_widget_show (dlg->priv->replace_entry);
- gtk_widget_show (dlg->priv->replace_all_button);
- gtk_widget_show (dlg->priv->replace_button);
+ gtk_widget_show (priv->replace_label);
+ gtk_widget_show (priv->replace_entry);
+ gtk_widget_show (priv->replace_all_button);
+ gtk_widget_show (priv->replace_button);
gtk_window_set_title (GTK_WINDOW (dlg), _("Replace"));
}
else
{
- gtk_widget_show (dlg->priv->original_text_checkbutton);
- gtk_widget_show (dlg->priv->translated_text_checkbutton);
+ gtk_widget_show (priv->original_text_checkbutton);
+ gtk_widget_show (priv->translated_text_checkbutton);
/*
* Set the default value of checkbuttons
*/
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->original_text_checkbutton),
+ (priv->original_text_checkbutton),
TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dlg->priv->translated_text_checkbutton),
+ (priv->translated_text_checkbutton),
TRUE);
- gtk_widget_hide (dlg->priv->replace_label);
- gtk_widget_hide (dlg->priv->replace_entry);
- gtk_widget_hide (dlg->priv->replace_all_button);
- gtk_widget_hide (dlg->priv->replace_button);
+ gtk_widget_hide (priv->replace_label);
+ gtk_widget_hide (priv->replace_entry);
+ gtk_widget_hide (priv->replace_all_button);
+ gtk_widget_hide (priv->replace_button);
gtk_window_set_title (GTK_WINDOW (dlg), _("Find"));
}
- gtk_widget_show (dlg->priv->find_button);
+ gtk_widget_show (priv->find_button);
}
static void
gtr_search_dialog_init (GtrSearchDialog * dlg)
{
GtkWidget *content;
- GtkWidget *action_area;
GtkBuilder *builder;
GtkBox *content_area;
gchar *root_objects[] = {
"search_dialog_content",
NULL
};
-
- dlg->priv = GTR_SEARCH_DIALOG_GET_PRIVATE (dlg);
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dlg);
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL);
+ _("_Close"), GTK_RESPONSE_CANCEL, NULL);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)));
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (content_area, 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
builder = gtk_builder_new ();
gtk_builder_add_objects_from_resource (builder, "/org/gnome/translator/gtr-search-dialog.ui",
root_objects, NULL);
content = GTK_WIDGET (gtk_builder_get_object (builder, "search_dialog_content"));
g_object_ref (content);
- dlg->priv->grid = GTK_WIDGET (gtk_builder_get_object (builder, "grid"));
- dlg->priv->search_label = GTK_WIDGET (gtk_builder_get_object (builder, "search_label"));
- dlg->priv->replace_label = GTK_WIDGET (gtk_builder_get_object (builder, "replace_with_label"));
- dlg->priv->original_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"original_text_checkbutton"));
- dlg->priv->translated_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"translated_text_checkbutton"));
- dlg->priv->fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fuzzy_checkbutton"));
- dlg->priv->match_case_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"match_case_checkbutton"));
- dlg->priv->entire_word_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"entire_word_checkbutton"));
- dlg->priv->backwards_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"search_backwards_checkbutton"));
- dlg->priv->wrap_around_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"wrap_around_checkbutton"));
+ priv->grid = GTK_WIDGET (gtk_builder_get_object (builder, "grid"));
+ priv->search_label = GTK_WIDGET (gtk_builder_get_object (builder, "search_label"));
+ priv->replace_label = GTK_WIDGET (gtk_builder_get_object (builder, "replace_with_label"));
+ priv->original_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"original_text_checkbutton"));
+ priv->translated_text_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"translated_text_checkbutton"));
+ priv->fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fuzzy_checkbutton"));
+ priv->match_case_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "match_case_checkbutton"));
+ priv->entire_word_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "entire_word_checkbutton"));
+ priv->backwards_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"search_backwards_checkbutton"));
+ priv->wrap_around_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "wrap_around_checkbutton"));
g_object_unref (builder);
- dlg->priv->search_entry = gtr_history_entry_new ("search-for-entry", TRUE);
- gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
- gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY (dlg->priv->search_entry),
+ priv->search_entry = gtr_history_entry_new ("search-for-entry", TRUE);
+ gtk_widget_set_size_request (priv->search_entry, 300, -1);
+ gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY (priv->search_entry),
(GtrHistoryEntryEscapeFunc) gtr_utils_escape_search_text);
- gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->search_entry), TRUE);
-
- dlg->priv->search_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (dlg->priv->search_entry));
- gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->search_text_entry), TRUE);
- gtk_widget_show (dlg->priv->search_entry);
- gtk_grid_attach_next_to (GTK_GRID (dlg->priv->grid),
- dlg->priv->search_entry,
- dlg->priv->search_label,
+ gtk_widget_set_hexpand (GTK_WIDGET (priv->search_entry), TRUE);
+
+ priv->search_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (priv->search_entry));
+ gtk_entry_set_activates_default (GTK_ENTRY (priv->search_text_entry), TRUE);
+ gtk_widget_show (priv->search_entry);
+ gtk_grid_attach_next_to (GTK_GRID (priv->grid),
+ priv->search_entry,
+ priv->search_label,
GTK_POS_RIGHT, 1, 1);
- dlg->priv->replace_entry = gtr_history_entry_new ("replace-with-entry", TRUE);
+ priv->replace_entry = gtr_history_entry_new ("replace-with-entry", TRUE);
gtr_history_entry_set_escape_func (GTR_HISTORY_ENTRY
- (dlg->priv->replace_entry),
+ (priv->replace_entry),
(GtrHistoryEntryEscapeFunc)
gtr_utils_escape_search_text);
- gtk_widget_set_hexpand (GTK_WIDGET (dlg->priv->replace_entry), TRUE);
-
- dlg->priv->replace_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (dlg->priv->replace_entry));
- gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->replace_text_entry), TRUE);
- gtk_widget_show (dlg->priv->replace_entry);
- gtk_grid_attach_next_to (GTK_GRID (dlg->priv->grid),
- dlg->priv->replace_entry,
- dlg->priv->replace_label,
+ gtk_widget_set_hexpand (GTK_WIDGET (priv->replace_entry), TRUE);
+
+ priv->replace_text_entry = gtr_history_entry_get_entry (GTR_HISTORY_ENTRY (priv->replace_entry));
+ gtk_entry_set_activates_default (GTK_ENTRY (priv->replace_text_entry), TRUE);
+ gtk_widget_show (priv->replace_entry);
+ gtk_grid_attach_next_to (GTK_GRID (priv->grid),
+ priv->replace_entry,
+ priv->replace_label,
GTK_POS_RIGHT, 1, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->search_label),
- dlg->priv->search_entry);
- gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->replace_label),
- dlg->priv->replace_entry);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (priv->search_label),
+ priv->search_entry);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (priv->replace_label),
+ priv->replace_entry);
- dlg->priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
- dlg->priv->replace_all_button =
+ priv->find_button = gtk_button_new_with_label (_("Find"));
+ priv->replace_all_button =
gtk_button_new_with_mnemonic (_("Replace _All"));
- dlg->priv->replace_button =
- gtk_button_new_from_stock (GTK_STOCK_FIND_AND_REPLACE);
- gtk_button_set_label (GTK_BUTTON (dlg->priv->replace_button),
+ priv->replace_button =
+ gtk_button_new_with_label (_("Find and replace"));
+ gtk_button_set_label (GTK_BUTTON (priv->replace_button),
_("_Replace"));
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- dlg->priv->replace_all_button,
+ priv->replace_all_button,
GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- dlg->priv->replace_button,
+ priv->replace_button,
GTR_SEARCH_DIALOG_REPLACE_RESPONSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- dlg->priv->find_button,
+ priv->find_button,
GTR_SEARCH_DIALOG_FIND_RESPONSE);
- g_object_set (G_OBJECT (dlg->priv->find_button), "can-default", TRUE, NULL);
+ g_object_set (G_OBJECT (priv->find_button), "can-default", TRUE, NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
GTR_SEARCH_DIALOG_FIND_RESPONSE);
@@ -487,19 +483,19 @@ gtr_search_dialog_init (GtrSearchDialog * dlg)
gtk_box_pack_start (content_area, content, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
- g_signal_connect (dlg->priv->search_text_entry,
+ g_signal_connect (priv->search_text_entry,
"insert_text", G_CALLBACK (insert_text_handler), NULL);
- g_signal_connect (dlg->priv->replace_text_entry,
+ g_signal_connect (priv->replace_text_entry,
"insert_text", G_CALLBACK (insert_text_handler), NULL);
- g_signal_connect (dlg->priv->search_entry,
+ g_signal_connect (priv->search_entry,
"changed", G_CALLBACK (search_entry_changed), dlg);
- g_signal_connect (dlg->priv->original_text_checkbutton,
+ g_signal_connect (priv->original_text_checkbutton,
"toggled",
G_CALLBACK (original_checkbutton_toggled),
dlg);
- g_signal_connect (dlg->priv->translated_text_checkbutton,
+ g_signal_connect (priv->translated_text_checkbutton,
"toggled",
G_CALLBACK (translated_checkbutton_toggled),
dlg);
@@ -525,32 +521,35 @@ void
gtr_search_dialog_present_with_time (GtrSearchDialog * dialog,
guint32 timestamp)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
- gtk_widget_grab_focus (dialog->priv->search_text_entry);
+ gtk_widget_grab_focus (priv->search_text_entry);
}
gboolean
gtr_search_dialog_get_show_replace (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
- return dialog->priv->show_replace;
+ return priv->show_replace;
}
void
gtr_search_dialog_set_show_replace (GtrSearchDialog * dialog,
gboolean show_replace)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- if (dialog->priv->glade_error)
+ if (priv->glade_error)
return;
- dialog->priv->show_replace = show_replace != FALSE;
- show_replace_widgets (dialog, dialog->priv->show_replace);
+ priv->show_replace = show_replace != FALSE;
+ show_replace_widgets (dialog, priv->show_replace);
g_object_notify (G_OBJECT (dialog), "show-replace");
}
@@ -559,18 +558,19 @@ void
gtr_search_dialog_set_search_text (GtrSearchDialog * dialog,
const gchar * text)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (text != NULL);
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->search_text_entry), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->search_text_entry), text);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GTR_SEARCH_DIALOG_FIND_RESPONSE,
- (text != '\0'));
+ (*text != '\0'));
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
- (text != '\0'));
+ (*text != '\0'));
}
/*
@@ -579,171 +579,182 @@ gtr_search_dialog_set_search_text (GtrSearchDialog * dialog,
const gchar *
gtr_search_dialog_get_search_text (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), NULL);
- return gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
+ return gtk_entry_get_text (GTK_ENTRY (priv->search_text_entry));
}
void
gtr_search_dialog_set_replace_text (GtrSearchDialog * dialog,
const gchar * text)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (text != NULL);
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->replace_text_entry), text);
+ gtk_entry_set_text (GTK_ENTRY (priv->replace_text_entry), text);
}
const gchar *
gtr_search_dialog_get_replace_text (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), NULL);
- return gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
+ return gtk_entry_get_text (GTK_ENTRY (priv->replace_text_entry));
}
void
gtr_search_dialog_set_original_text (GtrSearchDialog * dialog,
gboolean match_case)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->original_text_checkbutton),
+ (priv->original_text_checkbutton),
match_case);
}
gboolean
gtr_search_dialog_get_original_text (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
return
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->original_text_checkbutton));
+ (priv->original_text_checkbutton));
}
void
gtr_search_dialog_set_translated_text (GtrSearchDialog *
dialog, gboolean match_case)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->translated_text_checkbutton),
+ (priv->translated_text_checkbutton),
match_case);
}
gboolean
gtr_search_dialog_get_translated_text (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
- return
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->
- priv->translated_text_checkbutton));
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->translated_text_checkbutton));
}
void
gtr_search_dialog_set_fuzzy (GtrSearchDialog * dialog, gboolean match_case)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->fuzzy_checkbutton),
+ (priv->fuzzy_checkbutton),
match_case);
}
gboolean
gtr_search_dialog_get_fuzzy (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
- return
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->fuzzy_checkbutton));
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fuzzy_checkbutton));
}
void
gtr_search_dialog_set_match_case (GtrSearchDialog * dialog,
gboolean match_case)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->match_case_checkbutton),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->match_case_checkbutton),
match_case);
}
gboolean
gtr_search_dialog_get_match_case (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
return
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->match_case_checkbutton));
+ (priv->match_case_checkbutton));
}
void
gtr_search_dialog_set_entire_word (GtrSearchDialog * dialog,
gboolean entire_word)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->entire_word_checkbutton),
+ (priv->entire_word_checkbutton),
entire_word);
}
gboolean
gtr_search_dialog_get_entire_word (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
return
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->entire_word_checkbutton));
+ (priv->entire_word_checkbutton));
}
void
gtr_search_dialog_set_backwards (GtrSearchDialog * dialog, gboolean backwards)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->backwards_checkbutton),
+ (priv->backwards_checkbutton),
backwards);
}
gboolean
gtr_search_dialog_get_backwards (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
return
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->backwards_checkbutton));
+ (priv->backwards_checkbutton));
}
void
gtr_search_dialog_set_wrap_around (GtrSearchDialog * dialog,
gboolean wrap_around)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (dialog->priv->wrap_around_checkbutton),
+ (priv->wrap_around_checkbutton),
wrap_around);
}
gboolean
gtr_search_dialog_get_wrap_around (GtrSearchDialog * dialog)
{
+ GtrSearchDialogPrivate *priv = gtr_search_dialog_get_instance_private (dialog);
g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
return
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (dialog->priv->wrap_around_checkbutton));
+ (priv->wrap_around_checkbutton));
}
diff --git a/src/gtr-search-dialog.h b/src/gtr-search-dialog.h
index 2d7bca39..5659e520 100644
--- a/src/gtr-search-dialog.h
+++ b/src/gtr-search-dialog.h
@@ -36,8 +36,6 @@ G_BEGIN_DECLS
#define GTR_IS_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTR_TYPE_SEARCH_DIALOG))
#define GTR_IS_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_SEARCH_DIALOG))
#define GTR_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_SEARCH_DIALOG,
GtrSearchDialogClass))
-/* Private structure type */
-typedef struct _GtrSearchDialogPrivate GtrSearchDialogPrivate;
/*
* Main object structure
@@ -47,9 +45,6 @@ typedef struct _GtrSearchDialog GtrSearchDialog;
struct _GtrSearchDialog
{
GtkDialog dialog;
-
- /*< private > */
- GtrSearchDialogPrivate *priv;
};
/*
diff --git a/src/gtr-settings.c b/src/gtr-settings.c
index 709887fe..65c875fd 100644
--- a/src/gtr-settings.c
+++ b/src/gtr-settings.c
@@ -32,11 +32,7 @@
#include "gtr-dirs.h"
#include "gtr-utils.h"
-#define GTR_SETTINGS_SYSTEM_FONT "monospace-font-name"
-
-#define GTR_SETTINGS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GTR_TYPE_SETTINGS,
GtrSettingsPrivate))
-
-struct _GtrSettingsPrivate
+typedef struct
{
GSettings *interface;
GSettings *editor;
@@ -44,16 +40,17 @@ struct _GtrSettingsPrivate
GSettings *files;
gchar *old_scheme;
-};
+} GtrSettingsPrivate;
-G_DEFINE_TYPE (GtrSettings, gtr_settings, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GtrSettings, gtr_settings, G_TYPE_OBJECT)
static void
gtr_settings_finalize (GObject * object)
{
GtrSettings *gs = GTR_SETTINGS (object);
+ GtrSettingsPrivate *priv = gtr_settings_get_instance_private (gs);
- g_free (gs->priv->old_scheme);
+ g_free (priv->old_scheme);
G_OBJECT_CLASS (gtr_settings_parent_class)->finalize (object);
}
@@ -62,94 +59,15 @@ static void
gtr_settings_dispose (GObject * object)
{
GtrSettings *gs = GTR_SETTINGS (object);
+ GtrSettingsPrivate *priv = gtr_settings_get_instance_private (gs);
- g_clear_object (&gs->priv->interface);
- g_clear_object (&gs->priv->editor);
- g_clear_object (&gs->priv->ui);
+ g_clear_object (&priv->interface);
+ g_clear_object (&priv->editor);
+ g_clear_object (&priv->ui);
G_OBJECT_CLASS (gtr_settings_parent_class)->dispose (object);
}
-static void
-set_font (GtrSettings * gs, const gchar * font)
-{
- GList *views, *l;
-
- views = gtr_application_get_views (GTR_APP, TRUE, TRUE);
-
- for (l = views; l != NULL; l = g_list_next (l))
- {
- /* Note: we use def=FALSE to avoid GtrView to query gconf */
- gtr_view_set_font (GTR_VIEW (l->data), FALSE, font);
- }
-
- g_list_free (views);
-}
-
-static void
-on_system_font_changed (GSettings * settings,
- const gchar * key, GtrSettings * gs)
-{
-
- gboolean use_custom_font;
- gchar *font;
-
- use_custom_font = g_settings_get_boolean (gs->priv->editor,
- GTR_SETTINGS_USE_CUSTOM_FONT);
- if (!use_custom_font)
- return;
-
- font = g_settings_get_string (settings, key);
-
- set_font (gs, font);
-
- g_free (font);
-}
-
-static void
-on_use_custom_font_changed (GSettings * settings,
- const gchar * key, GtrSettings * gs)
-{
- gboolean def;
- gchar *font;
-
- def = g_settings_get_boolean (settings, key);
-
- if (!def)
- {
- font = g_settings_get_string (gs->priv->interface,
- GTR_SETTINGS_SYSTEM_FONT);
- }
- else
- {
- font = g_settings_get_string (gs->priv->editor,
- GTR_SETTINGS_EDITOR_FONT);
- }
-
- set_font (gs, font);
-
- g_free (font);
-}
-
-static void
-on_editor_font_changed (GSettings * settings,
- const gchar * key, GtrSettings * gs)
-{
- gboolean use_custom_font;
- gchar *font;
-
- use_custom_font = g_settings_get_boolean (gs->priv->editor,
- GTR_SETTINGS_USE_CUSTOM_FONT);
- if (!use_custom_font)
- return;
-
- font = g_settings_get_string (settings, key);
-
- set_font (gs, font);
-
- g_free (font);
-}
-
static void
on_auto_save_changed (GSettings * settings,
const gchar * key, GtrSettings * gs)
@@ -280,44 +198,34 @@ on_scheme_changed (GSettings * settings, const gchar * key, GtrSettings * gs)
static void
gtr_settings_init (GtrSettings * gs)
{
- gs->priv = GTR_SETTINGS_GET_PRIVATE (gs);
+ GtrSettingsPrivate *priv = gtr_settings_get_instance_private (gs);
- gs->priv->old_scheme = NULL;
+ priv->old_scheme = NULL;
- gs->priv->files = g_settings_new ("org.gnome.gtranslator.preferences.files");
- gs->priv->editor = g_settings_new ("org.gnome.gtranslator.preferences.editor");
- gs->priv->ui = g_settings_new ("org.gnome.gtranslator.preferences.ui");
+ priv->files = g_settings_new ("org.gnome.gtranslator.preferences.files");
+ priv->editor = g_settings_new ("org.gnome.gtranslator.preferences.editor");
+ priv->ui = g_settings_new ("org.gnome.gtranslator.preferences.ui");
/* Load settings */
- gs->priv->interface = g_settings_new ("org.gnome.desktop.interface");
-
- g_signal_connect (gs->priv->interface,
- "changed::monospace-font-name",
- G_CALLBACK (on_system_font_changed), gs);
+ priv->interface = g_settings_new ("org.gnome.desktop.interface");
/* editor changes */
- g_signal_connect (gs->priv->files,
+ g_signal_connect (priv->files,
"changed::autosave",
G_CALLBACK (on_auto_save_changed), gs);
- g_signal_connect (gs->priv->files,
+ g_signal_connect (priv->files,
"changed::autosave-interval",
G_CALLBACK (on_auto_save_interval_changed), gs);
- g_signal_connect (gs->priv->editor,
- "changed::use-custom-font",
- G_CALLBACK (on_use_custom_font_changed), gs);
- g_signal_connect (gs->priv->editor,
- "changed::editor-font",
- G_CALLBACK (on_editor_font_changed), gs);
- g_signal_connect (gs->priv->editor,
+ g_signal_connect (priv->editor,
"changed::highlight-syntax",
G_CALLBACK (on_syntax_highlighting_changed), gs);
- g_signal_connect (gs->priv->editor,
+ g_signal_connect (priv->editor,
"changed::visible-whitespace",
G_CALLBACK (on_visible_whitespace_changed), gs);
- g_signal_connect (gs->priv->editor,
+ g_signal_connect (priv->editor,
"changed::spellcheck",
G_CALLBACK (on_spellcheck_changed), gs);
- g_signal_connect (gs->priv->ui,
+ g_signal_connect (priv->ui,
"changed::color-scheme",
G_CALLBACK (on_scheme_changed), gs);
}
@@ -329,8 +237,6 @@ gtr_settings_class_init (GtrSettingsClass * klass)
object_class->finalize = gtr_settings_finalize;
object_class->dispose = gtr_settings_dispose;
-
- g_type_class_add_private (object_class, sizeof (GtrSettingsPrivate));
}
GSettings *
@@ -339,17 +245,4 @@ gtr_settings_new ()
return g_object_new (GTR_TYPE_SETTINGS, NULL);
}
-gchar *
-gtr_settings_get_system_font (GtrSettings * gs)
-{
- gchar *system_font;
-
- g_return_val_if_fail (GTR_IS_SETTINGS (gs), NULL);
-
- system_font = g_settings_get_string (gs->priv->interface,
- "monospace-font-name");
-
- return system_font;
-}
-
/* ex:ts=8:noet: */
diff --git a/src/gtr-settings.h b/src/gtr-settings.h
index 89d6b61e..065a5e5b 100644
--- a/src/gtr-settings.h
+++ b/src/gtr-settings.h
@@ -41,13 +41,10 @@ G_BEGIN_DECLS
typedef struct _GtrSettings GtrSettings;
typedef struct _GtrSettingsClass GtrSettingsClass;
-typedef struct _GtrSettingsPrivate GtrSettingsPrivate;
struct _GtrSettings
{
GObject parent;
-
- GtrSettingsPrivate *priv;
};
struct _GtrSettingsClass
@@ -59,8 +56,6 @@ GType gtr_settings_get_type (void) G_GNUC_CO
GSettings *gtr_settings_new (void);
-gchar *gtr_settings_get_system_font (GtrSettings *gs);
-
/* key constants: IMPORTANT: keep them in the same order as the schema */
#define GTR_SETTINGS_WARN_IF_CONTAINS_FUZZY "warn-if-contains-fuzzy"
#define GTR_SETTINGS_AUTO_SAVE "auto-save"
@@ -69,8 +64,6 @@ gchar *gtr_settings_get_system_font (GtrSettings *gs
#define GTR_SETTINGS_USE_PROFILE_VALUES "use-profile-values"
#define GTR_SETTINGS_HIGHLIGHT_SYNTAX "highlight-syntax"
#define GTR_SETTINGS_VISIBLE_WHITESPACE "visible-whitespace"
-#define GTR_SETTINGS_USE_CUSTOM_FONT "use-custom-font"
-#define GTR_SETTINGS_EDITOR_FONT "editor-font"
#define GTR_SETTINGS_UNMARK_FUZZY_WHEN_CHANGED "unmark-fuzzy-when-changed"
#define GTR_SETTINGS_SPELLCHECK "spellcheck"
#define GTR_SETTINGS_PANEL_SWITCHER_STYLE "panel-switcher-style"
diff --git a/src/gtr-status-combo-box.c b/src/gtr-status-combo-box.c
index 58774e74..4330b0e8 100644
--- a/src/gtr-status-combo-box.c
+++ b/src/gtr-status-combo-box.c
@@ -25,9 +25,7 @@
#define COMBO_BOX_TEXT_DATA "GtrStatusComboBoxTextData"
-#define GTR_STATUS_COMBO_BOX_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object),
GTR_TYPE_STATUS_COMBO_BOX, GtrStatusComboBoxPrivate))
-
-struct _GtrStatusComboBoxPrivate
+typedef struct
{
GtkWidget *frame;
GtkWidget *button;
@@ -38,7 +36,7 @@ struct _GtrStatusComboBoxPrivate
GtkWidget *menu;
GtkWidget *current_item;
-};
+} GtrStatusComboBoxPrivate;
struct _GtrStatusComboBoxClassPrivate
{
@@ -63,6 +61,7 @@ enum
static guint signals[NUM_SIGNALS] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GtrStatusComboBox, gtr_status_combo_box, GTK_TYPE_EVENT_BOX,
+ G_ADD_PRIVATE (GtrStatusComboBox)
g_type_add_class_private (g_define_type_id, sizeof (GtrStatusComboBoxClassPrivate)))
static void
@@ -114,13 +113,14 @@ gtr_status_combo_box_changed (GtrStatusComboBox *combo,
GtkMenuItem *item)
{
const gchar *text;
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
text = g_object_get_data (G_OBJECT (item), COMBO_BOX_TEXT_DATA);
if (text != NULL)
{
- gtk_label_set_markup (GTK_LABEL (combo->priv->item), text);
- combo->priv->current_item = GTK_WIDGET (item);
+ gtk_label_set_markup (GTK_LABEL (priv->item), text);
+ priv->current_item = GTK_WIDGET (item);
}
}
@@ -155,8 +155,6 @@ gtr_status_combo_box_class_init (GtrStatusComboBoxClass *klass)
NULL,
G_PARAM_READWRITE));
- g_type_class_add_private (object_class, sizeof (GtrStatusComboBoxPrivate));
-
klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GTR_TYPE_STATUS_COMBO_BOX,
GtrStatusComboBoxClassPrivate);
klass->priv->css = gtk_css_provider_new ();
@@ -167,36 +165,8 @@ static void
menu_deactivate (GtkMenu *menu,
GtrStatusComboBox *combo)
{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo->priv->button), FALSE);
-}
-
-static void
-menu_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- GtrStatusComboBox *combo)
-{
- GtkRequisition request;
- GtkAllocation allocation;
-
- *push_in = FALSE;
-
- gtk_widget_get_preferred_size (gtk_widget_get_toplevel (GTK_WIDGET (menu)),
- &request, NULL);
-
- /* get the origin... */
- gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (combo)), x, y);
-
- /* make the menu as wide as the widget */
- gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
- if (request.width < allocation.width)
- {
- gtk_widget_set_size_request (GTK_WIDGET (menu), allocation.width, -1);
- }
-
- /* position it above the widget */
- *y -= request.height;
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
}
static void
@@ -207,8 +177,9 @@ show_menu (GtrStatusComboBox *combo,
GtkRequisition request;
gint max_height;
GtkAllocation allocation;
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
- gtk_widget_get_preferred_size (combo->priv->menu,
+ gtk_widget_get_preferred_size (priv->menu,
&request, NULL);
/* do something relative to our own height here, maybe we can do better */
@@ -217,24 +188,19 @@ show_menu (GtrStatusComboBox *combo,
if (request.height > max_height)
{
- gtk_widget_set_size_request (combo->priv->menu, -1, max_height);
- gtk_widget_set_size_request (gtk_widget_get_toplevel (combo->priv->menu), -1, max_height);
+ gtk_widget_set_size_request (priv->menu, -1, max_height);
+ gtk_widget_set_size_request (gtk_widget_get_toplevel (priv->menu), -1, max_height);
}
- gtk_menu_popup (GTK_MENU (combo->priv->menu),
- NULL,
- NULL,
- (GtkMenuPositionFunc)menu_position_func,
- combo,
- button,
- time);
+ GdkEvent *event = gtk_get_current_event ();
+ gtk_menu_popup_at_pointer (GTK_MENU (priv->menu), event);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo->priv->button), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), TRUE);
- if (combo->priv->current_item)
+ if (priv->current_item)
{
- gtk_menu_shell_select_item (GTK_MENU_SHELL (combo->priv->menu),
- combo->priv->current_item);
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu),
+ priv->current_item);
}
}
@@ -274,13 +240,14 @@ set_shadow_type (GtrStatusComboBox *combo)
GtkStyleContext *context;
GtkShadowType shadow_type;
GtkWidget *statusbar;
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
/* This is a hack needed to use the shadow type of a statusbar */
statusbar = gtk_statusbar_new ();
context = gtk_widget_get_style_context (statusbar);
gtk_style_context_get_style (context, "shadow-type", &shadow_type, NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (combo->priv->frame), shadow_type);
+ gtk_frame_set_shadow_type (GTK_FRAME (priv->frame), shadow_type);
gtk_widget_destroy (statusbar);
}
@@ -289,71 +256,74 @@ static void
gtr_status_combo_box_init (GtrStatusComboBox *self)
{
GtkStyleContext *context;
-
- self->priv = GTR_STATUS_COMBO_BOX_GET_PRIVATE (self);
+ GtrStatusComboBox *combo = GTR_STATUS_COMBO_BOX (self);
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), TRUE);
- self->priv->frame = gtk_frame_new (NULL);
- gtk_widget_show (self->priv->frame);
+ priv->frame = gtk_frame_new (NULL);
+ gtk_widget_show (priv->frame);
- self->priv->button = gtk_toggle_button_new ();
- gtk_button_set_relief (GTK_BUTTON (self->priv->button), GTK_RELIEF_NONE);
- gtk_widget_show (self->priv->button);
+ priv->button = gtk_toggle_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (priv->button), GTK_RELIEF_NONE);
+ gtk_widget_show (priv->button);
set_shadow_type (self);
- self->priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
- gtk_widget_show (self->priv->hbox);
+ priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
+ gtk_widget_show (priv->hbox);
- gtk_container_add (GTK_CONTAINER (self), self->priv->frame);
- gtk_container_add (GTK_CONTAINER (self->priv->frame), self->priv->button);
- gtk_container_add (GTK_CONTAINER (self->priv->button), self->priv->hbox);
+ gtk_container_add (GTK_CONTAINER (self), priv->frame);
+ gtk_container_add (GTK_CONTAINER (priv->frame), priv->button);
+ gtk_container_add (GTK_CONTAINER (priv->button), priv->hbox);
- self->priv->label = gtk_label_new ("");
- gtk_widget_show (self->priv->label);
+ priv->label = gtk_label_new ("");
+ gtk_widget_show (priv->label);
- gtk_label_set_single_line_mode (GTK_LABEL (self->priv->label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (self->priv->label), 0.0, 0.5);
+ gtk_label_set_single_line_mode (GTK_LABEL (priv->label), TRUE);
+ gtk_label_set_xalign (GTK_LABEL (priv->label), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (priv->label), 0.5);
- gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->label, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, FALSE, TRUE, 0);
- self->priv->item = gtk_label_new ("");
- gtk_widget_show (self->priv->item);
+ priv->item = gtk_label_new ("");
+ gtk_widget_show (priv->item);
- gtk_label_set_single_line_mode (GTK_LABEL (self->priv->item), TRUE);
- gtk_misc_set_alignment (GTK_MISC (self->priv->item), 0, 0.5);
+ gtk_label_set_single_line_mode (GTK_LABEL (priv->item), TRUE);
+ gtk_label_set_xalign (GTK_LABEL (priv->item), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (priv->item), 0.5);
- gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->item, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->item, TRUE, TRUE, 0);
- self->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_widget_show (self->priv->arrow);
- gtk_misc_set_alignment (GTK_MISC (self->priv->arrow), 0.5, 0.5);
+ priv->arrow = gtk_image_new_from_icon_name ("go-down-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_widget_show (priv->arrow);
+ gtk_widget_set_halign (priv->arrow, 0.5);
+ gtk_widget_set_valign (priv->arrow, 0.5);
- gtk_box_pack_start (GTK_BOX (self->priv->hbox), self->priv->arrow, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->arrow, FALSE, TRUE, 0);
- self->priv->menu = gtk_menu_new ();
- g_object_ref_sink (self->priv->menu);
+ priv->menu = gtk_menu_new ();
+ g_object_ref_sink (priv->menu);
- g_signal_connect (self->priv->button,
+ g_signal_connect (priv->button,
"button-press-event",
G_CALLBACK (button_press_event),
self);
- g_signal_connect (self->priv->button,
+ g_signal_connect (priv->button,
"key-press-event",
G_CALLBACK (key_press_event),
self);
- g_signal_connect (self->priv->menu,
+ g_signal_connect (priv->menu,
"deactivate",
G_CALLBACK (menu_deactivate),
self);
/* make it as small as possible */
- context = gtk_widget_get_style_context (GTK_WIDGET (self->priv->button));
+ context = gtk_widget_get_style_context (GTK_WIDGET (priv->button));
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (GTR_STATUS_COMBO_BOX_GET_CLASS (self)->priv->css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- context = gtk_widget_get_style_context (GTK_WIDGET (self->priv->frame));
+ context = gtk_widget_get_style_context (GTK_WIDGET (priv->frame));
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (GTR_STATUS_COMBO_BOX_GET_CLASS (self)->priv->css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
@@ -381,20 +351,22 @@ gtr_status_combo_box_set_label (GtrStatusComboBox *combo,
const gchar *label)
{
gchar *text;
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
g_return_if_fail (GTR_IS_STATUS_COMBO_BOX (combo));
text = g_strconcat (" ", label, ": ", NULL);
- gtk_label_set_markup (GTK_LABEL (combo->priv->label), text);
+ gtk_label_set_markup (GTK_LABEL (priv->label), text);
g_free (text);
}
const gchar *
gtr_status_combo_box_get_label (GtrStatusComboBox *combo)
{
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
g_return_val_if_fail (GTR_IS_STATUS_COMBO_BOX (combo), NULL);
- return gtk_label_get_label (GTK_LABEL (combo->priv->label));
+ return gtk_label_get_label (GTK_LABEL (priv->label));
}
static void
@@ -415,10 +387,11 @@ gtr_status_combo_box_add_item (GtrStatusComboBox *combo,
GtkMenuItem *item,
const gchar *text)
{
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
g_return_if_fail (GTR_IS_STATUS_COMBO_BOX (combo));
g_return_if_fail (GTK_IS_MENU_ITEM (item));
- gtk_menu_shell_append (GTK_MENU_SHELL (combo->priv->menu), GTK_WIDGET (item));
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), GTK_WIDGET (item));
gtr_status_combo_box_set_item_text (combo, item, text);
g_signal_connect (item, "activate", G_CALLBACK (item_activated), combo);
@@ -428,10 +401,11 @@ void
gtr_status_combo_box_remove_item (GtrStatusComboBox *combo,
GtkMenuItem *item)
{
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
g_return_if_fail (GTR_IS_STATUS_COMBO_BOX (combo));
g_return_if_fail (GTK_IS_MENU_ITEM (item));
- gtk_container_remove (GTK_CONTAINER (combo->priv->menu),
+ gtk_container_remove (GTK_CONTAINER (priv->menu),
GTK_WIDGET (item));
}
@@ -444,9 +418,10 @@ gtr_status_combo_box_remove_item (GtrStatusComboBox *combo,
GList *
gtr_status_combo_box_get_items (GtrStatusComboBox *combo)
{
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
g_return_val_if_fail (GTR_IS_STATUS_COMBO_BOX (combo), NULL);
- return gtk_container_get_children (GTK_CONTAINER (combo->priv->menu));
+ return gtk_container_get_children (GTK_CONTAINER (priv->menu));
}
const gchar *
@@ -496,9 +471,10 @@ gtr_status_combo_box_set_item (GtrStatusComboBox *combo,
GtkLabel *
gtr_status_combo_box_get_item_label (GtrStatusComboBox *combo)
{
+ GtrStatusComboBoxPrivate *priv = gtr_status_combo_box_get_instance_private (combo);
g_return_val_if_fail (GTR_IS_STATUS_COMBO_BOX (combo), NULL);
- return GTK_LABEL (combo->priv->item);
+ return GTK_LABEL (priv->item);
}
/* ex:set ts=8 noet: */
diff --git a/src/gtr-status-combo-box.h b/src/gtr-status-combo-box.h
index 1e313dc4..3f44fb13 100644
--- a/src/gtr-status-combo-box.h
+++ b/src/gtr-status-combo-box.h
@@ -35,15 +35,12 @@ G_BEGIN_DECLS
#define GTR_STATUS_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_STATUS_COMBO_BOX,
GtrStatusComboBoxClass))
typedef struct _GtrStatusComboBox GtrStatusComboBox;
-typedef struct _GtrStatusComboBoxPrivate GtrStatusComboBoxPrivate;
typedef struct _GtrStatusComboBoxClass GtrStatusComboBoxClass;
typedef struct _GtrStatusComboBoxClassPrivate GtrStatusComboBoxClassPrivate;
struct _GtrStatusComboBox
{
GtkEventBox parent;
-
- GtrStatusComboBoxPrivate *priv;
};
struct _GtrStatusComboBoxClass
diff --git a/src/gtr-statusbar.c b/src/gtr-statusbar.c
index e602717f..bcc4cb9d 100644
--- a/src/gtr-statusbar.c
+++ b/src/gtr-statusbar.c
@@ -27,10 +27,7 @@
#include "gtr-statusbar.h"
-#define GTR_STATUSBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object),\
- GTR_TYPE_STATUSBAR, GtrStatusbarPrivate))
-
-struct _GtrStatusbarPrivate
+typedef struct
{
GtkWidget *statusbar;
GtkWidget *progress_bar;
@@ -44,15 +41,18 @@ struct _GtrStatusbarPrivate
guint flash_timeout;
guint flash_context_id;
guint flash_message_id;
-};
+} GtrStatusbarPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrStatusbar, gtr_statusbar, GTK_TYPE_BOX)
-G_DEFINE_TYPE (GtrStatusbar, gtr_statusbar, GTK_TYPE_BOX)
- static void gtr_statusbar_finalize (GObject * object)
+static void
+gtr_statusbar_finalize (GObject * object)
{
GtrStatusbar *statusbar = GTR_STATUSBAR (object);
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
- if (statusbar->priv->flash_timeout > 0)
- g_source_remove (statusbar->priv->flash_timeout);
+ if (priv->flash_timeout > 0)
+ g_source_remove (priv->flash_timeout);
G_OBJECT_CLASS (gtr_statusbar_parent_class)->finalize (object);
}
@@ -63,8 +63,6 @@ gtr_statusbar_class_init (GtrStatusbarClass * klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtr_statusbar_finalize;
-
- g_type_class_add_private (object_class, sizeof (GtrStatusbarPrivate));
}
static void
@@ -72,8 +70,7 @@ gtr_statusbar_init (GtrStatusbar * statusbar)
{
GtkWidget *frame;
GtkShadowType shadow_type;
-
- statusbar->priv = GTR_STATUSBAR_GET_PRIVATE (statusbar);
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
gtk_orientable_set_orientation (GTK_ORIENTABLE (statusbar),
GTK_ORIENTATION_HORIZONTAL);
@@ -81,50 +78,51 @@ gtr_statusbar_init (GtrStatusbar * statusbar)
/*
* Statusbar
*/
- statusbar->priv->statusbar = gtk_statusbar_new ();
- gtk_widget_show (statusbar->priv->statusbar);
- gtk_box_pack_end (GTK_BOX (statusbar), statusbar->priv->statusbar,
+ priv->statusbar = gtk_statusbar_new ();
+ gtk_widget_show (priv->statusbar);
+ gtk_box_pack_end (GTK_BOX (statusbar), priv->statusbar,
TRUE, TRUE, 0);
- statusbar->priv->default_context_id =
- gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar->priv->statusbar),
+ priv->default_context_id =
+ gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
"default-context-id");
/*
* Progress bar
*/
- statusbar->priv->progress_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(statusbar->priv->progress_bar), TRUE);
- gtk_widget_show (statusbar->priv->progress_bar);
- gtk_box_pack_start (GTK_BOX (statusbar), statusbar->priv->progress_bar,
+ priv->progress_bar = gtk_progress_bar_new ();
+ gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(priv->progress_bar), TRUE);
+ gtk_widget_show (priv->progress_bar);
+ gtk_box_pack_start (GTK_BOX (statusbar), priv->progress_bar,
FALSE, FALSE, 0);
/*
* Ins/Ovr stuff
*/
- gtk_widget_style_get (GTK_WIDGET (statusbar->priv->statusbar),
+ gtk_widget_style_get (GTK_WIDGET (priv->statusbar),
"shadow-type", &shadow_type, NULL);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), shadow_type);
gtk_widget_show (frame);
- statusbar->priv->overwrite_mode_label = gtk_label_new ("");
+ priv->overwrite_mode_label = gtk_label_new ("");
gtk_label_set_single_line_mode (GTK_LABEL
- (statusbar->priv->overwrite_mode_label),
+ (priv->overwrite_mode_label),
TRUE);
- gtk_misc_set_alignment (GTK_MISC (statusbar->priv->overwrite_mode_label),
- 0.0, 0.5);
+ gtk_label_set_xalign (GTK_LABEL (priv->overwrite_mode_label), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (priv->overwrite_mode_label), 0.5);
+
gtk_label_set_width_chars (GTK_LABEL
- (statusbar->priv->overwrite_mode_label),
+ (priv->overwrite_mode_label),
MAX (g_utf8_strlen (_("INS"), -1) + 1,
g_utf8_strlen (_("OVR"), -1) + 1));
gtk_container_add (GTK_CONTAINER (frame),
- statusbar->priv->overwrite_mode_label);
- gtk_widget_show (statusbar->priv->overwrite_mode_label);
+ priv->overwrite_mode_label);
+ gtk_widget_show (priv->overwrite_mode_label);
- gtk_box_pack_start (GTK_BOX (statusbar->priv->statusbar), frame,
+ gtk_box_pack_start (GTK_BOX (priv->statusbar), frame,
FALSE, FALSE, 0);
}
@@ -151,10 +149,11 @@ gtr_statusbar_new (void)
void
gtr_statusbar_push_default (GtrStatusbar * statusbar, const gchar * text)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
- gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->default_context_id, text);
+ gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar),
+ priv->default_context_id, text);
}
/**
@@ -166,10 +165,11 @@ gtr_statusbar_push_default (GtrStatusbar * statusbar, const gchar * text)
void
gtr_statusbar_pop_default (GtrStatusbar * statusbar)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->default_context_id);
+ gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar),
+ priv->default_context_id);
}
/**
@@ -186,9 +186,10 @@ guint
gtr_statusbar_push (GtrStatusbar * statusbar,
guint context_id, const gchar * text)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
g_return_val_if_fail (GTR_IS_STATUSBAR (statusbar), 0);
- return gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
+ return gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar),
context_id, text);
}
@@ -202,9 +203,10 @@ gtr_statusbar_push (GtrStatusbar * statusbar,
void
gtr_statusbar_pop (GtrStatusbar * statusbar, guint context_id)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->statusbar), context_id);
+ gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar), context_id);
}
/**
@@ -221,8 +223,9 @@ guint
gtr_statusbar_get_context_id (GtrStatusbar * statusbar,
const gchar * context_description)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
return
- gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar->priv->statusbar),
+ gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
context_description);
}
@@ -236,15 +239,16 @@ gtr_statusbar_get_context_id (GtrStatusbar * statusbar,
void
gtr_statusbar_set_overwrite (GtrStatusbar * statusbar, gboolean overwrite)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
if (overwrite)
/* Translators: Overwrite mode */
- gtk_label_set_text (GTK_LABEL (statusbar->priv->overwrite_mode_label),
+ gtk_label_set_text (GTK_LABEL (priv->overwrite_mode_label),
_("OVR"));
/* Translators: Insert mode */
else
- gtk_label_set_text (GTK_LABEL (statusbar->priv->overwrite_mode_label),
+ gtk_label_set_text (GTK_LABEL (priv->overwrite_mode_label),
_("INS"));
}
@@ -257,20 +261,22 @@ gtr_statusbar_set_overwrite (GtrStatusbar * statusbar, gboolean overwrite)
void
gtr_statusbar_clear_overwrite (GtrStatusbar * statusbar)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
- gtk_label_set_text (GTK_LABEL (statusbar->priv->overwrite_mode_label), "");
+ gtk_label_set_text (GTK_LABEL (priv->overwrite_mode_label), "");
}
static gboolean
remove_message_timeout (GtrStatusbar * statusbar)
{
- gtk_statusbar_remove (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->flash_context_id,
- statusbar->priv->flash_message_id);
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
+ gtk_statusbar_remove (GTK_STATUSBAR (priv->statusbar),
+ priv->flash_context_id,
+ priv->flash_message_id);
/* remove the timeout */
- statusbar->priv->flash_timeout = 0;
+ priv->flash_timeout = 0;
return FALSE;
}
@@ -286,6 +292,7 @@ void
gtr_statusbar_flash_message (GtrStatusbar * statusbar,
guint context_id, const gchar * format, ...)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
const guint32 flash_length = 3000; /* three seconds */
va_list args;
gchar *msg;
@@ -298,22 +305,22 @@ gtr_statusbar_flash_message (GtrStatusbar * statusbar,
va_end (args);
/* remove a currently ongoing flash message */
- if (statusbar->priv->flash_timeout > 0)
+ if (priv->flash_timeout > 0)
{
- g_source_remove (statusbar->priv->flash_timeout);
- statusbar->priv->flash_timeout = 0;
+ g_source_remove (priv->flash_timeout);
+ priv->flash_timeout = 0;
- gtk_statusbar_remove (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->flash_context_id,
- statusbar->priv->flash_message_id);
+ gtk_statusbar_remove (GTK_STATUSBAR (priv->statusbar),
+ priv->flash_context_id,
+ priv->flash_message_id);
}
- statusbar->priv->flash_context_id = context_id;
- statusbar->priv->flash_message_id =
- gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
+ priv->flash_context_id = context_id;
+ priv->flash_message_id =
+ gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar),
context_id, msg);
- statusbar->priv->flash_timeout = g_timeout_add (flash_length,
+ priv->flash_timeout = g_timeout_add (flash_length,
(GSourceFunc) remove_message_timeout,
statusbar);
@@ -333,6 +340,7 @@ gtr_statusbar_update_progress_bar (GtrStatusbar * statusbar,
gdouble translated_count,
gdouble messages_count)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
gdouble percentage;
g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
@@ -351,13 +359,13 @@ gtr_statusbar_update_progress_bar (GtrStatusbar * statusbar,
/* Set the progressbar status */
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
- (statusbar->priv->progress_bar),
+ (priv->progress_bar),
percentage);
percentage_str = g_strdup_printf ("%.2f%%", percentage * 100);
gtk_progress_bar_set_text (GTK_PROGRESS_BAR
- (statusbar->priv->progress_bar),
+ (priv->progress_bar),
percentage_str);
g_free (percentage_str);
}
@@ -372,6 +380,7 @@ gtr_statusbar_update_progress_bar (GtrStatusbar * statusbar,
void
gtr_statusbar_clear_progress_bar (GtrStatusbar * statusbar)
{
+ GtrStatusbarPrivate *priv = gtr_statusbar_get_instance_private (statusbar);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
- (statusbar->priv->progress_bar), 0.0);
+ (priv->progress_bar), 0.0);
}
diff --git a/src/gtr-statusbar.h b/src/gtr-statusbar.h
index 36cd4dde..bf5dbbc6 100644
--- a/src/gtr-statusbar.h
+++ b/src/gtr-statusbar.h
@@ -29,15 +29,11 @@ G_BEGIN_DECLS
#define GTR_IS_STATUSBAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_STATUSBAR))
#define GTR_STATUSBAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_STATUSBAR,
GtrStatusbarClass))
typedef struct _GtrStatusbar GtrStatusbar;
-typedef struct _GtrStatusbarPrivate GtrStatusbarPrivate;
typedef struct _GtrStatusbarClass GtrStatusbarClass;
struct _GtrStatusbar
{
GtkBox parent;
-
- /* <private/> */
- GtrStatusbarPrivate *priv;
};
struct _GtrStatusbarClass
diff --git a/src/gtr-tab-label.c b/src/gtr-tab-label.c
index 0b842bf3..192400c2 100644
--- a/src/gtr-tab-label.c
+++ b/src/gtr-tab-label.c
@@ -28,8 +28,6 @@
#include "gtr-tab-label.h"
#include "gtr-close-button.h"
-#define GTR_TAB_LABEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GTR_TYPE_TAB_LABEL,
GtrTabLabelPrivate))
-
/* Signals */
enum
{
@@ -43,7 +41,7 @@ enum
PROP_TAB
};
-struct _GtrTabLabelPrivate
+typedef struct
{
GtrTab *tab;
@@ -53,11 +51,11 @@ struct _GtrTabLabelPrivate
GtkWidget *label;
gboolean close_button_sensitive;
-};
+} GtrTabLabelPrivate;
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (GtrTabLabel, gtr_tab_label, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GtrTabLabel, gtr_tab_label, GTK_TYPE_BOX)
static void
gtr_tab_label_finalize (GObject *object)
@@ -72,11 +70,12 @@ gtr_tab_label_set_property (GObject *object,
GParamSpec *pspec)
{
GtrTabLabel *tab_label = GTR_TAB_LABEL (object);
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
switch (prop_id)
{
case PROP_TAB:
- tab_label->priv->tab = GTR_TAB (g_value_get_object (value));
+ priv->tab = GTR_TAB (g_value_get_object (value));
break;
default:
@@ -92,11 +91,12 @@ gtr_tab_label_get_property (GObject *object,
GParamSpec *pspec)
{
GtrTabLabel *tab_label = GTR_TAB_LABEL (object);
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
switch (prop_id)
{
case PROP_TAB:
- g_value_set_object (value, tab_label->priv->tab);
+ g_value_set_object (value, priv->tab);
break;
default:
@@ -116,11 +116,12 @@ static void
sync_tip (GtrTab *tab, GtrTabLabel *tab_label)
{
gchar *str;
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
str = _gtr_tab_get_tooltips (tab);
g_return_if_fail (str != NULL);
- gtk_widget_set_tooltip_markup (tab_label->priv->ebox, str);
+ gtk_widget_set_tooltip_markup (priv->ebox, str);
g_free (str);
}
@@ -128,13 +129,14 @@ static void
sync_name (GtrTab *tab, GParamSpec *pspec, GtrTabLabel *tab_label)
{
gchar *str;
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
- g_return_if_fail (tab == tab_label->priv->tab);
+ g_return_if_fail (tab == priv->tab);
str = _gtr_tab_get_name (tab);
g_return_if_fail (str != NULL);
- gtk_label_set_text (GTK_LABEL (tab_label->priv->label), str);
+ gtk_label_set_text (GTK_LABEL (priv->label), str);
g_free (str);
sync_tip (tab, tab_label);
@@ -145,13 +147,14 @@ static void
sync_state (GtrTab *tab, GParamSpec *pspec, GtrTabLabel *tab_label)
{
GtrTabState state;
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
- g_return_if_fail (tab == tab_label->priv->tab);
+ g_return_if_fail (tab == priv->tab);
state = gtr_tab_get_state (tab);
- gtk_widget_set_sensitive (tab_label->priv->close_button,
- tab_label->priv->close_button_sensitive &&
+ gtk_widget_set_sensitive (priv->close_button,
+ priv->close_button_sensitive &&
(state != GTR_TAB_STATE_CLOSING) &&
(state != GTR_TAB_STATE_SAVING) &&
(state != GTR_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
@@ -161,26 +164,26 @@ sync_state (GtrTab *tab, GParamSpec *pspec, GtrTabLabel *tab_label)
(state == GTR_TAB_STATE_SAVING) ||
(state == GTR_TAB_STATE_REVERTING))
{
- gtk_widget_hide (tab_label->priv->icon);
+ gtk_widget_hide (priv->icon);
- gtk_widget_show (tab_label->priv->spinner);
- gtk_spinner_start (GTK_SPINNER (tab_label->priv->spinner));
+ gtk_widget_show (priv->spinner);
+ gtk_spinner_start (GTK_SPINNER (priv->spinner));
}
else
{
GdkPixbuf *pixbuf;
pixbuf = _gtr_tab_get_icon (tab);
- gtk_image_set_from_pixbuf (GTK_IMAGE (tab_label->priv->icon), pixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), pixbuf);
if (pixbuf != NULL)
g_object_unref (pixbuf);
- gtk_widget_show (tab_label->priv->icon);
+ gtk_widget_show (priv->icon);
- gtk_widget_hide (tab_label->priv->spinner);
+ gtk_widget_hide (priv->spinner);
- gtk_spinner_stop (GTK_SPINNER (tab_label->priv->spinner));
+ gtk_spinner_stop (GTK_SPINNER (priv->spinner));
}
/* sync tip since encoding is known only after load/save end */
@@ -192,24 +195,25 @@ static void
gtr_tab_label_constructed (GObject *object)
{
GtrTabLabel *tab_label = GTR_TAB_LABEL (object);
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
- if (!tab_label->priv->tab)
+ if (!priv->tab)
{
g_critical ("The tab label was not properly constructed");
return;
}
- sync_name (tab_label->priv->tab, NULL, tab_label);
- /*sync_state (tab_label->priv->tab, NULL, tab_label); */
+ sync_name (priv->tab, NULL, tab_label);
+ /*sync_state (priv->tab, NULL, tab_label); */
- g_signal_connect_object (tab_label->priv->tab,
+ g_signal_connect_object (priv->tab,
"notify::name",
G_CALLBACK (sync_name),
tab_label,
0);
/*
- g_signal_connect_object (tab_label->priv->tab,
+ g_signal_connect_object (priv->tab,
"notify::state",
G_CALLBACK (sync_state),
tab_label,
@@ -244,8 +248,6 @@ gtr_tab_label_class_init (GtrTabLabelClass *klass)
GTR_TYPE_TAB,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
-
- g_type_class_add_private (object_class, sizeof(GtrTabLabelPrivate));
}
static void
@@ -257,10 +259,9 @@ gtr_tab_label_init (GtrTabLabel *tab_label)
GtkWidget *icon;
GtkWidget *label;
GtkWidget *dummy_label;
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
- tab_label->priv = GTR_TAB_LABEL_GET_PRIVATE (tab_label);
-
- tab_label->priv->close_button_sensitive = TRUE;
+ priv->close_button_sensitive = TRUE;
gtk_orientable_set_orientation (GTK_ORIENTABLE (tab_label),
GTK_ORIENTATION_HORIZONTAL);
@@ -268,7 +269,7 @@ gtr_tab_label_init (GtrTabLabel *tab_label)
ebox = gtk_event_box_new ();
gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
gtk_box_pack_start (GTK_BOX (tab_label), ebox, TRUE, TRUE, 0);
- tab_label->priv->ebox = ebox;
+ priv->ebox = ebox;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_container_add (GTK_CONTAINER (ebox), hbox);
@@ -276,7 +277,7 @@ gtr_tab_label_init (GtrTabLabel *tab_label)
close_button = gtr_close_button_new ();
gtk_widget_set_tooltip_text (close_button, _("Close document"));
gtk_box_pack_start (GTK_BOX (tab_label), close_button, FALSE, FALSE, 0);
- tab_label->priv->close_button = close_button;
+ priv->close_button = close_button;
g_signal_connect (close_button,
"clicked",
@@ -286,13 +287,13 @@ gtr_tab_label_init (GtrTabLabel *tab_label)
/* setup icon, empty by default */
icon = gtk_image_new ();
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
- tab_label->priv->icon = icon;
+ priv->icon = icon;
label = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_misc_set_padding (GTK_MISC (label), 0, 0);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- tab_label->priv->label = label;
+ priv->label = label;
dummy_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), dummy_label, TRUE, TRUE, 0);
@@ -309,25 +310,27 @@ void
gtr_tab_label_set_close_button_sensitive (GtrTabLabel *tab_label,
gboolean sensitive)
{
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
g_return_if_fail (GTR_IS_TAB_LABEL (tab_label));
sensitive = (sensitive != FALSE);
- if (sensitive == tab_label->priv->close_button_sensitive)
+ if (sensitive == priv->close_button_sensitive)
return;
- tab_label->priv->close_button_sensitive = sensitive;
+ priv->close_button_sensitive = sensitive;
- gtk_widget_set_sensitive (tab_label->priv->close_button,
- tab_label->priv->close_button_sensitive);
+ gtk_widget_set_sensitive (priv->close_button,
+ priv->close_button_sensitive);
}
GtrTab *
gtr_tab_label_get_tab (GtrTabLabel *tab_label)
{
+ GtrTabLabelPrivate *priv = gtr_tab_label_get_instance_private (tab_label);
g_return_val_if_fail (GTR_IS_TAB_LABEL (tab_label), NULL);
- return tab_label->priv->tab;
+ return priv->tab;
}
GtkWidget *
diff --git a/src/gtr-tab-label.h b/src/gtr-tab-label.h
index c64e7299..eb2701d3 100644
--- a/src/gtr-tab-label.h
+++ b/src/gtr-tab-label.h
@@ -37,12 +37,9 @@ G_BEGIN_DECLS
typedef struct _GtrTabLabel GtrTabLabel;
typedef struct _GtrTabLabelClass GtrTabLabelClass;
-typedef struct _GtrTabLabelPrivate GtrTabLabelPrivate;
struct _GtrTabLabel {
GtkBox parent;
-
- GtrTabLabelPrivate *priv;
};
struct _GtrTabLabelClass {
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index 7e7a2529..8bf2adbc 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -167,7 +167,7 @@ gtr_tab_autosave (GtrTab * tab)
GtrTabPrivate *priv;
priv = gtr_tab_get_instance_private (tab);
- if (!gtr_po_get_state (priv->po) == GTR_PO_STATE_MODIFIED)
+ if (!(gtr_po_get_state (priv->po) == GTR_PO_STATE_MODIFIED))
return TRUE;
gtr_po_save_file (priv->po, &error);
diff --git a/src/gtr-utils.c b/src/gtr-utils.c
index d9136c6d..16bfc09c 100644
--- a/src/gtr-utils.c
+++ b/src/gtr-utils.c
@@ -61,24 +61,24 @@ gtr_xml_open_file (const gchar * filename)
}
/**
- * gtr_gtk_button_new_with_stock_icon:
+ * gtr_gtk_button_new_with_icon_name:
* @label: the label of the button
- * @stock_id: the id of the stock image
+ * @icon_name: the icon name
*
* Convenience function to create a #GtkButton with a stock image.
*
* Returns: a new #GtkButton
*/
GtkWidget *
-gtr_gtk_button_new_with_stock_icon (const gchar * label,
- const gchar * stock_id)
+gtr_gtk_button_new_with_icon_name (const gchar * label,
+ const gchar * icon_name)
{
GtkWidget *button;
button = gtk_button_new_with_mnemonic (label);
gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (stock_id,
- GTK_ICON_SIZE_BUTTON));
+ gtk_image_new_from_icon_name (icon_name,
+ GTK_ICON_SIZE_BUTTON));
return button;
}
diff --git a/src/gtr-utils.h b/src/gtr-utils.h
index 9367b176..8590bd32 100644
--- a/src/gtr-utils.h
+++ b/src/gtr-utils.h
@@ -31,8 +31,8 @@ xmlDocPtr gtr_xml_new_doc (const gchar * name);
xmlDocPtr gtr_xml_open_file (const gchar * filename);
-GtkWidget *gtr_gtk_button_new_with_stock_icon (const gchar * label,
- const gchar * stock_id);
+GtkWidget *gtr_gtk_button_new_with_icon_name (const gchar * label,
+ const gchar * icon_name);
void gtr_utils_menu_position_under_widget (GtkMenu * menu,
gint * x,
diff --git a/src/gtr-view.c b/src/gtr-view.c
index eaf2e712..73dce596 100644
--- a/src/gtr-view.c
+++ b/src/gtr-view.c
@@ -140,23 +140,6 @@ gtr_view_init (GtrView * view)
g_settings_get_boolean (priv->editor_settings,
GTR_SETTINGS_VISIBLE_WHITESPACE));
- /* Set fonts according to preferences */
- if (g_settings_get_boolean (priv->editor_settings, GTR_SETTINGS_USE_CUSTOM_FONT))
- {
- gchar *editor_font;
-
- editor_font = g_settings_get_string (priv->editor_settings,
- GTR_SETTINGS_EDITOR_FONT);
-
- gtr_view_set_font (view, FALSE, editor_font);
-
- g_free (editor_font);
- }
- else
- {
- gtr_view_set_font (view, TRUE, NULL);
- }
-
/* Set scheme color according to preferences */
gtr_view_reload_scheme_color (view);
}
@@ -280,13 +263,22 @@ gtr_view_enable_spellcheck (GtrView * view, gboolean enable)
void
gtr_view_enable_visible_whitespace (GtrView * view, gboolean enable)
{
+ GtkSourceView *source;
+ GtkSourceSpaceDrawer *drawer;
+
g_return_if_fail (GTR_IS_VIEW (view));
+ source = GTK_SOURCE_VIEW (view);
+ drawer = gtk_source_view_get_space_drawer (source);
+
if (enable)
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view),
- GTK_SOURCE_DRAW_SPACES_ALL);
+ gtk_source_space_drawer_set_types_for_locations (drawer,
+ GTK_SOURCE_SPACE_LOCATION_ALL,
+ GTK_SOURCE_SPACE_TYPE_ALL);
else
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view), 0);
+ gtk_source_space_drawer_set_types_for_locations (drawer,
+ GTK_SOURCE_SPACE_LOCATION_NONE,
+ GTK_SOURCE_SPACE_TYPE_NONE);
}
/**
@@ -379,44 +371,6 @@ gtr_view_paste_clipboard (GtrView * view)
0.0, FALSE, 0.0, 0.0);
}
-/**
- * gtr_view_set_font:
- * @view: a #GtrView
- * @def: TRUE if you want to use the default font
- * @font_name: The name of the font you want to use in the #GtrView
- *
- * Sets the #GtrView font.
- **/
-void
-gtr_view_set_font (GtrView * view, gboolean def, const gchar * font_name)
-{
- PangoFontDescription *font_desc = NULL;
-
- g_return_if_fail (GTR_IS_VIEW (view));
-
- if (def)
- {
- GSettings *gtr_settings;
- gchar *font;
-
- gtr_settings = _gtr_application_get_settings (GTR_APP);
- font = gtr_settings_get_system_font (GTR_SETTINGS (gtr_settings));
-
- font_desc = pango_font_description_from_string (font);
- g_free (font);
- }
- else
- {
- font_desc = pango_font_description_from_string (font_name);
- }
-
- g_return_if_fail (font_desc != NULL);
-
- gtk_widget_modify_font (GTK_WIDGET (view), font_desc);
-
- pango_font_description_free (font_desc);
-}
-
/**
* gtr_view_set_search_text:
diff --git a/src/gtr-view.h b/src/gtr-view.h
index 8cd40bea..3b48e38c 100644
--- a/src/gtr-view.h
+++ b/src/gtr-view.h
@@ -87,9 +87,6 @@ gtr_view_get_type (void)
void gtr_view_paste_clipboard (GtrView * view);
- void gtr_view_set_font (GtrView * view,
- gboolean def, const gchar * font_name);
-
void gtr_view_set_search_text (GtrView * view,
const gchar * text, guint flags);
diff --git a/src/gtr-window.c b/src/gtr-window.c
index bd9165c4..31ceb6f9 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -1133,6 +1133,8 @@ gtr_window_show_tm_dialog (GtrWindow *window)
if (dlg == NULL)
{
dlg = gtr_translation_memory_dialog_new (priv->translation_memory);
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
+
g_signal_connect (dlg, "destroy",
G_CALLBACK (gtk_widget_destroyed), &dlg);
gtk_widget_show_all (dlg);
diff --git a/src/translation-memory/gda/gtr-gda.c b/src/translation-memory/gda/gtr-gda.c
index 0c140e07..0a165970 100644
--- a/src/translation-memory/gda/gtr-gda.c
+++ b/src/translation-memory/gda/gtr-gda.c
@@ -30,21 +30,10 @@
#include <glib-object.h>
#include <string.h>
-#define GTR_GDA_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- GTR_TYPE_GDA, \
- GtrGdaPrivate))
-
static void
gtr_translation_memory_iface_init (GtrTranslationMemoryInterface * iface);
-G_DEFINE_TYPE_WITH_CODE (GtrGda,
- gtr_gda,
- G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (GTR_TYPE_TRANSLATION_MEMORY,
- gtr_translation_memory_iface_init))
-
-struct _GtrGdaPrivate
+typedef struct
{
GdaConnection *db;
@@ -68,7 +57,14 @@ struct _GtrGdaPrivate
gint max_items;
GHashTable *lookup_query_cache;
-};
+} GtrGdaPrivate;
+
+G_DEFINE_TYPE_WITH_CODE (GtrGda,
+ gtr_gda,
+ G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtrGda)
+ G_IMPLEMENT_INTERFACE (GTR_TYPE_TRANSLATION_MEMORY,
+ gtr_translation_memory_iface_init))
static gint
select_integer (GdaConnection *db,
@@ -193,12 +189,13 @@ gtr_gda_words_append (GtrGda *self,
{
GError *inner_error;
gint word_id = 0;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
/* look for word */
{
inner_error = NULL;
- word_id = select_integer (self->priv->db,
- self->priv->stmt_select_word,
+ word_id = select_integer (priv->db,
+ priv->stmt_select_word,
gda_set_new_inline (1,
"value", G_TYPE_STRING,
word),
@@ -213,8 +210,8 @@ gtr_gda_words_append (GtrGda *self,
if (word_id == 0)
{
inner_error = NULL;
- word_id = insert_row (self->priv->db,
- self->priv->stmt_insert_word,
+ word_id = insert_row (priv->db,
+ priv->stmt_insert_word,
gda_set_new_inline (1,
"value", G_TYPE_STRING, word),
&inner_error);
@@ -234,8 +231,8 @@ gtr_gda_words_append (GtrGda *self,
"orig_id", G_TYPE_INT, orig_id);
inner_error = NULL;
- if (-1 == gda_connection_statement_execute_non_select (self->priv->db,
- self->priv->stmt_insert_link,
+ if (-1 == gda_connection_statement_execute_non_select (priv->db,
+ priv->stmt_insert_link,
params,
NULL,
&inner_error))
@@ -255,10 +252,11 @@ gtr_gda_store_impl (GtrGda *self,
gboolean found_translation = FALSE;
gchar **words = NULL;
GError *inner_error;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
inner_error = NULL;
- orig_id = select_integer (self->priv->db,
- self->priv->stmt_find_orig,
+ orig_id = select_integer (priv->db,
+ priv->stmt_find_orig,
gda_set_new_inline (1,
"original", G_TYPE_STRING,
original),
@@ -277,8 +275,8 @@ gtr_gda_store_impl (GtrGda *self,
sz = g_strv_length (words);
inner_error = NULL;
- orig_id = insert_row (self->priv->db,
- self->priv->stmt_insert_orig,
+ orig_id = insert_row (priv->db,
+ priv->stmt_insert_orig,
gda_set_new_inline (2,
"original", G_TYPE_STRING,
original,
@@ -302,8 +300,8 @@ gtr_gda_store_impl (GtrGda *self,
else
{
inner_error = NULL;
- found_translation = select_integer (self->priv->db,
- self->priv->stmt_find_trans,
+ found_translation = select_integer (priv->db,
+ priv->stmt_find_trans,
gda_set_new_inline (2,
"orig_id",
G_TYPE_INT,
@@ -319,8 +317,8 @@ gtr_gda_store_impl (GtrGda *self,
if (!found_translation)
{
inner_error = NULL;
- insert_row (self->priv->db,
- self->priv->stmt_insert_trans,
+ insert_row (priv->db,
+ priv->stmt_insert_trans,
gda_set_new_inline (2,
"orig_id", G_TYPE_INT,
orig_id,
@@ -345,11 +343,12 @@ gtr_gda_store (GtrTranslationMemory * tm, GtrMsg * msg)
GtrGda *self = GTR_GDA (tm);
gboolean result;
GError *error;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
g_return_val_if_fail (GTR_IS_GDA (self), FALSE);
error = NULL;
- if (!gda_connection_begin_transaction (self->priv->db,
+ if (!gda_connection_begin_transaction (priv->db,
NULL,
GDA_TRANSACTION_ISOLATION_READ_COMMITTED,
&error))
@@ -372,9 +371,9 @@ gtr_gda_store (GtrTranslationMemory * tm, GtrMsg * msg)
}
if (result)
- gda_connection_commit_transaction (self->priv->db, NULL, NULL);
+ gda_connection_commit_transaction (priv->db, NULL, NULL);
else
- gda_connection_rollback_transaction (self->priv->db, NULL, NULL);
+ gda_connection_rollback_transaction (priv->db, NULL, NULL);
return result;
}
@@ -386,11 +385,12 @@ gtr_gda_store_list (GtrTranslationMemory * tm, GList * msgs)
gboolean result = TRUE;
GList *l;
GError *error;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
g_return_val_if_fail (GTR_IS_GDA (self), FALSE);
error = NULL;
- if (!gda_connection_begin_transaction (self->priv->db,
+ if (!gda_connection_begin_transaction (priv->db,
NULL,
GDA_TRANSACTION_ISOLATION_READ_COMMITTED,
&error))
@@ -421,9 +421,9 @@ gtr_gda_store_list (GtrTranslationMemory * tm, GList * msgs)
}
if (result)
- gda_connection_commit_transaction (self->priv->db, NULL, NULL);
+ gda_connection_commit_transaction (priv->db, NULL, NULL);
else
- gda_connection_rollback_transaction (self->priv->db, NULL, NULL);
+ gda_connection_rollback_transaction (priv->db, NULL, NULL);
return result;
}
@@ -435,6 +435,7 @@ gtr_gda_remove (GtrTranslationMemory *tm,
GtrGda *self = GTR_GDA (tm);
GdaSet *params;
GError *error;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
params = gda_set_new_inline (1,
"id_trans",
@@ -442,8 +443,8 @@ gtr_gda_remove (GtrTranslationMemory *tm,
translation_id);
error = NULL;
- gda_connection_statement_execute_non_select (self->priv->db,
- self->priv->stmt_delete_trans,
+ gda_connection_statement_execute_non_select (priv->db,
+ priv->stmt_delete_trans,
params,
NULL,
&error);
@@ -470,6 +471,7 @@ build_lookup_query (GtrGda *self, guint word_count)
{
GString * query = g_string_sized_new (1024);
guint i;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
g_string_append_printf (query,
"select "
@@ -500,7 +502,7 @@ build_lookup_query (GtrGda *self, guint word_count)
" and WORD.VALUE in (",
word_count,
word_count,
- word_count + self->priv->max_delta);
+ word_count + priv->max_delta);
for (i = 0; i < word_count; ++i)
{
@@ -516,8 +518,8 @@ build_lookup_query (GtrGda *self, guint word_count)
"where ORID = TRANS.ORIG_ID "
"order by SCORE desc "
"limit %d",
- word_count - self->priv->max_omits,
- self->priv->max_items);
+ word_count - priv->max_omits,
+ priv->max_items);
return g_string_free (query, FALSE);
}
@@ -527,21 +529,22 @@ gtr_gda_get_lookup_statement (GtrGda *self, guint word_count, GError **error)
{
GdaStatement *stmt;
gchar *query;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
- stmt = GDA_STATEMENT (g_hash_table_lookup (self->priv->lookup_query_cache,
+ stmt = GDA_STATEMENT (g_hash_table_lookup (priv->lookup_query_cache,
GUINT_TO_POINTER (word_count)));
if (stmt)
return stmt;
query = build_lookup_query (self, word_count);
- stmt = gda_sql_parser_parse_string (self->priv->parser,
+ stmt = gda_sql_parser_parse_string (priv->parser,
query,
NULL,
error);
g_free (query);
- g_hash_table_insert (self->priv->lookup_query_cache,
+ g_hash_table_insert (priv->lookup_query_cache,
GUINT_TO_POINTER (word_count),
stmt);
@@ -560,10 +563,11 @@ gtr_gda_lookup (GtrTranslationMemory * tm, const gchar * phrase)
GdaSet *params = NULL;
GdaDataModel *model = NULL;
gint i;
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
g_return_val_if_fail (GTR_IS_GDA (self), NULL);
- if (!gda_connection_begin_transaction (self->priv->db,
+ if (!gda_connection_begin_transaction (priv->db,
NULL,
GDA_TRANSACTION_ISOLATION_READ_COMMITTED,
NULL))
@@ -604,7 +608,7 @@ gtr_gda_lookup (GtrTranslationMemory * tm, const gchar * phrase)
}
inner_error = NULL;
- model = gda_connection_statement_execute_select (self->priv->db,
+ model = gda_connection_statement_execute_select (priv->db,
stmt,
params,
&inner_error);
@@ -676,7 +680,7 @@ gtr_gda_lookup (GtrTranslationMemory * tm, const gchar * phrase)
if (params)
g_object_unref (params);
- gda_connection_rollback_transaction (self->priv->db, NULL, NULL);
+ gda_connection_rollback_transaction (priv->db, NULL, NULL);
if (inner_error)
{
@@ -697,27 +701,30 @@ static void
gtr_gda_set_max_omits (GtrTranslationMemory * tm, gsize omits)
{
GtrGda *self = GTR_GDA (tm);
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
- self->priv->max_omits = omits;
- g_hash_table_remove_all (self->priv->lookup_query_cache);
+ priv->max_omits = omits;
+ g_hash_table_remove_all (priv->lookup_query_cache);
}
static void
gtr_gda_set_max_delta (GtrTranslationMemory * tm, gsize delta)
{
GtrGda *self = GTR_GDA (tm);
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
- self->priv->max_delta = delta;
- g_hash_table_remove_all (self->priv->lookup_query_cache);
+ priv->max_delta = delta;
+ g_hash_table_remove_all (priv->lookup_query_cache);
}
static void
gtr_gda_set_max_items (GtrTranslationMemory * tm, gint items)
{
GtrGda *self = GTR_GDA (tm);
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
- self->priv->max_items = items;
- g_hash_table_remove_all (self->priv->lookup_query_cache);
+ priv->max_items = items;
+ g_hash_table_remove_all (priv->lookup_query_cache);
}
static void
@@ -758,8 +765,7 @@ gtr_gda_init (GtrGda * self)
{
gchar *connection_string;
GError *error = NULL;
-
- self->priv = GTR_GDA_GET_PRIVATE (self);
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
gda_init ();
@@ -777,7 +783,7 @@ gtr_gda_init (GtrGda * self)
g_free (encoded_config_dir);
}
- self->priv->db = gda_connection_open_from_string ("Sqlite",
+ priv->db = gda_connection_open_from_string ("Sqlite",
connection_string,
NULL,
GDA_CONNECTION_OPTIONS_NONE,
@@ -788,34 +794,34 @@ gtr_gda_init (GtrGda * self)
g_error_free (error);
}
- gda_connection_execute_non_select_command (self->priv->db,
+ gda_connection_execute_non_select_command (priv->db,
"create table WORD ("
"ID integer primary key autoincrement,"
"VALUE text unique)",
NULL);
- gda_connection_execute_non_select_command (self->priv->db,
+ gda_connection_execute_non_select_command (priv->db,
"create table WORD_ORIG_LINK ("
"WORD_ID integer,"
"ORIG_ID integer,"
"primary key (WORD_ID, ORIG_ID))",
NULL);
- gda_connection_execute_non_select_command (self->priv->db,
+ gda_connection_execute_non_select_command (priv->db,
"create table ORIG ("
"ID integer primary key autoincrement,"
"VALUE text unique,"
"SENTENCE_SIZE integer)",
NULL);
- gda_connection_execute_non_select_command (self->priv->db,
+ gda_connection_execute_non_select_command (priv->db,
"create table TRANS ("
"ID integer primary key autoincrement,"
"ORIG_ID integer,"
"VALUE text)",
NULL);
- gda_connection_execute_non_select_command (self->priv->db,
+ gda_connection_execute_non_select_command (priv->db,
"create index "
"if not exists IDX_TRANS_ORIG_ID "
"on TRANS (ORIG_ID)",
@@ -823,69 +829,69 @@ gtr_gda_init (GtrGda * self)
/* prepare statements */
- self->priv->parser = gda_connection_create_parser (self->priv->db);
- if (self->priv->parser == NULL)
- self->priv->parser = gda_sql_parser_new ();
+ priv->parser = gda_connection_create_parser (priv->db);
+ if (priv->parser == NULL)
+ priv->parser = gda_sql_parser_new ();
- self->priv->stmt_find_orig =
- prepare_statement (self->priv->parser,
+ priv->stmt_find_orig =
+ prepare_statement (priv->parser,
"select ID from ORIG "
"where VALUE=##original::string");
- self->priv->stmt_select_word =
- prepare_statement (self->priv->parser,
+ priv->stmt_select_word =
+ prepare_statement (priv->parser,
"select ID from WORD "
"where VALUE=##value::string");
- self->priv->stmt_select_trans =
- prepare_statement (self->priv->parser,
+ priv->stmt_select_trans =
+ prepare_statement (priv->parser,
"select VALUE from TRANS "
"where ORIG_ID=##orig_id::int");
- self->priv->stmt_find_trans =
- prepare_statement (self->priv->parser,
+ priv->stmt_find_trans =
+ prepare_statement (priv->parser,
"select ID from TRANS "
"where ORIG_ID=##orig_id::int "
"and VALUE=##value::string");
- self->priv->stmt_insert_orig =
- prepare_statement (self->priv->parser,
+ priv->stmt_insert_orig =
+ prepare_statement (priv->parser,
"insert into "
"ORIG (VALUE, SENTENCE_SIZE) "
"values "
"(##original::string, ##sentence_size::int)");
- self->priv->stmt_insert_word =
- prepare_statement (self->priv->parser,
+ priv->stmt_insert_word =
+ prepare_statement (priv->parser,
"insert into "
"WORD (VALUE) "
"values "
"(##value::string)");
- self->priv->stmt_insert_link =
- prepare_statement (self->priv->parser,
+ priv->stmt_insert_link =
+ prepare_statement (priv->parser,
"insert into "
"WORD_ORIG_LINK (WORD_ID, ORIG_ID) "
"values "
"(##word_id::int, ##orig_id::int)");
- self->priv->stmt_insert_trans =
- prepare_statement (self->priv->parser,
+ priv->stmt_insert_trans =
+ prepare_statement (priv->parser,
"insert into "
"TRANS (ORIG_ID, VALUE) "
"values "
"(##orig_id::int, ##value::string)");
- self->priv->stmt_delete_trans =
- prepare_statement (self->priv->parser,
+ priv->stmt_delete_trans =
+ prepare_statement (priv->parser,
"delete from TRANS "
"where id = ##id_trans::int");
- self->priv->max_omits = 0;
- self->priv->max_delta = 0;
- self->priv->max_items = 0;
+ priv->max_omits = 0;
+ priv->max_delta = 0;
+ priv->max_items = 0;
- self->priv->lookup_query_cache = g_hash_table_new_full (g_direct_hash,
+ priv->lookup_query_cache = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
g_object_unref);
@@ -895,77 +901,78 @@ static void
gtr_gda_dispose (GObject * object)
{
GtrGda *self = GTR_GDA (object);
+ GtrGdaPrivate *priv = gtr_gda_get_instance_private (self);
- if (self->priv->stmt_find_orig != NULL)
+ if (priv->stmt_find_orig != NULL)
{
- g_object_unref (self->priv->stmt_find_orig);
- self->priv->stmt_find_orig = NULL;
+ g_object_unref (priv->stmt_find_orig);
+ priv->stmt_find_orig = NULL;
}
- if (self->priv->stmt_select_trans != NULL)
+ if (priv->stmt_select_trans != NULL)
{
- g_object_unref (self->priv->stmt_select_trans);
- self->priv->stmt_select_trans = NULL;
+ g_object_unref (priv->stmt_select_trans);
+ priv->stmt_select_trans = NULL;
}
- if (self->priv->stmt_find_trans != NULL)
+ if (priv->stmt_find_trans != NULL)
{
- g_object_unref (self->priv->stmt_find_trans);
- self->priv->stmt_find_trans = NULL;
+ g_object_unref (priv->stmt_find_trans);
+ priv->stmt_find_trans = NULL;
}
- if (self->priv->stmt_select_word != NULL)
+ if (priv->stmt_select_word != NULL)
{
- g_object_unref (self->priv->stmt_select_word);
- self->priv->stmt_select_word = NULL;
+ g_object_unref (priv->stmt_select_word);
+ priv->stmt_select_word = NULL;
}
- if (self->priv->stmt_insert_orig != NULL)
+ if (priv->stmt_insert_orig != NULL)
{
- g_object_unref (self->priv->stmt_insert_orig);
- self->priv->stmt_insert_orig = NULL;
+ g_object_unref (priv->stmt_insert_orig);
+ priv->stmt_insert_orig = NULL;
}
- if (self->priv->stmt_insert_word != NULL)
+ if (priv->stmt_insert_word != NULL)
{
- g_object_unref (self->priv->stmt_insert_word);
- self->priv->stmt_insert_word = NULL;
+ g_object_unref (priv->stmt_insert_word);
+ priv->stmt_insert_word = NULL;
}
- if (self->priv->stmt_insert_link != NULL)
+ if (priv->stmt_insert_link != NULL)
{
- g_object_unref (self->priv->stmt_insert_link);
- self->priv->stmt_insert_link = NULL;
+ g_object_unref (priv->stmt_insert_link);
+ priv->stmt_insert_link = NULL;
}
- if (self->priv->stmt_insert_trans != NULL)
+ if (priv->stmt_insert_trans != NULL)
{
- g_object_unref (self->priv->stmt_insert_trans);
- self->priv->stmt_insert_trans = NULL;
+ g_object_unref (priv->stmt_insert_trans);
+ priv->stmt_insert_trans = NULL;
}
- if (self->priv->stmt_delete_trans != NULL)
+ if (priv->stmt_delete_trans != NULL)
{
- g_object_unref (self->priv->stmt_delete_trans);
- self->priv->stmt_delete_trans = NULL;
+ g_object_unref (priv->stmt_delete_trans);
+ priv->stmt_delete_trans = NULL;
}
- if (self->priv->parser != NULL)
+ if (priv->parser != NULL)
{
- g_object_unref (self->priv->parser);
- self->priv->parser = NULL;
+ g_object_unref (priv->parser);
+ priv->parser = NULL;
}
- if (self->priv->db != NULL)
+ if (priv->db != NULL)
{
- g_object_unref (self->priv->db);
- self->priv->db = NULL;
+ g_object_unref (priv->db);
+ priv->db = NULL;
}
- if (self->priv->lookup_query_cache != NULL)
+ if (priv->lookup_query_cache != NULL)
{
- g_hash_table_unref (self->priv->lookup_query_cache);
- self->priv->lookup_query_cache = NULL;
+ g_hash_table_unref (priv->lookup_query_cache);
+ priv->lookup_query_cache = NULL;
}
G_OBJECT_CLASS (gtr_gda_parent_class)->dispose (object);
@@ -975,8 +982,6 @@ static void
gtr_gda_class_init (GtrGdaClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GtrGdaPrivate));
object_class->dispose = gtr_gda_dispose;
}
diff --git a/src/translation-memory/gda/gtr-gda.h b/src/translation-memory/gda/gtr-gda.h
index a2f0e91b..3afef596 100644
--- a/src/translation-memory/gda/gtr-gda.h
+++ b/src/translation-memory/gda/gtr-gda.h
@@ -31,16 +31,12 @@ G_BEGIN_DECLS
#define GTR_IS_GDA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_GDA))
#define GTR_GDA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_GDA, GtrGdaClass))
-typedef struct _GtrGdaPrivate GtrGdaPrivate;
typedef struct _GtrGda GtrGda;
typedef struct _GtrGdaClass GtrGdaClass;
struct _GtrGda
{
GObject parent_instance;
-
- /*< private > */
- GtrGdaPrivate *priv;
};
struct _GtrGdaClass
diff --git a/src/translation-memory/gtr-translation-memory-dialog.c
b/src/translation-memory/gtr-translation-memory-dialog.c
index 26edca70..cdfe3336 100644
--- a/src/translation-memory/gtr-translation-memory-dialog.c
+++ b/src/translation-memory/gtr-translation-memory-dialog.c
@@ -23,9 +23,7 @@
#include <glib/gi18n.h>
-#define GTR_TRANSLATION_MEMORY_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object),
GTR_TYPE_TRANSLATION_MEMORY_DIALOG, GtrTranslationMemoryDialogPrivate))
-
-struct _GtrTranslationMemoryDialogPrivate
+typedef struct
{
GSettings *tm_settings;
@@ -37,9 +35,9 @@ struct _GtrTranslationMemoryDialogPrivate
GtkWidget *use_lang_profile_in_tm;
GtrTranslationMemory *translation_memory;
-};
+} GtrTranslationMemoryDialogPrivate;
-G_DEFINE_TYPE (GtrTranslationMemoryDialog, gtr_translation_memory_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE_WITH_PRIVATE (GtrTranslationMemoryDialog, gtr_translation_memory_dialog, GTK_TYPE_DIALOG)
static void
gtr_translation_memory_dialog_finalize (GObject *object)
@@ -50,7 +48,8 @@ gtr_translation_memory_dialog_finalize (GObject *object)
static void
gtr_translation_memory_dialog_dispose (GObject *object)
{
- GtrTranslationMemoryDialogPrivate *priv = GTR_TRANSLATION_MEMORY_DIALOG (object)->priv;
+ GtrTranslationMemoryDialog *dlg = GTR_TRANSLATION_MEMORY_DIALOG (object);
+ GtrTranslationMemoryDialogPrivate *priv = gtr_translation_memory_dialog_get_instance_private (dlg);
g_clear_object (&priv->tm_settings);
@@ -64,8 +63,6 @@ gtr_translation_memory_dialog_class_init (GtrTranslationMemoryDialogClass *klass
object_class->finalize = gtr_translation_memory_dialog_finalize;
object_class->dispose = gtr_translation_memory_dialog_dispose;
-
- g_type_class_add_private (object_class, sizeof (GtrTranslationMemoryDialogPrivate));
}
/***************Translation Memory pages****************/
@@ -74,14 +71,16 @@ response_filechooser_cb (GtkDialog *dialog,
gint response_id,
GtrTranslationMemoryDialog *dlg)
{
+ GtrTranslationMemoryDialogPrivate *priv = gtr_translation_memory_dialog_get_instance_private (dlg);
+
if (response_id == GTK_RESPONSE_YES)
{
gchar *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->directory_entry),
+ gtk_entry_set_text (GTK_ENTRY (priv->directory_entry),
filename);
- g_settings_set_string (dlg->priv->tm_settings,
+ g_settings_set_string (priv->tm_settings,
"po-directory",
filename);
g_free (filename);
@@ -99,9 +98,9 @@ on_search_button_clicked (GtkButton *button,
filechooser = gtk_file_chooser_dialog_new ("Select PO directory",
GTK_WINDOW (dlg),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL,
+ _("_Cancel"),
GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
+ _("_OK"),
GTK_RESPONSE_YES, NULL);
g_signal_connect (GTK_DIALOG (filechooser), "response",
@@ -209,8 +208,9 @@ on_add_database_button_clicked (GtkButton *button,
GFile *dir;
gchar *dir_name;
IdleData *data;
+ GtrTranslationMemoryDialogPrivate *priv = gtr_translation_memory_dialog_get_instance_private (dlg);
- dir_name = g_settings_get_string (dlg->priv->tm_settings,
+ dir_name = g_settings_get_string (priv->tm_settings,
"po-directory");
/* If dir name is empty, show a warning message */
@@ -236,12 +236,12 @@ on_add_database_button_clicked (GtkButton *button,
data = g_new0 (IdleData, 1);
data->list = NULL;
- if (g_settings_get_boolean (dlg->priv->tm_settings,
+ if (g_settings_get_boolean (priv->tm_settings,
"restrict-to-filename"))
{
gchar *restriction;
- restriction = g_settings_get_string (dlg->priv->tm_settings,
+ restriction = g_settings_get_string (priv->tm_settings,
"filename-restriction");
gtr_scan_dir (dir, &data->list, restriction);
g_free (restriction);
@@ -249,11 +249,11 @@ on_add_database_button_clicked (GtkButton *button,
else
gtr_scan_dir (dir, &data->list, NULL);
- data->tm = dlg->priv->translation_memory;
- data->progress = GTK_PROGRESS_BAR (dlg->priv->add_database_progressbar);
+ data->tm = priv->translation_memory;
+ data->progress = GTK_PROGRESS_BAR (priv->add_database_progressbar);
data->parent = GTK_WINDOW (dlg);
- gtk_widget_show (dlg->priv->add_database_progressbar);
+ gtk_widget_show (priv->add_database_progressbar);
g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
(GSourceFunc) add_to_database,
data, (GDestroyNotify) destroy_idle_data);
@@ -264,8 +264,7 @@ on_add_database_button_clicked (GtkButton *button,
static void
gtr_translation_memory_dialog_init (GtrTranslationMemoryDialog *dlg)
{
- GtrTranslationMemoryDialogPrivate *priv;
- GtkWidget *action_area;
+ GtrTranslationMemoryDialogPrivate *priv = gtr_translation_memory_dialog_get_instance_private (dlg);
GtkWidget *content_area;
GtkBuilder *builder;
GtkWidget *content;
@@ -278,13 +277,10 @@ gtr_translation_memory_dialog_init (GtrTranslationMemoryDialog *dlg)
NULL
};
- dlg->priv = GTR_TRANSLATION_MEMORY_DIALOG_GET_PRIVATE (dlg);
- priv = dlg->priv;
-
priv->tm_settings = g_settings_new ("org.gnome.gtranslator.plugins.translation-memory");
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE,
+ _("_Close"),
GTK_RESPONSE_CLOSE,
NULL);
@@ -292,14 +288,11 @@ gtr_translation_memory_dialog_init (GtrTranslationMemoryDialog *dlg)
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg));
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 4);
g_signal_connect (dlg, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
@@ -365,11 +358,17 @@ GtkWidget *
gtr_translation_memory_dialog_new (GtrTranslationMemory *translation_memory)
{
GtrTranslationMemoryDialog *dlg;
+ GtrTranslationMemoryDialogPrivate *priv;
- dlg = GTR_TRANSLATION_MEMORY_DIALOG (g_object_new (GTR_TYPE_TRANSLATION_MEMORY_DIALOG, NULL));
+ dlg = GTR_TRANSLATION_MEMORY_DIALOG (g_object_new (GTR_TYPE_TRANSLATION_MEMORY_DIALOG,
+ "use-header-bar", TRUE, NULL));
+ priv = gtr_translation_memory_dialog_get_instance_private (dlg);
/* FIXME: use a property */
- dlg->priv->translation_memory = translation_memory;
+ priv->translation_memory = translation_memory;
+
+ gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
return GTK_WIDGET (dlg);
}
diff --git a/src/translation-memory/gtr-translation-memory-dialog.h
b/src/translation-memory/gtr-translation-memory-dialog.h
index 7a6ed2d2..059aaa27 100644
--- a/src/translation-memory/gtr-translation-memory-dialog.h
+++ b/src/translation-memory/gtr-translation-memory-dialog.h
@@ -33,13 +33,10 @@ G_BEGIN_DECLS
typedef struct _GtrTranslationMemoryDialog GtrTranslationMemoryDialog;
typedef struct _GtrTranslationMemoryDialogClass GtrTranslationMemoryDialogClass;
-typedef struct _GtrTranslationMemoryDialogPrivate GtrTranslationMemoryDialogPrivate;
struct _GtrTranslationMemoryDialog
{
GtkDialog parent;
-
- GtrTranslationMemoryDialogPrivate *priv;
};
struct _GtrTranslationMemoryDialogClass
diff --git a/src/translation-memory/gtr-translation-memory-ui.c
b/src/translation-memory/gtr-translation-memory-ui.c
index db107175..cc318322 100644
--- a/src/translation-memory/gtr-translation-memory-ui.c
+++ b/src/translation-memory/gtr-translation-memory-ui.c
@@ -40,14 +40,7 @@
#define MAX_ELEMENTS 9
-#define GTR_TRANSLATION_MEMORY_UI_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- GTR_TYPE_TRANSLATION_MEMORY_UI, \
- GtrTranslationMemoryUiPrivate))
-
-G_DEFINE_TYPE (GtrTranslationMemoryUi, gtr_translation_memory_ui, GTK_TYPE_SCROLLED_WINDOW)
-
-struct _GtrTranslationMemoryUiPrivate
+typedef struct
{
GtrTranslationMemory *translation_memory;
GtkWidget *tree_view;
@@ -58,7 +51,10 @@ struct _GtrTranslationMemoryUiPrivate
GtkWidget *popup_menu;
GtrMsg *msg;
-};
+} GtrTranslationMemoryUiPrivate;
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtrTranslationMemoryUi, gtr_translation_memory_ui, GTK_TYPE_SCROLLED_WINDOW)
enum
{
@@ -81,11 +77,12 @@ choose_translation (GtrTranslationMemoryUi *tm_ui, const gchar *translation)
GtrPo *po;
GList *current_msg = NULL;
GtrMsg *msg;
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
- view = gtr_tab_get_active_view (tm_ui->priv->tab);
+ view = gtr_tab_get_active_view (priv->tab);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- po = gtr_tab_get_po (tm_ui->priv->tab);
+ po = gtr_tab_get_po (priv->tab);
current_msg = gtr_po_get_current_message (po);
msg = GTR_MSG (current_msg->data);
@@ -99,19 +96,6 @@ choose_translation (GtrTranslationMemoryUi *tm_ui, const gchar *translation)
gtr_po_set_state (po, GTR_PO_STATE_MODIFIED);
}
-static void
-on_activate_item_cb (GtkMenuItem *menuitem,
- GtrTranslationMemoryUi *tm_ui)
-{
- gint index;
-
- /* Possible this hack is not going to work with all languages neither, we
- are supposing the integer at the end of the string */
- index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "option"));
-
- choose_translation (tm_ui, tm_ui->priv->tm_list[index]);
-}
-
static void
free_match (gpointer data)
{
@@ -129,45 +113,38 @@ showed_message_cb (GtrTab *tab, GtrMsg *msg, GtrTranslationMemoryUi *tm_ui)
GtkTreeViewColumn *level_column;
const gchar *msgid;
gint i;
- gint j;
GList *tm_list = NULL;
GList *l = NULL;
GList *renderers_list = NULL;
- GtkWidget *tm_item;
- GtkWidget *tm_menu;
- GtkWidget *items_menu;
- GtkWidget *window;
- gchar *item_name;
-
- model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (tm_ui->priv->tree_view)));
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
- window = gtk_widget_get_toplevel (GTK_WIDGET (tm_ui));
+ model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree_view)));
- g_signal_connect (tm_ui->priv->tree_view,
+ g_signal_connect (priv->tree_view,
"size_allocate",
- G_CALLBACK (tree_view_size_cb), tm_ui->priv->tree_view);
+ G_CALLBACK (tree_view_size_cb), priv->tree_view);
- if (tm_ui->priv->msg)
- g_object_unref (tm_ui->priv->msg);
- tm_ui->priv->msg = g_object_ref (msg);
+ if (priv->msg)
+ g_object_unref (priv->msg);
+ priv->msg = g_object_ref (msg);
msgid = gtr_msg_get_msgid (msg);
- tm_list = gtr_translation_memory_lookup (tm_ui->priv->translation_memory, msgid);
- g_strfreev (tm_ui->priv->tm_list);
+ tm_list = gtr_translation_memory_lookup (priv->translation_memory, msgid);
+ g_strfreev (priv->tm_list);
gtk_list_store_clear (model);
- tm_ui->priv->tm_list = g_new (gchar *, MAX_ELEMENTS + 1);
- tm_ui->priv->tm_list_id = g_new (gint, MAX_ELEMENTS + 1);
+ priv->tm_list = g_new (gchar *, MAX_ELEMENTS + 1);
+ priv->tm_list_id = g_new (gint, MAX_ELEMENTS + 1);
i = 0;
for (l = tm_list; l && i < MAX_ELEMENTS; l = l->next)
{
GtrTranslationMemoryMatch *match = (GtrTranslationMemoryMatch *) l->data;
- tm_ui->priv->tm_list_id[i] = match->id;
- tm_ui->priv->tm_list[i] = g_strdup (match->match);
- level_column = gtk_tree_view_get_column (GTK_TREE_VIEW (tm_ui->priv->tree_view), 0);
+ priv->tm_list_id[i] = match->id;
+ priv->tm_list[i] = g_strdup (match->match);
+ level_column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->tree_view), 0);
renderers_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (level_column));
g_object_set (renderers_list->data,
@@ -184,7 +161,7 @@ showed_message_cb (GtrTab *tab, GtrMsg *msg, GtrTranslationMemoryUi *tm_ui)
}
/* Ensure last element is NULL */
- tm_ui->priv->tm_list[i] = NULL;
+ priv->tm_list[i] = NULL;
g_list_free_full (tm_list, free_match);
}
@@ -221,8 +198,9 @@ popup_menu_translation_activate (GtkMenuItem *menuitem,
GtkTreeModel *model;
GtkTreeIter iter;
gchar *translation;
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tm_ui->priv->tree_view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
if (!selection || !gtk_tree_selection_get_selected (selection, &model, &iter))
return;
@@ -244,8 +222,9 @@ popup_menu_remove_from_memory (GtkMenuItem *menuitem,
GtkTreeIter iter;
gint i;
gchar *translation;
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tm_ui->priv->tree_view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
if (!selection || !gtk_tree_selection_get_selected (selection, &model, &iter))
return;
@@ -253,27 +232,23 @@ popup_menu_remove_from_memory (GtkMenuItem *menuitem,
STRING_COLUMN, &translation,
-1);
- for (i = 0; tm_ui->priv->tm_list[i]; i++)
- if (!strcmp (tm_ui->priv->tm_list[i], translation))
+ for (i = 0; priv->tm_list[i]; i++)
+ if (!strcmp (priv->tm_list[i], translation))
break;
- gtr_translation_memory_remove (tm_ui->priv->translation_memory, tm_ui->priv->tm_list_id[i]);
+ gtr_translation_memory_remove (priv->translation_memory, priv->tm_list_id[i]);
g_free (translation);
/* update list */
- showed_message_cb (tm_ui->priv->tab, tm_ui->priv->msg, tm_ui);
+ showed_message_cb (priv->tab, priv->msg, tm_ui);
}
static GtkWidget *
create_tree_popup_menu (GtrTranslationMemoryUi *self)
{
- GtkTreeSelection *selection;
GtkWidget *menu;
GtkWidget *item;
- GtkWidget *image;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->tree_view));
menu = gtk_menu_new ();
@@ -282,9 +257,7 @@ create_tree_popup_menu (GtrTranslationMemoryUi *self)
G_CALLBACK (popup_menu_translation_activate), self);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
- image = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ item = gtk_menu_item_new_with_mnemonic (_("_Remove"));
g_signal_connect (item, "activate",
G_CALLBACK (popup_menu_remove_from_memory), self);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -298,31 +271,31 @@ create_tree_popup_menu (GtrTranslationMemoryUi *self)
static void
tree_popup_menu_detach (GtrTranslationMemoryUi *self, GtkMenu * menu)
{
- self->priv->popup_menu = NULL;
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (self);
+ priv->popup_menu = NULL;
}
static void
gtr_translation_memory_ui_show_menu (GtrTranslationMemoryUi *self,
GdkEventButton * event)
{
- if (self->priv->popup_menu)
- gtk_widget_destroy (self->priv->popup_menu);
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (self);
+ if (priv->popup_menu)
+ gtk_widget_destroy (priv->popup_menu);
- self->priv->popup_menu = create_tree_popup_menu (self);
+ priv->popup_menu = create_tree_popup_menu (self);
- gtk_menu_attach_to_widget (GTK_MENU (self->priv->popup_menu),
+ gtk_menu_attach_to_widget (GTK_MENU (priv->popup_menu),
GTK_WIDGET (self),
(GtkMenuDetachFunc) tree_popup_menu_detach);
if (event != NULL)
- gtk_menu_popup (GTK_MENU (self->priv->popup_menu), NULL, NULL,
- NULL, NULL,
- event->button, event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), (GdkEvent*)event);
else
- gtk_menu_popup (GTK_MENU (self->priv->popup_menu), NULL, NULL,
- gtr_utils_menu_position_under_tree_view,
- self->priv->tree_view,
- 0, gtk_get_current_event_time ());
+ {
+ GdkEvent *ev = gtk_get_current_event ();
+ gtk_menu_popup_at_pointer (GTK_MENU (priv->popup_menu), ev);
+ }
}
static void
@@ -378,16 +351,14 @@ tree_view_popup_menu (GtkTreeView *tree, GtrTranslationMemoryUi *tm_ui)
static void
gtr_translation_memory_ui_init (GtrTranslationMemoryUi * tm_ui)
{
- GtrTranslationMemoryUiPrivate *priv;
GtkListStore *model;
GtkCellRenderer *level_renderer, *string_renderer, *shortcut_renderer;
GtkTreeViewColumn *shortcut, *string, *level;
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
- tm_ui->priv = GTR_TRANSLATION_MEMORY_UI_GET_PRIVATE (tm_ui);
- priv = tm_ui->priv;
- tm_ui->priv->tm_list = NULL;
- tm_ui->priv->popup_menu = NULL;
- tm_ui->priv->msg = NULL;
+ priv->tm_list = NULL;
+ priv->popup_menu = NULL;
+ priv->msg = NULL;
priv->tree_view = gtk_tree_view_new ();
gtk_widget_show (priv->tree_view);
@@ -444,10 +415,11 @@ static void
gtr_translation_memory_ui_dispose (GObject * object)
{
GtrTranslationMemoryUi *tm_ui = GTR_TRANSLATION_MEMORY_UI (object);
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
DEBUG_PRINT ("Dispose translation memory ui");
- g_clear_object (&tm_ui->priv->msg);
+ g_clear_object (&priv->msg);
G_OBJECT_CLASS (gtr_translation_memory_ui_parent_class)->dispose (object);
}
@@ -456,10 +428,11 @@ static void
gtr_translation_memory_ui_finalize (GObject * object)
{
GtrTranslationMemoryUi *tm_ui = GTR_TRANSLATION_MEMORY_UI (object);
+ GtrTranslationMemoryUiPrivate *priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
DEBUG_PRINT ("Finalize translation memory ui");
- g_strfreev (tm_ui->priv->tm_list);
+ g_strfreev (priv->tm_list);
G_OBJECT_CLASS (gtr_translation_memory_ui_parent_class)->finalize (object);
}
@@ -469,8 +442,6 @@ gtr_translation_memory_ui_class_init (GtrTranslationMemoryUiClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtrTranslationMemoryUiPrivate));
-
object_class->dispose = gtr_translation_memory_ui_dispose;
object_class->finalize = gtr_translation_memory_ui_finalize;
}
@@ -480,16 +451,18 @@ gtr_translation_memory_ui_new (GtkWidget *tab,
GtrTranslationMemory *translation_memory)
{
GtrTranslationMemoryUi *tm_ui;
+ GtrTranslationMemoryUiPrivate *priv;
tm_ui = g_object_new (GTR_TYPE_TRANSLATION_MEMORY_UI, NULL);
- tm_ui->priv->tab = GTR_TAB (tab);
- tm_ui->priv->translation_memory = translation_memory;
+ priv = gtr_translation_memory_ui_get_instance_private (tm_ui);
+ priv->tab = GTR_TAB (tab);
+ priv->translation_memory = translation_memory;
g_signal_connect (tab,
"showed-message", G_CALLBACK (showed_message_cb), tm_ui);
/* Scrolledwindow needs to be realized to add a widget */
- gtk_container_add (GTK_CONTAINER (tm_ui), tm_ui->priv->tree_view);
+ gtk_container_add (GTK_CONTAINER (tm_ui), priv->tree_view);
return GTK_WIDGET (tm_ui);
}
diff --git a/src/translation-memory/gtr-translation-memory-ui.h
b/src/translation-memory/gtr-translation-memory-ui.h
index 536cfc9f..74cb4865 100644
--- a/src/translation-memory/gtr-translation-memory-ui.h
+++ b/src/translation-memory/gtr-translation-memory-ui.h
@@ -36,14 +36,10 @@ G_BEGIN_DECLS
typedef struct _GtrTranslationMemoryUi GtrTranslationMemoryUi;
typedef struct _GtrTranslationMemoryUiClass GtrTranslationMemoryUiClass;
-typedef struct _GtrTranslationMemoryUiPrivate GtrTranslationMemoryUiPrivate;
struct _GtrTranslationMemoryUi
{
GtkScrolledWindow parent_instance;
-
- /*< private > */
- GtrTranslationMemoryUiPrivate *priv;
};
struct _GtrTranslationMemoryUiClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]