[gtranslator] Adapted all the source code to the GNU Coding Standards
- From: Pablo Sanxiao Roca <psanxiao src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtranslator] Adapted all the source code to the GNU Coding Standards
- Date: Wed, 19 Aug 2009 20:29:45 +0000 (UTC)
commit dc03c99ae89475358712be4a7e07d6bb82358b33
Author: psanxiao <psanxiao Duibhe lan>
Date: Wed Aug 19 22:28:33 2009 +0200
Adapted all the source code to the GNU Coding Standards
.../alternate-language/alternate-language-panel.c | 552 ++--
.../alternate-language/alternate-language-panel.h | 30 +-
.../alternate-language/alternate-language-plugin.c | 305 +-
.../alternate-language/alternate-language-plugin.h | 21 +-
plugins/charmap/charmap-panel.c | 190 +-
plugins/charmap/charmap-panel.h | 34 +-
plugins/charmap/charmap-plugin.c | 390 ++--
plugins/charmap/charmap-plugin.h | 20 +-
plugins/dictionary/dict-panel.c | 1173 ++++----
plugins/dictionary/dict-panel.h | 31 +-
plugins/dictionary/dictionary-plugin.c | 106 +-
plugins/dictionary/dictionary-plugin.h | 19 +-
plugins/dictionary/gdict-sidebar.c | 148 +-
plugins/dictionary/gdict-sidebar.h | 39 +-
plugins/fullscreen/fullscreen-plugin.c | 161 +-
plugins/fullscreen/fullscreen-plugin.h | 21 +-
plugins/glossary/glossary-panel.c | 179 +-
plugins/glossary/glossary-panel.h | 28 +-
plugins/insert-params/insert-params-plugin.c | 588 ++--
plugins/insert-params/insert-params-plugin.h | 21 +-
plugins/insert-tags/insert-tags-plugin.c | 544 ++--
plugins/insert-tags/insert-tags-plugin.h | 21 +-
plugins/open-tran/open-tran-panel.c | 712 +++---
plugins/open-tran/open-tran-panel.h | 29 +-
plugins/open-tran/open-tran-plugin.c | 352 +--
plugins/open-tran/open-tran-plugin.h | 26 +-
plugins/source-code-view/source-code-view-plugin.c | 1219 ++++----
plugins/source-code-view/source-code-view-plugin.h | 28 +-
plugins/source-code-view/viewer.c | 658 ++--
plugins/source-code-view/viewer.h | 30 +-
plugins/subversion/async-command.c | 186 +-
plugins/subversion/async-command.h | 27 +-
plugins/subversion/checkout-dialog.c | 549 ++--
plugins/subversion/checkout-dialog.h | 28 +-
plugins/subversion/command.c | 109 +-
plugins/subversion/command.h | 44 +-
plugins/subversion/commit-dialog.c | 1126 ++++----
plugins/subversion/commit-dialog.h | 27 +-
plugins/subversion/diff-dialog.c | 958 +++---
plugins/subversion/diff-dialog.h | 27 +-
plugins/subversion/subversion-plugin.c | 654 ++--
plugins/subversion/subversion-plugin.h | 25 +-
plugins/subversion/subversion-utils.c | 196 +-
plugins/subversion/subversion-utils.h | 14 +-
plugins/subversion/svn-add-command.c | 119 +-
plugins/subversion/svn-add-command.h | 20 +-
plugins/subversion/svn-cat-command.c | 210 +-
plugins/subversion/svn-cat-command.h | 21 +-
plugins/subversion/svn-checkout-command.c | 134 +-
plugins/subversion/svn-checkout-command.h | 20 +-
plugins/subversion/svn-command.c | 1142 ++++----
plugins/subversion/svn-command.h | 38 +-
plugins/subversion/svn-commit-command.c | 212 +-
plugins/subversion/svn-commit-command.h | 22 +-
plugins/subversion/svn-diff-command.c | 317 +-
plugins/subversion/svn-diff-command.h | 30 +-
plugins/subversion/svn-resolve-command.c | 109 +-
plugins/subversion/svn-resolve-command.h | 20 +-
plugins/subversion/svn-status-command.c | 224 +-
plugins/subversion/svn-status-command.h | 24 +-
plugins/subversion/svn-status.c | 110 +-
plugins/subversion/svn-status.h | 23 +-
plugins/subversion/svn-update-command.c | 166 +-
plugins/subversion/svn-update-command.h | 22 +-
plugins/subversion/update-dialog.c | 477 ++--
plugins/subversion/update-dialog.h | 27 +-
plugins/subversion/vcs-status-tree-view.c | 558 ++--
plugins/subversion/vcs-status-tree-view.h | 67 +-
src/actions-documents.c | 20 +-
src/actions-edit.c | 180 +-
src/actions-file.c | 1358 ++++----
src/actions-go.c | 203 +-
src/actions-help.c | 137 +-
src/actions-search.c | 1206 ++++----
src/actions-view.c | 36 +-
src/actions.h | 172 +-
src/application.c | 598 ++--
src/application.h | 87 +-
src/context.c | 179 +-
src/context.h | 33 +-
src/debug.h | 8 +-
src/dialogs/assistant.c | 1454 +++++-----
src/dialogs/assistant.h | 27 +-
src/dialogs/close-confirmation-dialog.c | 938 +++---
src/dialogs/close-confirmation-dialog.h | 51 +-
src/dialogs/comment-dialog.c | 255 +-
src/dialogs/comment-dialog.h | 28 +-
src/dialogs/file-dialogs.c | 88 +-
src/dialogs/file-dialogs.h | 15 +-
src/dialogs/header-dialog.c | 659 ++--
src/dialogs/header-dialog.h | 24 +-
src/dialogs/jump-dialog.c | 265 +-
src/dialogs/jump-dialog.h | 27 +-
src/dialogs/preferences-dialog.c | 1822 ++++++------
src/dialogs/preferences-dialog.h | 50 +-
src/dialogs/profile-dialog.c | 899 +++---
src/dialogs/profile-dialog.h | 39 +-
src/dialogs/search-dialog.c | 1044 ++++---
src/dialogs/search-dialog.h | 132 +-
src/header.c | 543 ++--
src/header.h | 161 +-
src/history-entry.c | 799 +++---
src/history-entry.h | 68 +-
src/io-error-message-area.c | 140 +-
src/io-error-message-area.h | 6 +-
src/main.c | 344 +-
src/message-area.c | 608 ++--
src/message-area.h | 111 +-
src/message-table-model.c | 540 ++--
src/message-table-model.h | 63 +-
src/message-table.c | 639 ++--
src/message-table.h | 39 +-
src/msg.c | 510 ++--
src/msg.h | 118 +-
src/notebook.c | 411 ++--
src/notebook.h | 43 +-
src/plugin-system/module.c | 276 +-
src/plugin-system/module.h | 38 +-
src/plugin-system/plugin-info-priv.h | 46 +-
src/plugin-system/plugin-info.c | 487 ++--
src/plugin-system/plugin-info.h | 43 +-
src/plugin-system/plugin-manager.c | 1274 ++++----
src/plugin-system/plugin-manager.h | 28 +-
src/plugin-system/plugin.c | 89 +-
src/plugin-system/plugin.h | 86 +-
src/plugin-system/plugins-engine.c | 875 +++---
src/plugin-system/plugins-engine.h | 90 +-
src/po.c | 1625 +++++-----
src/po.h | 136 +-
src/prefs-manager-app.c | 921 +++---
src/prefs-manager-app.h | 44 +-
src/prefs-manager-private.h | 9 +-
src/prefs-manager.c | 371 ++--
src/prefs-manager.h | 101 +-
src/profile.c | 383 ++-
src/profile.h | 131 +-
src/statusbar.c | 363 ++--
src/statusbar.h | 74 +-
src/tab.c | 2355 +++++++-------
src/tab.h | 149 +-
src/toolbareditor/egg-editable-toolbar.c | 928 +++---
src/toolbareditor/egg-editable-toolbar.h | 69 +-
src/toolbareditor/egg-toolbar-editor.c | 256 +-
src/toolbareditor/egg-toolbar-editor.h | 17 +-
src/toolbareditor/egg-toolbars-model.c | 564 ++--
src/toolbareditor/egg-toolbars-model.h | 179 +-
src/translation-memory/berkeley/berkeley.c | 956 +++---
src/translation-memory/berkeley/berkeley.h | 27 +-
src/translation-memory/berkeley/db-base.c | 245 +-
src/translation-memory/berkeley/db-base.h | 52 +-
src/translation-memory/berkeley/db-keys.c | 102 +-
src/translation-memory/berkeley/db-keys.h | 37 +-
src/translation-memory/berkeley/db-orig.c | 123 +-
src/translation-memory/berkeley/db-orig.h | 39 +-
src/translation-memory/berkeley/db-trans.c | 334 +-
src/translation-memory/berkeley/db-trans.h | 48 +-
src/translation-memory/berkeley/db-words.c | 271 +-
src/translation-memory/berkeley/db-words.h | 44 +-
src/translation-memory/translation-memory-ui.c | 440 ++--
src/translation-memory/translation-memory-ui.h | 32 +-
src/translation-memory/translation-memory.c | 140 +-
src/translation-memory/translation-memory.h | 69 +-
src/utils.c | 1449 +++++-----
src/utils.h | 107 +-
src/view.c | 1021 +++---
src/view.h | 73 +-
src/window.c | 3289 ++++++++++----------
src/window.h | 114 +-
168 files changed, 26905 insertions(+), 27048 deletions(-)
---
diff --git a/plugins/alternate-language/alternate-language-panel.c b/plugins/alternate-language/alternate-language-panel.c
index c19fc08..ffb2e80 100644
--- a/plugins/alternate-language/alternate-language-panel.c
+++ b/plugins/alternate-language/alternate-language-panel.c
@@ -41,338 +41,332 @@
GTR_TYPE_ALTERNATE_LANG_PANEL, \
GtranslatorAlternateLangPanelPrivate))
-GTR_PLUGIN_DEFINE_TYPE(GtranslatorAlternateLangPanel, gtranslator_alternate_lang_panel, GTK_TYPE_VBOX)
+GTR_PLUGIN_DEFINE_TYPE (GtranslatorAlternateLangPanel,
+ gtranslator_alternate_lang_panel, GTK_TYPE_VBOX)
+ struct _GtranslatorAlternateLangPanelPrivate
+ {
+ GtkWidget *open_button;
+ GtkWidget *close_button;
+ GtkWidget *textview;
+ GtkWidget *status;
-struct _GtranslatorAlternateLangPanelPrivate
-{
- GtkWidget *open_button;
- GtkWidget *close_button;
- GtkWidget *textview;
-
- GtkWidget *status;
-
- GtranslatorPo *po;
- GtranslatorMsg *first;
- GtranslatorTab *tab;
-};
+ GtranslatorPo *po;
+ GtranslatorMsg *first;
+ GtranslatorTab *tab;
+ };
-static void
-gtranslator_alternate_lang_panel_set_text (GtranslatorAlternateLangPanel *panel,
- const gchar *text)
+ static void
+ gtranslator_alternate_lang_panel_set_text
+ (GtranslatorAlternateLangPanel * panel, const gchar * text)
{
- GtkTextBuffer *buf;
-
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->textview));
-
- gtk_text_buffer_set_text (buf, text, -1);
+ GtkTextBuffer *buf;
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->textview));
+
+ gtk_text_buffer_set_text (buf, text, -1);
}
static void
-search_message (GtranslatorAlternateLangPanel *panel,
- GtranslatorMsg *msg)
+search_message (GtranslatorAlternateLangPanel * panel, GtranslatorMsg * msg)
{
- GList *messages;
- GList *l;
- const gchar *msgid = gtranslator_msg_get_msgid (msg);
- gchar *msgid_collate;
- const gchar *string;
- gchar *string_collate;
- GtranslatorMsgStatus status;
-
- msgid_collate = g_utf8_collate_key (msgid, -1);
- messages = gtranslator_po_get_messages (panel->priv->po);
- l = messages;
- do
+ GList *messages;
+ GList *l;
+ const gchar *msgid = gtranslator_msg_get_msgid (msg);
+ gchar *msgid_collate;
+ const gchar *string;
+ gchar *string_collate;
+ GtranslatorMsgStatus status;
+
+ msgid_collate = g_utf8_collate_key (msgid, -1);
+ messages = gtranslator_po_get_messages (panel->priv->po);
+ l = messages;
+ do
+ {
+ string = gtranslator_msg_get_msgid (l->data);
+ string_collate = g_utf8_collate_key (string, -1);
+ if (strcmp (string_collate, msgid_collate) == 0)
{
- string = gtranslator_msg_get_msgid (l->data);
- string_collate = g_utf8_collate_key (string, -1);
- if (strcmp (string_collate, msgid_collate) == 0)
- {
- gtranslator_alternate_lang_panel_set_text (panel,
- gtranslator_msg_get_msgstr (l->data));
- status = gtranslator_msg_get_status (GTR_MSG (l->data));
- switch (status)
- {
- case GTR_MSG_STATUS_TRANSLATED:
- gtk_image_clear (GTK_IMAGE (panel->priv->status));
- break;
- case GTR_MSG_STATUS_FUZZY:
- gtk_image_set_from_stock (GTK_IMAGE (panel->priv->status),
- FUZZY_ICON,
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- break;
- default: break;
- }
-
- g_free (string_collate);
- g_free (msgid_collate);
- return;
- }
- g_free (string_collate);
- } while ((l = g_list_next (l)));
-
- g_free (msgid_collate);
- gtranslator_alternate_lang_panel_set_text (panel,
- _("Message not found"));
-
- /*
- * If we are here the status is untranslated
- */
- gtk_image_set_from_stock (GTK_IMAGE (panel->priv->status),
- UNTRANSLATED_ICON,
- GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtranslator_alternate_lang_panel_set_text (panel,
+ gtranslator_msg_get_msgstr
+ (l->data));
+ status = gtranslator_msg_get_status (GTR_MSG (l->data));
+ switch (status)
+ {
+ case GTR_MSG_STATUS_TRANSLATED:
+ gtk_image_clear (GTK_IMAGE (panel->priv->status));
+ break;
+ case GTR_MSG_STATUS_FUZZY:
+ gtk_image_set_from_stock (GTK_IMAGE (panel->priv->status),
+ FUZZY_ICON,
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ break;
+ default:
+ break;
+ }
+
+ g_free (string_collate);
+ g_free (msgid_collate);
+ return;
+ }
+ g_free (string_collate);
+ }
+ while ((l = g_list_next (l)));
+
+ g_free (msgid_collate);
+ gtranslator_alternate_lang_panel_set_text (panel, _("Message not found"));
+
+ /*
+ * If we are here the status is untranslated
+ */
+ gtk_image_set_from_stock (GTK_IMAGE (panel->priv->status),
+ UNTRANSLATED_ICON, GTK_ICON_SIZE_SMALL_TOOLBAR);
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorAlternateLangPanel *panel)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg,
+ GtranslatorAlternateLangPanel * panel)
{
- if (panel->priv->po == NULL)
- {
- panel->priv->first = msg;
- return;
- }
- search_message (panel, msg);
+ if (panel->priv->po == NULL)
+ {
+ panel->priv->first = msg;
+ return;
+ }
+ search_message (panel, msg);
}
static void
-open_file (GtkWidget *dialog,
- GtranslatorAlternateLangPanel *panel)
+open_file (GtkWidget * dialog, GtranslatorAlternateLangPanel * panel)
{
- GError *error = NULL;
- GFile *file;
- gchar *po_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
- file = g_file_new_for_path (po_file);
- g_free (po_file);
-
- panel->priv->po = gtranslator_po_new ();
- gtranslator_po_parse (panel->priv->po, file, &error);
-
- g_object_unref (file);
-
- if (error != NULL)
- {
- GtkWidget *erdialog;
- /*
- * FIXME: We have to get the window
- */
- erdialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", error->message);
- gtk_dialog_run (GTK_DIALOG (erdialog));
- gtk_widget_destroy (erdialog);
- g_error_free (error);
- }
-
- search_message (panel, panel->priv->first);
- gtk_widget_set_sensitive (panel->priv->textview, TRUE);
-
- gtk_widget_destroy (dialog);
+ GError *error = NULL;
+ GFile *file;
+ gchar *po_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+
+ file = g_file_new_for_path (po_file);
+ g_free (po_file);
+
+ panel->priv->po = gtranslator_po_new ();
+ gtranslator_po_parse (panel->priv->po, file, &error);
+
+ g_object_unref (file);
+
+ if (error != NULL)
+ {
+ GtkWidget *erdialog;
+ /*
+ * FIXME: We have to get the window
+ */
+ erdialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (erdialog));
+ gtk_widget_destroy (erdialog);
+ g_error_free (error);
+ }
+
+ search_message (panel, panel->priv->first);
+ gtk_widget_set_sensitive (panel->priv->textview, TRUE);
+
+ gtk_widget_destroy (dialog);
}
static void
gtranslator_file_chooser_analyse (gpointer dialog,
- GtranslatorAlternateLangPanel *panel)
-{
- gint reply;
-
- reply = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (reply){
- case GTK_RESPONSE_ACCEPT:
- open_file (GTK_WIDGET (dialog),
- panel);
- break;
- case GTK_RESPONSE_CANCEL:
- gtk_widget_hide (GTK_WIDGET (dialog));
- break;
- case GTK_RESPONSE_DELETE_EVENT:
- gtk_widget_hide (GTK_WIDGET (dialog));
- break;
- default:
- break;
- }
+ GtranslatorAlternateLangPanel * panel)
+{
+ gint reply;
+
+ reply = gtk_dialog_run (GTK_DIALOG (dialog));
+ switch (reply)
+ {
+ case GTK_RESPONSE_ACCEPT:
+ open_file (GTK_WIDGET (dialog), panel);
+ break;
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_hide (GTK_WIDGET (dialog));
+ break;
+ case GTK_RESPONSE_DELETE_EVENT:
+ gtk_widget_hide (GTK_WIDGET (dialog));
+ break;
+ default:
+ break;
+ }
}
static void
-open_button_clicked_cb (GtkWidget *open_button,
- GtranslatorAlternateLangPanel *panel)
+open_button_clicked_cb (GtkWidget * open_button,
+ GtranslatorAlternateLangPanel * panel)
{
- GtkWidget *dialog = NULL;
- gchar *dir;
- GtranslatorPo *tab_po;
- GFile *location, *parent;
-
- if(dialog != NULL) {
- gtk_window_present(GTK_WINDOW(dialog));
- return;
- }
+ GtkWidget *dialog = NULL;
+ gchar *dir;
+ GtranslatorPo *tab_po;
+ GFile *location, *parent;
+
+ if (dialog != NULL)
+ {
+ gtk_window_present (GTK_WINDOW (dialog));
+ return;
+ }
+
+ /*
+ * I need a way here to get the window
+ */
+ dialog = gtranslator_file_chooser_new (NULL,
+ FILESEL_OPEN,
+ _
+ ("Open file for alternate language"),
+ NULL);
+
+ tab_po = gtranslator_tab_get_po (panel->priv->tab);
+ location = gtranslator_po_get_location (tab_po);
+ parent = g_file_get_parent (location);
+ g_object_unref (location);
+
+ dir = g_file_get_path (parent);
+ g_object_unref (parent);
- /*
- * I need a way here to get the window
- */
- dialog = gtranslator_file_chooser_new (NULL,
- FILESEL_OPEN,
- _("Open file for alternate language"),
- NULL);
-
- tab_po = gtranslator_tab_get_po (panel->priv->tab);
- location = gtranslator_po_get_location (tab_po);
- parent = g_file_get_parent (location);
- g_object_unref (location);
-
- dir = g_file_get_path (parent);
- g_object_unref (parent);
-
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir);
- g_free (dir);
-
- gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
-
- gtranslator_file_chooser_analyse((gpointer) dialog, panel);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir);
+ g_free (dir);
+
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ gtranslator_file_chooser_analyse ((gpointer) dialog, panel);
}
static void
-close_button_clicked_cb (GtkWidget *close_button,
- GtranslatorAlternateLangPanel *panel)
+close_button_clicked_cb (GtkWidget * close_button,
+ GtranslatorAlternateLangPanel * panel)
{
- if(panel->priv->po != NULL)
- {
- gtranslator_alternate_lang_panel_set_text (panel, _("File closed"));
-
- gtk_widget_set_sensitive (panel->priv->textview, FALSE);
-
- g_object_unref (panel->priv->po);
-
- panel->priv->po = NULL;
- }
+ if (panel->priv->po != NULL)
+ {
+ gtranslator_alternate_lang_panel_set_text (panel, _("File closed"));
+
+ gtk_widget_set_sensitive (panel->priv->textview, FALSE);
+
+ g_object_unref (panel->priv->po);
+
+ panel->priv->po = NULL;
+ }
}
static void
-gtranslator_alternate_lang_panel_draw (GtranslatorAlternateLangPanel *panel)
+gtranslator_alternate_lang_panel_draw (GtranslatorAlternateLangPanel * panel)
{
- GtkWidget *hbox;
- GtkWidget *buttonbox;
- GtkWidget *scroll;
-
- /*
- * Hbox
- */
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (panel), hbox, FALSE, TRUE, 0);
-
- /*
- * Button box
- */
- buttonbox = gtk_hbutton_box_new ();
- gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox), GTK_BUTTONBOX_START);
- gtk_widget_show (buttonbox);
-
- panel->priv->open_button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
- g_signal_connect (panel->priv->open_button,
- "clicked",
- G_CALLBACK (open_button_clicked_cb),
- panel);
- gtk_widget_show (panel->priv->open_button);
-
- panel->priv->close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
- g_signal_connect (panel->priv->close_button,
- "clicked",
- G_CALLBACK (close_button_clicked_cb),
- panel);
- gtk_widget_show (panel->priv->close_button);
-
- gtk_box_pack_start (GTK_BOX (buttonbox),
- panel->priv->open_button,
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (buttonbox),
- panel->priv->close_button,
- TRUE, TRUE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), buttonbox, FALSE, TRUE, 0);
-
- /*
- * Radio buttons
- */
- panel->priv->status = gtk_image_new ();
- gtk_widget_show (panel->priv->status);
-
- gtk_box_pack_start (GTK_BOX (hbox), panel->priv->status, FALSE, FALSE, 0);
-
- /*
- * Text view
- */
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (scroll);
-
- panel->priv->textview = gtranslator_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (panel->priv->textview),
- GTK_WRAP_WORD);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (panel->priv->textview),
- FALSE);
- gtranslator_alternate_lang_panel_set_text (panel, _("There isn't any file loaded"));
- gtk_widget_set_sensitive (panel->priv->textview, FALSE);
- gtk_widget_show (panel->priv->textview);
-
- gtk_container_add (GTK_CONTAINER (scroll),
- panel->priv->textview);
-
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
- GTK_SHADOW_IN);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gtk_box_pack_start (GTK_BOX (panel), scroll,
- TRUE, TRUE, 0);
+ GtkWidget *hbox;
+ GtkWidget *buttonbox;
+ GtkWidget *scroll;
+
+ /*
+ * Hbox
+ */
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (panel), hbox, FALSE, TRUE, 0);
+
+ /*
+ * Button box
+ */
+ buttonbox = gtk_hbutton_box_new ();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox), GTK_BUTTONBOX_START);
+ gtk_widget_show (buttonbox);
+
+ panel->priv->open_button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
+ g_signal_connect (panel->priv->open_button,
+ "clicked", G_CALLBACK (open_button_clicked_cb), panel);
+ gtk_widget_show (panel->priv->open_button);
+
+ panel->priv->close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ g_signal_connect (panel->priv->close_button,
+ "clicked", G_CALLBACK (close_button_clicked_cb), panel);
+ gtk_widget_show (panel->priv->close_button);
+
+ gtk_box_pack_start (GTK_BOX (buttonbox),
+ panel->priv->open_button, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (buttonbox),
+ panel->priv->close_button, TRUE, TRUE, 0);
+
+ gtk_box_pack_start (GTK_BOX (hbox), buttonbox, FALSE, TRUE, 0);
+
+ /*
+ * Radio buttons
+ */
+ panel->priv->status = gtk_image_new ();
+ gtk_widget_show (panel->priv->status);
+
+ gtk_box_pack_start (GTK_BOX (hbox), panel->priv->status, FALSE, FALSE, 0);
+
+ /*
+ * Text view
+ */
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scroll);
+
+ panel->priv->textview = gtranslator_view_new ();
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (panel->priv->textview),
+ GTK_WRAP_WORD);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (panel->priv->textview), FALSE);
+ gtranslator_alternate_lang_panel_set_text (panel,
+ _
+ ("There isn't any file loaded"));
+ gtk_widget_set_sensitive (panel->priv->textview, FALSE);
+ gtk_widget_show (panel->priv->textview);
+
+ gtk_container_add (GTK_CONTAINER (scroll), panel->priv->textview);
+
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_IN);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_box_pack_start (GTK_BOX (panel), scroll, TRUE, TRUE, 0);
}
static void
-gtranslator_alternate_lang_panel_init (GtranslatorAlternateLangPanel *panel)
+gtranslator_alternate_lang_panel_init (GtranslatorAlternateLangPanel * panel)
{
- panel->priv = GTR_ALTERNATE_LANG_PANEL_GET_PRIVATE (panel);
-
- gtranslator_alternate_lang_panel_draw (panel);
-
- panel->priv->po = NULL;
+ panel->priv = GTR_ALTERNATE_LANG_PANEL_GET_PRIVATE (panel);
+
+ gtranslator_alternate_lang_panel_draw (panel);
+
+ panel->priv->po = NULL;
}
static void
-gtranslator_alternate_lang_panel_finalize (GObject *object)
+gtranslator_alternate_lang_panel_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_alternate_lang_panel_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_alternate_lang_panel_parent_class)->
+ finalize (object);
}
static void
-gtranslator_alternate_lang_panel_class_init (GtranslatorAlternateLangPanelClass *klass)
+gtranslator_alternate_lang_panel_class_init
+ (GtranslatorAlternateLangPanelClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorAlternateLangPanelPrivate));
+ g_type_class_add_private (klass,
+ sizeof (GtranslatorAlternateLangPanelPrivate));
- object_class->finalize = gtranslator_alternate_lang_panel_finalize;
+ object_class->finalize = gtranslator_alternate_lang_panel_finalize;
}
/***************************** Public funcs ***********************************/
GtkWidget *
-gtranslator_alternate_lang_panel_new (GtkWidget *tab)
+gtranslator_alternate_lang_panel_new (GtkWidget * tab)
{
- GtranslatorAlternateLangPanel *panel;
- panel = g_object_new (GTR_TYPE_ALTERNATE_LANG_PANEL, NULL);
-
- panel->priv->tab = GTR_TAB (tab);
-
- g_signal_connect (tab, "showed-message",
- G_CALLBACK (showed_message_cb),
- panel);
-
- return GTK_WIDGET (panel);
+ GtranslatorAlternateLangPanel *panel;
+ panel = g_object_new (GTR_TYPE_ALTERNATE_LANG_PANEL, NULL);
+
+ panel->priv->tab = GTR_TAB (tab);
+
+ g_signal_connect (tab, "showed-message",
+ G_CALLBACK (showed_message_cb), panel);
+
+ return GTK_WIDGET (panel);
}
diff --git a/plugins/alternate-language/alternate-language-panel.h b/plugins/alternate-language/alternate-language-panel.h
index 34e51c3..a9ef696 100644
--- a/plugins/alternate-language/alternate-language-panel.h
+++ b/plugins/alternate-language/alternate-language-panel.h
@@ -23,7 +23,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -33,40 +32,43 @@ G_BEGIN_DECLS
#define GTR_IS_ALTERNATE_LANG_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_ALTERNATE_LANG_PANEL))
#define GTR_IS_ALTERNATE_LANG_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_ALTERNATE_LANG_PANEL))
#define GTR_ALTERNATE_LANG_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_ALTERNATE_LANG_PANEL, GtranslatorAlternateLangPanelClass))
-
/* Private structure type */
-typedef struct _GtranslatorAlternateLangPanelPrivate GtranslatorAlternateLangPanelPrivate;
+typedef struct _GtranslatorAlternateLangPanelPrivate
+ GtranslatorAlternateLangPanelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorAlternateLangPanel GtranslatorAlternateLangPanel;
+typedef struct _GtranslatorAlternateLangPanel GtranslatorAlternateLangPanel;
struct _GtranslatorAlternateLangPanel
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorAlternateLangPanelPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorAlternateLangPanelPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorAlternateLangPanelClass GtranslatorAlternateLangPanelClass;
+typedef struct _GtranslatorAlternateLangPanelClass
+ GtranslatorAlternateLangPanelClass;
struct _GtranslatorAlternateLangPanelClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_alternate_lang_panel_get_type (void) G_GNUC_CONST;
-GType gtranslator_alternate_lang_panel_register_type (GTypeModule * module);
-GtkWidget *gtranslator_alternate_lang_panel_new (GtkWidget *tab);
+GType
+gtranslator_alternate_lang_panel_get_type (void)
+ G_GNUC_CONST;
+ GType gtranslator_alternate_lang_panel_register_type (GTypeModule *
+ module);
+ GtkWidget *gtranslator_alternate_lang_panel_new (GtkWidget * tab);
G_END_DECLS
-
#endif /* __ALTERNATE_LANG_PANEL_H__ */
diff --git a/plugins/alternate-language/alternate-language-plugin.c b/plugins/alternate-language/alternate-language-plugin.c
index 1fa8b10..c3af84c 100644
--- a/plugins/alternate-language/alternate-language-plugin.c
+++ b/plugins/alternate-language/alternate-language-plugin.c
@@ -36,213 +36,208 @@
GTR_TYPE_MESSAGE_TABLE, \
GtranslatorAlternateLangPluginPrivate))
-GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorAlternateLangPlugin, gtranslator_alternate_lang_plugin,
- gtranslator_alternate_lang_panel_register_type (module);
-)
-
-static void
-on_alternate_lang_activated (GtkAction *action,
- GtranslatorWindow *window)
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorAlternateLangPlugin,
+ gtranslator_alternate_lang_plugin,
+ gtranslator_alternate_lang_panel_register_type
+ (module);)
+ static void on_alternate_lang_activated (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *tab;
- GtkWidget *alternatelang;
-
- tab = gtranslator_window_get_active_tab (window);
- alternatelang = g_object_get_data (G_OBJECT (tab), TAB_DATA_KEY);
-
- gtranslator_tab_show_lateral_panel_widget (GTR_TAB (tab),
- alternatelang);
+ GtranslatorTab *tab;
+ GtkWidget *alternatelang;
+
+ tab = gtranslator_window_get_active_tab (window);
+ alternatelang = g_object_get_data (G_OBJECT (tab), TAB_DATA_KEY);
+
+ gtranslator_tab_show_lateral_panel_widget (GTR_TAB (tab), alternatelang);
}
-static const GtkActionEntry action_entries[] =
-{
- { "AlternateLang", NULL, N_("_Alternate Language"), "<control>L",
- N_("Show the Alternate Language panel"),
- G_CALLBACK (on_alternate_lang_activated)},
+static const GtkActionEntry action_entries[] = {
+ {"AlternateLang", NULL, N_("_Alternate Language"), "<control>L",
+ N_("Show the Alternate Language panel"),
+ G_CALLBACK (on_alternate_lang_activated)},
};
typedef struct
{
- GtkActionGroup *action_group;
- guint ui_id;
+ GtkActionGroup *action_group;
+ guint ui_id;
} WindowData;
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != NULL);
- g_free (data);
+ g_free (data);
}
static void
-update_ui_real (GtranslatorWindow *window,
- WindowData *data)
+update_ui_real (GtranslatorWindow * window, WindowData * data)
{
- GtranslatorTab *tab;
- GtkAction *action;
+ GtranslatorTab *tab;
+ GtkAction *action;
- tab = gtranslator_window_get_active_tab (window);
+ tab = gtranslator_window_get_active_tab (window);
- action = gtk_action_group_get_action (data->action_group,
- "AlternateLang");
- gtk_action_set_sensitive (action,
- (tab != NULL));
+ action = gtk_action_group_get_action (data->action_group, "AlternateLang");
+ gtk_action_set_sensitive (action, (tab != NULL));
}
static void
-gtranslator_alternate_lang_plugin_init (GtranslatorAlternateLangPlugin *message_table)
+gtranslator_alternate_lang_plugin_init (GtranslatorAlternateLangPlugin *
+ message_table)
{
}
static void
-gtranslator_alternate_lang_plugin_finalize (GObject *object)
+gtranslator_alternate_lang_plugin_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_alternate_lang_plugin_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_alternate_lang_plugin_parent_class)->
+ finalize (object);
}
static void
-create_alternate_lang_plugin_panel (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- GtranslatorWindow *window)
+create_alternate_lang_plugin_panel (GtkNotebook * notebook,
+ GtkWidget * child,
+ guint page_num,
+ GtranslatorWindow * window)
{
- GtkWidget *alternatelang;
- GtranslatorPo *po;
-
- po = gtranslator_tab_get_po (GTR_TAB (child));
-
- g_return_if_fail (po != NULL);
-
- alternatelang = gtranslator_alternate_lang_panel_new (child);
- gtk_widget_show (alternatelang);
-
- gtranslator_tab_add_widget_to_lateral_panel (GTR_TAB(child),
- alternatelang,
- _("Alternate Language"));
-
- g_object_set_data (G_OBJECT (child),
- TAB_DATA_KEY,
- alternatelang);
+ GtkWidget *alternatelang;
+ GtranslatorPo *po;
+
+ po = gtranslator_tab_get_po (GTR_TAB (child));
+
+ g_return_if_fail (po != NULL);
+
+ alternatelang = gtranslator_alternate_lang_panel_new (child);
+ gtk_widget_show (alternatelang);
+
+ gtranslator_tab_add_widget_to_lateral_panel (GTR_TAB (child),
+ alternatelang,
+ _("Alternate Language"));
+
+ g_object_set_data (G_OBJECT (child), TAB_DATA_KEY, alternatelang);
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtranslatorNotebook *notebook;
- GList *tabs = NULL;
- GtkUIManager *manager;
- WindowData *data;
-
- data = g_new (WindowData, 1);
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data->action_group = gtk_action_group_new ("GtranslatorAlternateLangPluginActions");
- gtk_action_group_set_translation_domain (data->action_group,
- GETTEXT_PACKAGE);
- gtk_action_group_add_actions (data->action_group,
- action_entries,
- G_N_ELEMENTS (action_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
-
- data->ui_id = gtk_ui_manager_new_merge_id (manager);
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
-
- gtk_ui_manager_add_ui (manager,
- data->ui_id,
- MENU_PATH,
- "AlternateLang",
- "AlternateLang",
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
-
- notebook = gtranslator_window_get_notebook(window);
-
- g_signal_connect(GTK_NOTEBOOK(notebook),
- "page-added",
- G_CALLBACK(create_alternate_lang_plugin_panel), window);
-
- tabs = gtranslator_window_get_all_tabs(window);
-
- if(tabs == NULL)
- return;
- do{
- create_alternate_lang_plugin_panel(GTK_NOTEBOOK(notebook),
- tabs->data,
- 0, window);
- }while((tabs = g_list_next(tabs)));
+ GtranslatorNotebook *notebook;
+ GList *tabs = NULL;
+ GtkUIManager *manager;
+ WindowData *data;
+
+ data = g_new (WindowData, 1);
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data->action_group =
+ gtk_action_group_new ("GtranslatorAlternateLangPluginActions");
+ gtk_action_group_set_translation_domain (data->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (data->action_group, action_entries,
+ G_N_ELEMENTS (action_entries), window);
+
+ gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
+
+ data->ui_id = gtk_ui_manager_new_merge_id (manager);
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
+
+ gtk_ui_manager_add_ui (manager,
+ data->ui_id,
+ MENU_PATH,
+ "AlternateLang",
+ "AlternateLang", GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ notebook = gtranslator_window_get_notebook (window);
+
+ g_signal_connect (GTK_NOTEBOOK (notebook),
+ "page-added",
+ G_CALLBACK (create_alternate_lang_plugin_panel), window);
+
+ tabs = gtranslator_window_get_all_tabs (window);
+
+ if (tabs == NULL)
+ return;
+ do
+ {
+ create_alternate_lang_plugin_panel (GTK_NOTEBOOK (notebook),
+ tabs->data, 0, window);
+ }
+ while ((tabs = g_list_next (tabs)));
}
static void
-impl_deactivate(GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtranslatorNotebook *notebook;
- GtkWidget *alternatelang;
- GList *tabs;
- GtkUIManager *manager;
- WindowData *data;
-
- tabs = gtranslator_window_get_all_tabs (window);
- notebook = gtranslator_window_get_notebook (window);
-
- if (tabs != NULL)
+ GtranslatorNotebook *notebook;
+ GtkWidget *alternatelang;
+ GList *tabs;
+ GtkUIManager *manager;
+ WindowData *data;
+
+ tabs = gtranslator_window_get_all_tabs (window);
+ notebook = gtranslator_window_get_notebook (window);
+
+ if (tabs != NULL)
+ {
+ do
{
- do{
- alternatelang = g_object_get_data (G_OBJECT (tabs->data), TAB_DATA_KEY);
- gtranslator_tab_remove_widget_from_lateral_panel (GTR_TAB (tabs->data),
- alternatelang);
+ alternatelang =
+ g_object_get_data (G_OBJECT (tabs->data), TAB_DATA_KEY);
+ gtranslator_tab_remove_widget_from_lateral_panel (GTR_TAB
+ (tabs->data),
+ alternatelang);
- g_object_set_data (G_OBJECT (tabs->data), WINDOW_DATA_KEY, NULL);
- }while ((tabs = g_list_next (tabs)));
+ g_object_set_data (G_OBJECT (tabs->data), WINDOW_DATA_KEY, NULL);
}
-
- g_signal_handlers_disconnect_by_func (notebook,
- create_alternate_lang_plugin_panel,
- window);
-
- /* Remove menuitem */
- manager = gtranslator_window_get_ui_manager (window);
-
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
-
- gtk_ui_manager_remove_ui (manager, data->ui_id);
- gtk_ui_manager_remove_action_group (manager, data->action_group);
-
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ while ((tabs = g_list_next (tabs)));
+ }
+
+ g_signal_handlers_disconnect_by_func (notebook,
+ create_alternate_lang_plugin_panel,
+ window);
+
+ /* Remove menuitem */
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ gtk_ui_manager_remove_ui (manager, data->ui_id);
+ gtk_ui_manager_remove_action_group (manager, data->action_group);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
static void
-impl_update_ui (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_update_ui (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
+ WindowData *data;
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- update_ui_real (window, data);
+ update_ui_real (window, data);
}
static void
-gtranslator_alternate_lang_plugin_class_init (GtranslatorAlternateLangPluginClass *klass)
+gtranslator_alternate_lang_plugin_class_init
+ (GtranslatorAlternateLangPluginClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
- object_class->finalize = gtranslator_alternate_lang_plugin_finalize;
+ object_class->finalize = gtranslator_alternate_lang_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->update_ui = impl_update_ui;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
}
diff --git a/plugins/alternate-language/alternate-language-plugin.h b/plugins/alternate-language/alternate-language-plugin.h
index 5bd09e9..016b2a6 100644
--- a/plugins/alternate-language/alternate-language-plugin.h
+++ b/plugins/alternate-language/alternate-language-plugin.h
@@ -26,7 +26,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -36,38 +35,40 @@ G_BEGIN_DECLS
#define GTR_IS_ALTERNATE_LANG_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_ALTERNATE_LANG_PLUGIN))
#define GTR_IS_ALTERNATE_LANG_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_ALTERNATE_LANG_PLUGIN))
#define GTR_ALTERNATE_LANG_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_ALTERNATE_LANG_PLUGIN_PLUGIN, GtranslatorAlternateLangPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorAlternateLangPluginPrivate GtranslatorAlternateLangPluginPrivate;
+typedef struct _GtranslatorAlternateLangPluginPrivate
+ GtranslatorAlternateLangPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorAlternateLangPlugin GtranslatorAlternateLangPlugin;
+typedef struct _GtranslatorAlternateLangPlugin GtranslatorAlternateLangPlugin;
struct _GtranslatorAlternateLangPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
};
/*
* Class definition
*/
-typedef struct _GtranslatorAlternateLangPluginClass GtranslatorAlternateLangPluginClass;
+typedef struct _GtranslatorAlternateLangPluginClass
+ GtranslatorAlternateLangPluginClass;
struct _GtranslatorAlternateLangPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_alternate_lang_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_alternate_lang_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_ALTERNATE_LANG_PLUGIN_H__ */
diff --git a/plugins/charmap/charmap-panel.c b/plugins/charmap/charmap-panel.c
index bcf8503..5a64e43 100644
--- a/plugins/charmap/charmap-panel.c
+++ b/plugins/charmap/charmap-panel.c
@@ -39,160 +39,160 @@
struct _GtranslatorCharmapPanelPrivate
{
#ifdef HAVE_GUCHARMAP_2
- GucharmapChaptersView *chapters_view;
- GucharmapChartable *chartable;
+ GucharmapChaptersView *chapters_view;
+ GucharmapChartable *chartable;
#else
- GtkWidget *table;
- GtkWidget *chapters;
+ GtkWidget *table;
+ GtkWidget *chapters;
#endif
};
-GTR_PLUGIN_DEFINE_TYPE(GtranslatorCharmapPanel, gtranslator_charmap_panel, GTK_TYPE_VBOX)
-
+GTR_PLUGIN_DEFINE_TYPE (GtranslatorCharmapPanel, gtranslator_charmap_panel,
+ GTK_TYPE_VBOX)
#ifdef HAVE_GUCHARMAP_2
-static void
-on_chapter_view_selection_changed (GtkTreeSelection *selection,
- GtranslatorCharmapPanel *panel)
+ static void
+ on_chapter_view_selection_changed (GtkTreeSelection * selection,
+ GtranslatorCharmapPanel * panel)
{
- GtranslatorCharmapPanelPrivate *priv = panel->priv;
- GucharmapCodepointList *codepoint_list;
- GtkTreeIter iter;
+ GtranslatorCharmapPanelPrivate *priv = panel->priv;
+ GucharmapCodepointList *codepoint_list;
+ GtkTreeIter iter;
- if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
- return;
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+ return;
- codepoint_list = gucharmap_chapters_view_get_codepoint_list (priv->chapters_view);
- gucharmap_chartable_set_codepoint_list (priv->chartable, codepoint_list);
- g_object_unref (codepoint_list);
+ codepoint_list =
+ gucharmap_chapters_view_get_codepoint_list (priv->chapters_view);
+ gucharmap_chartable_set_codepoint_list (priv->chartable, codepoint_list);
+ g_object_unref (codepoint_list);
}
#else
-
-static void
-on_chapter_changed (GucharmapChapters *chapters,
- GtranslatorCharmapPanel *panel)
+ static void
+ on_chapter_changed (GucharmapChapters * chapters,
+ GtranslatorCharmapPanel * panel)
{
- gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
- gucharmap_chapters_get_codepoint_list (chapters));
+ gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
+ gucharmap_chapters_get_codepoint_list
+ (chapters));
}
#endif /* HAVE_GUCHARMAP_2 */
static void
-gtranslator_charmap_panel_init (GtranslatorCharmapPanel *panel)
+gtranslator_charmap_panel_init (GtranslatorCharmapPanel * panel)
{
- GtranslatorCharmapPanelPrivate *priv;
- GtkPaned *paned;
+ GtranslatorCharmapPanelPrivate *priv;
+ GtkPaned *paned;
#ifdef HAVE_GUCHARMAP_2
- GtkWidget *scrolled_window, *view, *chartable;
- GtkTreeSelection *selection;
- GucharmapChaptersModel *model;
+ GtkWidget *scrolled_window, *view, *chartable;
+ GtkTreeSelection *selection;
+ GucharmapChaptersModel *model;
#else
- GucharmapCodepointList *codepoint_list;
+ GucharmapCodepointList *codepoint_list;
#endif
- priv = panel->priv = GTR_CHARMAP_PANEL_GET_PRIVATE (panel);
+ priv = panel->priv = GTR_CHARMAP_PANEL_GET_PRIVATE (panel);
- paned = GTK_PANED (gtk_vpaned_new ());
+ paned = GTK_PANED (gtk_vpaned_new ());
#ifdef HAVE_GUCHARMAP_2
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_SHADOW_ETCHED_IN);
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_ETCHED_IN);
- view = gucharmap_chapters_view_new ();
- priv->chapters_view = GUCHARMAP_CHAPTERS_VIEW (view);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
+ view = gucharmap_chapters_view_new ();
+ priv->chapters_view = GUCHARMAP_CHAPTERS_VIEW (view);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
- model = gucharmap_script_chapters_model_new ();
- gucharmap_chapters_view_set_model (priv->chapters_view, model);
- g_object_unref (model);
+ model = gucharmap_script_chapters_model_new ();
+ gucharmap_chapters_view_set_model (priv->chapters_view, model);
+ g_object_unref (model);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
- g_signal_connect (selection, "changed",
- G_CALLBACK (on_chapter_view_selection_changed), panel);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (on_chapter_view_selection_changed), panel);
- gtk_container_add (GTK_CONTAINER (scrolled_window), view);
- gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), view);
+ gtk_widget_show (view);
- gtk_paned_pack1 (paned, scrolled_window, FALSE, TRUE);
- gtk_widget_show (scrolled_window);
+ gtk_paned_pack1 (paned, scrolled_window, FALSE, TRUE);
+ gtk_widget_show (scrolled_window);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_SHADOW_ETCHED_IN);
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_ETCHED_IN);
- chartable = gucharmap_chartable_new ();
- priv->chartable = GUCHARMAP_CHARTABLE (chartable);
- gtk_container_add (GTK_CONTAINER (scrolled_window), chartable);
- gtk_widget_show (chartable);
+ chartable = gucharmap_chartable_new ();
+ priv->chartable = GUCHARMAP_CHARTABLE (chartable);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), chartable);
+ gtk_widget_show (chartable);
- gtk_paned_pack2 (paned, scrolled_window, TRUE, TRUE);
- gtk_widget_show (scrolled_window);
+ gtk_paned_pack2 (paned, scrolled_window, TRUE, TRUE);
+ gtk_widget_show (scrolled_window);
- gucharmap_chapters_view_select_locale (priv->chapters_view);
+ gucharmap_chapters_view_select_locale (priv->chapters_view);
#else
- priv->chapters = gucharmap_script_chapters_new ();
- g_signal_connect (priv->chapters,
- "changed",
- G_CALLBACK (on_chapter_changed),
- panel);
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (GUCHARMAP_CHAPTERS (priv->chapters)->tree_view),
- FALSE);
-
- codepoint_list = gucharmap_chapters_get_codepoint_list
- (GUCHARMAP_CHAPTERS (priv->chapters));
-
- priv->table = gucharmap_table_new ();
-
- gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (priv->table),
- codepoint_list);
-
- gtk_paned_pack1 (paned, priv->chapters, FALSE, TRUE);
- gtk_paned_pack2 (paned, priv->table, TRUE, TRUE);
+ priv->chapters = gucharmap_script_chapters_new ();
+ g_signal_connect (priv->chapters,
+ "changed", G_CALLBACK (on_chapter_changed), panel);
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW
+ (GUCHARMAP_CHAPTERS (priv->chapters)->
+ tree_view), FALSE);
+
+ codepoint_list = gucharmap_chapters_get_codepoint_list
+ (GUCHARMAP_CHAPTERS (priv->chapters));
+
+ priv->table = gucharmap_table_new ();
+
+ gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (priv->table),
+ codepoint_list);
+
+ gtk_paned_pack1 (paned, priv->chapters, FALSE, TRUE);
+ gtk_paned_pack2 (paned, priv->table, TRUE, TRUE);
#endif /* HAVE_GUCHARMAP_2 */
- gtk_paned_set_position (paned, 150);
-
- gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET (paned), TRUE, TRUE, 0);
+ gtk_paned_set_position (paned, 150);
+
+ gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET (paned), TRUE, TRUE, 0);
}
static void
-gtranslator_charmap_panel_finalize (GObject *object)
+gtranslator_charmap_panel_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_charmap_panel_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_charmap_panel_parent_class)->finalize (object);
}
static void
-gtranslator_charmap_panel_class_init (GtranslatorCharmapPanelClass *klass)
+gtranslator_charmap_panel_class_init (GtranslatorCharmapPanelClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorCharmapPanelPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorCharmapPanelPrivate));
- object_class->finalize = gtranslator_charmap_panel_finalize;
+ object_class->finalize = gtranslator_charmap_panel_finalize;
}
GtkWidget *
gtranslator_charmap_panel_new (void)
{
- return GTK_WIDGET (g_object_new (GTR_TYPE_CHARMAP_PANEL, NULL));
+ return GTK_WIDGET (g_object_new (GTR_TYPE_CHARMAP_PANEL, NULL));
}
#ifdef HAVE_GUCHARMAP_2
GucharmapChartable *
-gtranslator_charmap_panel_get_chartable (GtranslatorCharmapPanel *panel)
+gtranslator_charmap_panel_get_chartable (GtranslatorCharmapPanel * panel)
{
- return panel->priv->chartable;
+ return panel->priv->chartable;
}
#else
GucharmapTable *
-gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel *panel)
+gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel * panel)
{
- return GUCHARMAP_TABLE (panel->priv->table);
+ return GUCHARMAP_TABLE (panel->priv->table);
}
#endif
diff --git a/plugins/charmap/charmap-panel.h b/plugins/charmap/charmap-panel.h
index c0d0c1a..47f6f36 100644
--- a/plugins/charmap/charmap-panel.h
+++ b/plugins/charmap/charmap-panel.h
@@ -34,7 +34,6 @@
#endif
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -44,46 +43,49 @@ G_BEGIN_DECLS
#define GTR_IS_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PANEL))
#define GTR_IS_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PANEL))
#define GTR_CHARMAP_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PANEL, GtranslatorCharmapPanelClass))
-
/* Private structure type */
-typedef struct _GtranslatorCharmapPanelPrivate GtranslatorCharmapPanelPrivate;
+typedef struct _GtranslatorCharmapPanelPrivate GtranslatorCharmapPanelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorCharmapPanel GtranslatorCharmapPanel;
+typedef struct _GtranslatorCharmapPanel GtranslatorCharmapPanel;
struct _GtranslatorCharmapPanel
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorCharmapPanelPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorCharmapPanelPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorCharmapPanelClass GtranslatorCharmapPanelClass;
+typedef struct _GtranslatorCharmapPanelClass GtranslatorCharmapPanelClass;
struct _GtranslatorCharmapPanelClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_charmap_panel_get_type (void) G_GNUC_CONST;
-GType gtranslator_charmap_panel_register_type (GTypeModule * module);
-GtkWidget *gtranslator_charmap_panel_new (void);
+GType
+gtranslator_charmap_panel_get_type (void)
+ G_GNUC_CONST;
+ GType gtranslator_charmap_panel_register_type (GTypeModule * module);
+ GtkWidget *gtranslator_charmap_panel_new (void);
#ifdef HAVE_GUCHARMAP_2
-GucharmapChartable *gtranslator_charmap_panel_get_chartable (GtranslatorCharmapPanel *panel);
+ GucharmapChartable
+ *gtranslator_charmap_panel_get_chartable (GtranslatorCharmapPanel *
+ panel);
#else
-GucharmapTable *gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel *panel);
+ GucharmapTable
+ *gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel * panel);
#endif
G_END_DECLS
-
#endif /* __CHARMAP_PANEL_H__ */
diff --git a/plugins/charmap/charmap-plugin.c b/plugins/charmap/charmap-plugin.c
index 50d1c7a..e2af84e 100644
--- a/plugins/charmap/charmap-plugin.c
+++ b/plugins/charmap/charmap-plugin.c
@@ -47,307 +47,289 @@
typedef struct
{
- GtkWidget *panel;
- guint context_id;
+ GtkWidget *panel;
+ guint context_id;
} WindowData;
-GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorCharmapPlugin, gtranslator_charmap_plugin,
- gtranslator_charmap_panel_register_type (module);
-)
-
-static void
-gtranslator_charmap_plugin_init (GtranslatorCharmapPlugin *plugin)
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorCharmapPlugin,
+ gtranslator_charmap_plugin,
+ gtranslator_charmap_panel_register_type
+ (module);)
+ static void gtranslator_charmap_plugin_init (GtranslatorCharmapPlugin *
+ plugin)
{
- //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorCharmapPlugin initializing");
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorCharmapPlugin initializing");
}
static void
-gtranslator_charmap_plugin_finalize (GObject *object)
+gtranslator_charmap_plugin_finalize (GObject * object)
{
- //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorCharmapPlugin finalizing");
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorCharmapPlugin finalizing");
- G_OBJECT_CLASS (gtranslator_charmap_plugin_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_charmap_plugin_parent_class)->finalize (object);
}
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_slice_free (WindowData, data);
+ g_slice_free (WindowData, data);
}
static void
#ifdef HAVE_GUCHARMAP_2
-on_table_status_message (GucharmapChartable *chartable,
+ on_table_status_message (GucharmapChartable * chartable,
#else
-on_table_status_message (GucharmapTable *chartable,
+on_table_status_message (GucharmapTable * chartable,
#endif
- const gchar *message,
- GtranslatorWindow *window)
+ const gchar * message, GtranslatorWindow * window)
{
- GtranslatorStatusbar *statusbar;
- WindowData *data;
+ GtranslatorStatusbar *statusbar;
+ WindowData *data;
- statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- gtranslator_statusbar_pop (statusbar, data->context_id);
+ gtranslator_statusbar_pop (statusbar, data->context_id);
- if (message)
- gtranslator_statusbar_push (statusbar, data->context_id, message);
+ if (message)
+ gtranslator_statusbar_push (statusbar, data->context_id, message);
}
static void
#ifdef HAVE_GUCHARMAP_2
-on_table_sync_active_char (GucharmapChartable *chartable,
- GParamSpec *psepc,
- GtranslatorWindow *window)
+on_table_sync_active_char (GucharmapChartable * chartable,
+ GParamSpec * psepc, GtranslatorWindow * window)
#else
-on_table_set_active_char (GucharmapTable *chartable,
- gunichar wc,
- GtranslatorWindow *window)
+on_table_set_active_char (GucharmapTable * chartable,
+ gunichar wc, GtranslatorWindow * window)
#endif
{
- GString *gs;
- const gchar **temps;
- gint i;
+ GString *gs;
+ const gchar **temps;
+ gint i;
#ifdef HAVE_GUCHARMAP_2
- gunichar wc;
+ gunichar wc;
- wc = gucharmap_chartable_get_active_character (chartable);
+ wc = gucharmap_chartable_get_active_character (chartable);
#endif
- gs = g_string_new (NULL);
- g_string_append_printf (gs, "U+%4.4X %s", wc,
- gucharmap_get_unicode_name (wc));
-
- temps = gucharmap_get_nameslist_equals (wc);
- if (temps)
- {
- g_string_append_printf (gs, " = %s", temps[0]);
- for (i = 1; temps[i]; i++)
- g_string_append_printf (gs, "; %s", temps[i]);
- g_free (temps);
- }
-
- temps = gucharmap_get_nameslist_stars (wc);
- if (temps)
- {
- g_string_append_printf (gs, " \342\200\242 %s", temps[0]);
- for (i = 1; temps[i]; i++)
- g_string_append_printf (gs, "; %s", temps[i]);
- g_free (temps);
- }
-
- on_table_status_message (chartable, gs->str, window);
- g_string_free (gs, TRUE);
+ gs = g_string_new (NULL);
+ g_string_append_printf (gs, "U+%4.4X %s", wc,
+ gucharmap_get_unicode_name (wc));
+
+ temps = gucharmap_get_nameslist_equals (wc);
+ if (temps)
+ {
+ g_string_append_printf (gs, " = %s", temps[0]);
+ for (i = 1; temps[i]; i++)
+ g_string_append_printf (gs, "; %s", temps[i]);
+ g_free (temps);
+ }
+
+ temps = gucharmap_get_nameslist_stars (wc);
+ if (temps)
+ {
+ g_string_append_printf (gs, " \342\200\242 %s", temps[0]);
+ for (i = 1; temps[i]; i++)
+ g_string_append_printf (gs, "; %s", temps[i]);
+ g_free (temps);
+ }
+
+ on_table_status_message (chartable, gs->str, window);
+ g_string_free (gs, TRUE);
}
static gboolean
-on_table_focus_out_event (GtkWidget *drawing_area,
- GdkEventFocus *event,
- GtranslatorWindow *window)
+on_table_focus_out_event (GtkWidget * drawing_area,
+ GdkEventFocus * event, GtranslatorWindow * window)
{
#ifdef HAVE_GUCHARMAP_2
- GucharmapChartable *chartable;
+ GucharmapChartable *chartable;
#else
- GucharmapTable *chartable;
+ GucharmapTable *chartable;
#endif
- WindowData *data;
-
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_val_if_fail (data != NULL, FALSE);
+ WindowData *data;
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_val_if_fail (data != NULL, FALSE);
#ifdef HAVE_GUCHARMAP_2
- chartable = gtranslator_charmap_panel_get_chartable
- (GTR_CHARMAP_PANEL (data->panel));
+ chartable = gtranslator_charmap_panel_get_chartable
+ (GTR_CHARMAP_PANEL (data->panel));
#else
- chartable = gtranslator_charmap_panel_get_table
- (GTR_CHARMAP_PANEL (data->panel));
+ chartable = gtranslator_charmap_panel_get_table
+ (GTR_CHARMAP_PANEL (data->panel));
#endif
- on_table_status_message (chartable, NULL, window);
- return FALSE;
+ on_table_status_message (chartable, NULL, window);
+ return FALSE;
}
#ifdef HAVE_GUCHARMAP_2
static void
-on_table_activate (GucharmapChartable *chartable,
- GtranslatorWindow *window)
+on_table_activate (GucharmapChartable * chartable, GtranslatorWindow * window)
#else
static void
-on_table_activate (GucharmapTable *chartable,
- gunichar wc,
- GtranslatorWindow *window)
+on_table_activate (GucharmapTable * chartable,
+ gunichar wc, GtranslatorWindow * window)
#endif
{
- GtkTextView *view;
- GtkTextBuffer *document;
- GtkTextIter start, end;
- gchar buffer[6];
- gchar length;
+ GtkTextView *view;
+ GtkTextBuffer *document;
+ GtkTextIter start, end;
+ gchar buffer[6];
+ gchar length;
#ifdef HAVE_GUCHARMAP_2
- gunichar wc;
+ gunichar wc;
- wc = gucharmap_chartable_get_active_character (chartable);
+ wc = gucharmap_chartable_get_active_character (chartable);
#endif
-
- g_return_if_fail (gucharmap_unichar_validate (wc));
-
- view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
-
- if (!view || !gtk_text_view_get_editable (view))
- return;
-
- document = gtk_text_view_get_buffer (view);
-
- g_return_if_fail (document != NULL);
-
- length = g_unichar_to_utf8 (wc, buffer);
-
- gtk_text_buffer_begin_user_action (document);
-
- gtk_text_buffer_get_selection_bounds (document, &start, &end);
-
- gtk_text_buffer_delete_interactive (document, &start, &end, TRUE);
- if (gtk_text_iter_editable (&start, TRUE))
- gtk_text_buffer_insert (document, &start, buffer, length);
-
- gtk_text_buffer_end_user_action (document);
+
+ g_return_if_fail (gucharmap_unichar_validate (wc));
+
+ view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
+
+ if (!view || !gtk_text_view_get_editable (view))
+ return;
+
+ document = gtk_text_view_get_buffer (view);
+
+ g_return_if_fail (document != NULL);
+
+ length = g_unichar_to_utf8 (wc, buffer);
+
+ gtk_text_buffer_begin_user_action (document);
+
+ gtk_text_buffer_get_selection_bounds (document, &start, &end);
+
+ gtk_text_buffer_delete_interactive (document, &start, &end, TRUE);
+ if (gtk_text_iter_editable (&start, TRUE))
+ gtk_text_buffer_insert (document, &start, buffer, length);
+
+ gtk_text_buffer_end_user_action (document);
}
static GtkWidget *
-create_charmap_panel (GtranslatorWindow *window)
+create_charmap_panel (GtranslatorWindow * window)
{
- GtkWidget *panel;
+ GtkWidget *panel;
#ifdef HAVE_GUCHARMAP_2
- GucharmapChartable *chartable;
+ GucharmapChartable *chartable;
#else
- GucharmapTable *table;
+ GucharmapTable *table;
#endif
- panel = gtranslator_charmap_panel_new ();
+ panel = gtranslator_charmap_panel_new ();
#ifdef HAVE_GUCHARMAP_2
- chartable = gtranslator_charmap_panel_get_chartable (GTR_CHARMAP_PANEL (panel));
+ chartable =
+ gtranslator_charmap_panel_get_chartable (GTR_CHARMAP_PANEL (panel));
#else
- table = gtranslator_charmap_panel_get_table (GTR_CHARMAP_PANEL (panel));
+ table = gtranslator_charmap_panel_get_table (GTR_CHARMAP_PANEL (panel));
#endif
#ifdef HAVE_GUCHARMAP_2
- g_signal_connect (chartable,
- "notify::active-character",
- G_CALLBACK (on_table_sync_active_char),
- window);
- g_signal_connect (chartable,
- "focus-out-event",
- G_CALLBACK (on_table_focus_out_event),
- window);
- g_signal_connect (chartable,
- "status-message",
- G_CALLBACK (on_table_status_message),
- window);
- g_signal_connect (chartable,
- "activate",
- G_CALLBACK (on_table_activate),
- window);
+ g_signal_connect (chartable,
+ "notify::active-character",
+ G_CALLBACK (on_table_sync_active_char), window);
+ g_signal_connect (chartable,
+ "focus-out-event",
+ G_CALLBACK (on_table_focus_out_event), window);
+ g_signal_connect (chartable,
+ "status-message",
+ G_CALLBACK (on_table_status_message), window);
+ g_signal_connect (chartable,
+ "activate", G_CALLBACK (on_table_activate), window);
#else
- g_signal_connect (table,
- "set-active-char",
- G_CALLBACK (on_table_set_active_char),
- window);
- /* Note: GucharmapTable does not provide focus-out-event ... */
- g_signal_connect (table->drawing_area,
- "focus-out-event",
- G_CALLBACK (on_table_focus_out_event),
- window);
- g_signal_connect (table,
- "status-message",
- G_CALLBACK (on_table_status_message),
- window);
- g_signal_connect (table,
- "activate",
- G_CALLBACK (on_table_activate),
- window);
+ g_signal_connect (table,
+ "set-active-char",
+ G_CALLBACK (on_table_set_active_char), window);
+ /* Note: GucharmapTable does not provide focus-out-event ... */
+ g_signal_connect (table->drawing_area,
+ "focus-out-event",
+ G_CALLBACK (on_table_focus_out_event), window);
+ g_signal_connect (table,
+ "status-message",
+ G_CALLBACK (on_table_status_message), window);
+ g_signal_connect (table,
+ "activate", G_CALLBACK (on_table_activate), window);
#endif /* HAVE_GUCHARMAP_2 */
- gtk_widget_show_all (panel);
+ gtk_widget_show_all (panel);
- return panel;
+ return panel;
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtranslatorStatusbar *statusbar;
- WindowData *data;
-
- data = g_new (WindowData, 1);
-
- gtranslator_application_register_icon (GTR_APP, "gucharmap.ico",
- "charmap-plugin-icon");
-
- data->panel = create_charmap_panel (window);
-
- gtranslator_window_add_widget (window,
- data->panel,
- "GtranslatorCharmapPlugin",
- _("Character Map"),
- "charmap-plugin-icon",
- GTR_WINDOW_PLACEMENT_LEFT);
-
- statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- data->context_id = gtranslator_statusbar_get_context_id (statusbar,
- "Character Description");
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
+ GtranslatorStatusbar *statusbar;
+ WindowData *data;
+
+ data = g_new (WindowData, 1);
+
+ gtranslator_application_register_icon (GTR_APP, "gucharmap.ico",
+ "charmap-plugin-icon");
+
+ data->panel = create_charmap_panel (window);
+
+ gtranslator_window_add_widget (window,
+ data->panel,
+ "GtranslatorCharmapPlugin",
+ _("Character Map"),
+ "charmap-plugin-icon",
+ GTR_WINDOW_PLACEMENT_LEFT);
+
+ statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ data->context_id = gtranslator_statusbar_get_context_id (statusbar,
+ "Character Description");
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
}
static void
-impl_deactivate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
+ WindowData *data;
#ifdef HAVE_GUCHARMAP_2
- GucharmapChartable *chartable;
+ GucharmapChartable *chartable;
#else
- GucharmapTable *chartable;
+ GucharmapTable *chartable;
#endif
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
#ifdef HAVE_GUCHARMAP_2
- chartable = gtranslator_charmap_panel_get_chartable
- (GTR_CHARMAP_PANEL (data->panel));
+ chartable = gtranslator_charmap_panel_get_chartable
+ (GTR_CHARMAP_PANEL (data->panel));
#else
- chartable = gtranslator_charmap_panel_get_table
- (GTR_CHARMAP_PANEL (data->panel));
+ chartable = gtranslator_charmap_panel_get_table
+ (GTR_CHARMAP_PANEL (data->panel));
#endif
- on_table_status_message (chartable, NULL, window);
+ on_table_status_message (chartable, NULL, window);
+
+ gtranslator_window_remove_widget (window, data->panel);
- gtranslator_window_remove_widget (window, data->panel);
-
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
static void
-gtranslator_charmap_plugin_class_init (GtranslatorCharmapPluginClass *klass)
+gtranslator_charmap_plugin_class_init (GtranslatorCharmapPluginClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
- object_class->finalize = gtranslator_charmap_plugin_finalize;
+ object_class->finalize = gtranslator_charmap_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
}
diff --git a/plugins/charmap/charmap-plugin.h b/plugins/charmap/charmap-plugin.h
index cbc8009..aab9d1d 100644
--- a/plugins/charmap/charmap-plugin.h
+++ b/plugins/charmap/charmap-plugin.h
@@ -28,7 +28,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -38,38 +37,39 @@ G_BEGIN_DECLS
#define GTR_IS_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PLUGIN))
#define GTR_IS_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PLUGIN))
#define GTR_CHARMAP_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PLUGIN, GtranslatorCharmapPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorCharmapPluginPrivate GtranslatorCharmapPluginPrivate;
+typedef struct _GtranslatorCharmapPluginPrivate
+ GtranslatorCharmapPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorCharmapPlugin GtranslatorCharmapPlugin;
+typedef struct _GtranslatorCharmapPlugin GtranslatorCharmapPlugin;
struct _GtranslatorCharmapPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
};
/*
* Class definition
*/
-typedef struct _GtranslatorCharmapPluginClass GtranslatorCharmapPluginClass;
+typedef struct _GtranslatorCharmapPluginClass GtranslatorCharmapPluginClass;
struct _GtranslatorCharmapPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_charmap_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_charmap_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_CHARMAP_PLUGIN_H__ */
diff --git a/plugins/dictionary/dict-panel.c b/plugins/dictionary/dict-panel.c
index 0be3f77..b7a616c 100644
--- a/plugins/dictionary/dict-panel.c
+++ b/plugins/dictionary/dict-panel.c
@@ -52,675 +52,684 @@
#define GDICT_SIDEBAR_STRATEGIES_PAGE "strat-chooser"
#define GDICT_SIDEBAR_SOURCES_PAGE "source-chooser"
-GTR_PLUGIN_DEFINE_TYPE(GtranslatorDictPanel, gtranslator_dict_panel, GTK_TYPE_VBOX)
-
-struct _GtranslatorDictPanelPrivate
+GTR_PLUGIN_DEFINE_TYPE (GtranslatorDictPanel, gtranslator_dict_panel,
+ GTK_TYPE_VBOX)
+ struct _GtranslatorDictPanelPrivate
+ {
+ GtkPaned *paned;
+ GtranslatorStatusbar *status;
+
+ GConfClient *gconf_client;
+ guint notify_id;
+
+ gchar *database;
+ gchar *strategy;
+ gchar *source_name;
+
+ gchar *word;
+ GdictContext *context;
+
+ GdictSourceLoader *loader;
+
+ GtkWidget *speller;
+ GtkWidget *db_chooser;
+ GtkWidget *strat_chooser;
+ GtkWidget *source_chooser;
+ GtkWidget *entry;
+ GtkWidget *button;
+ GtkWidget *defbox;
+ GtkWidget *sidebar;
+ };
+
+ static void
+ gtranslator_dict_panel_create_warning_dialog (const gchar * primary,
+ const gchar * secondary)
{
- GtkPaned *paned;
- GtranslatorStatusbar *status;
-
- GConfClient *gconf_client;
- guint notify_id;
-
- gchar *database;
- gchar *strategy;
- gchar *source_name;
-
- gchar *word;
- GdictContext *context;
-
- GdictSourceLoader *loader;
-
- GtkWidget *speller;
- GtkWidget *db_chooser;
- GtkWidget *strat_chooser;
- GtkWidget *source_chooser;
- GtkWidget *entry;
- GtkWidget *button;
- GtkWidget *defbox;
- GtkWidget *sidebar;
-};
+ GtkWidget *dialog;
-static void
-gtranslator_dict_panel_create_warning_dialog (const gchar *primary,
- const gchar *secondary)
-{
- GtkWidget *dialog;
-
- if (!primary)
- return;
-
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- "%s", primary);
-
- if (secondary)
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", secondary);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ if (!primary)
+ return;
+
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE, "%s", primary);
+
+ if (secondary)
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", secondary);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
static gchar *
-gdict_gconf_get_string_with_default (GConfClient *client,
- const gchar *key,
- const gchar *def)
+gdict_gconf_get_string_with_default (GConfClient * client,
+ const gchar * key, const gchar * def)
{
- gchar *val;
-
- val = gconf_client_get_string (client, key, NULL);
- return val ? val : g_strdup (def);
+ gchar *val;
+
+ val = gconf_client_get_string (client, key, NULL);
+ return val ? val : g_strdup (def);
}
static void
-gtranslator_dict_panel_entry_activate_cb (GtkWidget *widget,
- GtranslatorDictPanel *panel)
+gtranslator_dict_panel_entry_activate_cb (GtkWidget * widget,
+ GtranslatorDictPanel * panel)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- const gchar *text;
-
- text = gtk_entry_get_text (GTK_ENTRY(priv->entry));
-
- if (!text)
- return;
-
- g_free (priv->word);
- priv->word = g_strdup(text);
-
- gdict_defbox_lookup (GDICT_DEFBOX (priv->defbox), priv->word);
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ const gchar *text;
+
+ text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+
+ if (!text)
+ return;
+
+ g_free (priv->word);
+ priv->word = g_strdup (text);
+
+ gdict_defbox_lookup (GDICT_DEFBOX (priv->defbox), priv->word);
}
static void
-gtranslator_dict_panel_set_database (GtranslatorDictPanel *panel,
- const gchar *database)
+gtranslator_dict_panel_set_database (GtranslatorDictPanel * panel,
+ const gchar * database)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
-
- g_free (priv->database);
-
- if (database)
- priv->database = g_strdup (database);
- else
- priv->database = gdict_gconf_get_string_with_default (priv->gconf_client,
- DICTIONARY_GCONF_DATABASE_KEY,
- GDICT_DEFAULT_DATABASE);
- if (priv->defbox)
- gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox),
- priv->database);
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ g_free (priv->database);
+
+ if (database)
+ priv->database = g_strdup (database);
+ else
+ priv->database = gdict_gconf_get_string_with_default (priv->gconf_client,
+ DICTIONARY_GCONF_DATABASE_KEY,
+ GDICT_DEFAULT_DATABASE);
+ if (priv->defbox)
+ gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox), priv->database);
}
static void
-gtranslator_dict_panel_set_strategy (GtranslatorDictPanel *panel,
- const gchar *strategy)
+gtranslator_dict_panel_set_strategy (GtranslatorDictPanel * panel,
+ const gchar * strategy)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
-
- g_free (priv->strategy);
-
- if (strategy)
- priv->strategy = g_strdup (strategy);
- else
- priv->strategy = gdict_gconf_get_string_with_default (priv->gconf_client,
- DICTIONARY_GCONF_STRATEGY_KEY,
- GDICT_DEFAULT_STRATEGY);
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ g_free (priv->strategy);
+
+ if (strategy)
+ priv->strategy = g_strdup (strategy);
+ else
+ priv->strategy = gdict_gconf_get_string_with_default (priv->gconf_client,
+ DICTIONARY_GCONF_STRATEGY_KEY,
+ GDICT_DEFAULT_STRATEGY);
}
static GdictContext *
-get_context_from_loader (GtranslatorDictPanel *panel)
+get_context_from_loader (GtranslatorDictPanel * panel)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- GdictSource *source;
- GdictContext *retval;
-
- if (!priv->source_name)
- priv->source_name = g_strdup (DICTIONARY_DEFAULT_SOURCE_NAME);
-
- source = gdict_source_loader_get_source (priv->loader,
- priv->source_name);
- if (!source)
- {
- gchar *detail;
-
- detail = g_strdup_printf (_("No dictionary source available with name '%s'"),
- priv->source_name);
-
- gtranslator_dict_panel_create_warning_dialog (_("Unable to find dictionary source"),
- detail);
- g_free (detail);
-
- return NULL;
- }
-
- gtranslator_dict_panel_set_database (panel, gdict_source_get_database (source));
- gtranslator_dict_panel_set_strategy (panel, gdict_source_get_strategy (source));
-
- retval = gdict_source_get_context (source);
- if (!retval)
- {
- gchar *detail;
-
- detail = g_strdup_printf (_("No context available for source '%s'"),
- gdict_source_get_description (source));
-
- gtranslator_dict_panel_create_warning_dialog (_("Unable to create a context"),
- detail);
-
- g_free (detail);
- g_object_unref (source);
-
- return NULL;
- }
-
- g_object_unref (source);
-
- return retval;
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ GdictSource *source;
+ GdictContext *retval;
+
+ if (!priv->source_name)
+ priv->source_name = g_strdup (DICTIONARY_DEFAULT_SOURCE_NAME);
+
+ source = gdict_source_loader_get_source (priv->loader, priv->source_name);
+ if (!source)
+ {
+ gchar *detail;
+
+ detail =
+ g_strdup_printf (_("No dictionary source available with name '%s'"),
+ priv->source_name);
+
+ gtranslator_dict_panel_create_warning_dialog (_
+ ("Unable to find dictionary source"),
+ detail);
+ g_free (detail);
+
+ return NULL;
+ }
+
+ gtranslator_dict_panel_set_database (panel,
+ gdict_source_get_database (source));
+ gtranslator_dict_panel_set_strategy (panel,
+ gdict_source_get_strategy (source));
+
+ retval = gdict_source_get_context (source);
+ if (!retval)
+ {
+ gchar *detail;
+
+ detail = g_strdup_printf (_("No context available for source '%s'"),
+ gdict_source_get_description (source));
+
+ gtranslator_dict_panel_create_warning_dialog (_
+ ("Unable to create a context"),
+ detail);
+
+ g_free (detail);
+ g_object_unref (source);
+
+ return NULL;
+ }
+
+ g_object_unref (source);
+
+ return retval;
}
static void
-gtranslator_dict_panel_set_context (GtranslatorDictPanel *panel,
- GdictContext *context)
+gtranslator_dict_panel_set_context (GtranslatorDictPanel * panel,
+ GdictContext * context)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
-
- if (priv->context)
- {
- g_object_unref (priv->context);
- priv->context = NULL;
- }
-
- if (priv->defbox)
- gdict_defbox_set_context (GDICT_DEFBOX (priv->defbox), context);
-
- if (priv->db_chooser)
- gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (priv->db_chooser), context);
-
- if (priv->strat_chooser)
- gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (priv->strat_chooser), context);
-
- if (!context)
- return;
-
- priv->context = context;
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ if (priv->context)
+ {
+ g_object_unref (priv->context);
+ priv->context = NULL;
+ }
+
+ if (priv->defbox)
+ gdict_defbox_set_context (GDICT_DEFBOX (priv->defbox), context);
+
+ if (priv->db_chooser)
+ gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER
+ (priv->db_chooser), context);
+
+ if (priv->strat_chooser)
+ gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER
+ (priv->strat_chooser), context);
+
+ if (!context)
+ return;
+
+ priv->context = context;
}
static void
-gtranslator_dict_panel_set_source_name (GtranslatorDictPanel *panel,
- const gchar *source_name)
+gtranslator_dict_panel_set_source_name (GtranslatorDictPanel * panel,
+ const gchar * source_name)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- GdictContext *context;
-
- if (priv->source_name && source_name &&
- strcmp (priv->source_name, source_name) == 0)
- return;
-
- g_free (priv->source_name);
-
- if (source_name)
- priv->source_name = g_strdup (source_name);
- else
- priv->source_name = gdict_gconf_get_string_with_default (priv->gconf_client,
- DICTIONARY_GCONF_SOURCE_KEY,
- DICTIONARY_DEFAULT_SOURCE_NAME);
-
- context = get_context_from_loader (panel);
- gtranslator_dict_panel_set_context (panel, context);
-
- if (priv->source_chooser)
- gdict_source_chooser_set_current_source (GDICT_SOURCE_CHOOSER (priv->source_chooser),
- priv->source_name);
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ GdictContext *context;
+
+ if (priv->source_name && source_name &&
+ strcmp (priv->source_name, source_name) == 0)
+ return;
+
+ g_free (priv->source_name);
+
+ if (source_name)
+ priv->source_name = g_strdup (source_name);
+ else
+ priv->source_name =
+ gdict_gconf_get_string_with_default (priv->gconf_client,
+ DICTIONARY_GCONF_SOURCE_KEY,
+ DICTIONARY_DEFAULT_SOURCE_NAME);
+
+ context = get_context_from_loader (panel);
+ gtranslator_dict_panel_set_context (panel, context);
+
+ if (priv->source_chooser)
+ gdict_source_chooser_set_current_source (GDICT_SOURCE_CHOOSER
+ (priv->source_chooser),
+ priv->source_name);
}
static void
-source_activated_cb (GdictSourceChooser *chooser,
- const gchar *source_name,
- GdictSource *source,
- GtranslatorDictPanel *panel)
+source_activated_cb (GdictSourceChooser * chooser,
+ const gchar * source_name,
+ GdictSource * source, GtranslatorDictPanel * panel)
{
- g_signal_handlers_block_by_func (chooser, source_activated_cb, panel);
- gtranslator_dict_panel_set_source_name (panel, source_name);
- g_signal_handlers_unblock_by_func (chooser, source_activated_cb, panel);
-
- if (panel->priv->status)
- {
- gchar *message;
-
- message = g_strdup_printf (_("Dictionary source '%s' selected"),
- gdict_source_get_description (source));
- gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s", message);
- g_free (message);
- }
+ g_signal_handlers_block_by_func (chooser, source_activated_cb, panel);
+ gtranslator_dict_panel_set_source_name (panel, source_name);
+ g_signal_handlers_unblock_by_func (chooser, source_activated_cb, panel);
+
+ if (panel->priv->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Dictionary source '%s' selected"),
+ gdict_source_get_description (source));
+ gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s",
+ message);
+ g_free (message);
+ }
}
static void
-strategy_activated_cb (GdictStrategyChooser *chooser,
- const gchar *strat_name,
- const gchar *strat_desc,
- GtranslatorDictPanel *panel)
+strategy_activated_cb (GdictStrategyChooser * chooser,
+ const gchar * strat_name,
+ const gchar * strat_desc, GtranslatorDictPanel * panel)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- gtranslator_dict_panel_set_strategy (panel, strat_name);
-
- if (priv->status)
- {
- gchar *message;
-
- message = g_strdup_printf (_("Strategy '%s' selected"), strat_desc);
- gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s", message);
- g_free (message);
- }
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gtranslator_dict_panel_set_strategy (panel, strat_name);
+
+ if (priv->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Strategy '%s' selected"), strat_desc);
+ gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s",
+ message);
+ g_free (message);
+ }
}
static void
-database_activated_cb (GdictDatabaseChooser *chooser,
- const gchar *db_name,
- const gchar *db_desc,
- GtranslatorDictPanel *panel)
+database_activated_cb (GdictDatabaseChooser * chooser,
+ const gchar * db_name,
+ const gchar * db_desc, GtranslatorDictPanel * panel)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- gtranslator_dict_panel_set_database (panel, db_name);
-
- if (priv->status)
- {
- gchar *message;
-
- message = g_strdup_printf (_("Database '%s' selected"), db_desc);
- gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s", message);
- g_free (message);
- }
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gtranslator_dict_panel_set_database (panel, db_name);
+
+ if (priv->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Database '%s' selected"), db_desc);
+ gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s",
+ message);
+ g_free (message);
+ }
}
static void
-gtranslator_dict_panel_set_word (GtranslatorDictPanel *panel,
- const gchar *word,
- const gchar *database)
+gtranslator_dict_panel_set_word (GtranslatorDictPanel * panel,
+ const gchar * word, const gchar * database)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
+ GtranslatorDictPanelPrivate *priv = panel->priv;
- g_free (priv->word);
- priv->word = NULL;
+ g_free (priv->word);
+ priv->word = NULL;
- if (word && word[0] != '\0')
- priv->word = g_strdup (word);
- else
- return;
+ if (word && word[0] != '\0')
+ priv->word = g_strdup (word);
+ else
+ return;
- if (!database || database[0] == '\0')
- database = priv->database;
+ if (!database || database[0] == '\0')
+ database = priv->database;
- if (priv->defbox)
- {
- gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox), database);
- gdict_defbox_lookup (GDICT_DEFBOX (priv->defbox), word);
- }
+ if (priv->defbox)
+ {
+ gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox), database);
+ gdict_defbox_lookup (GDICT_DEFBOX (priv->defbox), word);
+ }
}
static void
-speller_word_activated_cb (GdictSpeller *speller,
- const gchar *word,
- const gchar *db_name,
- GtranslatorDictPanel *panel)
+speller_word_activated_cb (GdictSpeller * speller,
+ const gchar * word,
+ const gchar * db_name,
+ GtranslatorDictPanel * panel)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- gtk_entry_set_text (GTK_ENTRY (priv->entry), word);
-
- gtranslator_dict_panel_set_word (panel, word, db_name);
-
- if (priv->status)
- {
- gchar *message;
-
- message = g_strdup_printf (_("Word '%s' selected"), word);
- gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s", message);
- g_free (message);
- }
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), word);
+
+ gtranslator_dict_panel_set_word (panel, word, db_name);
+
+ if (priv->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Word '%s' selected"), word);
+ gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s",
+ message);
+ g_free (message);
+ }
}
static void
-sidebar_page_changed_cb (GdictSidebar *sidebar,
- GtranslatorDictPanel *panel)
+sidebar_page_changed_cb (GdictSidebar * sidebar, GtranslatorDictPanel * panel)
{
- GtranslatorDictPanelPrivate *priv = panel->priv;
- const gchar *page_id;
- const gchar *message;
-
- page_id = gdict_sidebar_current_page (sidebar);
-
- switch (page_id[0])
- {
- case 's':
- {
- switch (page_id[1])
- {
- case 'p': /* speller */
- message = _("Double-click on the word to look up");
- if (priv->word)
- gdict_speller_match (GDICT_SPELLER (priv->speller),
- priv->word);
- break;
- case 't': /* strat-chooser */
- message = _("Double-click on the matching strategy to use");
-
- gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (priv->strat_chooser));
- break;
- case 'o': /* source-chooser */
- message = _("Double-click on the source to use");
- gdict_source_chooser_refresh (GDICT_SOURCE_CHOOSER (priv->source_chooser));
- break;
- default:
- message = NULL;
- }
- }
- break;
- case 'd': /* db-chooser */
- message = _("Double-click on the database to use");
-
- gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (priv->db_chooser));
- break;
- default:
- message = NULL;
- break;
- }
-
- if (message && priv->status)
- gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s", message);
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ const gchar *page_id;
+ const gchar *message;
+
+ page_id = gdict_sidebar_current_page (sidebar);
+
+ switch (page_id[0])
+ {
+ case 's':
+ {
+ switch (page_id[1])
+ {
+ case 'p': /* speller */
+ message = _("Double-click on the word to look up");
+ if (priv->word)
+ gdict_speller_match (GDICT_SPELLER (priv->speller), priv->word);
+ break;
+ case 't': /* strat-chooser */
+ message = _("Double-click on the matching strategy to use");
+
+ gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER
+ (priv->strat_chooser));
+ break;
+ case 'o': /* source-chooser */
+ message = _("Double-click on the source to use");
+ gdict_source_chooser_refresh (GDICT_SOURCE_CHOOSER
+ (priv->source_chooser));
+ break;
+ default:
+ message = NULL;
+ }
+ }
+ break;
+ case 'd': /* db-chooser */
+ message = _("Double-click on the database to use");
+
+ gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER
+ (priv->db_chooser));
+ break;
+ default:
+ message = NULL;
+ break;
+ }
+
+ if (message && priv->status)
+ gtranslator_statusbar_flash_message (panel->priv->status, 0, "%s",
+ message);
}
static void
-store_position (GObject *gobject,
- GParamSpec *arg1,
- gpointer user_data)
+store_position (GObject * gobject, GParamSpec * arg1, gpointer user_data)
{
- GtkPaned *paned = GTK_PANED (gobject);
- GConfClient *client;
- gint position;
-
- client = gconf_client_get_default ();
- position = gtk_paned_get_position (paned);
- gconf_client_set_int (client, DICTIONARY_GCONF_POSITION_KEY, position, NULL);
-
- g_object_unref (client);
+ GtkPaned *paned = GTK_PANED (gobject);
+ GConfClient *client;
+ gint position;
+
+ client = gconf_client_get_default ();
+ position = gtk_paned_get_position (paned);
+ gconf_client_set_int (client, DICTIONARY_GCONF_POSITION_KEY, position,
+ NULL);
+
+ g_object_unref (client);
}
static void
-gtranslator_dict_panel_link_clicked(GtkWidget *defbox,
- const gchar *link_text,
- GtranslatorDictPanel *panel)
+gtranslator_dict_panel_link_clicked (GtkWidget * defbox,
+ const gchar * link_text,
+ GtranslatorDictPanel * panel)
{
- if (!link_text)
- return;
-
- g_free (panel->priv->word);
- panel->priv->word = g_strdup(link_text);
-
- gtk_entry_set_text(GTK_ENTRY(panel->priv->entry), link_text);
-
- gdict_defbox_lookup (GDICT_DEFBOX (defbox), panel->priv->word);
+ if (!link_text)
+ return;
+
+ g_free (panel->priv->word);
+ panel->priv->word = g_strdup (link_text);
+
+ gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), link_text);
+
+ gdict_defbox_lookup (GDICT_DEFBOX (defbox), panel->priv->word);
}
static void
-gtranslator_dict_panel_draw (GtranslatorDictPanel *panel)
+gtranslator_dict_panel_draw (GtranslatorDictPanel * panel)
{
- GtkWidget *vbox;
- GtkWidget *hbox;
- gint position;
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- gtk_widget_show (vbox);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- /*
- * Look up Button
- */
- panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:"));
- g_signal_connect(panel->priv->button, "clicked",
- G_CALLBACK (gtranslator_dict_panel_entry_activate_cb),
- panel);
- gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE);
- gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0);
- gtk_widget_show(panel->priv->button);
-
- /*
- * Entry
- */
- panel->priv->entry = gtk_entry_new ();
- if (panel->priv->word)
- gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word);
-
- g_signal_connect (panel->priv->entry, "activate",
- G_CALLBACK (gtranslator_dict_panel_entry_activate_cb),
- panel);
- gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
- gtk_widget_show (panel->priv->entry);
-
-
- /*
- * Defbox
- */
- panel->priv->defbox = gdict_defbox_new ();
- if (panel->priv->context)
- gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox),
- panel->priv->context);
- g_signal_connect(panel->priv->defbox, "link-clicked",
- G_CALLBACK(gtranslator_dict_panel_link_clicked), panel);
-
- gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox);
- gtk_widget_show (panel->priv->defbox);
-
- /*
- * Sidebar
- */
- panel->priv->sidebar = gdict_sidebar_new ();
- g_signal_connect (panel->priv->sidebar, "page-changed",
- G_CALLBACK (sidebar_page_changed_cb),
- panel);
-
- /*
- * Paned
- */
- panel->priv->paned = GTK_PANED(gtk_vpaned_new());
- gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET(panel->priv->paned), TRUE, TRUE, 0);
- gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE);
- gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE);
- gtk_widget_show (GTK_WIDGET(panel->priv->paned));
-
- position = gconf_client_get_int (panel->priv->gconf_client,
- DICTIONARY_GCONF_POSITION_KEY, NULL);
- gtk_paned_set_position (GTK_PANED (panel->priv->paned), position);
-
- g_signal_connect (panel->priv->paned, "notify::position",
- G_CALLBACK(store_position), NULL);
-
-
- /*
- * Speller
- */
- panel->priv->speller = gdict_speller_new ();
- if (panel->priv->context)
- gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller),
- panel->priv->context);
- g_signal_connect (panel->priv->speller, "word-activated",
- G_CALLBACK (speller_word_activated_cb),
- panel);
-
- gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
- GDICT_SIDEBAR_SPELLER_PAGE,
- _("Similar words"),
- panel->priv->speller);
- gtk_widget_show (panel->priv->speller);
-
- /*
- * db chooser
- */
- panel->priv->db_chooser = gdict_database_chooser_new ();
- if (panel->priv->context)
- gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (panel->priv->db_chooser),
- panel->priv->context);
- g_signal_connect (panel->priv->db_chooser, "database-activated",
- G_CALLBACK (database_activated_cb),
- panel);
- gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
- GDICT_SIDEBAR_DATABASES_PAGE,
- _("Available dictionaries"),
- panel->priv->db_chooser);
- gtk_widget_show (panel->priv->db_chooser);
-
- /*
- * Strategy chooser
- */
- panel->priv->strat_chooser = gdict_strategy_chooser_new ();
- if (panel->priv->context)
- gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (panel->priv->strat_chooser),
- panel->priv->context);
- g_signal_connect (panel->priv->strat_chooser, "strategy-activated",
- G_CALLBACK (strategy_activated_cb),
- panel);
- gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
- GDICT_SIDEBAR_STRATEGIES_PAGE,
- _("Available strategies"),
- panel->priv->strat_chooser);
- gtk_widget_show (panel->priv->strat_chooser);
-
- /* Source chooser */
- panel->priv->source_chooser = gdict_source_chooser_new_with_loader (panel->priv->loader);
- g_signal_connect (panel->priv->source_chooser, "source-activated",
- G_CALLBACK (source_activated_cb),
- panel);
- gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
- GDICT_SIDEBAR_SOURCES_PAGE,
- _("Dictionary sources"),
- panel->priv->source_chooser);
- gtk_widget_show (panel->priv->source_chooser);
-
- gtk_widget_show (panel->priv->sidebar);
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ gint position;
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+ gtk_widget_show (vbox);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ /*
+ * Look up Button
+ */
+ panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:"));
+ g_signal_connect (panel->priv->button, "clicked",
+ G_CALLBACK (gtranslator_dict_panel_entry_activate_cb),
+ panel);
+ gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE);
+ gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0);
+ gtk_widget_show (panel->priv->button);
+
+ /*
+ * Entry
+ */
+ panel->priv->entry = gtk_entry_new ();
+ if (panel->priv->word)
+ gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word);
+
+ g_signal_connect (panel->priv->entry, "activate",
+ G_CALLBACK (gtranslator_dict_panel_entry_activate_cb),
+ panel);
+ gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
+ gtk_widget_show (panel->priv->entry);
+
+
+ /*
+ * Defbox
+ */
+ panel->priv->defbox = gdict_defbox_new ();
+ if (panel->priv->context)
+ gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox),
+ panel->priv->context);
+ g_signal_connect (panel->priv->defbox, "link-clicked",
+ G_CALLBACK (gtranslator_dict_panel_link_clicked), panel);
+
+ gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox);
+ gtk_widget_show (panel->priv->defbox);
+
+ /*
+ * Sidebar
+ */
+ panel->priv->sidebar = gdict_sidebar_new ();
+ g_signal_connect (panel->priv->sidebar, "page-changed",
+ G_CALLBACK (sidebar_page_changed_cb), panel);
+
+ /*
+ * Paned
+ */
+ panel->priv->paned = GTK_PANED (gtk_vpaned_new ());
+ gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET (panel->priv->paned), TRUE,
+ TRUE, 0);
+ gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE);
+ gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE);
+ gtk_widget_show (GTK_WIDGET (panel->priv->paned));
+
+ position = gconf_client_get_int (panel->priv->gconf_client,
+ DICTIONARY_GCONF_POSITION_KEY, NULL);
+ gtk_paned_set_position (GTK_PANED (panel->priv->paned), position);
+
+ g_signal_connect (panel->priv->paned, "notify::position",
+ G_CALLBACK (store_position), NULL);
+
+
+ /*
+ * Speller
+ */
+ panel->priv->speller = gdict_speller_new ();
+ if (panel->priv->context)
+ gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller),
+ panel->priv->context);
+ g_signal_connect (panel->priv->speller, "word-activated",
+ G_CALLBACK (speller_word_activated_cb), panel);
+
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_SPELLER_PAGE,
+ _("Similar words"), panel->priv->speller);
+ gtk_widget_show (panel->priv->speller);
+
+ /*
+ * db chooser
+ */
+ panel->priv->db_chooser = gdict_database_chooser_new ();
+ if (panel->priv->context)
+ gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER
+ (panel->priv->db_chooser),
+ panel->priv->context);
+ g_signal_connect (panel->priv->db_chooser, "database-activated",
+ G_CALLBACK (database_activated_cb), panel);
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_DATABASES_PAGE,
+ _("Available dictionaries"),
+ panel->priv->db_chooser);
+ gtk_widget_show (panel->priv->db_chooser);
+
+ /*
+ * Strategy chooser
+ */
+ panel->priv->strat_chooser = gdict_strategy_chooser_new ();
+ if (panel->priv->context)
+ gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER
+ (panel->priv->strat_chooser),
+ panel->priv->context);
+ g_signal_connect (panel->priv->strat_chooser, "strategy-activated",
+ G_CALLBACK (strategy_activated_cb), panel);
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_STRATEGIES_PAGE,
+ _("Available strategies"),
+ panel->priv->strat_chooser);
+ gtk_widget_show (panel->priv->strat_chooser);
+
+ /* Source chooser */
+ panel->priv->source_chooser =
+ gdict_source_chooser_new_with_loader (panel->priv->loader);
+ g_signal_connect (panel->priv->source_chooser, "source-activated",
+ G_CALLBACK (source_activated_cb), panel);
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_SOURCES_PAGE, _("Dictionary sources"),
+ panel->priv->source_chooser);
+ gtk_widget_show (panel->priv->source_chooser);
+
+ gtk_widget_show (panel->priv->sidebar);
}
static void
-gtranslator_dict_panel_gconf_notify_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+gtranslator_dict_panel_gconf_notify_cb (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GtranslatorDictPanel *panel = GTR_DICT_PANEL (user_data);
-
- if (strcmp (entry->key, DICTIONARY_GCONF_SOURCE_KEY) == 0)
- {
- if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
- gtranslator_dict_panel_set_source_name (panel, gconf_value_get_string (entry->value));
- else
- gtranslator_dict_panel_set_source_name (panel, DICTIONARY_DEFAULT_SOURCE_NAME);
- }
- else if (strcmp (entry->key, DICTIONARY_GCONF_DATABASE_KEY) == 0)
- {
- if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
- gtranslator_dict_panel_set_database (panel, gconf_value_get_string (entry->value));
- else
- gtranslator_dict_panel_set_database (panel, GDICT_DEFAULT_DATABASE);
- }
- else if (strcmp (entry->key, DICTIONARY_GCONF_STRATEGY_KEY) == 0)
- {
- if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
- gtranslator_dict_panel_set_strategy (panel, gconf_value_get_string (entry->value));
- else
- gtranslator_dict_panel_set_strategy (panel, GDICT_DEFAULT_STRATEGY);
- }
+ GtranslatorDictPanel *panel = GTR_DICT_PANEL (user_data);
+
+ if (strcmp (entry->key, DICTIONARY_GCONF_SOURCE_KEY) == 0)
+ {
+ if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
+ gtranslator_dict_panel_set_source_name (panel,
+ gconf_value_get_string
+ (entry->value));
+ else
+ gtranslator_dict_panel_set_source_name (panel,
+ DICTIONARY_DEFAULT_SOURCE_NAME);
+ }
+ else if (strcmp (entry->key, DICTIONARY_GCONF_DATABASE_KEY) == 0)
+ {
+ if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
+ gtranslator_dict_panel_set_database (panel,
+ gconf_value_get_string (entry->
+ value));
+ else
+ gtranslator_dict_panel_set_database (panel, GDICT_DEFAULT_DATABASE);
+ }
+ else if (strcmp (entry->key, DICTIONARY_GCONF_STRATEGY_KEY) == 0)
+ {
+ if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
+ gtranslator_dict_panel_set_strategy (panel,
+ gconf_value_get_string (entry->
+ value));
+ else
+ gtranslator_dict_panel_set_strategy (panel, GDICT_DEFAULT_STRATEGY);
+ }
}
static void
-gtranslator_dict_panel_init(GtranslatorDictPanel *panel)
+gtranslator_dict_panel_init (GtranslatorDictPanel * panel)
{
- gchar * data_dir;
- GtranslatorDictPanelPrivate *priv;
- GError *gconf_error;
-
- panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel);
- priv = panel->priv;
-
- priv->status = NULL;
-
- if (!priv->loader)
- panel->priv->loader = gdict_source_loader_new ();
-
- /* add our data dir inside $HOME to the loader's search paths */
- data_dir = gtranslator_utils_get_user_config_dir ();
- gdict_source_loader_add_search_path (priv->loader, data_dir);
- g_free (data_dir);
-
- /* get the default gconf client */
- if (!priv->gconf_client)
- priv->gconf_client = gconf_client_get_default ();
-
- gconf_error = NULL;
- gconf_client_add_dir (priv->gconf_client,
- DICTIONARY_GCONF_DIR,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- &gconf_error);
- if (gconf_error)
- {
- /*gdict_show_gerror_dialog (NULL,
- _("Unable to connect to GConf"),
- gconf_error);*/
- gconf_error = NULL;
- }
-
- priv->notify_id = gconf_client_notify_add (priv->gconf_client,
- DICTIONARY_GCONF_DIR,
- gtranslator_dict_panel_gconf_notify_cb,
- panel, NULL,
- &gconf_error);
- if (gconf_error)
- {
- /*gdict_show_gerror_dialog (NULL,
- _("Unable to get notification for preferences"),
- gconf_error);*/
-
- gconf_error = NULL;
- }
-
- /* force retrieval of the configuration from GConf */
- gtranslator_dict_panel_set_source_name (panel, NULL);
-
- /* Draw widgets */
- gtranslator_dict_panel_draw(panel);
+ gchar *data_dir;
+ GtranslatorDictPanelPrivate *priv;
+ GError *gconf_error;
+
+ panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel);
+ priv = panel->priv;
+
+ priv->status = NULL;
+
+ if (!priv->loader)
+ panel->priv->loader = gdict_source_loader_new ();
+
+ /* add our data dir inside $HOME to the loader's search paths */
+ data_dir = gtranslator_utils_get_user_config_dir ();
+ gdict_source_loader_add_search_path (priv->loader, data_dir);
+ g_free (data_dir);
+
+ /* get the default gconf client */
+ if (!priv->gconf_client)
+ priv->gconf_client = gconf_client_get_default ();
+
+ gconf_error = NULL;
+ gconf_client_add_dir (priv->gconf_client,
+ DICTIONARY_GCONF_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, &gconf_error);
+ if (gconf_error)
+ {
+ /*gdict_show_gerror_dialog (NULL,
+ _("Unable to connect to GConf"),
+ gconf_error); */
+ gconf_error = NULL;
+ }
+
+ priv->notify_id = gconf_client_notify_add (priv->gconf_client,
+ DICTIONARY_GCONF_DIR,
+ gtranslator_dict_panel_gconf_notify_cb,
+ panel, NULL, &gconf_error);
+ if (gconf_error)
+ {
+ /*gdict_show_gerror_dialog (NULL,
+ _("Unable to get notification for preferences"),
+ gconf_error); */
+
+ gconf_error = NULL;
+ }
+
+ /* force retrieval of the configuration from GConf */
+ gtranslator_dict_panel_set_source_name (panel, NULL);
+
+ /* Draw widgets */
+ gtranslator_dict_panel_draw (panel);
}
static void
-gtranslator_dict_panel_finalize (GObject *object)
+gtranslator_dict_panel_finalize (GObject * object)
{
- GtranslatorDictPanel *panel = GTR_DICT_PANEL (object);
-
- g_free (panel->priv->source_name);
- g_free (panel->priv->word);
- g_free (panel->priv->database);
- g_free (panel->priv->strategy);
-
- G_OBJECT_CLASS (gtranslator_dict_panel_parent_class)->finalize (object);
+ GtranslatorDictPanel *panel = GTR_DICT_PANEL (object);
+
+ g_free (panel->priv->source_name);
+ g_free (panel->priv->word);
+ g_free (panel->priv->database);
+ g_free (panel->priv->strategy);
+
+ G_OBJECT_CLASS (gtranslator_dict_panel_parent_class)->finalize (object);
}
static void
-gtranslator_dict_panel_class_init (GtranslatorDictPanelClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GtranslatorDictPanelPrivate));
-
- gobject_class->finalize = gtranslator_dict_panel_finalize;
-
+gtranslator_dict_panel_class_init (GtranslatorDictPanelClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorDictPanelPrivate));
+
+ gobject_class->finalize = gtranslator_dict_panel_finalize;
+
}
GtkWidget *
-gtranslator_dict_panel_new (GtranslatorWindow *window)
+gtranslator_dict_panel_new (GtranslatorWindow * window)
{
- GtranslatorDictPanel *panel;
-
- panel = g_object_new (GTR_TYPE_DICT_PANEL, NULL);
- panel->priv->status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
-
- return GTK_WIDGET (panel);
+ GtranslatorDictPanel *panel;
+
+ panel = g_object_new (GTR_TYPE_DICT_PANEL, NULL);
+ panel->priv->status =
+ GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+
+ return GTK_WIDGET (panel);
}
diff --git a/plugins/dictionary/dict-panel.h b/plugins/dictionary/dict-panel.h
index f485df0..17b0a3a 100644
--- a/plugins/dictionary/dict-panel.h
+++ b/plugins/dictionary/dict-panel.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,45 +34,45 @@ G_BEGIN_DECLS
#define GTR_IS_DICT_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DICT_PANEL))
#define GTR_IS_DICT_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DICT_PANEL))
#define GTR_DICT_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DICT_PANEL, GtranslatorDictPanelClass))
-
/* Private structure type */
-typedef struct _GtranslatorDictPanelPrivate GtranslatorDictPanelPrivate;
+typedef struct _GtranslatorDictPanelPrivate GtranslatorDictPanelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDictPanel GtranslatorDictPanel;
+typedef struct _GtranslatorDictPanel GtranslatorDictPanel;
struct _GtranslatorDictPanel
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorDictPanelPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorDictPanelPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDictPanelClass GtranslatorDictPanelClass;
+typedef struct _GtranslatorDictPanelClass GtranslatorDictPanelClass;
struct _GtranslatorDictPanelClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_dict_panel_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_dict_panel_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_dict_panel_register_type (GTypeModule * module);
+ GType gtranslator_dict_panel_register_type (GTypeModule * module);
-GtkWidget * gtranslator_dict_panel_new (GtranslatorWindow *window);
+ GtkWidget *gtranslator_dict_panel_new (GtranslatorWindow * window);
-void gtranslator_dict_panel_set_position (GtranslatorDictPanel *panel,
- gint pos);
+ void gtranslator_dict_panel_set_position (GtranslatorDictPanel * panel,
+ gint pos);
G_END_DECLS
-
#endif /* __DICT_PANEL_H__ */
diff --git a/plugins/dictionary/dictionary-plugin.c b/plugins/dictionary/dictionary-plugin.c
index e6e5dd0..fc2f57d 100644
--- a/plugins/dictionary/dictionary-plugin.c
+++ b/plugins/dictionary/dictionary-plugin.c
@@ -35,95 +35,91 @@
typedef struct
{
- GtkWidget *panel;
- guint context_id;
+ GtkWidget *panel;
+ guint context_id;
} WindowData;
-GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorDictPlugin, gtranslator_dict_plugin,
- gtranslator_dict_panel_register_type (module);
-)
-
-static void
-gtranslator_dict_plugin_init (GtranslatorDictPlugin *plugin)
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorDictPlugin,
+ gtranslator_dict_plugin,
+ gtranslator_dict_panel_register_type
+ (module);)
+ static void gtranslator_dict_plugin_init (GtranslatorDictPlugin * plugin)
{
}
static void
-gtranslator_dict_plugin_finalize (GObject *object)
+gtranslator_dict_plugin_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_dict_plugin_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_dict_plugin_parent_class)->finalize (object);
}
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_return_if_fail (data != NULL);
-
- g_free (data);
+ g_return_if_fail (data != NULL);
+
+ g_free (data);
}
static GtkWidget *
-create_dict_panel (GtranslatorWindow *window)
+create_dict_panel (GtranslatorWindow * window)
{
- GtkWidget *panel;
+ GtkWidget *panel;
- panel = gtranslator_dict_panel_new (window);
+ panel = gtranslator_dict_panel_new (window);
- gtk_widget_show (panel);
+ gtk_widget_show (panel);
- return panel;
+ return panel;
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
-
- data = g_new (WindowData, 1);
-
- data->panel = create_dict_panel (window);
-
- gtranslator_application_register_icon (GTR_APP, "gnome-dictionary.png",
- "dictionary-icon");
-
- gtranslator_window_add_widget (window,
- data->panel,
- "GtranslatorDictionaryPlugin",
- _("Dictionary"),
- "dictionary-icon",
- GTR_WINDOW_PLACEMENT_LEFT);
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
+ WindowData *data;
+
+ data = g_new (WindowData, 1);
+
+ data->panel = create_dict_panel (window);
+
+ gtranslator_application_register_icon (GTR_APP, "gnome-dictionary.png",
+ "dictionary-icon");
+
+ gtranslator_window_add_widget (window,
+ data->panel,
+ "GtranslatorDictionaryPlugin",
+ _("Dictionary"),
+ "dictionary-icon",
+ GTR_WINDOW_PLACEMENT_LEFT);
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
}
static void
-impl_deactivate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
+ WindowData *data;
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- gtranslator_window_remove_widget (window, data->panel);
+ gtranslator_window_remove_widget (window, data->panel);
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
static void
-gtranslator_dict_plugin_class_init (GtranslatorDictPluginClass *klass)
+gtranslator_dict_plugin_class_init (GtranslatorDictPluginClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
- object_class->finalize = gtranslator_dict_plugin_finalize;
+ object_class->finalize = gtranslator_dict_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
}
diff --git a/plugins/dictionary/dictionary-plugin.h b/plugins/dictionary/dictionary-plugin.h
index c05e78e..2934261 100644
--- a/plugins/dictionary/dictionary-plugin.h
+++ b/plugins/dictionary/dictionary-plugin.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -34,38 +33,38 @@ G_BEGIN_DECLS
#define GTR_IS_DICT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_Dict_PLUGIN))
#define GTR_IS_DICT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_Dict_PLUGIN))
#define GTR_Dict_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_Dict_PLUGIN, GtranslatorDictPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorDictPluginPrivate GtranslatorDictPluginPrivate;
+typedef struct _GtranslatorDictPluginPrivate GtranslatorDictPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDictPlugin GtranslatorDictPlugin;
+typedef struct _GtranslatorDictPlugin GtranslatorDictPlugin;
struct _GtranslatorDictPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDictPluginClass GtranslatorDictPluginClass;
+typedef struct _GtranslatorDictPluginClass GtranslatorDictPluginClass;
struct _GtranslatorDictPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_dict_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_dict_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_Dict_PLUGIN_H__ */
diff --git a/plugins/dictionary/gdict-sidebar.c b/plugins/dictionary/gdict-sidebar.c
index a6ceae6..e933bb7 100644
--- a/plugins/dictionary/gdict-sidebar.c
+++ b/plugins/dictionary/gdict-sidebar.c
@@ -71,19 +71,18 @@ enum
};
static guint sidebar_signals[LAST_SIGNAL] = { 0 };
+
static GQuark sidebar_page_id_quark = 0;
G_DEFINE_TYPE (GdictSidebar, gdict_sidebar, GTK_TYPE_VBOX);
static SidebarPage *
-sidebar_page_new (const gchar *id,
- const gchar *name,
- GtkWidget *widget)
+sidebar_page_new (const gchar * id, const gchar * name, GtkWidget * widget)
{
SidebarPage *page;
page = g_slice_new (SidebarPage);
-
+
page->id = g_strdup (id);
page->name = g_strdup (name);
page->child = widget;
@@ -94,19 +93,19 @@ sidebar_page_new (const gchar *id,
}
static void
-sidebar_page_free (SidebarPage *page)
+sidebar_page_free (SidebarPage * page)
{
if (G_LIKELY (page))
{
g_free (page->name);
g_free (page->id);
-
+
g_slice_free (SidebarPage, page);
}
}
static void
-gdict_sidebar_finalize (GObject *object)
+gdict_sidebar_finalize (GObject * object)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (object);
GdictSidebarPrivate *priv = sidebar->priv;
@@ -124,7 +123,7 @@ gdict_sidebar_finalize (GObject *object)
}
static void
-gdict_sidebar_dispose (GObject *object)
+gdict_sidebar_dispose (GObject * object)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (object);
@@ -138,11 +137,10 @@ gdict_sidebar_dispose (GObject *object)
}
static void
-gdict_sidebar_menu_position_function (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+gdict_sidebar_menu_position_function (GtkMenu * menu,
+ gint * x,
+ gint * y,
+ gboolean * push_in, gpointer user_data)
{
GtkWidget *widget;
@@ -159,9 +157,9 @@ gdict_sidebar_menu_position_function (GtkMenu *menu,
}
static gboolean
-gdict_sidebar_select_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
+gdict_sidebar_select_button_press_cb (GtkWidget * widget,
+ GdkEventButton * event,
+ gpointer user_data)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
@@ -174,7 +172,7 @@ gdict_sidebar_select_button_press_cb (GtkWidget *widget,
gtk_widget_set_size_request (sidebar->priv->menu, -1, -1);
gtk_widget_size_request (sidebar->priv->menu, &req);
gtk_widget_set_size_request (sidebar->priv->menu,
- MAX (width, req.width), -1);
+ MAX (width, req.width), -1);
gtk_widget_grab_focus (widget);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
@@ -190,16 +188,14 @@ gdict_sidebar_select_button_press_cb (GtkWidget *widget,
}
static gboolean
-gdict_sidebar_select_key_press_cb (GtkWidget *widget,
- GdkEventKey *event,
- gpointer user_data)
+gdict_sidebar_select_key_press_cb (GtkWidget * widget,
+ GdkEventKey * event, gpointer user_data)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
if (event->keyval == GDK_space ||
event->keyval == GDK_KP_Space ||
- event->keyval == GDK_Return ||
- event->keyval == GDK_KP_Enter)
+ event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_menu_popup (GTK_MENU (sidebar->priv->menu),
@@ -214,8 +210,7 @@ gdict_sidebar_select_key_press_cb (GtkWidget *widget,
}
static void
-gdict_sidebar_menu_deactivate_cb (GtkWidget *widget,
- gpointer user_data)
+gdict_sidebar_menu_deactivate_cb (GtkWidget * widget, gpointer user_data)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
GdictSidebarPrivate *priv = sidebar->priv;
@@ -225,8 +220,7 @@ gdict_sidebar_menu_deactivate_cb (GtkWidget *widget,
}
static void
-gdict_sidebar_menu_detach_cb (GtkWidget *widget,
- GtkMenu *menu)
+gdict_sidebar_menu_detach_cb (GtkWidget * widget, GtkMenu * menu)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (widget);
@@ -234,8 +228,7 @@ gdict_sidebar_menu_detach_cb (GtkWidget *widget,
}
static void
-gdict_sidebar_menu_item_activate (GtkWidget *widget,
- gpointer user_data)
+gdict_sidebar_menu_item_activate (GtkWidget * widget, gpointer user_data)
{
GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
GdictSidebarPrivate *priv = sidebar->priv;
@@ -247,29 +240,30 @@ gdict_sidebar_menu_item_activate (GtkWidget *widget,
menu_item = gtk_menu_get_active (GTK_MENU (priv->menu));
id = g_object_get_qdata (G_OBJECT (menu_item), sidebar_page_id_quark);
g_assert (id != NULL);
-
+
page = g_hash_table_lookup (priv->pages_by_id, id);
g_assert (page != NULL);
- current_index = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
+ current_index =
+ gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
if (current_index == page->index)
return;
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
- page->index);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page->index);
gtk_label_set_text (GTK_LABEL (priv->label), page->name);
g_signal_emit (sidebar, sidebar_signals[PAGE_CHANGED], 0);
}
static void
-gdict_sidebar_class_init (GdictSidebarClass *klass)
+gdict_sidebar_class_init (GdictSidebarClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (gobject_class, sizeof (GdictSidebarPrivate));
-
- sidebar_page_id_quark = g_quark_from_static_string ("gdict-sidebar-page-id");
+
+ sidebar_page_id_quark =
+ g_quark_from_static_string ("gdict-sidebar-page-id");
gobject_class->finalize = gdict_sidebar_finalize;
gobject_class->dispose = gdict_sidebar_dispose;
@@ -279,21 +273,17 @@ gdict_sidebar_class_init (GdictSidebarClass *klass)
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdictSidebarClass, page_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
sidebar_signals[CLOSED] =
g_signal_new ("closed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdictSidebarClass, closed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gdict_sidebar_init (GdictSidebar *sidebar)
+gdict_sidebar_init (GdictSidebar * sidebar)
{
GdictSidebarPrivate *priv;
GtkWidget *hbox;
@@ -324,12 +314,11 @@ gdict_sidebar_init (GdictSidebar *sidebar)
G_CALLBACK (gdict_sidebar_select_button_press_cb),
sidebar);
g_signal_connect (select_button, "key-press-event",
- G_CALLBACK (gdict_sidebar_select_key_press_cb),
- sidebar);
+ G_CALLBACK (gdict_sidebar_select_key_press_cb), sidebar);
priv->select_button = select_button;
select_hbox = gtk_hbox_new (FALSE, 0);
-
+
priv->label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (select_hbox), priv->label, FALSE, FALSE, 0);
@@ -347,17 +336,18 @@ gdict_sidebar_init (GdictSidebar *sidebar)
sidebar->priv->menu = gtk_menu_new ();
g_signal_connect (sidebar->priv->menu, "deactivate",
- G_CALLBACK (gdict_sidebar_menu_deactivate_cb),
- sidebar);
+ G_CALLBACK (gdict_sidebar_menu_deactivate_cb), sidebar);
gtk_menu_attach_to_widget (GTK_MENU (sidebar->priv->menu),
- GTK_WIDGET (sidebar),
+ GTK_WIDGET (sidebar),
gdict_sidebar_menu_detach_cb);
gtk_widget_show (sidebar->priv->menu);
sidebar->priv->notebook = gtk_notebook_new ();
- gtk_notebook_set_show_border (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (sidebar->priv->notebook),
+ FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
- gtk_box_pack_start (GTK_BOX (sidebar), sidebar->priv->notebook, TRUE, TRUE, 6);
+ gtk_box_pack_start (GTK_BOX (sidebar), sidebar->priv->notebook, TRUE, TRUE,
+ 6);
gtk_widget_show (sidebar->priv->notebook);
}
@@ -372,50 +362,45 @@ gdict_sidebar_new (void)
}
void
-gdict_sidebar_add_page (GdictSidebar *sidebar,
- const gchar *page_id,
- const gchar *page_name,
- GtkWidget *page_widget)
+gdict_sidebar_add_page (GdictSidebar * sidebar,
+ const gchar * page_id,
+ const gchar * page_name, GtkWidget * page_widget)
{
GdictSidebarPrivate *priv;
SidebarPage *page;
GtkWidget *menu_item;
-
+
g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
g_return_if_fail (page_id != NULL);
g_return_if_fail (page_name != NULL);
g_return_if_fail (GTK_IS_WIDGET (page_widget));
priv = sidebar->priv;
-
+
if (g_hash_table_lookup (priv->pages_by_id, page_id))
{
g_warning ("Attempting to add a page to the sidebar with "
"id `%s', but there already is a page with the "
- "same id. Aborting...",
- page_id);
+ "same id. Aborting...", page_id);
return;
}
/* add the page inside the page list */
page = sidebar_page_new (page_id, page_name, page_widget);
-
+
priv->pages = g_slist_append (priv->pages, page);
g_hash_table_insert (priv->pages_by_id, page->id, page);
page->index = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
- page_widget,
- NULL);
+ page_widget, NULL);
/* add the menu item for the page */
menu_item = gtk_image_menu_item_new_with_label (page_name);
g_object_set_qdata_full (G_OBJECT (menu_item),
sidebar_page_id_quark,
- g_strdup (page_id),
- (GDestroyNotify) g_free);
+ g_strdup (page_id), (GDestroyNotify) g_free);
g_signal_connect (menu_item, "activate",
- G_CALLBACK (gdict_sidebar_menu_item_activate),
- sidebar);
+ G_CALLBACK (gdict_sidebar_menu_item_activate), sidebar);
gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_item);
gtk_widget_show (menu_item);
page->menu_item = menu_item;
@@ -426,18 +411,17 @@ gdict_sidebar_add_page (GdictSidebar *sidebar,
}
void
-gdict_sidebar_remove_page (GdictSidebar *sidebar,
- const gchar *page_id)
+gdict_sidebar_remove_page (GdictSidebar * sidebar, const gchar * page_id)
{
GdictSidebarPrivate *priv;
SidebarPage *page;
GList *children, *l;
-
+
g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
g_return_if_fail (page_id != NULL);
priv = sidebar->priv;
-
+
if ((page = g_hash_table_lookup (priv->pages_by_id, page_id)) == NULL)
{
g_warning ("Attempting to remove a page from the sidebar with "
@@ -452,8 +436,8 @@ gdict_sidebar_remove_page (GdictSidebar *sidebar,
GtkWidget *menu_item = l->data;
if (menu_item == page->menu_item)
- {
- gtk_container_remove (GTK_CONTAINER (priv->menu), menu_item);
+ {
+ gtk_container_remove (GTK_CONTAINER (priv->menu), menu_item);
break;
}
}
@@ -470,21 +454,22 @@ gdict_sidebar_remove_page (GdictSidebar *sidebar,
page = priv->pages->data;
if (page)
{
- gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu), page->menu_item);
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu),
+ page->menu_item);
gtk_label_set_text (GTK_LABEL (priv->label), page->name);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page->index);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
+ page->index);
}
else
gtk_widget_hide (GTK_WIDGET (sidebar));
}
void
-gdict_sidebar_view_page (GdictSidebar *sidebar,
- const gchar *page_id)
+gdict_sidebar_view_page (GdictSidebar * sidebar, const gchar * page_id)
{
GdictSidebarPrivate *priv;
SidebarPage *page;
-
+
g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
g_return_if_fail (page_id != NULL);
@@ -499,16 +484,16 @@ gdict_sidebar_view_page (GdictSidebar *sidebar,
}
G_CONST_RETURN gchar *
-gdict_sidebar_current_page (GdictSidebar *sidebar)
+gdict_sidebar_current_page (GdictSidebar * sidebar)
{
GdictSidebarPrivate *priv;
gint index;
SidebarPage *page;
-
+
g_return_val_if_fail (GDICT_IS_SIDEBAR (sidebar), NULL);
priv = sidebar->priv;
-
+
index = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
page = g_slist_nth_data (priv->pages, index);
g_assert (page != NULL);
@@ -517,8 +502,7 @@ gdict_sidebar_current_page (GdictSidebar *sidebar)
}
gchar **
-gdict_sidebar_list_pages (GdictSidebar *sidebar,
- gsize *length)
+gdict_sidebar_list_pages (GdictSidebar * sidebar, gsize * length)
{
GdictSidebarPrivate *priv;
gchar **retval;
@@ -529,7 +513,7 @@ gdict_sidebar_list_pages (GdictSidebar *sidebar,
priv = sidebar->priv;
- retval = g_new (gchar*, g_slist_length (priv->pages) + 1);
+ retval = g_new (gchar *, g_slist_length (priv->pages) + 1);
for (l = priv->pages, i = 0; l; l = l->next, i++)
retval[i++] = g_strdup (l->data);
diff --git a/plugins/dictionary/gdict-sidebar.h b/plugins/dictionary/gdict-sidebar.h
index 2a27774..8433a29 100644
--- a/plugins/dictionary/gdict-sidebar.h
+++ b/plugins/dictionary/gdict-sidebar.h
@@ -33,9 +33,9 @@
#define GDICT_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDICT_TYPE_SIDEBAR))
#define GDICT_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDICT_TYPE_SIDEBAR, GdictSidebarClass))
-typedef struct _GdictSidebar GdictSidebar;
-typedef struct _GdictSidebarPrivate GdictSidebarPrivate;
-typedef struct _GdictSidebarClass GdictSidebarClass;
+typedef struct _GdictSidebar GdictSidebar;
+typedef struct _GdictSidebarPrivate GdictSidebarPrivate;
+typedef struct _GdictSidebarClass GdictSidebarClass;
struct _GdictSidebar
{
@@ -48,8 +48,8 @@ struct _GdictSidebarClass
{
GtkVBoxClass parent_class;
- void (*page_changed) (GdictSidebar *sidebar);
- void (*closed) (GdictSidebar *sidebar);
+ void (*page_changed) (GdictSidebar * sidebar);
+ void (*closed) (GdictSidebar * sidebar);
void (*_gdict_padding_1) (void);
void (*_gdict_padding_2) (void);
@@ -57,19 +57,22 @@ struct _GdictSidebarClass
void (*_gdict_padding_4) (void);
};
-GType gdict_sidebar_get_type (void) G_GNUC_CONST;
+GType
+gdict_sidebar_get_type (void)
+ G_GNUC_CONST;
-GtkWidget * gdict_sidebar_new (void);
-void gdict_sidebar_add_page (GdictSidebar *sidebar,
- const gchar *page_id,
- const gchar *page_name,
- GtkWidget *page_widget);
-void gdict_sidebar_remove_page (GdictSidebar *sidebar,
- const gchar *page_id);
-void gdict_sidebar_view_page (GdictSidebar *sidebar,
- const gchar *page_id);
-G_CONST_RETURN gchar *gdict_sidebar_current_page (GdictSidebar *sidebar);
-gchar ** gdict_sidebar_list_pages (GdictSidebar *sidebar,
- gsize *length) G_GNUC_MALLOC;
+ GtkWidget *gdict_sidebar_new (void);
+ void gdict_sidebar_add_page (GdictSidebar * sidebar,
+ const gchar * page_id,
+ const gchar * page_name,
+ GtkWidget * page_widget);
+ void gdict_sidebar_remove_page (GdictSidebar * sidebar,
+ const gchar * page_id);
+ void gdict_sidebar_view_page (GdictSidebar * sidebar,
+ const gchar * page_id);
+ G_CONST_RETURN gchar *gdict_sidebar_current_page (GdictSidebar *
+ sidebar);
+ gchar **gdict_sidebar_list_pages (GdictSidebar * sidebar,
+ gsize * length) G_GNUC_MALLOC;
#endif /* __GDICT_SIDEBAR_H__ */
diff --git a/plugins/fullscreen/fullscreen-plugin.c b/plugins/fullscreen/fullscreen-plugin.c
index ce705a0..328b2f8 100644
--- a/plugins/fullscreen/fullscreen-plugin.c
+++ b/plugins/fullscreen/fullscreen-plugin.c
@@ -30,123 +30,120 @@
#define WINDOW_DATA_KEY "GtranslatorFullscreenPluginWindowData"
#define MENU_PATH "/MainMenu/ViewMenu/ViewOps_1"
-GTR_PLUGIN_REGISTER_TYPE(GtranslatorFullscreenPlugin, gtranslator_fullscreen_plugin)
-
-static void
-on_fullscreen_activated (GtkToggleAction *action,
- GtranslatorWindow *window)
+GTR_PLUGIN_REGISTER_TYPE (GtranslatorFullscreenPlugin,
+ gtranslator_fullscreen_plugin)
+ static void on_fullscreen_activated (GtkToggleAction * action,
+ GtranslatorWindow * window)
{
- if (gtk_toggle_action_get_active (action))
- gtk_window_fullscreen (GTK_WINDOW (window));
- else gtk_window_unfullscreen (GTK_WINDOW (window));
+ if (gtk_toggle_action_get_active (action))
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ else
+ gtk_window_unfullscreen (GTK_WINDOW (window));
}
-static const GtkToggleActionEntry action_entries[] =
-{
- { "Fullscreen", NULL, N_("_Fullscreen"), "F11",
- N_("Place window on fullscreen state"),
- G_CALLBACK (on_fullscreen_activated)},
+static const GtkToggleActionEntry action_entries[] = {
+ {"Fullscreen", NULL, N_("_Fullscreen"), "F11",
+ N_("Place window on fullscreen state"),
+ G_CALLBACK (on_fullscreen_activated)},
};
typedef struct
{
- GtkActionGroup *action_group;
- guint ui_id;
+ GtkActionGroup *action_group;
+ guint ui_id;
} WindowData;
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != NULL);
- g_free (data);
+ g_free (data);
}
static void
-gtranslator_fullscreen_plugin_init (GtranslatorFullscreenPlugin *message_table)
+gtranslator_fullscreen_plugin_init (GtranslatorFullscreenPlugin *
+ message_table)
{
}
static void
-gtranslator_fullscreen_plugin_finalize (GObject *object)
+gtranslator_fullscreen_plugin_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_fullscreen_plugin_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_fullscreen_plugin_parent_class)->
+ finalize (object);
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkUIManager *manager;
- WindowData *data;
- GError *error = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- data = g_new (WindowData, 1);
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data->action_group = gtk_action_group_new ("GtranslatorFullscreenPluginActions");
- gtk_action_group_set_translation_domain (data->action_group,
- GETTEXT_PACKAGE);
- gtk_action_group_add_toggle_actions (data->action_group,
- action_entries,
- G_N_ELEMENTS (action_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
-
- data->ui_id = gtk_ui_manager_new_merge_id (manager);
-
- if (data->ui_id == 0)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- g_free (data);
- return;
- }
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
-
- gtk_ui_manager_add_ui (manager,
- data->ui_id,
- MENU_PATH,
- "Fullscreen",
- "Fullscreen",
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
+ GtkUIManager *manager;
+ WindowData *data;
+ GError *error = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ data = g_new (WindowData, 1);
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data->action_group =
+ gtk_action_group_new ("GtranslatorFullscreenPluginActions");
+ gtk_action_group_set_translation_domain (data->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_toggle_actions (data->action_group, action_entries,
+ G_N_ELEMENTS (action_entries), window);
+
+ gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
+
+ data->ui_id = gtk_ui_manager_new_merge_id (manager);
+
+ if (data->ui_id == 0)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_free (data);
+ return;
+ }
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
+
+ gtk_ui_manager_add_ui (manager,
+ data->ui_id,
+ MENU_PATH,
+ "Fullscreen",
+ "Fullscreen", GTK_UI_MANAGER_MENUITEM, FALSE);
}
static void
-impl_deactivate(GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkUIManager *manager;
- WindowData *data;
-
- manager = gtranslator_window_get_ui_manager (window);
+ GtkUIManager *manager;
+ WindowData *data;
+
+ manager = gtranslator_window_get_ui_manager (window);
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- gtk_ui_manager_remove_ui (manager, data->ui_id);
- gtk_ui_manager_remove_action_group (manager, data->action_group);
+ gtk_ui_manager_remove_ui (manager, data->ui_id);
+ gtk_ui_manager_remove_action_group (manager, data->action_group);
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
static void
-gtranslator_fullscreen_plugin_class_init (GtranslatorFullscreenPluginClass *klass)
+gtranslator_fullscreen_plugin_class_init (GtranslatorFullscreenPluginClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
- object_class->finalize = gtranslator_fullscreen_plugin_finalize;
+ object_class->finalize = gtranslator_fullscreen_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
}
diff --git a/plugins/fullscreen/fullscreen-plugin.h b/plugins/fullscreen/fullscreen-plugin.h
index 7a3180e..bba80e6 100644
--- a/plugins/fullscreen/fullscreen-plugin.h
+++ b/plugins/fullscreen/fullscreen-plugin.h
@@ -25,7 +25,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,38 +34,40 @@ G_BEGIN_DECLS
#define GTR_IS_FULLSCREEN_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_FULLSCREEN_PLUGIN))
#define GTR_IS_FULLSCREEN_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_FULLSCREEN_PLUGIN))
#define GTR_FULLSCREEN_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_FULLSCREEN_PLUGIN_PLUGIN, GtranslatorFullscreenPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorFullscreenPluginPrivate GtranslatorFullscreenPluginPrivate;
+typedef struct _GtranslatorFullscreenPluginPrivate
+ GtranslatorFullscreenPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorFullscreenPlugin GtranslatorFullscreenPlugin;
+typedef struct _GtranslatorFullscreenPlugin GtranslatorFullscreenPlugin;
struct _GtranslatorFullscreenPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
};
/*
* Class definition
*/
-typedef struct _GtranslatorFullscreenPluginClass GtranslatorFullscreenPluginClass;
+typedef struct _GtranslatorFullscreenPluginClass
+ GtranslatorFullscreenPluginClass;
struct _GtranslatorFullscreenPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_fullscreen_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_fullscreen_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_FULLSCREEN_PLUGIN_H__ */
diff --git a/plugins/glossary/glossary-panel.c b/plugins/glossary/glossary-panel.c
index 3435298..6483f58 100644
--- a/plugins/glossary/glossary-panel.c
+++ b/plugins/glossary/glossary-panel.c
@@ -37,134 +37,135 @@
GTR_TYPE_GLOSSARY_PANEL, \
GtranslatorGlossaryPanelPrivate))
-G_DEFINE_TYPE(GtranslatorGlossaryPanel, gtranslator_glossary_panel, GTK_TYPE_VBOX)
-
+G_DEFINE_TYPE (GtranslatorGlossaryPanel, gtranslator_glossary_panel,
+ GTK_TYPE_VBOX)
#define XML_FILE_NAME "glossary.xml"
-
/*
* TreeItem structure
*/
-typedef struct _TreeItem TreeItem;
-struct _TreeItem
-{
- gchar *word;
- gchar *description;
- GList *children;
-};
-
-enum
-{
- WORD_COLUMN,
- DESCRIPTION_COLUMN,
- N_COLUMNS
-};
-
-struct _GtranslatorGlossaryPanelPrivate
-{
- GtkWidget *tree;
- GtkWidget *search_entry;
- GtkWidget *add_button;
- xmlDocPtr *doc;
- GList *elements;
-};
-
-typedef struct person {
- xmlChar *name;
- xmlChar *email;
- xmlChar *company;
- xmlChar *organisation;
- xmlChar *smail;
- xmlChar *webPage;
- xmlChar *phone;
-} person, *personPtr;
+ typedef struct _TreeItem TreeItem;
+ struct _TreeItem
+ {
+ gchar *word;
+ gchar *description;
+ GList *children;
+ };
+
+ enum
+ {
+ WORD_COLUMN,
+ DESCRIPTION_COLUMN,
+ N_COLUMNS
+ };
+
+ struct _GtranslatorGlossaryPanelPrivate
+ {
+ GtkWidget *tree;
+ GtkWidget *search_entry;
+ GtkWidget *add_button;
+ xmlDocPtr *doc;
+ GList *elements;
+ };
+
+ typedef struct person
+ {
+ xmlChar *name;
+ xmlChar *email;
+ xmlChar *company;
+ xmlChar *organisation;
+ xmlChar *smail;
+ xmlChar *webPage;
+ xmlChar *phone;
+ } person, *personPtr;
/*
* And the code needed to parse it
*/
-static personPtr
-parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
- personPtr ret = NULL;
-
- /*
- * allocate the struct
- */
- ret = (personPtr) malloc(sizeof(person));
- if (ret == NULL) {
- fprintf(stderr,"out of memory\n");
- return(NULL);
+ static personPtr parsePerson (xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
+{
+ personPtr ret = NULL;
+
+ /*
+ * allocate the struct
+ */
+ ret = (personPtr) malloc (sizeof (person));
+ if (ret == NULL)
+ {
+ fprintf (stderr, "out of memory\n");
+ return (NULL);
}
- memset(ret, 0, sizeof(person));
-
- /* We don't care what the top level element name is */
- /* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
- cur = cur->xmlChildrenNode;
- while (cur != NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"Person")) &&
- (cur->ns == ns))
- ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"Email")) &&
- (cur->ns == ns))
- ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
- cur = cur->next;
+ memset (ret, 0, sizeof (person));
+
+ /* We don't care what the top level element name is */
+ /* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp (cur->name, (const xmlChar *) "Person")) &&
+ (cur->ns == ns))
+ ret->name = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
+ if ((!xmlStrcmp (cur->name, (const xmlChar *) "Email")) &&
+ (cur->ns == ns))
+ ret->email = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
+ cur = cur->next;
}
- return(ret);
+ return (ret);
}
static void
-process_node(xmlNode *root_node)
-{
- GtranslatorGlossaryPanelPrivate *priv;
-
- xmlNodePtr cur_node;
-
- cur_node = cur_node->xmlChildrenNode;
+process_node (xmlNode * root_node)
+{
+ GtranslatorGlossaryPanelPrivate *priv;
+
+ xmlNodePtr cur_node;
+
+ cur_node = cur_node->xmlChildrenNode;
}
static gboolean
-gtranslator_glossary_panel_load_items(GtranslatorGlossaryPanel *panel)
+gtranslator_glossary_panel_load_items (GtranslatorGlossaryPanel * panel)
{
- GtranslatorGlossaryPanelPrivate *priv = panel->priv;
-
- return FALSE;
+ GtranslatorGlossaryPanelPrivate *priv = panel->priv;
+
+ return FALSE;
}
static void
-gtranslator_glossary_panel_draw (GtranslatorGlossaryPanel *panel)
+gtranslator_glossary_panel_draw (GtranslatorGlossaryPanel * panel)
{
- GtranslatorGlossaryPanelPrivate *priv = panel->priv;
-
- priv->tree = gtk_tree_view_new();
+ GtranslatorGlossaryPanelPrivate *priv = panel->priv;
+
+ priv->tree = gtk_tree_view_new ();
}
static void
-gtranslator_glossary_panel_init (GtranslatorGlossaryPanel *panel)
-{
- panel->priv = GTR_GLOSSARY_PANEL_GET_PRIVATE (panel);
-
-
+gtranslator_glossary_panel_init (GtranslatorGlossaryPanel * panel)
+{
+ panel->priv = GTR_GLOSSARY_PANEL_GET_PRIVATE (panel);
+
+
}
static void
-gtranslator_glossary_panel_finalize (GObject *object)
+gtranslator_glossary_panel_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_glossary_panel_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_glossary_panel_parent_class)->finalize (object);
}
static void
-gtranslator_glossary_panel_class_init (GtranslatorGlossaryPanelClass *klass)
+gtranslator_glossary_panel_class_init (GtranslatorGlossaryPanelClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorGlossaryPanelPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorGlossaryPanelPrivate));
- object_class->finalize = gtranslator_glossary_panel_finalize;
+ object_class->finalize = gtranslator_glossary_panel_finalize;
}
GtkWidget *
gtranslator_glossary_panel_new (void)
{
- return GTK_WIDGET (g_object_new (GTR_TYPE_GLOSSARY_PANEL, NULL));
+ return GTK_WIDGET (g_object_new (GTR_TYPE_GLOSSARY_PANEL, NULL));
}
-
diff --git a/plugins/glossary/glossary-panel.h b/plugins/glossary/glossary-panel.h
index a393bcd..d4798f4 100644
--- a/plugins/glossary/glossary-panel.h
+++ b/plugins/glossary/glossary-panel.h
@@ -29,7 +29,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -39,40 +38,41 @@ G_BEGIN_DECLS
#define GTR_IS_GLOSSARY_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_GLOSSARY_PANEL))
#define GTR_IS_GLOSSARY_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_GLOSSARY_PANEL))
#define GTR_GLOSSARY_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_GLOSSARY_PANEL, GtranslatorGlossaryPanelClass))
-
/* Private structure type */
-typedef struct _GtranslatorGlossaryPanelPrivate GtranslatorGlossaryPanelPrivate;
+typedef struct _GtranslatorGlossaryPanelPrivate
+ GtranslatorGlossaryPanelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorGlossaryPanel GtranslatorGlossaryPanel;
+typedef struct _GtranslatorGlossaryPanel GtranslatorGlossaryPanel;
struct _GtranslatorGlossaryPanel
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorGlossaryPanelPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorGlossaryPanelPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorGlossaryPanelClass GtranslatorGlossaryPanelClass;
+typedef struct _GtranslatorGlossaryPanelClass GtranslatorGlossaryPanelClass;
struct _GtranslatorGlossaryPanelClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_glossary_panel_get_type (void) G_GNUC_CONST;
-GType gtranslator_glossary_panel_register_type (GTypeModule * module);
-GtkWidget *gtranslator_glossary_panel_new (void);
+GType
+gtranslator_glossary_panel_get_type (void)
+ G_GNUC_CONST;
+ GType gtranslator_glossary_panel_register_type (GTypeModule * module);
+ GtkWidget *gtranslator_glossary_panel_new (void);
G_END_DECLS
-
#endif /* __GLOSSARY_PANEL_H__ */
diff --git a/plugins/insert-params/insert-params-plugin.c b/plugins/insert-params/insert-params-plugin.c
index 8d5208b..f045ad2 100644
--- a/plugins/insert-params/insert-params-plugin.c
+++ b/plugins/insert-params/insert-params-plugin.c
@@ -31,373 +31,357 @@
#define WINDOW_DATA_KEY "GtranslatorInsertParamsPluginWindowData"
-GTR_PLUGIN_REGISTER_TYPE(GtranslatorInsertParamsPlugin, gtranslator_insert_params_plugin)
+GTR_PLUGIN_REGISTER_TYPE (GtranslatorInsertParamsPlugin,
+ gtranslator_insert_params_plugin)
+ static GSList *params = NULL;
+ static gint param_position;
+
+ static const gchar param_regex[] = "\\%\\%|\\%" "(?:[1-9][0-9]*\\$)?" // argument
+ "[#0\\-\\ \\+\\'I]*" // flags
+ "(?:[1-9][0-9]*|\\*)?" // width
+ "(?:\\.\\-?(?:[0-9]+|\\*))?" // precision
+ "(?:hh|ll|[hlLqjzt])?" // length modifier
+ "[diouxXeEfFgGaAcsCSpnm]"; // conversion specifier
+
+ static void
+ on_next_tag_activated (GtkAction * action, GtranslatorWindow * window)
+{
+ GtranslatorView *view;
+ GtkTextBuffer *buffer;
+ GSList *param;
-static GSList *params = NULL;
-static gint param_position;
+ if (params == NULL)
+ return;
-static const gchar param_regex[] =
- "\\%\\%|\\%"
- "(?:[1-9][0-9]*\\$)?" // argument
- "[#0\\-\\ \\+\\'I]*" // flags
- "(?:[1-9][0-9]*|\\*)?" // width
- "(?:\\.\\-?(?:[0-9]+|\\*))?" // precision
- "(?:hh|ll|[hlLqjzt])?" // length modifier
- "[diouxXeEfFgGaAcsCSpnm]"; // conversion specifier
+ if (param_position >= g_slist_length (params))
+ param_position = 0;
-static void
-on_next_tag_activated (GtkAction *action,
- GtranslatorWindow *window)
-{
- GtranslatorView *view;
- GtkTextBuffer *buffer;
- GSList *param;
-
- if (params == NULL)
- return;
-
- if (param_position >= g_slist_length (params))
- param_position = 0;
-
- param = g_slist_nth (params, param_position);
-
- view = gtranslator_window_get_active_view (window);
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- gtk_text_buffer_begin_user_action (buffer);
- gtk_text_buffer_insert_at_cursor (buffer,
- (const gchar *)param->data,
- strlen (param->data));
- gtk_text_buffer_end_user_action (buffer);
-
- param_position++;
+ param = g_slist_nth (params, param_position);
+
+ view = gtranslator_window_get_active_view (window);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_buffer_insert_at_cursor (buffer,
+ (const gchar *) param->data,
+ strlen (param->data));
+ gtk_text_buffer_end_user_action (buffer);
+
+ param_position++;
}
-static const GtkActionEntry action_entries[] =
-{
- { "NextParam", NULL, N_("_Next Param"), "<control><shift>K",
- N_("Insert the next param of the message"),
- G_CALLBACK (on_next_tag_activated)},
- { "InsertParams", NULL, N_("_Insert Params") }
+static const GtkActionEntry action_entries[] = {
+ {"NextParam", NULL, N_("_Next Param"), "<control><shift>K",
+ N_("Insert the next param of the message"),
+ G_CALLBACK (on_next_tag_activated)},
+ {"InsertParams", NULL, N_("_Insert Params")}
};
static const gchar submenu[] =
-"<ui>"
-" <menubar name='MainMenu'>"
-" <menu name='EditMenu' action='Edit'>"
-" <placeholder name='EditOps_1'>"
-" <menuitem name='EditNextParam' action='NextParam' />"
-" <menuitem name='EditInsertParams' action='InsertParams' />"
-" </placeholder>"
-" </menu>"
-" </menubar>"
-"</ui>";
+ "<ui>"
+ " <menubar name='MainMenu'>"
+ " <menu name='EditMenu' action='Edit'>"
+ " <placeholder name='EditOps_1'>"
+ " <menuitem name='EditNextParam' action='NextParam' />"
+ " <menuitem name='EditInsertParams' action='InsertParams' />"
+ " </placeholder>" " </menu>" " </menubar>" "</ui>";
typedef struct
{
- GtkActionGroup *action_group;
- guint ui_id;
+ GtkActionGroup *action_group;
+ guint ui_id;
} WindowData;
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != NULL);
- g_free (data);
+ g_free (data);
}
static void
-update_ui_real (GtranslatorWindow *window,
- WindowData *data)
+update_ui_real (GtranslatorWindow * window, WindowData * data)
{
- GtkTextView *view;
- GtkAction *action;
-
- view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
-
- action = gtk_action_group_get_action (data->action_group,
- "InsertParams");
- gtk_action_set_sensitive (action,
- (view != NULL) &&
- gtk_text_view_get_editable (view));
-
- action = gtk_action_group_get_action (data->action_group,
- "NextParam");
- gtk_action_set_sensitive (action,
- (view != NULL) &&
- gtk_text_view_get_editable (view));
+ GtkTextView *view;
+ GtkAction *action;
+
+ view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
+
+ action = gtk_action_group_get_action (data->action_group, "InsertParams");
+ gtk_action_set_sensitive (action,
+ (view != NULL) &&
+ gtk_text_view_get_editable (view));
+
+ action = gtk_action_group_get_action (data->action_group, "NextParam");
+ gtk_action_set_sensitive (action,
+ (view != NULL) &&
+ gtk_text_view_get_editable (view));
}
static void
-gtranslator_insert_params_plugin_init (GtranslatorInsertParamsPlugin *message_table)
+gtranslator_insert_params_plugin_init (GtranslatorInsertParamsPlugin *
+ message_table)
{
}
static void
-gtranslator_insert_params_plugin_finalize (GObject *object)
+gtranslator_insert_params_plugin_finalize (GObject * object)
{
- if (params != NULL)
- {
- g_slist_free (params);
- params = NULL;
- }
-
- G_OBJECT_CLASS (gtranslator_insert_params_plugin_parent_class)->finalize (object);
+ if (params != NULL)
+ {
+ g_slist_free (params);
+ params = NULL;
+ }
+
+ G_OBJECT_CLASS (gtranslator_insert_params_plugin_parent_class)->
+ finalize (object);
}
static void
-on_menuitem_activated (GtkMenuItem *item,
- GtranslatorWindow *window)
+on_menuitem_activated (GtkMenuItem * item, GtranslatorWindow * window)
{
- const gchar *name;
- GtkWidget *label;
- GtranslatorView *view;
- GtkTextBuffer *buffer;
-
- label = gtk_bin_get_child (GTK_BIN (item));
- name = gtk_label_get_text (GTK_LABEL (label));
-
- view = gtranslator_window_get_active_view (window);
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- gtk_text_buffer_begin_user_action (buffer);
- gtk_text_buffer_insert_at_cursor (buffer,
- name, strlen (name));
- gtk_text_buffer_end_user_action (buffer);
+ const gchar *name;
+ GtkWidget *label;
+ GtranslatorView *view;
+ GtkTextBuffer *buffer;
+
+ label = gtk_bin_get_child (GTK_BIN (item));
+ name = gtk_label_get_text (GTK_LABEL (label));
+
+ view = gtranslator_window_get_active_view (window);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_buffer_insert_at_cursor (buffer, name, strlen (name));
+ gtk_text_buffer_end_user_action (buffer);
}
static void
-parse_list (GtranslatorWindow *window)
+parse_list (GtranslatorWindow * window)
{
- GtkUIManager *manager;
- GtkWidget *insert_params, *next_param;
- GtkWidget *menuitem;
- GtkWidget *menu;
- GSList *l = params;
-
- manager = gtranslator_window_get_ui_manager (window);
-
- insert_params = gtk_ui_manager_get_widget (manager,
- "/MainMenu/EditMenu/EditOps_1/EditInsertParams");
- next_param = gtk_ui_manager_get_widget (manager,
- "/MainMenu/EditMenu/EditOps_1/EditNextParam");
-
- if (params == NULL)
- {
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_params), NULL);
- gtk_widget_set_sensitive (insert_params, FALSE);
- gtk_widget_set_sensitive (next_param, FALSE);
- return;
- }
-
- gtk_widget_set_sensitive (insert_params, TRUE);
- gtk_widget_set_sensitive (next_param, TRUE);
-
- menu = gtk_menu_new ();
- do{
- menuitem = gtk_menu_item_new_with_label ((const gchar *)l->data);
- gtk_widget_show (menuitem);
-
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (on_menuitem_activated), window);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- }while ((l = g_slist_next (l)));
-
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_params), menu);
+ GtkUIManager *manager;
+ GtkWidget *insert_params, *next_param;
+ GtkWidget *menuitem;
+ GtkWidget *menu;
+ GSList *l = params;
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ insert_params = gtk_ui_manager_get_widget (manager,
+ "/MainMenu/EditMenu/EditOps_1/EditInsertParams");
+ next_param = gtk_ui_manager_get_widget (manager,
+ "/MainMenu/EditMenu/EditOps_1/EditNextParam");
+
+ if (params == NULL)
+ {
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_params), NULL);
+ gtk_widget_set_sensitive (insert_params, FALSE);
+ gtk_widget_set_sensitive (next_param, FALSE);
+ return;
+ }
+
+ gtk_widget_set_sensitive (insert_params, TRUE);
+ gtk_widget_set_sensitive (next_param, TRUE);
+
+ menu = gtk_menu_new ();
+ do
+ {
+ menuitem = gtk_menu_item_new_with_label ((const gchar *) l->data);
+ gtk_widget_show (menuitem);
+
+ g_signal_connect (menuitem, "activate",
+ G_CALLBACK (on_menuitem_activated), window);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ }
+ while ((l = g_slist_next (l)));
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_params), menu);
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorWindow *window)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg, GtranslatorWindow * window)
{
- const gchar *msgid;
- GRegex *regex;
- GMatchInfo *match_info;
- gchar *word;
- gint i;
-
- if (params != NULL)
- {
- g_slist_foreach (params, (GFunc)g_free, NULL);
- g_slist_free (params);
- params = NULL;
- }
-
- /*
- * If we show another message we have to restart the index
- * of the params
- */
- param_position = 0;
-
- msgid = gtranslator_msg_get_msgid (msg);
-
- /*
- * Regular expression
- */
- regex = g_regex_new (param_regex, 0, 0, NULL);
- g_regex_match (regex, msgid, 0, &match_info);
- while (g_match_info_matches (match_info))
+ const gchar *msgid;
+ GRegex *regex;
+ GMatchInfo *match_info;
+ gchar *word;
+ gint i;
+
+ if (params != NULL)
+ {
+ g_slist_foreach (params, (GFunc) g_free, NULL);
+ g_slist_free (params);
+ params = NULL;
+ }
+
+ /*
+ * If we show another message we have to restart the index
+ * of the params
+ */
+ param_position = 0;
+
+ msgid = gtranslator_msg_get_msgid (msg);
+
+ /*
+ * Regular expression
+ */
+ regex = g_regex_new (param_regex, 0, 0, NULL);
+ g_regex_match (regex, msgid, 0, &match_info);
+ while (g_match_info_matches (match_info))
+ {
+ gchar *word_collate;
+
+ word = g_match_info_fetch (match_info, 0);
+ word_collate = g_utf8_collate_key (word, -1);
+ for (i = 0; i < g_slist_length (params); i++)
{
- gchar *word_collate;
-
- word = g_match_info_fetch (match_info, 0);
- word_collate = g_utf8_collate_key (word, -1);
- for (i = 0; i < g_slist_length (params); i++)
- {
- gchar *param_collate;
- gchar *param = g_slist_nth_data (params, i);
-
- param_collate = g_utf8_collate_key (param, -1);
- if (strcmp (param_collate, word_collate) == 0)
- {
- g_free (word);
- word = NULL;
- }
- g_free (param_collate);
- }
- g_free (word_collate);
-
- if (word != NULL)
- params = g_slist_append (params, word);
- g_match_info_next (match_info, NULL);
+ gchar *param_collate;
+ gchar *param = g_slist_nth_data (params, i);
+
+ param_collate = g_utf8_collate_key (param, -1);
+ if (strcmp (param_collate, word_collate) == 0)
+ {
+ g_free (word);
+ word = NULL;
+ }
+ g_free (param_collate);
}
- g_match_info_free (match_info);
- g_regex_unref (regex);
-
- parse_list (window);
+ g_free (word_collate);
+
+ if (word != NULL)
+ params = g_slist_append (params, word);
+ g_match_info_next (match_info, NULL);
+ }
+ g_match_info_free (match_info);
+ g_regex_unref (regex);
+
+ parse_list (window);
}
static void
-page_added_cb (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- GtranslatorWindow *window)
-{
- g_signal_connect (child, "showed-message",
- G_CALLBACK (showed_message_cb), window);
+page_added_cb (GtkNotebook * notebook,
+ GtkWidget * child, guint page_num, GtranslatorWindow * window)
+{
+ g_signal_connect (child, "showed-message",
+ G_CALLBACK (showed_message_cb), window);
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkUIManager *manager;
- WindowData *data;
- GError *error = NULL;
- GtranslatorNotebook *notebook;
- GList *tabs = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- data = g_new (WindowData, 1);
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data->action_group = gtk_action_group_new ("GtranslatorInsertParamsPluginActions");
- gtk_action_group_set_translation_domain (data->action_group,
- GETTEXT_PACKAGE);
- gtk_action_group_add_actions (data->action_group,
- action_entries,
- G_N_ELEMENTS (action_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
-
- data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
- submenu,
- -1,
- &error);
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- g_free (data);
- return;
- }
+ GtkUIManager *manager;
+ WindowData *data;
+ GError *error = NULL;
+ GtranslatorNotebook *notebook;
+ GList *tabs = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ data = g_new (WindowData, 1);
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data->action_group =
+ gtk_action_group_new ("GtranslatorInsertParamsPluginActions");
+ gtk_action_group_set_translation_domain (data->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (data->action_group, action_entries,
+ G_N_ELEMENTS (action_entries), window);
+
+ gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
+
+ data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
+ submenu, -1, &error);
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_free (data);
+ return;
+ }
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
+
+ update_ui_real (window, data);
+
+ /*Adding menuitems */
+
+ notebook = gtranslator_window_get_notebook (window);
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
-
- update_ui_real (window, data);
-
- /*Adding menuitems*/
-
- notebook = gtranslator_window_get_notebook (window);
-
- g_signal_connect (GTK_NOTEBOOK (notebook),
- "page-added",
- G_CALLBACK (page_added_cb), window);
-
- tabs = gtranslator_window_get_all_tabs (window);
-
- if(tabs == NULL)
- return;
- do{
- g_signal_connect (tabs->data, "showed-message",
- G_CALLBACK (showed_message_cb), window);
- }while((tabs = g_list_next(tabs)));
+ g_signal_connect (GTK_NOTEBOOK (notebook),
+ "page-added", G_CALLBACK (page_added_cb), window);
+
+ tabs = gtranslator_window_get_all_tabs (window);
+
+ if (tabs == NULL)
+ return;
+ do
+ {
+ g_signal_connect (tabs->data, "showed-message",
+ G_CALLBACK (showed_message_cb), window);
+ }
+ while ((tabs = g_list_next (tabs)));
}
static void
-impl_deactivate(GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtranslatorNotebook *notebook;
- GtkUIManager *manager;
- WindowData *data;
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
-
- gtk_ui_manager_remove_ui (manager, data->ui_id);
- gtk_ui_manager_remove_action_group (manager, data->action_group);
-
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
-
- notebook = gtranslator_window_get_notebook(window);
-
- g_signal_handlers_disconnect_by_func(notebook,
- page_added_cb,
- window);
-
- if (params != NULL)
- {
- g_slist_free (params);
- params = NULL;
- }
+ GtranslatorNotebook *notebook;
+ GtkUIManager *manager;
+ WindowData *data;
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ gtk_ui_manager_remove_ui (manager, data->ui_id);
+ gtk_ui_manager_remove_action_group (manager, data->action_group);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+
+ notebook = gtranslator_window_get_notebook (window);
+
+ g_signal_handlers_disconnect_by_func (notebook, page_added_cb, window);
+
+ if (params != NULL)
+ {
+ g_slist_free (params);
+ params = NULL;
+ }
}
static void
-impl_update_ui (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_update_ui (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
+ WindowData *data;
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- update_ui_real (window, data);
+ update_ui_real (window, data);
}
static void
-gtranslator_insert_params_plugin_class_init (GtranslatorInsertParamsPluginClass *klass)
+gtranslator_insert_params_plugin_class_init
+ (GtranslatorInsertParamsPluginClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
- object_class->finalize = gtranslator_insert_params_plugin_finalize;
+ object_class->finalize = gtranslator_insert_params_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->update_ui = impl_update_ui;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
}
diff --git a/plugins/insert-params/insert-params-plugin.h b/plugins/insert-params/insert-params-plugin.h
index 191bfcb..bda2c14 100644
--- a/plugins/insert-params/insert-params-plugin.h
+++ b/plugins/insert-params/insert-params-plugin.h
@@ -25,7 +25,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,38 +34,40 @@ G_BEGIN_DECLS
#define GTR_IS_INSERT_PARAMS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_INSERT_PARAMS_PLUGIN))
#define GTR_IS_INSERT_PARAMS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_INSERT_PARAMS_PLUGIN))
#define GTR_INSERT_PARAMS_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_INSERT_PARAMS_PLUGIN_PLUGIN, GtranslatorInsertParamsPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorInsertParamsPluginPrivate GtranslatorInsertParamsPluginPrivate;
+typedef struct _GtranslatorInsertParamsPluginPrivate
+ GtranslatorInsertParamsPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorInsertParamsPlugin GtranslatorInsertParamsPlugin;
+typedef struct _GtranslatorInsertParamsPlugin GtranslatorInsertParamsPlugin;
struct _GtranslatorInsertParamsPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
};
/*
* Class definition
*/
-typedef struct _GtranslatorInsertParamsPluginClass GtranslatorInsertParamsPluginClass;
+typedef struct _GtranslatorInsertParamsPluginClass
+ GtranslatorInsertParamsPluginClass;
struct _GtranslatorInsertParamsPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_insert_params_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_insert_params_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_INSERT_PARAMS_PLUGIN_H__ */
diff --git a/plugins/insert-tags/insert-tags-plugin.c b/plugins/insert-tags/insert-tags-plugin.c
index 0e63aa7..40c3702 100644
--- a/plugins/insert-tags/insert-tags-plugin.c
+++ b/plugins/insert-tags/insert-tags-plugin.c
@@ -31,346 +31,332 @@
#define WINDOW_DATA_KEY "GtranslatorInsertTagsPluginWindowData"
-GTR_PLUGIN_REGISTER_TYPE(GtranslatorInsertTagsPlugin, gtranslator_insert_tags_plugin)
+GTR_PLUGIN_REGISTER_TYPE (GtranslatorInsertTagsPlugin,
+ gtranslator_insert_tags_plugin)
+ static GSList *tags = NULL;
+ static gint tag_position;
-static GSList *tags = NULL;
-static gint tag_position;
-
-static void
-on_next_tag_activated (GtkAction *action,
- GtranslatorWindow *window)
+ static void
+ on_next_tag_activated (GtkAction * action, GtranslatorWindow * window)
{
- GtranslatorView *view;
- GtkTextBuffer *buffer;
- GSList *tag;
-
- if (tags == NULL)
- return;
-
- if (tag_position >= g_slist_length (tags))
- tag_position = 0;
-
- tag = g_slist_nth (tags, tag_position);
-
- view = gtranslator_window_get_active_view (window);
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- gtk_text_buffer_begin_user_action (buffer);
- gtk_text_buffer_insert_at_cursor (buffer,
- (const gchar *)tag->data,
- strlen (tag->data));
- gtk_text_buffer_end_user_action (buffer);
-
- tag_position++;
+ GtranslatorView *view;
+ GtkTextBuffer *buffer;
+ GSList *tag;
+
+ if (tags == NULL)
+ return;
+
+ if (tag_position >= g_slist_length (tags))
+ tag_position = 0;
+
+ tag = g_slist_nth (tags, tag_position);
+
+ view = gtranslator_window_get_active_view (window);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_buffer_insert_at_cursor (buffer,
+ (const gchar *) tag->data,
+ strlen (tag->data));
+ gtk_text_buffer_end_user_action (buffer);
+
+ tag_position++;
}
-static const GtkActionEntry action_entries[] =
-{
- { "NextTag", NULL, N_("_Next Tag"), "<control><shift>I",
- N_("Insert the next tag of the message"),
- G_CALLBACK (on_next_tag_activated)},
- { "InsertTags", NULL, N_("_Insert Tags") }
+static const GtkActionEntry action_entries[] = {
+ {"NextTag", NULL, N_("_Next Tag"), "<control><shift>I",
+ N_("Insert the next tag of the message"),
+ G_CALLBACK (on_next_tag_activated)},
+ {"InsertTags", NULL, N_("_Insert Tags")}
};
static const gchar submenu[] =
-"<ui>"
-" <menubar name='MainMenu'>"
-" <menu name='EditMenu' action='Edit'>"
-" <placeholder name='EditOps_1'>"
-" <menuitem name='EditNextTag' action='NextTag' />"
-" <menuitem name='EditInsertTags' action='InsertTags' />"
-" </placeholder>"
-" </menu>"
-" </menubar>"
-"</ui>";
+ "<ui>"
+ " <menubar name='MainMenu'>"
+ " <menu name='EditMenu' action='Edit'>"
+ " <placeholder name='EditOps_1'>"
+ " <menuitem name='EditNextTag' action='NextTag' />"
+ " <menuitem name='EditInsertTags' action='InsertTags' />"
+ " </placeholder>" " </menu>" " </menubar>" "</ui>";
typedef struct
{
- GtkActionGroup *action_group;
- guint ui_id;
+ GtkActionGroup *action_group;
+ guint ui_id;
} WindowData;
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != NULL);
- g_free (data);
+ g_free (data);
}
static void
-update_ui_real (GtranslatorWindow *window,
- WindowData *data)
+update_ui_real (GtranslatorWindow * window, WindowData * data)
{
- GtkTextView *view;
- GtkAction *action;
-
- view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
-
- action = gtk_action_group_get_action (data->action_group,
- "InsertTags");
- gtk_action_set_sensitive (action,
- (view != NULL) &&
- gtk_text_view_get_editable (view));
-
- action = gtk_action_group_get_action (data->action_group,
- "NextTag");
- gtk_action_set_sensitive (action,
- (view != NULL) &&
- gtk_text_view_get_editable (view));
+ GtkTextView *view;
+ GtkAction *action;
+
+ view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
+
+ action = gtk_action_group_get_action (data->action_group, "InsertTags");
+ gtk_action_set_sensitive (action,
+ (view != NULL) &&
+ gtk_text_view_get_editable (view));
+
+ action = gtk_action_group_get_action (data->action_group, "NextTag");
+ gtk_action_set_sensitive (action,
+ (view != NULL) &&
+ gtk_text_view_get_editable (view));
}
static void
-gtranslator_insert_tags_plugin_init (GtranslatorInsertTagsPlugin *message_table)
+gtranslator_insert_tags_plugin_init (GtranslatorInsertTagsPlugin *
+ message_table)
{
}
static void
-gtranslator_insert_tags_plugin_finalize (GObject *object)
+gtranslator_insert_tags_plugin_finalize (GObject * object)
{
- if (tags != NULL)
- {
- g_slist_free (tags);
- tags = NULL;
- }
-
- G_OBJECT_CLASS (gtranslator_insert_tags_plugin_parent_class)->finalize (object);
+ if (tags != NULL)
+ {
+ g_slist_free (tags);
+ tags = NULL;
+ }
+
+ G_OBJECT_CLASS (gtranslator_insert_tags_plugin_parent_class)->
+ finalize (object);
}
static void
-on_menuitem_activated (GtkMenuItem *item,
- GtranslatorWindow *window)
+on_menuitem_activated (GtkMenuItem * item, GtranslatorWindow * window)
{
- const gchar *name;
- GtkWidget *label;
- GtranslatorView *view;
- GtkTextBuffer *buffer;
-
- label = gtk_bin_get_child (GTK_BIN (item));
- name = gtk_label_get_text (GTK_LABEL (label));
-
- view = gtranslator_window_get_active_view (window);
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- gtk_text_buffer_begin_user_action (buffer);
- gtk_text_buffer_insert_at_cursor (buffer,
- name, strlen (name));
- gtk_text_buffer_end_user_action (buffer);
+ const gchar *name;
+ GtkWidget *label;
+ GtranslatorView *view;
+ GtkTextBuffer *buffer;
+
+ label = gtk_bin_get_child (GTK_BIN (item));
+ name = gtk_label_get_text (GTK_LABEL (label));
+
+ view = gtranslator_window_get_active_view (window);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_buffer_insert_at_cursor (buffer, name, strlen (name));
+ gtk_text_buffer_end_user_action (buffer);
}
static void
-parse_list (GtranslatorWindow *window)
+parse_list (GtranslatorWindow * window)
{
- GtkUIManager *manager;
- GtkWidget *insert_tags, *next_tag;
- GtkWidget *menuitem;
- GtkWidget *menu;
- GSList *l = tags;
-
- manager = gtranslator_window_get_ui_manager (window);
-
- insert_tags = gtk_ui_manager_get_widget (manager,
- "/MainMenu/EditMenu/EditOps_1/EditInsertTags");
- next_tag = gtk_ui_manager_get_widget (manager,
- "/MainMenu/EditMenu/EditOps_1/EditNextTag");
-
- if (tags == NULL)
- {
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_tags), NULL);
- gtk_widget_set_sensitive (insert_tags, FALSE);
- gtk_widget_set_sensitive (next_tag, FALSE);
- return;
- }
-
- gtk_widget_set_sensitive (insert_tags, TRUE);
- gtk_widget_set_sensitive (next_tag, TRUE);
-
- menu = gtk_menu_new ();
-
- do{
- menuitem = gtk_menu_item_new_with_label ((const gchar *)l->data);
- gtk_widget_show (menuitem);
-
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (on_menuitem_activated), window);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- }while ((l = g_slist_next (l)));
-
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_tags), menu);
+ GtkUIManager *manager;
+ GtkWidget *insert_tags, *next_tag;
+ GtkWidget *menuitem;
+ GtkWidget *menu;
+ GSList *l = tags;
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ insert_tags = gtk_ui_manager_get_widget (manager,
+ "/MainMenu/EditMenu/EditOps_1/EditInsertTags");
+ next_tag = gtk_ui_manager_get_widget (manager,
+ "/MainMenu/EditMenu/EditOps_1/EditNextTag");
+
+ if (tags == NULL)
+ {
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_tags), NULL);
+ gtk_widget_set_sensitive (insert_tags, FALSE);
+ gtk_widget_set_sensitive (next_tag, FALSE);
+ return;
+ }
+
+ gtk_widget_set_sensitive (insert_tags, TRUE);
+ gtk_widget_set_sensitive (next_tag, TRUE);
+
+ menu = gtk_menu_new ();
+
+ do
+ {
+ menuitem = gtk_menu_item_new_with_label ((const gchar *) l->data);
+ gtk_widget_show (menuitem);
+
+ g_signal_connect (menuitem, "activate",
+ G_CALLBACK (on_menuitem_activated), window);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ }
+ while ((l = g_slist_next (l)));
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_tags), menu);
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorWindow *window)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg, GtranslatorWindow * window)
{
- const gchar *msgid;
- GRegex *regex;
- GMatchInfo *match_info;
-
- if (tags != NULL)
- {
- g_slist_foreach (tags, (GFunc)g_free, NULL);
- g_slist_free (tags);
- tags = NULL;
- }
-
- /*
- * If we show another message we have to restart the index
- * of the tags
- */
- tag_position = 0;
-
- msgid = gtranslator_msg_get_msgid (msg);
-
- /*
- * Regular expression
- */
- regex = g_regex_new ("<[-0-9a-zA-Z=.:_?\"/ ]+>", 0, 0, NULL);
- g_regex_match (regex, msgid, 0, &match_info);
- while (g_match_info_matches (match_info))
- {
- gchar *word;
-
- word = g_match_info_fetch (match_info, 0);
- tags = g_slist_append (tags, word);
- g_match_info_next (match_info, NULL);
- }
- g_match_info_free (match_info);
- g_regex_unref (regex);
-
- parse_list (window);
+ const gchar *msgid;
+ GRegex *regex;
+ GMatchInfo *match_info;
+
+ if (tags != NULL)
+ {
+ g_slist_foreach (tags, (GFunc) g_free, NULL);
+ g_slist_free (tags);
+ tags = NULL;
+ }
+
+ /*
+ * If we show another message we have to restart the index
+ * of the tags
+ */
+ tag_position = 0;
+
+ msgid = gtranslator_msg_get_msgid (msg);
+
+ /*
+ * Regular expression
+ */
+ regex = g_regex_new ("<[-0-9a-zA-Z=.:_?\"/ ]+>", 0, 0, NULL);
+ g_regex_match (regex, msgid, 0, &match_info);
+ while (g_match_info_matches (match_info))
+ {
+ gchar *word;
+
+ word = g_match_info_fetch (match_info, 0);
+ tags = g_slist_append (tags, word);
+ g_match_info_next (match_info, NULL);
+ }
+ g_match_info_free (match_info);
+ g_regex_unref (regex);
+
+ parse_list (window);
}
static void
-page_added_cb (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- GtranslatorWindow *window)
-{
- g_signal_connect (child, "showed-message",
- G_CALLBACK (showed_message_cb), window);
+page_added_cb (GtkNotebook * notebook,
+ GtkWidget * child, guint page_num, GtranslatorWindow * window)
+{
+ g_signal_connect (child, "showed-message",
+ G_CALLBACK (showed_message_cb), window);
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkUIManager *manager;
- WindowData *data;
- GError *error = NULL;
- GtranslatorNotebook *notebook;
- GList *tabs = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- data = g_new (WindowData, 1);
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data->action_group = gtk_action_group_new ("GtranslatorInsertTagsPluginActions");
- gtk_action_group_set_translation_domain (data->action_group,
- GETTEXT_PACKAGE);
- gtk_action_group_add_actions (data->action_group,
- action_entries,
- G_N_ELEMENTS (action_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
-
- data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
- submenu,
- -1,
- &error);
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- g_free (data);
- return;
- }
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
-
- update_ui_real (window, data);
-
- /*Adding menuitems*/
-
- notebook = gtranslator_window_get_notebook (window);
-
- g_signal_connect (GTK_NOTEBOOK (notebook),
- "page-added",
- G_CALLBACK (page_added_cb), window);
-
- tabs = gtranslator_window_get_all_tabs (window);
-
- if(tabs == NULL)
- return;
- do{
- g_signal_connect (tabs->data, "showed-message",
- G_CALLBACK (showed_message_cb), window);
- }while((tabs = g_list_next(tabs)));
+ GtkUIManager *manager;
+ WindowData *data;
+ GError *error = NULL;
+ GtranslatorNotebook *notebook;
+ GList *tabs = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ data = g_new (WindowData, 1);
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data->action_group =
+ gtk_action_group_new ("GtranslatorInsertTagsPluginActions");
+ gtk_action_group_set_translation_domain (data->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (data->action_group, action_entries,
+ G_N_ELEMENTS (action_entries), window);
+
+ gtk_ui_manager_insert_action_group (manager, data->action_group, -1);
+
+ data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
+ submenu, -1, &error);
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_free (data);
+ return;
+ }
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
+
+ update_ui_real (window, data);
+
+ /*Adding menuitems */
+
+ notebook = gtranslator_window_get_notebook (window);
+
+ g_signal_connect (GTK_NOTEBOOK (notebook),
+ "page-added", G_CALLBACK (page_added_cb), window);
+
+ tabs = gtranslator_window_get_all_tabs (window);
+
+ if (tabs == NULL)
+ return;
+ do
+ {
+ g_signal_connect (tabs->data, "showed-message",
+ G_CALLBACK (showed_message_cb), window);
+ }
+ while ((tabs = g_list_next (tabs)));
}
static void
-impl_deactivate(GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtranslatorNotebook *notebook;
- GtkUIManager *manager;
- WindowData *data;
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
-
- gtk_ui_manager_remove_ui (manager, data->ui_id);
- gtk_ui_manager_remove_action_group (manager, data->action_group);
-
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
-
- notebook = gtranslator_window_get_notebook(window);
-
- g_signal_handlers_disconnect_by_func(notebook,
- page_added_cb,
- window);
-
- if (tags != NULL)
- {
- g_slist_free (tags);
- tags = NULL;
- }
+ GtranslatorNotebook *notebook;
+ GtkUIManager *manager;
+ WindowData *data;
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ gtk_ui_manager_remove_ui (manager, data->ui_id);
+ gtk_ui_manager_remove_action_group (manager, data->action_group);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+
+ notebook = gtranslator_window_get_notebook (window);
+
+ g_signal_handlers_disconnect_by_func (notebook, page_added_cb, window);
+
+ if (tags != NULL)
+ {
+ g_slist_free (tags);
+ tags = NULL;
+ }
}
static void
-impl_update_ui (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_update_ui (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
+ WindowData *data;
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- update_ui_real (window, data);
+ update_ui_real (window, data);
}
static void
-gtranslator_insert_tags_plugin_class_init (GtranslatorInsertTagsPluginClass *klass)
+gtranslator_insert_tags_plugin_class_init (GtranslatorInsertTagsPluginClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
- object_class->finalize = gtranslator_insert_tags_plugin_finalize;
+ object_class->finalize = gtranslator_insert_tags_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->update_ui = impl_update_ui;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
}
diff --git a/plugins/insert-tags/insert-tags-plugin.h b/plugins/insert-tags/insert-tags-plugin.h
index a05f06e..1ffbdd1 100644
--- a/plugins/insert-tags/insert-tags-plugin.h
+++ b/plugins/insert-tags/insert-tags-plugin.h
@@ -25,7 +25,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,38 +34,40 @@ G_BEGIN_DECLS
#define GTR_IS_INSERT_TAGS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_INSERT_TAGS_PLUGIN))
#define GTR_IS_INSERT_TAGS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_INSERT_TAGS_PLUGIN))
#define GTR_INSERT_TAGS_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_INSERT_TAGS_PLUGIN_PLUGIN, GtranslatorInsertTagsPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorInsertTagsPluginPrivate GtranslatorInsertTagsPluginPrivate;
+typedef struct _GtranslatorInsertTagsPluginPrivate
+ GtranslatorInsertTagsPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorInsertTagsPlugin GtranslatorInsertTagsPlugin;
+typedef struct _GtranslatorInsertTagsPlugin GtranslatorInsertTagsPlugin;
struct _GtranslatorInsertTagsPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
};
/*
* Class definition
*/
-typedef struct _GtranslatorInsertTagsPluginClass GtranslatorInsertTagsPluginClass;
+typedef struct _GtranslatorInsertTagsPluginClass
+ GtranslatorInsertTagsPluginClass;
struct _GtranslatorInsertTagsPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_insert_tags_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_insert_tags_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_INSERT_TAGS_PLUGIN_H__ */
diff --git a/plugins/open-tran/open-tran-panel.c b/plugins/open-tran/open-tran-panel.c
index d9407de..e156445 100644
--- a/plugins/open-tran/open-tran-panel.c
+++ b/plugins/open-tran/open-tran-panel.c
@@ -49,115 +49,111 @@
#define OPEN_OFFICE_ICON PIXMAPSDIR"/oo-logo.png"
#define FEDORA_ICON PIXMAPSDIR"/fedora.png"
-GTR_PLUGIN_DEFINE_TYPE(GtranslatorOpenTranPanel, gtranslator_open_tran_panel, GTK_TYPE_VBOX)
+GTR_PLUGIN_DEFINE_TYPE (GtranslatorOpenTranPanel, gtranslator_open_tran_panel,
+ GTK_TYPE_VBOX)
+ struct _GtranslatorOpenTranPanelPrivate
+ {
+ GConfClient *gconf_client;
-struct _GtranslatorOpenTranPanelPrivate
-{
- GConfClient *gconf_client;
-
- GtkWidget *treeview;
- GtkListStore *store;
-
- GtkWidget *entry;
-
- SoupSession *session;
-
- GtranslatorWindow *window;
-
- gchar *text;
-};
-
-enum
-{
- ICON_COLUMN,
- TEXT_COLUMN,
- N_COLUMNS
-};
+ GtkWidget *treeview;
+ GtkListStore *store;
-static void
-show_error_dialog (GtranslatorWindow *parent,
- const gchar *message_format,
- ...)
+ GtkWidget *entry;
+
+ SoupSession *session;
+
+ GtranslatorWindow *window;
+
+ gchar *text;
+ };
+
+ enum
+ {
+ ICON_COLUMN,
+ TEXT_COLUMN,
+ N_COLUMNS
+ };
+
+ static void
+ show_error_dialog (GtranslatorWindow * parent,
+ const gchar * message_format, ...)
{
- gchar *msg = NULL;
- va_list args;
- GtkWidget *dialog;
-
- va_start (args, message_format);
- msg = g_strdup_vprintf (message_format, args);
- va_end (args);
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", msg);
- g_free (msg);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- &dialog);
- gtk_widget_show (dialog);
+ gchar *msg = NULL;
+ va_list args;
+ GtkWidget *dialog;
+
+ va_start (args, message_format);
+ msg = g_strdup_vprintf (message_format, args);
+ va_end (args);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE, "%s", msg);
+ g_free (msg);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), &dialog);
+ gtk_widget_show (dialog);
}
static GdkPixbuf *
-create_pixbuf (const gchar *path)
+create_pixbuf (const gchar * path)
{
- GdkPixbuf *icon;
- GError *error = NULL;
-
- icon = gdk_pixbuf_new_from_file (path, &error);
-
- if (error)
- {
- g_warning ("Could not load icon: %s\n", error->message);
- g_error_free (error);
- return NULL;
- }
-
- return icon;
+ GdkPixbuf *icon;
+ GError *error = NULL;
+
+ icon = gdk_pixbuf_new_from_file (path, &error);
+
+ if (error)
+ {
+ g_warning ("Could not load icon: %s\n", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+
+ return icon;
}
static void
-print_struct_to_tree_view (const gchar *str,
- GtranslatorOpenTranPanel *panel)
+print_struct_to_tree_view (const gchar * str,
+ GtranslatorOpenTranPanel * panel)
{
- GdkPixbuf *icon;
- GtkTreeIter iter;
-
- /*
- * Text value
- */
- if (strcmp ("GNOME", str) == 0)
- icon = create_pixbuf (GNOME_ICON);
- else if (strcmp ("KDE", str) == 0)
- icon = create_pixbuf (KDE_ICON);
- else if (strcmp ("MOZILLA", str) == 0)
- icon = create_pixbuf (MOZILLA_ICON);
- else if (strcmp ("DEBIAN", str) == 0)
- icon = create_pixbuf (DEBIAN_ICON);
- else if (strcmp ("SUSE", str) == 0)
- icon = create_pixbuf (SUSE_ICON);
- else if (strcmp ("XFCE", str) == 0)
- icon = create_pixbuf (XFCE_ICON);
- else if (strcmp ("Inkscape", str) == 0)
- icon = create_pixbuf (INKSCAPE_ICON);
- else if (strcmp ("OpenOffice.org", str) == 0)
- icon = create_pixbuf (OPEN_OFFICE_ICON);
- else if (strcmp ("Fedora", str) == 0)
- icon = create_pixbuf (FEDORA_ICON);
- else icon = NULL;
-
- gtk_list_store_append (panel->priv->store, &iter);
- gtk_list_store_set (panel->priv->store, &iter,
- ICON_COLUMN, icon,
- TEXT_COLUMN, panel->priv->text,
- -1);
-
- g_free (panel->priv->text);
-
- if (icon)
- g_object_unref (icon);
+ GdkPixbuf *icon;
+ GtkTreeIter iter;
+
+ /*
+ * Text value
+ */
+ if (strcmp ("GNOME", str) == 0)
+ icon = create_pixbuf (GNOME_ICON);
+ else if (strcmp ("KDE", str) == 0)
+ icon = create_pixbuf (KDE_ICON);
+ else if (strcmp ("MOZILLA", str) == 0)
+ icon = create_pixbuf (MOZILLA_ICON);
+ else if (strcmp ("DEBIAN", str) == 0)
+ icon = create_pixbuf (DEBIAN_ICON);
+ else if (strcmp ("SUSE", str) == 0)
+ icon = create_pixbuf (SUSE_ICON);
+ else if (strcmp ("XFCE", str) == 0)
+ icon = create_pixbuf (XFCE_ICON);
+ else if (strcmp ("Inkscape", str) == 0)
+ icon = create_pixbuf (INKSCAPE_ICON);
+ else if (strcmp ("OpenOffice.org", str) == 0)
+ icon = create_pixbuf (OPEN_OFFICE_ICON);
+ else if (strcmp ("Fedora", str) == 0)
+ icon = create_pixbuf (FEDORA_ICON);
+ else
+ icon = NULL;
+
+ gtk_list_store_append (panel->priv->store, &iter);
+ gtk_list_store_set (panel->priv->store, &iter,
+ ICON_COLUMN, icon, TEXT_COLUMN, panel->priv->text, -1);
+
+ g_free (panel->priv->text);
+
+ if (icon)
+ g_object_unref (icon);
}
/*
@@ -165,315 +161,307 @@ print_struct_to_tree_view (const gchar *str,
* http://bugzilla.gnome.org/show_bug.cgi?id=506469
*/
static void
-print_struct_field (gpointer key,
- gpointer value,
- gpointer data)
+print_struct_field (gpointer key, gpointer value, gpointer data)
{
- GtranslatorOpenTranPanel *panel = GTR_OPEN_TRAN_PANEL (data);
- GHashTable *hash;
- GValueArray *array;
- const gchar *str;
-
- if (G_VALUE_HOLDS_STRING (value))
+ GtranslatorOpenTranPanel *panel = GTR_OPEN_TRAN_PANEL (data);
+ GHashTable *hash;
+ GValueArray *array;
+ const gchar *str;
+
+ if (G_VALUE_HOLDS_STRING (value))
+ {
+ str = g_value_get_string (value);
+ panel->priv->text = g_strdup (str);
+ }
+ else if (G_VALUE_HOLDS (value, G_TYPE_VALUE_ARRAY))
+ {
+ array = g_value_get_boxed (value);
+
+ if (G_VALUE_HOLDS (array->values, G_TYPE_HASH_TABLE))
{
- str = g_value_get_string (value);
- panel->priv->text = g_strdup (str);
- }
- else if (G_VALUE_HOLDS (value, G_TYPE_VALUE_ARRAY))
- {
- array = g_value_get_boxed (value);
-
- if (G_VALUE_HOLDS (array->values, G_TYPE_HASH_TABLE))
- {
- gpointer name;
-
- hash = g_value_get_boxed (array->values);
- name = g_hash_table_lookup (hash, "name");
-
- if (name != NULL)
- {
- print_struct_to_tree_view (g_value_get_string (name),
- panel);
- }
- }
-
- /*
- * It's important freeing the array after the use of its contents
- */
- g_value_array_free (array);
- }
-}
+ gpointer name;
-static void
-check_xmlrpc (GValue *value, GType type, ...)
-{
- va_list args;
+ hash = g_value_get_boxed (array->values);
+ name = g_hash_table_lookup (hash, "name");
- if (!G_VALUE_HOLDS (value, type)) {
- g_warning (_("ERROR: could not parse response\n"));
- g_value_unset (value);
- return;
+ if (name != NULL)
+ {
+ print_struct_to_tree_view (g_value_get_string (name), panel);
+ }
}
- va_start (args, type);
- SOUP_VALUE_GETV (value, type, args);
- va_end (args);
+ /*
+ * It's important freeing the array after the use of its contents
+ */
+ g_value_array_free (array);
+ }
}
static void
-open_connection (GtranslatorOpenTranPanel *panel,
- const gchar *text,
- const gchar *search_code,
- const gchar *own_code)
+check_xmlrpc (GValue * value, GType type, ...)
{
- const gchar *uri = "http://open-tran.eu/RPC2";
- SoupMessage *msg;
- gchar *body;
- GValueArray *array;
- GError *err = NULL;
- GValue retval;
- GHashTable *result;
- GtkTreeIter treeiter;
- gint i;
-
- panel->priv->session = soup_session_async_new ();
-
- array = soup_value_array_new_with_vals (G_TYPE_STRING, text,
- G_TYPE_STRING, search_code,
- G_TYPE_STRING, own_code,
- NULL);
-
- body = soup_xmlrpc_build_method_call ("suggest2", array->values,
- array->n_values);
-
- g_value_array_free (array);
-
- if (!body)
- return;
-
- msg = soup_message_new ("POST", uri);
- soup_message_set_request (msg, "text/xml", SOUP_MEMORY_TAKE,
- body, strlen (body));
- soup_session_send_message (panel->priv->session, msg);
-
- if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
- show_error_dialog (panel->priv->window,
- _("ERROR: %d %s\n"), msg->status_code,
- msg->reason_phrase);
- g_object_unref (msg);
- return;
- }
+ va_list args;
+
+ if (!G_VALUE_HOLDS (value, type))
+ {
+ g_warning (_("ERROR: could not parse response\n"));
+ g_value_unset (value);
+ return;
+ }
+
+ va_start (args, type);
+ SOUP_VALUE_GETV (value, type, args);
+ va_end (args);
+}
- if (!soup_xmlrpc_parse_method_response (msg->response_body->data,
- msg->response_body->length,
- &retval, &err)) {
- if (err) {
- show_error_dialog (panel->priv->window,
- _("FAULT: %d %s\n"), err->code,
- err->message);
- g_error_free (err);
- } else
- show_error_dialog (panel->priv->window,
- _("ERROR: could not parse response\n"));
- }
- g_object_unref (msg);
-
- check_xmlrpc (&retval, G_TYPE_VALUE_ARRAY, &array);
-
- for (i = 0; i < array->n_values; i++)
+static void
+open_connection (GtranslatorOpenTranPanel * panel,
+ const gchar * text,
+ const gchar * search_code, const gchar * own_code)
+{
+ const gchar *uri = "http://open-tran.eu/RPC2";
+ SoupMessage *msg;
+ gchar *body;
+ GValueArray *array;
+ GError *err = NULL;
+ GValue retval;
+ GHashTable *result;
+ GtkTreeIter treeiter;
+ gint i;
+
+ panel->priv->session = soup_session_async_new ();
+
+ array = soup_value_array_new_with_vals (G_TYPE_STRING, text,
+ G_TYPE_STRING, search_code,
+ G_TYPE_STRING, own_code, NULL);
+
+ body = soup_xmlrpc_build_method_call ("suggest2", array->values,
+ array->n_values);
+
+ g_value_array_free (array);
+
+ if (!body)
+ return;
+
+ msg = soup_message_new ("POST", uri);
+ soup_message_set_request (msg, "text/xml", SOUP_MEMORY_TAKE,
+ body, strlen (body));
+ soup_session_send_message (panel->priv->session, msg);
+
+ if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
+ {
+ show_error_dialog (panel->priv->window,
+ _("ERROR: %d %s\n"), msg->status_code,
+ msg->reason_phrase);
+ g_object_unref (msg);
+ return;
+ }
+
+ if (!soup_xmlrpc_parse_method_response (msg->response_body->data,
+ msg->response_body->length,
+ &retval, &err))
+ {
+ if (err)
{
- if (!soup_value_array_get_nth (array, i, G_TYPE_HASH_TABLE, &result))
- {
- show_error_dialog (panel->priv->window,
- _("WRONG! Can't get result element %d\n"), i + 1);
- break;
- }
-
- g_hash_table_foreach (result, print_struct_field, panel);
+ show_error_dialog (panel->priv->window,
+ _("FAULT: %d %s\n"), err->code, err->message);
+ g_error_free (err);
}
-
- /*
- * We have to check if we didn't find any text
- */
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (panel->priv->store),
- &treeiter))
+ else
+ show_error_dialog (panel->priv->window,
+ _("ERROR: could not parse response\n"));
+ }
+ g_object_unref (msg);
+
+ check_xmlrpc (&retval, G_TYPE_VALUE_ARRAY, &array);
+
+ for (i = 0; i < array->n_values; i++)
+ {
+ if (!soup_value_array_get_nth (array, i, G_TYPE_HASH_TABLE, &result))
{
- gtk_list_store_append (panel->priv->store, &treeiter);
- gtk_list_store_set (panel->priv->store, &treeiter,
- ICON_COLUMN, NULL,
- TEXT_COLUMN, _("Phrase not found"),
- -1);
+ show_error_dialog (panel->priv->window,
+ _("WRONG! Can't get result element %d\n"),
+ i + 1);
+ break;
}
-
- soup_session_abort (panel->priv->session);
- g_object_unref (panel->priv->session);
+
+ g_hash_table_foreach (result, print_struct_field, panel);
+ }
+
+ /*
+ * We have to check if we didn't find any text
+ */
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (panel->priv->store),
+ &treeiter))
+ {
+ gtk_list_store_append (panel->priv->store, &treeiter);
+ gtk_list_store_set (panel->priv->store, &treeiter,
+ ICON_COLUMN, NULL,
+ TEXT_COLUMN, _("Phrase not found"), -1);
+ }
+
+ soup_session_abort (panel->priv->session);
+ g_object_unref (panel->priv->session);
}
static void
-entry_activate_cb (GtkEntry *entry,
- GtranslatorOpenTranPanel *panel)
+entry_activate_cb (GtkEntry * entry, GtranslatorOpenTranPanel * panel)
{
- const gchar *entry_text = NULL;
- const gchar *search_code = NULL;
- const gchar *own_code = NULL;
-
- gtk_list_store_clear (panel->priv->store);
-
- entry_text = gtk_entry_get_text (GTK_ENTRY (panel->priv->entry));
- if (!entry_text)
- {
- show_error_dialog (panel->priv->window,
- _("You have to provide a phrase to search"));
- return;
- }
-
- search_code = gconf_client_get_string (panel->priv->gconf_client,
- SEARCH_CODE_KEY,
- NULL);
- if (!search_code)
- {
- show_error_dialog (panel->priv->window,
- _("You have to provide a search language code"));
- return;
- }
-
- own_code = gconf_client_get_string (panel->priv->gconf_client,
- OWN_CODE_KEY,
- NULL);
- if (!own_code)
- {
- show_error_dialog (panel->priv->window,
- _("You have to provide a language code for your language"));
- return;
- }
-
- open_connection (panel, entry_text, search_code, own_code);
+ const gchar *entry_text = NULL;
+ const gchar *search_code = NULL;
+ const gchar *own_code = NULL;
+
+ gtk_list_store_clear (panel->priv->store);
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (panel->priv->entry));
+ if (!entry_text)
+ {
+ show_error_dialog (panel->priv->window,
+ _("You have to provide a phrase to search"));
+ return;
+ }
+
+ search_code = gconf_client_get_string (panel->priv->gconf_client,
+ SEARCH_CODE_KEY, NULL);
+ if (!search_code)
+ {
+ show_error_dialog (panel->priv->window,
+ _("You have to provide a search language code"));
+ return;
+ }
+
+ own_code = gconf_client_get_string (panel->priv->gconf_client,
+ OWN_CODE_KEY, NULL);
+ if (!own_code)
+ {
+ show_error_dialog (panel->priv->window,
+ _
+ ("You have to provide a language code for your language"));
+ return;
+ }
+
+ open_connection (panel, entry_text, search_code, own_code);
}
static void
-gtranslator_open_tran_panel_draw_treeview (GtranslatorOpenTranPanel *panel)
+gtranslator_open_tran_panel_draw_treeview (GtranslatorOpenTranPanel * panel)
{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- GtranslatorOpenTranPanelPrivate *priv = panel->priv;
-
- priv->store = gtk_list_store_new (N_COLUMNS,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING);
-
- priv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(priv->store));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview),
- FALSE);
-
- /*
- * Icon column
- */
- column = gtk_tree_view_column_new ();
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Type"),
- renderer, "pixbuf",
- ICON_COLUMN, NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
-
- /*
- * Text column
- */
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Open-Tran.eu"),
- renderer,
- "text", TEXT_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ GtranslatorOpenTranPanelPrivate *priv = panel->priv;
+
+ priv->store = gtk_list_store_new (N_COLUMNS,
+ GDK_TYPE_PIXBUF, G_TYPE_STRING);
+
+ priv->treeview =
+ gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->store));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
+
+ /*
+ * Icon column
+ */
+ column = gtk_tree_view_column_new ();
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Type"),
+ renderer, "pixbuf",
+ ICON_COLUMN, NULL);
+ gtk_tree_view_column_set_resizable (column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+
+ /*
+ * Text column
+ */
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Open-Tran.eu"),
+ renderer,
+ "text", TEXT_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_resizable (column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
}
static void
-gtranslator_open_tran_panel_draw (GtranslatorOpenTranPanel *panel)
+gtranslator_open_tran_panel_draw (GtranslatorOpenTranPanel * panel)
{
- GtkWidget *scrolledwindow;
- GtkWidget *button;
- GtkWidget *hbox;
-
- /*
- * Set up the scrolling window for the extracted comments display
- */
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (panel), scrolledwindow, TRUE, TRUE, 0);
-
- /*
- * TreeView
- */
- gtranslator_open_tran_panel_draw_treeview (panel);
- gtk_container_add (GTK_CONTAINER (scrolledwindow),
- panel->priv->treeview);
-
- /*
- * Entry
- */
- hbox = gtk_hbox_new (FALSE, 6);
-
- button = gtk_button_new_with_label (_("Look for:"));
- gtk_button_set_relief (GTK_BUTTON (button),
- GTK_RELIEF_NONE);
- g_signal_connect (button, "clicked",
- G_CALLBACK (entry_activate_cb), panel);
-
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-
- panel->priv->entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
- g_signal_connect (panel->priv->entry, "activate",
- G_CALLBACK (entry_activate_cb), panel);
-
- gtk_box_pack_start (GTK_BOX (panel), hbox, FALSE, TRUE, 0);
+ GtkWidget *scrolledwindow;
+ GtkWidget *button;
+ GtkWidget *hbox;
+
+ /*
+ * Set up the scrolling window for the extracted comments display
+ */
+ scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (panel), scrolledwindow, TRUE, TRUE, 0);
+
+ /*
+ * TreeView
+ */
+ gtranslator_open_tran_panel_draw_treeview (panel);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow), panel->priv->treeview);
+
+ /*
+ * Entry
+ */
+ hbox = gtk_hbox_new (FALSE, 6);
+
+ button = gtk_button_new_with_label (_("Look for:"));
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ g_signal_connect (button, "clicked", G_CALLBACK (entry_activate_cb), panel);
+
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ panel->priv->entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
+ g_signal_connect (panel->priv->entry, "activate",
+ G_CALLBACK (entry_activate_cb), panel);
+
+ gtk_box_pack_start (GTK_BOX (panel), hbox, FALSE, TRUE, 0);
}
static void
-gtranslator_open_tran_panel_init (GtranslatorOpenTranPanel *panel)
+gtranslator_open_tran_panel_init (GtranslatorOpenTranPanel * panel)
{
-
- panel->priv = GTR_OPEN_TRAN_PANEL_GET_PRIVATE (panel);
- panel->priv->gconf_client = gconf_client_get_default ();
-
- gtranslator_open_tran_panel_draw (panel);
+ panel->priv = GTR_OPEN_TRAN_PANEL_GET_PRIVATE (panel);
+
+ panel->priv->gconf_client = gconf_client_get_default ();
+
+ gtranslator_open_tran_panel_draw (panel);
}
static void
-gtranslator_open_tran_panel_finalize (GObject *object)
+gtranslator_open_tran_panel_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_open_tran_panel_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_open_tran_panel_parent_class)->
+ finalize (object);
}
static void
-gtranslator_open_tran_panel_class_init (GtranslatorOpenTranPanelClass *klass)
+gtranslator_open_tran_panel_class_init (GtranslatorOpenTranPanelClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorOpenTranPanelPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorOpenTranPanelPrivate));
- object_class->finalize = gtranslator_open_tran_panel_finalize;
+ object_class->finalize = gtranslator_open_tran_panel_finalize;
}
GtkWidget *
-gtranslator_open_tran_panel_new (GtranslatorWindow *window)
+gtranslator_open_tran_panel_new (GtranslatorWindow * window)
{
- GtranslatorOpenTranPanel *panel;
-
- panel = g_object_new (GTR_TYPE_OPEN_TRAN_PANEL, NULL);
-
- panel->priv->window = window;
+ GtranslatorOpenTranPanel *panel;
- return GTK_WIDGET(panel);
-}
+ panel = g_object_new (GTR_TYPE_OPEN_TRAN_PANEL, NULL);
+ panel->priv->window = window;
+
+ return GTK_WIDGET (panel);
+}
diff --git a/plugins/open-tran/open-tran-panel.h b/plugins/open-tran/open-tran-panel.h
index 3950a45..a839351 100644
--- a/plugins/open-tran/open-tran-panel.h
+++ b/plugins/open-tran/open-tran-panel.h
@@ -26,7 +26,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -36,45 +35,45 @@ G_BEGIN_DECLS
#define GTR_IS_OPEN_TRAN_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_OPEN_TRAN_PANEL))
#define GTR_IS_OPEN_TRAN_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_OPEN_TRAN_PANEL))
#define GTR_OPEN_TRAN_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_OPEN_TRAN_PANEL, GtranslatorOpenTranPanelClass))
-
/* Gconf keys */
#define OPEN_TRAN_BASE_KEY "/apps/gtranslator/plugins/open-tran"
#define SEARCH_CODE_KEY OPEN_TRAN_BASE_KEY "/search_code"
#define OWN_CODE_KEY OPEN_TRAN_BASE_KEY "/own_code"
-
/* Private structure type */
-typedef struct _GtranslatorOpenTranPanelPrivate GtranslatorOpenTranPanelPrivate;
+typedef struct _GtranslatorOpenTranPanelPrivate
+ GtranslatorOpenTranPanelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorOpenTranPanel GtranslatorOpenTranPanel;
+typedef struct _GtranslatorOpenTranPanel GtranslatorOpenTranPanel;
struct _GtranslatorOpenTranPanel
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorOpenTranPanelPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorOpenTranPanelPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorOpenTranPanelClass GtranslatorOpenTranPanelClass;
+typedef struct _GtranslatorOpenTranPanelClass GtranslatorOpenTranPanelClass;
struct _GtranslatorOpenTranPanelClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_open_tran_panel_get_type (void) G_GNUC_CONST;
-GType gtranslator_open_tran_panel_register_type (GTypeModule * module);
-GtkWidget *gtranslator_open_tran_panel_new (GtranslatorWindow *window);
+GType
+gtranslator_open_tran_panel_get_type (void)
+ G_GNUC_CONST;
+ GType gtranslator_open_tran_panel_register_type (GTypeModule * module);
+ GtkWidget *gtranslator_open_tran_panel_new (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __OPEN_TRAN_PANEL_H__ */
diff --git a/plugins/open-tran/open-tran-plugin.c b/plugins/open-tran/open-tran-plugin.c
index bfa79ec..701562f 100644
--- a/plugins/open-tran/open-tran-plugin.c
+++ b/plugins/open-tran/open-tran-plugin.c
@@ -27,7 +27,7 @@
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
-
+
#include "application.h"
#include "window.h"
#include "utils.h"
@@ -43,234 +43,226 @@
struct _GtranslatorOpenTranPluginPrivate
{
- GConfClient *gconf_client;
-
- /* Dialog stuff */
- GtkWidget *dialog;
-
- GtkWidget *main_box;
- GtkWidget *search_code_entry;
- GtkWidget *own_code_entry;
+ GConfClient *gconf_client;
+
+ /* Dialog stuff */
+ GtkWidget *dialog;
+
+ GtkWidget *main_box;
+ GtkWidget *search_code_entry;
+ GtkWidget *own_code_entry;
};
typedef struct
{
- GtkWidget *panel;
- guint context_id;
+ GtkWidget *panel;
+ guint context_id;
} WindowData;
-GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorOpenTranPlugin, gtranslator_open_tran_plugin,
- gtranslator_open_tran_panel_register_type (module);
-)
-
-static void
-gtranslator_open_tran_plugin_init (GtranslatorOpenTranPlugin *plugin)
-{
- plugin->priv = GTR_OPEN_TRAN_PLUGIN_GET_PRIVATE (plugin);
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorOpenTranPlugin,
+ gtranslator_open_tran_plugin,
+ gtranslator_open_tran_panel_register_type
+ (module);)
+ static void gtranslator_open_tran_plugin_init (GtranslatorOpenTranPlugin
+ * plugin)
+{
+ plugin->priv = GTR_OPEN_TRAN_PLUGIN_GET_PRIVATE (plugin);
- plugin->priv->gconf_client = gconf_client_get_default ();
+ plugin->priv->gconf_client = gconf_client_get_default ();
- gconf_client_add_dir (plugin->priv->gconf_client,
- OPEN_TRAN_BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ gconf_client_add_dir (plugin->priv->gconf_client,
+ OPEN_TRAN_BASE_KEY,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
}
static void
-gtranslator_open_tran_plugin_finalize (GObject *object)
+gtranslator_open_tran_plugin_finalize (GObject * object)
{
- GtranslatorOpenTranPlugin *plugin = GTR_OPEN_TRAN_PLUGIN (object);
-
- gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
+ GtranslatorOpenTranPlugin *plugin = GTR_OPEN_TRAN_PLUGIN (object);
+
+ gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
- g_object_unref (G_OBJECT (plugin->priv->gconf_client));
-
- G_OBJECT_CLASS (gtranslator_open_tran_plugin_parent_class)->finalize (object);
+ g_object_unref (G_OBJECT (plugin->priv->gconf_client));
+
+ G_OBJECT_CLASS (gtranslator_open_tran_plugin_parent_class)->
+ finalize (object);
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkWidget *opentran;
-
- gtranslator_application_register_icon (GTR_APP, "open-tran.png",
- "open-tran-plugin-icon");
-
- opentran = gtranslator_open_tran_panel_new (window);
- gtk_widget_show (opentran);
-
- gtranslator_window_add_widget (window,
- opentran,
- "GtranslatorOpenTranPlugin",
- _("Open Tran"),
- "open-tran-plugin-icon",
- GTR_WINDOW_PLACEMENT_LEFT);
-
- g_object_set_data (G_OBJECT (window),
- WINDOW_DATA_KEY,
- opentran);
+ GtkWidget *opentran;
+
+ gtranslator_application_register_icon (GTR_APP, "open-tran.png",
+ "open-tran-plugin-icon");
+
+ opentran = gtranslator_open_tran_panel_new (window);
+ gtk_widget_show (opentran);
+
+ gtranslator_window_add_widget (window,
+ opentran,
+ "GtranslatorOpenTranPlugin",
+ _("Open Tran"),
+ "open-tran-plugin-icon",
+ GTR_WINDOW_PLACEMENT_LEFT);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, opentran);
}
static void
-impl_deactivate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkWidget *opentran;
+ GtkWidget *opentran;
+
+ opentran = (GtkWidget *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (opentran != NULL);
- opentran = (GtkWidget *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_if_fail (opentran != NULL);
+ gtranslator_window_remove_widget (window, opentran);
- gtranslator_window_remove_widget (window, opentran);
-
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
static void
-get_custom_code (GtranslatorOpenTranPlugin *plugin,
- gboolean own_code)
+get_custom_code (GtranslatorOpenTranPlugin * plugin, gboolean own_code)
{
- gchar *type;
- gchar *code;
-
- if (own_code)
- type = g_strdup (OWN_CODE_KEY);
- else type = g_strdup (SEARCH_CODE_KEY);
-
- code = gconf_client_get_string (plugin->priv->gconf_client,
- type,
- NULL);
-
- g_free (type);
-
- if (!code && !own_code)
- code = g_strdup ("en");
- else if (!code && own_code)
- code = g_strdup ("gl"); //Why gl? Just because i want.
-
- if (!own_code)
- gtk_entry_set_text (GTK_ENTRY (plugin->priv->search_code_entry), code);
- else gtk_entry_set_text (GTK_ENTRY (plugin->priv->own_code_entry), code);
-
- g_free (code);
+ gchar *type;
+ gchar *code;
+
+ if (own_code)
+ type = g_strdup (OWN_CODE_KEY);
+ else
+ type = g_strdup (SEARCH_CODE_KEY);
+
+ code = gconf_client_get_string (plugin->priv->gconf_client, type, NULL);
+
+ g_free (type);
+
+ if (!code && !own_code)
+ code = g_strdup ("en");
+ else if (!code && own_code)
+ code = g_strdup ("gl"); //Why gl? Just because i want.
+
+ if (!own_code)
+ gtk_entry_set_text (GTK_ENTRY (plugin->priv->search_code_entry), code);
+ else
+ gtk_entry_set_text (GTK_ENTRY (plugin->priv->own_code_entry), code);
+
+ g_free (code);
}
static GtkWidget *
-get_configuration_dialog (GtranslatorOpenTranPlugin *plugin)
+get_configuration_dialog (GtranslatorOpenTranPlugin * plugin)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "dialog",
- NULL
- };
-
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
- "dialog", &plugin->priv->dialog,
- "main_box", &plugin->priv->main_box,
- "search_code", &plugin->priv->search_code_entry,
- "own_code", &plugin->priv->own_code_entry,
- NULL);
-
- if(!ret)
- {
- //FIXME: We have to show a dialog
- }
-
- get_custom_code (plugin, FALSE);
- get_custom_code (plugin, TRUE);
-
- return plugin->priv->dialog;
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "dialog",
+ NULL
+ };
+
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "dialog", &plugin->priv->dialog,
+ "main_box", &plugin->priv->main_box,
+ "search_code",
+ &plugin->priv->search_code_entry,
+ "own_code",
+ &plugin->priv->own_code_entry,
+ NULL);
+
+ if (!ret)
+ {
+ //FIXME: We have to show a dialog
+ }
+
+ get_custom_code (plugin, FALSE);
+ get_custom_code (plugin, TRUE);
+
+ return plugin->priv->dialog;
}
static void
-ok_button_pressed (GtranslatorOpenTranPlugin *plugin)
+ok_button_pressed (GtranslatorOpenTranPlugin * plugin)
{
- const gchar *search_code;
- const gchar *own_code;
-
- /* We have to get the text from the entries */
- search_code = gtk_entry_get_text (GTK_ENTRY (plugin->priv->search_code_entry));
- own_code = gtk_entry_get_text (GTK_ENTRY (plugin->priv->own_code_entry));
-
- /* Now we store the data in gconf */
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- SEARCH_CODE_KEY,
- NULL))
- return;
-
- gconf_client_set_string (plugin->priv->gconf_client,
- SEARCH_CODE_KEY,
- search_code,
- NULL);
-
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- OWN_CODE_KEY,
- NULL))
- return;
-
- gconf_client_set_string (plugin->priv->gconf_client,
- OWN_CODE_KEY,
- own_code,
- NULL);
+ const gchar *search_code;
+ const gchar *own_code;
+
+ /* We have to get the text from the entries */
+ search_code =
+ gtk_entry_get_text (GTK_ENTRY (plugin->priv->search_code_entry));
+ own_code = gtk_entry_get_text (GTK_ENTRY (plugin->priv->own_code_entry));
+
+ /* Now we store the data in gconf */
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ SEARCH_CODE_KEY, NULL))
+ return;
+
+ gconf_client_set_string (plugin->priv->gconf_client,
+ SEARCH_CODE_KEY, search_code, NULL);
+
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ OWN_CODE_KEY, NULL))
+ return;
+
+ gconf_client_set_string (plugin->priv->gconf_client,
+ OWN_CODE_KEY, own_code, NULL);
}
static void
-configure_dialog_response_cb (GtkWidget *widget,
- gint response,
- GtranslatorOpenTranPlugin *plugin)
+configure_dialog_response_cb (GtkWidget * widget,
+ gint response,
+ GtranslatorOpenTranPlugin * plugin)
{
- switch (response)
- {
- case GTK_RESPONSE_OK:
- {
- ok_button_pressed (plugin);
-
- gtk_widget_destroy (plugin->priv->dialog);
- break;
- }
- case GTK_RESPONSE_CANCEL:
- {
- gtk_widget_destroy (plugin->priv->dialog);
- }
- }
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ ok_button_pressed (plugin);
+
+ gtk_widget_destroy (plugin->priv->dialog);
+ break;
+ }
+ case GTK_RESPONSE_CANCEL:
+ {
+ gtk_widget_destroy (plugin->priv->dialog);
+ }
+ }
}
static GtkWidget *
-impl_create_configure_dialog (GtranslatorPlugin *plugin)
+impl_create_configure_dialog (GtranslatorPlugin * plugin)
{
- GtkWidget *dialog;
-
- dialog = get_configuration_dialog (GTR_OPEN_TRAN_PLUGIN (plugin));
-
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (configure_dialog_response_cb),
- GTR_OPEN_TRAN_PLUGIN (plugin));
- g_signal_connect (dialog,
- "destroy",
- G_CALLBACK (gtk_widget_destroy),
- &dialog);
-
- return dialog;
+ GtkWidget *dialog;
+
+ dialog = get_configuration_dialog (GTR_OPEN_TRAN_PLUGIN (plugin));
+
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (configure_dialog_response_cb),
+ GTR_OPEN_TRAN_PLUGIN (plugin));
+ g_signal_connect (dialog,
+ "destroy", G_CALLBACK (gtk_widget_destroy), &dialog);
+
+ return dialog;
}
static void
-gtranslator_open_tran_plugin_class_init (GtranslatorOpenTranPluginClass *klass)
+gtranslator_open_tran_plugin_class_init (GtranslatorOpenTranPluginClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_open_tran_plugin_finalize;
- object_class->finalize = gtranslator_open_tran_plugin_finalize;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->create_configure_dialog = impl_create_configure_dialog;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->create_configure_dialog = impl_create_configure_dialog;
-
- g_type_class_add_private (object_class, sizeof (GtranslatorOpenTranPluginPrivate));
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorOpenTranPluginPrivate));
}
diff --git a/plugins/open-tran/open-tran-plugin.h b/plugins/open-tran/open-tran-plugin.h
index 7b6f321..ff26af2 100644
--- a/plugins/open-tran/open-tran-plugin.h
+++ b/plugins/open-tran/open-tran-plugin.h
@@ -25,7 +25,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,41 +34,42 @@ G_BEGIN_DECLS
#define GTR_IS_OPEN_TRAN_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_OPEN_TRAN_PLUGIN))
#define GTR_IS_OPEN_TRAN_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_OPEN_TRAN_PLUGIN))
#define GTR_OPEN_TRAN_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_OPEN_TRAN_PLUGIN, GtranslatorOpenTranPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorOpenTranPluginPrivate GtranslatorOpenTranPluginPrivate;
+typedef struct _GtranslatorOpenTranPluginPrivate
+ GtranslatorOpenTranPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorOpenTranPlugin GtranslatorOpenTranPlugin;
+typedef struct _GtranslatorOpenTranPlugin GtranslatorOpenTranPlugin;
struct _GtranslatorOpenTranPlugin
{
- GtranslatorPlugin parent_instance;
-
- /* private */
- GtranslatorOpenTranPluginPrivate *priv;
+ GtranslatorPlugin parent_instance;
+
+ /* private */
+ GtranslatorOpenTranPluginPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorOpenTranPluginClass GtranslatorOpenTranPluginClass;
+typedef struct _GtranslatorOpenTranPluginClass GtranslatorOpenTranPluginClass;
struct _GtranslatorOpenTranPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_open_tran_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_open_tran_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_OPEN_TRAN_PLUGIN_H__ */
diff --git a/plugins/source-code-view/source-code-view-plugin.c b/plugins/source-code-view/source-code-view-plugin.c
index 6645040..57d154a 100644
--- a/plugins/source-code-view/source-code-view-plugin.c
+++ b/plugins/source-code-view/source-code-view-plugin.c
@@ -49,277 +49,261 @@
struct _GtranslatorSourceCodeViewPluginPrivate
{
- GConfClient *gconf_client;
-
- /* Dialog stuff */
- GtkWidget *dialog;
-
- GtkWidget *main_box;
- GtkWidget *use_editor_checkbutton;
- GtkWidget *program_box;
- GtkWidget *program_cmd_entry;
- GtkWidget *line_cmd_entry;
-
- GtranslatorWindow *window;
-
- GSList *tags;
-};
+ GConfClient *gconf_client;
-GTR_PLUGIN_REGISTER_TYPE(GtranslatorSourceCodeViewPlugin, gtranslator_source_code_view_plugin)
+ /* Dialog stuff */
+ GtkWidget *dialog;
-static void
-insert_link (GtkTextBuffer *buffer,
- GtkTextIter *iter,
- const gchar *path,
- gint *line,
- GtranslatorSourceCodeViewPlugin *plugin,
- const gchar *msgid)
-{
- GtkTextTag *tag;
- gchar *text;
+ GtkWidget *main_box;
+ GtkWidget *use_editor_checkbutton;
+ GtkWidget *program_box;
+ GtkWidget *program_cmd_entry;
+ GtkWidget *line_cmd_entry;
- tag = gtk_text_buffer_create_tag (buffer, NULL,
- "foreground", "blue",
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
- g_object_set_data (G_OBJECT (tag), "path", g_strdup (path));
- g_object_set_data (G_OBJECT (tag), "line", line);
- g_object_set_data (G_OBJECT (tag), "msgid", g_strdup (msgid));
-
- text = g_strdup_printf ("%s:%d\n", path, GPOINTER_TO_INT (line));
- gtk_text_buffer_insert_with_tags (buffer, iter, text, -1, tag, NULL);
- g_free (text);
-
- plugin->priv->tags = g_slist_prepend (plugin->priv->tags, tag);
+ GtranslatorWindow *window;
+
+ GSList *tags;
+};
+
+GTR_PLUGIN_REGISTER_TYPE (GtranslatorSourceCodeViewPlugin,
+ gtranslator_source_code_view_plugin)
+ static void insert_link (GtkTextBuffer * buffer, GtkTextIter * iter,
+ const gchar * path, gint * line,
+ GtranslatorSourceCodeViewPlugin * plugin,
+ const gchar * msgid)
+{
+ GtkTextTag *tag;
+ gchar *text;
+
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "foreground", "blue",
+ "underline", PANGO_UNDERLINE_SINGLE,
+ NULL);
+ g_object_set_data (G_OBJECT (tag), "path", g_strdup (path));
+ g_object_set_data (G_OBJECT (tag), "line", line);
+ g_object_set_data (G_OBJECT (tag), "msgid", g_strdup (msgid));
+
+ text = g_strdup_printf ("%s:%d\n", path, GPOINTER_TO_INT (line));
+ gtk_text_buffer_insert_with_tags (buffer, iter, text, -1, tag, NULL);
+ g_free (text);
+
+ plugin->priv->tags = g_slist_prepend (plugin->priv->tags, tag);
}
static void
-show_in_editor (const gchar *program_name,
- const gchar *line_cmd,
- const gchar *path,
- gint line)
+show_in_editor (const gchar * program_name,
+ const gchar * line_cmd, const gchar * path, gint line)
{
- gchar *open[4];
-
- if (g_find_program_in_path (program_name))
- {
- open[0] = g_strdup (program_name);
- }
- else
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_DIALOG_MODAL,
- GTK_BUTTONS_CLOSE,
- _("Please install %s to be able to show the file"),
- program_name);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
-
- open[1] = g_strdup (path);
- open[2] = g_strdup_printf ("%s%d",line_cmd, line);
- open[3] = NULL;
-
- gdk_spawn_on_screen (gdk_screen_get_default (),
- NULL,
- open,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL, NULL, NULL);
- g_free (open[0]);
- g_free (open[1]);
- g_free (open[2]);
+ gchar *open[4];
+
+ if (g_find_program_in_path (program_name))
+ {
+ open[0] = g_strdup (program_name);
+ }
+ else
+ {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_DIALOG_MODAL,
+ GTK_BUTTONS_CLOSE,
+ _
+ ("Please install %s to be able to show the file"),
+ program_name);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+
+ open[1] = g_strdup (path);
+ open[2] = g_strdup_printf ("%s%d", line_cmd, line);
+ open[3] = NULL;
+
+ gdk_spawn_on_screen (gdk_screen_get_default (),
+ NULL,
+ open,
+ NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+ g_free (open[0]);
+ g_free (open[1]);
+ g_free (open[2]);
}
static void
-show_source (GtranslatorSourceCodeViewPlugin *plugin,
- const gchar *path,
- gint line)
+show_source (GtranslatorSourceCodeViewPlugin * plugin,
+ const gchar * path, gint line)
{
- gboolean use_editor;
-
- use_editor = gconf_client_get_bool (plugin->priv->gconf_client,
- USE_EDITOR_KEY,
- NULL);
+ gboolean use_editor;
- if (use_editor)
- {
- gchar *program_cmd;
- gchar *line_cmd;
-
- //Program cmd
- program_cmd = gconf_client_get_string (plugin->priv->gconf_client,
- PROGRAM_CMD_KEY,
- NULL);
-
- //Line cmd
- line_cmd = gconf_client_get_string (plugin->priv->gconf_client,
- LINE_CMD_KEY,
- NULL);
-
- show_in_editor (program_cmd,
- line_cmd,
- path, line);
-
- g_free (program_cmd);
- g_free (line_cmd);
- }
- else gtranslator_show_viewer (plugin->priv->window,
- path, line);
+ use_editor = gconf_client_get_bool (plugin->priv->gconf_client,
+ USE_EDITOR_KEY, NULL);
+
+ if (use_editor)
+ {
+ gchar *program_cmd;
+ gchar *line_cmd;
+
+ //Program cmd
+ program_cmd = gconf_client_get_string (plugin->priv->gconf_client,
+ PROGRAM_CMD_KEY, NULL);
+
+ //Line cmd
+ line_cmd = gconf_client_get_string (plugin->priv->gconf_client,
+ LINE_CMD_KEY, NULL);
+
+ show_in_editor (program_cmd, line_cmd, path, line);
+
+ g_free (program_cmd);
+ g_free (line_cmd);
+ }
+ else
+ gtranslator_show_viewer (plugin->priv->window, path, line);
}
static gboolean
-path_is_fake (const gchar *path)
+path_is_fake (const gchar * path)
{
- return g_str_has_suffix (path, ".h") && !g_file_test (path, G_FILE_TEST_EXISTS);
+ return g_str_has_suffix (path, ".h")
+ && !g_file_test (path, G_FILE_TEST_EXISTS);
}
static gchar *
-real_path (const gchar *path)
+real_path (const gchar * path)
{
- gchar *result = g_strdup (path);
+ gchar *result = g_strdup (path);
- if (path_is_fake (path))
- result[strlen (result) - 2] = '\0';
+ if (path_is_fake (path))
+ result[strlen (result) - 2] = '\0';
- return result;
+ return result;
}
static int
-get_line_for_text (const gchar *path, const gchar *msgid)
+get_line_for_text (const gchar * path, const gchar * msgid)
{
- gchar *content, *str_found, *i, *escaped;
- int result;
+ gchar *content, *str_found, *i, *escaped;
+ int result;
+
+ content = NULL;
+ result = 1;
+ escaped = g_markup_escape_text (msgid, -1);
+
+ if (!g_file_get_contents (path, &content, NULL, NULL))
+ goto out;
+
+ i = content;
+ while ((str_found = g_strstr_len (i, -1, escaped)))
+ {
+ gchar c;
+
+ i = str_found + strlen (escaped);
+ c = *i;
+ if (!isalpha (c) &&
+ !isalpha (*(str_found - 1)) && !(c == ':') && !(c == '_'))
+ break;
+ }
+ if (!str_found)
+ goto out;
+
+ for (i = content; i < str_found; i++)
+ if (*i == '\n')
+ result++;
+
+out:
+ g_free (content);
+ g_free (escaped);
+
+ return result;
+}
- content = NULL;
- result = 1;
- escaped = g_markup_escape_text (msgid, -1);
+static void
+follow_if_link (GtranslatorSourceCodeViewPlugin * plugin,
+ GtkWidget * text_view, GtkTextIter * iter)
+{
+ GSList *tags = NULL, *tagp = NULL;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ gchar *fullpath;
+ gchar *dirname;
+ GFile *location, *parent;
- if (!g_file_get_contents (path, &content, NULL, NULL))
- goto out;
+ tab = gtranslator_window_get_active_tab (plugin->priv->window);
- i = content;
- while ( (str_found = g_strstr_len (i, -1, escaped)) )
- {
- gchar c;
-
- i = str_found + strlen (escaped);
- c = *i;
- if ( !isalpha (c) &&
- !isalpha (*(str_found -1)) &&
- !(c == ':') &&
- !(c == '_')
- )
- break;
- }
- if (!str_found)
- goto out;
+ if (!tab)
+ return;
+ po = gtranslator_tab_get_po (tab);
- for (i = content; i < str_found; i++)
- if (*i == '\n')
- result++;
+ location = gtranslator_po_get_location (po);
+ parent = g_file_get_parent (location);
+ g_object_unref (location);
- out:
- g_free (content);
- g_free (escaped);
+ dirname = g_file_get_path (parent);
+ g_object_unref (parent);
- return result;
-}
+ tags = gtk_text_iter_get_tags (iter);
+ for (tagp = tags; tagp != NULL; tagp = tagp->next)
+ {
+ GtkTextTag *tag = tagp->data;
+ gchar *path = g_object_get_data (G_OBJECT (tag), "path");
+ gint line =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "line"));
-static void
-follow_if_link (GtranslatorSourceCodeViewPlugin *plugin,
- GtkWidget *text_view,
- GtkTextIter *iter)
-{
- GSList *tags = NULL, *tagp = NULL;
- GtranslatorTab *tab;
- GtranslatorPo *po;
- gchar *fullpath;
- gchar *dirname;
- GFile *location, *parent;
-
- tab = gtranslator_window_get_active_tab (plugin->priv->window);
-
- if (!tab)
- return;
- po = gtranslator_tab_get_po (tab);
-
- location = gtranslator_po_get_location (po);
- parent = g_file_get_parent (location);
- g_object_unref (location);
-
- dirname = g_file_get_path (parent);
- g_object_unref (parent);
-
- tags = gtk_text_iter_get_tags (iter);
- for (tagp = tags; tagp != NULL; tagp = tagp->next)
+ fullpath = g_build_filename (dirname, path, NULL);
+
+ if (path_is_fake (fullpath))
{
- GtkTextTag *tag = tagp->data;
- gchar *path = g_object_get_data (G_OBJECT (tag), "path");
- gint line = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "line"));
+ gchar *msgid = g_object_get_data (G_OBJECT (tag), "msgid");
- fullpath = g_build_filename (dirname, path, NULL);
+ path = g_strdup (fullpath);
+ g_free (fullpath);
+ fullpath = real_path (path);
+ g_free (path);
- if (path_is_fake (fullpath))
- {
- gchar *msgid = g_object_get_data (G_OBJECT (tag), "msgid");
+ line = get_line_for_text (fullpath, msgid);
+ }
- path = g_strdup (fullpath);
- g_free (fullpath);
- fullpath = real_path (path);
- g_free (path);
+ show_source (plugin, fullpath, line);
- line = get_line_for_text (fullpath, msgid);
- }
+ g_free (fullpath);
+ }
- show_source (plugin, fullpath, line);
-
- g_free (fullpath);
- }
+ if (tags)
+ g_slist_free (tags);
- if (tags)
- g_slist_free (tags);
-
- g_free (dirname);
+ g_free (dirname);
}
static gboolean
-event_after (GtkWidget *text_view,
- GdkEvent *ev,
- GtranslatorSourceCodeViewPlugin *plugin)
+event_after (GtkWidget * text_view,
+ GdkEvent * ev, GtranslatorSourceCodeViewPlugin * plugin)
{
- GtkTextIter start, end, iter;
- GtkTextBuffer *buffer;
- GdkEventButton *event;
- gint x, y;
+ GtkTextIter start, end, iter;
+ GtkTextBuffer *buffer;
+ GdkEventButton *event;
+ gint x, y;
+
+ if (ev->type != GDK_BUTTON_RELEASE)
+ return FALSE;
- if (ev->type != GDK_BUTTON_RELEASE)
- return FALSE;
+ event = (GdkEventButton *) ev;
- event = (GdkEventButton *)ev;
+ if (event->button != 1)
+ return FALSE;
- if (event->button != 1)
- return FALSE;
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
+ /* we shouldn't follow a link if the user has selected something */
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+ if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
+ return FALSE;
- /* we shouldn't follow a link if the user has selected something */
- gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
- if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
- return FALSE;
+ gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+ GTK_TEXT_WINDOW_WIDGET,
+ event->x, event->y, &x, &y);
- gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
- GTK_TEXT_WINDOW_WIDGET,
- event->x, event->y, &x, &y);
-
- gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
+ gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
- follow_if_link (plugin, text_view, &iter);
+ follow_if_link (plugin, text_view, &iter);
- return FALSE;
+ return FALSE;
}
static gboolean hovering_over_link = FALSE;
@@ -331,497 +315,476 @@ static GdkCursor *regular_cursor = NULL;
* typically used by web browsers.
*/
static void
-set_cursor_if_appropriate (GtkTextView *text_view,
- gint x,
- gint y)
+set_cursor_if_appropriate (GtkTextView * text_view, gint x, gint y)
{
- GSList *tags = NULL, *tagp = NULL;
- GtkTextIter iter;
- gboolean hovering = FALSE;
-
- gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
-
- tags = gtk_text_iter_get_tags (&iter);
- for (tagp = tags; tagp != NULL; tagp = tagp->next)
- {
- GtkTextTag *tag = tagp->data;
- gchar *path = g_object_get_data (G_OBJECT (tag), "path");
-
- if (path)
- {
- hovering = TRUE;
- break;
- }
- }
+ GSList *tags = NULL, *tagp = NULL;
+ GtkTextIter iter;
+ gboolean hovering = FALSE;
+
+ gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
- if (hovering != hovering_over_link)
+ tags = gtk_text_iter_get_tags (&iter);
+ for (tagp = tags; tagp != NULL; tagp = tagp->next)
+ {
+ GtkTextTag *tag = tagp->data;
+ gchar *path = g_object_get_data (G_OBJECT (tag), "path");
+
+ if (path)
{
- hovering_over_link = hovering;
-
- if (hovering_over_link)
- gdk_window_set_cursor (gtk_text_view_get_window (text_view,
- GTK_TEXT_WINDOW_TEXT),
- hand_cursor);
- else
- gdk_window_set_cursor (gtk_text_view_get_window (text_view,
- GTK_TEXT_WINDOW_TEXT),
- regular_cursor);
+ hovering = TRUE;
+ break;
}
-
- if (tags)
- g_slist_free (tags);
+ }
+
+ if (hovering != hovering_over_link)
+ {
+ hovering_over_link = hovering;
+
+ if (hovering_over_link)
+ gdk_window_set_cursor (gtk_text_view_get_window (text_view,
+ GTK_TEXT_WINDOW_TEXT),
+ hand_cursor);
+ else
+ gdk_window_set_cursor (gtk_text_view_get_window (text_view,
+ GTK_TEXT_WINDOW_TEXT),
+ regular_cursor);
+ }
+
+ if (tags)
+ g_slist_free (tags);
}
/*
* Update the cursor image if the pointer moved.
*/
static gboolean
-motion_notify_event (GtkWidget *text_view,
- GdkEventMotion *event)
+motion_notify_event (GtkWidget * text_view, GdkEventMotion * event)
{
- gint x, y;
+ gint x, y;
- gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
- GTK_TEXT_WINDOW_WIDGET,
- event->x, event->y, &x, &y);
+ gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+ GTK_TEXT_WINDOW_WIDGET,
+ event->x, event->y, &x, &y);
- set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
+ set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
- gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
- return FALSE;
+ gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
+ return FALSE;
}
/* Also update the cursor image if the window becomes visible
* (e.g. when a window covering it got iconified).
*/
static gboolean
-visibility_notify_event (GtkWidget *text_view,
- GdkEventVisibility *event)
+visibility_notify_event (GtkWidget * text_view, GdkEventVisibility * event)
{
- gint wx, wy, bx, by;
-
- gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
-
- gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
- GTK_TEXT_WINDOW_WIDGET,
- wx, wy, &bx, &by);
+ gint wx, wy, bx, by;
+
+ gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
- set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), bx, by);
+ gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+ GTK_TEXT_WINDOW_WIDGET,
+ wx, wy, &bx, &by);
- return FALSE;
+ set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), bx, by);
+
+ return FALSE;
}
static void
-gtranslator_source_code_view_plugin_init (GtranslatorSourceCodeViewPlugin *plugin)
+gtranslator_source_code_view_plugin_init (GtranslatorSourceCodeViewPlugin *
+ plugin)
{
- plugin->priv = GTR_SOURCE_CODE_VIEW_PLUGIN_GET_PRIVATE (plugin);
+ plugin->priv = GTR_SOURCE_CODE_VIEW_PLUGIN_GET_PRIVATE (plugin);
+
+ plugin->priv->gconf_client = gconf_client_get_default ();
- plugin->priv->gconf_client = gconf_client_get_default ();
+ gconf_client_add_dir (plugin->priv->gconf_client,
+ SOURCE_CODE_VIEW_BASE_KEY,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- gconf_client_add_dir (plugin->priv->gconf_client,
- SOURCE_CODE_VIEW_BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- plugin->priv->tags = NULL;
+ plugin->priv->tags = NULL;
}
static void
-gtranslator_source_code_view_plugin_finalize (GObject *object)
+gtranslator_source_code_view_plugin_finalize (GObject * object)
{
- GtranslatorSourceCodeViewPlugin *plugin = GTR_SOURCE_CODE_VIEW_PLUGIN (object);
-
- gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
+ GtranslatorSourceCodeViewPlugin *plugin =
+ GTR_SOURCE_CODE_VIEW_PLUGIN (object);
+
+ gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
- g_object_unref (G_OBJECT (plugin->priv->gconf_client));
-
- G_OBJECT_CLASS (gtranslator_source_code_view_plugin_parent_class)->finalize (object);
+ g_object_unref (G_OBJECT (plugin->priv->gconf_client));
+
+ G_OBJECT_CLASS (gtranslator_source_code_view_plugin_parent_class)->
+ finalize (object);
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorSourceCodeViewPlugin *plugin)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg,
+ GtranslatorSourceCodeViewPlugin * plugin)
{
- const gchar *filename = NULL;
- gint i = 0;
- gint *line = NULL;
- GtkTextIter iter;
- GtkTextBuffer *buffer;
- GtkTextView *view;
- GtranslatorContextPanel *panel;
- GtkTextMark *path_start, *path_end;
-
- panel = gtranslator_tab_get_context_panel (tab);
- view = gtranslator_context_panel_get_context_text_view (panel);
-
- buffer = gtk_text_view_get_buffer (view);
-
- gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
-
- path_start = gtk_text_buffer_create_mark (buffer,
- "path_start",
- &iter,
- TRUE);
- gtk_text_buffer_insert (buffer, &iter, _("Paths:\n"), -1);
-
- filename = gtranslator_msg_get_filename (msg, i);
- while (filename)
- {
- line = gtranslator_msg_get_file_line (msg, i);
- insert_link (buffer, &iter, filename, line, plugin, gtranslator_msg_get_msgid (msg));
- i++;
- filename = gtranslator_msg_get_filename (msg, i);
- }
-
- /*
- * The tags are managed by buffer, so lets add a reference in the buffer
- */
- g_object_set_data (G_OBJECT (buffer), "link_tags", plugin->priv->tags);
- plugin->priv->tags = NULL;
-
- path_end = gtk_text_buffer_create_mark (buffer,
- "path_end",
- &iter,
- TRUE);
+ const gchar *filename = NULL;
+ gint i = 0;
+ gint *line = NULL;
+ GtkTextIter iter;
+ GtkTextBuffer *buffer;
+ GtkTextView *view;
+ GtranslatorContextPanel *panel;
+ GtkTextMark *path_start, *path_end;
+
+ panel = gtranslator_tab_get_context_panel (tab);
+ view = gtranslator_context_panel_get_context_text_view (panel);
+
+ buffer = gtk_text_view_get_buffer (view);
+
+ gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+
+ path_start = gtk_text_buffer_create_mark (buffer,
+ "path_start", &iter, TRUE);
+ gtk_text_buffer_insert (buffer, &iter, _("Paths:\n"), -1);
+
+ filename = gtranslator_msg_get_filename (msg, i);
+ while (filename)
+ {
+ line = gtranslator_msg_get_file_line (msg, i);
+ insert_link (buffer, &iter, filename, line, plugin,
+ gtranslator_msg_get_msgid (msg));
+ i++;
+ filename = gtranslator_msg_get_filename (msg, i);
+ }
+
+ /*
+ * The tags are managed by buffer, so lets add a reference in the buffer
+ */
+ g_object_set_data (G_OBJECT (buffer), "link_tags", plugin->priv->tags);
+ plugin->priv->tags = NULL;
+
+ path_end = gtk_text_buffer_create_mark (buffer, "path_end", &iter, TRUE);
}
static void
-delete_text_and_tags (GtranslatorTab *tab,
- GtranslatorSourceCodeViewPlugin *plugin)
+delete_text_and_tags (GtranslatorTab * tab,
+ GtranslatorSourceCodeViewPlugin * plugin)
{
- GSList *tagp = NULL, *tags;
- GtkTextBuffer *buffer;
- GtranslatorContextPanel *panel;
- GtkTextView *view;
- GtkTextIter start, end;
- GtkTextMark *path_start, *path_end;
-
- panel = gtranslator_tab_get_context_panel (tab);
- view = gtranslator_context_panel_get_context_text_view (panel);
-
- buffer = gtk_text_view_get_buffer (view);
- path_start = gtk_text_buffer_get_mark (buffer, "path_start");
-
- if (path_start == NULL)
- return;
-
- path_end = gtk_text_buffer_get_mark (buffer, "path_end");
- tags = g_object_get_data (G_OBJECT (buffer), "link_tags");
-
- for (tagp = tags; tagp != NULL; tagp = tagp->next)
- {
- GtkTextTag *tag = tagp->data;
- gchar *path = g_object_get_data (G_OBJECT (tag), "path");
- gchar *msgid = g_object_get_data (G_OBJECT (tag), "msgid");
-
- if (path)
- g_free (path);
- if (msgid)
- g_free (msgid);
- }
- g_slist_free (tags);
-
- /*
- * Deleting the text
- */
- gtk_text_buffer_get_iter_at_mark (buffer, &start, path_start);
- gtk_text_buffer_get_iter_at_mark (buffer, &end, path_end);
- gtk_text_buffer_delete (buffer, &start, &end);
-
- /*
- * Deleting the marks
- */
- gtk_text_buffer_delete_mark (buffer, path_start);
- gtk_text_buffer_delete_mark (buffer, path_end);
+ GSList *tagp = NULL, *tags;
+ GtkTextBuffer *buffer;
+ GtranslatorContextPanel *panel;
+ GtkTextView *view;
+ GtkTextIter start, end;
+ GtkTextMark *path_start, *path_end;
+
+ panel = gtranslator_tab_get_context_panel (tab);
+ view = gtranslator_context_panel_get_context_text_view (panel);
+
+ buffer = gtk_text_view_get_buffer (view);
+ path_start = gtk_text_buffer_get_mark (buffer, "path_start");
+
+ if (path_start == NULL)
+ return;
+
+ path_end = gtk_text_buffer_get_mark (buffer, "path_end");
+ tags = g_object_get_data (G_OBJECT (buffer), "link_tags");
+
+ for (tagp = tags; tagp != NULL; tagp = tagp->next)
+ {
+ GtkTextTag *tag = tagp->data;
+ gchar *path = g_object_get_data (G_OBJECT (tag), "path");
+ gchar *msgid = g_object_get_data (G_OBJECT (tag), "msgid");
+
+ if (path)
+ g_free (path);
+ if (msgid)
+ g_free (msgid);
+ }
+ g_slist_free (tags);
+
+ /*
+ * Deleting the text
+ */
+ gtk_text_buffer_get_iter_at_mark (buffer, &start, path_start);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, path_end);
+ gtk_text_buffer_delete (buffer, &start, &end);
+
+ /*
+ * Deleting the marks
+ */
+ gtk_text_buffer_delete_mark (buffer, path_start);
+ gtk_text_buffer_delete_mark (buffer, path_end);
}
static void
-message_edition_finished_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorSourceCodeViewPlugin *plugin)
+message_edition_finished_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg,
+ GtranslatorSourceCodeViewPlugin * plugin)
{
- delete_text_and_tags (tab, plugin);
+ delete_text_and_tags (tab, plugin);
}
static void
-page_added_cb (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- GtranslatorSourceCodeViewPlugin *plugin)
-{
- GtranslatorContextPanel *panel;
- GtkTextView *view;
-
- panel = gtranslator_tab_get_context_panel (GTR_TAB (child));
- view = gtranslator_context_panel_get_context_text_view (panel);
-
- g_return_if_fail (GTK_IS_TEXT_VIEW (view));
-
- g_signal_connect_after (child, "showed-message",
- G_CALLBACK (showed_message_cb), plugin);
- g_signal_connect (child, "message-edition-finished",
- G_CALLBACK (message_edition_finished_cb), plugin);
-
- g_signal_connect (view, "event-after",
- G_CALLBACK (event_after), plugin);
- g_signal_connect (view, "motion-notify-event",
- G_CALLBACK (motion_notify_event), NULL);
- g_signal_connect (view, "visibility-notify-event",
- G_CALLBACK (visibility_notify_event), NULL);
+page_added_cb (GtkNotebook * notebook,
+ GtkWidget * child,
+ guint page_num, GtranslatorSourceCodeViewPlugin * plugin)
+{
+ GtranslatorContextPanel *panel;
+ GtkTextView *view;
+
+ panel = gtranslator_tab_get_context_panel (GTR_TAB (child));
+ view = gtranslator_context_panel_get_context_text_view (panel);
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (view));
+
+ g_signal_connect_after (child, "showed-message",
+ G_CALLBACK (showed_message_cb), plugin);
+ g_signal_connect (child, "message-edition-finished",
+ G_CALLBACK (message_edition_finished_cb), plugin);
+
+ g_signal_connect (view, "event-after", G_CALLBACK (event_after), plugin);
+ g_signal_connect (view, "motion-notify-event",
+ G_CALLBACK (motion_notify_event), NULL);
+ g_signal_connect (view, "visibility-notify-event",
+ G_CALLBACK (visibility_notify_event), NULL);
}
static void
-use_editor_toggled (GtkToggleButton *button,
- GtranslatorSourceCodeViewPlugin *plugin)
+use_editor_toggled (GtkToggleButton * button,
+ GtranslatorSourceCodeViewPlugin * plugin)
{
- gtk_widget_set_sensitive (plugin->priv->program_box,
- gtk_toggle_button_get_active (button));
+ gtk_widget_set_sensitive (plugin->priv->program_box,
+ gtk_toggle_button_get_active (button));
}
static GtkWidget *
-get_configuration_dialog (GtranslatorSourceCodeViewPlugin *plugin)
+get_configuration_dialog (GtranslatorSourceCodeViewPlugin * plugin)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *value;
- gboolean use_editor;
- gchar *root_objects [] = {
- "dialog",
- NULL
- };
-
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
- "dialog", &plugin->priv->dialog,
- "main_box", &plugin->priv->main_box,
- "use_editor", &plugin->priv->use_editor_checkbutton,
- "program_box", &plugin->priv->program_box,
- "program_cmd", &plugin->priv->program_cmd_entry,
- "line_cmd", &plugin->priv->line_cmd_entry,
- NULL);
-
- if(!ret)
- {
- //FIXME: We have to show a dialog
- }
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *value;
+ gboolean use_editor;
+ gchar *root_objects[] = {
+ "dialog",
+ NULL
+ };
+
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "dialog", &plugin->priv->dialog,
+ "main_box", &plugin->priv->main_box,
+ "use_editor",
+ &plugin->priv->
+ use_editor_checkbutton,
+ "program_box",
+ &plugin->priv->program_box,
+ "program_cmd",
+ &plugin->priv->program_cmd_entry,
+ "line_cmd",
+ &plugin->priv->line_cmd_entry,
+ NULL);
+
+ if (!ret)
+ {
+ //FIXME: We have to show a dialog
+ }
+
+ /* Set default values */
+
+ //Use editor
+ use_editor = gconf_client_get_bool (plugin->priv->gconf_client,
+ USE_EDITOR_KEY, NULL);
+
+ g_signal_connect (plugin->priv->use_editor_checkbutton, "toggled",
+ G_CALLBACK (use_editor_toggled), plugin);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (plugin->priv->use_editor_checkbutton),
+ use_editor);
+
+ use_editor_toggled (GTK_TOGGLE_BUTTON
+ (plugin->priv->use_editor_checkbutton), plugin);
+
+ //Program cmd
+ value = gconf_client_get_string (plugin->priv->gconf_client,
+ PROGRAM_CMD_KEY, NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (plugin->priv->program_cmd_entry), value);
+
+ g_free (value);
- /* Set default values */
-
- //Use editor
- use_editor = gconf_client_get_bool (plugin->priv->gconf_client,
- USE_EDITOR_KEY,
- NULL);
-
- g_signal_connect (plugin->priv->use_editor_checkbutton, "toggled",
- G_CALLBACK (use_editor_toggled), plugin);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (plugin->priv->use_editor_checkbutton),
- use_editor);
-
- use_editor_toggled (GTK_TOGGLE_BUTTON (plugin->priv->use_editor_checkbutton),
- plugin);
-
- //Program cmd
- value = gconf_client_get_string (plugin->priv->gconf_client,
- PROGRAM_CMD_KEY,
- NULL);
-
- gtk_entry_set_text (GTK_ENTRY (plugin->priv->program_cmd_entry),
- value);
-
- g_free (value);
-
- //Line cmd
- value = gconf_client_get_string (plugin->priv->gconf_client,
- LINE_CMD_KEY,
- NULL);
-
- gtk_entry_set_text (GTK_ENTRY (plugin->priv->line_cmd_entry),
- value);
-
- g_free (value);
-
- return plugin->priv->dialog;
+ //Line cmd
+ value = gconf_client_get_string (plugin->priv->gconf_client,
+ LINE_CMD_KEY, NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (plugin->priv->line_cmd_entry), value);
+
+ g_free (value);
+
+ return plugin->priv->dialog;
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
-{
- GtkWidget *notebook;
- GtranslatorSourceCodeViewPlugin *source_code_view = GTR_SOURCE_CODE_VIEW_PLUGIN (plugin);
- GList *tabs, *l;
-
- /*
- * Cursors
- */
- hand_cursor = gdk_cursor_new (GDK_HAND2);
- regular_cursor = gdk_cursor_new (GDK_XTERM);
-
- notebook = GTK_WIDGET (gtranslator_window_get_notebook (window));
-
- source_code_view->priv->window = window;
-
- g_signal_connect (notebook, "page-added",
- G_CALLBACK (page_added_cb), plugin);
-
- /*
- * If we already have tabs opened we have to add them
- */
- tabs = gtranslator_window_get_all_tabs (window);
- for (l = tabs; l != NULL; l = g_list_next (l))
- {
- GtranslatorPo *po;
- GList *msg;
-
- page_added_cb (GTK_NOTEBOOK (notebook),
- l->data, 0, GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
-
- po = gtranslator_tab_get_po (GTR_TAB (l->data));
- msg = gtranslator_po_get_current_message (po);
-
- showed_message_cb (GTR_TAB (l->data),
- msg->data, GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
- }
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
+{
+ GtkWidget *notebook;
+ GtranslatorSourceCodeViewPlugin *source_code_view =
+ GTR_SOURCE_CODE_VIEW_PLUGIN (plugin);
+ GList *tabs, *l;
+
+ /*
+ * Cursors
+ */
+ hand_cursor = gdk_cursor_new (GDK_HAND2);
+ regular_cursor = gdk_cursor_new (GDK_XTERM);
+
+ notebook = GTK_WIDGET (gtranslator_window_get_notebook (window));
+
+ source_code_view->priv->window = window;
+
+ g_signal_connect (notebook, "page-added",
+ G_CALLBACK (page_added_cb), plugin);
+
+ /*
+ * If we already have tabs opened we have to add them
+ */
+ tabs = gtranslator_window_get_all_tabs (window);
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ GtranslatorPo *po;
+ GList *msg;
+
+ page_added_cb (GTK_NOTEBOOK (notebook),
+ l->data, 0, GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
+
+ po = gtranslator_tab_get_po (GTR_TAB (l->data));
+ msg = gtranslator_po_get_current_message (po);
+
+ showed_message_cb (GTR_TAB (l->data),
+ msg->data, GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
+ }
}
static void
-impl_deactivate(GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GList *tabs, *l;
- GtkTextView *view;
- GtranslatorContextPanel *panel;
- GtkWidget *notebook;
-
- tabs = gtranslator_window_get_all_tabs (window);
- notebook = GTK_WIDGET (gtranslator_window_get_notebook (window));
-
- for (l = tabs; l != NULL; l = g_list_next (l))
- {
- panel = gtranslator_tab_get_context_panel (GTR_TAB (l->data));
- view = gtranslator_context_panel_get_context_text_view (panel);
-
- delete_text_and_tags (GTR_TAB (l->data), GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
-
- g_signal_handlers_disconnect_by_func (l->data,
- showed_message_cb,
- plugin);
-
- g_signal_handlers_disconnect_by_func (view,
- event_after,
- window);
- g_signal_handlers_disconnect_by_func (view,
- motion_notify_event,
- NULL);
- g_signal_handlers_disconnect_by_func (view,
- visibility_notify_event,
- NULL);
- }
-
- g_signal_handlers_disconnect_by_func (notebook,
- page_added_cb,
- plugin);
+ GList *tabs, *l;
+ GtkTextView *view;
+ GtranslatorContextPanel *panel;
+ GtkWidget *notebook;
+
+ tabs = gtranslator_window_get_all_tabs (window);
+ notebook = GTK_WIDGET (gtranslator_window_get_notebook (window));
+
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ panel = gtranslator_tab_get_context_panel (GTR_TAB (l->data));
+ view = gtranslator_context_panel_get_context_text_view (panel);
+
+ delete_text_and_tags (GTR_TAB (l->data),
+ GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
+
+ g_signal_handlers_disconnect_by_func (l->data,
+ showed_message_cb, plugin);
+
+ g_signal_handlers_disconnect_by_func (view, event_after, window);
+ g_signal_handlers_disconnect_by_func (view, motion_notify_event, NULL);
+ g_signal_handlers_disconnect_by_func (view,
+ visibility_notify_event, NULL);
+ }
+
+ g_signal_handlers_disconnect_by_func (notebook, page_added_cb, plugin);
}
static void
-ok_button_pressed (GtranslatorSourceCodeViewPlugin *plugin)
+ok_button_pressed (GtranslatorSourceCodeViewPlugin * plugin)
{
- const gchar *program_cmd;
- const gchar *line_cmd;
- gboolean use_editor;
-
- /* We have to get the text from the entries */
- use_editor = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (plugin->priv->use_editor_checkbutton));
- program_cmd = gtk_entry_get_text (GTK_ENTRY (plugin->priv->program_cmd_entry));
- line_cmd = gtk_entry_get_text (GTK_ENTRY (plugin->priv->line_cmd_entry));
-
- /* Now we store the data in gconf */
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- USE_EDITOR_KEY,
- NULL))
- return;
-
- gconf_client_set_bool (plugin->priv->gconf_client,
- USE_EDITOR_KEY,
- use_editor,
- NULL);
-
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- PROGRAM_CMD_KEY,
- NULL))
- return;
-
- gconf_client_set_string (plugin->priv->gconf_client,
- PROGRAM_CMD_KEY,
- program_cmd,
- NULL);
-
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- LINE_CMD_KEY,
- NULL))
- return;
-
- gconf_client_set_string (plugin->priv->gconf_client,
- LINE_CMD_KEY,
- line_cmd,
- NULL);
+ const gchar *program_cmd;
+ const gchar *line_cmd;
+ gboolean use_editor;
+
+ /* We have to get the text from the entries */
+ use_editor =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (plugin->priv->use_editor_checkbutton));
+ program_cmd =
+ gtk_entry_get_text (GTK_ENTRY (plugin->priv->program_cmd_entry));
+ line_cmd = gtk_entry_get_text (GTK_ENTRY (plugin->priv->line_cmd_entry));
+
+ /* Now we store the data in gconf */
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ USE_EDITOR_KEY, NULL))
+ return;
+
+ gconf_client_set_bool (plugin->priv->gconf_client,
+ USE_EDITOR_KEY, use_editor, NULL);
+
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ PROGRAM_CMD_KEY, NULL))
+ return;
+
+ gconf_client_set_string (plugin->priv->gconf_client,
+ PROGRAM_CMD_KEY, program_cmd, NULL);
+
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ LINE_CMD_KEY, NULL))
+ return;
+
+ gconf_client_set_string (plugin->priv->gconf_client,
+ LINE_CMD_KEY, line_cmd, NULL);
}
static void
-configure_dialog_response_cb (GtkWidget *widget,
- gint response,
- GtranslatorSourceCodeViewPlugin *plugin)
+configure_dialog_response_cb (GtkWidget * widget,
+ gint response,
+ GtranslatorSourceCodeViewPlugin * plugin)
{
- switch (response)
- {
- case GTK_RESPONSE_OK:
- {
- ok_button_pressed (plugin);
-
- gtk_widget_destroy (plugin->priv->dialog);
- break;
- }
- case GTK_RESPONSE_CANCEL:
- {
- gtk_widget_destroy (plugin->priv->dialog);
- }
- }
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ ok_button_pressed (plugin);
+
+ gtk_widget_destroy (plugin->priv->dialog);
+ break;
+ }
+ case GTK_RESPONSE_CANCEL:
+ {
+ gtk_widget_destroy (plugin->priv->dialog);
+ }
+ }
}
static GtkWidget *
-impl_create_configure_dialog (GtranslatorPlugin *plugin)
+impl_create_configure_dialog (GtranslatorPlugin * plugin)
{
- GtkWidget *dialog;
-
- dialog = get_configuration_dialog (GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
-
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (configure_dialog_response_cb),
- GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
- g_signal_connect (dialog,
- "destroy",
- G_CALLBACK (gtk_widget_destroy),
- &dialog);
-
- return dialog;
+ GtkWidget *dialog;
+
+ dialog = get_configuration_dialog (GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
+
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (configure_dialog_response_cb),
+ GTR_SOURCE_CODE_VIEW_PLUGIN (plugin));
+ g_signal_connect (dialog,
+ "destroy", G_CALLBACK (gtk_widget_destroy), &dialog);
+
+ return dialog;
}
static void
-gtranslator_source_code_view_plugin_class_init (GtranslatorSourceCodeViewPluginClass *klass)
+gtranslator_source_code_view_plugin_class_init
+ (GtranslatorSourceCodeViewPluginClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_source_code_view_plugin_finalize;
- object_class->finalize = gtranslator_source_code_view_plugin_finalize;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->create_configure_dialog = impl_create_configure_dialog;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->create_configure_dialog = impl_create_configure_dialog;
-
- g_type_class_add_private (object_class, sizeof (GtranslatorSourceCodeViewPluginPrivate));
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorSourceCodeViewPluginPrivate));
}
diff --git a/plugins/source-code-view/source-code-view-plugin.h b/plugins/source-code-view/source-code-view-plugin.h
index 12d86eb..5e46a50 100644
--- a/plugins/source-code-view/source-code-view-plugin.h
+++ b/plugins/source-code-view/source-code-view-plugin.h
@@ -25,7 +25,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,41 +34,44 @@ G_BEGIN_DECLS
#define GTR_IS_SOURCE_CODE_VIEW_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_SOURCE_CODE_VIEW_PLUGIN))
#define GTR_IS_SOURCE_CODE_VIEW_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_SOURCE_CODE_VIEW_PLUGIN))
#define GTR_SOURCE_CODE_VIEW_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_SOURCE_CODE_VIEW_PLUGIN_PLUGIN, GtranslatorSourceCodeViewPluginClass))
-
/* Private structure type */
-typedef struct _GtranslatorSourceCodeViewPluginPrivate GtranslatorSourceCodeViewPluginPrivate;
+typedef struct _GtranslatorSourceCodeViewPluginPrivate
+ GtranslatorSourceCodeViewPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorSourceCodeViewPlugin GtranslatorSourceCodeViewPlugin;
+typedef struct _GtranslatorSourceCodeViewPlugin
+ GtranslatorSourceCodeViewPlugin;
struct _GtranslatorSourceCodeViewPlugin
{
- GtranslatorPlugin parent_instance;
-
- /* private */
- GtranslatorSourceCodeViewPluginPrivate *priv;
+ GtranslatorPlugin parent_instance;
+
+ /* private */
+ GtranslatorSourceCodeViewPluginPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorSourceCodeViewPluginClass GtranslatorSourceCodeViewPluginClass;
+typedef struct _GtranslatorSourceCodeViewPluginClass
+ GtranslatorSourceCodeViewPluginClass;
struct _GtranslatorSourceCodeViewPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_source_code_view_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_source_code_view_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_SOURCE_CODE_VIEW_PLUGIN_H__ */
diff --git a/plugins/source-code-view/viewer.c b/plugins/source-code-view/viewer.c
index 8d50e91..bd8e810 100644
--- a/plugins/source-code-view/viewer.c
+++ b/plugins/source-code-view/viewer.c
@@ -38,432 +38,414 @@
GtranslatorViewerPrivate))
-G_DEFINE_TYPE(GtranslatorViewer, gtranslator_viewer, GTK_TYPE_DIALOG)
-
-struct _GtranslatorViewerPrivate
-{
- GtkWidget *main_box;
- GtkWidget *view;
- GtkWidget *filename_label;
-};
-
-static void
-dialog_response_handler (GtkDialog *dlg,
- gint res_id)
+G_DEFINE_TYPE (GtranslatorViewer, gtranslator_viewer, GTK_TYPE_DIALOG)
+ struct _GtranslatorViewerPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *view;
+ GtkWidget *filename_label;
+ };
+
+ static void dialog_response_handler (GtkDialog * dlg, gint res_id)
{
- switch (res_id)
- {
- default:
- gtk_widget_destroy (GTK_WIDGET(dlg));
- }
+ switch (res_id)
+ {
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
}
static void
-gtranslator_viewer_init (GtranslatorViewer *dlg)
+gtranslator_viewer_init (GtranslatorViewer * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- GtkWidget *sw;
- gchar *root_objects [] = {
- "main_box",
- NULL
- };
-
- dlg->priv = GTR_VIEWER_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Source Viewer"));
- gtk_window_set_default_size(GTK_WINDOW(dlg), 800, 600);
- gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Builder*/
- ret = gtranslator_utils_get_ui_objects (DATADIR "/viewer.ui",
- root_objects,
- &error_widget,
-
- "main_box", &dlg->priv->main_box,
- "scrolledwindow", &sw,
- "filename_label", &dlg->priv->filename_label,
- NULL);
-
- if(!ret)
- {
- gtk_widget_show(error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
- /* Source view */
- dlg->priv->view = gtk_source_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->priv->view), FALSE);
- gtk_widget_show (dlg->priv->view);
- gtk_container_add (GTK_CONTAINER (sw), dlg->priv->view);
-
- gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (dlg->priv->view),
- TRUE);
-
- gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW (dlg->priv->view),
- TRUE);
-
- gtk_source_view_set_show_right_margin (GTK_SOURCE_VIEW (dlg->priv->view),
- TRUE);
+ gboolean ret;
+ GtkWidget *error_widget;
+ GtkWidget *sw;
+ gchar *root_objects[] = {
+ "main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_VIEWER_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Source Viewer"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 800, 600);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Builder */
+ ret = gtranslator_utils_get_ui_objects (DATADIR "/viewer.ui",
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "scrolledwindow", &sw,
+ "filename_label",
+ &dlg->priv->filename_label, NULL);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
+ /* Source view */
+ dlg->priv->view = gtk_source_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->priv->view), FALSE);
+ gtk_widget_show (dlg->priv->view);
+ gtk_container_add (GTK_CONTAINER (sw), dlg->priv->view);
+
+ gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW
+ (dlg->priv->view), TRUE);
+
+ gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW (dlg->priv->view),
+ TRUE);
+
+ gtk_source_view_set_show_right_margin (GTK_SOURCE_VIEW (dlg->priv->view),
+ TRUE);
}
static void
-gtranslator_viewer_finalize (GObject *object)
+gtranslator_viewer_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_viewer_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_viewer_parent_class)->finalize (object);
}
static void
-gtranslator_viewer_class_init (GtranslatorViewerClass *klass)
+gtranslator_viewer_class_init (GtranslatorViewerClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorViewerPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorViewerPrivate));
- object_class->finalize = gtranslator_viewer_finalize;
+ object_class->finalize = gtranslator_viewer_finalize;
}
/***************** File loading *****************/
static void
-error_dialog (GtkWindow *parent, const gchar *msg, ...)
+error_dialog (GtkWindow * parent, const gchar * msg, ...)
{
- va_list ap;
- gchar *tmp;
- GtkWidget *dialog;
-
- va_start (ap, msg);
- tmp = g_strdup_vprintf (msg, ap);
- va_end (ap);
-
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s", tmp);
- g_free (tmp);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ va_list ap;
+ gchar *tmp;
+ GtkWidget *dialog;
+
+ va_start (ap, msg);
+ tmp = g_strdup_vprintf (msg, ap);
+ va_end (ap);
+
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, "%s", tmp);
+ g_free (tmp);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
static gboolean
-gtk_source_buffer_load_file (GtkSourceBuffer *source_buffer,
- const gchar *filename,
- GError **error)
+gtk_source_buffer_load_file (GtkSourceBuffer * source_buffer,
+ const gchar * filename, GError ** error)
{
- GtkTextIter iter;
- gchar *buffer;
- GError *error_here = NULL;
-
- g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (source_buffer), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
-
- if (!g_file_get_contents (filename, &buffer, NULL, &error_here))
- {
- error_dialog (NULL, "%s\nFile %s", error_here->message, filename);
- g_propagate_error (error, error_here);
- return FALSE;
- }
-
- gtk_source_buffer_begin_not_undoable_action (source_buffer);
- gtk_text_buffer_set_text (GTK_TEXT_BUFFER (source_buffer), buffer, -1);
- gtk_source_buffer_end_not_undoable_action (source_buffer);
- gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (source_buffer), FALSE);
-
- /* move cursor to the beginning */
- gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (source_buffer), &iter);
- gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (source_buffer), &iter);
-
- {
- GtkTextIter start, end;
- char *text;
- gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (source_buffer), &start, &end);
- text = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (source_buffer), &start, &end, TRUE);
- g_assert (!strcmp (text, buffer));
- g_free (text);
- }
-
- g_free (buffer);
- return TRUE;
+ GtkTextIter iter;
+ gchar *buffer;
+ GError *error_here = NULL;
+
+ g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (source_buffer), FALSE);
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ if (!g_file_get_contents (filename, &buffer, NULL, &error_here))
+ {
+ error_dialog (NULL, "%s\nFile %s", error_here->message, filename);
+ g_propagate_error (error, error_here);
+ return FALSE;
+ }
+
+ gtk_source_buffer_begin_not_undoable_action (source_buffer);
+ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (source_buffer), buffer, -1);
+ gtk_source_buffer_end_not_undoable_action (source_buffer);
+ gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (source_buffer), FALSE);
+
+ /* move cursor to the beginning */
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (source_buffer), &iter);
+ gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (source_buffer), &iter);
+
+ {
+ GtkTextIter start, end;
+ char *text;
+ gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (source_buffer), &start,
+ &end);
+ text =
+ gtk_text_buffer_get_text (GTK_TEXT_BUFFER (source_buffer), &start, &end,
+ TRUE);
+ g_assert (!strcmp (text, buffer));
+ g_free (text);
+ }
+
+ g_free (buffer);
+ return TRUE;
}
static void
-remove_all_marks (GtkSourceBuffer *buffer)
+remove_all_marks (GtkSourceBuffer * buffer)
{
- GtkTextIter s, e;
+ GtkTextIter s, e;
- gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer), &s, &e);
+ gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer), &s, &e);
- gtk_source_buffer_remove_source_marks (buffer, &s, &e, NULL);
+ gtk_source_buffer_remove_source_marks (buffer, &s, &e, NULL);
}
/* Note this is wrong for several reasons, e.g. g_pattern_match is broken
* for glob matching. */
static GtkSourceLanguage *
-get_language_for_filename (const gchar *filename)
+get_language_for_filename (const gchar * filename)
{
- const gchar * const *languages;
- gchar *filename_utf8;
- GtkSourceLanguageManager *manager;
+ const gchar *const *languages;
+ gchar *filename_utf8;
+ GtkSourceLanguageManager *manager;
+
+ filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+ g_return_val_if_fail (filename_utf8 != NULL, NULL);
+
+ manager = gtk_source_language_manager_get_default ();
+ languages = gtk_source_language_manager_get_language_ids (manager);
- filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
- g_return_val_if_fail (filename_utf8 != NULL, NULL);
+ while (*languages != NULL)
+ {
+ GtkSourceLanguage *lang;
+ gchar **globs, **p;
- manager = gtk_source_language_manager_get_default ();
- languages = gtk_source_language_manager_get_language_ids (manager);
+ lang = gtk_source_language_manager_get_language (manager, *languages);
+ g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (lang), NULL);
+ ++languages;
- while (*languages != NULL)
+ globs = gtk_source_language_get_globs (lang);
+ if (globs == NULL)
+ continue;
+
+ for (p = globs; *p != NULL; p++)
{
- GtkSourceLanguage *lang;
- gchar **globs, **p;
-
- lang = gtk_source_language_manager_get_language (manager,
- *languages);
- g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (lang), NULL);
- ++languages;
-
- globs = gtk_source_language_get_globs (lang);
- if (globs == NULL)
- continue;
-
- for (p = globs; *p != NULL; p++)
- {
- if (g_pattern_match_simple (*p, filename_utf8))
- {
- g_strfreev (globs);
- g_free (filename_utf8);
-
- return lang;
- }
- }
-
- g_strfreev (globs);
+ if (g_pattern_match_simple (*p, filename_utf8))
+ {
+ g_strfreev (globs);
+ g_free (filename_utf8);
+
+ return lang;
+ }
}
- g_free (filename_utf8);
- return NULL;
+ g_strfreev (globs);
+ }
+
+ g_free (filename_utf8);
+ return NULL;
}
static GtkSourceLanguage *
-get_language_for_file (const gchar *filename)
+get_language_for_file (const gchar * filename)
{
- GtkSourceLanguage *language = NULL;
+ GtkSourceLanguage *language = NULL;
- if (!language)
- language = get_language_for_filename (filename);
+ if (!language)
+ language = get_language_for_filename (filename);
- return language;
+ return language;
}
static GtkSourceLanguage *
-get_language_by_id (const gchar *id)
+get_language_by_id (const gchar * id)
{
- GtkSourceLanguageManager *manager;
- manager = gtk_source_language_manager_get_default ();
- return gtk_source_language_manager_get_language (manager, id);
+ GtkSourceLanguageManager *manager;
+ manager = gtk_source_language_manager_get_default ();
+ return gtk_source_language_manager_get_language (manager, id);
}
static GtkSourceLanguage *
-get_language (GtkTextBuffer *buffer, const gchar *filename)
+get_language (GtkTextBuffer * buffer, const gchar * filename)
{
- GtkSourceLanguage *language = NULL;
- GtkTextIter start, end;
- gchar *text;
- gchar *lang_string;
+ GtkSourceLanguage *language = NULL;
+ GtkTextIter start, end;
+ gchar *text;
+ gchar *lang_string;
- gtk_text_buffer_get_start_iter (buffer, &start);
- end = start;
- gtk_text_iter_forward_line (&end);
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ end = start;
+ gtk_text_iter_forward_line (&end);
#define LANG_STRING "gtk-source-lang:"
- text = gtk_text_iter_get_slice (&start, &end);
- lang_string = strstr (text, LANG_STRING);
- if (lang_string != NULL)
- {
- gchar **tokens;
+ text = gtk_text_iter_get_slice (&start, &end);
+ lang_string = strstr (text, LANG_STRING);
+ if (lang_string != NULL)
+ {
+ gchar **tokens;
- lang_string += strlen (LANG_STRING);
- g_strchug (lang_string);
+ lang_string += strlen (LANG_STRING);
+ g_strchug (lang_string);
- tokens = g_strsplit_set (lang_string, " \t\n", 2);
+ tokens = g_strsplit_set (lang_string, " \t\n", 2);
- if (tokens != NULL && tokens[0] != NULL)
- language = get_language_by_id (tokens[0]);
+ if (tokens != NULL && tokens[0] != NULL)
+ language = get_language_by_id (tokens[0]);
- g_strfreev (tokens);
- }
+ g_strfreev (tokens);
+ }
- if (!language)
- language = get_language_for_file (filename);
+ if (!language)
+ language = get_language_for_file (filename);
- g_free (text);
- return language;
+ g_free (text);
+ return language;
}
static gboolean
-open_file (GtkSourceBuffer *buffer, const gchar *filename)
+open_file (GtkSourceBuffer * buffer, const gchar * filename)
{
- GtkSourceLanguage *language = NULL;
- gchar *freeme = NULL;
- gboolean success = FALSE;
- GFile *file;
- gchar *path;
-
- file = g_file_new_for_path (filename);
- path = g_file_get_path (file);
- g_object_unref (file);
-
- remove_all_marks (buffer);
-
- success = gtk_source_buffer_load_file (buffer, path, NULL);
-
- if (!success)
- goto out;
-
- language = get_language (GTK_TEXT_BUFFER (buffer), filename);
-
- if (language == NULL)
- g_print ("No language found for file `%s'\n", filename);
-
- gtk_source_buffer_set_language (buffer, language);
- g_object_set_data_full (G_OBJECT (buffer),
- "filename", g_strdup (filename),
- (GDestroyNotify) g_free);
-
- if (language != NULL)
- {
- gchar **styles;
+ GtkSourceLanguage *language = NULL;
+ gchar *freeme = NULL;
+ gboolean success = FALSE;
+ GFile *file;
+ gchar *path;
- styles = gtk_source_language_get_style_ids (language);
+ file = g_file_new_for_path (filename);
+ path = g_file_get_path (file);
+ g_object_unref (file);
- if (styles == NULL)
- g_print ("No styles in language '%s'\n", gtk_source_language_get_name (language));
- else
- {
- gchar **ids;
- g_print ("Styles in in language '%s':\n", gtk_source_language_get_name (language));
+ remove_all_marks (buffer);
- ids = styles;
+ success = gtk_source_buffer_load_file (buffer, path, NULL);
- while (*ids != NULL)
- {
- const gchar *name;
+ if (!success)
+ goto out;
- name = gtk_source_language_get_style_name (language, *ids);
+ language = get_language (GTK_TEXT_BUFFER (buffer), filename);
- g_print ("- %s (name: '%s')\n", *ids, name);
+ if (language == NULL)
+ g_print ("No language found for file `%s'\n", filename);
- ++ids;
- }
+ gtk_source_buffer_set_language (buffer, language);
+ g_object_set_data_full (G_OBJECT (buffer),
+ "filename", g_strdup (filename),
+ (GDestroyNotify) g_free);
- g_strfreev (styles);
- }
+ if (language != NULL)
+ {
+ gchar **styles;
- g_print("\n");
+ styles = gtk_source_language_get_style_ids (language);
+
+ if (styles == NULL)
+ g_print ("No styles in language '%s'\n",
+ gtk_source_language_get_name (language));
+ else
+ {
+ gchar **ids;
+ g_print ("Styles in in language '%s':\n",
+ gtk_source_language_get_name (language));
+
+ ids = styles;
+
+ while (*ids != NULL)
+ {
+ const gchar *name;
+
+ name = gtk_source_language_get_style_name (language, *ids);
+
+ g_print ("- %s (name: '%s')\n", *ids, name);
+
+ ++ids;
+ }
+
+ g_strfreev (styles);
}
+
+ g_print ("\n");
+ }
out:
- g_free (freeme);
- return success;
+ g_free (freeme);
+ return success;
}
static void
-jump_to_line (GtkTextView *view,
- gint line)
+jump_to_line (GtkTextView * view, gint line)
{
- GtkTextBuffer *buffer;
- GtkTextIter iter;
- gint line_count;
-
- buffer = gtk_text_view_get_buffer (view);
-
- line_count = gtk_text_buffer_get_line_count (buffer);
-
- if (line >= line_count)
- gtk_text_buffer_get_end_iter (buffer,
- &iter);
- else
- gtk_text_buffer_get_iter_at_line (buffer,
- &iter,
- line-1);
-
- gtk_text_buffer_place_cursor (buffer, &iter);
-
- gtk_text_view_scroll_to_mark (view,
- gtk_text_buffer_get_insert (buffer),
- 0.25,
- FALSE,
- 0.0,
- 0.0);
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+ gint line_count;
+
+ buffer = gtk_text_view_get_buffer (view);
+
+ line_count = gtk_text_buffer_get_line_count (buffer);
+
+ if (line >= line_count)
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ else
+ gtk_text_buffer_get_iter_at_line (buffer, &iter, line - 1);
+
+ gtk_text_buffer_place_cursor (buffer, &iter);
+
+ gtk_text_view_scroll_to_mark (view,
+ gtk_text_buffer_get_insert (buffer),
+ 0.25, FALSE, 0.0, 0.0);
}
void
-gtranslator_show_viewer (GtranslatorWindow *window,
- const gchar *path,
- gint line)
+gtranslator_show_viewer (GtranslatorWindow * window,
+ const gchar * path, gint line)
{
- static GtranslatorViewer *dlg = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- if (dlg == NULL)
- {
- GtkSourceBuffer *buffer;
- gchar *label;
-
- dlg = g_object_new (GTR_TYPE_VIEWER, NULL);
-
- buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->view)));
-
- open_file (buffer, path);
- jump_to_line (GTK_TEXT_VIEW (dlg->priv->view), line);
-
- label = g_strdup_printf ("<b>%s</b>", g_path_get_basename (path));
- gtk_label_set_markup (GTK_LABEL (dlg->priv->filename_label),
- label);
- g_free (label);
-
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
- gtk_widget_show (GTK_WIDGET (dlg));
- }
-
- if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (dlg),
- GTK_WINDOW (window));
- }
+ static GtranslatorViewer *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ GtkSourceBuffer *buffer;
+ gchar *label;
+
+ dlg = g_object_new (GTR_TYPE_VIEWER, NULL);
+
+ buffer =
+ GTK_SOURCE_BUFFER (gtk_text_view_get_buffer
+ (GTK_TEXT_VIEW (dlg->priv->view)));
+
+ open_file (buffer, path);
+ jump_to_line (GTK_TEXT_VIEW (dlg->priv->view), line);
+
+ label = g_strdup_printf ("<b>%s</b>", g_path_get_basename (path));
+ gtk_label_set_markup (GTK_LABEL (dlg->priv->filename_label), label);
+ g_free (label);
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+ gtk_widget_show (GTK_WIDGET (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_present (GTK_WINDOW (dlg));
+ gtk_window_present (GTK_WINDOW (dlg));
}
diff --git a/plugins/source-code-view/viewer.h b/plugins/source-code-view/viewer.h
index e2d846f..4841903 100644
--- a/plugins/source-code-view/viewer.h
+++ b/plugins/source-code-view/viewer.h
@@ -26,7 +26,6 @@
#include "msg.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -36,44 +35,43 @@ G_BEGIN_DECLS
#define GTR_IS_VIEWER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_VIEWER))
#define GTR_IS_VIEWER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_VIEWER))
#define GTR_VIEWER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_VIEWER, GtranslatorViewerClass))
-
/* Private structure type */
-typedef struct _GtranslatorViewerPrivate GtranslatorViewerPrivate;
+typedef struct _GtranslatorViewerPrivate GtranslatorViewerPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorViewer GtranslatorViewer;
+typedef struct _GtranslatorViewer GtranslatorViewer;
struct _GtranslatorViewer
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorViewerPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorViewerPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorViewerClass GtranslatorViewerClass;
+typedef struct _GtranslatorViewerClass GtranslatorViewerClass;
struct _GtranslatorViewerClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_viewer_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_viewer_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_viewer_register_type (GTypeModule * module);
+ GType gtranslator_viewer_register_type (GTypeModule * module);
-void gtranslator_show_viewer (GtranslatorWindow *window,
- const gchar *path,
- gint line);
+ void gtranslator_show_viewer (GtranslatorWindow * window,
+ const gchar * path, gint line);
G_END_DECLS
-
#endif /* __VIEWER_H__ */
diff --git a/plugins/subversion/async-command.c b/plugins/subversion/async-command.c
index 830f9fe..b152bb1 100644
--- a/plugins/subversion/async-command.c
+++ b/plugins/subversion/async-command.c
@@ -48,136 +48,136 @@
struct _GtranslatorAsyncCommandPriv
{
- GMutex *mutex;
- guint return_code;
- gboolean complete;
- gboolean new_data_arrived;
+ GMutex *mutex;
+ guint return_code;
+ gboolean complete;
+ gboolean new_data_arrived;
};
-G_DEFINE_TYPE (GtranslatorAsyncCommand, gtranslator_async_command, GTR_TYPE_COMMAND);
+G_DEFINE_TYPE (GtranslatorAsyncCommand, gtranslator_async_command,
+ GTR_TYPE_COMMAND);
static void
-gtranslator_async_command_init (GtranslatorAsyncCommand *self)
+gtranslator_async_command_init (GtranslatorAsyncCommand * self)
{
- self->priv = g_new0 (GtranslatorAsyncCommandPriv, 1);
-
- self->priv->mutex = g_mutex_new ();
+ self->priv = g_new0 (GtranslatorAsyncCommandPriv, 1);
+
+ self->priv->mutex = g_mutex_new ();
}
static void
-gtranslator_async_command_finalize (GObject *object)
+gtranslator_async_command_finalize (GObject * object)
{
- GtranslatorAsyncCommand *self;
-
- self = GTR_ASYNC_COMMAND (object);
-
- g_mutex_free (self->priv->mutex);
- g_idle_remove_by_data (self);
-
- g_free (self->priv);
-
- G_OBJECT_CLASS (gtranslator_async_command_parent_class)->finalize (object);
+ GtranslatorAsyncCommand *self;
+
+ self = GTR_ASYNC_COMMAND (object);
+
+ g_mutex_free (self->priv->mutex);
+ g_idle_remove_by_data (self);
+
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (gtranslator_async_command_parent_class)->finalize (object);
}
static gboolean
-gtranslator_async_command_notification_poll (GtranslatorCommand *command)
+gtranslator_async_command_notification_poll (GtranslatorCommand * command)
{
- GtranslatorAsyncCommand *self;
-
- self = GTR_ASYNC_COMMAND (command);
-
- if (self->priv->new_data_arrived &&
- g_mutex_trylock (self->priv->mutex))
- {
- g_signal_emit_by_name (command, "data-arrived");
- g_mutex_unlock (self->priv->mutex);
- self->priv->new_data_arrived = FALSE;
- }
-
- if (self->priv->complete)
- {
- g_signal_emit_by_name (command, "command-finished",
- self->priv->return_code);
- return FALSE;
- }
- else
- return TRUE;
-
+ GtranslatorAsyncCommand *self;
+
+ self = GTR_ASYNC_COMMAND (command);
+
+ if (self->priv->new_data_arrived && g_mutex_trylock (self->priv->mutex))
+ {
+ g_signal_emit_by_name (command, "data-arrived");
+ g_mutex_unlock (self->priv->mutex);
+ self->priv->new_data_arrived = FALSE;
+ }
+
+ if (self->priv->complete)
+ {
+ g_signal_emit_by_name (command, "command-finished",
+ self->priv->return_code);
+ return FALSE;
+ }
+ else
+ return TRUE;
+
}
static gpointer
-gtranslator_async_command_thread (GtranslatorCommand *command)
+gtranslator_async_command_thread (GtranslatorCommand * command)
{
- guint return_code;
-
- return_code = GTR_COMMAND_GET_CLASS (command)->run (command);
- gtranslator_command_notify_complete (command, return_code);
- return NULL;
+ guint return_code;
+
+ return_code = GTR_COMMAND_GET_CLASS (command)->run (command);
+ gtranslator_command_notify_complete (command, return_code);
+ return NULL;
}
static void
-start_command (GtranslatorCommand *command)
+start_command (GtranslatorCommand * command)
{
- g_idle_add ((GSourceFunc) gtranslator_async_command_notification_poll,
- command);
- g_thread_create ((GThreadFunc) gtranslator_async_command_thread,
- command, FALSE, NULL);
+ g_idle_add ((GSourceFunc) gtranslator_async_command_notification_poll,
+ command);
+ g_thread_create ((GThreadFunc) gtranslator_async_command_thread,
+ command, FALSE, NULL);
}
static void
-notify_data_arrived (GtranslatorCommand *command)
+notify_data_arrived (GtranslatorCommand * command)
{
- GtranslatorAsyncCommand *self;
-
- self = GTR_ASYNC_COMMAND (command);
-
- self->priv->new_data_arrived = TRUE;
+ GtranslatorAsyncCommand *self;
+
+ self = GTR_ASYNC_COMMAND (command);
+
+ self->priv->new_data_arrived = TRUE;
}
static void
-notify_complete (GtranslatorCommand *command, guint return_code)
+notify_complete (GtranslatorCommand * command, guint return_code)
{
- GtranslatorAsyncCommand *self;
-
- self = GTR_ASYNC_COMMAND (command);
-
- self->priv->complete = TRUE;
- self->priv->return_code = return_code;
+ GtranslatorAsyncCommand *self;
+
+ self = GTR_ASYNC_COMMAND (command);
+
+ self->priv->complete = TRUE;
+ self->priv->return_code = return_code;
}
static void
-gtranslator_async_command_class_init (GtranslatorAsyncCommandClass *klass)
+gtranslator_async_command_class_init (GtranslatorAsyncCommandClass * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass* parent_class = GTR_COMMAND_CLASS (klass);
-
- object_class->finalize = gtranslator_async_command_finalize;
-
- parent_class->start = start_command;
- parent_class->notify_data_arrived = notify_data_arrived;
- parent_class->notify_complete = notify_complete;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *parent_class = GTR_COMMAND_CLASS (klass);
+
+ object_class->finalize = gtranslator_async_command_finalize;
+
+ parent_class->start = start_command;
+ parent_class->notify_data_arrived = notify_data_arrived;
+ parent_class->notify_complete = notify_complete;
}
void
-gtranslator_async_command_set_error_message (GtranslatorCommand *command,
- gchar *error_message)
+gtranslator_async_command_set_error_message (GtranslatorCommand * command,
+ gchar * error_message)
{
- gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
- GTR_COMMAND_GET_CLASS (command)->set_error_message (command,
- error_message);
- gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
+ gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
+ GTR_COMMAND_GET_CLASS (command)->set_error_message (command, error_message);
+ gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
}
gchar *
-gtranslator_async_command_get_error_message (GtranslatorCommand *command)
+gtranslator_async_command_get_error_message (GtranslatorCommand * command)
{
- gchar *error_message;
-
- gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
- error_message = GTR_COMMAND_GET_CLASS (command)->get_error_message (command);
- gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
-
- return error_message;
+ gchar *error_message;
+
+ gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
+ error_message =
+ GTR_COMMAND_GET_CLASS (command)->get_error_message (command);
+ gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
+
+ return error_message;
}
/**
@@ -187,9 +187,9 @@ gtranslator_async_command_get_error_message (GtranslatorCommand *command)
* Locks the command's built-in mutex.
*/
void
-gtranslator_async_command_lock (GtranslatorAsyncCommand *self)
+gtranslator_async_command_lock (GtranslatorAsyncCommand * self)
{
- g_mutex_lock (self->priv->mutex);
+ g_mutex_lock (self->priv->mutex);
}
/**
@@ -199,7 +199,7 @@ gtranslator_async_command_lock (GtranslatorAsyncCommand *self)
* Unlocks the command's built-in mutex.
*/
void
-gtranslator_async_command_unlock (GtranslatorAsyncCommand *self)
+gtranslator_async_command_unlock (GtranslatorAsyncCommand * self)
{
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (self->priv->mutex);
}
diff --git a/plugins/subversion/async-command.h b/plugins/subversion/async-command.h
index f3fd7a5..24dc2bf 100644
--- a/plugins/subversion/async-command.h
+++ b/plugins/subversion/async-command.h
@@ -32,39 +32,40 @@
#include "command.h"
G_BEGIN_DECLS
-
#define GTR_TYPE_ASYNC_COMMAND (gtranslator_async_command_get_type ())
#define GTR_ASYNC_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_ASYNC_COMMAND, GtranslatorAsyncCommand))
#define GTR_ASYNC_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_ASYNC_COMMAND, GtranslatorAsyncCommandClass))
#define IS_GTR_ASYNC_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_ASYNC_COMMAND))
#define IS_GTR_ASYNC_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_ASYNC_COMMAND))
#define GTR_ASYNC_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_ASYNC_COMMAND, GtranslatorAsyncCommandClass))
-
typedef struct _GtranslatorAsyncCommandClass GtranslatorAsyncCommandClass;
typedef struct _GtranslatorAsyncCommand GtranslatorAsyncCommand;
typedef struct _GtranslatorAsyncCommandPriv GtranslatorAsyncCommandPriv;
struct _GtranslatorAsyncCommandClass
{
- GtranslatorCommandClass parent_class;
+ GtranslatorCommandClass parent_class;
};
struct _GtranslatorAsyncCommand
{
- GtranslatorCommand parent_instance;
-
- GtranslatorAsyncCommandPriv *priv;
+ GtranslatorCommand parent_instance;
+
+ GtranslatorAsyncCommandPriv *priv;
};
-GType gtranslator_async_command_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_async_command_get_type (void)
+ G_GNUC_CONST;
-void gtranslator_async_command_set_error_message (GtranslatorCommand *command,
- gchar *error_message);
-gchar *gtranslator_async_command_get_error_message (GtranslatorCommand *command);
+ void gtranslator_async_command_set_error_message (GtranslatorCommand *
+ command,
+ gchar * error_message);
+ gchar *gtranslator_async_command_get_error_message (GtranslatorCommand *
+ command);
-void gtranslator_async_command_lock (GtranslatorAsyncCommand *self);
-void gtranslator_async_command_unlock (GtranslatorAsyncCommand *self);
+ void gtranslator_async_command_lock (GtranslatorAsyncCommand * self);
+ void gtranslator_async_command_unlock (GtranslatorAsyncCommand * self);
G_END_DECLS
-
#endif /* _GTR_ASYNC_COMMAND_H_ */
diff --git a/plugins/subversion/checkout-dialog.c b/plugins/subversion/checkout-dialog.c
index acf4d84..fe393ae 100644
--- a/plugins/subversion/checkout-dialog.c
+++ b/plugins/subversion/checkout-dialog.c
@@ -41,324 +41,307 @@
GtranslatorCheckoutDialogPrivate))
-G_DEFINE_TYPE(GtranslatorCheckoutDialog, gtranslator_checkout_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GtranslatorCheckoutDialog, gtranslator_checkout_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorCheckoutDialogPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *path_entry;
+ GtkWidget *dir_find_button;
+ GtkWidget *url_entry;
-struct _GtranslatorCheckoutDialogPrivate
-{
- GtkWidget *main_box;
- GtkWidget *path_entry;
- GtkWidget *dir_find_button;
- GtkWidget *url_entry;
-
- GtkListStore *store;
- GtkWidget *checkout_treeview;
-
- GtranslatorWindow *window;
-};
-
-enum
-{
- ICON_COLUMN,
- TEXT_COLUMN,
- N_COLUMNS
-};
+ GtkListStore *store;
+ GtkWidget *checkout_treeview;
-static void
-on_checkout_command_finished (GtranslatorCommand *command,
- guint return_code,
- GtranslatorCheckoutDialog *dlg)
+ GtranslatorWindow *window;
+ };
+
+ enum
+ {
+ ICON_COLUMN,
+ TEXT_COLUMN,
+ N_COLUMNS
+ };
+
+ static void
+ on_checkout_command_finished (GtranslatorCommand * command,
+ guint return_code,
+ GtranslatorCheckoutDialog * dlg)
{
- GtranslatorStatusbar *status;
-
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
-
- gtranslator_statusbar_flash_message (status, 0,
- _("Subversion: Checkout complete."));
-
- subversion_utils_report_errors (dlg->priv->window,
- command, return_code);
-
- svn_checkout_command_destroy (SVN_CHECKOUT_COMMAND (command));
+ GtranslatorStatusbar *status;
+
+ status =
+ GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
+
+ gtranslator_statusbar_flash_message (status, 0,
+ _("Subversion: Checkout complete."));
+
+ subversion_utils_report_errors (dlg->priv->window, command, return_code);
+
+ svn_checkout_command_destroy (SVN_CHECKOUT_COMMAND (command));
}
static void
-on_checkout_command_info_arrived (GtranslatorCommand *command,
- GtranslatorCheckoutDialog *dlg)
+on_checkout_command_info_arrived (GtranslatorCommand * command,
+ GtranslatorCheckoutDialog * dlg)
{
- GQueue *info;
- gchar *message;
- GtkTreeIter iter;
-
- info = svn_command_get_info_queue (SVN_COMMAND (command));
-
- while (g_queue_peek_head (info))
- {
- message = g_queue_pop_head (info);
-
- gtk_list_store_append (dlg->priv->store, &iter);
- gtk_list_store_set (dlg->priv->store, &iter,
- TEXT_COLUMN, message,
- -1);
-
- g_free (message);
- }
+ GQueue *info;
+ gchar *message;
+ GtkTreeIter iter;
+
+ info = svn_command_get_info_queue (SVN_COMMAND (command));
+
+ while (g_queue_peek_head (info))
+ {
+ message = g_queue_pop_head (info);
+
+ gtk_list_store_append (dlg->priv->store, &iter);
+ gtk_list_store_set (dlg->priv->store, &iter, TEXT_COLUMN, message, -1);
+
+ g_free (message);
+ }
}
static void
-dialog_response_handler (GtranslatorCheckoutDialog *dlg,
- gint res_id)
+dialog_response_handler (GtranslatorCheckoutDialog * dlg, gint res_id)
{
- switch (res_id)
- {
- case GTK_RESPONSE_APPLY:
- {
- const gchar *path, *url;
- SvnCheckoutCommand *checkout_command;
-
- path = gtk_entry_get_text (GTK_ENTRY (dlg->priv->path_entry));
- if (strcmp ("", path) == 0)
- {
- GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (dlg->priv->window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("Please add a directory path to make the checkout"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- break;
- }
-
- url = gtk_entry_get_text (GTK_ENTRY (dlg->priv->url_entry));
- if (strcmp ("", url) == 0)
- {
- GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (dlg->priv->window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CLOSE,
- _("Please add a Subversion URL"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- break;
- }
-
- checkout_command = svn_checkout_command_new (url, path);
-
- gtk_list_store_clear (dlg->priv->store);
-
- g_signal_connect (G_OBJECT (checkout_command), "command-finished",
- G_CALLBACK (on_checkout_command_finished),
- dlg);
-
- g_signal_connect (G_OBJECT (checkout_command), "data-arrived",
- G_CALLBACK (on_checkout_command_info_arrived),
- dlg);
-
- gtranslator_command_start (GTR_COMMAND (checkout_command));
-
- break;
- }
- default:
- gtk_widget_hide (GTK_WIDGET (dlg));
- }
+ switch (res_id)
+ {
+ case GTK_RESPONSE_APPLY:
+ {
+ const gchar *path, *url;
+ SvnCheckoutCommand *checkout_command;
+
+ path = gtk_entry_get_text (GTK_ENTRY (dlg->priv->path_entry));
+ if (strcmp ("", path) == 0)
+ {
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW (dlg->priv->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE,
+ _
+ ("Please add a directory path to make the checkout"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ break;
+ }
+
+ url = gtk_entry_get_text (GTK_ENTRY (dlg->priv->url_entry));
+ if (strcmp ("", url) == 0)
+ {
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW (dlg->priv->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CLOSE,
+ _("Please add a Subversion URL"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ break;
+ }
+
+ checkout_command = svn_checkout_command_new (url, path);
+
+ gtk_list_store_clear (dlg->priv->store);
+
+ g_signal_connect (G_OBJECT (checkout_command), "command-finished",
+ G_CALLBACK (on_checkout_command_finished), dlg);
+
+ g_signal_connect (G_OBJECT (checkout_command), "data-arrived",
+ G_CALLBACK (on_checkout_command_info_arrived), dlg);
+
+ gtranslator_command_start (GTR_COMMAND (checkout_command));
+
+ break;
+ }
+ default:
+ gtk_widget_hide (GTK_WIDGET (dlg));
+ }
}
static void
-on_dir_find_button_clicked (GtkButton *button,
- GtranslatorCheckoutDialog *dlg)
+on_dir_find_button_clicked (GtkButton * button,
+ GtranslatorCheckoutDialog * dlg)
{
- GtkWidget *dialog;
- gint res;
-
- dialog = gtk_file_chooser_dialog_new (_("Checkout directory"),
- GTK_WINDOW (dlg->priv->window),
- GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (res)
- {
- case GTK_RESPONSE_OK:
- {
- gchar *filename;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->path_entry),
- filename);
- g_free (filename);
- break;
- }
- default:
- break;
- }
- gtk_widget_destroy (dialog);
+ GtkWidget *dialog;
+ gint res;
+
+ dialog = gtk_file_chooser_dialog_new (_("Checkout directory"),
+ GTK_WINDOW (dlg->priv->window),
+ GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ switch (res)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ gchar *filename;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->path_entry), filename);
+ g_free (filename);
+ break;
+ }
+ default:
+ break;
+ }
+ gtk_widget_destroy (dialog);
}
static void
-setup_treeview (GtranslatorCheckoutDialog *dlg)
+setup_treeview (GtranslatorCheckoutDialog * dlg)
{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- dlg->priv->store = gtk_list_store_new (N_COLUMNS,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->checkout_treeview),
- GTK_TREE_MODEL (dlg->priv->store));
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dlg->priv->checkout_treeview),
- FALSE);
-
- column = gtk_tree_view_column_new ();
- /*
- * Icon column
- */
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (renderer,
- "stock-id", GTK_STOCK_INFO,
- "stock-size", GTK_ICON_SIZE_MENU,
- "xalign", 1.0,
- "xpad", 6,
- NULL);
-
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
-
- /*
- * Text column
- */
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "text", TEXT_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->checkout_treeview),
- column);
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ dlg->priv->store = gtk_list_store_new (N_COLUMNS,
+ GDK_TYPE_PIXBUF, G_TYPE_STRING);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->checkout_treeview),
+ GTK_TREE_MODEL (dlg->priv->store));
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW
+ (dlg->priv->checkout_treeview), FALSE);
+
+ column = gtk_tree_view_column_new ();
+ /*
+ * Icon column
+ */
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (renderer,
+ "stock-id", GTK_STOCK_INFO,
+ "stock-size", GTK_ICON_SIZE_MENU,
+ "xalign", 1.0, "xpad", 6, NULL);
+
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+
+ /*
+ * Text column
+ */
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer, "text", TEXT_COLUMN, NULL);
+
+ gtk_tree_view_column_set_resizable (column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->checkout_treeview),
+ column);
}
static void
-gtranslator_checkout_dialog_init (GtranslatorCheckoutDialog *dlg)
+gtranslator_checkout_dialog_init (GtranslatorCheckoutDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "checkout_main_box",
- NULL
- };
-
- dlg->priv = GTR_CHECKOUT_DIALOG_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_REFRESH,
- GTK_RESPONSE_APPLY,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Checkout repository"));
- gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 600);
- gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Glade*/
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
-
- "checkout_main_box", &dlg->priv->main_box,
- "path_entry", &dlg->priv->path_entry,
- "dir_find_button", &dlg->priv->dir_find_button,
- "url_entry", &dlg->priv->url_entry,
- "checkout_treeview", &dlg->priv->checkout_treeview,
-
- NULL);
-
- if(!ret)
- {
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- setup_treeview (dlg);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
- g_signal_connect (dlg->priv->dir_find_button, "clicked",
- G_CALLBACK (on_dir_find_button_clicked), dlg);
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "checkout_main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_CHECKOUT_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_REFRESH,
+ GTK_RESPONSE_APPLY,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Checkout repository"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 600);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "checkout_main_box",
+ &dlg->priv->main_box, "path_entry",
+ &dlg->priv->path_entry,
+ "dir_find_button",
+ &dlg->priv->dir_find_button,
+ "url_entry", &dlg->priv->url_entry,
+ "checkout_treeview",
+ &dlg->priv->checkout_treeview,
+ NULL);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ setup_treeview (dlg);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
+ g_signal_connect (dlg->priv->dir_find_button, "clicked",
+ G_CALLBACK (on_dir_find_button_clicked), dlg);
}
static void
-gtranslator_checkout_dialog_finalize (GObject *object)
+gtranslator_checkout_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_checkout_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_checkout_dialog_parent_class)->
+ finalize (object);
}
static void
-gtranslator_checkout_dialog_class_init (GtranslatorCheckoutDialogClass *klass)
+gtranslator_checkout_dialog_class_init (GtranslatorCheckoutDialogClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorCheckoutDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorCheckoutDialogPrivate));
- object_class->finalize = gtranslator_checkout_dialog_finalize;
+ object_class->finalize = gtranslator_checkout_dialog_finalize;
}
void
-gtranslator_show_checkout_dialog (GtranslatorWindow *window)
+gtranslator_show_checkout_dialog (GtranslatorWindow * window)
{
- static GtranslatorCheckoutDialog *dlg = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- if(dlg == NULL)
- {
- dlg = g_object_new (GTR_TYPE_CHECKOUT_DIALOG, NULL);
-
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg),
- TRUE);
-
- dlg->priv->window = window;
-
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
-
- gtk_widget_show (GTK_WIDGET (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_present (GTK_WINDOW (dlg));
+ static GtranslatorCheckoutDialog *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_CHECKOUT_DIALOG, NULL);
+
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ dlg->priv->window = window;
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+
+ gtk_widget_show (GTK_WIDGET (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_present (GTK_WINDOW (dlg));
}
diff --git a/plugins/subversion/checkout-dialog.h b/plugins/subversion/checkout-dialog.h
index 1e8c4e3..3f36f77 100644
--- a/plugins/subversion/checkout-dialog.h
+++ b/plugins/subversion/checkout-dialog.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,42 +34,43 @@ G_BEGIN_DECLS
#define GTR_IS_CHECKOUT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHECKOUT_DIALOG))
#define GTR_IS_CHECKOUT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHECKOUT_DIALOG))
#define GTR_CHECKOUT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHECKOUT_DIALOG, GtranslatorCheckoutDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorCheckoutDialogPrivate GtranslatorCheckoutDialogPrivate;
+typedef struct _GtranslatorCheckoutDialogPrivate
+ GtranslatorCheckoutDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorCheckoutDialog GtranslatorCheckoutDialog;
+typedef struct _GtranslatorCheckoutDialog GtranslatorCheckoutDialog;
struct _GtranslatorCheckoutDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorCheckoutDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorCheckoutDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorCheckoutDialogClass GtranslatorCheckoutDialogClass;
+typedef struct _GtranslatorCheckoutDialogClass GtranslatorCheckoutDialogClass;
struct _GtranslatorCheckoutDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_checkout_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_checkout_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_checkout_dialog_register_type (GTypeModule * module);
+ GType gtranslator_checkout_dialog_register_type (GTypeModule * module);
-void gtranslator_show_checkout_dialog (GtranslatorWindow *window);
+ void gtranslator_show_checkout_dialog (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __CHECKOUT_DIALOG_H__ */
diff --git a/plugins/subversion/command.c b/plugins/subversion/command.c
index 8a115b1..d1c53a2 100644
--- a/plugins/subversion/command.c
+++ b/plugins/subversion/command.c
@@ -51,15 +51,15 @@
struct _GtranslatorCommandPriv
{
- gchar *error_message;
+ gchar *error_message;
};
enum
{
- DATA_ARRIVED,
- COMMAND_FINISHED,
+ DATA_ARRIVED,
+ COMMAND_FINISHED,
- LAST_SIGNAL
+ LAST_SIGNAL
};
@@ -68,37 +68,37 @@ static guint gtranslator_command_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GtranslatorCommand, gtranslator_command, G_TYPE_OBJECT);
static void
-gtranslator_command_init (GtranslatorCommand *self)
+gtranslator_command_init (GtranslatorCommand * self)
{
- self->priv = g_new0 (GtranslatorCommandPriv, 1);
+ self->priv = g_new0 (GtranslatorCommandPriv, 1);
}
static void
-gtranslator_command_finalize (GObject *object)
+gtranslator_command_finalize (GObject * object)
{
- GtranslatorCommand *self;
-
- self = GTR_COMMAND (object);
-
- g_free (self->priv->error_message);
- g_free (self->priv);
-
- G_OBJECT_CLASS (gtranslator_command_parent_class)->finalize (object);
+ GtranslatorCommand *self;
+
+ self = GTR_COMMAND (object);
+
+ g_free (self->priv->error_message);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (gtranslator_command_parent_class)->finalize (object);
}
static void
-gtranslator_command_class_init (GtranslatorCommandClass *klass)
+gtranslator_command_class_init (GtranslatorCommandClass * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gtranslator_command_finalize;
-
- klass->run = NULL;
- klass->start = NULL;
- klass->notify_data_arrived = NULL;
- klass->notify_complete = NULL;
- klass->set_error_message = gtranslator_command_set_error_message;
- klass->get_error_message = gtranslator_command_get_error_message;
+ object_class->finalize = gtranslator_command_finalize;
+
+ klass->run = NULL;
+ klass->start = NULL;
+ klass->notify_data_arrived = NULL;
+ klass->notify_complete = NULL;
+ klass->set_error_message = gtranslator_command_set_error_message;
+ klass->get_error_message = gtranslator_command_get_error_message;
/**
* GtranslatorCommand::data-arrived:
@@ -107,15 +107,12 @@ gtranslator_command_class_init (GtranslatorCommandClass *klass)
* Notifies clients that the command has processed data that is ready to
* be used.
*/
- gtranslator_command_signals[DATA_ARRIVED] =
- g_signal_new ("data-arrived",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ gtranslator_command_signals[DATA_ARRIVED] =
+ g_signal_new ("data-arrived",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GtranslatorCommand::command-finished:
@@ -125,15 +122,13 @@ gtranslator_command_class_init (GtranslatorCommandClass *klass)
* Indicates that the command has completed. Clients should at least handle
* this signal to unref the command object.
*/
- gtranslator_command_signals[COMMAND_FINISHED] =
- g_signal_new ("command-finished",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__UINT ,
- G_TYPE_NONE, 1,
- G_TYPE_UINT);
+ gtranslator_command_signals[COMMAND_FINISHED] =
+ g_signal_new ("command-finished",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
}
/**
@@ -147,9 +142,9 @@ gtranslator_command_class_init (GtranslatorCommandClass *klass)
* call ::run, which actually does the command's legwork.
*/
void
-gtranslator_command_start (GtranslatorCommand *self)
+gtranslator_command_start (GtranslatorCommand * self)
{
- GTR_COMMAND_GET_CLASS (self)->start (self);
+ GTR_COMMAND_GET_CLASS (self)->start (self);
}
@@ -162,9 +157,9 @@ gtranslator_command_start (GtranslatorCommand *self)
* objects that are not base classes.
*/
void
-gtranslator_command_notify_data_arrived (GtranslatorCommand *self)
+gtranslator_command_notify_data_arrived (GtranslatorCommand * self)
{
- GTR_COMMAND_GET_CLASS (self)->notify_data_arrived (self);
+ GTR_COMMAND_GET_CLASS (self)->notify_data_arrived (self);
}
/**
@@ -176,9 +171,10 @@ gtranslator_command_notify_data_arrived (GtranslatorCommand *self)
* #GtranslatorCommand objects that are not base classes.
*/
void
-gtranslator_command_notify_complete (GtranslatorCommand *self, guint return_code)
+gtranslator_command_notify_complete (GtranslatorCommand * self,
+ guint return_code)
{
- GTR_COMMAND_GET_CLASS (self)->notify_complete (self, return_code);
+ GTR_COMMAND_GET_CLASS (self)->notify_complete (self, return_code);
}
/**
@@ -190,12 +186,13 @@ gtranslator_command_notify_complete (GtranslatorCommand *self, guint return_code
* of failure.
*/
void
-gtranslator_command_set_error_message (GtranslatorCommand *self, gchar *error_message)
+gtranslator_command_set_error_message (GtranslatorCommand * self,
+ gchar * error_message)
{
- if (self->priv->error_message)
- g_free (error_message);
-
- self->priv->error_message = g_strdup (error_message);
+ if (self->priv->error_message)
+ g_free (error_message);
+
+ self->priv->error_message = g_strdup (error_message);
}
/**
@@ -211,7 +208,7 @@ gtranslator_command_set_error_message (GtranslatorCommand *self, gchar *error_me
* If no error is set, return %NULL.
*/
gchar *
-gtranslator_command_get_error_message (GtranslatorCommand *self)
+gtranslator_command_get_error_message (GtranslatorCommand * self)
{
- return g_strdup (self->priv->error_message);
+ return g_strdup (self->priv->error_message);
}
diff --git a/plugins/subversion/command.h b/plugins/subversion/command.h
index 2ad2755..9ad5898 100644
--- a/plugins/subversion/command.h
+++ b/plugins/subversion/command.h
@@ -28,48 +28,50 @@
#include <glib-object.h>
G_BEGIN_DECLS
-
#define GTR_TYPE_COMMAND (gtranslator_command_get_type ())
#define GTR_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_COMMAND, GtranslatorCommand))
#define GTR_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_COMMAND, GtranslatorCommandClass))
#define GTR_IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_COMMAND))
#define GTR_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_COMMAND))
#define GTR_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_COMMAND, GtranslatorCommandClass))
-
typedef struct _GtranslatorCommandClass GtranslatorCommandClass;
typedef struct _GtranslatorCommand GtranslatorCommand;
typedef struct _GtranslatorCommandPriv GtranslatorCommandPriv;
struct _GtranslatorCommandClass
{
- GObjectClass parent_class;
-
- /* Virtual Methods */
- guint (*run) (GtranslatorCommand *self);
- void (*start) (GtranslatorCommand *self);
- void (*notify_data_arrived) (GtranslatorCommand *self);
- void (*notify_complete) (GtranslatorCommand *self, guint return_code);
- void (*set_error_message) (GtranslatorCommand *self, gchar *error_message);
- gchar * (*get_error_message) (GtranslatorCommand *self);
+ GObjectClass parent_class;
+
+ /* Virtual Methods */
+ guint (*run) (GtranslatorCommand * self);
+ void (*start) (GtranslatorCommand * self);
+ void (*notify_data_arrived) (GtranslatorCommand * self);
+ void (*notify_complete) (GtranslatorCommand * self, guint return_code);
+ void (*set_error_message) (GtranslatorCommand * self,
+ gchar * error_message);
+ gchar *(*get_error_message) (GtranslatorCommand * self);
};
struct _GtranslatorCommand
{
- GObject parent_instance;
-
- GtranslatorCommandPriv *priv;
+ GObject parent_instance;
+
+ GtranslatorCommandPriv *priv;
};
-GType gtranslator_command_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_command_get_type (void)
+ G_GNUC_CONST;
-void gtranslator_command_start (GtranslatorCommand *self);
-void gtranslator_command_notify_data_arrived (GtranslatorCommand *self);
-void gtranslator_command_notify_complete (GtranslatorCommand *self, guint return_code);
+ void gtranslator_command_start (GtranslatorCommand * self);
+ void gtranslator_command_notify_data_arrived (GtranslatorCommand * self);
+ void gtranslator_command_notify_complete (GtranslatorCommand * self,
+ guint return_code);
-void gtranslator_command_set_error_message (GtranslatorCommand *self, gchar *error_message);
-gchar *gtranslator_command_get_error_message (GtranslatorCommand *self);
+ void gtranslator_command_set_error_message (GtranslatorCommand * self,
+ gchar * error_message);
+ gchar *gtranslator_command_get_error_message (GtranslatorCommand * self);
G_END_DECLS
-
#endif /* _GTR_COMMAND_H_ */
diff --git a/plugins/subversion/commit-dialog.c b/plugins/subversion/commit-dialog.c
index 95f796a..c6983b6 100644
--- a/plugins/subversion/commit-dialog.c
+++ b/plugins/subversion/commit-dialog.c
@@ -49,94 +49,92 @@
#define ADD_CHANGE_LOG_KEY SUBVERSION_BASE_KEY "/add_change_log"
-G_DEFINE_TYPE(GtranslatorCommitDialog, gtranslator_commit_dialog, GTK_TYPE_DIALOG)
-
-struct _GtranslatorCommitDialogPrivate
-{
- GConfClient *gconf_client;
-
- GtkWidget *main_box;
- GtkWidget *changelog_view;
- GtkWidget *status_view;
- GtkWidget *select_all_button;
- GtkWidget *clear_button;
- GtkWidget *status_progress_bar;
- GtkWidget *add_log_checkbutton;
-
- GtranslatorWindow *window;
- gchar *dirname;
-};
-
-static void send_status_command (GtranslatorCommitDialog *dlg,
- GtranslatorWindow *window);
-
-static void
-select_all_status_items (GtkButton *select_all_button,
- GtranslatorVcsStatusTreeView *tree_view)
+G_DEFINE_TYPE (GtranslatorCommitDialog, gtranslator_commit_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorCommitDialogPrivate
+ {
+ GConfClient *gconf_client;
+
+ GtkWidget *main_box;
+ GtkWidget *changelog_view;
+ GtkWidget *status_view;
+ GtkWidget *select_all_button;
+ GtkWidget *clear_button;
+ GtkWidget *status_progress_bar;
+ GtkWidget *add_log_checkbutton;
+
+ GtranslatorWindow *window;
+ gchar *dirname;
+ };
+
+ static void send_status_command (GtranslatorCommitDialog * dlg,
+ GtranslatorWindow * window);
+
+ static void
+ select_all_status_items (GtkButton * select_all_button,
+ GtranslatorVcsStatusTreeView * tree_view)
{
- gtranslator_vcs_status_tree_view_select_all (tree_view);
+ gtranslator_vcs_status_tree_view_select_all (tree_view);
}
static void
-clear_all_status_selections (GtkButton *clear_button,
- GtranslatorVcsStatusTreeView *tree_view)
+clear_all_status_selections (GtkButton * clear_button,
+ GtranslatorVcsStatusTreeView * tree_view)
{
- gtranslator_vcs_status_tree_view_unselect_all (tree_view);
+ gtranslator_vcs_status_tree_view_unselect_all (tree_view);
}
static gboolean
-pulse_timer (GtkProgressBar *progress_bar)
+pulse_timer (GtkProgressBar * progress_bar)
{
- gtk_progress_bar_pulse (progress_bar);
- return TRUE;
+ gtk_progress_bar_pulse (progress_bar);
+ return TRUE;
}
static void
-stop_pulse_timer (gpointer timer_id, GtkProgressBar *progress_bar)
+stop_pulse_timer (gpointer timer_id, GtkProgressBar * progress_bar)
{
- g_source_remove (GPOINTER_TO_UINT (timer_id));
+ g_source_remove (GPOINTER_TO_UINT (timer_id));
}
static void
-pulse_progress_bar (GtkProgressBar *progress_bar)
+pulse_progress_bar (GtkProgressBar * progress_bar)
{
- guint timer_id;
-
- timer_id = g_timeout_add (100, (GSourceFunc) pulse_timer,
- progress_bar);
- g_object_set_data (G_OBJECT (progress_bar), "pulse-timer-id",
- GUINT_TO_POINTER (timer_id));
-
- g_object_weak_ref (G_OBJECT (progress_bar),
- (GWeakNotify) stop_pulse_timer,
- GUINT_TO_POINTER (timer_id));
+ guint timer_id;
+
+ timer_id = g_timeout_add (100, (GSourceFunc) pulse_timer, progress_bar);
+ g_object_set_data (G_OBJECT (progress_bar), "pulse-timer-id",
+ GUINT_TO_POINTER (timer_id));
+
+ g_object_weak_ref (G_OBJECT (progress_bar),
+ (GWeakNotify) stop_pulse_timer,
+ GUINT_TO_POINTER (timer_id));
}
static void
-hide_pulse_progress_bar (GtranslatorCommand *command,
- guint return_code,
- GtkProgressBar *progress_bar)
+hide_pulse_progress_bar (GtranslatorCommand * command,
+ guint return_code, GtkProgressBar * progress_bar)
{
- guint timer_id;
-
- /* If the progress bar has already been destroyed, the timer should be
- * stopped by stop_pulse_timer */
- if (GTK_IS_PROGRESS_BAR (progress_bar))
- {
- timer_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (progress_bar),
- "pulse-timer-id"));
-
- g_source_remove (GPOINTER_TO_UINT (timer_id));
- gtk_widget_hide (GTK_WIDGET (progress_bar));
- }
+ guint timer_id;
+
+ /* If the progress bar has already been destroyed, the timer should be
+ * stopped by stop_pulse_timer */
+ if (GTK_IS_PROGRESS_BAR (progress_bar))
+ {
+ timer_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (progress_bar),
+ "pulse-timer-id"));
+
+ g_source_remove (GPOINTER_TO_UINT (timer_id));
+ gtk_widget_hide (GTK_WIDGET (progress_bar));
+ }
}
static void
-select_all_files (GtranslatorCommand *command,
- guint return_code,
- GtranslatorVcsStatusTreeView *status_view)
+select_all_files (GtranslatorCommand * command,
+ guint return_code,
+ GtranslatorVcsStatusTreeView * status_view)
{
- gtranslator_vcs_status_tree_view_select_all (status_view);
+ gtranslator_vcs_status_tree_view_select_all (status_view);
}
/* This function is normally intended to disconnect stock data-arrived signal
@@ -146,572 +144,556 @@ select_all_files (GtranslatorCommand *command,
* by connecting cancel_data_arrived_signal_disconnect to the command-finished
* signal so we don't try to disconnect signals on a destroyed command. */
static void
-disconnect_data_arrived_signals (GtranslatorCommand *command,
- GObject *object)
+disconnect_data_arrived_signals (GtranslatorCommand * command,
+ GObject * object)
{
- guint data_arrived_signal;
-
- if (GTR_IS_COMMAND (command))
- {
- data_arrived_signal = g_signal_lookup ("data-arrived",
- GTR_TYPE_COMMAND);
-
- g_signal_handlers_disconnect_matched (command,
- G_SIGNAL_MATCH_DATA,
- data_arrived_signal,
- 0,
- NULL,
- NULL,
- object);
- }
-
+ guint data_arrived_signal;
+
+ if (GTR_IS_COMMAND (command))
+ {
+ data_arrived_signal = g_signal_lookup ("data-arrived",
+ GTR_TYPE_COMMAND);
+
+ g_signal_handlers_disconnect_matched (command,
+ G_SIGNAL_MATCH_DATA,
+ data_arrived_signal,
+ 0, NULL, NULL, object);
+ }
+
}
-static void
-cancel_data_arrived_signal_disconnect (GtranslatorCommand *command,
+static void
+cancel_data_arrived_signal_disconnect (GtranslatorCommand * command,
guint return_code,
- GObject *signal_target)
+ GObject * signal_target)
{
- g_object_weak_unref (signal_target,
- (GWeakNotify) disconnect_data_arrived_signals,
- command);
+ g_object_weak_unref (signal_target,
+ (GWeakNotify) disconnect_data_arrived_signals,
+ command);
}
static void
-on_status_command_finished (GtranslatorCommand *command,
- guint return_code,
- GtranslatorWindow *window)
+on_status_command_finished (GtranslatorCommand * command,
+ guint return_code, GtranslatorWindow * window)
{
- subversion_utils_report_errors (window, command, return_code);
-
- svn_status_command_destroy (SVN_STATUS_COMMAND (command));
+ subversion_utils_report_errors (window, command, return_code);
+
+ svn_status_command_destroy (SVN_STATUS_COMMAND (command));
}
static void
-on_status_command_data_arrived (GtranslatorCommand *command,
- GtranslatorVcsStatusTreeView *tree_view)
+on_status_command_data_arrived (GtranslatorCommand * command,
+ GtranslatorVcsStatusTreeView * tree_view)
{
- GQueue *status_queue;
- SvnStatus *status;
- gchar *path;
-
- status_queue = svn_status_command_get_status_queue (SVN_STATUS_COMMAND (command));
-
- while (g_queue_peek_head (status_queue))
- {
- status = g_queue_pop_head (status_queue);
- path = svn_status_get_path (status);
-
- gtranslator_vcs_status_tree_view_add (tree_view, path,
- svn_status_get_vcs_status (status),
- FALSE);
-
- svn_status_destroy (status);
- g_free (path);
- }
+ GQueue *status_queue;
+ SvnStatus *status;
+ gchar *path;
+
+ status_queue =
+ svn_status_command_get_status_queue (SVN_STATUS_COMMAND (command));
+
+ while (g_queue_peek_head (status_queue))
+ {
+ status = g_queue_pop_head (status_queue);
+ path = svn_status_get_path (status);
+
+ gtranslator_vcs_status_tree_view_add (tree_view, path,
+ svn_status_get_vcs_status
+ (status), FALSE);
+
+ svn_status_destroy (status);
+ g_free (path);
+ }
}
static void
-on_commit_command_finished (GtranslatorCommand *command,
- guint return_code,
- GtranslatorCommitDialog *dlg)
+on_commit_command_finished (GtranslatorCommand * command,
+ guint return_code, GtranslatorCommitDialog * dlg)
{
- GtranslatorStatusbar *status;
-
- g_return_if_fail (GTR_IS_WINDOW (dlg->priv->window));
-
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
-
- gtranslator_statusbar_flash_message (status, 0,
- _("Subversion: Commit complete."));
-
- subversion_utils_report_errors (dlg->priv->window,
- command, return_code);
-
- svn_commit_command_destroy (SVN_COMMIT_COMMAND (command));
+ GtranslatorStatusbar *status;
+
+ g_return_if_fail (GTR_IS_WINDOW (dlg->priv->window));
+
+ status =
+ GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
+
+ gtranslator_statusbar_flash_message (status, 0,
+ _("Subversion: Commit complete."));
+
+ subversion_utils_report_errors (dlg->priv->window, command, return_code);
+
+ svn_commit_command_destroy (SVN_COMMIT_COMMAND (command));
}
static void
-on_command_info_arrived (GtranslatorCommand *command,
- GtranslatorWindow *window)
+on_command_info_arrived (GtranslatorCommand * command,
+ GtranslatorWindow * window)
{
- GQueue *info;
- gchar *message;
- GtranslatorStatusbar *status;
-
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- info = svn_command_get_info_queue (SVN_COMMAND (command));
-
- while (g_queue_peek_head (info))
- {
- message = g_queue_pop_head (info);
- gtranslator_statusbar_flash_message (status, 0,
- "%s", message);
- g_free (message);
- }
+ GQueue *info;
+ gchar *message;
+ GtranslatorStatusbar *status;
+
+ status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ info = svn_command_get_info_queue (SVN_COMMAND (command));
+
+ while (g_queue_peek_head (info))
+ {
+ message = g_queue_pop_head (info);
+ gtranslator_statusbar_flash_message (status, 0, "%s", message);
+ g_free (message);
+ }
}
static void
-add_changelog_to_text_view (GtkWidget *textview)
+add_changelog_to_text_view (GtkWidget * textview)
{
- gchar *log;
- GtkTextBuffer *buf;
-
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
-
- log = g_strdup_printf ("Updated %s translation",
- /*
- * Translators: Please change LANGUAGE for your language name in English.
- * This string is used to fill the ChangeLog entry
- * For example: "Updated Galician translation"
- * where LANGUAGE = Galician.
- */
- C_("ChangeLog entry", "LANGUAGE"));
-
- gtk_text_buffer_set_text (buf, log, -1);
- g_free (log);
+ gchar *log;
+ GtkTextBuffer *buf;
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
+
+ log = g_strdup_printf ("Updated %s translation",
+ /*
+ * Translators: Please change LANGUAGE for your language name in English.
+ * This string is used to fill the ChangeLog entry
+ * For example: "Updated Galician translation"
+ * where LANGUAGE = Galician.
+ */
+ C_ ("ChangeLog entry", "LANGUAGE"));
+
+ gtk_text_buffer_set_text (buf, log, -1);
+ g_free (log);
}
static void
-add_changelog_entry (GtranslatorCommitDialog *dlg)
+add_changelog_entry (GtranslatorCommitDialog * dlg)
{
- guint tmpfd;
- GError *error = NULL;
- gchar *tmp_fname;
- GFile *tmp_file;
- gchar *changelog;
- GFile *changelog_file;
- GFileInputStream *istream;
- GFileOutputStream *ostream;
- gchar *changelog_entry;
-
- changelog = g_build_filename (dlg->priv->dirname,
- "ChangeLog",
- NULL);
-
- changelog_file = g_file_new_for_path (changelog);
- if (!g_file_query_exists (changelog_file, NULL))
- {
- g_warning (_("The ChangeLog file '%s' does not exist"),
- changelog);
- g_free (changelog);
- g_object_unref (changelog_file);
- return;
- }
- g_free (changelog);
-
- tmpfd = g_file_open_tmp (".gtranslator-changelog-XXXXXX",
- &tmp_fname,
- &error);
-
- if (tmpfd == -1)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- g_object_unref (changelog_file);
-
- /* In this case we don't have to close the file */
- return;
- }
-
- tmp_file = g_file_new_for_path (tmp_fname);
-
- istream = g_file_read (changelog_file, NULL, &error);
- if (error)
- goto free;
-
- ostream = g_file_append_to (tmp_file, G_FILE_CREATE_NONE,
- NULL, &error);
- if (error)
- goto free;
-
- /*
- * We move the current ChangeLog file to the temp file
- */
- subversion_utils_from_file_to_file (G_INPUT_STREAM (istream),
- G_OUTPUT_STREAM (ostream));
-
- /*
- * Then we remove the old changelog_file
- */
- g_file_delete (changelog_file, NULL, &error);
- if (error)
- goto free;
-
- /*
- * We create the new one
- */
- ostream = g_file_create (changelog_file, G_FILE_CREATE_NONE,
- NULL, &error);
- if (error)
- goto free;
-
- /*
- * Now, adding the new changelog entry
- */
- changelog_entry = subversion_utils_get_changelog_entry_from_view (dlg->priv->changelog_view);
-
- g_output_stream_write (G_OUTPUT_STREAM (ostream), changelog_entry,
- g_utf8_strlen (changelog_entry, -1),
- NULL, &error);
- if (error)
- goto free;
-
- istream = g_file_read (tmp_file, NULL, &error);
- if (error)
- goto free;
-
- /* Now, appending from tempfile to ChangeLog file */
- subversion_utils_from_file_to_file (G_INPUT_STREAM (istream),
- G_OUTPUT_STREAM (ostream));
-
- /*
- * Updating the dialog
- */
- gtranslator_vsc_status_tree_view_clear (GTR_VCS_STATUS_TREE_VIEW (dlg->priv->status_view));
- send_status_command (dlg, dlg->priv->window);
-
-free: if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- g_object_unref (tmp_file);
- close (tmpfd);
- g_free (tmp_fname);
- g_object_unref (changelog_file);
+ guint tmpfd;
+ GError *error = NULL;
+ gchar *tmp_fname;
+ GFile *tmp_file;
+ gchar *changelog;
+ GFile *changelog_file;
+ GFileInputStream *istream;
+ GFileOutputStream *ostream;
+ gchar *changelog_entry;
+
+ changelog = g_build_filename (dlg->priv->dirname, "ChangeLog", NULL);
+
+ changelog_file = g_file_new_for_path (changelog);
+ if (!g_file_query_exists (changelog_file, NULL))
+ {
+ g_warning (_("The ChangeLog file '%s' does not exist"), changelog);
+ g_free (changelog);
+ g_object_unref (changelog_file);
+ return;
+ }
+ g_free (changelog);
+
+ tmpfd = g_file_open_tmp (".gtranslator-changelog-XXXXXX",
+ &tmp_fname, &error);
+
+ if (tmpfd == -1)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_object_unref (changelog_file);
+
+ /* In this case we don't have to close the file */
+ return;
+ }
+
+ tmp_file = g_file_new_for_path (tmp_fname);
+
+ istream = g_file_read (changelog_file, NULL, &error);
+ if (error)
+ goto free;
+
+ ostream = g_file_append_to (tmp_file, G_FILE_CREATE_NONE, NULL, &error);
+ if (error)
+ goto free;
+
+ /*
+ * We move the current ChangeLog file to the temp file
+ */
+ subversion_utils_from_file_to_file (G_INPUT_STREAM (istream),
+ G_OUTPUT_STREAM (ostream));
+
+ /*
+ * Then we remove the old changelog_file
+ */
+ g_file_delete (changelog_file, NULL, &error);
+ if (error)
+ goto free;
+
+ /*
+ * We create the new one
+ */
+ ostream = g_file_create (changelog_file, G_FILE_CREATE_NONE, NULL, &error);
+ if (error)
+ goto free;
+
+ /*
+ * Now, adding the new changelog entry
+ */
+ changelog_entry =
+ subversion_utils_get_changelog_entry_from_view (dlg->priv->
+ changelog_view);
+
+ g_output_stream_write (G_OUTPUT_STREAM (ostream), changelog_entry,
+ g_utf8_strlen (changelog_entry, -1), NULL, &error);
+ if (error)
+ goto free;
+
+ istream = g_file_read (tmp_file, NULL, &error);
+ if (error)
+ goto free;
+
+ /* Now, appending from tempfile to ChangeLog file */
+ subversion_utils_from_file_to_file (G_INPUT_STREAM (istream),
+ G_OUTPUT_STREAM (ostream));
+
+ /*
+ * Updating the dialog
+ */
+ gtranslator_vsc_status_tree_view_clear (GTR_VCS_STATUS_TREE_VIEW
+ (dlg->priv->status_view));
+ send_status_command (dlg, dlg->priv->window);
+
+free:if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ g_object_unref (tmp_file);
+ close (tmpfd);
+ g_free (tmp_fname);
+ g_object_unref (changelog_file);
}
static void
-dialog_response_handler (GtkDialog *dlg,
- gint res_id)
+dialog_response_handler (GtkDialog * dlg, gint res_id)
{
- GtranslatorCommitDialog *commit = GTR_COMMIT_DIALOG (dlg);
-
- switch (res_id)
- {
- case GTK_RESPONSE_OK:
- {
- gchar* log = NULL;
- GList *selected_paths;
- SvnCommitCommand *commit_command;
- //guint pulse_timer_id;
-
- log = subversion_utils_get_log_from_textview (commit->priv->changelog_view);
- if (!g_utf8_strlen (log, -1))
- {
- gint result;
- GtkWidget* dialog = gtk_message_dialog_new (GTK_WINDOW (commit->priv->window),
- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO,
- GTK_BUTTONS_YES_NO,
- _("Are you sure that you want to pass an empty log message?"));
- result = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- if (result == GTK_RESPONSE_NO)
- {
- g_free (log);
- break;
- }
- }
-
- selected_paths = gtranslator_vcs_status_tree_view_get_selected (GTR_VCS_STATUS_TREE_VIEW (commit->priv->status_view));
-
- if (selected_paths == NULL)
- {
- GtkWidget* dialog = gtk_message_dialog_new (GTK_WINDOW (commit->priv->window),
- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- _("You have to select at least one file to send"));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_free (log);
- break;
- }
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (commit->priv->add_log_checkbutton)))
- {
- gchar *changelog_path;
-
- add_changelog_entry (commit);
-
- changelog_path = g_build_filename (commit->priv->dirname,
- "ChangeLog",
- NULL);
- selected_paths = g_list_append (selected_paths,
- changelog_path);
- }
-
- commit_command = svn_commit_command_new (selected_paths,
- log,
- FALSE);
- g_free (log);
-
- svn_command_free_path_list (selected_paths);
-
- /*pulse_timer_id = status_bar_progress_pulse (data->plugin,
- _("Subversion: "
- "Committing changes "
- "to the "
- "repository..."));
-
- g_signal_connect (G_OBJECT (commit_command), "command-finished",
- G_CALLBACK (stop_status_bar_progress_pulse),
- GUINT_TO_POINTER (pulse_timer_id));*/
-
- g_signal_connect (G_OBJECT (commit_command), "command-finished",
- G_CALLBACK (on_commit_command_finished),
- commit);
-
- g_signal_connect (G_OBJECT (commit_command), "data-arrived",
- G_CALLBACK (on_command_info_arrived),
- commit->priv->window);
-
- gtranslator_command_start (GTR_COMMAND (commit_command));
-
- gtk_widget_hide (GTK_WIDGET (dlg));
- break;
- }
- default:
- gtk_widget_destroy (GTK_WIDGET (dlg));
- }
+ GtranslatorCommitDialog *commit = GTR_COMMIT_DIALOG (dlg);
+
+ switch (res_id)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ gchar *log = NULL;
+ GList *selected_paths;
+ SvnCommitCommand *commit_command;
+ //guint pulse_timer_id;
+
+ log =
+ subversion_utils_get_log_from_textview (commit->priv->
+ changelog_view);
+ if (!g_utf8_strlen (log, -1))
+ {
+ gint result;
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW (commit->priv->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_YES_NO,
+ _
+ ("Are you sure that you want to pass an empty log message?"));
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ if (result == GTK_RESPONSE_NO)
+ {
+ g_free (log);
+ break;
+ }
+ }
+
+ selected_paths =
+ gtranslator_vcs_status_tree_view_get_selected
+ (GTR_VCS_STATUS_TREE_VIEW (commit->priv->status_view));
+
+ if (selected_paths == NULL)
+ {
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW (commit->priv->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ _
+ ("You have to select at least one file to send"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (log);
+ break;
+ }
+
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (commit->priv->add_log_checkbutton)))
+ {
+ gchar *changelog_path;
+
+ add_changelog_entry (commit);
+
+ changelog_path = g_build_filename (commit->priv->dirname,
+ "ChangeLog", NULL);
+ selected_paths = g_list_append (selected_paths, changelog_path);
+ }
+
+ commit_command = svn_commit_command_new (selected_paths, log, FALSE);
+ g_free (log);
+
+ svn_command_free_path_list (selected_paths);
+
+ /*pulse_timer_id = status_bar_progress_pulse (data->plugin,
+ _("Subversion: "
+ "Committing changes "
+ "to the "
+ "repository..."));
+
+ g_signal_connect (G_OBJECT (commit_command), "command-finished",
+ G_CALLBACK (stop_status_bar_progress_pulse),
+ GUINT_TO_POINTER (pulse_timer_id)); */
+
+ g_signal_connect (G_OBJECT (commit_command), "command-finished",
+ G_CALLBACK (on_commit_command_finished), commit);
+
+ g_signal_connect (G_OBJECT (commit_command), "data-arrived",
+ G_CALLBACK (on_command_info_arrived),
+ commit->priv->window);
+
+ gtranslator_command_start (GTR_COMMAND (commit_command));
+
+ gtk_widget_hide (GTK_WIDGET (dlg));
+ break;
+ }
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
}
static void
-send_status_command (GtranslatorCommitDialog *dlg,
- GtranslatorWindow *window)
+send_status_command (GtranslatorCommitDialog * dlg,
+ GtranslatorWindow * window)
{
- SvnStatusCommand *status_command;
- GtranslatorTab *tab;
- GtranslatorPo *po;
- GFile *location, *parent;
-
- /* Setting up */
- dlg->priv->window = window;
- tab = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (tab);
- g_free (dlg->priv->dirname);
-
- location = gtranslator_po_get_location (po);
- parent = g_file_get_parent (location);
- g_object_unref (location);
-
- dlg->priv->dirname = g_file_get_path (parent);
- g_object_unref (parent);
-
- status_command = svn_status_command_new (dlg->priv->dirname,
- TRUE, TRUE);
-
- g_signal_connect (G_OBJECT (status_command), "command-finished",
- G_CALLBACK (select_all_files),
- dlg->priv->status_view);
-
- pulse_progress_bar (GTK_PROGRESS_BAR (dlg->priv->status_progress_bar));
-
- g_signal_connect (G_OBJECT (status_command), "command-finished",
- G_CALLBACK (cancel_data_arrived_signal_disconnect),
- dlg->priv->status_view);
-
- g_signal_connect (G_OBJECT (status_command), "command-finished",
- G_CALLBACK (hide_pulse_progress_bar),
- dlg->priv->status_progress_bar);
-
- g_signal_connect (G_OBJECT (status_command), "command-finished",
- G_CALLBACK (on_status_command_finished),
- dlg->priv->window);
-
- g_signal_connect (G_OBJECT (status_command), "data-arrived",
- G_CALLBACK (on_status_command_data_arrived),
- dlg->priv->status_view);
-
- g_object_weak_ref (G_OBJECT (dlg->priv->status_view),
- (GWeakNotify) disconnect_data_arrived_signals,
- status_command);
-
- gtranslator_command_start (GTR_COMMAND (status_command));
+ SvnStatusCommand *status_command;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ GFile *location, *parent;
+
+ /* Setting up */
+ dlg->priv->window = window;
+ tab = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (tab);
+ g_free (dlg->priv->dirname);
+
+ location = gtranslator_po_get_location (po);
+ parent = g_file_get_parent (location);
+ g_object_unref (location);
+
+ dlg->priv->dirname = g_file_get_path (parent);
+ g_object_unref (parent);
+
+ status_command = svn_status_command_new (dlg->priv->dirname, TRUE, TRUE);
+
+ g_signal_connect (G_OBJECT (status_command), "command-finished",
+ G_CALLBACK (select_all_files), dlg->priv->status_view);
+
+ pulse_progress_bar (GTK_PROGRESS_BAR (dlg->priv->status_progress_bar));
+
+ g_signal_connect (G_OBJECT (status_command), "command-finished",
+ G_CALLBACK (cancel_data_arrived_signal_disconnect),
+ dlg->priv->status_view);
+
+ g_signal_connect (G_OBJECT (status_command), "command-finished",
+ G_CALLBACK (hide_pulse_progress_bar),
+ dlg->priv->status_progress_bar);
+
+ g_signal_connect (G_OBJECT (status_command), "command-finished",
+ G_CALLBACK (on_status_command_finished),
+ dlg->priv->window);
+
+ g_signal_connect (G_OBJECT (status_command), "data-arrived",
+ G_CALLBACK (on_status_command_data_arrived),
+ dlg->priv->status_view);
+
+ g_object_weak_ref (G_OBJECT (dlg->priv->status_view),
+ (GWeakNotify) disconnect_data_arrived_signals,
+ status_command);
+
+ gtranslator_command_start (GTR_COMMAND (status_command));
}
static void
-on_add_log_checkbutton_toggled (GtkToggleButton *button,
- GtranslatorCommitDialog *dlg)
+on_add_log_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorCommitDialog * dlg)
{
- g_return_if_fail (GTR_IS_COMMIT_DIALOG (dlg));
-
- if (!gconf_client_key_is_writable (dlg->priv->gconf_client,
- ADD_CHANGE_LOG_KEY,
- NULL))
- return;
-
- gconf_client_set_bool (dlg->priv->gconf_client,
- ADD_CHANGE_LOG_KEY,
- gtk_toggle_button_get_active (button),
- NULL);
+ g_return_if_fail (GTR_IS_COMMIT_DIALOG (dlg));
+
+ if (!gconf_client_key_is_writable (dlg->priv->gconf_client,
+ ADD_CHANGE_LOG_KEY, NULL))
+ return;
+
+ gconf_client_set_bool (dlg->priv->gconf_client,
+ ADD_CHANGE_LOG_KEY,
+ gtk_toggle_button_get_active (button), NULL);
}
static void
-gtranslator_commit_dialog_init (GtranslatorCommitDialog *dlg)
+gtranslator_commit_dialog_init (GtranslatorCommitDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- GtkWidget *sw_view;
- gboolean data;
- gchar *root_objects [] = {
- "commit_main_box",
- NULL
- };
-
- dlg->priv = GTR_COMMIT_DIALOG_GET_PRIVATE (dlg);
-
- dlg->priv->gconf_client = gconf_client_get_default ();
- dlg->priv->dirname = NULL;
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Commit Changes"));
- gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 600);
- gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Glade*/
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
-
- "commit_main_box", &dlg->priv->main_box,
- "changelog_view", &dlg->priv->changelog_view,
- "add_log_checkbutton", &dlg->priv->add_log_checkbutton,
- "select_all_button", &dlg->priv->select_all_button,
- "clear_button", &dlg->priv->clear_button,
- "status_progress_bar", &dlg->priv->status_progress_bar,
- "sw_view", &sw_view,
-
- NULL);
-
- if(!ret)
- {
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- /* status view */
- dlg->priv->status_view = gtranslator_vcs_status_tree_view_new ();
- gtk_widget_show (dlg->priv->status_view);
- gtk_container_add (GTK_CONTAINER (sw_view),
- dlg->priv->status_view);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
- /*
- * We add the ChangeLog
- */
- add_changelog_to_text_view (dlg->priv->changelog_view);
-
- g_signal_connect (dlg->priv->add_log_checkbutton, "toggled",
- G_CALLBACK (on_add_log_checkbutton_toggled), dlg);
-
- g_signal_connect (G_OBJECT (dlg->priv->select_all_button), "clicked",
- G_CALLBACK (select_all_status_items),
- dlg->priv->status_view);
-
- g_signal_connect (G_OBJECT (dlg->priv->clear_button), "clicked",
- G_CALLBACK (clear_all_status_selections),
- dlg->priv->status_view);
-
- /*
- * Set add_log_checkbutton value
- */
- data = gconf_client_get_bool (dlg->priv->gconf_client,
- ADD_CHANGE_LOG_KEY,
- NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->add_log_checkbutton),
- data);
+ gboolean ret;
+ GtkWidget *error_widget;
+ GtkWidget *sw_view;
+ gboolean data;
+ gchar *root_objects[] = {
+ "commit_main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_COMMIT_DIALOG_GET_PRIVATE (dlg);
+
+ dlg->priv->gconf_client = gconf_client_get_default ();
+ dlg->priv->dirname = NULL;
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Commit Changes"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 600);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "commit_main_box",
+ &dlg->priv->main_box,
+ "changelog_view",
+ &dlg->priv->changelog_view,
+ "add_log_checkbutton",
+ &dlg->priv->add_log_checkbutton,
+ "select_all_button",
+ &dlg->priv->select_all_button,
+ "clear_button",
+ &dlg->priv->clear_button,
+ "status_progress_bar",
+ &dlg->priv->status_progress_bar,
+ "sw_view", &sw_view, NULL);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ /* status view */
+ dlg->priv->status_view = gtranslator_vcs_status_tree_view_new ();
+ gtk_widget_show (dlg->priv->status_view);
+ gtk_container_add (GTK_CONTAINER (sw_view), dlg->priv->status_view);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
+ /*
+ * We add the ChangeLog
+ */
+ add_changelog_to_text_view (dlg->priv->changelog_view);
+
+ g_signal_connect (dlg->priv->add_log_checkbutton, "toggled",
+ G_CALLBACK (on_add_log_checkbutton_toggled), dlg);
+
+ g_signal_connect (G_OBJECT (dlg->priv->select_all_button), "clicked",
+ G_CALLBACK (select_all_status_items),
+ dlg->priv->status_view);
+
+ g_signal_connect (G_OBJECT (dlg->priv->clear_button), "clicked",
+ G_CALLBACK (clear_all_status_selections),
+ dlg->priv->status_view);
+
+ /*
+ * Set add_log_checkbutton value
+ */
+ data = gconf_client_get_bool (dlg->priv->gconf_client,
+ ADD_CHANGE_LOG_KEY, NULL);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->add_log_checkbutton), data);
}
static void
-gtranslator_commit_dialog_finalize (GObject *object)
+gtranslator_commit_dialog_finalize (GObject * object)
{
- GtranslatorCommitDialog *dlg = GTR_COMMIT_DIALOG (object);
-
- gconf_client_suggest_sync (dlg->priv->gconf_client, NULL);
-
- g_object_unref (G_OBJECT (dlg->priv->gconf_client));
-
- g_free (dlg->priv->dirname);
-
- G_OBJECT_CLASS (gtranslator_commit_dialog_parent_class)->finalize (object);
+ GtranslatorCommitDialog *dlg = GTR_COMMIT_DIALOG (object);
+
+ gconf_client_suggest_sync (dlg->priv->gconf_client, NULL);
+
+ g_object_unref (G_OBJECT (dlg->priv->gconf_client));
+
+ g_free (dlg->priv->dirname);
+
+ G_OBJECT_CLASS (gtranslator_commit_dialog_parent_class)->finalize (object);
}
static void
-gtranslator_commit_dialog_class_init (GtranslatorCommitDialogClass *klass)
+gtranslator_commit_dialog_class_init (GtranslatorCommitDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorCommitDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorCommitDialogPrivate));
- object_class->finalize = gtranslator_commit_dialog_finalize;
+ object_class->finalize = gtranslator_commit_dialog_finalize;
}
void
-gtranslator_show_commit_dialog (GtranslatorWindow *window)
+gtranslator_show_commit_dialog (GtranslatorWindow * window)
{
- static GtranslatorCommitDialog *dlg = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- if(dlg == NULL)
- {
- dlg = g_object_new (GTR_TYPE_COMMIT_DIALOG, NULL);
-
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg),
- TRUE);
-
- send_status_command (dlg, window);
-
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
- gtk_widget_show (GTK_WIDGET (dlg));
- }
- else
- {
- /* We clean the current status treeview and send another
- status command */
- gtranslator_vsc_status_tree_view_clear (GTR_VCS_STATUS_TREE_VIEW (dlg->priv->status_view));
- send_status_command (dlg, dlg->priv->window);
- }
-
- 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_present (GTK_WINDOW (dlg));
+ static GtranslatorCommitDialog *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_COMMIT_DIALOG, NULL);
+
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ send_status_command (dlg, window);
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+ gtk_widget_show (GTK_WIDGET (dlg));
+ }
+ else
+ {
+ /* We clean the current status treeview and send another
+ status command */
+ gtranslator_vsc_status_tree_view_clear (GTR_VCS_STATUS_TREE_VIEW
+ (dlg->priv->status_view));
+ send_status_command (dlg, dlg->priv->window);
+ }
+
+ 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_present (GTK_WINDOW (dlg));
}
diff --git a/plugins/subversion/commit-dialog.h b/plugins/subversion/commit-dialog.h
index 472dc40..596d6c1 100644
--- a/plugins/subversion/commit-dialog.h
+++ b/plugins/subversion/commit-dialog.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,42 +34,42 @@ G_BEGIN_DECLS
#define GTR_IS_COMMIT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_COMMIT_DIALOG))
#define GTR_IS_COMMIT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_COMMIT_DIALOG))
#define GTR_COMMIT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_COMMIT_DIALOG, GtranslatorCommitDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorCommitDialogPrivate GtranslatorCommitDialogPrivate;
+typedef struct _GtranslatorCommitDialogPrivate GtranslatorCommitDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorCommitDialog GtranslatorCommitDialog;
+typedef struct _GtranslatorCommitDialog GtranslatorCommitDialog;
struct _GtranslatorCommitDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorCommitDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorCommitDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorCommitDialogClass GtranslatorCommitDialogClass;
+typedef struct _GtranslatorCommitDialogClass GtranslatorCommitDialogClass;
struct _GtranslatorCommitDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_commit_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_commit_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_commit_dialog_register_type (GTypeModule * module);
+ GType gtranslator_commit_dialog_register_type (GTypeModule * module);
-void gtranslator_show_commit_dialog (GtranslatorWindow *window);
+ void gtranslator_show_commit_dialog (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __COMMIT_DIALOG_H__ */
diff --git a/plugins/subversion/diff-dialog.c b/plugins/subversion/diff-dialog.c
index 1abfb5d..3c8c03e 100644
--- a/plugins/subversion/diff-dialog.c
+++ b/plugins/subversion/diff-dialog.c
@@ -49,568 +49,534 @@
GtranslatorDiffDialogPrivate))
-G_DEFINE_TYPE(GtranslatorDiffDialog, gtranslator_diff_dialog, GTK_TYPE_DIALOG)
-
-struct _GtranslatorDiffDialogPrivate
+G_DEFINE_TYPE (GtranslatorDiffDialog, gtranslator_diff_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorDiffDialogPrivate
+ {
+ GConfClient *gconf_client;
+
+ GtkWidget *main_box;
+ GtkWidget *use_configured_program;
+ GtkWidget *save_diff;
+ GtkWidget *diff_filename_entry;
+ GtkWidget *diff_find;
+
+ gchar *filename;
+
+ GtranslatorWindow *window;
+ };
+
+ static void
+ on_diff_command_finished (GtranslatorCommand * command,
+ guint return_code,
+ GtranslatorDiffDialog * dlg)
{
- GConfClient *gconf_client;
-
- GtkWidget *main_box;
- GtkWidget *use_configured_program;
- GtkWidget *save_diff;
- GtkWidget *diff_filename_entry;
- GtkWidget *diff_find;
-
- gchar *filename;
+ GtranslatorStatusbar *status;
- GtranslatorWindow *window;
-};
+ status =
+ GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
-static void
-on_diff_command_finished (GtranslatorCommand *command,
- guint return_code,
- GtranslatorDiffDialog *dlg)
-{
- GtranslatorStatusbar *status;
-
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
-
- gtranslator_statusbar_flash_message (status, 0,
- _("Subversion: Diff complete."));
-
- subversion_utils_report_errors (dlg->priv->window,
- command, return_code);
-
- if (SVN_IS_DIFF_COMMAND (command))
- svn_diff_command_destroy (SVN_DIFF_COMMAND (command));
- else svn_cat_command_destroy (SVN_CAT_COMMAND (command));
+ gtranslator_statusbar_flash_message (status, 0,
+ _("Subversion: Diff complete."));
+
+ subversion_utils_report_errors (dlg->priv->window, command, return_code);
+
+ if (SVN_IS_DIFF_COMMAND (command))
+ svn_diff_command_destroy (SVN_DIFF_COMMAND (command));
+ else
+ svn_cat_command_destroy (SVN_CAT_COMMAND (command));
}
static void
-show_in_program (const gchar *program_name,
- const gchar *line_arg,
- const gchar *path1,
- const gchar *path2)
+show_in_program (const gchar * program_name,
+ const gchar * line_arg,
+ const gchar * path1, const gchar * path2)
{
- gchar *open[5];
-
- if (g_find_program_in_path (program_name))
- {
- open[0] = g_strdup (program_name);
- }
- else
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_DIALOG_MODAL,
- GTK_BUTTONS_CLOSE,
- _("Please install %s to be able to diff the file"),
- program_name);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
-
- open[1] = g_strdup (path1);
- open[2] = g_strdup (path2);
-
- if (strcmp (line_arg, ""))
- {
- open[3] = g_strdup_printf ("%s",line_arg);
- open[4] = NULL;
- }
- else open[3] = NULL;
-
- gdk_spawn_on_screen (gdk_screen_get_default (),
- NULL,
- open,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL, NULL, NULL);
- g_free (open[0]);
- g_free (open[1]);
- g_free (open[2]);
- g_free (open[3]);
+ gchar *open[5];
+
+ if (g_find_program_in_path (program_name))
+ {
+ open[0] = g_strdup (program_name);
+ }
+ else
+ {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_DIALOG_MODAL,
+ GTK_BUTTONS_CLOSE,
+ _
+ ("Please install %s to be able to diff the file"),
+ program_name);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+
+ open[1] = g_strdup (path1);
+ open[2] = g_strdup (path2);
+
+ if (strcmp (line_arg, ""))
+ {
+ open[3] = g_strdup_printf ("%s", line_arg);
+ open[4] = NULL;
+ }
+ else
+ open[3] = NULL;
+
+ gdk_spawn_on_screen (gdk_screen_get_default (),
+ NULL,
+ open,
+ NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+ g_free (open[0]);
+ g_free (open[1]);
+ g_free (open[2]);
+ g_free (open[3]);
}
static void
-on_cat_command_info_arrived (GtranslatorCommand *command,
- GtranslatorDiffDialog *dlg)
+on_cat_command_info_arrived (GtranslatorCommand * command,
+ GtranslatorDiffDialog * dlg)
{
- GQueue *output;
- gchar *line;
- guint tmpfd;
- GError *error = NULL;
- gchar *tmp_fname;
- GFile *tmp_file;
- GFileOutputStream *ostream;
- gboolean check;
- gchar *program_name;
- gchar *program_arg;
-
- output = svn_cat_command_get_output (SVN_CAT_COMMAND (command));
-
- tmpfd = g_file_open_tmp (".gtranslator-changelog-XXXXXX",
- &tmp_fname,
- &error);
-
- if (tmpfd == -1)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
-
- /* In this case we don't have to close the file */
- return;
- }
-
- tmp_file = g_file_new_for_path (tmp_fname);
-
- ostream = g_file_append_to (tmp_file, G_FILE_CREATE_NONE,
- NULL, &error);
-
- while (g_queue_peek_head (output))
- {
- line = g_queue_pop_head (output);
-
- g_output_stream_write (G_OUTPUT_STREAM (ostream), line,
- strlen (line),
- NULL, &error);
-
- g_free (line);
-
- if (error)
- break;
- }
-
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- if (!g_output_stream_close (G_OUTPUT_STREAM (ostream), NULL, &error))
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- /*
- * Check if we have to show it in an external diff program
- */
- check = gconf_client_get_bool (dlg->priv->gconf_client,
- USE_CONFIGURED_PROGRAM_KEY,
- NULL);
-
- if (check)
- {
- program_name = gconf_client_get_string (dlg->priv->gconf_client,
- PROGRAM_NAME_KEY,
- NULL);
- program_arg = gconf_client_get_string (dlg->priv->gconf_client,
- LINE_ARGUMENT_KEY,
- NULL);
-
- show_in_program (program_name, program_arg,
- tmp_fname, dlg->priv->filename);
-
- g_free (program_name);
- g_free (program_arg);
- }
-
- close (tmpfd);
- g_free (tmp_fname);
- g_object_unref (tmp_file);
+ GQueue *output;
+ gchar *line;
+ guint tmpfd;
+ GError *error = NULL;
+ gchar *tmp_fname;
+ GFile *tmp_file;
+ GFileOutputStream *ostream;
+ gboolean check;
+ gchar *program_name;
+ gchar *program_arg;
+
+ output = svn_cat_command_get_output (SVN_CAT_COMMAND (command));
+
+ tmpfd = g_file_open_tmp (".gtranslator-changelog-XXXXXX",
+ &tmp_fname, &error);
+
+ if (tmpfd == -1)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+
+ /* In this case we don't have to close the file */
+ return;
+ }
+
+ tmp_file = g_file_new_for_path (tmp_fname);
+
+ ostream = g_file_append_to (tmp_file, G_FILE_CREATE_NONE, NULL, &error);
+
+ while (g_queue_peek_head (output))
+ {
+ line = g_queue_pop_head (output);
+
+ g_output_stream_write (G_OUTPUT_STREAM (ostream), line,
+ strlen (line), NULL, &error);
+
+ g_free (line);
+
+ if (error)
+ break;
+ }
+
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ if (!g_output_stream_close (G_OUTPUT_STREAM (ostream), NULL, &error))
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ /*
+ * Check if we have to show it in an external diff program
+ */
+ check = gconf_client_get_bool (dlg->priv->gconf_client,
+ USE_CONFIGURED_PROGRAM_KEY, NULL);
+
+ if (check)
+ {
+ program_name = gconf_client_get_string (dlg->priv->gconf_client,
+ PROGRAM_NAME_KEY, NULL);
+ program_arg = gconf_client_get_string (dlg->priv->gconf_client,
+ LINE_ARGUMENT_KEY, NULL);
+
+ show_in_program (program_name, program_arg,
+ tmp_fname, dlg->priv->filename);
+
+ g_free (program_name);
+ g_free (program_arg);
+ }
+
+ close (tmpfd);
+ g_free (tmp_fname);
+ g_object_unref (tmp_file);
}
static void
-on_diff_command_info_arrived (GtranslatorCommand *command,
- GtranslatorDiffDialog *dlg)
+on_diff_command_info_arrived (GtranslatorCommand * command,
+ GtranslatorDiffDialog * dlg)
{
- GQueue *output;
- gchar *line;
- GError *error = NULL;
- GFile *tmp_file;
- const gchar *tmp_fname;
- GFileOutputStream *ostream;
-
- output = svn_diff_command_get_output (SVN_DIFF_COMMAND (command));
-
- tmp_fname = gtk_entry_get_text (GTK_ENTRY (dlg->priv->diff_filename_entry));
-
- tmp_file = g_file_new_for_path (tmp_fname);
-
- if (g_file_query_exists (tmp_file, NULL))
- {
- if (!g_file_delete (tmp_file, NULL, &error))
- {
- g_warning ("%s", error->message);
- g_error_free (error);
-
- g_object_unref (tmp_file);
- return;
- }
- }
-
- ostream = g_file_create (tmp_file, G_FILE_CREATE_NONE,
- NULL, &error);
-
- while (g_queue_peek_head (output))
- {
- line = g_queue_pop_head (output);
-
- g_output_stream_write (G_OUTPUT_STREAM (ostream), line,
- strlen (line),
- NULL, &error);
-
- g_free (line);
-
- if (error)
- break;
- }
-
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- if (!g_output_stream_close (G_OUTPUT_STREAM (ostream), NULL, &error))
+ GQueue *output;
+ gchar *line;
+ GError *error = NULL;
+ GFile *tmp_file;
+ const gchar *tmp_fname;
+ GFileOutputStream *ostream;
+
+ output = svn_diff_command_get_output (SVN_DIFF_COMMAND (command));
+
+ tmp_fname = gtk_entry_get_text (GTK_ENTRY (dlg->priv->diff_filename_entry));
+
+ tmp_file = g_file_new_for_path (tmp_fname);
+
+ if (g_file_query_exists (tmp_file, NULL))
+ {
+ if (!g_file_delete (tmp_file, NULL, &error))
{
- g_warning ("%s", error->message);
- g_error_free (error);
+ g_warning ("%s", error->message);
+ g_error_free (error);
+
+ g_object_unref (tmp_file);
+ return;
}
-
- g_object_unref (tmp_file);
+ }
+
+ ostream = g_file_create (tmp_file, G_FILE_CREATE_NONE, NULL, &error);
+
+ while (g_queue_peek_head (output))
+ {
+ line = g_queue_pop_head (output);
+
+ g_output_stream_write (G_OUTPUT_STREAM (ostream), line,
+ strlen (line), NULL, &error);
+
+ g_free (line);
+
+ if (error)
+ break;
+ }
+
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ if (!g_output_stream_close (G_OUTPUT_STREAM (ostream), NULL, &error))
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (tmp_file);
}
static void
-send_diff_command (GtranslatorDiffDialog *dlg)
+send_diff_command (GtranslatorDiffDialog * dlg)
{
- SvnDiffCommand *diff_command;
-
- diff_command = svn_diff_command_new (dlg->priv->filename,
- SVN_DIFF_REVISION_NONE,
- SVN_DIFF_REVISION_NONE,
- TRUE);
-
- g_signal_connect (G_OBJECT (diff_command), "command-finished",
- G_CALLBACK (on_diff_command_finished),
- dlg);
-
- g_signal_connect (G_OBJECT (diff_command), "data-arrived",
- G_CALLBACK (on_diff_command_info_arrived),
- dlg);
-
- gtranslator_command_start (GTR_COMMAND (diff_command));
+ SvnDiffCommand *diff_command;
+
+ diff_command = svn_diff_command_new (dlg->priv->filename,
+ SVN_DIFF_REVISION_NONE,
+ SVN_DIFF_REVISION_NONE, TRUE);
+
+ g_signal_connect (G_OBJECT (diff_command), "command-finished",
+ G_CALLBACK (on_diff_command_finished), dlg);
+
+ g_signal_connect (G_OBJECT (diff_command), "data-arrived",
+ G_CALLBACK (on_diff_command_info_arrived), dlg);
+
+ gtranslator_command_start (GTR_COMMAND (diff_command));
}
static void
-send_cat_command (GtranslatorDiffDialog *dlg)
+send_cat_command (GtranslatorDiffDialog * dlg)
{
- SvnCatCommand *cat_command;
-
- cat_command = svn_cat_command_new (dlg->priv->filename,
- SVN_DIFF_REVISION_NONE);
-
- g_signal_connect (G_OBJECT (cat_command), "command-finished",
- G_CALLBACK (on_diff_command_finished),
- dlg);
-
- g_signal_connect (G_OBJECT (cat_command), "data-arrived",
- G_CALLBACK (on_cat_command_info_arrived),
- dlg);
-
- gtranslator_command_start (GTR_COMMAND (cat_command));
+ SvnCatCommand *cat_command;
+
+ cat_command = svn_cat_command_new (dlg->priv->filename,
+ SVN_DIFF_REVISION_NONE);
+
+ g_signal_connect (G_OBJECT (cat_command), "command-finished",
+ G_CALLBACK (on_diff_command_finished), dlg);
+
+ g_signal_connect (G_OBJECT (cat_command), "data-arrived",
+ G_CALLBACK (on_cat_command_info_arrived), dlg);
+
+ gtranslator_command_start (GTR_COMMAND (cat_command));
}
static void
-dialog_response_handler (GtranslatorDiffDialog *dlg,
- gint res_id)
+dialog_response_handler (GtranslatorDiffDialog * dlg, gint res_id)
{
- switch (res_id)
- {
- case GTK_RESPONSE_OK:
- {
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->save_diff)))
- send_diff_command (dlg);
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->use_configured_program)))
- send_cat_command (dlg);
- gtk_widget_hide (GTK_WIDGET (dlg));
- break;
- }
- default:
- gtk_widget_hide (GTK_WIDGET (dlg));
- }
+ switch (res_id)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dlg->priv->save_diff)))
+ send_diff_command (dlg);
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dlg->priv->use_configured_program)))
+ send_cat_command (dlg);
+ gtk_widget_hide (GTK_WIDGET (dlg));
+ break;
+ }
+ default:
+ gtk_widget_hide (GTK_WIDGET (dlg));
+ }
}
static void
-setup_diff_filename_entry (GtranslatorDiffDialog *dlg)
+setup_diff_filename_entry (GtranslatorDiffDialog * dlg)
{
- gchar *file;
-
- file = g_strdup_printf ("%s.diff", dlg->priv->filename);
-
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->diff_filename_entry),
- file);
- g_free (file);
+ gchar *file;
+
+ file = g_strdup_printf ("%s.diff", dlg->priv->filename);
+
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->diff_filename_entry), file);
+ g_free (file);
}
static void
-use_configured_program_toggled (GtkToggleButton *button,
- GtranslatorDiffDialog *dlg)
+use_configured_program_toggled (GtkToggleButton * button,
+ GtranslatorDiffDialog * dlg)
{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
-
- if (!gconf_client_key_is_writable (dlg->priv->gconf_client,
- USE_CONFIGURED_PROGRAM_KEY,
- NULL))
- return;
-
- gconf_client_set_bool (dlg->priv->gconf_client,
- USE_CONFIGURED_PROGRAM_KEY,
- gtk_toggle_button_get_active (button),
- NULL);
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
+
+ if (!gconf_client_key_is_writable (dlg->priv->gconf_client,
+ USE_CONFIGURED_PROGRAM_KEY, NULL))
+ return;
+
+ gconf_client_set_bool (dlg->priv->gconf_client,
+ USE_CONFIGURED_PROGRAM_KEY,
+ gtk_toggle_button_get_active (button), NULL);
}
static void
-save_diff_toggled (GtkToggleButton *button,
- GtranslatorDiffDialog *dlg)
+save_diff_toggled (GtkToggleButton * button, GtranslatorDiffDialog * dlg)
{
- gboolean active;
-
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
-
- active = gtk_toggle_button_get_active (button);
-
- if (!gconf_client_key_is_writable (dlg->priv->gconf_client,
- SAVE_DIFF_KEY,
- NULL))
- return;
-
- gconf_client_set_bool (dlg->priv->gconf_client,
- SAVE_DIFF_KEY,
- active,
- NULL);
-
-
-
- gtk_widget_set_sensitive (dlg->priv->diff_filename_entry, active);
- gtk_widget_set_sensitive (dlg->priv->diff_find, active);
+ gboolean active;
+
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
+
+ active = gtk_toggle_button_get_active (button);
+
+ if (!gconf_client_key_is_writable (dlg->priv->gconf_client,
+ SAVE_DIFF_KEY, NULL))
+ return;
+
+ gconf_client_set_bool (dlg->priv->gconf_client,
+ SAVE_DIFF_KEY, active, NULL);
+
+
+
+ gtk_widget_set_sensitive (dlg->priv->diff_filename_entry, active);
+ gtk_widget_set_sensitive (dlg->priv->diff_find, active);
}
static void
-on_diff_find_clicked (GtkButton *button,
- GtranslatorDiffDialog *dlg)
+on_diff_find_clicked (GtkButton * button, GtranslatorDiffDialog * dlg)
{
- GtkWidget *dialog;
- gint res;
-
- dialog = gtk_file_chooser_dialog_new (_("Diff file"),
- GTK_WINDOW (dlg->priv->window),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (res)
- {
- case GTK_RESPONSE_OK:
- {
- gchar *filename;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->diff_filename_entry),
- filename);
- g_free (filename);
- break;
- }
- default:
- break;
- }
- gtk_widget_destroy (dialog);
+ GtkWidget *dialog;
+ gint res;
+
+ dialog = gtk_file_chooser_dialog_new (_("Diff file"),
+ GTK_WINDOW (dlg->priv->window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ switch (res)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ gchar *filename;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->diff_filename_entry),
+ filename);
+ g_free (filename);
+ break;
+ }
+ default:
+ break;
+ }
+ gtk_widget_destroy (dialog);
}
static void
-set_values (GtranslatorDiffDialog *dlg)
+set_values (GtranslatorDiffDialog * dlg)
{
- gboolean data;
-
- /* Use configured program */
- data = gconf_client_get_bool (dlg->priv->gconf_client,
- USE_CONFIGURED_PROGRAM_KEY,
- NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->use_configured_program),
- data);
-
- /* Save diff */
- data = gconf_client_get_bool (dlg->priv->gconf_client,
- SAVE_DIFF_KEY,
- NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->save_diff),
- data);
+ gboolean data;
+
+ /* Use configured program */
+ data = gconf_client_get_bool (dlg->priv->gconf_client,
+ USE_CONFIGURED_PROGRAM_KEY, NULL);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->use_configured_program), data);
+
+ /* Save diff */
+ data = gconf_client_get_bool (dlg->priv->gconf_client, SAVE_DIFF_KEY, NULL);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->save_diff),
+ data);
}
static void
-gtranslator_diff_dialog_init (GtranslatorDiffDialog *dlg)
+gtranslator_diff_dialog_init (GtranslatorDiffDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gboolean active;
- gchar *root_objects [] = {
- "diff_main_box",
- NULL
- };
-
- dlg->priv = GTR_DIFF_DIALOG_GET_PRIVATE (dlg);
-
- dlg->priv->gconf_client = gconf_client_get_default ();
- dlg->priv->filename = NULL;
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Diff"));
- gtk_window_set_default_size (GTK_WINDOW (dlg), 500, 300);
- gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Glade*/
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
-
- "diff_main_box", &dlg->priv->main_box,
- "use_configured_program", &dlg->priv->use_configured_program,
- "save_diff", &dlg->priv->save_diff,
- "diff_filename_entry", &dlg->priv->diff_filename_entry,
- "diff_find", &dlg->priv->diff_find,
-
- NULL);
-
- if(!ret)
- {
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
- g_signal_connect (dlg->priv->use_configured_program, "toggled",
- G_CALLBACK (use_configured_program_toggled), dlg);
-
- g_signal_connect (dlg->priv->save_diff, "toggled",
- G_CALLBACK (save_diff_toggled), dlg);
-
- g_signal_connect (dlg->priv->diff_find, "clicked",
- G_CALLBACK (on_diff_find_clicked), dlg);
-
- /*
- * Set values
- */
- set_values (dlg);
-
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->save_diff));
- gtk_widget_set_sensitive (dlg->priv->diff_filename_entry, active);
- gtk_widget_set_sensitive (dlg->priv->diff_find, active);
+ gboolean ret;
+ GtkWidget *error_widget;
+ gboolean active;
+ gchar *root_objects[] = {
+ "diff_main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_DIFF_DIALOG_GET_PRIVATE (dlg);
+
+ dlg->priv->gconf_client = gconf_client_get_default ();
+ dlg->priv->filename = NULL;
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Diff"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 500, 300);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "diff_main_box",
+ &dlg->priv->main_box,
+ "use_configured_program",
+ &dlg->priv->use_configured_program,
+ "save_diff", &dlg->priv->save_diff,
+ "diff_filename_entry",
+ &dlg->priv->diff_filename_entry,
+ "diff_find", &dlg->priv->diff_find,
+ NULL);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
+ g_signal_connect (dlg->priv->use_configured_program, "toggled",
+ G_CALLBACK (use_configured_program_toggled), dlg);
+
+ g_signal_connect (dlg->priv->save_diff, "toggled",
+ G_CALLBACK (save_diff_toggled), dlg);
+
+ g_signal_connect (dlg->priv->diff_find, "clicked",
+ G_CALLBACK (on_diff_find_clicked), dlg);
+
+ /*
+ * Set values
+ */
+ set_values (dlg);
+
+ active =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->save_diff));
+ gtk_widget_set_sensitive (dlg->priv->diff_filename_entry, active);
+ gtk_widget_set_sensitive (dlg->priv->diff_find, active);
}
static void
-gtranslator_diff_dialog_finalize (GObject *object)
+gtranslator_diff_dialog_finalize (GObject * object)
{
- GtranslatorDiffDialog *dlg = GTR_DIFF_DIALOG (object);
-
- gconf_client_suggest_sync (dlg->priv->gconf_client, NULL);
-
- g_object_unref (G_OBJECT (dlg->priv->gconf_client));
-
- g_free (dlg->priv->filename);
-
- G_OBJECT_CLASS (gtranslator_diff_dialog_parent_class)->finalize (object);
+ GtranslatorDiffDialog *dlg = GTR_DIFF_DIALOG (object);
+
+ gconf_client_suggest_sync (dlg->priv->gconf_client, NULL);
+
+ g_object_unref (G_OBJECT (dlg->priv->gconf_client));
+
+ g_free (dlg->priv->filename);
+
+ G_OBJECT_CLASS (gtranslator_diff_dialog_parent_class)->finalize (object);
}
static void
-gtranslator_diff_dialog_class_init (GtranslatorDiffDialogClass *klass)
+gtranslator_diff_dialog_class_init (GtranslatorDiffDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorDiffDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorDiffDialogPrivate));
- object_class->finalize = gtranslator_diff_dialog_finalize;
+ object_class->finalize = gtranslator_diff_dialog_finalize;
}
void
-gtranslator_show_diff_dialog (GtranslatorWindow *window)
+gtranslator_show_diff_dialog (GtranslatorWindow * window)
{
- static GtranslatorDiffDialog *dlg = NULL;
- GtranslatorTab *tab;
- GtranslatorPo *po;
- GFile *location;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- tab = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (tab);
- location = gtranslator_po_get_location (po);
-
- if(dlg == NULL)
- {
- dlg = g_object_new (GTR_TYPE_DIFF_DIALOG, NULL);
-
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg),
- TRUE);
-
- dlg->priv->window = window;
-
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
-
- gtk_widget_show (GTK_WIDGET (dlg));
- }
-
- //As we are not destroying the dialog we have to free the filename
- g_free (dlg->priv->filename);
- dlg->priv->filename = g_file_get_path (location);
- setup_diff_filename_entry (dlg);
-
- if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (dlg),
- GTK_WINDOW (window));
- }
+ static GtranslatorDiffDialog *dlg = NULL;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ GFile *location;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ tab = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (tab);
+ location = gtranslator_po_get_location (po);
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_DIFF_DIALOG, NULL);
+
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ dlg->priv->window = window;
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+
+ gtk_widget_show (GTK_WIDGET (dlg));
+ }
+
+ //As we are not destroying the dialog we have to free the filename
+ g_free (dlg->priv->filename);
+ dlg->priv->filename = g_file_get_path (location);
+ setup_diff_filename_entry (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_present (GTK_WINDOW (dlg));
+ gtk_window_present (GTK_WINDOW (dlg));
}
diff --git a/plugins/subversion/diff-dialog.h b/plugins/subversion/diff-dialog.h
index 9e32369..9184224 100644
--- a/plugins/subversion/diff-dialog.h
+++ b/plugins/subversion/diff-dialog.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,42 +34,42 @@ G_BEGIN_DECLS
#define GTR_IS_DIFF_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DIFF_DIALOG))
#define GTR_IS_DIFF_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DIFF_DIALOG))
#define GTR_DIFF_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DIFF_DIALOG, GtranslatorDiffDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorDiffDialogPrivate GtranslatorDiffDialogPrivate;
+typedef struct _GtranslatorDiffDialogPrivate GtranslatorDiffDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDiffDialog GtranslatorDiffDialog;
+typedef struct _GtranslatorDiffDialog GtranslatorDiffDialog;
struct _GtranslatorDiffDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorDiffDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorDiffDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDiffDialogClass GtranslatorDiffDialogClass;
+typedef struct _GtranslatorDiffDialogClass GtranslatorDiffDialogClass;
struct _GtranslatorDiffDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_diff_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_diff_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_diff_dialog_register_type (GTypeModule * module);
+ GType gtranslator_diff_dialog_register_type (GTypeModule * module);
-void gtranslator_show_diff_dialog (GtranslatorWindow *window);
+ void gtranslator_show_diff_dialog (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __DIFF_DIALOG_H__ */
diff --git a/plugins/subversion/subversion-plugin.c b/plugins/subversion/subversion-plugin.c
index c8f4dec..4c76636 100644
--- a/plugins/subversion/subversion-plugin.c
+++ b/plugins/subversion/subversion-plugin.c
@@ -43,438 +43,408 @@
GTR_TYPE_SUBVERSION_PLUGIN, \
GtranslatorSubversionPluginPrivate))
-GTR_PLUGIN_REGISTER_TYPE(GtranslatorSubversionPlugin, gtranslator_subversion_plugin)
-
-struct _GtranslatorSubversionPluginPrivate
-{
- GConfClient *gconf_client;
-
- /* Dialog stuff */
- GtkWidget *dialog;
-
- GtkWidget *main_box;
- GtkWidget *program_name_entry;
- GtkWidget *line_argument_entry;
-};
-
-static void
-on_update_activated (GtkAction *action,
- GtranslatorWindow *window)
+GTR_PLUGIN_REGISTER_TYPE (GtranslatorSubversionPlugin,
+ gtranslator_subversion_plugin)
+ struct _GtranslatorSubversionPluginPrivate
+ {
+ GConfClient *gconf_client;
+
+ /* Dialog stuff */
+ GtkWidget *dialog;
+
+ GtkWidget *main_box;
+ GtkWidget *program_name_entry;
+ GtkWidget *line_argument_entry;
+ };
+
+ static void
+ on_update_activated (GtkAction * action, GtranslatorWindow * window)
{
- gtranslator_show_update_dialog (window);
+ gtranslator_show_update_dialog (window);
}
static void
-on_commit_activated (GtkAction *action,
- GtranslatorWindow *window)
+on_commit_activated (GtkAction * action, GtranslatorWindow * window)
{
- gtranslator_show_commit_dialog (window);
+ gtranslator_show_commit_dialog (window);
}
static void
-on_add_command_finished (GtranslatorCommand *command,
- guint return_code,
- GtranslatorWindow *window)
+on_add_command_finished (GtranslatorCommand * command,
+ guint return_code, GtranslatorWindow * window)
{
- GtranslatorStatusbar *statusbar;
-
- statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
-
- gtranslator_statusbar_flash_message (statusbar, 0,
- _("Subversion: File will be added on next "
- "commit."));
-
- subversion_utils_report_errors (window, command, return_code);
-
- svn_add_command_destroy (SVN_ADD_COMMAND (command));
+ GtranslatorStatusbar *statusbar;
+
+ statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+
+ gtranslator_statusbar_flash_message (statusbar, 0,
+ _
+ ("Subversion: File will be added on next "
+ "commit."));
+
+ subversion_utils_report_errors (window, command, return_code);
+
+ svn_add_command_destroy (SVN_ADD_COMMAND (command));
}
static void
-on_add_activated (GtkAction *action,
- GtranslatorWindow *window)
+on_add_activated (GtkAction * action, GtranslatorWindow * window)
{
- GtranslatorTab *tab;
- GtranslatorPo *po;
- SvnAddCommand *add_command;
- GFile *location;
- gchar *path;
-
- tab = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (tab);
-
- location = gtranslator_po_get_location (po);
- path = g_file_get_path (location);
- g_object_unref (location);
-
- add_command = svn_add_command_new (path,
- FALSE,
- FALSE);
-
- g_free (path);
-
- g_signal_connect (G_OBJECT (add_command), "command-finished",
- G_CALLBACK (on_add_command_finished),
- window);
-
- gtranslator_command_start (GTR_COMMAND (add_command));
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ SvnAddCommand *add_command;
+ GFile *location;
+ gchar *path;
+
+ tab = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (tab);
+
+ location = gtranslator_po_get_location (po);
+ path = g_file_get_path (location);
+ g_object_unref (location);
+
+ add_command = svn_add_command_new (path, FALSE, FALSE);
+
+ g_free (path);
+
+ g_signal_connect (G_OBJECT (add_command), "command-finished",
+ G_CALLBACK (on_add_command_finished), window);
+
+ gtranslator_command_start (GTR_COMMAND (add_command));
}
static void
-on_diff_activated (GtkAction *action,
- GtranslatorWindow *window)
+on_diff_activated (GtkAction * action, GtranslatorWindow * window)
{
- gtranslator_show_diff_dialog (window);
+ gtranslator_show_diff_dialog (window);
}
static void
-on_checkout_activated (GtkAction *action,
- GtranslatorWindow *window)
+on_checkout_activated (GtkAction * action, GtranslatorWindow * window)
{
- gtranslator_show_checkout_dialog (window);
+ gtranslator_show_checkout_dialog (window);
}
-static const GtkActionEntry action_entries[] =
-{
- { "SubversionUpdate", GTK_STOCK_REFRESH, N_("_Update"), NULL,
- N_("Sync your local copy with the Subversion tree"),
- G_CALLBACK (on_update_activated)},
-
- { "SubversionCommit", GTK_STOCK_YES, N_("_Commit"), NULL,
- N_("Commit your changes to the Subversion tree"),
- G_CALLBACK (on_commit_activated)},
-
- { "SubversionAdd", GTK_STOCK_ADD, N_("_Add"), NULL,
- N_("Add a new file/directory to the Subversion tree"),
- G_CALLBACK (on_add_activated)},
-
- { "SubversionDiff", GTK_STOCK_ZOOM_100, N_("_Diff"), NULL,
- N_("Diff local PO file with repository PO file"),
- G_CALLBACK (on_diff_activated)},
-
- { "SubversionCheckout", GTK_STOCK_SAVE, N_("C_heckout"), "",
- N_("Get a new repository copy"),
- G_CALLBACK (on_checkout_activated)},
-
- { "Subversion", NULL, N_("S_ubversion") }
+static const GtkActionEntry action_entries[] = {
+ {"SubversionUpdate", GTK_STOCK_REFRESH, N_("_Update"), NULL,
+ N_("Sync your local copy with the Subversion tree"),
+ G_CALLBACK (on_update_activated)},
+
+ {"SubversionCommit", GTK_STOCK_YES, N_("_Commit"), NULL,
+ N_("Commit your changes to the Subversion tree"),
+ G_CALLBACK (on_commit_activated)},
+
+ {"SubversionAdd", GTK_STOCK_ADD, N_("_Add"), NULL,
+ N_("Add a new file/directory to the Subversion tree"),
+ G_CALLBACK (on_add_activated)},
+
+ {"SubversionDiff", GTK_STOCK_ZOOM_100, N_("_Diff"), NULL,
+ N_("Diff local PO file with repository PO file"),
+ G_CALLBACK (on_diff_activated)},
+
+ {"SubversionCheckout", GTK_STOCK_SAVE, N_("C_heckout"), "",
+ N_("Get a new repository copy"),
+ G_CALLBACK (on_checkout_activated)},
+
+ {"Subversion", NULL, N_("S_ubversion")}
};
static const gchar submenu[] =
-"<ui>"
-" <menubar name=\"MainMenu\">"
-" <placeholder name=\"SubversionPlaceholder\">"
-" <menu name=\"SubversionMenu\" action=\"Subversion\">"
-" <menuitem name=\"SubversionUpdateMenu\" action=\"SubversionUpdate\"/>"
-" <menuitem name=\"SubversionCommitMenu\" action=\"SubversionCommit\"/>"
-" <separator />"
-" <menuitem name=\"SubversionAddMenu\" action=\"SubversionAdd\"/>"
-" <separator />"
-" <menuitem name=\"SubversionDiffMenu\" action=\"SubversionDiff\"/>"
-" <separator />"
-" <menuitem name=\"SubversionCheckoutMenu\" action=\"SubversionCheckout\"/>"
-" </menu>"
-" </placeholder>"
-" </menubar>"
-"</ui>";
+ "<ui>"
+ " <menubar name=\"MainMenu\">"
+ " <placeholder name=\"SubversionPlaceholder\">"
+ " <menu name=\"SubversionMenu\" action=\"Subversion\">"
+ " <menuitem name=\"SubversionUpdateMenu\" action=\"SubversionUpdate\"/>"
+ " <menuitem name=\"SubversionCommitMenu\" action=\"SubversionCommit\"/>"
+ " <separator />"
+ " <menuitem name=\"SubversionAddMenu\" action=\"SubversionAdd\"/>"
+ " <separator />"
+ " <menuitem name=\"SubversionDiffMenu\" action=\"SubversionDiff\"/>"
+ " <separator />"
+ " <menuitem name=\"SubversionCheckoutMenu\" action=\"SubversionCheckout\"/>"
+ " </menu>" " </placeholder>" " </menubar>" "</ui>";
typedef struct
{
- GtkActionGroup *action_group;
- guint ui_id;
+ GtkActionGroup *action_group;
+ guint ui_id;
} WindowData;
static void
-free_window_data (WindowData *data)
+free_window_data (WindowData * data)
{
- g_return_if_fail (data != NULL);
+ g_return_if_fail (data != NULL);
- g_free (data);
+ g_free (data);
}
static void
-update_ui_real (GtranslatorWindow *window,
- WindowData *data)
+update_ui_real (GtranslatorWindow * window, WindowData * data)
{
- GList *tabs;
- GtkAction *action;
-
- tabs = gtranslator_window_get_all_tabs (window);
-
- action = gtk_action_group_get_action (data->action_group,
- "SubversionAdd");
- gtk_action_set_sensitive (action,
- tabs != NULL);
-
- action = gtk_action_group_get_action (data->action_group,
- "SubversionUpdate");
- gtk_action_set_sensitive (action,
- tabs != NULL);
-
- action = gtk_action_group_get_action (data->action_group,
- "SubversionCommit");
- gtk_action_set_sensitive (action,
- tabs != NULL);
-
- action = gtk_action_group_get_action (data->action_group,
- "SubversionDiff");
- gtk_action_set_sensitive (action,
- tabs != NULL);
+ GList *tabs;
+ GtkAction *action;
+
+ tabs = gtranslator_window_get_all_tabs (window);
+
+ action = gtk_action_group_get_action (data->action_group, "SubversionAdd");
+ gtk_action_set_sensitive (action, tabs != NULL);
+
+ action = gtk_action_group_get_action (data->action_group,
+ "SubversionUpdate");
+ gtk_action_set_sensitive (action, tabs != NULL);
+
+ action = gtk_action_group_get_action (data->action_group,
+ "SubversionCommit");
+ gtk_action_set_sensitive (action, tabs != NULL);
+
+ action = gtk_action_group_get_action (data->action_group, "SubversionDiff");
+ gtk_action_set_sensitive (action, tabs != NULL);
}
static void
-gtranslator_subversion_plugin_init (GtranslatorSubversionPlugin *plugin)
+gtranslator_subversion_plugin_init (GtranslatorSubversionPlugin * plugin)
{
- plugin->priv = GTR_SUBVERSION_PLUGIN_GET_PRIVATE (plugin);
+ plugin->priv = GTR_SUBVERSION_PLUGIN_GET_PRIVATE (plugin);
+
+ plugin->priv->gconf_client = gconf_client_get_default ();
- plugin->priv->gconf_client = gconf_client_get_default ();
+ gconf_client_add_dir (plugin->priv->gconf_client,
+ SUBVERSION_BASE_KEY,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- gconf_client_add_dir (plugin->priv->gconf_client,
- SUBVERSION_BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- apr_initialize ();
+ apr_initialize ();
}
static void
-gtranslator_subversion_plugin_finalize (GObject *object)
+gtranslator_subversion_plugin_finalize (GObject * object)
{
- GtranslatorSubversionPlugin *plugin = GTR_SUBVERSION_PLUGIN (object);
-
- gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
-
- g_object_unref (G_OBJECT (plugin->priv->gconf_client));
-
- apr_terminate ();
-
- G_OBJECT_CLASS (gtranslator_subversion_plugin_parent_class)->finalize (object);
+ GtranslatorSubversionPlugin *plugin = GTR_SUBVERSION_PLUGIN (object);
+
+ gconf_client_suggest_sync (plugin->priv->gconf_client, NULL);
+
+ g_object_unref (G_OBJECT (plugin->priv->gconf_client));
+
+ apr_terminate ();
+
+ G_OBJECT_CLASS (gtranslator_subversion_plugin_parent_class)->
+ finalize (object);
}
static void
-impl_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_activate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkUIManager *manager;
- WindowData *data;
- GError *error = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- data = g_new (WindowData, 1);
-
- manager = gtranslator_window_get_ui_manager (window);
-
- data->action_group = gtk_action_group_new ("GtranslatorSubversionPluginActions");
- gtk_action_group_set_translation_domain (data->action_group,
- GETTEXT_PACKAGE);
- gtk_action_group_add_actions (data->action_group,
- action_entries,
- G_N_ELEMENTS (action_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, data->action_group, 0);
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data,
- (GDestroyNotify) free_window_data);
-
- data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
- submenu,
- -1,
- &error);
-
- if (data->ui_id == 0)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- return;
- }
-
- gtk_ui_manager_ensure_update (manager);
- update_ui_real (window, data);
+ GtkUIManager *manager;
+ WindowData *data;
+ GError *error = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ data = g_new (WindowData, 1);
+
+ manager = gtranslator_window_get_ui_manager (window);
+
+ data->action_group =
+ gtk_action_group_new ("GtranslatorSubversionPluginActions");
+ gtk_action_group_set_translation_domain (data->action_group,
+ GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (data->action_group, action_entries,
+ G_N_ELEMENTS (action_entries), window);
+
+ gtk_ui_manager_insert_action_group (manager, data->action_group, 0);
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data, (GDestroyNotify) free_window_data);
+
+ data->ui_id = gtk_ui_manager_add_ui_from_string (manager,
+ submenu, -1, &error);
+
+ if (data->ui_id == 0)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ gtk_ui_manager_ensure_update (manager);
+ update_ui_real (window, data);
}
static void
-impl_deactivate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_deactivate (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- GtkUIManager *manager;
- WindowData *data;
-
- manager = gtranslator_window_get_ui_manager (window);
+ GtkUIManager *manager;
+ WindowData *data;
+
+ manager = gtranslator_window_get_ui_manager (window);
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- gtk_ui_manager_remove_ui (manager, data->ui_id);
- gtk_ui_manager_remove_action_group (manager, data->action_group);
+ gtk_ui_manager_remove_ui (manager, data->ui_id);
+ gtk_ui_manager_remove_action_group (manager, data->action_group);
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
static void
-impl_update_ui (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+impl_update_ui (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- WindowData *data;
+ WindowData *data;
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ data =
+ (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
- update_ui_real (window, data);
+ update_ui_real (window, data);
}
static void
-get_program (GtranslatorSubversionPlugin *plugin)
+get_program (GtranslatorSubversionPlugin * plugin)
{
- gchar *data;
-
- /* Program name */
- data = gconf_client_get_string (plugin->priv->gconf_client,
- PROGRAM_NAME_KEY,
- NULL);
-
- if (!data)
- data = g_strdup ("meld");
-
- gtk_entry_set_text (GTK_ENTRY (plugin->priv->program_name_entry), data);
-
- g_free (data);
-
- /* Line argument */
- data = gconf_client_get_string (plugin->priv->gconf_client,
- LINE_ARGUMENT_KEY,
- NULL);
-
- if (!data)
- data = g_strdup ("");
-
- gtk_entry_set_text (GTK_ENTRY (plugin->priv->line_argument_entry), data);
-
- g_free (data);
+ gchar *data;
+
+ /* Program name */
+ data = gconf_client_get_string (plugin->priv->gconf_client,
+ PROGRAM_NAME_KEY, NULL);
+
+ if (!data)
+ data = g_strdup ("meld");
+
+ gtk_entry_set_text (GTK_ENTRY (plugin->priv->program_name_entry), data);
+
+ g_free (data);
+
+ /* Line argument */
+ data = gconf_client_get_string (plugin->priv->gconf_client,
+ LINE_ARGUMENT_KEY, NULL);
+
+ if (!data)
+ data = g_strdup ("");
+
+ gtk_entry_set_text (GTK_ENTRY (plugin->priv->line_argument_entry), data);
+
+ g_free (data);
}
static GtkWidget *
-get_configuration_dialog (GtranslatorSubversionPlugin *plugin)
+get_configuration_dialog (GtranslatorSubversionPlugin * plugin)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "settings_dialog",
- NULL
- };
-
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
- "settings_dialog", &plugin->priv->dialog,
- "main_box", &plugin->priv->main_box,
- "program_name", &plugin->priv->program_name_entry,
- "line_argument", &plugin->priv->line_argument_entry,
- NULL);
-
- if(!ret)
- {
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plugin->priv->dialog)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return plugin->priv->dialog;
- }
-
- get_program (plugin);
-
- return plugin->priv->dialog;
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "settings_dialog",
+ NULL
+ };
+
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "settings_dialog",
+ &plugin->priv->dialog, "main_box",
+ &plugin->priv->main_box,
+ "program_name",
+ &plugin->priv->program_name_entry,
+ "line_argument",
+ &plugin->priv->line_argument_entry,
+ NULL);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plugin->priv->dialog)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return plugin->priv->dialog;
+ }
+
+ get_program (plugin);
+
+ return plugin->priv->dialog;
}
static void
-ok_button_pressed (GtranslatorSubversionPlugin *plugin)
+ok_button_pressed (GtranslatorSubversionPlugin * plugin)
{
- const gchar *program_name;
- const gchar *line_argument;
-
- /* We have to get the text from the entries */
- program_name = gtk_entry_get_text (GTK_ENTRY (plugin->priv->program_name_entry));
- line_argument = gtk_entry_get_text (GTK_ENTRY (plugin->priv->line_argument_entry));
-
- /* Now we store the data in gconf */
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- PROGRAM_NAME_KEY,
- NULL))
- return;
-
- gconf_client_set_string (plugin->priv->gconf_client,
- PROGRAM_NAME_KEY,
- program_name,
- NULL);
-
- if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
- LINE_ARGUMENT_KEY,
- NULL))
- return;
-
- gconf_client_set_string (plugin->priv->gconf_client,
- LINE_ARGUMENT_KEY,
- line_argument,
- NULL);
+ const gchar *program_name;
+ const gchar *line_argument;
+
+ /* We have to get the text from the entries */
+ program_name =
+ gtk_entry_get_text (GTK_ENTRY (plugin->priv->program_name_entry));
+ line_argument =
+ gtk_entry_get_text (GTK_ENTRY (plugin->priv->line_argument_entry));
+
+ /* Now we store the data in gconf */
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ PROGRAM_NAME_KEY, NULL))
+ return;
+
+ gconf_client_set_string (plugin->priv->gconf_client,
+ PROGRAM_NAME_KEY, program_name, NULL);
+
+ if (!gconf_client_key_is_writable (plugin->priv->gconf_client,
+ LINE_ARGUMENT_KEY, NULL))
+ return;
+
+ gconf_client_set_string (plugin->priv->gconf_client,
+ LINE_ARGUMENT_KEY, line_argument, NULL);
}
static void
-configure_dialog_response_cb (GtkWidget *widget,
- gint response,
- GtranslatorSubversionPlugin *plugin)
+configure_dialog_response_cb (GtkWidget * widget,
+ gint response,
+ GtranslatorSubversionPlugin * plugin)
{
- switch (response)
- {
- case GTK_RESPONSE_OK:
- {
- ok_button_pressed (plugin);
-
- gtk_widget_destroy (plugin->priv->dialog);
- break;
- }
- case GTK_RESPONSE_CANCEL:
- {
- gtk_widget_destroy (plugin->priv->dialog);
- }
- }
+ switch (response)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ ok_button_pressed (plugin);
+
+ gtk_widget_destroy (plugin->priv->dialog);
+ break;
+ }
+ case GTK_RESPONSE_CANCEL:
+ {
+ gtk_widget_destroy (plugin->priv->dialog);
+ }
+ }
}
static GtkWidget *
-impl_create_configure_dialog (GtranslatorPlugin *plugin)
+impl_create_configure_dialog (GtranslatorPlugin * plugin)
{
- GtkWidget *dialog;
-
- dialog = get_configuration_dialog (GTR_SUBVERSION_PLUGIN (plugin));
-
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (configure_dialog_response_cb),
- GTR_SUBVERSION_PLUGIN (plugin));
- g_signal_connect (dialog,
- "destroy",
- G_CALLBACK (gtk_widget_destroy),
- &dialog);
-
- return dialog;
+ GtkWidget *dialog;
+
+ dialog = get_configuration_dialog (GTR_SUBVERSION_PLUGIN (plugin));
+
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (configure_dialog_response_cb),
+ GTR_SUBVERSION_PLUGIN (plugin));
+ g_signal_connect (dialog,
+ "destroy", G_CALLBACK (gtk_widget_destroy), &dialog);
+
+ return dialog;
}
static void
-gtranslator_subversion_plugin_class_init (GtranslatorSubversionPluginClass *klass)
+gtranslator_subversion_plugin_class_init (GtranslatorSubversionPluginClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_subversion_plugin_finalize;
- object_class->finalize = gtranslator_subversion_plugin_finalize;
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
+ plugin_class->create_configure_dialog = impl_create_configure_dialog;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->update_ui = impl_update_ui;
- plugin_class->create_configure_dialog = impl_create_configure_dialog;
-
- g_type_class_add_private (object_class, sizeof (GtranslatorSubversionPluginPrivate));
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorSubversionPluginPrivate));
}
diff --git a/plugins/subversion/subversion-plugin.h b/plugins/subversion/subversion-plugin.h
index 5ad8e59..001839d 100644
--- a/plugins/subversion/subversion-plugin.h
+++ b/plugins/subversion/subversion-plugin.h
@@ -25,7 +25,6 @@
#include "plugin.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,47 +34,47 @@ G_BEGIN_DECLS
#define GTR_IS_SUBVERSION_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_SUBVERSION_PLUGIN))
#define GTR_IS_SUBVERSION_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_SUBVERSION_PLUGIN))
#define GTR_SUBVERSION_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_SUBVERSION_PLUGIN_PLUGIN, GtranslatorSubversionPluginClass))
-
#define UI_FILE DATADIR "/subversion.ui"
-
/* Gconf keys */
#define SUBVERSION_BASE_KEY "/apps/gtranslator/plugins/subversion"
#define PROGRAM_NAME_KEY SUBVERSION_BASE_KEY "/program_name"
#define LINE_ARGUMENT_KEY SUBVERSION_BASE_KEY "/line_argument"
-
/* Private structure type */
-typedef struct _GtranslatorSubversionPluginPrivate GtranslatorSubversionPluginPrivate;
+typedef struct _GtranslatorSubversionPluginPrivate
+ GtranslatorSubversionPluginPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorSubversionPlugin GtranslatorSubversionPlugin;
+typedef struct _GtranslatorSubversionPlugin GtranslatorSubversionPlugin;
struct _GtranslatorSubversionPlugin
{
- GtranslatorPlugin parent_instance;
+ GtranslatorPlugin parent_instance;
- GtranslatorSubversionPluginPrivate *priv;
+ GtranslatorSubversionPluginPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorSubversionPluginClass GtranslatorSubversionPluginClass;
+typedef struct _GtranslatorSubversionPluginClass
+ GtranslatorSubversionPluginClass;
struct _GtranslatorSubversionPluginClass
{
- GtranslatorPluginClass parent_class;
+ GtranslatorPluginClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_subversion_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_subversion_plugin_get_type (void)
+ G_GNUC_CONST;
/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+ G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule * module);
G_END_DECLS
-
#endif /* __GTR_SUBVERSION_PLUGIN_H__ */
diff --git a/plugins/subversion/subversion-utils.c b/plugins/subversion/subversion-utils.c
index 9e7698b..4881d4e 100644
--- a/plugins/subversion/subversion-utils.c
+++ b/plugins/subversion/subversion-utils.c
@@ -35,49 +35,48 @@
typedef struct _PulseProgressData
{
- GtranslatorStatusbar *status;
- gchar *text;
-}PulseProgressData;
+ GtranslatorStatusbar *status;
+ gchar *text;
+} PulseProgressData;
void
-subversion_utils_report_errors (GtranslatorWindow *window,
- GtranslatorCommand *command,
+subversion_utils_report_errors (GtranslatorWindow * window,
+ GtranslatorCommand * command,
guint error_code)
{
- GtkWidget *dialog;
-
- if (error_code)
- {
- gchar *message;
-
- message = gtranslator_command_get_error_message (command);
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", message);
- g_free (message);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
+ GtkWidget *dialog;
+
+ if (error_code)
+ {
+ gchar *message;
+
+ message = gtranslator_command_get_error_message (command);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE, "%s", message);
+ g_free (message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
}
-gchar *
-subversion_utils_get_log_from_textview (GtkWidget* textview)
+gchar *
+subversion_utils_get_log_from_textview (GtkWidget * textview)
{
- gchar* log;
- GtkTextBuffer* textbuf;
- GtkTextIter iterbegin, iterend;
- gchar* escaped_log;
-
- textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
- gtk_text_buffer_get_start_iter(textbuf, &iterbegin);
- gtk_text_buffer_get_end_iter(textbuf, &iterend) ;
- log = gtk_text_buffer_get_text(textbuf, &iterbegin, &iterend, FALSE);
+ gchar *log;
+ GtkTextBuffer *textbuf;
+ GtkTextIter iterbegin, iterend;
+ gchar *escaped_log;
- escaped_log = gtranslator_utils_escape_search_text (log);
- return escaped_log;
+ textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
+ gtk_text_buffer_get_start_iter (textbuf, &iterbegin);
+ gtk_text_buffer_get_end_iter (textbuf, &iterend);
+ log = gtk_text_buffer_get_text (textbuf, &iterbegin, &iterend, FALSE);
+
+ escaped_log = gtranslator_utils_escape_search_text (log);
+ return escaped_log;
}
/*guint
@@ -95,74 +94,71 @@ subversion_utils_status_bar_progress_pulse (GtranslatorWindow *window, gchar *te
}*/
void
-subversion_utils_from_file_to_file (GInputStream *istream,
- GOutputStream *ostream)
+subversion_utils_from_file_to_file (GInputStream * istream,
+ GOutputStream * ostream)
{
- gsize bytes = 1;
- GError *error = NULL;
- gchar buffer[4096];
-
- while (bytes != 0 && bytes != -1)
- {
- bytes = g_input_stream_read (istream, buffer,
- sizeof (buffer),
- NULL, &error);
- if (error)
- break;
-
- g_output_stream_write (ostream, buffer,
- bytes,
- NULL, &error);
- if (error)
- break;
- }
-
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- if (!g_output_stream_close (ostream, NULL, &error))
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
- if (!g_input_stream_close (istream, NULL, &error))
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ gsize bytes = 1;
+ GError *error = NULL;
+ gchar buffer[4096];
+
+ while (bytes != 0 && bytes != -1)
+ {
+ bytes = g_input_stream_read (istream, buffer,
+ sizeof (buffer), NULL, &error);
+ if (error)
+ break;
+
+ g_output_stream_write (ostream, buffer, bytes, NULL, &error);
+ if (error)
+ break;
+ }
+
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ if (!g_output_stream_close (ostream, NULL, &error))
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ if (!g_input_stream_close (istream, NULL, &error))
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
gchar *
-subversion_utils_get_changelog_entry_from_view (GtkWidget *view)
+subversion_utils_get_changelog_entry_from_view (GtkWidget * view)
{
- gchar *log;
- GtranslatorProfile *profile;
- gchar *name;
- gchar *email;
- gchar *changelog_entry;
- gchar *date;
- gchar *code;
-
- log = subversion_utils_get_log_from_textview (view);
-
- profile = gtranslator_application_get_active_profile (GTR_APP);
- name = gtranslator_profile_get_author_name (profile);
- email = gtranslator_profile_get_author_email (profile);
- code = gtranslator_profile_get_language_code (profile);
- date = gtranslator_utils_get_current_date ();
-
- changelog_entry = g_strdup_printf ("%s %s <%s>\n"
- "\n\t * %s.po: %s\n\n", date, name, email,
- code, log);
- g_free (log);
- g_free (date);
- //g_free (name);
- //g_free (email);
-
- return changelog_entry;
+ gchar *log;
+ GtranslatorProfile *profile;
+ gchar *name;
+ gchar *email;
+ gchar *changelog_entry;
+ gchar *date;
+ gchar *code;
+
+ log = subversion_utils_get_log_from_textview (view);
+
+ profile = gtranslator_application_get_active_profile (GTR_APP);
+ name = gtranslator_profile_get_author_name (profile);
+ email = gtranslator_profile_get_author_email (profile);
+ code = gtranslator_profile_get_language_code (profile);
+ date = gtranslator_utils_get_current_date ();
+
+ changelog_entry = g_strdup_printf ("%s %s <%s>\n"
+ "\n\t * %s.po: %s\n\n", date, name,
+ email, code, log);
+ g_free (log);
+ g_free (date);
+ //g_free (name);
+ //g_free (email);
+
+ return changelog_entry;
}
diff --git a/plugins/subversion/subversion-utils.h b/plugins/subversion/subversion-utils.h
index 7fe71b9..a97353b 100644
--- a/plugins/subversion/subversion-utils.h
+++ b/plugins/subversion/subversion-utils.h
@@ -27,15 +27,15 @@
#include "window.h"
#include "command.h"
-void subversion_utils_report_errors (GtranslatorWindow *window,
- GtranslatorCommand *command,
- guint error_code);
+void subversion_utils_report_errors (GtranslatorWindow * window,
+ GtranslatorCommand * command,
+ guint error_code);
-gchar *subversion_utils_get_log_from_textview (GtkWidget* textview);
+gchar *subversion_utils_get_log_from_textview (GtkWidget * textview);
-void subversion_utils_from_file_to_file (GInputStream *istream,
- GOutputStream *ostream);
+void subversion_utils_from_file_to_file (GInputStream * istream,
+ GOutputStream * ostream);
-gchar *subversion_utils_get_changelog_entry_from_view (GtkWidget *view);
+gchar *subversion_utils_get_changelog_entry_from_view (GtkWidget * view);
#endif
diff --git a/plugins/subversion/svn-add-command.c b/plugins/subversion/svn-add-command.c
index 1f7d607..3613d06 100644
--- a/plugins/subversion/svn-add-command.c
+++ b/plugins/subversion/svn-add-command.c
@@ -29,91 +29,92 @@
struct _SvnAddCommandPriv
{
- gchar *path;
- gboolean force;
- gboolean recursive;
+ gchar *path;
+ gboolean force;
+ gboolean recursive;
};
G_DEFINE_TYPE (SvnAddCommand, svn_add_command, SVN_TYPE_COMMAND);
static void
-svn_add_command_init (SvnAddCommand *self)
+svn_add_command_init (SvnAddCommand * self)
{
- self->priv = g_new0 (SvnAddCommandPriv, 1);
+ self->priv = g_new0 (SvnAddCommandPriv, 1);
}
static void
-svn_add_command_finalize (GObject *object)
+svn_add_command_finalize (GObject * object)
{
- SvnAddCommand *self;
-
- self = SVN_ADD_COMMAND (object);
-
- g_free (self->priv->path);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_add_command_parent_class)->finalize (object);
+ SvnAddCommand *self;
+
+ self = SVN_ADD_COMMAND (object);
+
+ g_free (self->priv->path);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_add_command_parent_class)->finalize (object);
}
static guint
-svn_add_command_run (GtranslatorCommand *command)
+svn_add_command_run (GtranslatorCommand * command)
{
- SvnAddCommand *self;
- SvnCommand *svn_command;
- svn_error_t *error;
- svn_depth_t depth;
-
- self = SVN_ADD_COMMAND (command);
- svn_command = SVN_COMMAND (command);
-
- if (self->priv->recursive == TRUE)
- depth = svn_depth_infinity;
- else depth = svn_depth_empty;
-
- error = svn_client_add4 (self->priv->path,
- depth,
- self->priv->force,
- FALSE,
- FALSE,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- return 0;
+ SvnAddCommand *self;
+ SvnCommand *svn_command;
+ svn_error_t *error;
+ svn_depth_t depth;
+
+ self = SVN_ADD_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+
+ if (self->priv->recursive == TRUE)
+ depth = svn_depth_infinity;
+ else
+ depth = svn_depth_empty;
+
+ error = svn_client_add4 (self->priv->path,
+ depth,
+ self->priv->force,
+ FALSE,
+ FALSE,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ return 0;
}
static void
-svn_add_command_class_init (SvnAddCommandClass *klass)
+svn_add_command_class_init (SvnAddCommandClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_add_command_finalize;
- command_class->run = svn_add_command_run;
+ object_class->finalize = svn_add_command_finalize;
+ command_class->run = svn_add_command_run;
}
SvnAddCommand *
-svn_add_command_new (const gchar *path, gboolean force, gboolean recursive)
+svn_add_command_new (const gchar * path, gboolean force, gboolean recursive)
{
- SvnAddCommand *self;
-
- self = g_object_new (SVN_TYPE_ADD_COMMAND, NULL);
- self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
- path);
- self->priv->force = force;
- self->priv->recursive = recursive;
-
- return self;
+ SvnAddCommand *self;
+
+ self = g_object_new (SVN_TYPE_ADD_COMMAND, NULL);
+ self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
+ path);
+ self->priv->force = force;
+ self->priv->recursive = recursive;
+
+ return self;
}
void
-svn_add_command_destroy (SvnAddCommand *self)
+svn_add_command_destroy (SvnAddCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
diff --git a/plugins/subversion/svn-add-command.h b/plugins/subversion/svn-add-command.h
index d8ff5d0..8a03b91 100644
--- a/plugins/subversion/svn-add-command.h
+++ b/plugins/subversion/svn-add-command.h
@@ -32,34 +32,34 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_ADD_COMMAND (svn_add_command_get_type ())
#define SVN_ADD_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_ADD_COMMAND, SvnAddCommand))
#define SVN_ADD_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_ADD_COMMAND, SvnAddCommandClass))
#define SVN_IS_ADD_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_ADD_COMMAND))
#define SVN_IS_ADD_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_ADD_COMMAND))
#define SVN_ADD_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_ADD_COMMAND, SvnAddCommandClass))
-
typedef struct _SvnAddCommandClass SvnAddCommandClass;
typedef struct _SvnAddCommand SvnAddCommand;
typedef struct _SvnAddCommandPriv SvnAddCommandPriv;
struct _SvnAddCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnAddCommand
{
- SvnCommand parent_instance;
-
- SvnAddCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnAddCommandPriv *priv;
};
-GType svn_add_command_get_type (void) G_GNUC_CONST;
-SvnAddCommand * svn_add_command_new (const gchar *path, gboolean force, gboolean recursive);
-void svn_add_command_destroy (SvnAddCommand *self);
+GType
+svn_add_command_get_type (void)
+ G_GNUC_CONST;
+ SvnAddCommand *svn_add_command_new (const gchar * path, gboolean force,
+ gboolean recursive);
+ void svn_add_command_destroy (SvnAddCommand * self);
G_END_DECLS
-
#endif /* _SVN_ADD_COMMAND_H_ */
diff --git a/plugins/subversion/svn-cat-command.c b/plugins/subversion/svn-cat-command.c
index cac8997..6673140 100644
--- a/plugins/subversion/svn-cat-command.c
+++ b/plugins/subversion/svn-cat-command.c
@@ -26,144 +26,144 @@
struct _SvnCatCommandPriv
{
- gchar *path;
- glong revision;
- GQueue *output;
+ gchar *path;
+ glong revision;
+ GQueue *output;
};
G_DEFINE_TYPE (SvnCatCommand, svn_cat_command, SVN_TYPE_COMMAND);
static void
-svn_cat_command_init (SvnCatCommand *self)
+svn_cat_command_init (SvnCatCommand * self)
{
- self->priv = g_new0 (SvnCatCommandPriv, 1);
+ self->priv = g_new0 (SvnCatCommandPriv, 1);
}
static void
-svn_cat_command_finalize (GObject *object)
+svn_cat_command_finalize (GObject * object)
{
- SvnCatCommand *self;
- GList *current_output;
-
- self = SVN_CAT_COMMAND (object);
-
- g_free (self->priv->path);
-
- current_output = self->priv->output->head;
-
- while (current_output)
- {
- g_free (current_output->data);
- current_output = g_list_next (current_output);
- }
-
- g_queue_free (self->priv->output);
-
- g_free (self->priv);
+ SvnCatCommand *self;
+ GList *current_output;
+
+ self = SVN_CAT_COMMAND (object);
+
+ g_free (self->priv->path);
+
+ current_output = self->priv->output->head;
+
+ while (current_output)
+ {
+ g_free (current_output->data);
+ current_output = g_list_next (current_output);
+ }
- G_OBJECT_CLASS (svn_cat_command_parent_class)->finalize (object);
+ g_queue_free (self->priv->output);
+
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_cat_command_parent_class)->finalize (object);
}
static guint
-svn_cat_command_run (GtranslatorCommand *command)
+svn_cat_command_run (GtranslatorCommand * command)
{
- SvnCatCommand *self;
- SvnCommand *svn_command;
- svn_opt_revision_t revision;
- svn_opt_revision_t peg_revision;
- svn_stream_t *cat_stream;
- apr_file_t *cat_input;
- apr_file_t *cat_output;
- apr_size_t read_size;
- gchar *line;
- svn_error_t *error;
- apr_status_t apr_error;
-
- self = SVN_CAT_COMMAND (command);
- svn_command = SVN_COMMAND (command);
-
- apr_file_pipe_create (&cat_output, &cat_input,
- svn_command_get_pool (svn_command));
- apr_file_pipe_timeout_set (cat_output, 0);
- apr_file_pipe_timeout_set (cat_input, 0);
- cat_stream = svn_stream_from_aprfile2 (cat_input, FALSE,
- svn_command_get_pool (svn_command));
-
- revision.kind = svn_opt_revision_base;
- revision.value.number = self->priv->revision;
- peg_revision.kind = svn_opt_revision_unspecified;
-
- error = svn_client_cat2 (cat_stream,
- self->priv->path,
- &peg_revision,
- &revision,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- while (apr_file_eof (cat_output) != APR_EOF)
+ SvnCatCommand *self;
+ SvnCommand *svn_command;
+ svn_opt_revision_t revision;
+ svn_opt_revision_t peg_revision;
+ svn_stream_t *cat_stream;
+ apr_file_t *cat_input;
+ apr_file_t *cat_output;
+ apr_size_t read_size;
+ gchar *line;
+ svn_error_t *error;
+ apr_status_t apr_error;
+
+ self = SVN_CAT_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+
+ apr_file_pipe_create (&cat_output, &cat_input,
+ svn_command_get_pool (svn_command));
+ apr_file_pipe_timeout_set (cat_output, 0);
+ apr_file_pipe_timeout_set (cat_input, 0);
+ cat_stream = svn_stream_from_aprfile2 (cat_input, FALSE,
+ svn_command_get_pool (svn_command));
+
+ revision.kind = svn_opt_revision_base;
+ revision.value.number = self->priv->revision;
+ peg_revision.kind = svn_opt_revision_unspecified;
+
+ error = svn_client_cat2 (cat_stream,
+ self->priv->path,
+ &peg_revision,
+ &revision,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ while (apr_file_eof (cat_output) != APR_EOF)
+ {
+ read_size = 80;
+ line = g_new0 (gchar, (read_size + 1));
+
+ apr_error = apr_file_read (cat_output, line, &read_size);
+
+ if (apr_error)
+ break;
+
+ if (strlen (line))
{
- read_size = 80;
- line = g_new0 (gchar, (read_size + 1));
-
- apr_error = apr_file_read (cat_output, line, &read_size);
-
- if (apr_error)
- break;
-
- if (strlen (line))
- {
- gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
- g_queue_push_tail (self->priv->output, g_strdup (line));
- gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
-
- g_free (line);
-
- gtranslator_command_notify_data_arrived (command);
- }
+ gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
+ g_queue_push_tail (self->priv->output, g_strdup (line));
+ gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
+
+ g_free (line);
+
+ gtranslator_command_notify_data_arrived (command);
}
-
- return 0;
+ }
+
+ return 0;
}
static void
-svn_cat_command_class_init (SvnCatCommandClass *klass)
+svn_cat_command_class_init (SvnCatCommandClass * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass* command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_cat_command_finalize;
- command_class->run = svn_cat_command_run;
+ object_class->finalize = svn_cat_command_finalize;
+ command_class->run = svn_cat_command_run;
}
SvnCatCommand *
-svn_cat_command_new (const gchar *path, glong revision)
+svn_cat_command_new (const gchar * path, glong revision)
{
- SvnCatCommand *self;
-
- self = g_object_new (SVN_TYPE_CAT_COMMAND, NULL);
- self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
- path);
- self->priv->revision = revision;
- self->priv->output = g_queue_new ();
-
- return self;
+ SvnCatCommand *self;
+
+ self = g_object_new (SVN_TYPE_CAT_COMMAND, NULL);
+ self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
+ path);
+ self->priv->revision = revision;
+ self->priv->output = g_queue_new ();
+
+ return self;
}
void
-svn_cat_command_destroy (SvnCatCommand *self)
+svn_cat_command_destroy (SvnCatCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
GQueue *
-svn_cat_command_get_output (SvnCatCommand *self)
+svn_cat_command_get_output (SvnCatCommand * self)
{
- return self->priv->output;
+ return self->priv->output;
}
diff --git a/plugins/subversion/svn-cat-command.h b/plugins/subversion/svn-cat-command.h
index 68414b1..d8626b3 100644
--- a/plugins/subversion/svn-cat-command.h
+++ b/plugins/subversion/svn-cat-command.h
@@ -29,35 +29,34 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_CAT_COMMAND (svn_cat_command_get_type ())
#define SVN_CAT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_CAT_COMMAND, SvnCatCommand))
#define SVN_CAT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_CAT_COMMAND, SvnCatCommandClass))
#define SVN_IS_CAT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_CAT_COMMAND))
#define SVN_IS_CAT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_CAT_COMMAND))
#define SVN_CAT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_CAT_COMMAND, SvnCatCommandClass))
-
typedef struct _SvnCatCommandClass SvnCatCommandClass;
typedef struct _SvnCatCommand SvnCatCommand;
typedef struct _SvnCatCommandPriv SvnCatCommandPriv;
struct _SvnCatCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnCatCommand
{
- SvnCommand parent_instance;
-
- SvnCatCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnCatCommandPriv *priv;
};
-GType svn_cat_command_get_type (void) G_GNUC_CONST;
-SvnCatCommand * svn_cat_command_new (const gchar *path, glong revision);
-void svn_cat_command_destroy (SvnCatCommand *self);
-GQueue *svn_cat_command_get_output (SvnCatCommand *self);
+GType
+svn_cat_command_get_type (void)
+ G_GNUC_CONST;
+ SvnCatCommand *svn_cat_command_new (const gchar * path, glong revision);
+ void svn_cat_command_destroy (SvnCatCommand * self);
+ GQueue *svn_cat_command_get_output (SvnCatCommand * self);
G_END_DECLS
-
#endif /* _SVN_CAT_COMMAND_H_ */
diff --git a/plugins/subversion/svn-checkout-command.c b/plugins/subversion/svn-checkout-command.c
index a9af642..e0b6eac 100644
--- a/plugins/subversion/svn-checkout-command.c
+++ b/plugins/subversion/svn-checkout-command.c
@@ -20,98 +20,98 @@
struct _SvnCheckoutCommandPriv
{
- gchar *url;
- gchar *path;
+ gchar *url;
+ gchar *path;
};
G_DEFINE_TYPE (SvnCheckoutCommand, svn_checkout_command, SVN_TYPE_COMMAND);
static void
-svn_checkout_command_init (SvnCheckoutCommand *self)
-{
- self->priv = g_new0 (SvnCheckoutCommandPriv, 1);
+svn_checkout_command_init (SvnCheckoutCommand * self)
+{
+ self->priv = g_new0 (SvnCheckoutCommandPriv, 1);
}
static void
-svn_checkout_command_finalize (GObject *object)
+svn_checkout_command_finalize (GObject * object)
{
- SvnCheckoutCommand *self;
-
- self = SVN_CHECKOUT_COMMAND (object);
-
- g_free (self->priv->url);
- g_free (self->priv->path);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_checkout_command_parent_class)->finalize (object);
+ SvnCheckoutCommand *self;
+
+ self = SVN_CHECKOUT_COMMAND (object);
+
+ g_free (self->priv->url);
+ g_free (self->priv->path);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_checkout_command_parent_class)->finalize (object);
}
static guint
-svn_checkout_command_run (GtranslatorCommand *command)
+svn_checkout_command_run (GtranslatorCommand * command)
{
- SvnCheckoutCommand *self;
- SvnCommand *svn_command;
- svn_opt_revision_t revision;
- svn_opt_revision_t peg_revision;
- svn_revnum_t revnum;
- svn_error_t *error = NULL;
- svn_revnum_t revision_number;
- gchar *revision_message;
-
- self = SVN_CHECKOUT_COMMAND (command);
- svn_command = SVN_COMMAND (command);
-
- revision.kind = svn_opt_revision_head;
- peg_revision.kind = svn_opt_revision_unspecified;
-
- error = svn_client_checkout3 (&revnum,
- self->priv->url,
- self->priv->path,
- &peg_revision,
- &revision,
- svn_depth_unknown,
- TRUE,
- FALSE,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- return 0;
+ SvnCheckoutCommand *self;
+ SvnCommand *svn_command;
+ svn_opt_revision_t revision;
+ svn_opt_revision_t peg_revision;
+ svn_revnum_t revnum;
+ svn_error_t *error = NULL;
+ svn_revnum_t revision_number;
+ gchar *revision_message;
+
+ self = SVN_CHECKOUT_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+
+ revision.kind = svn_opt_revision_head;
+ peg_revision.kind = svn_opt_revision_unspecified;
+
+ error = svn_client_checkout3 (&revnum,
+ self->priv->url,
+ self->priv->path,
+ &peg_revision,
+ &revision,
+ svn_depth_unknown,
+ TRUE,
+ FALSE,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ return 0;
}
static void
-svn_checkout_command_class_init (SvnCheckoutCommandClass *klass)
+svn_checkout_command_class_init (SvnCheckoutCommandClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_checkout_command_finalize;
- command_class->run = svn_checkout_command_run;
+ object_class->finalize = svn_checkout_command_finalize;
+ command_class->run = svn_checkout_command_run;
}
SvnCheckoutCommand *
-svn_checkout_command_new (const gchar *url, const gchar *path)
+svn_checkout_command_new (const gchar * url, const gchar * path)
{
- SvnCheckoutCommand *self;
-
- self = g_object_new (SVN_TYPE_CHECKOUT_COMMAND, NULL);
-
- self->priv->url = svn_command_make_canonical_path (SVN_COMMAND (self),
- (gchar*)url);
- self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
- (gchar*)path);
-
- return self;
+ SvnCheckoutCommand *self;
+
+ self = g_object_new (SVN_TYPE_CHECKOUT_COMMAND, NULL);
+
+ self->priv->url = svn_command_make_canonical_path (SVN_COMMAND (self),
+ (gchar *) url);
+ self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
+ (gchar *) path);
+
+ return self;
}
void
-svn_checkout_command_destroy (SvnCheckoutCommand *self)
+svn_checkout_command_destroy (SvnCheckoutCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
diff --git a/plugins/subversion/svn-checkout-command.h b/plugins/subversion/svn-checkout-command.h
index 990d90e..4f51969 100644
--- a/plugins/subversion/svn-checkout-command.h
+++ b/plugins/subversion/svn-checkout-command.h
@@ -25,34 +25,34 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_CHECKOUT_COMMAND (svn_checkout_command_get_type ())
#define SVN_CHECKOUT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_CHECKOUT_COMMAND, SvnCheckoutCommand))
#define SVN_CHECKOUT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_CHECKOUT_COMMAND, SvnCheckoutCommandClass))
#define SVN_IS_CHECKOUT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_CHECKOUT_COMMAND))
#define SVN_IS_CHECKOUT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_CHECKOUT_COMMAND))
#define SVN_CHECKOUT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_CHECKOUT_COMMAND, SvnCheckoutCommandClass))
-
typedef struct _SvnCheckoutCommandClass SvnCheckoutCommandClass;
typedef struct _SvnCheckoutCommand SvnCheckoutCommand;
typedef struct _SvnCheckoutCommandPriv SvnCheckoutCommandPriv;
struct _SvnCheckoutCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnCheckoutCommand
{
- SvnCommand parent_instance;
-
- SvnCheckoutCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnCheckoutCommandPriv *priv;
};
-GType svn_checkout_command_get_type (void) G_GNUC_CONST;
-SvnCheckoutCommand * svn_checkout_command_new (const gchar *url, const gchar *path);
-void svn_checkout_command_destroy (SvnCheckoutCommand *self);
+GType
+svn_checkout_command_get_type (void)
+ G_GNUC_CONST;
+ SvnCheckoutCommand *svn_checkout_command_new (const gchar * url,
+ const gchar * path);
+ void svn_checkout_command_destroy (SvnCheckoutCommand * self);
G_END_DECLS
-
#endif /* _SVN_CHECKOUT_COMMAND_H_ */
diff --git a/plugins/subversion/svn-command.c b/plugins/subversion/svn-command.c
index d045a38..5ef6762 100644
--- a/plugins/subversion/svn-command.c
+++ b/plugins/subversion/svn-command.c
@@ -28,40 +28,40 @@
struct _SvnCommandPriv
{
- svn_client_ctx_t *client_context;
- apr_pool_t *pool;
- GQueue *info_messages;
- GMutex *ui_lock;
- gboolean main_thread_has_ui_lock;
+ svn_client_ctx_t *client_context;
+ apr_pool_t *pool;
+ GQueue *info_messages;
+ GMutex *ui_lock;
+ gboolean main_thread_has_ui_lock;
};
G_DEFINE_TYPE (SvnCommand, svn_command, GTR_TYPE_ASYNC_COMMAND);
static gboolean
-svn_command_acquire_ui_lock (SvnCommand *self)
+svn_command_acquire_ui_lock (SvnCommand * self)
{
- gboolean got_lock;
-
- if (!self->priv->main_thread_has_ui_lock)
- {
- got_lock = g_mutex_trylock (self->priv->ui_lock);
-
- if (got_lock)
- self->priv->main_thread_has_ui_lock = TRUE;
-
- return !got_lock;
- }
- else
- return FALSE;
+ gboolean got_lock;
+
+ if (!self->priv->main_thread_has_ui_lock)
+ {
+ got_lock = g_mutex_trylock (self->priv->ui_lock);
+
+ if (got_lock)
+ self->priv->main_thread_has_ui_lock = TRUE;
+
+ return !got_lock;
+ }
+ else
+ return FALSE;
}
static gboolean
-svn_command_release_ui_lock (GMutex *ui_lock)
+svn_command_release_ui_lock (GMutex * ui_lock)
{
- g_mutex_unlock (ui_lock);
- g_mutex_free (ui_lock);
-
- return FALSE;
+ g_mutex_unlock (ui_lock);
+ g_mutex_free (ui_lock);
+
+ return FALSE;
}
/* Auth functions */
@@ -73,646 +73,640 @@ svn_command_release_ui_lock (GMutex *ui_lock)
/* svn_auth_simple_prompt_func_cb argumements */
typedef struct
{
- svn_auth_cred_simple_t **cred;
- void *baton;
- gchar *realm;
- gchar *username;
- svn_boolean_t may_save;
- apr_pool_t *pool;
- svn_error_t *error;
+ svn_auth_cred_simple_t **cred;
+ void *baton;
+ gchar *realm;
+ gchar *username;
+ svn_boolean_t may_save;
+ apr_pool_t *pool;
+ svn_error_t *error;
} SimplePromptArgs;
/* svn_auth_ssl_server_trust_prompt_func_cb arguements */
typedef struct
{
- svn_auth_cred_ssl_server_trust_t **cred;
- void *baton;
- gchar *realm;
- apr_uint32_t failures;
- svn_auth_ssl_server_cert_info_t *cert_info;
- svn_boolean_t may_save;
- apr_pool_t *pool;
- svn_error_t *error;
+ svn_auth_cred_ssl_server_trust_t **cred;
+ void *baton;
+ gchar *realm;
+ apr_uint32_t failures;
+ svn_auth_ssl_server_cert_info_t *cert_info;
+ svn_boolean_t may_save;
+ apr_pool_t *pool;
+ svn_error_t *error;
} SSLServerTrustArgs;
static gboolean
-simple_prompt (SimplePromptArgs *args)
+simple_prompt (SimplePromptArgs * args)
{
- GtkWidget* svn_user_auth;
- GtkWidget* auth_realm;
- GtkWidget* username_entry;
- GtkWidget* password_entry;
- GtkWidget* remember_pwd;
- GtkWidget *error_widget;
- gboolean ret;
- svn_error_t *err = NULL;
- SvnCommand *svn_command;
- gchar *root_objects [] = {
- "svn_user_auth",
- NULL
- };
-
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
- "svn_user_auth", &svn_user_auth,
- "auth_realm", &auth_realm,
- "username_entry", &username_entry,
- "password_entry", &password_entry,
- "remember_pwd", &remember_pwd,
- NULL);
-
- if(!ret)
- {
- GtkWidget *dlg = gtk_dialog_new ();
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
- gtk_dialog_run (GTK_DIALOG (dlg));
- gtk_widget_destroy (dlg);
-
- return FALSE;
- }
-
- gtk_dialog_set_default_response (GTK_DIALOG (svn_user_auth),
- GTK_RESPONSE_OK);
-
- if (args->realm)
- gtk_label_set_text (GTK_LABEL (auth_realm), args->realm);
- if (args->username)
- {
- gtk_entry_set_text (GTK_ENTRY (username_entry), args->username);
- gtk_widget_grab_focus (password_entry);
- }
- if (!args->may_save)
- gtk_widget_set_sensitive(remember_pwd, FALSE);
-
- /* Then the dialog is prompted to user and when user clicks ok, the
- * values entered, i.e username, password and remember password (true
- * by default) should be used to initialized the memebers below. If the
- * user cancels the dialog, I think we return an error struct
- * appropriately initialized. -- naba
- */
-
- switch (gtk_dialog_run (GTK_DIALOG (svn_user_auth)))
- {
- case GTK_RESPONSE_OK:
- {
- *args->cred = apr_pcalloc (args->pool, sizeof(*(args->cred)));
- (*(args->cred))->may_save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
- (remember_pwd));
- (*(args->cred))->username = apr_pstrdup (args->pool,
- gtk_entry_get_text(GTK_ENTRY(username_entry)));
- (*(args->cred))->password = apr_pstrdup (args->pool,
- gtk_entry_get_text(GTK_ENTRY(password_entry)));
-
- err = SVN_NO_ERROR;
- break;
- }
- default:
- err = svn_error_create (SVN_ERR_AUTHN_CREDS_UNAVAILABLE, NULL,
- _("Authentication canceled"));
-
- break;
- }
- gtk_widget_destroy (svn_user_auth);
- args->error = err;
-
- /* Release because main thread should already have the lock */
- svn_command = SVN_COMMAND (args->baton);
- svn_command_unlock_ui (svn_command);
-
- return FALSE;
+ GtkWidget *svn_user_auth;
+ GtkWidget *auth_realm;
+ GtkWidget *username_entry;
+ GtkWidget *password_entry;
+ GtkWidget *remember_pwd;
+ GtkWidget *error_widget;
+ gboolean ret;
+ svn_error_t *err = NULL;
+ SvnCommand *svn_command;
+ gchar *root_objects[] = {
+ "svn_user_auth",
+ NULL
+ };
+
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "svn_user_auth", &svn_user_auth,
+ "auth_realm", &auth_realm,
+ "username_entry", &username_entry,
+ "password_entry", &password_entry,
+ "remember_pwd", &remember_pwd,
+ NULL);
+
+ if (!ret)
+ {
+ GtkWidget *dlg = gtk_dialog_new ();
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+ gtk_dialog_run (GTK_DIALOG (dlg));
+ gtk_widget_destroy (dlg);
+
+ return FALSE;
+ }
+
+ gtk_dialog_set_default_response (GTK_DIALOG (svn_user_auth),
+ GTK_RESPONSE_OK);
+
+ if (args->realm)
+ gtk_label_set_text (GTK_LABEL (auth_realm), args->realm);
+ if (args->username)
+ {
+ gtk_entry_set_text (GTK_ENTRY (username_entry), args->username);
+ gtk_widget_grab_focus (password_entry);
+ }
+ if (!args->may_save)
+ gtk_widget_set_sensitive (remember_pwd, FALSE);
+
+ /* Then the dialog is prompted to user and when user clicks ok, the
+ * values entered, i.e username, password and remember password (true
+ * by default) should be used to initialized the memebers below. If the
+ * user cancels the dialog, I think we return an error struct
+ * appropriately initialized. -- naba
+ */
+
+ switch (gtk_dialog_run (GTK_DIALOG (svn_user_auth)))
+ {
+ case GTK_RESPONSE_OK:
+ {
+ *args->cred = apr_pcalloc (args->pool, sizeof (*(args->cred)));
+ (*(args->cred))->may_save =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pwd));
+ (*(args->cred))->username =
+ apr_pstrdup (args->pool,
+ gtk_entry_get_text (GTK_ENTRY (username_entry)));
+ (*(args->cred))->password =
+ apr_pstrdup (args->pool,
+ gtk_entry_get_text (GTK_ENTRY (password_entry)));
+
+ err = SVN_NO_ERROR;
+ break;
+ }
+ default:
+ err = svn_error_create (SVN_ERR_AUTHN_CREDS_UNAVAILABLE, NULL,
+ _("Authentication canceled"));
+
+ break;
+ }
+ gtk_widget_destroy (svn_user_auth);
+ args->error = err;
+
+ /* Release because main thread should already have the lock */
+ svn_command = SVN_COMMAND (args->baton);
+ svn_command_unlock_ui (svn_command);
+
+ return FALSE;
}
static gboolean
-ssl_server_trust_prompt (SSLServerTrustArgs *args)
+ssl_server_trust_prompt (SSLServerTrustArgs * args)
{
- GtkWidget* svn_server_trust;
- GtkWidget* auth_realm;
- GtkWidget* server_info;
- GtkWidget* remember_check;
- GtkWidget *error_widget;
- gboolean ret;
- svn_error_t *err = NULL;
- gchar* info;
- SvnCommand *svn_command;
- gchar *root_objects [] = {
- "svn_server_trust",
- NULL
- };
-
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
- "svn_server_trust", &svn_server_trust,
- "realm_label", &auth_realm,
- "server_info_label", &server_info,
- "remember_check", &remember_check,
- NULL);
-
- if(!ret)
- {
- GtkWidget *dlg = gtk_dialog_new ();
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
- gtk_dialog_run (GTK_DIALOG (dlg));
- gtk_widget_destroy (dlg);
-
- return FALSE;
- }
-
- if (args->realm)
- gtk_label_set_text (GTK_LABEL (auth_realm), args->realm);
-
- info = g_strconcat(_("Hostname:"), args->cert_info->hostname, "\n",
- _("Fingerprint:"), args->cert_info->fingerprint, "\n",
- _("Valid from:"), args->cert_info->valid_from, "\n",
- _("Valid until:"), args->cert_info->valid_until, "\n",
- _("Issuer DN:"), args->cert_info->issuer_dname, "\n",
- _("DER certificate:"), args->cert_info->ascii_cert, "\n",
- NULL);
- gtk_label_set_text (GTK_LABEL (server_info), info);
-
- if (!args->may_save)
- gtk_widget_set_sensitive(remember_check, FALSE);
-
- gtk_dialog_set_default_response (GTK_DIALOG (svn_server_trust), GTK_RESPONSE_YES);
-
-
- switch (gtk_dialog_run(GTK_DIALOG(svn_server_trust)))
- {
- case GTK_RESPONSE_YES:
- *args->cred = apr_pcalloc (args->pool,
- sizeof(*(args->cred)));
- (*(args->cred))->may_save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
- (remember_check));
- err = SVN_NO_ERROR;
- /* TODO: Set bitmask for accepted_failures */
- break;
- default:
- err = svn_error_create (SVN_ERR_AUTHN_CREDS_UNAVAILABLE, NULL,
- _("Authentication canceled"));
- break;
- }
- gtk_widget_destroy (svn_server_trust);
- args->error = err;
-
- /* Release because main thread should already have the lock */
- svn_command = SVN_COMMAND (args->baton);
- svn_command_unlock_ui (svn_command);
-
- return FALSE;
+ GtkWidget *svn_server_trust;
+ GtkWidget *auth_realm;
+ GtkWidget *server_info;
+ GtkWidget *remember_check;
+ GtkWidget *error_widget;
+ gboolean ret;
+ svn_error_t *err = NULL;
+ gchar *info;
+ SvnCommand *svn_command;
+ gchar *root_objects[] = {
+ "svn_server_trust",
+ NULL
+ };
+
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "svn_server_trust",
+ &svn_server_trust, "realm_label",
+ &auth_realm, "server_info_label",
+ &server_info, "remember_check",
+ &remember_check, NULL);
+
+ if (!ret)
+ {
+ GtkWidget *dlg = gtk_dialog_new ();
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+ gtk_dialog_run (GTK_DIALOG (dlg));
+ gtk_widget_destroy (dlg);
+
+ return FALSE;
+ }
+
+ if (args->realm)
+ gtk_label_set_text (GTK_LABEL (auth_realm), args->realm);
+
+ info = g_strconcat (_("Hostname:"), args->cert_info->hostname, "\n",
+ _("Fingerprint:"), args->cert_info->fingerprint, "\n",
+ _("Valid from:"), args->cert_info->valid_from, "\n",
+ _("Valid until:"), args->cert_info->valid_until, "\n",
+ _("Issuer DN:"), args->cert_info->issuer_dname, "\n",
+ _("DER certificate:"), args->cert_info->ascii_cert,
+ "\n", NULL);
+ gtk_label_set_text (GTK_LABEL (server_info), info);
+
+ if (!args->may_save)
+ gtk_widget_set_sensitive (remember_check, FALSE);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (svn_server_trust),
+ GTK_RESPONSE_YES);
+
+
+ switch (gtk_dialog_run (GTK_DIALOG (svn_server_trust)))
+ {
+ case GTK_RESPONSE_YES:
+ *args->cred = apr_pcalloc (args->pool, sizeof (*(args->cred)));
+ (*(args->cred))->may_save =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_check));
+ err = SVN_NO_ERROR;
+ /* TODO: Set bitmask for accepted_failures */
+ break;
+ default:
+ err = svn_error_create (SVN_ERR_AUTHN_CREDS_UNAVAILABLE, NULL,
+ _("Authentication canceled"));
+ break;
+ }
+ gtk_widget_destroy (svn_server_trust);
+ args->error = err;
+
+ /* Release because main thread should already have the lock */
+ svn_command = SVN_COMMAND (args->baton);
+ svn_command_unlock_ui (svn_command);
+
+ return FALSE;
}
/* User authentication prompts handlers */
-static svn_error_t*
-svn_auth_simple_prompt_func_cb (svn_auth_cred_simple_t **cred, void *baton,
- const char *realm, const char *username,
- svn_boolean_t may_save, apr_pool_t *pool)
+static svn_error_t *
+svn_auth_simple_prompt_func_cb (svn_auth_cred_simple_t ** cred, void *baton,
+ const char *realm, const char *username,
+ svn_boolean_t may_save, apr_pool_t * pool)
{
- SimplePromptArgs *args;
- SvnCommand *svn_command;
- svn_error_t *error;
-
- args = g_new0 (SimplePromptArgs, 1);
- args->cred = cred;
- args->baton = baton;
- args->realm = g_strdup (realm);
- args->username = g_strdup (username);
- args->may_save = may_save;
- args->pool = pool;
-
- svn_command = SVN_COMMAND (baton);
-
- g_idle_add ((GSourceFunc) simple_prompt, args);
-
- svn_command_lock_ui (svn_command);
- svn_command_unlock_ui (svn_command);
-
- error = args->error;
- g_free (args->realm);
- g_free (args->username);
- g_free (args);
-
- return error;
+ SimplePromptArgs *args;
+ SvnCommand *svn_command;
+ svn_error_t *error;
+
+ args = g_new0 (SimplePromptArgs, 1);
+ args->cred = cred;
+ args->baton = baton;
+ args->realm = g_strdup (realm);
+ args->username = g_strdup (username);
+ args->may_save = may_save;
+ args->pool = pool;
+
+ svn_command = SVN_COMMAND (baton);
+
+ g_idle_add ((GSourceFunc) simple_prompt, args);
+
+ svn_command_lock_ui (svn_command);
+ svn_command_unlock_ui (svn_command);
+
+ error = args->error;
+ g_free (args->realm);
+ g_free (args->username);
+ g_free (args);
+
+ return error;
}
-static svn_error_t*
-svn_auth_ssl_server_trust_prompt_func_cb (svn_auth_cred_ssl_server_trust_t **cred,
- void *baton, const char *realm,
- apr_uint32_t failures,
- const svn_auth_ssl_server_cert_info_t *cert_info,
- svn_boolean_t may_save,
- apr_pool_t *pool)
+static svn_error_t *
+svn_auth_ssl_server_trust_prompt_func_cb (svn_auth_cred_ssl_server_trust_t **
+ cred, void *baton,
+ const char *realm,
+ apr_uint32_t failures,
+ const
+ svn_auth_ssl_server_cert_info_t *
+ cert_info, svn_boolean_t may_save,
+ apr_pool_t * pool)
{
- SSLServerTrustArgs *args;
- SvnCommand *svn_command;
- svn_error_t *error;
-
- args = g_new0 (SSLServerTrustArgs, 1);
- args->cred = cred;
- args->baton = baton;
- args->realm = g_strdup (realm);
- args->failures = failures;
- args->cert_info = g_memdup (cert_info,
- sizeof (svn_auth_ssl_server_cert_info_t));
- args->may_save = may_save;
- args->pool = pool;
-
- svn_command = SVN_COMMAND (baton);
-
- g_idle_add_full (G_PRIORITY_HIGH_IDLE,
- (GSourceFunc) ssl_server_trust_prompt, args, NULL);
-
- svn_command_lock_ui (svn_command);
- svn_command_unlock_ui (svn_command);
-
- error = args->error;
- g_free (args->realm);
- g_free (args->cert_info);
- g_free (args);
-
- return error;
+ SSLServerTrustArgs *args;
+ SvnCommand *svn_command;
+ svn_error_t *error;
+
+ args = g_new0 (SSLServerTrustArgs, 1);
+ args->cred = cred;
+ args->baton = baton;
+ args->realm = g_strdup (realm);
+ args->failures = failures;
+ args->cert_info = g_memdup (cert_info,
+ sizeof (svn_auth_ssl_server_cert_info_t));
+ args->may_save = may_save;
+ args->pool = pool;
+
+ svn_command = SVN_COMMAND (baton);
+
+ g_idle_add_full (G_PRIORITY_HIGH_IDLE,
+ (GSourceFunc) ssl_server_trust_prompt, args, NULL);
+
+ svn_command_lock_ui (svn_command);
+ svn_command_unlock_ui (svn_command);
+
+ error = args->error;
+ g_free (args->realm);
+ g_free (args->cert_info);
+ g_free (args);
+
+ return error;
}
-static svn_error_t*
-svn_auth_ssl_client_cert_prompt_func_cb (svn_auth_cred_ssl_client_cert_t **cred,
- void *baton, const char *realm,
- svn_boolean_t may_save,
- apr_pool_t *pool)
+static svn_error_t *
+svn_auth_ssl_client_cert_prompt_func_cb (svn_auth_cred_ssl_client_cert_t **
+ cred, void *baton, const char *realm,
+ svn_boolean_t may_save,
+ apr_pool_t * pool)
{
-
- /* Ask for the file where client certificate of authenticity is.
- * I think it is some sort of private key. */
- return SVN_NO_ERROR;
+
+ /* Ask for the file where client certificate of authenticity is.
+ * I think it is some sort of private key. */
+ return SVN_NO_ERROR;
}
-static svn_error_t*
-svn_auth_ssl_client_cert_pw_prompt_func_cb (svn_auth_cred_ssl_client_cert_pw_t **cred,
- void *baton, const char *realm,
- svn_boolean_t may_save,
- apr_pool_t *pool)
+static svn_error_t *
+svn_auth_ssl_client_cert_pw_prompt_func_cb (svn_auth_cred_ssl_client_cert_pw_t
+ ** cred, void *baton,
+ const char *realm,
+ svn_boolean_t may_save,
+ apr_pool_t * pool)
{
-
- /* Prompt for password only. I think it is pass-phrase of the above key. */
- return SVN_NO_ERROR;;
+
+ /* Prompt for password only. I think it is pass-phrase of the above key. */
+ return SVN_NO_ERROR;;
}
/* Notification callback to handle notifications from Subversion itself */
static void
on_svn_notify (gpointer baton,
- const svn_wc_notify_t *notify,
- apr_pool_t *pool)
+ const svn_wc_notify_t * notify, apr_pool_t * pool)
{
- SvnCommand *self;
- gchar *action_message;
- gchar *state_message;
-
- self = SVN_COMMAND (baton);
- action_message = NULL;
- state_message = NULL;
-
- switch (notify->action)
- {
- case svn_wc_notify_delete:
- action_message = g_strdup_printf (_("Deleted: %s"), notify->path);
- break;
- case svn_wc_notify_add:
- action_message = g_strdup_printf (_("Added: %s"), notify->path);
- break;
- case svn_wc_notify_revert:
- action_message = g_strdup_printf (_("Reverted: %s"), notify->path);
- break;
- case svn_wc_notify_failed_revert:
- action_message = g_strdup_printf (_("Revert failed: %s"),
- notify->path);
- break;
- case svn_wc_notify_resolved:
- action_message = g_strdup_printf (_("Resolved: %s"), notify->path);
- break;
- case svn_wc_notify_update_delete:
- action_message = g_strdup_printf (_("Deleted: %s"), notify->path);
- break;
- case svn_wc_notify_update_update:
- action_message = g_strdup_printf (_("Updated: %s"), notify->path);
- break;
- case svn_wc_notify_update_add:
- action_message = g_strdup_printf (_("Added: %s"), notify->path);
- break;
- case svn_wc_notify_update_external:
- action_message = g_strdup_printf (_("Externally Updated: %s"),
- notify->path);
- break;
- case svn_wc_notify_commit_modified:
- action_message = g_strdup_printf (_("Commit Modified: %s"),
- notify->path);
- break;
- case svn_wc_notify_commit_added:
- action_message = g_strdup_printf (_("Commit Added: %s"), notify->path);
- break;
- case svn_wc_notify_commit_deleted:
- action_message = g_strdup_printf (_("Commit Deleted: %s"),
- notify->path);
- break;
- case svn_wc_notify_commit_replaced:
- action_message = g_strdup_printf (_("Commit Replaced: %s"),
- notify->path);
- break;
- case svn_wc_notify_copy:
- action_message = g_strdup_printf (_("Created File: %s"), notify->path);
- break;
- default:
- break;
- }
-
- if (action_message)
- {
- svn_command_push_info (self, action_message);
- g_free (action_message);
- }
-
- switch (notify->content_state)
- {
- case svn_wc_notify_state_changed:
- state_message = g_strdup_printf (_("Modified: %s"), notify->path);
- break;
- case svn_wc_notify_state_merged:
- state_message = g_strdup_printf (_("Merged: %s"), notify->path);
- break;
- case svn_wc_notify_state_conflicted:
- state_message = g_strdup_printf (_("Conflicted: %s"),
- notify->path);
- break;
- case svn_wc_notify_state_missing:
- state_message = g_strdup_printf (_("Missing: %s"), notify->path);
- break;
- case svn_wc_notify_state_obstructed:
- state_message = g_strdup_printf (_("Obstructed: %s"), notify->path);
- break;
- default:
- break;
- }
-
- if (state_message)
- {
- svn_command_push_info (self, state_message);
- g_free (state_message);
- }
+ SvnCommand *self;
+ gchar *action_message;
+ gchar *state_message;
+
+ self = SVN_COMMAND (baton);
+ action_message = NULL;
+ state_message = NULL;
+
+ switch (notify->action)
+ {
+ case svn_wc_notify_delete:
+ action_message = g_strdup_printf (_("Deleted: %s"), notify->path);
+ break;
+ case svn_wc_notify_add:
+ action_message = g_strdup_printf (_("Added: %s"), notify->path);
+ break;
+ case svn_wc_notify_revert:
+ action_message = g_strdup_printf (_("Reverted: %s"), notify->path);
+ break;
+ case svn_wc_notify_failed_revert:
+ action_message = g_strdup_printf (_("Revert failed: %s"), notify->path);
+ break;
+ case svn_wc_notify_resolved:
+ action_message = g_strdup_printf (_("Resolved: %s"), notify->path);
+ break;
+ case svn_wc_notify_update_delete:
+ action_message = g_strdup_printf (_("Deleted: %s"), notify->path);
+ break;
+ case svn_wc_notify_update_update:
+ action_message = g_strdup_printf (_("Updated: %s"), notify->path);
+ break;
+ case svn_wc_notify_update_add:
+ action_message = g_strdup_printf (_("Added: %s"), notify->path);
+ break;
+ case svn_wc_notify_update_external:
+ action_message = g_strdup_printf (_("Externally Updated: %s"),
+ notify->path);
+ break;
+ case svn_wc_notify_commit_modified:
+ action_message = g_strdup_printf (_("Commit Modified: %s"),
+ notify->path);
+ break;
+ case svn_wc_notify_commit_added:
+ action_message = g_strdup_printf (_("Commit Added: %s"), notify->path);
+ break;
+ case svn_wc_notify_commit_deleted:
+ action_message = g_strdup_printf (_("Commit Deleted: %s"),
+ notify->path);
+ break;
+ case svn_wc_notify_commit_replaced:
+ action_message = g_strdup_printf (_("Commit Replaced: %s"),
+ notify->path);
+ break;
+ case svn_wc_notify_copy:
+ action_message = g_strdup_printf (_("Created File: %s"), notify->path);
+ break;
+ default:
+ break;
+ }
+
+ if (action_message)
+ {
+ svn_command_push_info (self, action_message);
+ g_free (action_message);
+ }
+
+ switch (notify->content_state)
+ {
+ case svn_wc_notify_state_changed:
+ state_message = g_strdup_printf (_("Modified: %s"), notify->path);
+ break;
+ case svn_wc_notify_state_merged:
+ state_message = g_strdup_printf (_("Merged: %s"), notify->path);
+ break;
+ case svn_wc_notify_state_conflicted:
+ state_message = g_strdup_printf (_("Conflicted: %s"), notify->path);
+ break;
+ case svn_wc_notify_state_missing:
+ state_message = g_strdup_printf (_("Missing: %s"), notify->path);
+ break;
+ case svn_wc_notify_state_obstructed:
+ state_message = g_strdup_printf (_("Obstructed: %s"), notify->path);
+ break;
+ default:
+ break;
+ }
+
+ if (state_message)
+ {
+ svn_command_push_info (self, state_message);
+ g_free (state_message);
+ }
}
static void
-svn_command_init (SvnCommand *self)
+svn_command_init (SvnCommand * self)
{
- svn_auth_baton_t *auth_baton;
- apr_array_header_t *providers;
- svn_auth_provider_object_t *provider;
-
- self->priv = g_new0 (SvnCommandPriv, 1);
-
- self->priv->pool = svn_pool_create (NULL);
- svn_client_create_context (&self->priv->client_context, self->priv->pool);
- self->priv->client_context->notify_func2 = on_svn_notify;
- self->priv->client_context->notify_baton2 = self;
-
- svn_config_get_config (&(self->priv->client_context)->config,
- NULL, /* default dir */
- self->priv->pool);
+ svn_auth_baton_t *auth_baton;
+ apr_array_header_t *providers;
+ svn_auth_provider_object_t *provider;
- self->priv->info_messages = g_queue_new ();
- self->priv->ui_lock = g_mutex_new ();
-
- /* Make sure that the main thread holds the lock */
- g_idle_add ((GSourceFunc) svn_command_acquire_ui_lock, self);
-
- /* Fill in the auth baton callbacks */
- providers = apr_array_make (self->priv->pool, 1,
- sizeof (svn_auth_provider_object_t *));
-
- /* Provider that authenticates username/password from ~/.subversion */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_simple_provider (&provider, self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that authenticates server trust from ~/.subversion */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_ssl_server_trust_file_provider (&provider, self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that authenticates client cert from ~/.subversion */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_ssl_client_cert_file_provider (&provider, self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that authenticates client cert password from ~/.subversion */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_ssl_client_cert_pw_file_provider (&provider,
- self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that prompts for username/password */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_simple_prompt_provider(&provider,
- svn_auth_simple_prompt_func_cb,
- self, 3, self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that prompts for server trust */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_ssl_server_trust_prompt_provider (&provider,
- svn_auth_ssl_server_trust_prompt_func_cb,
- self,
- self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that prompts for client certificate file */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_ssl_client_cert_prompt_provider (&provider,
- svn_auth_ssl_client_cert_prompt_func_cb,
- NULL, 3, self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- /* Provider that prompts for client certificate file password */
- provider = apr_pcalloc (self->priv->pool, sizeof(*provider));
- svn_client_get_ssl_client_cert_pw_prompt_provider (&provider,
- svn_auth_ssl_client_cert_pw_prompt_func_cb,
- NULL, 3,
- self->priv->pool);
- *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
-
- svn_auth_open (&auth_baton, providers, self->priv->pool);
- self->priv->client_context->auth_baton = auth_baton;
+ self->priv = g_new0 (SvnCommandPriv, 1);
+
+ self->priv->pool = svn_pool_create (NULL);
+ svn_client_create_context (&self->priv->client_context, self->priv->pool);
+ self->priv->client_context->notify_func2 = on_svn_notify;
+ self->priv->client_context->notify_baton2 = self;
+
+ svn_config_get_config (&(self->priv->client_context)->config, NULL, /* default dir */
+ self->priv->pool);
+
+ self->priv->info_messages = g_queue_new ();
+ self->priv->ui_lock = g_mutex_new ();
+
+ /* Make sure that the main thread holds the lock */
+ g_idle_add ((GSourceFunc) svn_command_acquire_ui_lock, self);
+
+ /* Fill in the auth baton callbacks */
+ providers = apr_array_make (self->priv->pool, 1,
+ sizeof (svn_auth_provider_object_t *));
+
+ /* Provider that authenticates username/password from ~/.subversion */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_simple_provider (&provider, self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that authenticates server trust from ~/.subversion */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_ssl_server_trust_file_provider (&provider, self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that authenticates client cert from ~/.subversion */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_ssl_client_cert_file_provider (&provider, self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that authenticates client cert password from ~/.subversion */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_ssl_client_cert_pw_file_provider (&provider,
+ self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that prompts for username/password */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_simple_prompt_provider (&provider,
+ svn_auth_simple_prompt_func_cb,
+ self, 3, self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that prompts for server trust */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_ssl_server_trust_prompt_provider (&provider,
+ svn_auth_ssl_server_trust_prompt_func_cb,
+ self, self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that prompts for client certificate file */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_ssl_client_cert_prompt_provider (&provider,
+ svn_auth_ssl_client_cert_prompt_func_cb,
+ NULL, 3, self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ /* Provider that prompts for client certificate file password */
+ provider = apr_pcalloc (self->priv->pool, sizeof (*provider));
+ svn_client_get_ssl_client_cert_pw_prompt_provider (&provider,
+ svn_auth_ssl_client_cert_pw_prompt_func_cb,
+ NULL, 3,
+ self->priv->pool);
+ *(svn_auth_provider_object_t **) apr_array_push (providers) = provider;
+
+ svn_auth_open (&auth_baton, providers, self->priv->pool);
+ self->priv->client_context->auth_baton = auth_baton;
}
static void
-svn_command_finalize (GObject *object)
+svn_command_finalize (GObject * object)
{
- SvnCommand *self;
- GList *current_message_line;
-
- self = SVN_COMMAND (object);
-
- svn_pool_clear (self->priv->pool);
-
- current_message_line = self->priv->info_messages->head;
-
- while (current_message_line)
- {
- g_free (current_message_line->data);
- current_message_line = g_list_next (current_message_line);
- }
-
- g_idle_add ((GSourceFunc) svn_command_release_ui_lock, self->priv->ui_lock);
-
- g_queue_free (self->priv->info_messages);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_command_parent_class)->finalize (object);
+ SvnCommand *self;
+ GList *current_message_line;
+
+ self = SVN_COMMAND (object);
+
+ svn_pool_clear (self->priv->pool);
+
+ current_message_line = self->priv->info_messages->head;
+
+ while (current_message_line)
+ {
+ g_free (current_message_line->data);
+ current_message_line = g_list_next (current_message_line);
+ }
+
+ g_idle_add ((GSourceFunc) svn_command_release_ui_lock, self->priv->ui_lock);
+
+ g_queue_free (self->priv->info_messages);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_command_parent_class)->finalize (object);
}
static void
-svn_command_class_init (SvnCommandClass *klass)
+svn_command_class_init (SvnCommandClass * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = svn_command_finalize;
+ object_class->finalize = svn_command_finalize;
}
void
-svn_command_push_info (SvnCommand *self, const gchar *message)
+svn_command_push_info (SvnCommand * self, const gchar * message)
{
- gtranslator_async_command_lock (GTR_ASYNC_COMMAND (self));
- g_queue_push_tail (self->priv->info_messages, g_strdup (message));
- gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (self));
-
- gtranslator_command_notify_data_arrived (GTR_COMMAND (self));
+ gtranslator_async_command_lock (GTR_ASYNC_COMMAND (self));
+ g_queue_push_tail (self->priv->info_messages, g_strdup (message));
+ gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (self));
+
+ gtranslator_command_notify_data_arrived (GTR_COMMAND (self));
}
GQueue *
-svn_command_get_info_queue (SvnCommand *self)
+svn_command_get_info_queue (SvnCommand * self)
{
- return self->priv->info_messages;
+ return self->priv->info_messages;
}
void
-svn_command_set_error (SvnCommand *self, svn_error_t *error)
+svn_command_set_error (SvnCommand * self, svn_error_t * error)
{
- GString *error_string;
- svn_error_t *current_error;
- gchar *error_c_string;
-
- error_string = g_string_new ("");
- current_error = error;
-
- while (current_error)
- {
- g_string_append (error_string, current_error->message);
-
- if (current_error->child)
- g_string_append_c (error_string, '\n');
-
- current_error = current_error->child;
- }
-
- error_c_string = g_string_free (error_string, FALSE);
- gtranslator_async_command_set_error_message (GTR_COMMAND (self),
- error_c_string);
-
- g_free (error_c_string);
+ GString *error_string;
+ svn_error_t *current_error;
+ gchar *error_c_string;
+
+ error_string = g_string_new ("");
+ current_error = error;
+
+ while (current_error)
+ {
+ g_string_append (error_string, current_error->message);
+
+ if (current_error->child)
+ g_string_append_c (error_string, '\n');
+
+ current_error = current_error->child;
+ }
+
+ error_c_string = g_string_free (error_string, FALSE);
+ gtranslator_async_command_set_error_message (GTR_COMMAND (self),
+ error_c_string);
+
+ g_free (error_c_string);
}
svn_client_ctx_t *
-svn_command_get_client_context (SvnCommand *self)
+svn_command_get_client_context (SvnCommand * self)
{
- return self->priv->client_context;
+ return self->priv->client_context;
}
apr_pool_t *
-svn_command_get_pool (SvnCommand *self)
+svn_command_get_pool (SvnCommand * self)
{
- return self->priv->pool;
+ return self->priv->pool;
}
void
-svn_command_lock_ui (SvnCommand *self)
+svn_command_lock_ui (SvnCommand * self)
{
- g_mutex_lock (self->priv->ui_lock);
-
- /* Have the main thread acquire the lock as soon as the other thread is done
- * with it. The main thread should *not* acqure the lock, only release
- * it. */
- self->priv->main_thread_has_ui_lock = FALSE;
- g_idle_add ((GSourceFunc) svn_command_acquire_ui_lock, self);
+ g_mutex_lock (self->priv->ui_lock);
+
+ /* Have the main thread acquire the lock as soon as the other thread is done
+ * with it. The main thread should *not* acqure the lock, only release
+ * it. */
+ self->priv->main_thread_has_ui_lock = FALSE;
+ g_idle_add ((GSourceFunc) svn_command_acquire_ui_lock, self);
}
void
-svn_command_unlock_ui (SvnCommand *self)
+svn_command_unlock_ui (SvnCommand * self)
{
- g_mutex_unlock (self->priv->ui_lock);
+ g_mutex_unlock (self->priv->ui_lock);
}
gchar *
-svn_command_make_canonical_path (SvnCommand *self, const gchar *path)
+svn_command_make_canonical_path (SvnCommand * self, const gchar * path)
{
- const gchar *canonical_path;
-
- canonical_path = svn_path_canonicalize (path, self->priv->pool);
-
- return g_strdup (canonical_path);
+ const gchar *canonical_path;
+
+ canonical_path = svn_path_canonicalize (path, self->priv->pool);
+
+ return g_strdup (canonical_path);
}
svn_opt_revision_t *
-svn_command_get_revision (const gchar *revision)
+svn_command_get_revision (const gchar * revision)
{
- svn_opt_revision_t* svn_revision;
-
- svn_revision = g_new0 (svn_opt_revision_t, 1);
-
- /* FIXME: Parse the revision string */
- svn_revision->kind = svn_opt_revision_head;
-
- return svn_revision;
+ svn_opt_revision_t *svn_revision;
+
+ svn_revision = g_new0 (svn_opt_revision_t, 1);
+
+ /* FIXME: Parse the revision string */
+ svn_revision->kind = svn_opt_revision_head;
+
+ return svn_revision;
}
GList *
-svn_command_copy_path_list (GList *list)
+svn_command_copy_path_list (GList * list)
{
- GList *current_path;
- GList *new_list;
-
- new_list = NULL;
- current_path = list;
-
- while (current_path)
- {
- new_list = g_list_append (new_list, g_strdup (current_path->data));
- current_path = g_list_next (current_path);
- }
-
- return new_list;
+ GList *current_path;
+ GList *new_list;
+
+ new_list = NULL;
+ current_path = list;
+
+ while (current_path)
+ {
+ new_list = g_list_append (new_list, g_strdup (current_path->data));
+ current_path = g_list_next (current_path);
+ }
+
+ return new_list;
}
void
-svn_command_free_path_list (GList *list)
+svn_command_free_path_list (GList * list)
{
- GList *current_path;
-
- current_path = list;
-
- while (current_path)
- {
- g_free (current_path->data);
- current_path = g_list_next (current_path);
- }
-
- g_list_free (list);
+ GList *current_path;
+
+ current_path = list;
+
+ while (current_path)
+ {
+ g_free (current_path->data);
+ current_path = g_list_next (current_path);
+ }
+
+ g_list_free (list);
}
diff --git a/plugins/subversion/svn-command.h b/plugins/subversion/svn-command.h
index 38f35b1..f57d9b5 100644
--- a/plugins/subversion/svn-command.h
+++ b/plugins/subversion/svn-command.h
@@ -34,55 +34,55 @@
#include "async-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_COMMAND (svn_command_get_type ())
#define SVN_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_COMMAND, SvnCommand))
#define SVN_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_COMMAND, SvnCommandClass))
#define SVN_IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_COMMAND))
#define SVN_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_COMMAND))
#define SVN_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_COMMAND, SvnCommandClass))
-
typedef struct _SvnCommandClass SvnCommandClass;
typedef struct _SvnCommand SvnCommand;
typedef struct _SvnCommandPriv SvnCommandPriv;
struct _SvnCommandClass
{
- GtranslatorAsyncCommandClass parent_class;
+ GtranslatorAsyncCommandClass parent_class;
};
struct _SvnCommand
{
- GtranslatorAsyncCommand parent_instance;
-
- SvnCommandPriv *priv;
+ GtranslatorAsyncCommand parent_instance;
+
+ SvnCommandPriv *priv;
};
-GType svn_command_get_type (void) G_GNUC_CONST;
+GType
+svn_command_get_type (void)
+ G_GNUC_CONST;
-void svn_command_push_info (SvnCommand *self, const gchar *message);
+ void svn_command_push_info (SvnCommand * self, const gchar * message);
-GQueue * svn_command_get_info_queue (SvnCommand *self);
+ GQueue *svn_command_get_info_queue (SvnCommand * self);
-void svn_command_set_error (SvnCommand *self, svn_error_t *error);
+ void svn_command_set_error (SvnCommand * self, svn_error_t * error);
-svn_client_ctx_t *svn_command_get_client_context (SvnCommand *self);
+ svn_client_ctx_t *svn_command_get_client_context (SvnCommand * self);
-apr_pool_t *svn_command_get_pool (SvnCommand *self);
+ apr_pool_t *svn_command_get_pool (SvnCommand * self);
-void svn_command_lock_ui (SvnCommand *self);
+ void svn_command_lock_ui (SvnCommand * self);
-void svn_command_unlock_ui (SvnCommand *self);
+ void svn_command_unlock_ui (SvnCommand * self);
-gchar *svn_command_make_canonical_path (SvnCommand *self, const gchar *path);
+ gchar *svn_command_make_canonical_path (SvnCommand * self,
+ const gchar * path);
/* Static methods */
-svn_opt_revision_t *svn_command_get_revision (const gchar *revision);
+ svn_opt_revision_t *svn_command_get_revision (const gchar * revision);
-GList *svn_command_copy_path_list (GList *list);
+ GList *svn_command_copy_path_list (GList * list);
-void svn_command_free_path_list (GList *list);
+ void svn_command_free_path_list (GList * list);
G_END_DECLS
-
#endif /* _SVN_COMMAND_H_ */
diff --git a/plugins/subversion/svn-commit-command.c b/plugins/subversion/svn-commit-command.c
index dfe4dc7..4202fb2 100644
--- a/plugins/subversion/svn-commit-command.c
+++ b/plugins/subversion/svn-commit-command.c
@@ -29,141 +29,141 @@
struct _SvnCommitCommandPriv
{
- GList *paths;
- gchar *log_message;
- gboolean recursive;
+ GList *paths;
+ gchar *log_message;
+ gboolean recursive;
};
G_DEFINE_TYPE (SvnCommitCommand, svn_commit_command, SVN_TYPE_COMMAND);
-static svn_error_t*
+static svn_error_t *
on_log_callback (const char **log_msg,
- const char **tmp_file,
- apr_array_header_t *commit_items,
- void *baton,
- apr_pool_t *pool)
+ const char **tmp_file,
+ apr_array_header_t * commit_items,
+ void *baton, apr_pool_t * pool)
{
-
- SvnCommitCommand *self;
-
- self = SVN_COMMIT_COMMAND (baton);
-
- *log_msg = self->priv->log_message;
- *tmp_file = NULL;
-
- return SVN_NO_ERROR;
+
+ SvnCommitCommand *self;
+
+ self = SVN_COMMIT_COMMAND (baton);
+
+ *log_msg = self->priv->log_message;
+ *tmp_file = NULL;
+
+ return SVN_NO_ERROR;
}
static void
-svn_commit_command_init (SvnCommitCommand *self)
+svn_commit_command_init (SvnCommitCommand * self)
{
- svn_client_ctx_t *client_context;
-
- self->priv = g_new0 (SvnCommitCommandPriv, 1);
- client_context = svn_command_get_client_context (SVN_COMMAND (self));
-
- client_context->log_msg_func = on_log_callback;
- client_context->log_msg_baton = self;
-
+ svn_client_ctx_t *client_context;
+
+ self->priv = g_new0 (SvnCommitCommandPriv, 1);
+ client_context = svn_command_get_client_context (SVN_COMMAND (self));
+
+ client_context->log_msg_func = on_log_callback;
+ client_context->log_msg_baton = self;
+
}
static void
-svn_commit_command_finalize (GObject *object)
+svn_commit_command_finalize (GObject * object)
{
- SvnCommitCommand *self;
-
- self = SVN_COMMIT_COMMAND (object);
-
- svn_command_free_path_list (self->priv->paths);
- g_free (self->priv->log_message);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_commit_command_parent_class)->finalize (object);
+ SvnCommitCommand *self;
+
+ self = SVN_COMMIT_COMMAND (object);
+
+ svn_command_free_path_list (self->priv->paths);
+ g_free (self->priv->log_message);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_commit_command_parent_class)->finalize (object);
}
static guint
-svn_commit_command_run (GtranslatorCommand *command)
+svn_commit_command_run (GtranslatorCommand * command)
{
- SvnCommitCommand *self;
- SvnCommand *svn_command;
- GList *current_path;
- apr_array_header_t *commit_paths;
- gchar *revision_message;
- svn_error_t *error;
- svn_commit_info_t *commit_info;
- svn_depth_t depth;
-
- self = SVN_COMMIT_COMMAND (command);
- svn_command = SVN_COMMAND (command);
- current_path = self->priv->paths;
- commit_paths = apr_array_make (svn_command_get_pool (svn_command),
- g_list_length (self->priv->paths),
- sizeof (char *));
-
- while (current_path)
- {
- /* I just copied this so don't blame me... */
- (*((const char **) apr_array_push (commit_paths))) = current_path->data;
- current_path = g_list_next (current_path);
- }
-
- if (self->priv->recursive == TRUE)
- depth = svn_depth_infinity;
- else depth = svn_depth_files;
-
- error = svn_client_commit4 (&commit_info,
- commit_paths,
- depth,
- TRUE,
- FALSE,
- NULL,
- NULL,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- if (commit_info)
- {
- revision_message = g_strdup_printf ("Committed revision %ld.",
- commit_info->revision);
- svn_command_push_info (SVN_COMMAND (command), revision_message);
- g_free (revision_message);
- }
-
- return 0;
+ SvnCommitCommand *self;
+ SvnCommand *svn_command;
+ GList *current_path;
+ apr_array_header_t *commit_paths;
+ gchar *revision_message;
+ svn_error_t *error;
+ svn_commit_info_t *commit_info;
+ svn_depth_t depth;
+
+ self = SVN_COMMIT_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+ current_path = self->priv->paths;
+ commit_paths = apr_array_make (svn_command_get_pool (svn_command),
+ g_list_length (self->priv->paths),
+ sizeof (char *));
+
+ while (current_path)
+ {
+ /* I just copied this so don't blame me... */
+ (*((const char **) apr_array_push (commit_paths))) = current_path->data;
+ current_path = g_list_next (current_path);
+ }
+
+ if (self->priv->recursive == TRUE)
+ depth = svn_depth_infinity;
+ else
+ depth = svn_depth_files;
+
+ error = svn_client_commit4 (&commit_info,
+ commit_paths,
+ depth,
+ TRUE,
+ FALSE,
+ NULL,
+ NULL,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ if (commit_info)
+ {
+ revision_message = g_strdup_printf ("Committed revision %ld.",
+ commit_info->revision);
+ svn_command_push_info (SVN_COMMAND (command), revision_message);
+ g_free (revision_message);
+ }
+
+ return 0;
}
static void
-svn_commit_command_class_init (SvnCommitCommandClass *klass)
+svn_commit_command_class_init (SvnCommitCommandClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_commit_command_finalize;
- command_class->run = svn_commit_command_run;
+ object_class->finalize = svn_commit_command_finalize;
+ command_class->run = svn_commit_command_run;
}
SvnCommitCommand *
-svn_commit_command_new (GList *paths, const gchar *log_message,
- gboolean recursive)
+svn_commit_command_new (GList * paths, const gchar * log_message,
+ gboolean recursive)
{
- SvnCommitCommand *self;
-
- self = g_object_new (SVN_TYPE_COMMIT_COMMAND, NULL);
- self->priv->paths = svn_command_copy_path_list (paths);
- self->priv->log_message = g_strdup (log_message);
- self->priv->recursive = recursive;
-
- return self;
+ SvnCommitCommand *self;
+
+ self = g_object_new (SVN_TYPE_COMMIT_COMMAND, NULL);
+ self->priv->paths = svn_command_copy_path_list (paths);
+ self->priv->log_message = g_strdup (log_message);
+ self->priv->recursive = recursive;
+
+ return self;
}
void
-svn_commit_command_destroy (SvnCommitCommand *self)
+svn_commit_command_destroy (SvnCommitCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
diff --git a/plugins/subversion/svn-commit-command.h b/plugins/subversion/svn-commit-command.h
index 5685c5e..4898d20 100644
--- a/plugins/subversion/svn-commit-command.h
+++ b/plugins/subversion/svn-commit-command.h
@@ -32,35 +32,35 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_COMMIT_COMMAND (svn_commit_command_get_type ())
#define SVN_COMMIT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_COMMIT_COMMAND, SvnCommitCommand))
#define SVN_COMMIT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_COMMIT_COMMAND, SvnCommitCommandClass))
#define SVN_IS_COMMIT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_COMMIT_COMMAND))
#define SVN_IS_COMMIT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_COMMIT_COMMAND))
#define SVN_COMMIT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_COMMIT_COMMAND, SvnCommitCommandClass))
-
typedef struct _SvnCommitCommandClass SvnCommitCommandClass;
typedef struct _SvnCommitCommand SvnCommitCommand;
typedef struct _SvnCommitCommandPriv SvnCommitCommandPriv;
struct _SvnCommitCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnCommitCommand
{
- SvnCommand parent_instance;
-
- SvnCommitCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnCommitCommandPriv *priv;
};
-GType svn_commit_command_get_type (void) G_GNUC_CONST;
-SvnCommitCommand * svn_commit_command_new (GList *paths, const gchar *log_message,
- gboolean recursive);
-void svn_commit_command_destroy (SvnCommitCommand *self);
+GType
+svn_commit_command_get_type (void)
+ G_GNUC_CONST;
+ SvnCommitCommand *svn_commit_command_new (GList * paths,
+ const gchar * log_message,
+ gboolean recursive);
+ void svn_commit_command_destroy (SvnCommitCommand * self);
G_END_DECLS
-
#endif /* _SVN_COMMIT_COMMAND_H_ */
diff --git a/plugins/subversion/svn-diff-command.c b/plugins/subversion/svn-diff-command.c
index e426aaf..918a239 100644
--- a/plugins/subversion/svn-diff-command.c
+++ b/plugins/subversion/svn-diff-command.c
@@ -29,195 +29,196 @@
struct _SvnDiffCommandPriv
{
- GQueue *output;
- gchar *path;
- glong revision1;
- glong revision2;
- gboolean recursive;
+ GQueue *output;
+ gchar *path;
+ glong revision1;
+ glong revision2;
+ gboolean recursive;
};
G_DEFINE_TYPE (SvnDiffCommand, svn_diff_command, SVN_TYPE_COMMAND);
static void
-svn_diff_command_init (SvnDiffCommand *self)
+svn_diff_command_init (SvnDiffCommand * self)
{
- self->priv = g_new0 (SvnDiffCommandPriv, 1);
- self->priv->output = g_queue_new ();
+ self->priv = g_new0 (SvnDiffCommandPriv, 1);
+ self->priv->output = g_queue_new ();
}
static void
-svn_diff_command_finalize (GObject *object)
+svn_diff_command_finalize (GObject * object)
{
- SvnDiffCommand *self;
- GList *current_line;
-
- self = SVN_DIFF_COMMAND (object);
-
- current_line = self->priv->output->head;
-
- while (current_line)
- {
- g_free (current_line->data);
- current_line = g_list_next (current_line);
- }
-
- g_queue_free (self->priv->output);
- g_free (self->priv->path);
- g_free (self->priv);
+ SvnDiffCommand *self;
+ GList *current_line;
+
+ self = SVN_DIFF_COMMAND (object);
+
+ current_line = self->priv->output->head;
- G_OBJECT_CLASS (svn_diff_command_parent_class)->finalize (object);
+ while (current_line)
+ {
+ g_free (current_line->data);
+ current_line = g_list_next (current_line);
+ }
+
+ g_queue_free (self->priv->output);
+ g_free (self->priv->path);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_diff_command_parent_class)->finalize (object);
}
-static guint
-svn_diff_command_run (GtranslatorCommand *command)
+static guint
+svn_diff_command_run (GtranslatorCommand * command)
{
- SvnDiffCommand *self;
- SvnCommand *svn_command;
- svn_opt_revision_t revision1;
- svn_opt_revision_t revision2;
- apr_array_header_t *options;
- apr_file_t *diff_file;
- gchar file_template[] = "gtranslator-svn-diffXXXXXX";
- apr_size_t read_size;
- gchar *line;
- svn_error_t *error;
- apr_status_t apr_error;
- apr_off_t offset;
- svn_depth_t depth;
-
- self = SVN_DIFF_COMMAND (command);
- svn_command = SVN_COMMAND (self);
-
- switch (self->priv->revision1)
- {
- case SVN_DIFF_REVISION_NONE:
- /* Treat this as a diff between working copy and base
- * (show only mods made to the revision of this working copy.) */
- revision1.kind = svn_opt_revision_base;
- revision2.kind = svn_opt_revision_working;
- break;
- case SVN_DIFF_REVISION_PREVIOUS:
- /* Diff between selected revision and the one before it.
- * This is relative to revision2. */
- revision1.kind = svn_opt_revision_number;
- revision1.value.number = self->priv->revision2 - 1;
- revision2.kind = svn_opt_revision_number;
- revision2.value.number = self->priv->revision2;
- break;
- default:
- /* Diff between two distinct revisions */
- revision1.kind = svn_opt_revision_number;
- revision1.value.number = self->priv->revision1;
- revision2.kind = svn_opt_revision_number;
- revision2.value.number = self->priv->revision2;
- break;
- }
-
- options = apr_array_make(svn_command_get_pool (SVN_COMMAND (command)),
- 0, sizeof (char *));
-
- apr_file_mktemp (&diff_file, file_template, 0,
- svn_command_get_pool (SVN_COMMAND (command)));
-
- if (self->priv->recursive == TRUE)
- depth = svn_depth_infinity;
- else depth = svn_depth_empty;
-
- error = svn_client_diff4 (options,
- self->priv->path,
- &revision1,
- self->priv->path,
- &revision2,
- NULL,
- depth,
- FALSE,
- FALSE,
- FALSE,
- SVN_APR_LOCALE_CHARSET,
- diff_file,
- NULL,
- NULL,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- offset = 0;
- apr_file_seek (diff_file, APR_SET, &offset);
-
- while (apr_file_eof (diff_file) != APR_EOF)
+ SvnDiffCommand *self;
+ SvnCommand *svn_command;
+ svn_opt_revision_t revision1;
+ svn_opt_revision_t revision2;
+ apr_array_header_t *options;
+ apr_file_t *diff_file;
+ gchar file_template[] = "gtranslator-svn-diffXXXXXX";
+ apr_size_t read_size;
+ gchar *line;
+ svn_error_t *error;
+ apr_status_t apr_error;
+ apr_off_t offset;
+ svn_depth_t depth;
+
+ self = SVN_DIFF_COMMAND (command);
+ svn_command = SVN_COMMAND (self);
+
+ switch (self->priv->revision1)
+ {
+ case SVN_DIFF_REVISION_NONE:
+ /* Treat this as a diff between working copy and base
+ * (show only mods made to the revision of this working copy.) */
+ revision1.kind = svn_opt_revision_base;
+ revision2.kind = svn_opt_revision_working;
+ break;
+ case SVN_DIFF_REVISION_PREVIOUS:
+ /* Diff between selected revision and the one before it.
+ * This is relative to revision2. */
+ revision1.kind = svn_opt_revision_number;
+ revision1.value.number = self->priv->revision2 - 1;
+ revision2.kind = svn_opt_revision_number;
+ revision2.value.number = self->priv->revision2;
+ break;
+ default:
+ /* Diff between two distinct revisions */
+ revision1.kind = svn_opt_revision_number;
+ revision1.value.number = self->priv->revision1;
+ revision2.kind = svn_opt_revision_number;
+ revision2.value.number = self->priv->revision2;
+ break;
+ }
+
+ options = apr_array_make (svn_command_get_pool (SVN_COMMAND (command)),
+ 0, sizeof (char *));
+
+ apr_file_mktemp (&diff_file, file_template, 0,
+ svn_command_get_pool (SVN_COMMAND (command)));
+
+ if (self->priv->recursive == TRUE)
+ depth = svn_depth_infinity;
+ else
+ depth = svn_depth_empty;
+
+ error = svn_client_diff4 (options,
+ self->priv->path,
+ &revision1,
+ self->priv->path,
+ &revision2,
+ NULL,
+ depth,
+ FALSE,
+ FALSE,
+ FALSE,
+ SVN_APR_LOCALE_CHARSET,
+ diff_file,
+ NULL,
+ NULL,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ offset = 0;
+ apr_file_seek (diff_file, APR_SET, &offset);
+
+ while (apr_file_eof (diff_file) != APR_EOF)
+ {
+ read_size = 80;
+ line = g_new0 (gchar, (read_size + 1));
+
+ apr_error = apr_file_read (diff_file, line, &read_size);
+
+ if (strlen (line))
{
- read_size = 80;
- line = g_new0 (gchar, (read_size + 1));
-
- apr_error = apr_file_read (diff_file, line, &read_size);
-
- if (strlen (line))
- {
- gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
-
- /* Make sure that we only output UTF-8. We could have done this by
- * passing in "UTF-8" for header encoding to the diff API, but there
- * is the possiblity that an external diff program could be used, in
- * which case that arguement wouldn't do anything. As a workaround,
- * have the internal diff system return things in the system
- * charset, and make the (hopefully safe) assumption that any
- * external diff program also outputs in the current locale. */
- g_queue_push_tail (self->priv->output,
- g_locale_to_utf8 (line, read_size, NULL, NULL,
- NULL));
- gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
-
- g_free (line);
-
- gtranslator_command_notify_data_arrived (command);
- }
+ gtranslator_async_command_lock (GTR_ASYNC_COMMAND (command));
+
+ /* Make sure that we only output UTF-8. We could have done this by
+ * passing in "UTF-8" for header encoding to the diff API, but there
+ * is the possiblity that an external diff program could be used, in
+ * which case that arguement wouldn't do anything. As a workaround,
+ * have the internal diff system return things in the system
+ * charset, and make the (hopefully safe) assumption that any
+ * external diff program also outputs in the current locale. */
+ g_queue_push_tail (self->priv->output,
+ g_locale_to_utf8 (line, read_size, NULL, NULL,
+ NULL));
+ gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (command));
+
+ g_free (line);
+
+ gtranslator_command_notify_data_arrived (command);
}
-
- apr_file_close (diff_file);
-
- return 0;
-
+ }
+
+ apr_file_close (diff_file);
+
+ return 0;
+
}
static void
-svn_diff_command_class_init (SvnDiffCommandClass *klass)
+svn_diff_command_class_init (SvnDiffCommandClass * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_diff_command_finalize;
- command_class->run = svn_diff_command_run;
+ object_class->finalize = svn_diff_command_finalize;
+ command_class->run = svn_diff_command_run;
}
SvnDiffCommand *
-svn_diff_command_new (const gchar *path, glong revision1, glong revision2,
- gboolean recursive)
+svn_diff_command_new (const gchar * path, glong revision1, glong revision2,
+ gboolean recursive)
{
- SvnDiffCommand *self;
-
- self = g_object_new (SVN_TYPE_DIFF_COMMAND, NULL);
- self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
- path);
- self->priv->revision1 = revision1;
- self->priv->revision2 = revision2;
- self->priv->recursive = recursive;
-
- return self;
+ SvnDiffCommand *self;
+
+ self = g_object_new (SVN_TYPE_DIFF_COMMAND, NULL);
+ self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
+ path);
+ self->priv->revision1 = revision1;
+ self->priv->revision2 = revision2;
+ self->priv->recursive = recursive;
+
+ return self;
}
void
-svn_diff_command_destroy (SvnDiffCommand *self)
+svn_diff_command_destroy (SvnDiffCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
GQueue *
-svn_diff_command_get_output (SvnDiffCommand *self)
+svn_diff_command_get_output (SvnDiffCommand * self)
{
- return self->priv->output;
+ return self->priv->output;
}
diff --git a/plugins/subversion/svn-diff-command.h b/plugins/subversion/svn-diff-command.h
index 36f976f..4273752 100644
--- a/plugins/subversion/svn-diff-command.h
+++ b/plugins/subversion/svn-diff-command.h
@@ -30,43 +30,43 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_DIFF_COMMAND (svn_diff_command_get_type ())
#define SVN_DIFF_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_DIFF_COMMAND, SvnDiffCommand))
#define SVN_DIFF_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_DIFF_COMMAND, SvnDiffCommandClass))
#define SVN_IS_DIFF_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_DIFF_COMMAND))
#define SVN_IS_DIFF_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_DIFF_COMMAND))
#define SVN_DIFF_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_DIFF_COMMAND, SvnDiffCommandClass))
-
typedef struct _SvnDiffCommandClass SvnDiffCommandClass;
typedef struct _SvnDiffCommand SvnDiffCommand;
typedef struct _SvnDiffCommandPriv SvnDiffCommandPriv;
struct _SvnDiffCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnDiffCommand
{
- SvnCommandClass parent_instance;
-
- SvnDiffCommandPriv *priv;
+ SvnCommandClass parent_instance;
+
+ SvnDiffCommandPriv *priv;
};
enum
{
- SVN_DIFF_REVISION_PREVIOUS = -1,
- SVN_DIFF_REVISION_NONE = 0
-};
+ SVN_DIFF_REVISION_PREVIOUS = -1,
+ SVN_DIFF_REVISION_NONE = 0
+};
-GType svn_diff_command_get_type (void) G_GNUC_CONST;
-SvnDiffCommand *svn_diff_command_new (const gchar *path, glong revision1,
- glong revision2, gboolean recursive);
-void svn_diff_command_destroy (SvnDiffCommand *self);
+GType
+svn_diff_command_get_type (void)
+ G_GNUC_CONST;
+ SvnDiffCommand *svn_diff_command_new (const gchar * path,
+ glong revision1, glong revision2,
+ gboolean recursive);
+ void svn_diff_command_destroy (SvnDiffCommand * self);
-GQueue *svn_diff_command_get_output (SvnDiffCommand *self);
+ GQueue *svn_diff_command_get_output (SvnDiffCommand * self);
G_END_DECLS
-
#endif /* _SVN_DIFF_COMMAND_H_ */
diff --git a/plugins/subversion/svn-resolve-command.c b/plugins/subversion/svn-resolve-command.c
index eac9b3f..9f9df37 100644
--- a/plugins/subversion/svn-resolve-command.c
+++ b/plugins/subversion/svn-resolve-command.c
@@ -26,87 +26,88 @@
struct _SvnResolveCommandPriv
{
- GList *paths;
- gboolean recursive;
+ GList *paths;
+ gboolean recursive;
};
G_DEFINE_TYPE (SvnResolveCommand, svn_resolve_command, SVN_TYPE_COMMAND);
static void
-svn_resolve_command_init (SvnResolveCommand *self)
-{
- self->priv = g_new0 (SvnResolveCommandPriv, 1);
+svn_resolve_command_init (SvnResolveCommand * self)
+{
+ self->priv = g_new0 (SvnResolveCommandPriv, 1);
}
static void
-svn_resolve_command_finalize (GObject *object)
+svn_resolve_command_finalize (GObject * object)
{
- SvnResolveCommand *self;
-
- self = SVN_RESOLVE_COMMAND (object);
-
- svn_command_free_path_list (self->priv->paths);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_resolve_command_parent_class)->finalize (object);
+ SvnResolveCommand *self;
+
+ self = SVN_RESOLVE_COMMAND (object);
+
+ svn_command_free_path_list (self->priv->paths);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_resolve_command_parent_class)->finalize (object);
}
static guint
-svn_resolve_command_run (GtranslatorCommand *command)
+svn_resolve_command_run (GtranslatorCommand * command)
{
- SvnResolveCommand *self;
- SvnCommand *svn_command;
- GList *current_path;
- svn_error_t *error;
-
- self = SVN_RESOLVE_COMMAND (command);
- svn_command = SVN_COMMAND (command);
- current_path = self->priv->paths;
-
- while (current_path)
+ SvnResolveCommand *self;
+ SvnCommand *svn_command;
+ GList *current_path;
+ svn_error_t *error;
+
+ self = SVN_RESOLVE_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+ current_path = self->priv->paths;
+
+ while (current_path)
+ {
+ error = svn_client_resolved (current_path->data,
+ self->priv->recursive,
+ svn_command_get_client_context
+ (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
{
- error = svn_client_resolved (current_path->data,
- self->priv->recursive,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- current_path = g_list_next (current_path);
+ svn_command_set_error (svn_command, error);
+ return 1;
}
-
- return 0;
+
+ current_path = g_list_next (current_path);
+ }
+
+ return 0;
}
static void
-svn_resolve_command_class_init (SvnResolveCommandClass *klass)
+svn_resolve_command_class_init (SvnResolveCommandClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_resolve_command_finalize;
- command_class->run = svn_resolve_command_run;
+ object_class->finalize = svn_resolve_command_finalize;
+ command_class->run = svn_resolve_command_run;
}
SvnResolveCommand *
-svn_resolve_command_new (GList *paths, gboolean recursive)
+svn_resolve_command_new (GList * paths, gboolean recursive)
{
- SvnResolveCommand *self;
-
- self = g_object_new (SVN_TYPE_RESOLVE_COMMAND, NULL);
- self->priv->paths = svn_command_copy_path_list (paths);
- self->priv->recursive = recursive;
-
- return self;
+ SvnResolveCommand *self;
+
+ self = g_object_new (SVN_TYPE_RESOLVE_COMMAND, NULL);
+ self->priv->paths = svn_command_copy_path_list (paths);
+ self->priv->recursive = recursive;
+
+ return self;
}
void
-svn_resolve_command_destroy (SvnResolveCommand *self)
+svn_resolve_command_destroy (SvnResolveCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
diff --git a/plugins/subversion/svn-resolve-command.h b/plugins/subversion/svn-resolve-command.h
index e3a9e08..32862aa 100644
--- a/plugins/subversion/svn-resolve-command.h
+++ b/plugins/subversion/svn-resolve-command.h
@@ -29,34 +29,34 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_RESOLVE_COMMAND (svn_resolve_command_get_type ())
#define SVN_RESOLVE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_RESOLVE_COMMAND, SvnResolveCommand))
#define SVN_RESOLVE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_RESOLVE_COMMAND, SvnResolveCommandClass))
#define SVN_IS_RESOLVE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_RESOLVE_COMMAND))
#define SVN_IS_RESOLVE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_RESOLVE_COMMAND))
#define SVN_RESOLVE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_RESOLVE_COMMAND, SvnResolveCommandClass))
-
typedef struct _SvnResolveCommandClass SvnResolveCommandClass;
typedef struct _SvnResolveCommand SvnResolveCommand;
typedef struct _SvnResolveCommandPriv SvnResolveCommandPriv;
struct _SvnResolveCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnResolveCommand
{
- SvnCommand parent_instance;
-
- SvnResolveCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnResolveCommandPriv *priv;
};
-GType svn_resolve_command_get_type (void) G_GNUC_CONST;
-SvnResolveCommand *svn_resolve_command_new (GList *paths, gboolean recursive);
-void svn_resolve_command_destroy (SvnResolveCommand *self);
+GType
+svn_resolve_command_get_type (void)
+ G_GNUC_CONST;
+ SvnResolveCommand *svn_resolve_command_new (GList * paths,
+ gboolean recursive);
+ void svn_resolve_command_destroy (SvnResolveCommand * self);
G_END_DECLS
-
#endif /* _SVN_RESOLVE_COMMAND_H_ */
diff --git a/plugins/subversion/svn-status-command.c b/plugins/subversion/svn-status-command.c
index e84a318..94de519 100644
--- a/plugins/subversion/svn-status-command.c
+++ b/plugins/subversion/svn-status-command.c
@@ -26,148 +26,150 @@
struct _SvnStatusCommandPriv
{
- gchar *path;
- gboolean recursive;
- gboolean get_all_items;
- GQueue *status_queue;
+ gchar *path;
+ gboolean recursive;
+ gboolean get_all_items;
+ GQueue *status_queue;
};
G_DEFINE_TYPE (SvnStatusCommand, svn_status_command, SVN_TYPE_COMMAND);
static void
-svn_status_command_init (SvnStatusCommand *self)
-{
- self->priv = g_new0 (SvnStatusCommandPriv, 1);
- self->priv->status_queue = g_queue_new ();
+svn_status_command_init (SvnStatusCommand * self)
+{
+ self->priv = g_new0 (SvnStatusCommandPriv, 1);
+ self->priv->status_queue = g_queue_new ();
}
static void
-svn_status_command_finalize (GObject *object)
+svn_status_command_finalize (GObject * object)
{
- SvnStatusCommand *self;
- GList *current_status;
-
- self = SVN_STATUS_COMMAND (object);
- current_status = self->priv->status_queue->head;
-
- g_free (self->priv->path);
-
- while (current_status)
- {
- svn_status_destroy (current_status->data);
- current_status = g_list_next (current_status);
- }
-
- g_queue_free (self->priv->status_queue);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_status_command_parent_class)->finalize (object);
+ SvnStatusCommand *self;
+ GList *current_status;
+
+ self = SVN_STATUS_COMMAND (object);
+ current_status = self->priv->status_queue->head;
+
+ g_free (self->priv->path);
+
+ while (current_status)
+ {
+ svn_status_destroy (current_status->data);
+ current_status = g_list_next (current_status);
+ }
+
+ g_queue_free (self->priv->status_queue);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_status_command_parent_class)->finalize (object);
}
static void
-on_svn_status_notify (void *baton, const char *path, svn_wc_status2_t *status)
+on_svn_status_notify (void *baton, const char *path,
+ svn_wc_status2_t * status)
{
- SvnStatusCommand *self;
- SvnStatus *status_object;
-
- self = SVN_STATUS_COMMAND (baton);
-
- /* Right now we only support text status (no properties.) */
-
- switch (status->text_status)
- {
- case svn_wc_status_modified:
- case svn_wc_status_added:
- case svn_wc_status_deleted:
- case svn_wc_status_conflicted:
- case svn_wc_status_missing:
- status_object = svn_status_new ((gchar *) path,
- status->text_status);
-
- gtranslator_async_command_lock (GTR_ASYNC_COMMAND (self));
- g_queue_push_tail (self->priv->status_queue, status_object);
- gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (self));
-
- gtranslator_command_notify_data_arrived (GTR_COMMAND (self));
-
- break;
- default:
- break;
- }
+ SvnStatusCommand *self;
+ SvnStatus *status_object;
+
+ self = SVN_STATUS_COMMAND (baton);
+
+ /* Right now we only support text status (no properties.) */
+
+ switch (status->text_status)
+ {
+ case svn_wc_status_modified:
+ case svn_wc_status_added:
+ case svn_wc_status_deleted:
+ case svn_wc_status_conflicted:
+ case svn_wc_status_missing:
+ status_object = svn_status_new ((gchar *) path, status->text_status);
+
+ gtranslator_async_command_lock (GTR_ASYNC_COMMAND (self));
+ g_queue_push_tail (self->priv->status_queue, status_object);
+ gtranslator_async_command_unlock (GTR_ASYNC_COMMAND (self));
+
+ gtranslator_command_notify_data_arrived (GTR_COMMAND (self));
+
+ break;
+ default:
+ break;
+ }
}
-static guint
-svn_status_command_run (GtranslatorCommand *command)
+static guint
+svn_status_command_run (GtranslatorCommand * command)
{
- SvnStatusCommand *self;
- SvnCommand *svn_command;
- svn_opt_revision_t revision;
- svn_error_t *error;
- svn_depth_t depth;
-
- self = SVN_STATUS_COMMAND (command);
- svn_command = SVN_COMMAND (command);
- revision.kind = svn_opt_revision_working;
-
- if (self->priv->recursive == TRUE)
- depth = svn_depth_infinity;
- else depth = svn_depth_immediates;
-
- error = svn_client_status3 (NULL,
- self->priv->path,
- &revision,
- on_svn_status_notify,
- self,
- depth,
- self->priv->get_all_items,
- FALSE,
- FALSE,
- TRUE,
- NULL,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- return 0;
+ SvnStatusCommand *self;
+ SvnCommand *svn_command;
+ svn_opt_revision_t revision;
+ svn_error_t *error;
+ svn_depth_t depth;
+
+ self = SVN_STATUS_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+ revision.kind = svn_opt_revision_working;
+
+ if (self->priv->recursive == TRUE)
+ depth = svn_depth_infinity;
+ else
+ depth = svn_depth_immediates;
+
+ error = svn_client_status3 (NULL,
+ self->priv->path,
+ &revision,
+ on_svn_status_notify,
+ self,
+ depth,
+ self->priv->get_all_items,
+ FALSE,
+ FALSE,
+ TRUE,
+ NULL,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ return 0;
}
static void
-svn_status_command_class_init (SvnStatusCommandClass *klass)
+svn_status_command_class_init (SvnStatusCommandClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- command_class->run = svn_status_command_run;
- object_class->finalize = svn_status_command_finalize;
+ command_class->run = svn_status_command_run;
+ object_class->finalize = svn_status_command_finalize;
}
SvnStatusCommand *
-svn_status_command_new (const gchar *path, gboolean recursive, gboolean get_all_items)
+svn_status_command_new (const gchar * path, gboolean recursive,
+ gboolean get_all_items)
{
- SvnStatusCommand *self;
-
- self = g_object_new (SVN_TYPE_STATUS_COMMAND, NULL);
- self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
- path);
- self->priv->recursive = recursive;
- self->priv->get_all_items = get_all_items;
-
- return self;
+ SvnStatusCommand *self;
+
+ self = g_object_new (SVN_TYPE_STATUS_COMMAND, NULL);
+ self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
+ path);
+ self->priv->recursive = recursive;
+ self->priv->get_all_items = get_all_items;
+
+ return self;
}
void
-svn_status_command_destroy (SvnStatusCommand *self)
+svn_status_command_destroy (SvnStatusCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
GQueue *
-svn_status_command_get_status_queue (SvnStatusCommand *self)
+svn_status_command_get_status_queue (SvnStatusCommand * self)
{
- return self->priv->status_queue;
+ return self->priv->status_queue;
}
diff --git a/plugins/subversion/svn-status-command.h b/plugins/subversion/svn-status-command.h
index 688b3e8..b23a1be 100644
--- a/plugins/subversion/svn-status-command.h
+++ b/plugins/subversion/svn-status-command.h
@@ -30,36 +30,36 @@
#include "svn-status.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_STATUS_COMMAND (svn_status_command_get_type ())
#define SVN_STATUS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_STATUS_COMMAND, SvnStatusCommand))
#define SVN_STATUS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_STATUS_COMMAND, SvnStatusCommandClass))
#define SVN_IS_STATUS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_STATUS_COMMAND))
#define SVN_IS_STATUS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_STATUS_COMMAND))
#define SVN_STATUS_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_STATUS_COMMAND, SvnStatusCommandClass))
-
typedef struct _SvnStatusCommandClass SvnStatusCommandClass;
typedef struct _SvnStatusCommand SvnStatusCommand;
typedef struct _SvnStatusCommandPriv SvnStatusCommandPriv;
struct _SvnStatusCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnStatusCommand
{
- SvnCommand parent_instance;
-
- SvnStatusCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnStatusCommandPriv *priv;
};
-GType svn_status_command_get_type (void) G_GNUC_CONST;
-SvnStatusCommand *svn_status_command_new (const gchar *path, gboolean recursive,
- gboolean get_all_items);
-void svn_status_command_destroy (SvnStatusCommand *self);
-GQueue *svn_status_command_get_status_queue (SvnStatusCommand *self);
+GType
+svn_status_command_get_type (void)
+ G_GNUC_CONST;
+ SvnStatusCommand *svn_status_command_new (const gchar * path,
+ gboolean recursive,
+ gboolean get_all_items);
+ void svn_status_command_destroy (SvnStatusCommand * self);
+ GQueue *svn_status_command_get_status_queue (SvnStatusCommand * self);
G_END_DECLS
-
#endif /* _SVN_STATUS_COMMAND_H_ */
diff --git a/plugins/subversion/svn-status.c b/plugins/subversion/svn-status.c
index 37f9798..869d4a7 100644
--- a/plugins/subversion/svn-status.c
+++ b/plugins/subversion/svn-status.c
@@ -26,90 +26,90 @@
struct _SvnStatusPriv
{
- gchar *path;
- enum svn_wc_status_kind status;
+ gchar *path;
+ enum svn_wc_status_kind status;
};
G_DEFINE_TYPE (SvnStatus, svn_status, G_TYPE_OBJECT);
static void
-svn_status_init (SvnStatus *self)
+svn_status_init (SvnStatus * self)
{
- self->priv = g_new0 (SvnStatusPriv, 1);
+ self->priv = g_new0 (SvnStatusPriv, 1);
}
static void
-svn_status_finalize (GObject *object)
+svn_status_finalize (GObject * object)
{
- SvnStatus *self;
-
- self = SVN_STATUS (object);
-
- g_free (self->priv->path);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_status_parent_class)->finalize (object);
+ SvnStatus *self;
+
+ self = SVN_STATUS (object);
+
+ g_free (self->priv->path);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_status_parent_class)->finalize (object);
}
static void
-svn_status_class_init (SvnStatusClass *klass)
+svn_status_class_init (SvnStatusClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = svn_status_finalize;
+ object_class->finalize = svn_status_finalize;
}
SvnStatus *
-svn_status_new (gchar *path, enum svn_wc_status_kind status)
+svn_status_new (gchar * path, enum svn_wc_status_kind status)
{
- SvnStatus *self;
-
- self = g_object_new (SVN_TYPE_STATUS, NULL);
-
- self->priv->path = g_strdup (path);
- self->priv->status = status;
-
- return self;
+ SvnStatus *self;
+
+ self = g_object_new (SVN_TYPE_STATUS, NULL);
+
+ self->priv->path = g_strdup (path);
+ self->priv->status = status;
+
+ return self;
}
void
-svn_status_destroy (SvnStatus *self)
+svn_status_destroy (SvnStatus * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
gchar *
-svn_status_get_path (SvnStatus *self)
+svn_status_get_path (SvnStatus * self)
{
- return g_strdup (self->priv->path);
+ return g_strdup (self->priv->path);
}
GtranslatorVcsStatus
-svn_status_get_vcs_status (SvnStatus *self)
+svn_status_get_vcs_status (SvnStatus * self)
{
- GtranslatorVcsStatus status;
-
- switch (self->priv->status)
- {
- case svn_wc_status_modified:
- status = GTR_VCS_STATUS_MODIFIED;
- break;
- case svn_wc_status_added:
- status = GTR_VCS_STATUS_ADDED;
- break;
- case svn_wc_status_deleted:
- status = GTR_VCS_STATUS_DELETED;
- break;
- case svn_wc_status_conflicted:
- status = GTR_VCS_STATUS_CONFLICTED;
- break;
- case svn_wc_status_missing:
- status = GTR_VCS_STATUS_MISSING;
- break;
- default:
- status = GTR_VCS_STATUS_NONE;
- break;
- }
-
- return status;
+ GtranslatorVcsStatus status;
+
+ switch (self->priv->status)
+ {
+ case svn_wc_status_modified:
+ status = GTR_VCS_STATUS_MODIFIED;
+ break;
+ case svn_wc_status_added:
+ status = GTR_VCS_STATUS_ADDED;
+ break;
+ case svn_wc_status_deleted:
+ status = GTR_VCS_STATUS_DELETED;
+ break;
+ case svn_wc_status_conflicted:
+ status = GTR_VCS_STATUS_CONFLICTED;
+ break;
+ case svn_wc_status_missing:
+ status = GTR_VCS_STATUS_MISSING;
+ break;
+ default:
+ status = GTR_VCS_STATUS_NONE;
+ break;
+ }
+
+ return status;
}
diff --git a/plugins/subversion/svn-status.h b/plugins/subversion/svn-status.h
index a043e1c..b473176 100644
--- a/plugins/subversion/svn-status.h
+++ b/plugins/subversion/svn-status.h
@@ -30,36 +30,35 @@
#include "vcs-status-tree-view.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_STATUS (svn_status_get_type ())
#define SVN_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_STATUS, SvnStatus))
#define SVN_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_STATUS, SvnStatusClass))
#define SVN_IS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_STATUS))
#define SVN_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_STATUS))
#define SVN_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_STATUS, SvnStatusClass))
-
typedef struct _SvnStatusClass SvnStatusClass;
typedef struct _SvnStatus SvnStatus;
typedef struct _SvnStatusPriv SvnStatusPriv;
struct _SvnStatusClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
struct _SvnStatus
{
- GObject parent_instance;
-
- SvnStatusPriv *priv;
+ GObject parent_instance;
+
+ SvnStatusPriv *priv;
};
-GType svn_status_get_type (void) G_GNUC_CONST;
-SvnStatus *svn_status_new (gchar *path, enum svn_wc_status_kind status);
-void svn_status_destroy (SvnStatus *self);
-gchar * svn_status_get_path (SvnStatus *self);
-GtranslatorVcsStatus svn_status_get_vcs_status (SvnStatus *self);
+GType
+svn_status_get_type (void)
+ G_GNUC_CONST;
+ SvnStatus *svn_status_new (gchar * path, enum svn_wc_status_kind status);
+ void svn_status_destroy (SvnStatus * self);
+ gchar *svn_status_get_path (SvnStatus * self);
+ GtranslatorVcsStatus svn_status_get_vcs_status (SvnStatus * self);
G_END_DECLS
-
#endif /* _SVN_STATUS_H_ */
diff --git a/plugins/subversion/svn-update-command.c b/plugins/subversion/svn-update-command.c
index f1e6116..7966dd5 100644
--- a/plugins/subversion/svn-update-command.c
+++ b/plugins/subversion/svn-update-command.c
@@ -29,113 +29,115 @@
struct _SvnUpdateCommandPriv
{
- gchar *path;
- gchar *revision;
- gboolean recursive;
+ gchar *path;
+ gchar *revision;
+ gboolean recursive;
};
G_DEFINE_TYPE (SvnUpdateCommand, svn_update_command, SVN_TYPE_COMMAND);
static void
-svn_update_command_init (SvnUpdateCommand *self)
-{
- self->priv = g_new0 (SvnUpdateCommandPriv, 1);
+svn_update_command_init (SvnUpdateCommand * self)
+{
+ self->priv = g_new0 (SvnUpdateCommandPriv, 1);
}
static void
-svn_update_command_finalize (GObject *object)
+svn_update_command_finalize (GObject * object)
{
- SvnUpdateCommand *self;
-
- self = SVN_UPDATE_COMMAND (object);
-
- g_free (self->priv->path);
- g_free (self->priv->revision);
- g_free (self->priv);
-
- G_OBJECT_CLASS (svn_update_command_parent_class)->finalize (object);
+ SvnUpdateCommand *self;
+
+ self = SVN_UPDATE_COMMAND (object);
+
+ g_free (self->priv->path);
+ g_free (self->priv->revision);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (svn_update_command_parent_class)->finalize (object);
}
static guint
-svn_update_command_run (GtranslatorCommand *command)
+svn_update_command_run (GtranslatorCommand * command)
{
- SvnUpdateCommand *self;
- SvnCommand *svn_command;
- svn_opt_revision_t *revision;
- apr_array_header_t *update_paths;
- apr_array_header_t *update_revisions;
- svn_error_t *error;
- svn_revnum_t revision_number;
- gchar *revision_message;
- svn_depth_t depth;
-
- self = SVN_UPDATE_COMMAND (command);
- svn_command = SVN_COMMAND (command);
- revision = svn_command_get_revision (self->priv->revision);
-
- /* I just copied this so don't blame me... */
- update_paths = apr_array_make (svn_command_get_pool (svn_command), 1,
- sizeof (char *));
- (*((const char **) apr_array_push (update_paths))) = self->priv->path;
-
- if (self->priv->recursive == TRUE)
- depth = svn_depth_infinity;
- else depth = svn_depth_files;
-
- error = svn_client_update3 (&update_revisions,
- update_paths,
- revision,
- depth,
- FALSE,
- FALSE,
- FALSE,
- svn_command_get_client_context (svn_command),
- svn_command_get_pool (svn_command));
-
- if (error)
- {
- svn_command_set_error (svn_command, error);
- return 1;
- }
-
- revision_number = (*(svn_revnum_t *) apr_array_pop (update_revisions));
-
- revision_message = g_strdup_printf (_("Updated to revision %ld."),
- (glong) revision_number);
- svn_command_push_info (SVN_COMMAND (command), revision_message);
- g_free (revision_message);
-
- return 0;
+ SvnUpdateCommand *self;
+ SvnCommand *svn_command;
+ svn_opt_revision_t *revision;
+ apr_array_header_t *update_paths;
+ apr_array_header_t *update_revisions;
+ svn_error_t *error;
+ svn_revnum_t revision_number;
+ gchar *revision_message;
+ svn_depth_t depth;
+
+ self = SVN_UPDATE_COMMAND (command);
+ svn_command = SVN_COMMAND (command);
+ revision = svn_command_get_revision (self->priv->revision);
+
+ /* I just copied this so don't blame me... */
+ update_paths = apr_array_make (svn_command_get_pool (svn_command), 1,
+ sizeof (char *));
+ (*((const char **) apr_array_push (update_paths))) = self->priv->path;
+
+ if (self->priv->recursive == TRUE)
+ depth = svn_depth_infinity;
+ else
+ depth = svn_depth_files;
+
+ error = svn_client_update3 (&update_revisions,
+ update_paths,
+ revision,
+ depth,
+ FALSE,
+ FALSE,
+ FALSE,
+ svn_command_get_client_context (svn_command),
+ svn_command_get_pool (svn_command));
+
+ if (error)
+ {
+ svn_command_set_error (svn_command, error);
+ return 1;
+ }
+
+ revision_number = (*(svn_revnum_t *) apr_array_pop (update_revisions));
+
+ revision_message = g_strdup_printf (_("Updated to revision %ld."),
+ (glong) revision_number);
+ svn_command_push_info (SVN_COMMAND (command), revision_message);
+ g_free (revision_message);
+
+ return 0;
}
static void
-svn_update_command_class_init (SvnUpdateCommandClass *klass)
+svn_update_command_class_init (SvnUpdateCommandClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorCommandClass *command_class = GTR_COMMAND_CLASS (klass);
- object_class->finalize = svn_update_command_finalize;
- command_class->run = svn_update_command_run;
+ object_class->finalize = svn_update_command_finalize;
+ command_class->run = svn_update_command_run;
}
SvnUpdateCommand *
-svn_update_command_new (const gchar *path, const gchar *revision, gboolean recursive)
+svn_update_command_new (const gchar * path, const gchar * revision,
+ gboolean recursive)
{
- SvnUpdateCommand *self;
-
- self = g_object_new (SVN_TYPE_UPDATE_COMMAND, NULL);
-
- self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
- path);
- self->priv->revision = g_strdup (revision);
- self->priv->recursive = recursive;
-
- return self;
+ SvnUpdateCommand *self;
+
+ self = g_object_new (SVN_TYPE_UPDATE_COMMAND, NULL);
+
+ self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
+ path);
+ self->priv->revision = g_strdup (revision);
+ self->priv->recursive = recursive;
+
+ return self;
}
void
-svn_update_command_destroy (SvnUpdateCommand *self)
+svn_update_command_destroy (SvnUpdateCommand * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
diff --git a/plugins/subversion/svn-update-command.h b/plugins/subversion/svn-update-command.h
index d0fc016..8be5b08 100644
--- a/plugins/subversion/svn-update-command.h
+++ b/plugins/subversion/svn-update-command.h
@@ -34,35 +34,35 @@
#include "svn-command.h"
G_BEGIN_DECLS
-
#define SVN_TYPE_UPDATE_COMMAND (svn_update_command_get_type ())
#define SVN_UPDATE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SVN_TYPE_UPDATE_COMMAND, SvnUpdateCommand))
#define SVN_UPDATE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SVN_TYPE_UPDATE_COMMAND, SvnUpdateCommandClass))
#define SVN_IS_UPDATE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SVN_TYPE_UPDATE_COMMAND))
#define SVN_IS_UPDATE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SVN_TYPE_UPDATE_COMMAND))
#define SVN_UPDATE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SVN_TYPE_UPDATE_COMMAND, SvnUpdateCommandClass))
-
typedef struct _SvnUpdateCommandClass SvnUpdateCommandClass;
typedef struct _SvnUpdateCommand SvnUpdateCommand;
typedef struct _SvnUpdateCommandPriv SvnUpdateCommandPriv;
struct _SvnUpdateCommandClass
{
- SvnCommandClass parent_class;
+ SvnCommandClass parent_class;
};
struct _SvnUpdateCommand
{
- SvnCommand parent_instance;
-
- SvnUpdateCommandPriv *priv;
+ SvnCommand parent_instance;
+
+ SvnUpdateCommandPriv *priv;
};
-GType svn_update_command_get_type (void) G_GNUC_CONST;
-SvnUpdateCommand * svn_update_command_new (const gchar *path, const gchar *revision,
- gboolean recursive);
-void svn_update_command_destroy (SvnUpdateCommand *self);
+GType
+svn_update_command_get_type (void)
+ G_GNUC_CONST;
+ SvnUpdateCommand *svn_update_command_new (const gchar * path,
+ const gchar * revision,
+ gboolean recursive);
+ void svn_update_command_destroy (SvnUpdateCommand * self);
G_END_DECLS
-
#endif /* _SVN_UPDATE_COMMAND_H_ */
diff --git a/plugins/subversion/update-dialog.c b/plugins/subversion/update-dialog.c
index 92c2b82..d546af7 100644
--- a/plugins/subversion/update-dialog.c
+++ b/plugins/subversion/update-dialog.c
@@ -41,289 +41,270 @@
GtranslatorUpdateDialogPrivate))
-G_DEFINE_TYPE(GtranslatorUpdateDialog, gtranslator_update_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GtranslatorUpdateDialog, gtranslator_update_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorUpdateDialogPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *dir_button;
-struct _GtranslatorUpdateDialogPrivate
-{
- GtkWidget *main_box;
- GtkWidget *dir_button;
-
- GtkListStore *store;
- GtkWidget *update_treeview;
-
- GtranslatorWindow *window;
-};
-
-enum
-{
- ICON_COLUMN,
- TEXT_COLUMN,
- N_COLUMNS
-};
+ GtkListStore *store;
+ GtkWidget *update_treeview;
-static void
-on_update_command_finished (GtranslatorCommand *command,
- guint return_code,
- GtranslatorUpdateDialog *dlg)
+ GtranslatorWindow *window;
+ };
+
+ enum
+ {
+ ICON_COLUMN,
+ TEXT_COLUMN,
+ N_COLUMNS
+ };
+
+ static void
+ on_update_command_finished (GtranslatorCommand * command,
+ guint return_code,
+ GtranslatorUpdateDialog * dlg)
{
- GtranslatorStatusbar *status;
-
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
-
- gtranslator_statusbar_flash_message (status, 0,
- _("Subversion: Update complete."));
-
- subversion_utils_report_errors (dlg->priv->window,
- command, return_code);
-
- svn_update_command_destroy (SVN_UPDATE_COMMAND (command));
+ GtranslatorStatusbar *status;
+
+ status =
+ GTR_STATUSBAR (gtranslator_window_get_statusbar (dlg->priv->window));
+
+ gtranslator_statusbar_flash_message (status, 0,
+ _("Subversion: Update complete."));
+
+ subversion_utils_report_errors (dlg->priv->window, command, return_code);
+
+ svn_update_command_destroy (SVN_UPDATE_COMMAND (command));
}
static void
-on_update_command_info_arrived (GtranslatorCommand *command,
- GtranslatorUpdateDialog *dlg)
+on_update_command_info_arrived (GtranslatorCommand * command,
+ GtranslatorUpdateDialog * dlg)
{
- GQueue *info;
- gchar *message;
- GtkTreeIter iter;
-
- info = svn_command_get_info_queue (SVN_COMMAND (command));
-
- while (g_queue_peek_head (info))
- {
- message = g_queue_pop_head (info);
-
- gtk_list_store_append(dlg->priv->store, &iter);
- gtk_list_store_set (dlg->priv->store, &iter,
- TEXT_COLUMN, message,
- -1);
-
- g_free (message);
- }
+ GQueue *info;
+ gchar *message;
+ GtkTreeIter iter;
+
+ info = svn_command_get_info_queue (SVN_COMMAND (command));
+
+ while (g_queue_peek_head (info))
+ {
+ message = g_queue_pop_head (info);
+
+ gtk_list_store_append (dlg->priv->store, &iter);
+ gtk_list_store_set (dlg->priv->store, &iter, TEXT_COLUMN, message, -1);
+
+ g_free (message);
+ }
}
static void
-dialog_response_handler (GtranslatorUpdateDialog *dlg,
- gint res_id)
+dialog_response_handler (GtranslatorUpdateDialog * dlg, gint res_id)
{
- switch (res_id)
- {
- case GTK_RESPONSE_APPLY:
- {
- gchar *filename;
- SvnUpdateCommand *update_command;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg->priv->dir_button));
-
- update_command = svn_update_command_new ((gchar *) filename,
- (gchar *)"",
- TRUE);
- g_free (filename);
-
- gtk_list_store_clear (dlg->priv->store);
-
- g_signal_connect (G_OBJECT (update_command), "command-finished",
- G_CALLBACK (on_update_command_finished),
- dlg);
-
- g_signal_connect (G_OBJECT (update_command), "data-arrived",
- G_CALLBACK (on_update_command_info_arrived),
- dlg);
-
- gtranslator_command_start (GTR_COMMAND (update_command));
-
- break;
- }
- default:
- gtk_widget_hide (GTK_WIDGET (dlg));
- }
+ switch (res_id)
+ {
+ case GTK_RESPONSE_APPLY:
+ {
+ gchar *filename;
+ SvnUpdateCommand *update_command;
+
+ filename =
+ gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
+ (dlg->priv->dir_button));
+
+ update_command = svn_update_command_new ((gchar *) filename,
+ (gchar *) "", TRUE);
+ g_free (filename);
+
+ gtk_list_store_clear (dlg->priv->store);
+
+ g_signal_connect (G_OBJECT (update_command), "command-finished",
+ G_CALLBACK (on_update_command_finished), dlg);
+
+ g_signal_connect (G_OBJECT (update_command), "data-arrived",
+ G_CALLBACK (on_update_command_info_arrived), dlg);
+
+ gtranslator_command_start (GTR_COMMAND (update_command));
+
+ break;
+ }
+ default:
+ gtk_widget_hide (GTK_WIDGET (dlg));
+ }
}
static void
-setup_treeview (GtranslatorUpdateDialog *dlg)
+setup_treeview (GtranslatorUpdateDialog * dlg)
{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- dlg->priv->store = gtk_list_store_new (N_COLUMNS,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->update_treeview),
- GTK_TREE_MODEL (dlg->priv->store));
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dlg->priv->update_treeview),
- FALSE);
-
- column = gtk_tree_view_column_new ();
- /*
- * Icon column
- */
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (renderer,
- "stock-id", GTK_STOCK_INFO,
- "stock-size", GTK_ICON_SIZE_MENU,
- "xalign", 1.0,
- "xpad", 6,
- NULL);
-
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
-
- /*
- * Text column
- */
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "text", TEXT_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->update_treeview),
- column);
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ dlg->priv->store = gtk_list_store_new (N_COLUMNS,
+ GDK_TYPE_PIXBUF, G_TYPE_STRING);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->update_treeview),
+ GTK_TREE_MODEL (dlg->priv->store));
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW
+ (dlg->priv->update_treeview), FALSE);
+
+ column = gtk_tree_view_column_new ();
+ /*
+ * Icon column
+ */
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (renderer,
+ "stock-id", GTK_STOCK_INFO,
+ "stock-size", GTK_ICON_SIZE_MENU,
+ "xalign", 1.0, "xpad", 6, NULL);
+
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+
+ /*
+ * Text column
+ */
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer, "text", TEXT_COLUMN, NULL);
+
+ gtk_tree_view_column_set_resizable (column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->update_treeview),
+ column);
}
static void
-setup_dir (GtranslatorUpdateDialog *dlg)
+setup_dir (GtranslatorUpdateDialog * dlg)
{
- GtranslatorTab *tab;
- GtranslatorPo *po;
- gchar *dir;
- GFile *location, *parent, *file;
-
- tab = gtranslator_window_get_active_tab (dlg->priv->window);
- po = gtranslator_tab_get_po (tab);
- location = gtranslator_po_get_location (po);
-
- /* Get the directory of the po file */
- parent = g_file_get_parent (location);
- g_object_unref (location);
-
- /* Get the parent directory */
- file = g_file_get_parent (parent);
-
- dir = g_file_get_uri (file);
-
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dlg->priv->dir_button),
- dir);
- g_free (dir);
- g_object_unref (file);
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ gchar *dir;
+ GFile *location, *parent, *file;
+
+ tab = gtranslator_window_get_active_tab (dlg->priv->window);
+ po = gtranslator_tab_get_po (tab);
+ location = gtranslator_po_get_location (po);
+
+ /* Get the directory of the po file */
+ parent = g_file_get_parent (location);
+ g_object_unref (location);
+
+ /* Get the parent directory */
+ file = g_file_get_parent (parent);
+
+ dir = g_file_get_uri (file);
+
+ gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dlg->priv->dir_button), dir);
+ g_free (dir);
+ g_object_unref (file);
}
static void
-gtranslator_update_dialog_init (GtranslatorUpdateDialog *dlg)
+gtranslator_update_dialog_init (GtranslatorUpdateDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "upadate_main_box",
- NULL
- };
-
- dlg->priv = GTR_UPDATE_DIALOG_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_REFRESH,
- GTK_RESPONSE_APPLY,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Update repository"));
- gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 600);
- gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- ret = gtranslator_utils_get_ui_objects (UI_FILE,
- root_objects,
- &error_widget,
- "update_main_box", &dlg->priv->main_box,
- "dir_button", &dlg->priv->dir_button,
- "update_treeview", &dlg->priv->update_treeview,
- NULL);
-
- if(!ret)
- {
- gtk_widget_show (error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- setup_treeview (dlg);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "upadate_main_box",
+ NULL
+ };
+
+ dlg->priv = GTR_UPDATE_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_REFRESH,
+ GTK_RESPONSE_APPLY,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Update repository"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 600);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ ret = gtranslator_utils_get_ui_objects (UI_FILE,
+ root_objects,
+ &error_widget,
+ "update_main_box",
+ &dlg->priv->main_box, "dir_button",
+ &dlg->priv->dir_button,
+ "update_treeview",
+ &dlg->priv->update_treeview, NULL);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ setup_treeview (dlg);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
}
static void
-gtranslator_update_dialog_finalize (GObject *object)
+gtranslator_update_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_update_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_update_dialog_parent_class)->finalize (object);
}
static void
-gtranslator_update_dialog_class_init (GtranslatorUpdateDialogClass *klass)
+gtranslator_update_dialog_class_init (GtranslatorUpdateDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorUpdateDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorUpdateDialogPrivate));
- object_class->finalize = gtranslator_update_dialog_finalize;
+ object_class->finalize = gtranslator_update_dialog_finalize;
}
void
-gtranslator_show_update_dialog (GtranslatorWindow *window)
+gtranslator_show_update_dialog (GtranslatorWindow * window)
{
- static GtranslatorUpdateDialog *dlg = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- if(dlg == NULL)
- {
- dlg = g_object_new (GTR_TYPE_UPDATE_DIALOG, NULL);
-
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg),
- TRUE);
-
- dlg->priv->window = window;
-
- setup_dir (dlg);
-
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
-
- gtk_widget_show (GTK_WIDGET (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_present (GTK_WINDOW (dlg));
+ static GtranslatorUpdateDialog *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_UPDATE_DIALOG, NULL);
+
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ dlg->priv->window = window;
+
+ setup_dir (dlg);
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+
+ gtk_widget_show (GTK_WIDGET (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_present (GTK_WINDOW (dlg));
}
diff --git a/plugins/subversion/update-dialog.h b/plugins/subversion/update-dialog.h
index 4d75d13..67c2817 100644
--- a/plugins/subversion/update-dialog.h
+++ b/plugins/subversion/update-dialog.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,42 +34,42 @@ G_BEGIN_DECLS
#define GTR_IS_UPDATE_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_UPDATE_DIALOG))
#define GTR_IS_UPDATE_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_UPDATE_DIALOG))
#define GTR_UPDATE_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_UPDATE_DIALOG, GtranslatorUpdateDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorUpdateDialogPrivate GtranslatorUpdateDialogPrivate;
+typedef struct _GtranslatorUpdateDialogPrivate GtranslatorUpdateDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorUpdateDialog GtranslatorUpdateDialog;
+typedef struct _GtranslatorUpdateDialog GtranslatorUpdateDialog;
struct _GtranslatorUpdateDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorUpdateDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorUpdateDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorUpdateDialogClass GtranslatorUpdateDialogClass;
+typedef struct _GtranslatorUpdateDialogClass GtranslatorUpdateDialogClass;
struct _GtranslatorUpdateDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_update_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_update_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_update_dialog_register_type (GTypeModule * module);
+ GType gtranslator_update_dialog_register_type (GTypeModule * module);
-void gtranslator_show_update_dialog (GtranslatorWindow *window);
+ void gtranslator_show_update_dialog (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __UPDATE_DIALOG_H__ */
diff --git a/plugins/subversion/vcs-status-tree-view.c b/plugins/subversion/vcs-status-tree-view.c
index 379d785..f302a71 100644
--- a/plugins/subversion/vcs-status-tree-view.c
+++ b/plugins/subversion/vcs-status-tree-view.c
@@ -26,370 +26,362 @@
#include <string.h>
#include <glib/gi18n.h>
-enum
+enum
{
- COL_SELECTED,
- COL_STATUS,
- COL_PATH,
- NUM_COLS
+ COL_SELECTED,
+ COL_STATUS,
+ COL_PATH,
+ NUM_COLS
};
enum
{
- GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES = 1,
- GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS
+ GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES = 1,
+ GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS
};
struct _GtranslatorVcsStatusTreeViewPriv
{
- GtkListStore *store;
- GHashTable *selected_paths;
- guint status_codes;
- gboolean show_status;
+ GtkListStore *store;
+ GHashTable *selected_paths;
+ guint status_codes;
+ gboolean show_status;
};
-G_DEFINE_TYPE (GtranslatorVcsStatusTreeView, gtranslator_vcs_status_tree_view,
- GTK_TYPE_TREE_VIEW);
+G_DEFINE_TYPE (GtranslatorVcsStatusTreeView, gtranslator_vcs_status_tree_view,
+ GTK_TYPE_TREE_VIEW);
static void
-on_selected_column_toggled (GtkCellRendererToggle *renderer,
- gchar *tree_path,
- GtranslatorVcsStatusTreeView *self)
+on_selected_column_toggled (GtkCellRendererToggle * renderer,
+ gchar * tree_path,
+ GtranslatorVcsStatusTreeView * self)
{
- GtkTreeIter iter;
- gchar *vcs_path;
- gboolean selected;
-
- gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (self->priv->store),
- &iter, tree_path);
-
- gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
- COL_PATH, &vcs_path,
- COL_SELECTED, &selected, -1);
-
- gtk_list_store_set (self->priv->store, &iter,
- COL_SELECTED, !selected, -1);
-
- g_free (vcs_path);
-
+ GtkTreeIter iter;
+ gchar *vcs_path;
+ gboolean selected;
+
+ gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (self->priv->store),
+ &iter, tree_path);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
+ COL_PATH, &vcs_path, COL_SELECTED, &selected, -1);
+
+ gtk_list_store_set (self->priv->store, &iter, COL_SELECTED, !selected, -1);
+
+ g_free (vcs_path);
+
}
static void
-gtranslator_vcs_status_tree_view_create_columns (GtranslatorVcsStatusTreeView *self)
+gtranslator_vcs_status_tree_view_create_columns (GtranslatorVcsStatusTreeView
+ * self)
{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- /* Selected column */
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
- gtk_tree_view_column_add_attribute (column, renderer, "active",
- COL_SELECTED);
-
- g_signal_connect (G_OBJECT (renderer), "toggled",
- G_CALLBACK (on_selected_column_toggled),
- self);
-
- /* Status column */
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
- gtk_tree_view_column_add_attribute (column, renderer, "text",
- COL_STATUS);
-
- /* Path column */
- column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
- gtk_tree_view_column_add_attribute (column, renderer, "text",
- COL_PATH);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (self),
- GTK_TREE_MODEL (self->priv->store));
- g_object_unref (self->priv->store);
-
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ /* Selected column */
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_toggle_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
+ gtk_tree_view_column_add_attribute (column, renderer, "active",
+ COL_SELECTED);
+
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (on_selected_column_toggled), self);
+
+ /* Status column */
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
+ gtk_tree_view_column_add_attribute (column, renderer, "text", COL_STATUS);
+
+ /* Path column */
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (self), column);
+ gtk_tree_view_column_add_attribute (column, renderer, "text", COL_PATH);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self),
+ GTK_TREE_MODEL (self->priv->store));
+ g_object_unref (self->priv->store);
+
}
static gint
-path_sort (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
- gpointer user_data)
+path_sort (GtkTreeModel * model, GtkTreeIter * a, GtkTreeIter * b,
+ gpointer user_data)
{
- gint compare_value;
- gchar *path1;
- gchar *path2;
-
- gtk_tree_model_get (model, a, COL_PATH, &path1, -1);
- gtk_tree_model_get (model, b, COL_PATH, &path2, -1);
-
- compare_value = strcmp (path1, path2);
-
- g_free (path1);
- g_free (path2);
-
- return compare_value;
+ gint compare_value;
+ gchar *path1;
+ gchar *path2;
+
+ gtk_tree_model_get (model, a, COL_PATH, &path1, -1);
+ gtk_tree_model_get (model, b, COL_PATH, &path2, -1);
+
+ compare_value = strcmp (path1, path2);
+
+ g_free (path1);
+ g_free (path2);
+
+ return compare_value;
}
static void
-gtranslator_vcs_status_tree_view_init (GtranslatorVcsStatusTreeView *self)
+gtranslator_vcs_status_tree_view_init (GtranslatorVcsStatusTreeView * self)
{
- GtkTreeSortable *sortable;
-
- self->priv = g_new0 (GtranslatorVcsStatusTreeViewPriv, 1);
- self->priv->store = gtk_list_store_new (NUM_COLS,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING,
- G_TYPE_STRING);
- self->priv->selected_paths = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
-
- gtranslator_vcs_status_tree_view_create_columns (self);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self), FALSE);
-
- sortable = GTK_TREE_SORTABLE (self->priv->store);
- gtk_tree_sortable_set_sort_column_id (sortable, COL_PATH,
- GTK_SORT_ASCENDING);
- gtk_tree_sortable_set_sort_func (sortable, COL_PATH, path_sort, NULL,
- NULL);
+ GtkTreeSortable *sortable;
+
+ self->priv = g_new0 (GtranslatorVcsStatusTreeViewPriv, 1);
+ self->priv->store = gtk_list_store_new (NUM_COLS,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_STRING);
+ self->priv->selected_paths = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
+
+ gtranslator_vcs_status_tree_view_create_columns (self);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self), FALSE);
+
+ sortable = GTK_TREE_SORTABLE (self->priv->store);
+ gtk_tree_sortable_set_sort_column_id (sortable, COL_PATH,
+ GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_func (sortable, COL_PATH, path_sort, NULL, NULL);
}
static void
-gtranslator_vcs_status_tree_view_finalize (GObject *object)
+gtranslator_vcs_status_tree_view_finalize (GObject * object)
{
- GtranslatorVcsStatusTreeView *self;
-
- self = GTR_VCS_STATUS_TREE_VIEW (object);
-
- g_hash_table_destroy (self->priv->selected_paths);
- g_free (self->priv);
-
- G_OBJECT_CLASS (gtranslator_vcs_status_tree_view_parent_class)->finalize (object);
+ GtranslatorVcsStatusTreeView *self;
+
+ self = GTR_VCS_STATUS_TREE_VIEW (object);
+
+ g_hash_table_destroy (self->priv->selected_paths);
+ g_free (self->priv);
+
+ G_OBJECT_CLASS (gtranslator_vcs_status_tree_view_parent_class)->
+ finalize (object);
}
static void
-gtranslator_vcs_status_tree_view_set_property (GObject *object, guint property_id,
- const GValue *value,
- GParamSpec *param_spec)
+gtranslator_vcs_status_tree_view_set_property (GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * param_spec)
{
- GtranslatorVcsStatusTreeView *self;
- GtkTreeView *tree_view;
- GtkTreeViewColumn *column;
-
- self = GTR_VCS_STATUS_TREE_VIEW (object);
-
- switch (property_id)
- {
- case GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES:
- self->priv->status_codes = g_value_get_flags (value);
- break;
- case GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS:
- tree_view = GTK_TREE_VIEW (object);
- column = gtk_tree_view_get_column (tree_view, COL_STATUS);
- self->priv->show_status = g_value_get_boolean (value);
-
- gtk_tree_view_column_set_visible (column, self->priv->show_status);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
- break;
- }
+ GtranslatorVcsStatusTreeView *self;
+ GtkTreeView *tree_view;
+ GtkTreeViewColumn *column;
+
+ self = GTR_VCS_STATUS_TREE_VIEW (object);
+
+ switch (property_id)
+ {
+ case GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES:
+ self->priv->status_codes = g_value_get_flags (value);
+ break;
+ case GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS:
+ tree_view = GTK_TREE_VIEW (object);
+ column = gtk_tree_view_get_column (tree_view, COL_STATUS);
+ self->priv->show_status = g_value_get_boolean (value);
+
+ gtk_tree_view_column_set_visible (column, self->priv->show_status);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
+ break;
+ }
}
static void
-gtranslator_vcs_status_tree_view_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *param_spec)
+gtranslator_vcs_status_tree_view_get_property (GObject * object,
+ guint property_id,
+ GValue * value,
+ GParamSpec * param_spec)
{
- GtranslatorVcsStatusTreeView *self;
-
- self = GTR_VCS_STATUS_TREE_VIEW (object);
-
- switch (property_id)
- {
- case GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES:
- g_value_set_flags (value, self->priv->status_codes);
- break;
- case GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS:
- g_value_set_boolean (value, self->priv->show_status);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
- break;
- }
+ GtranslatorVcsStatusTreeView *self;
+
+ self = GTR_VCS_STATUS_TREE_VIEW (object);
+
+ switch (property_id)
+ {
+ case GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES:
+ g_value_set_flags (value, self->priv->status_codes);
+ break;
+ case GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS:
+ g_value_set_boolean (value, self->priv->show_status);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, param_spec);
+ break;
+ }
}
static void
-gtranslator_vcs_status_tree_view_class_init (GtranslatorVcsStatusTreeViewClass *klass)
+gtranslator_vcs_status_tree_view_class_init (GtranslatorVcsStatusTreeViewClass
+ * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- GParamSpec *param_spec;
-
- object_class->finalize = gtranslator_vcs_status_tree_view_finalize;
- object_class->get_property = gtranslator_vcs_status_tree_view_get_property;
- object_class->set_property = gtranslator_vcs_status_tree_view_set_property;
-
- param_spec = g_param_spec_flags ("status-codes", "Status codes",
- "Control which status codes are shown in "
- "the list.",
- GTR_TYPE_VCS_STATUS,
- GTR_VCS_DEFAULT_STATUS_CODES,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (object_class,
- GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES,
- param_spec);
-
- param_spec = g_param_spec_boolean ("show-status", "Show status",
- "Show or hide status description",
- TRUE,
- G_PARAM_READWRITE);
- g_object_class_install_property (object_class,
- GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS,
- param_spec);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GParamSpec *param_spec;
+
+ object_class->finalize = gtranslator_vcs_status_tree_view_finalize;
+ object_class->get_property = gtranslator_vcs_status_tree_view_get_property;
+ object_class->set_property = gtranslator_vcs_status_tree_view_set_property;
+
+ param_spec = g_param_spec_flags ("status-codes", "Status codes",
+ "Control which status codes are shown in "
+ "the list.",
+ GTR_TYPE_VCS_STATUS,
+ GTR_VCS_DEFAULT_STATUS_CODES,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (object_class,
+ GTR_VCS_STATUS_TREE_VIEW_CONSTRUCT_STATUS_CODES,
+ param_spec);
+
+ param_spec = g_param_spec_boolean ("show-status", "Show status",
+ "Show or hide status description",
+ TRUE, G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ GTR_VCS_STATUS_TREE_VIEW_SHOW_STATUS,
+ param_spec);
}
GtkWidget *
gtranslator_vcs_status_tree_view_new (void)
{
- return g_object_new (GTR_VCS_TYPE_STATUS_TREE_VIEW, NULL);
+ return g_object_new (GTR_VCS_TYPE_STATUS_TREE_VIEW, NULL);
}
void
-gtranslator_vcs_status_tree_view_destroy (GtranslatorVcsStatusTreeView *self)
+gtranslator_vcs_status_tree_view_destroy (GtranslatorVcsStatusTreeView * self)
{
- g_object_unref (self);
+ g_object_unref (self);
}
void
-gtranslator_vcs_status_tree_view_add (GtranslatorVcsStatusTreeView *self, gchar *path,
- GtranslatorVcsStatus status, gboolean selected)
+gtranslator_vcs_status_tree_view_add (GtranslatorVcsStatusTreeView * self,
+ gchar * path,
+ GtranslatorVcsStatus status,
+ gboolean selected)
{
- GtkTreeIter iter;
-
- if (status & self->priv->status_codes)
+ GtkTreeIter iter;
+
+ if (status & self->priv->status_codes)
+ {
+ gtk_list_store_append (self->priv->store, &iter);
+
+ gtk_list_store_set (self->priv->store, &iter,
+ COL_SELECTED, selected, COL_PATH, path, -1);
+
+ if (selected)
+ {
+ g_hash_table_insert (self->priv->selected_paths, g_strdup (path),
+ NULL);
+ }
+
+ switch (status)
{
- gtk_list_store_append (self->priv->store, &iter);
-
- gtk_list_store_set (self->priv->store, &iter,
- COL_SELECTED, selected,
- COL_PATH, path,
- -1);
-
- if (selected)
- {
- g_hash_table_insert (self->priv->selected_paths, g_strdup (path),
- NULL);
- }
-
- switch (status)
- {
- case GTR_VCS_STATUS_MODIFIED:
- gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
- _("Modified"), -1);
- break;
- case GTR_VCS_STATUS_ADDED:
- gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
- _("Added"), -1);
- break;
- case GTR_VCS_STATUS_DELETED:
- gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
- _("Deleted"), -1);
- break;
- case GTR_VCS_STATUS_CONFLICTED:
- gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
- _("Conflicted"), -1);
- break;
- case GTR_VCS_STATUS_MISSING:
- gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
- _("Missing"), -1);
- break;
- case GTR_VCS_STATUS_NONE:
- default:
- break;
-
- }
+ case GTR_VCS_STATUS_MODIFIED:
+ gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
+ _("Modified"), -1);
+ break;
+ case GTR_VCS_STATUS_ADDED:
+ gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
+ _("Added"), -1);
+ break;
+ case GTR_VCS_STATUS_DELETED:
+ gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
+ _("Deleted"), -1);
+ break;
+ case GTR_VCS_STATUS_CONFLICTED:
+ gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
+ _("Conflicted"), -1);
+ break;
+ case GTR_VCS_STATUS_MISSING:
+ gtk_list_store_set (self->priv->store, &iter, COL_STATUS,
+ _("Missing"), -1);
+ break;
+ case GTR_VCS_STATUS_NONE:
+ default:
+ break;
+
}
+ }
}
static gboolean
-select_all_paths (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
- GtranslatorVcsStatusTreeView *self)
-{
- gtk_list_store_set (self->priv->store, iter,
- COL_SELECTED, TRUE,
- -1);
-
- return FALSE;
+select_all_paths (GtkTreeModel * model, GtkTreePath * path,
+ GtkTreeIter * iter, GtranslatorVcsStatusTreeView * self)
+{
+ gtk_list_store_set (self->priv->store, iter, COL_SELECTED, TRUE, -1);
+
+ return FALSE;
}
void
-gtranslator_vcs_status_tree_view_select_all (GtranslatorVcsStatusTreeView *self)
+gtranslator_vcs_status_tree_view_select_all (GtranslatorVcsStatusTreeView *
+ self)
{
- gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
- (GtkTreeModelForeachFunc) select_all_paths,
- self);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
+ (GtkTreeModelForeachFunc) select_all_paths, self);
}
-static gboolean
-unselect_all_paths (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
- GtranslatorVcsStatusTreeView *self)
+static gboolean
+unselect_all_paths (GtkTreeModel * model, GtkTreePath * path,
+ GtkTreeIter * iter, GtranslatorVcsStatusTreeView * self)
{
- gtk_list_store_set (self->priv->store, iter,
- COL_SELECTED, FALSE,
- -1);
-
- return FALSE;
+ gtk_list_store_set (self->priv->store, iter, COL_SELECTED, FALSE, -1);
+
+ return FALSE;
}
void
-gtranslator_vcs_status_tree_view_unselect_all (GtranslatorVcsStatusTreeView *self)
+gtranslator_vcs_status_tree_view_unselect_all (GtranslatorVcsStatusTreeView *
+ self)
{
- gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
- (GtkTreeModelForeachFunc) unselect_all_paths,
- self);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
+ (GtkTreeModelForeachFunc) unselect_all_paths, self);
}
static gboolean
-create_selected_paths_list (GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, GList **list)
+create_selected_paths_list (GtkTreeModel * model, GtkTreePath * path,
+ GtkTreeIter * iter, GList ** list)
{
- gboolean selected;
- gchar *file_path;
-
- gtk_tree_model_get (model, iter,
- COL_SELECTED, &selected,
- COL_PATH, &file_path,
- -1);
-
- if (selected)
- *list = g_list_append (*list, g_strdup (file_path));
-
- return FALSE;
+ gboolean selected;
+ gchar *file_path;
+
+ gtk_tree_model_get (model, iter,
+ COL_SELECTED, &selected, COL_PATH, &file_path, -1);
+
+ if (selected)
+ *list = g_list_append (*list, g_strdup (file_path));
+
+ return FALSE;
}
GList *
-gtranslator_vcs_status_tree_view_get_selected (GtranslatorVcsStatusTreeView *self)
+gtranslator_vcs_status_tree_view_get_selected (GtranslatorVcsStatusTreeView *
+ self)
{
- GList *list;
-
- list = NULL;
-
- gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
- (GtkTreeModelForeachFunc) create_selected_paths_list,
- &list);
-
- return list;
+ GList *list;
+
+ list = NULL;
+
+ gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
+ (GtkTreeModelForeachFunc)
+ create_selected_paths_list, &list);
+
+ return list;
}
void
-gtranslator_vsc_status_tree_view_clear (GtranslatorVcsStatusTreeView *self)
+gtranslator_vsc_status_tree_view_clear (GtranslatorVcsStatusTreeView * self)
{
- g_return_if_fail (GTR_VCS_IS_STATUS_TREE_VIEW (self));
-
- gtk_list_store_clear (self->priv->store);
-}
\ No newline at end of file
+ g_return_if_fail (GTR_VCS_IS_STATUS_TREE_VIEW (self));
+
+ gtk_list_store_clear (self->priv->store);
+}
diff --git a/plugins/subversion/vcs-status-tree-view.h b/plugins/subversion/vcs-status-tree-view.h
index 3876464..978ebe6 100644
--- a/plugins/subversion/vcs-status-tree-view.h
+++ b/plugins/subversion/vcs-status-tree-view.h
@@ -30,60 +30,69 @@
#include "subversion-enum-types.h"
G_BEGIN_DECLS
-
#define GTR_VCS_TYPE_STATUS_TREE_VIEW (gtranslator_vcs_status_tree_view_get_type ())
#define GTR_VCS_STATUS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_VCS_TYPE_STATUS_TREE_VIEW, GtranslatorVcsStatusTreeView))
#define GTR_VCS_STATUS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_VCS_TYPE_STATUS_TREE_VIEW, GtranslatorVcsStatusTreeViewClass))
#define GTR_VCS_IS_STATUS_TREE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_VCS_TYPE_STATUS_TREE_VIEW))
#define GTR_VCS_IS_STATUS_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_VCS_TYPE_STATUS_TREE_VIEW))
#define GTR_VCS_STATUS_TREE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_VCS_TYPE_STATUS_TREE_VIEW, GtranslatorVcsStatusTreeViewClass))
-
/* Show default status codes: Modified, Added, Deleted, and Conflicted */
#define GTR_VCS_DEFAULT_STATUS_CODES (GTR_VCS_STATUS_MODIFIED | \
GTR_VCS_STATUS_ADDED | \
GTR_VCS_STATUS_DELETED | \
GTR_VCS_STATUS_CONFLICTED)
-
-typedef struct _GtranslatorVcsStatusTreeViewClass GtranslatorVcsStatusTreeViewClass;
+typedef struct _GtranslatorVcsStatusTreeViewClass
+ GtranslatorVcsStatusTreeViewClass;
typedef struct _GtranslatorVcsStatusTreeView GtranslatorVcsStatusTreeView;
-typedef struct _GtranslatorVcsStatusTreeViewPriv GtranslatorVcsStatusTreeViewPriv;
+typedef struct _GtranslatorVcsStatusTreeViewPriv
+ GtranslatorVcsStatusTreeViewPriv;
struct _GtranslatorVcsStatusTreeViewClass
{
- GtkTreeViewClass parent_class;
+ GtkTreeViewClass parent_class;
};
struct _GtranslatorVcsStatusTreeView
{
- GtkTreeView parent_instance;
-
- GtranslatorVcsStatusTreeViewPriv *priv;
+ GtkTreeView parent_instance;
+
+ GtranslatorVcsStatusTreeViewPriv *priv;
};
typedef enum
{
- /* Unversioned, ignored, or uninteresting items */
- GTR_VCS_STATUS_NONE = 0, /*< skip >*/
-
- GTR_VCS_STATUS_MODIFIED = 1 << 0,
- GTR_VCS_STATUS_ADDED = 1 << 1,
- GTR_VCS_STATUS_DELETED = 1 << 2,
- GTR_VCS_STATUS_CONFLICTED = 1 << 3,
- GTR_VCS_STATUS_MISSING = 1 << 4,
+ /* Unversioned, ignored, or uninteresting items */
+ GTR_VCS_STATUS_NONE = 0, /*< skip > */
+
+ GTR_VCS_STATUS_MODIFIED = 1 << 0,
+ GTR_VCS_STATUS_ADDED = 1 << 1,
+ GTR_VCS_STATUS_DELETED = 1 << 2,
+ GTR_VCS_STATUS_CONFLICTED = 1 << 3,
+ GTR_VCS_STATUS_MISSING = 1 << 4,
} GtranslatorVcsStatus;
-GType gtranslator_vcs_status_tree_view_get_type (void) G_GNUC_CONST;
-GtkWidget *gtranslator_vcs_status_tree_view_new (void);
-void gtranslator_vcs_status_tree_view_destroy (GtranslatorVcsStatusTreeView *self);
-void gtranslator_vcs_status_tree_view_add (GtranslatorVcsStatusTreeView *self,
- gchar *path,
- GtranslatorVcsStatus status,
- gboolean selected);
-void gtranslator_vsc_status_tree_view_clear (GtranslatorVcsStatusTreeView *self);
-void gtranslator_vcs_status_tree_view_select_all (GtranslatorVcsStatusTreeView *self);
-void gtranslator_vcs_status_tree_view_unselect_all (GtranslatorVcsStatusTreeView *self);
-GList *gtranslator_vcs_status_tree_view_get_selected (GtranslatorVcsStatusTreeView *self);
+GType
+gtranslator_vcs_status_tree_view_get_type (void)
+ G_GNUC_CONST;
+ GtkWidget *gtranslator_vcs_status_tree_view_new (void);
+ void
+ gtranslator_vcs_status_tree_view_destroy (GtranslatorVcsStatusTreeView
+ * self);
+ void gtranslator_vcs_status_tree_view_add (GtranslatorVcsStatusTreeView *
+ self, gchar * path,
+ GtranslatorVcsStatus status,
+ gboolean selected);
+ void gtranslator_vsc_status_tree_view_clear (GtranslatorVcsStatusTreeView
+ * self);
+ void
+ gtranslator_vcs_status_tree_view_select_all
+ (GtranslatorVcsStatusTreeView * self);
+ void
+ gtranslator_vcs_status_tree_view_unselect_all
+ (GtranslatorVcsStatusTreeView * self);
+ GList
+ *gtranslator_vcs_status_tree_view_get_selected
+ (GtranslatorVcsStatusTreeView * self);
G_END_DECLS
-
#endif /* _GTR_VCS_STATUS_TREE_VIEW_H_ */
diff --git a/src/actions-documents.c b/src/actions-documents.c
index 78462ee..560d71d 100644
--- a/src/actions-documents.c
+++ b/src/actions-documents.c
@@ -22,19 +22,19 @@
#include "actions.h"
void
-gtranslator_actions_documents_next_document (GtkAction * action,
- GtranslatorWindow *window)
+gtranslator_actions_documents_next_document (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorNotebook *notebook;
- notebook = gtranslator_window_get_notebook (window);
- gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
+ GtranslatorNotebook *notebook;
+ notebook = gtranslator_window_get_notebook (window);
+ gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
}
void
-gtranslator_actions_documents_previous_document (GtkAction * action,
- GtranslatorWindow *window)
+gtranslator_actions_documents_previous_document (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorNotebook *notebook;
- notebook = gtranslator_window_get_notebook (window);
- gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
+ GtranslatorNotebook *notebook;
+ notebook = gtranslator_window_get_notebook (window);
+ gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
}
diff --git a/src/actions-edit.c b/src/actions-edit.c
index c8beb2c..c05f95d 100644
--- a/src/actions-edit.c
+++ b/src/actions-edit.c
@@ -33,156 +33,156 @@
#include "window.h"
void
-gtranslator_actions_edit_undo (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_undo (GtkAction * action, GtranslatorWindow * window)
{
- GtranslatorView *active_view;
- GtkSourceBuffer *active_document;
+ GtranslatorView *active_view;
+ GtkSourceBuffer *active_document;
- active_view = gtranslator_window_get_active_view (window);
- g_return_if_fail (active_view);
+ active_view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (active_view);
- active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
+ active_document =
+ GTK_SOURCE_BUFFER (gtk_text_view_get_buffer
+ (GTK_TEXT_VIEW (active_view)));
- gtk_text_buffer_begin_user_action(GTK_TEXT_BUFFER(active_document));
- gtk_source_buffer_undo (active_document);
- gtk_text_buffer_end_user_action(GTK_TEXT_BUFFER(active_document));
+ gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (active_document));
+ gtk_source_buffer_undo (active_document);
+ gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (active_document));
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
}
void
-gtranslator_actions_edit_redo (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_redo (GtkAction * action, GtranslatorWindow * window)
{
- GtranslatorView *active_view;
- GtkSourceBuffer *active_document;
+ GtranslatorView *active_view;
+ GtkSourceBuffer *active_document;
- active_view = gtranslator_window_get_active_view (window);
- g_return_if_fail (active_view);
+ active_view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (active_view);
- active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
+ active_document =
+ GTK_SOURCE_BUFFER (gtk_text_view_get_buffer
+ (GTK_TEXT_VIEW (active_view)));
- gtk_text_buffer_begin_user_action(GTK_TEXT_BUFFER(active_document));
- gtk_source_buffer_redo (active_document);
- gtk_text_buffer_end_user_action(GTK_TEXT_BUFFER(active_document));
+ gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (active_document));
+ gtk_source_buffer_redo (active_document);
+ gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (active_document));
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
}
void
-gtranslator_actions_edit_cut (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_cut (GtkAction * action, GtranslatorWindow * window)
{
- GtranslatorView *active_view;
+ GtranslatorView *active_view;
- active_view = gtranslator_window_get_active_view (window);
- g_return_if_fail (active_view);
+ active_view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (active_view);
- gtranslator_view_cut_clipboard (active_view);
+ gtranslator_view_cut_clipboard (active_view);
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
}
void
-gtranslator_actions_edit_copy (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_copy (GtkAction * action, GtranslatorWindow * window)
{
- GtranslatorView *active_view;
+ GtranslatorView *active_view;
- active_view = gtranslator_window_get_active_view (window);
- g_return_if_fail (active_view);
+ active_view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (active_view);
- gtranslator_view_copy_clipboard (active_view);
+ gtranslator_view_copy_clipboard (active_view);
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
}
void
-gtranslator_actions_edit_paste (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_paste (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorView *active_view;
+ GtranslatorView *active_view;
- active_view = gtranslator_window_get_active_view (window);
- g_return_if_fail (active_view);
+ active_view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (active_view);
- gtranslator_view_paste_clipboard (active_view);
+ gtranslator_view_paste_clipboard (active_view);
- gtk_widget_grab_focus (GTK_WIDGET (active_view));
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
}
/*
* Use the untranslated message as the translation.
*/
-void
-gtranslator_message_copy_to_translation(GtkAction *action,
- GtranslatorWindow *window)
+void
+gtranslator_message_copy_to_translation (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
-
- current = gtranslator_window_get_active_tab (window);
-
- gtranslator_tab_copy_to_translation (current);
+ GtranslatorTab *current;
+
+ current = gtranslator_window_get_active_tab (window);
+
+ gtranslator_tab_copy_to_translation (current);
}
/*
* Toggle the sticky status
*/
-void
-gtranslator_message_status_toggle_fuzzy(GtkAction *action,
- GtranslatorWindow *window)
+void
+gtranslator_message_status_toggle_fuzzy (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
- GList *msg;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- msg = gtranslator_po_get_current_message(po);
-
- if(gtranslator_msg_is_fuzzy(msg->data))
- gtranslator_msg_set_fuzzy(msg->data, FALSE);
- else
- gtranslator_msg_set_fuzzy(msg->data, TRUE);
-
- /*
- * Emit that message was changed.
- */
- g_signal_emit_by_name(current, "message_changed", msg->data);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+ GList *msg;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ msg = gtranslator_po_get_current_message (po);
+
+ if (gtranslator_msg_is_fuzzy (msg->data))
+ gtranslator_msg_set_fuzzy (msg->data, FALSE);
+ else
+ gtranslator_msg_set_fuzzy (msg->data, TRUE);
+
+ /*
+ * Emit that message was changed.
+ */
+ g_signal_emit_by_name (current, "message_changed", msg->data);
}
void
-gtranslator_actions_edit_preferences(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_preferences (GtkAction * action,
+ GtranslatorWindow * window)
{
- gtranslator_show_preferences_dialog(window);
+ gtranslator_show_preferences_dialog (window);
}
void
-gtranslator_actions_edit_header(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_header (GtkAction * action,
+ GtranslatorWindow * window)
{
- gtranslator_show_header_dialog(window);
+ gtranslator_show_header_dialog (window);
}
void
-gtranslator_edit_message_comment(GtkAction *action,
- GtranslatorWindow *window)
-{
- gtranslator_show_comment_dialog(window);
+gtranslator_edit_message_comment (GtkAction * action,
+ GtranslatorWindow * window)
+{
+ gtranslator_show_comment_dialog (window);
}
void
-gtranslator_actions_edit_clear (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_edit_clear (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *tab;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- tab = gtranslator_window_get_active_tab (window);
-
- gtranslator_tab_clear_msgstr_views (tab);
+ GtranslatorTab *tab;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ tab = gtranslator_window_get_active_tab (window);
+
+ gtranslator_tab_clear_msgstr_views (tab);
}
diff --git a/src/actions-file.c b/src/actions-file.c
index ea83405..edf91ed 100644
--- a/src/actions-file.c
+++ b/src/actions-file.c
@@ -45,142 +45,148 @@
#define GTR_TAB_SAVE_AS "gtranslator-tab-save-as"
#define GTR_IS_CLOSING_ALL "gtranslator-is-closing-all"
-static void load_file_list(GtranslatorWindow *window,
- const GSList *uris);
+static void load_file_list (GtranslatorWindow * window, const GSList * uris);
/*
* The main file opening function. Checks that the file isn't already open,
* and if not, opens it in a new tab.
*/
-gboolean
-gtranslator_open (GFile *location,
- GtranslatorWindow *window,
- GError **error)
+gboolean
+gtranslator_open (GFile * location,
+ GtranslatorWindow * window, GError ** error)
{
- GtranslatorHeader *header;
- GtranslatorPo *po;
- GtranslatorTab *tab;
- GList *current;
- GtranslatorView *active_view;
- const gchar *project_id;
-
- /*
- * If the filename can't be opened, pass the error back to the caller
- * to handle.
- */
- po = gtranslator_po_new();
- gtranslator_po_parse (po, location, error);
-
- if((*error != NULL) && (((GError *)*error)->code != GTR_PO_ERROR_RECOVERY))
- return FALSE;
-
- header = gtranslator_po_get_header(po);
- project_id = gtranslator_header_get_prj_id_version(header);
-
- /*
- * If not a crash/temporary file, add to the history.
- */
- gtranslator_recent_add (window, location, project_id);
-
- /*
- * Create a page to add to our list of open files
- */
- tab = gtranslator_window_create_tab(window, po);
- gtranslator_window_set_active_tab (window, GTK_WIDGET (tab));
-
- /*
- * Show the current message.
- */
- current = gtranslator_po_get_current_message(po);
- gtranslator_tab_message_go_to (tab, current, FALSE, GTR_TAB_MOVE_NONE);
-
- /*
- * Grab the focus
- */
- active_view = gtranslator_tab_get_active_view(tab);
- gtk_widget_grab_focus(GTK_WIDGET(active_view));
-
- gtranslator_statusbar_update_progress_bar (GTR_STATUSBAR (gtranslator_window_get_statusbar (window)),
- (gdouble)gtranslator_po_get_translated_count (po),
- (gdouble)gtranslator_po_get_messages_count (po));
-
- return TRUE;
+ GtranslatorHeader *header;
+ GtranslatorPo *po;
+ GtranslatorTab *tab;
+ GList *current;
+ GtranslatorView *active_view;
+ const gchar *project_id;
+
+ /*
+ * If the filename can't be opened, pass the error back to the caller
+ * to handle.
+ */
+ po = gtranslator_po_new ();
+ gtranslator_po_parse (po, location, error);
+
+ if ((*error != NULL)
+ && (((GError *) * error)->code != GTR_PO_ERROR_RECOVERY))
+ return FALSE;
+
+ header = gtranslator_po_get_header (po);
+ project_id = gtranslator_header_get_prj_id_version (header);
+
+ /*
+ * If not a crash/temporary file, add to the history.
+ */
+ gtranslator_recent_add (window, location, project_id);
+
+ /*
+ * Create a page to add to our list of open files
+ */
+ tab = gtranslator_window_create_tab (window, po);
+ gtranslator_window_set_active_tab (window, GTK_WIDGET (tab));
+
+ /*
+ * Show the current message.
+ */
+ current = gtranslator_po_get_current_message (po);
+ gtranslator_tab_message_go_to (tab, current, FALSE, GTR_TAB_MOVE_NONE);
+
+ /*
+ * Grab the focus
+ */
+ active_view = gtranslator_tab_get_active_view (tab);
+ gtk_widget_grab_focus (GTK_WIDGET (active_view));
+
+ gtranslator_statusbar_update_progress_bar (GTR_STATUSBAR
+ (gtranslator_window_get_statusbar
+ (window)),
+ (gdouble)
+ gtranslator_po_get_translated_count
+ (po),
+ (gdouble)
+ gtranslator_po_get_messages_count
+ (po));
+
+ return TRUE;
}
-static void
+static void
gtranslator_po_parse_files_from_dialog (GtkWidget * dialog,
- GtranslatorWindow *window)
+ GtranslatorWindow * window)
{
- GSList *po_files, *l;
- GSList *locations = NULL;
- GFile *file, *parent;
- gchar *uri;
-
- po_files = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
- for (l = po_files; l != NULL; l = g_slist_next (l))
- {
- GFile *file;
-
- file = g_file_new_for_uri (l->data);
- locations = g_slist_prepend (locations, file);
- }
-
- /*
- * We store latest directory
- */
- file = g_file_new_for_uri (po_files->data);
- g_slist_foreach (po_files, (GFunc)g_free, NULL);
- g_slist_free (po_files);
-
- parent = g_file_get_parent (file);
- g_object_unref (file);
-
- uri = g_file_get_uri (parent);
- g_object_unref (parent);
- _gtranslator_application_set_last_dir (GTR_APP,
- uri);
-
- g_free (uri);
-
- /*
- * Open the file via our centralized opening function.
- */
- load_file_list (window, (const GSList *)locations);
- g_slist_foreach (locations, (GFunc)g_object_unref, NULL);
- g_slist_free (locations);
-
- /*
- * Destroy the dialog
- */
- gtk_widget_destroy (dialog);
+ GSList *po_files, *l;
+ GSList *locations = NULL;
+ GFile *file, *parent;
+ gchar *uri;
+
+ po_files = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
+ for (l = po_files; l != NULL; l = g_slist_next (l))
+ {
+ GFile *file;
+
+ file = g_file_new_for_uri (l->data);
+ locations = g_slist_prepend (locations, file);
+ }
+
+ /*
+ * We store latest directory
+ */
+ file = g_file_new_for_uri (po_files->data);
+ g_slist_foreach (po_files, (GFunc) g_free, NULL);
+ g_slist_free (po_files);
+
+ parent = g_file_get_parent (file);
+ g_object_unref (file);
+
+ uri = g_file_get_uri (parent);
+ g_object_unref (parent);
+ _gtranslator_application_set_last_dir (GTR_APP, uri);
+
+ g_free (uri);
+
+ /*
+ * Open the file via our centralized opening function.
+ */
+ load_file_list (window, (const GSList *) locations);
+ g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
+ g_slist_free (locations);
+
+ /*
+ * Destroy the dialog
+ */
+ gtk_widget_destroy (dialog);
}
static void
-gtranslator_file_chooser_analyse(gpointer dialog,
- FileselMode mode,
- GtranslatorWindow *window)
-{
- gint reply;
-
- reply = gtk_dialog_run(GTK_DIALOG (dialog));
- switch (reply){
- case GTK_RESPONSE_ACCEPT:
- if (mode == FILESEL_OPEN){
- gtranslator_po_parse_files_from_dialog(GTK_WIDGET(dialog),
- window);
- }
- break;
- case GTK_RESPONSE_CANCEL:
- gtk_widget_hide(GTK_WIDGET(dialog));
- break;
- case GTK_RESPONSE_DELETE_EVENT:
- gtk_widget_hide(GTK_WIDGET(dialog));
- break;
- default:
- break;
+gtranslator_file_chooser_analyse (gpointer dialog,
+ FileselMode mode,
+ GtranslatorWindow * window)
+{
+ gint reply;
+
+ reply = gtk_dialog_run (GTK_DIALOG (dialog));
+ switch (reply)
+ {
+ case GTK_RESPONSE_ACCEPT:
+ if (mode == FILESEL_OPEN)
+ {
+ gtranslator_po_parse_files_from_dialog (GTK_WIDGET (dialog),
+ window);
}
+ break;
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_hide (GTK_WIDGET (dialog));
+ break;
+ case GTK_RESPONSE_DELETE_EVENT:
+ gtk_widget_hide (GTK_WIDGET (dialog));
+ break;
+ default:
+ break;
+ }
}
@@ -188,115 +194,113 @@ gtranslator_file_chooser_analyse(gpointer dialog,
* The "Open file" dialog.
*/
void
-gtranslator_open_file_dialog(GtkAction * action,
- GtranslatorWindow *window)
+gtranslator_open_file_dialog (GtkAction * action, GtranslatorWindow * window)
{
- GtkWidget *dialog = NULL;
-
- if(dialog != NULL) {
- gtk_window_present(GTK_WINDOW(dialog));
- return;
- }
- dialog = gtranslator_file_chooser_new (GTK_WINDOW(window),
- FILESEL_OPEN,
- _("Open file for translation"),
- _gtranslator_application_get_last_dir (GTR_APP));
-
- /*
- * With the gettext parser/writer API, we can't currently read/write
- * to remote files with gnome-vfs. Eventually, we should intercept
- * remote requests and use gnome-vfs to retrieve a temporary file to
- * work on, and transmit it back when saved.
- */
- //gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
-
- gtranslator_file_chooser_analyse((gpointer) dialog, FILESEL_OPEN, window);
+ GtkWidget *dialog = NULL;
+
+ if (dialog != NULL)
+ {
+ gtk_window_present (GTK_WINDOW (dialog));
+ return;
+ }
+ dialog = gtranslator_file_chooser_new (GTK_WINDOW (window),
+ FILESEL_OPEN,
+ _("Open file for translation"),
+ _gtranslator_application_get_last_dir
+ (GTR_APP));
+
+ /*
+ * With the gettext parser/writer API, we can't currently read/write
+ * to remote files with gnome-vfs. Eventually, we should intercept
+ * remote requests and use gnome-vfs to retrieve a temporary file to
+ * work on, and transmit it back when saved.
+ */
+ //gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
+
+ gtranslator_file_chooser_analyse ((gpointer) dialog, FILESEL_OPEN, window);
}
static void
-save_dialog_response_cb (GtkDialog *dialog,
- gint response_id,
- GtranslatorWindow *window)
+save_dialog_response_cb (GtkDialog * dialog,
+ gint response_id, GtranslatorWindow * window)
{
- GError *error = NULL;
- GtranslatorPo *po;
- GtranslatorTab *tab;
- gchar *filename;
- GFile *location;
- GtranslatorStatusbar *status;
-
- tab = GTR_TAB (g_object_get_data (G_OBJECT (dialog),
- GTR_TAB_SAVE_AS));
-
- g_return_if_fail (GTK_IS_FILE_CHOOSER (dialog));
-
- po = gtranslator_tab_get_po (tab);
-
- if (response_id != GTK_RESPONSE_ACCEPT)
- {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- return;
- }
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- g_return_if_fail (filename != NULL);
-
- location = g_file_new_for_path (filename);
- g_free (filename);
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
- if (po != NULL)
+ GError *error = NULL;
+ GtranslatorPo *po;
+ GtranslatorTab *tab;
+ gchar *filename;
+ GFile *location;
+ GtranslatorStatusbar *status;
+
+ tab = GTR_TAB (g_object_get_data (G_OBJECT (dialog), GTR_TAB_SAVE_AS));
+
+ g_return_if_fail (GTK_IS_FILE_CHOOSER (dialog));
+
+ po = gtranslator_tab_get_po (tab);
+
+ if (response_id != GTK_RESPONSE_ACCEPT)
+ {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ return;
+ }
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ g_return_if_fail (filename != NULL);
+
+ location = g_file_new_for_path (filename);
+ g_free (filename);
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (po != NULL)
+ {
+ gtranslator_po_set_location (po, location);
+
+ g_object_unref (location);
+
+ gtranslator_po_save_file (po, &error);
+
+ if (error)
{
- gtranslator_po_set_location (po, location);
-
- g_object_unref (location);
-
- gtranslator_po_save_file (po, &error);
-
- if (error)
- {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", error->message);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- g_clear_error(&error);
- return;
- }
-
- /* We have to change the state of the tab */
- gtranslator_po_set_state(po, GTR_PO_STATE_SAVED);
-
- /* Flash a message */
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- gtranslator_statusbar_flash_message (status, 0, _("File saved."));
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_clear_error (&error);
+ return;
}
- g_object_unref (location);
+
+ /* We have to change the state of the tab */
+ gtranslator_po_set_state (po, GTR_PO_STATE_SAVED);
+
+ /* Flash a message */
+ status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ gtranslator_statusbar_flash_message (status, 0, _("File saved."));
+ }
+ g_object_unref (location);
}
static GtkFileChooserConfirmation
-confirm_overwrite_callback (GtkFileChooser *dialog,
- gpointer data)
+confirm_overwrite_callback (GtkFileChooser * dialog, gpointer data)
{
- gchar *uri;
- GtkFileChooserConfirmation res;
+ gchar *uri;
+ GtkFileChooserConfirmation res;
- uri = gtk_file_chooser_get_uri (dialog);
+ uri = gtk_file_chooser_get_uri (dialog);
- /*
- * FIXME: We have to detect if the file is read-only
- */
+ /*
+ * FIXME: We have to detect if the file is read-only
+ */
- /* fall back to the default confirmation dialog */
- res = GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
+ /* fall back to the default confirmation dialog */
+ res = GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
- g_free (uri);
+ g_free (uri);
- return res;
+ return res;
}
/*
@@ -304,195 +308,188 @@ confirm_overwrite_callback (GtkFileChooser *dialog,
*/
void
gtranslator_save_file_as_dialog (GtkAction * action,
- GtranslatorWindow *window)
+ GtranslatorWindow * window)
{
- GtkWidget *dialog = NULL;
- GtranslatorTab *current_page;
- GtranslatorPo *po;
- GFile *location;
- gchar *uri = NULL;
- gboolean uri_set = FALSE;
-
- if (dialog != NULL) {
- gtk_window_present (GTK_WINDOW (dialog));
- return;
- }
+ GtkWidget *dialog = NULL;
+ GtranslatorTab *current_page;
+ GtranslatorPo *po;
+ GFile *location;
+ gchar *uri = NULL;
+ gboolean uri_set = FALSE;
+
+ if (dialog != NULL)
+ {
+ gtk_window_present (GTK_WINDOW (dialog));
+ return;
+ }
+
+ current_page = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current_page);
+
+ dialog = gtranslator_file_chooser_new (GTK_WINDOW (window),
+ FILESEL_SAVE,
+ _("Save file as..."),
+ _gtranslator_application_get_last_dir
+ (GTR_APP));
- current_page = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (current_page);
-
- dialog = gtranslator_file_chooser_new (GTK_WINDOW (window),
- FILESEL_SAVE,
- _("Save file as..."),
- _gtranslator_application_get_last_dir (GTR_APP));
-
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
- TRUE);
- g_signal_connect (dialog,
- "confirm-overwrite",
- G_CALLBACK (confirm_overwrite_callback),
- NULL);
-
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
- /*Set the suggested file */
- location = gtranslator_po_get_location (po);
-
- uri = g_file_get_uri (location);
-
- g_object_unref (location);
-
- if (uri)
- uri_set = gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog),
- uri);
-
- g_free (uri);
-
- /*
- * FIXME: If we can't set the uri we should add a default path and name
- */
-
- g_object_set_data (G_OBJECT (dialog),
- GTR_TAB_SAVE_AS,
- current_page);
-
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (save_dialog_response_cb),
- window);
-
- gtk_widget_show (GTK_WIDGET (dialog));
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
+ TRUE);
+ g_signal_connect (dialog,
+ "confirm-overwrite",
+ G_CALLBACK (confirm_overwrite_callback), NULL);
+
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+ /*Set the suggested file */
+ location = gtranslator_po_get_location (po);
+
+ uri = g_file_get_uri (location);
+
+ g_object_unref (location);
+
+ if (uri)
+ uri_set = gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
+
+ g_free (uri);
+
+ /*
+ * FIXME: If we can't set the uri we should add a default path and name
+ */
+
+ g_object_set_data (G_OBJECT (dialog), GTR_TAB_SAVE_AS, current_page);
+
+ g_signal_connect (dialog,
+ "response", G_CALLBACK (save_dialog_response_cb), window);
+
+ gtk_widget_show (GTK_WIDGET (dialog));
}
/*
* A callback for Save
*/
-void
+void
gtranslator_save_current_file_dialog (GtkWidget * widget,
- GtranslatorWindow *window)
+ GtranslatorWindow * window)
{
- GError *error = NULL;
- GtranslatorTab *current;
- GtranslatorPo *po;
- GtranslatorStatusbar *status;
-
- current = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (current);
-
- gtranslator_po_save_file (po, &error);
-
- if (error)
- {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", error->message);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- g_clear_error(&error);
- return;
- }
-
- /* We have to change the state of the tab */
- gtranslator_po_set_state(po, GTR_PO_STATE_SAVED);
-
- /* Flash a message */
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- gtranslator_statusbar_flash_message (status, 0, _("File saved."));
+ GError *error = NULL;
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+ GtranslatorStatusbar *status;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+
+ gtranslator_po_save_file (po, &error);
+
+ if (error)
+ {
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK, "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_clear_error (&error);
+ return;
+ }
+
+ /* We have to change the state of the tab */
+ gtranslator_po_set_state (po, GTR_PO_STATE_SAVED);
+
+ /* Flash a message */
+ status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ gtranslator_statusbar_flash_message (status, 0, _("File saved."));
}
static gboolean
-is_duplicated_location (const GSList *locations,
- GFile *u)
+is_duplicated_location (const GSList * locations, GFile * u)
{
- GSList *l;
-
- for (l = (GSList *)locations; l != NULL; l = g_slist_next (l))
- {
- if (g_file_equal (u, l->data))
- return TRUE;
- }
-
- return FALSE;
+ GSList *l;
+
+ for (l = (GSList *) locations; l != NULL; l = g_slist_next (l))
+ {
+ if (g_file_equal (u, l->data))
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
-load_file_list (GtranslatorWindow *window,
- const GSList *locations)
+load_file_list (GtranslatorWindow * window, const GSList * locations)
{
- GSList *locations_to_load = NULL;
- const GSList *l;
- GError *error = NULL;
- GtkWidget *tab;
-
- g_return_if_fail ((locations != NULL) && (locations->data != NULL));
-
- /* Remove the uris corresponding to documents already open
- * in "window" and remove duplicates from "uris" list */
- l = locations;
- while (locations != NULL)
+ GSList *locations_to_load = NULL;
+ const GSList *l;
+ GError *error = NULL;
+ GtkWidget *tab;
+
+ g_return_if_fail ((locations != NULL) && (locations->data != NULL));
+
+ /* Remove the uris corresponding to documents already open
+ * in "window" and remove duplicates from "uris" list */
+ l = locations;
+ while (locations != NULL)
+ {
+ if (!is_duplicated_location (locations_to_load, locations->data))
{
- if (!is_duplicated_location (locations_to_load, locations->data))
- {
- /*We need to now if is already loaded in any tab*/
- tab = gtranslator_window_get_tab_from_location (window,
- (GFile *)locations->data);
-
- if (tab != NULL)
- {
- if (locations == l)
- gtranslator_window_set_active_tab (window,
- tab);
- }
- else
- locations_to_load = g_slist_prepend (locations_to_load,
- locations->data);
-
- }
-
- locations = g_slist_next (locations);
- }
+ /*We need to now if is already loaded in any tab */
+ tab = gtranslator_window_get_tab_from_location (window,
+ (GFile *)
+ locations->data);
+
+ if (tab != NULL)
+ {
+ if (locations == l)
+ gtranslator_window_set_active_tab (window, tab);
+ }
+ else
+ locations_to_load = g_slist_prepend (locations_to_load,
+ locations->data);
- if (locations_to_load == NULL)
- return;
-
- locations_to_load = g_slist_reverse (locations_to_load);
- l = locations_to_load;
-
- while (locations_to_load != NULL)
- {
- g_return_if_fail (locations_to_load->data != NULL);
-
- if (!gtranslator_open (locations_to_load->data, window, &error))
- break;
-
- locations_to_load = g_slist_next (locations_to_load);
}
-
- /*
- * Now if there are any error we have to manage it
- * and free the path
- */
- if(error != NULL)
- {
- GtkWidget *dialog;
- /*
- * We have to show the error in a dialog
- */
- dialog = gtk_message_dialog_new(GTK_WINDOW(window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", error->message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_error_free(error);
- }
-
- /* Free uris_to_load. Note that l points to the first element of uris_to_load */
- g_slist_free ((GSList *)l);
+
+ locations = g_slist_next (locations);
+ }
+
+ if (locations_to_load == NULL)
+ return;
+
+ locations_to_load = g_slist_reverse (locations_to_load);
+ l = locations_to_load;
+
+ while (locations_to_load != NULL)
+ {
+ g_return_if_fail (locations_to_load->data != NULL);
+
+ if (!gtranslator_open (locations_to_load->data, window, &error))
+ break;
+
+ locations_to_load = g_slist_next (locations_to_load);
+ }
+
+ /*
+ * Now if there are any error we have to manage it
+ * and free the path
+ */
+ if (error != NULL)
+ {
+ GtkWidget *dialog;
+ /*
+ * We have to show the error in a dialog
+ */
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_error_free (error);
+ }
+
+ /* Free uris_to_load. Note that l points to the first element of uris_to_load */
+ g_slist_free ((GSList *) l);
}
@@ -502,370 +499,359 @@ load_file_list (GtranslatorWindow *window,
* Ignore non-existing URIs
*/
void
-gtranslator_actions_load_locations (GtranslatorWindow *window,
- const GSList *locations)
-{
- g_return_if_fail (GTR_IS_WINDOW (window));
- g_return_if_fail ((locations != NULL) && (locations->data != NULL));
-
- load_file_list (window, locations);
+gtranslator_actions_load_locations (GtranslatorWindow * window,
+ const GSList * locations)
+{
+ g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail ((locations != NULL) && (locations->data != NULL));
+
+ load_file_list (window, locations);
}
static void
-save_and_close_document (GtranslatorPo *po,
- GtranslatorWindow *window)
+save_and_close_document (GtranslatorPo * po, GtranslatorWindow * window)
{
- GtranslatorTab *tab;
-
- gtranslator_save_current_file_dialog (NULL, window);
-
- tab = gtranslator_tab_get_from_document (po);
-
- _gtranslator_window_close_tab (window, tab);
+ GtranslatorTab *tab;
+
+ gtranslator_save_current_file_dialog (NULL, window);
+
+ tab = gtranslator_tab_get_from_document (po);
+
+ _gtranslator_window_close_tab (window, tab);
}
static void
-close_all_tabs (GtranslatorWindow *window)
+close_all_tabs (GtranslatorWindow * window)
{
- GtranslatorNotebook *nb;
- gint pages;
-
- nb = gtranslator_window_get_notebook (window);
- pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK(nb));
-
- while(pages >= 0)
- {
- gtk_notebook_remove_page (GTK_NOTEBOOK (nb),
- pages);
-
- pages--;
- }
-
- //FIXME: This has to change once we add the close all documents menuitem
- gtk_widget_destroy (GTK_WIDGET (window));
+ GtranslatorNotebook *nb;
+ gint pages;
+
+ nb = gtranslator_window_get_notebook (window);
+ pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
+
+ while (pages >= 0)
+ {
+ gtk_notebook_remove_page (GTK_NOTEBOOK (nb), pages);
+
+ pages--;
+ }
+
+ //FIXME: This has to change once we add the close all documents menuitem
+ gtk_widget_destroy (GTK_WIDGET (window));
}
static void
-save_and_close_all_documents (GList *unsaved_documents,
- GtranslatorWindow *window)
+save_and_close_all_documents (GList * unsaved_documents,
+ GtranslatorWindow * window)
{
- GtranslatorTab *tab;
- GList *l;
- GError *error = NULL;
-
- for (l = unsaved_documents; l != NULL; l = g_list_next (l))
+ GtranslatorTab *tab;
+ GList *l;
+ GError *error = NULL;
+
+ for (l = unsaved_documents; l != NULL; l = g_list_next (l))
+ {
+ gtranslator_po_save_file (l->data, &error);
+
+ if (error)
{
- gtranslator_po_save_file (l->data, &error);
-
- if (error)
- {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", error->message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_clear_error (&error);
-
- return;
- }
-
- tab = gtranslator_tab_get_from_document (l->data);
-
- _gtranslator_window_close_tab (window, tab);
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_clear_error (&error);
+
+ return;
}
-
- gtk_widget_destroy (GTK_WIDGET (window));
+
+ tab = gtranslator_tab_get_from_document (l->data);
+
+ _gtranslator_window_close_tab (window, tab);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (window));
}
static void
-close_confirmation_dialog_response_handler (GtranslatorCloseConfirmationDialog *dlg,
- gint response_id,
- GtranslatorWindow *window)
+close_confirmation_dialog_response_handler (GtranslatorCloseConfirmationDialog
+ * dlg, gint response_id,
+ GtranslatorWindow * window)
{
- GList *selected_documents;
- gboolean is_closing_all;
+ GList *selected_documents;
+ gboolean is_closing_all;
+
+ gtk_widget_hide (GTK_WIDGET (dlg));
+
+ is_closing_all = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
+ GTR_IS_CLOSING_ALL));
+
+ switch (response_id)
+ {
+ case GTK_RESPONSE_YES: /* Save and Close */
+ selected_documents =
+ gtranslator_close_confirmation_dialog_get_selected_documents (dlg);
+ if (selected_documents == NULL)
+ {
+ if (is_closing_all)
+ {
+ gtk_widget_destroy (GTK_WIDGET (dlg));
- gtk_widget_hide (GTK_WIDGET (dlg));
-
- is_closing_all = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
- GTR_IS_CLOSING_ALL));
+ close_all_tabs (window);
- switch (response_id)
+ return;
+ }
+ else
+ g_return_if_reached ();
+ }
+ else
{
- case GTK_RESPONSE_YES: /* Save and Close */
- selected_documents = gtranslator_close_confirmation_dialog_get_selected_documents (dlg);
- if (selected_documents == NULL)
- {
- if (is_closing_all)
- {
- gtk_widget_destroy (GTK_WIDGET (dlg));
-
- close_all_tabs (window);
-
- return;
- }
- else g_return_if_reached ();
- }
- else
- {
- if (is_closing_all)
- {
- save_and_close_all_documents (selected_documents,
- window);
- }
- else
- {
- save_and_close_document (selected_documents->data,
- window);
- }
- }
-
- g_list_free (selected_documents);
-
- break;
-
- case GTK_RESPONSE_NO: /* Close without Saving */
- if (is_closing_all)
- {
- gtk_widget_destroy (GTK_WIDGET (dlg));
-
- close_all_tabs (window);
-
- return;
- }
- else
- {
- const GList *unsaved_documents;
-
- unsaved_documents = gtranslator_close_confirmation_dialog_get_unsaved_documents (dlg);
- g_return_if_fail (unsaved_documents->next == NULL);
-
- _gtranslator_window_close_tab (window,
- gtranslator_tab_get_from_document (unsaved_documents->data));
- }
-
- break;
- default: /* Do not close */
- break;
+ if (is_closing_all)
+ {
+ save_and_close_all_documents (selected_documents, window);
+ }
+ else
+ {
+ save_and_close_document (selected_documents->data, window);
+ }
}
- gtk_widget_destroy (GTK_WIDGET (dlg));
-}
+ g_list_free (selected_documents);
-void
-gtranslator_close_tab (GtranslatorTab *tab,
- GtranslatorWindow *window)
-{
- g_object_set_data (G_OBJECT (window),
- GTR_IS_CLOSING_ALL,
- GINT_TO_POINTER (0));
-
- if (!_gtranslator_tab_can_close (tab))
+ break;
+
+ case GTK_RESPONSE_NO: /* Close without Saving */
+ if (is_closing_all)
{
- GtkWidget *dlg;
+ gtk_widget_destroy (GTK_WIDGET (dlg));
- dlg = gtranslator_close_confirmation_dialog_new_single (GTK_WINDOW (window),
- gtranslator_tab_get_po (tab),
- FALSE);
+ close_all_tabs (window);
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (close_confirmation_dialog_response_handler),
- window);
+ return;
+ }
+ else
+ {
+ const GList *unsaved_documents;
- gtk_widget_show (dlg);
+ unsaved_documents =
+ gtranslator_close_confirmation_dialog_get_unsaved_documents (dlg);
+ g_return_if_fail (unsaved_documents->next == NULL);
+
+ _gtranslator_window_close_tab (window,
+ gtranslator_tab_get_from_document
+ (unsaved_documents->data));
}
- else
- _gtranslator_window_close_tab (window, tab);
+
+ break;
+ default: /* Do not close */
+ break;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+}
+
+void
+gtranslator_close_tab (GtranslatorTab * tab, GtranslatorWindow * window)
+{
+ g_object_set_data (G_OBJECT (window),
+ GTR_IS_CLOSING_ALL, GINT_TO_POINTER (0));
+
+ if (!_gtranslator_tab_can_close (tab))
+ {
+ GtkWidget *dlg;
+
+ dlg =
+ gtranslator_close_confirmation_dialog_new_single (GTK_WINDOW (window),
+ gtranslator_tab_get_po
+ (tab), FALSE);
+
+ g_signal_connect (dlg,
+ "response",
+ G_CALLBACK
+ (close_confirmation_dialog_response_handler), window);
+
+ gtk_widget_show (dlg);
+ }
+ else
+ _gtranslator_window_close_tab (window, tab);
}
-void
-gtranslator_file_close (GtkAction * widget,
- GtranslatorWindow *window)
+void
+gtranslator_file_close (GtkAction * widget, GtranslatorWindow * window)
{
- GtranslatorTab *tab;
-
- tab = gtranslator_window_get_active_tab (window);
-
- gtranslator_close_tab (tab, window);
+ GtranslatorTab *tab;
+
+ tab = gtranslator_window_get_active_tab (window);
+
+ gtranslator_close_tab (tab, window);
}
static GList *
-get_modified_documents (GtranslatorWindow *window)
+get_modified_documents (GtranslatorWindow * window)
{
- GtranslatorNotebook *nb;
- GtranslatorTab *tab;
- GtranslatorPo *po;
- gint pages;
- GList *list = NULL;
-
- nb = gtranslator_window_get_notebook (window);
- pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
-
- while (pages > 0)
- {
- tab = GTR_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (nb),
- pages - 1));
-
- po = gtranslator_tab_get_po (tab);
- if (gtranslator_po_get_state (po) == GTR_PO_STATE_MODIFIED)
- list = g_list_prepend (list, po);
-
- pages--;
- }
-
- return list;
+ GtranslatorNotebook *nb;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ gint pages;
+ GList *list = NULL;
+
+ nb = gtranslator_window_get_notebook (window);
+ pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb));
+
+ while (pages > 0)
+ {
+ tab = GTR_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (nb),
+ pages - 1));
+
+ po = gtranslator_tab_get_po (tab);
+ if (gtranslator_po_get_state (po) == GTR_PO_STATE_MODIFIED)
+ list = g_list_prepend (list, po);
+
+ pages--;
+ }
+
+ return list;
}
static void
-close_all_documents (GtranslatorWindow *window,
- gboolean logout_mode)
+close_all_documents (GtranslatorWindow * window, gboolean logout_mode)
{
- GList *list;
-
- list = get_modified_documents (window);
+ GList *list;
- if (list != NULL)
- {
- GtkWidget *dlg;
+ list = get_modified_documents (window);
- dlg = gtranslator_close_confirmation_dialog_new (GTK_WINDOW (window),
- list, logout_mode);
+ if (list != NULL)
+ {
+ GtkWidget *dlg;
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (close_confirmation_dialog_response_handler),
- window);
-
- g_list_free (list);
+ dlg = gtranslator_close_confirmation_dialog_new (GTK_WINDOW (window),
+ list, logout_mode);
- gtk_widget_show (dlg);
- }
- else
+ g_signal_connect (dlg,
+ "response",
+ G_CALLBACK
+ (close_confirmation_dialog_response_handler), window);
+
+ g_list_free (list);
+
+ gtk_widget_show (dlg);
+ }
+ else
+ {
+ close_all_tabs (window);
+
+ if (logout_mode)
{
- close_all_tabs (window);
-
- if (logout_mode)
- {
- gtk_widget_destroy (GTK_WIDGET (window));
- }
+ gtk_widget_destroy (GTK_WIDGET (window));
}
+ }
}
void
-gtranslator_file_quit (GtkAction *action,
- GtranslatorWindow *window)
-{
- GtranslatorNotebook *nb;
- GtranslatorTab *tab;
- GtranslatorPo *po;
- gint pages;
- GList *list = NULL;
- GList *profiles_list = NULL;
- gchar *config_folder;
- gchar *filename, *filename_temp;
- GFile *file, *file_temp;
- gint r;
-
- config_folder = gtranslator_utils_get_user_config_dir ();
- filename = g_build_filename (config_folder,
- "profiles.xml",
- NULL);
- filename_temp = g_build_filename (g_get_tmp_dir (),
- "profiles.xml",
- NULL);
-
- file = g_file_new_for_path (filename);
- file_temp = g_file_new_for_path (filename_temp);
-
- profiles_list = gtranslator_application_get_profiles (GTR_APP);
-
-
- if (profiles_list != NULL) {
- if (g_file_query_exists (file_temp, NULL)) {
- r = gtranslator_profile_save_profiles_in_xml (filename_temp);
- } else {
- g_file_create (file_temp,
- G_FILE_CREATE_NONE,
- NULL,
- NULL);
- r = gtranslator_profile_save_profiles_in_xml (filename_temp);
- }
- if (r != -1)
- {
- g_file_move (file_temp,
- file,
- G_FILE_COPY_OVERWRITE,
- NULL,
- NULL,
- NULL,
- NULL);
- }
- else
- {
- g_warning (_("Failed to write profile data into profiles file '%s'"), filename);
- }
+gtranslator_file_quit (GtkAction * action, GtranslatorWindow * window)
+{
+ GtranslatorNotebook *nb;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ gint pages;
+ GList *list = NULL;
+ GList *profiles_list = NULL;
+ gchar *config_folder;
+ gchar *filename, *filename_temp;
+ GFile *file, *file_temp;
+ gint r;
+
+ config_folder = gtranslator_utils_get_user_config_dir ();
+ filename = g_build_filename (config_folder, "profiles.xml", NULL);
+ filename_temp = g_build_filename (g_get_tmp_dir (), "profiles.xml", NULL);
+
+ file = g_file_new_for_path (filename);
+ file_temp = g_file_new_for_path (filename_temp);
+
+ profiles_list = gtranslator_application_get_profiles (GTR_APP);
+
+
+ if (profiles_list != NULL)
+ {
+ if (g_file_query_exists (file_temp, NULL))
+ {
+ r = gtranslator_profile_save_profiles_in_xml (filename_temp);
+ }
+ else
+ {
+ g_file_create (file_temp, G_FILE_CREATE_NONE, NULL, NULL);
+ r = gtranslator_profile_save_profiles_in_xml (filename_temp);
+ }
+ if (r != -1)
+ {
+ g_file_move (file_temp,
+ file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
+ }
+ else
+ {
+ g_warning (_
+ ("Failed to write profile data into profiles file '%s'"),
+ filename);
}
-
- g_free (config_folder);
- g_object_unref (file_temp);
- g_object_unref (file);
+ }
+
+ g_free (config_folder);
+ g_object_unref (file_temp);
+ g_object_unref (file);
- g_object_set_data (G_OBJECT (window),
- GTR_IS_CLOSING_ALL,
- GINT_TO_POINTER (1));
+ g_object_set_data (G_OBJECT (window),
+ GTR_IS_CLOSING_ALL, GINT_TO_POINTER (1));
- close_all_documents (window, TRUE);
+ close_all_documents (window, TRUE);
}
void
-_gtranslator_actions_file_close_all (GtkAction *action,
- GtranslatorWindow *window)
+_gtranslator_actions_file_close_all (GtkAction * action,
+ GtranslatorWindow * window)
{
- close_all_documents (window, FALSE);
+ close_all_documents (window, FALSE);
}
void
-_gtranslator_actions_file_save_all (GtkAction *action,
- GtranslatorWindow *window)
+_gtranslator_actions_file_save_all (GtkAction * action,
+ GtranslatorWindow * window)
{
- GList *list, *l;
-
- list = get_modified_documents (window);
-
- for (l = list; l != NULL; l = g_list_next (l))
+ GList *list, *l;
+
+ list = get_modified_documents (window);
+
+ for (l = list; l != NULL; l = g_list_next (l))
+ {
+ GError *error = NULL;
+ GtranslatorStatusbar *status;
+
+ gtranslator_po_save_file (GTR_PO (l->data), &error);
+
+ if (error)
{
- GError *error = NULL;
- GtranslatorStatusbar *status;
-
- gtranslator_po_save_file (GTR_PO (l->data), &error);
-
- if (error)
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "%s", error->message);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- g_clear_error (&error);
-
- return;
- }
-
- /* We have to change the state of the tab */
- gtranslator_po_set_state (GTR_PO (l->data), GTR_PO_STATE_SAVED);
-
- /* Flash a message */
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- gtranslator_statusbar_flash_message (status, 0, _("Files saved."));
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "%s", error->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_clear_error (&error);
+
+ return;
}
-
- g_list_free (list);
+
+ /* We have to change the state of the tab */
+ gtranslator_po_set_state (GTR_PO (l->data), GTR_PO_STATE_SAVED);
+
+ /* Flash a message */
+ status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ gtranslator_statusbar_flash_message (status, 0, _("Files saved."));
+ }
+
+ g_list_free (list);
}
diff --git a/src/actions-go.c b/src/actions-go.c
index 77aacb2..0cc3e7f 100644
--- a/src/actions-go.c
+++ b/src/actions-go.c
@@ -31,143 +31,144 @@
#include "window.h"
-void
-gtranslator_message_go_to_first(GtkAction *action,
- GtranslatorWindow *window)
+void
+gtranslator_message_go_to_first (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- gtranslator_tab_go_to_first (current);
- set_sensitive_according_to_message(window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ gtranslator_tab_go_to_first (current);
+ set_sensitive_according_to_message (window, po);
}
-void
-gtranslator_message_go_to_previous(GtkAction *action,
- GtranslatorWindow *window)
+void
+gtranslator_message_go_to_previous (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- gtranslator_tab_go_to_prev (current);
- set_sensitive_according_to_message(window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ gtranslator_tab_go_to_prev (current);
+ set_sensitive_according_to_message (window, po);
}
-void
-gtranslator_message_go_to_next(GtkAction *action,
- GtranslatorWindow *window)
+void
+gtranslator_message_go_to_next (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- gtranslator_tab_go_to_next (current);
- set_sensitive_according_to_message(window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ gtranslator_tab_go_to_next (current);
+ set_sensitive_according_to_message (window, po);
}
-void
-gtranslator_message_go_to_last(GtkAction *action,
- GtranslatorWindow *window)
+void
+gtranslator_message_go_to_last (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- gtranslator_tab_go_to_last (current);
- set_sensitive_according_to_message(window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ gtranslator_tab_go_to_last (current);
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_go_to_next_fuzzy(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_go_to_next_fuzzy (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
-
- current = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (current);
- if (gtranslator_tab_go_to_next_fuzzy (current))
- set_sensitive_according_to_message (window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ if (gtranslator_tab_go_to_next_fuzzy (current))
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_go_to_prev_fuzzy(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_go_to_prev_fuzzy (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- if (gtranslator_tab_go_to_prev_fuzzy (current))
- set_sensitive_according_to_message (window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ if (gtranslator_tab_go_to_prev_fuzzy (current))
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_go_to_next_untranslated(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_go_to_next_untranslated (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
- GList *msg;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- if (gtranslator_tab_go_to_next_untrans (current))
- set_sensitive_according_to_message (window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+ GList *msg;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ if (gtranslator_tab_go_to_next_untrans (current))
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_go_to_prev_untranslated(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_go_to_prev_untranslated (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
- GList *msg;
-
- current = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(current);
- if (gtranslator_tab_go_to_prev_untrans (current))
- set_sensitive_according_to_message (window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+ GList *msg;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ if (gtranslator_tab_go_to_prev_untrans (current))
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_go_to_next_fuzzy_or_untranslated (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_go_to_next_fuzzy_or_untranslated (GtkAction * action,
+ GtranslatorWindow *
+ window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
- GList *msg;
-
- current = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (current);
- if (gtranslator_tab_go_to_next_fuzzy_or_untrans (current))
- set_sensitive_according_to_message (window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+ GList *msg;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ if (gtranslator_tab_go_to_next_fuzzy_or_untrans (current))
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_go_to_prev_fuzzy_or_untranslated (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_go_to_prev_fuzzy_or_untranslated (GtkAction * action,
+ GtranslatorWindow *
+ window)
{
- GtranslatorTab *current;
- GtranslatorPo *po;
- GList *msg;
-
- current = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (current);
- if (gtranslator_tab_go_to_prev_fuzzy_or_untrans (current))
- set_sensitive_according_to_message (window, po);
+ GtranslatorTab *current;
+ GtranslatorPo *po;
+ GList *msg;
+
+ current = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (current);
+ if (gtranslator_tab_go_to_prev_fuzzy_or_untrans (current))
+ set_sensitive_according_to_message (window, po);
}
void
-gtranslator_message_jump (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_message_jump (GtkAction * action, GtranslatorWindow * window)
{
- gtranslator_show_jump_dialog (window);
+ gtranslator_show_jump_dialog (window);
}
diff --git a/src/actions-help.c b/src/actions-help.c
index a96c490..fc8ddcb 100644
--- a/src/actions-help.c
+++ b/src/actions-help.c
@@ -34,86 +34,81 @@
* Show the user's guide for gtranslator
*/
void
-gtranslator_cmd_help_contents (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_cmd_help_contents (GtkAction * action, GtranslatorWindow * window)
{
- gtranslator_utils_help_display (GTK_WINDOW (window),
- "gtranslator",
- "gtranslator.xml");
+ gtranslator_utils_help_display (GTK_WINDOW (window),
+ "gtranslator", "gtranslator.xml");
}
/*
* Creates and shows the about box for gtranslator.
- */
+ */
void
-gtranslator_about_dialog(GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_about_dialog (GtkAction * action, GtranslatorWindow * window)
{
- gchar *license_trans;
-
- const gchar *authors[] = {
- N_("Current Developers"),
- "---------------------------------------------------------",
- "Pablo Sanxiao <psanxiao gmail org>",
- "Ignacio Casal Quinteiro <nacho resa gmail com>",
- "Seán de Búrca <leftmostcat gmail com>",
- "",
- N_("Previous Developers"),
- "---------------------------------------------------------",
- "Ross Golder <ross golder org>",
- "Fatih Demir <kabalak kabalak net>",
- "Gediminas Paulauskas <menesis delfi lt>",
- "Thomas Ziehmer <thomas kabalak net>",
- "Peeter Vois <peeter kabalak net>",
- NULL
- };
- const gchar *documenters[] =
- {
- "Abel Cheung <deaddog deaddog org>",
- "Emese Kovacs <emese gnome hu>",
- "Pablo Sanxiao <psanxiao gmail org>",
- NULL
- };
-
-
- const gchar *license[] = {
- N_("This program is free software: you can redistribute it and/or modify "
- "it under the terms of the GNU General Public License as published by "
- "the Free Software Foundation, either version 3 of the License, or "
- "(at your option) any later version."),
- N_("This program is distributed in the hope that it will be useful, "
- "but WITHOUT ANY WARRANTY; without even the implied warranty of "
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
- "GNU General Public License for more details."),
- N_("You should have received a copy of the GNU General Public License "
- "along with this program. If not, see <http://www.gnu.org/licenses/>.")
- };
+ gchar *license_trans;
+
+ const gchar *authors[] = {
+ N_("Current Developers"),
+ "---------------------------------------------------------",
+ "Pablo Sanxiao <psanxiao gmail org>",
+ "Ignacio Casal Quinteiro <nacho resa gmail com>",
+ "Seán de Búrca <leftmostcat gmail com>",
+ "",
+ N_("Previous Developers"),
+ "---------------------------------------------------------",
+ "Ross Golder <ross golder org>",
+ "Fatih Demir <kabalak kabalak net>",
+ "Gediminas Paulauskas <menesis delfi lt>",
+ "Thomas Ziehmer <thomas kabalak net>",
+ "Peeter Vois <peeter kabalak net>",
+ NULL
+ };
+ const gchar *documenters[] = {
+ "Abel Cheung <deaddog deaddog org>",
+ "Emese Kovacs <emese gnome hu>",
+ "Pablo Sanxiao <psanxiao gmail org>",
+ NULL
+ };
+
+
+ const gchar *license[] = {
+ N_("This program is free software: you can redistribute it and/or modify "
+ "it under the terms of the GNU General Public License as published by "
+ "the Free Software Foundation, either version 3 of the License, or "
+ "(at your option) any later version."),
+ N_("This program is distributed in the hope that it will be useful, "
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
+ "GNU General Public License for more details."),
+ N_("You should have received a copy of the GNU General Public License "
+ "along with this program. If not, see <http://www.gnu.org/licenses/>.")
+ };
+
+ license_trans = g_strconcat (_(license[0]), "\n\n",
+ _(license[1]), "\n\n", _(license[2]), NULL);
- license_trans = g_strconcat (_(license[0]), "\n\n",
- _(license[1]), "\n\n",
- _(license[2]),
- NULL);
-
- gtk_show_about_dialog (GTK_WINDOW (window),
- "comments", _("Translation file editing suite for localization of applications and libraries."),
- "authors", authors,
- "copyright", _("Copyright © 1999-2008 Free Software Foundation, Inc."),
- "documenters", documenters,
- "license", license_trans,
- "logo-icon-name", "gtranslator",
- "title", _("About Gtranslator"),
- /*
- * Note to translators: put here your name and email so it will show
- * up in the "about" box
- */
- "translator-credits", _("translator-credits"),
- "version", VERSION,
- "website", "http://gtranslator.sourceforge.net/",
- "wrap-license", TRUE,
- "website-label", _("Gtranslator Web Site"),
- NULL);
+ gtk_show_about_dialog (GTK_WINDOW (window),
+ "comments",
+ _
+ ("Translation file editing suite for localization of applications and libraries."),
+ "authors", authors, "copyright",
+ _
+ ("Copyright © 1999-2008 Free Software Foundation, Inc."),
+ "documenters", documenters, "license", license_trans,
+ "logo-icon-name", "gtranslator", "title",
+ _("About Gtranslator"),
+ /*
+ * Note to translators: put here your name and email so it will show
+ * up in the "about" box
+ */
+ "translator-credits", _("translator-credits"),
+ "version", VERSION,
+ "website", "http://gtranslator.sourceforge.net/",
+ "wrap-license", TRUE,
+ "website-label", _("Gtranslator Web Site"), NULL);
- g_free (license_trans);
+ g_free (license_trans);
}
diff --git a/src/actions-search.c b/src/actions-search.c
index 6defdec..37f8c86 100644
--- a/src/actions-search.c
+++ b/src/actions-search.c
@@ -51,753 +51,735 @@
typedef struct _LastSearchData LastSearchData;
struct _LastSearchData
{
- gchar *find_text;
- gchar *replace_text;
-
- gint original_text:1;
- gint translated_text:1;
- gint fuzzy_messages:1;
- gint match_case :1;
- gint entire_word :1;
- gint backwards :1;
- gint wrap_around :1;
+ gchar *find_text;
+ gchar *replace_text;
+
+ gint original_text:1;
+ gint translated_text:1;
+ gint fuzzy_messages:1;
+ gint match_case:1;
+ gint entire_word:1;
+ gint backwards:1;
+ gint wrap_around:1;
};
static void
-last_search_data_free (LastSearchData *data)
+last_search_data_free (LastSearchData * data)
{
- g_free (data->find_text);
- g_free (data->replace_text);
- g_free (data);
+ g_free (data->find_text);
+ g_free (data->replace_text);
+ g_free (data);
}
static void
-last_search_data_set (LastSearchData *data,
- GtranslatorSearchDialog *dialog)
+last_search_data_set (LastSearchData * data, GtranslatorSearchDialog * dialog)
{
- const gchar *str;
-
- str = gtranslator_search_dialog_get_search_text (dialog);
- if (str != NULL && *str != '\0')
- {
- g_free (data->find_text);
- data->find_text = gtranslator_utils_unescape_search_text (str);
- }
-
- str = gtranslator_search_dialog_get_replace_text (dialog);
- if (str != NULL && *str != '\0')
- {
- g_free (data->replace_text);
- data->replace_text = gtranslator_utils_unescape_search_text (str);
- }
-
- data->original_text = gtranslator_search_dialog_get_original_text (dialog);
- data->translated_text = gtranslator_search_dialog_get_translated_text (dialog);
- data->fuzzy_messages = gtranslator_search_dialog_get_fuzzy (dialog);
- data->match_case = gtranslator_search_dialog_get_match_case (dialog);
- data->entire_word = gtranslator_search_dialog_get_entire_word (dialog);
- data->backwards = gtranslator_search_dialog_get_backwards (dialog);
- data->wrap_around = gtranslator_search_dialog_get_wrap_around (dialog);
+ const gchar *str;
+
+ str = gtranslator_search_dialog_get_search_text (dialog);
+ if (str != NULL && *str != '\0')
+ {
+ g_free (data->find_text);
+ data->find_text = gtranslator_utils_unescape_search_text (str);
+ }
+
+ str = gtranslator_search_dialog_get_replace_text (dialog);
+ if (str != NULL && *str != '\0')
+ {
+ g_free (data->replace_text);
+ data->replace_text = gtranslator_utils_unescape_search_text (str);
+ }
+
+ data->original_text = gtranslator_search_dialog_get_original_text (dialog);
+ data->translated_text =
+ gtranslator_search_dialog_get_translated_text (dialog);
+ data->fuzzy_messages = gtranslator_search_dialog_get_fuzzy (dialog);
+ data->match_case = gtranslator_search_dialog_get_match_case (dialog);
+ data->entire_word = gtranslator_search_dialog_get_entire_word (dialog);
+ data->backwards = gtranslator_search_dialog_get_backwards (dialog);
+ data->wrap_around = gtranslator_search_dialog_get_wrap_around (dialog);
}
static void
-search_dialog_set_last_find_text (GtranslatorSearchDialog *dialog,
- LastSearchData *data)
+search_dialog_set_last_find_text (GtranslatorSearchDialog * dialog,
+ LastSearchData * data)
{
- if (data->find_text)
- gtranslator_search_dialog_set_search_text (dialog, data->find_text);
+ if (data->find_text)
+ gtranslator_search_dialog_set_search_text (dialog, data->find_text);
}
static void
-search_dialog_set_last_replace_text (GtranslatorSearchDialog *dialog,
- LastSearchData *data)
+search_dialog_set_last_replace_text (GtranslatorSearchDialog * dialog,
+ LastSearchData * data)
{
- if (data->replace_text)
- gtranslator_search_dialog_set_replace_text (dialog, data->replace_text);
+ if (data->replace_text)
+ gtranslator_search_dialog_set_replace_text (dialog, data->replace_text);
}
static void
-search_dialog_set_last_options (GtranslatorSearchDialog *dialog,
- LastSearchData *data)
+search_dialog_set_last_options (GtranslatorSearchDialog * dialog,
+ LastSearchData * data)
{
- gtranslator_search_dialog_set_original_text (dialog, data->original_text);
- gtranslator_search_dialog_set_translated_text (dialog, data->translated_text);
- gtranslator_search_dialog_set_fuzzy (dialog, data->fuzzy_messages);
- gtranslator_search_dialog_set_match_case (dialog, data->match_case);
- gtranslator_search_dialog_set_entire_word (dialog, data->entire_word);
- gtranslator_search_dialog_set_backwards (dialog, data->backwards);
- gtranslator_search_dialog_set_wrap_around (dialog, data->wrap_around);
+ gtranslator_search_dialog_set_original_text (dialog, data->original_text);
+ gtranslator_search_dialog_set_translated_text (dialog,
+ data->translated_text);
+ gtranslator_search_dialog_set_fuzzy (dialog, data->fuzzy_messages);
+ gtranslator_search_dialog_set_match_case (dialog, data->match_case);
+ gtranslator_search_dialog_set_entire_word (dialog, data->entire_word);
+ gtranslator_search_dialog_set_backwards (dialog, data->backwards);
+ gtranslator_search_dialog_set_wrap_around (dialog, data->wrap_around);
}
/*
* Used to get the old search data and store the new values.
*/
static void
-restore_last_searched_data (GtranslatorSearchDialog *dialog,
- GtranslatorTab *tab)
+restore_last_searched_data (GtranslatorSearchDialog * dialog,
+ GtranslatorTab * tab)
{
- LastSearchData *data;
+ LastSearchData *data;
- data = g_object_get_data (G_OBJECT (tab), GTR_LAST_SEARCH_DATA_KEY);
+ data = g_object_get_data (G_OBJECT (tab), GTR_LAST_SEARCH_DATA_KEY);
- if (data == NULL)
- {
- data = g_new0 (LastSearchData, 1);
- last_search_data_set (data, dialog);
+ if (data == NULL)
+ {
+ data = g_new0 (LastSearchData, 1);
+ last_search_data_set (data, dialog);
- g_object_set_data (G_OBJECT (tab),
- GTR_LAST_SEARCH_DATA_KEY,
- data);
+ g_object_set_data (G_OBJECT (tab), GTR_LAST_SEARCH_DATA_KEY, data);
- g_object_weak_ref (G_OBJECT (tab),
- (GWeakNotify) last_search_data_free,
- data);
- }
- else
- {
- last_search_data_set (data, dialog);
- }
+ g_object_weak_ref (G_OBJECT (tab),
+ (GWeakNotify) last_search_data_free, data);
+ }
+ else
+ {
+ last_search_data_set (data, dialog);
+ }
}
/* Use occurences only for Replace All */
static void
-phrase_found (GtranslatorWindow *window,
- gint occurrences)
+phrase_found (GtranslatorWindow * window, gint occurrences)
{
- GtranslatorStatusbar *statusbar;
-
- statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
-
- if (occurrences > 1)
- {
- gtranslator_statusbar_flash_message (statusbar,
- 0,
- ngettext("Found and replaced %d occurrence",
- "Found and replaced %d occurrences",
- occurrences),
- occurrences);
- }
- else
- {
- if (occurrences == 1)
- gtranslator_statusbar_flash_message (statusbar,
- 0,
- _("Found and replaced one occurrence"));
- else
- gtranslator_statusbar_flash_message (statusbar,
- 0,
- " ");
- }
+ GtranslatorStatusbar *statusbar;
+
+ statusbar = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+
+ if (occurrences > 1)
+ {
+ gtranslator_statusbar_flash_message (statusbar,
+ 0,
+ ngettext
+ ("Found and replaced %d occurrence",
+ "Found and replaced %d occurrences",
+ occurrences), occurrences);
+ }
+ else
+ {
+ if (occurrences == 1)
+ gtranslator_statusbar_flash_message (statusbar,
+ 0,
+ _
+ ("Found and replaced one occurrence"));
+ else
+ gtranslator_statusbar_flash_message (statusbar, 0, " ");
+ }
}
static void
-phrase_not_found (GtranslatorWindow *window)
+phrase_not_found (GtranslatorWindow * window)
{
- GtranslatorStatusbar *status;
-
- status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
- gtranslator_statusbar_flash_message (status, 0,
- _("Phrase not found"));
+ GtranslatorStatusbar *status;
+
+ status = GTR_STATUSBAR (gtranslator_window_get_statusbar (window));
+ gtranslator_statusbar_flash_message (status, 0, _("Phrase not found"));
}
static gboolean
-run_search (GtranslatorView *view,
- gboolean follow)
+run_search (GtranslatorView * view, gboolean follow)
{
- GtkSourceBuffer *doc;
- GtkTextIter start_iter;
- GtkTextIter match_start;
- GtkTextIter match_end;
- gboolean found = FALSE;
-
- g_return_val_if_fail(GTR_IS_VIEW(view), FALSE);
-
- doc = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
-
- if(!follow)
- gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(doc), &start_iter);
- else
- gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
- NULL,
- &start_iter);
-
- found = gtranslator_view_search_forward (view,
- &start_iter,
- NULL,
- &match_start,
- &match_end);
-
- if (found)
- {
- gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
- &match_start);
+ GtkSourceBuffer *doc;
+ GtkTextIter start_iter;
+ GtkTextIter match_start;
+ GtkTextIter match_end;
+ gboolean found = FALSE;
- gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc),
- "selection_bound",
- &match_end);
+ g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
- }
- else
- {
- gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
- &start_iter);
- }
-
- return found;
+ doc = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ if (!follow)
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (doc), &start_iter);
+ else
+ gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
+ NULL, &start_iter);
+
+ found = gtranslator_view_search_forward (view,
+ &start_iter,
+ NULL, &match_start, &match_end);
+
+ if (found)
+ {
+ gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &match_start);
+
+ gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc),
+ "selection_bound", &match_end);
+
+ }
+ else
+ {
+ gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &start_iter);
+ }
+
+ return found;
}
static gboolean
-find_in_list(GtranslatorWindow *window,
- GList *views,
- gboolean fuzzy,
- gboolean wrap_around,
- gboolean search_backwards)
+find_in_list (GtranslatorWindow * window,
+ GList * views,
+ gboolean fuzzy, gboolean wrap_around, gboolean search_backwards)
{
- GtranslatorTab *tab = gtranslator_window_get_active_tab(window);
- GtranslatorPo *po = gtranslator_tab_get_po(tab);
- GList *l = gtranslator_po_get_current_message(po);
- GList *current;
- static GList *viewsaux = NULL;
-
- current = l;
-
- if(viewsaux == NULL)
- viewsaux = views;
-
- /*
- * Variable used to know when start search in from the beggining of the view
- */
- static gboolean found = FALSE;
-
- do{
- if(gtranslator_msg_is_fuzzy(GTR_MSG(l->data)) && !fuzzy)
+ GtranslatorTab *tab = gtranslator_window_get_active_tab (window);
+ GtranslatorPo *po = gtranslator_tab_get_po (tab);
+ GList *l = gtranslator_po_get_current_message (po);
+ GList *current;
+ static GList *viewsaux = NULL;
+
+ current = l;
+
+ if (viewsaux == NULL)
+ viewsaux = views;
+
+ /*
+ * Variable used to know when start search in from the beggining of the view
+ */
+ static gboolean found = FALSE;
+
+ do
+ {
+ if (gtranslator_msg_is_fuzzy (GTR_MSG (l->data)) && !fuzzy)
+ {
+ if (!search_backwards)
+ {
+ if (l->next == NULL)
{
- if(!search_backwards)
- {
- if(l->next == NULL)
- {
- if(!wrap_around)
- return FALSE;
- l = g_list_first(l);
- }
- else l = l->next;
- }
- else{
- if(l->prev == NULL)
- {
- if(!wrap_around)
- return FALSE;
- l = g_list_last(l);
- }
- else l = l->prev;
- }
- gtranslator_tab_message_go_to(tab, l, TRUE, GTR_TAB_MOVE_NONE);
+ if (!wrap_around)
+ return FALSE;
+ l = g_list_first (l);
}
- else{
- while(viewsaux != NULL)
- {
- gboolean aux = found;
-
- found = run_search(GTR_VIEW(viewsaux->data), found);
- if(found)
- {
- gtranslator_tab_message_go_to (tab, l, FALSE, GTR_TAB_MOVE_NONE);
- run_search (GTR_VIEW (viewsaux->data), aux);
- return TRUE;
- }
- viewsaux = viewsaux->next;
- }
- if(!search_backwards)
- {
- if(l->next == NULL)
- {
- if(!wrap_around)
- return FALSE;
- l = g_list_first(l);
- }
- else l = l->next;
- }
- else{
- if(l->prev == NULL)
- {
- if(!wrap_around)
- return FALSE;
- l = g_list_last(l);
- }
- else l = l->prev;
- }
- gtranslator_tab_message_go_to(tab, l, TRUE, GTR_TAB_MOVE_NONE);
- viewsaux = views;
+ else
+ l = l->next;
+ }
+ else
+ {
+ if (l->prev == NULL)
+ {
+ if (!wrap_around)
+ return FALSE;
+ l = g_list_last (l);
}
- }while(l != current);
-
- return FALSE;
-}
-
-static void
-do_find (GtranslatorSearchDialog *dialog,
- GtranslatorWindow *window)
-{
- GtranslatorTab *tab;
- GList *views, *list;
- gchar *search_text;
- const gchar *entry_text;
- gboolean original_text;
- gboolean translated_text;
- gboolean fuzzy;
- gboolean match_case;
- gboolean entire_word;
- gboolean wrap_around;
- gboolean search_backwards;
- guint flags = 0;
- guint old_flags = 0;
- gboolean found;
-
- /* Used to store search options */
- tab = gtranslator_window_get_active_tab(window);
-
- entry_text = gtranslator_search_dialog_get_search_text (dialog);
-
- /* Views where find */
- original_text = gtranslator_search_dialog_get_original_text (dialog);
- translated_text = gtranslator_search_dialog_get_translated_text (dialog);
- fuzzy = gtranslator_search_dialog_get_fuzzy (dialog);
-
- /* Flags */
- match_case = gtranslator_search_dialog_get_match_case (dialog);
- entire_word = gtranslator_search_dialog_get_entire_word (dialog);
- search_backwards = gtranslator_search_dialog_get_backwards (dialog);
- wrap_around = gtranslator_search_dialog_get_wrap_around (dialog);
-
- if(!original_text && !translated_text && !fuzzy)
- return;
-
- /* Get textviews */
- views = gtranslator_window_get_all_views(window, original_text,
- translated_text);
-
- g_return_if_fail(views != NULL);
-
- list = views;
-
- GTR_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
- GTR_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
-
- while(list != NULL)
+ else
+ l = l->prev;
+ }
+ gtranslator_tab_message_go_to (tab, l, TRUE, GTR_TAB_MOVE_NONE);
+ }
+ else
{
- search_text = gtranslator_view_get_search_text (GTR_VIEW(list->data), &old_flags);
+ while (viewsaux != NULL)
+ {
+ gboolean aux = found;
- if ((search_text == NULL) ||
- (strcmp (search_text, entry_text) != 0) ||
- (flags != old_flags))
+ found = run_search (GTR_VIEW (viewsaux->data), found);
+ if (found)
{
- gtranslator_view_set_search_text (GTR_VIEW(list->data), entry_text, flags);
+ gtranslator_tab_message_go_to (tab, l, FALSE,
+ GTR_TAB_MOVE_NONE);
+ run_search (GTR_VIEW (viewsaux->data), aux);
+ return TRUE;
}
-
- g_free (search_text);
- list = list->next;
+ viewsaux = viewsaux->next;
+ }
+ if (!search_backwards)
+ {
+ if (l->next == NULL)
+ {
+ if (!wrap_around)
+ return FALSE;
+ l = g_list_first (l);
+ }
+ else
+ l = l->next;
+ }
+ else
+ {
+ if (l->prev == NULL)
+ {
+ if (!wrap_around)
+ return FALSE;
+ l = g_list_last (l);
+ }
+ else
+ l = l->prev;
+ }
+ gtranslator_tab_message_go_to (tab, l, TRUE, GTR_TAB_MOVE_NONE);
+ viewsaux = views;
}
-
- found = find_in_list (window, views, fuzzy,
- wrap_around, search_backwards);
-
- if (found)
- phrase_found (window, 0);
- else
- phrase_not_found (window);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
- found);
+ }
+ while (l != current);
- restore_last_searched_data (dialog, tab);
+ return FALSE;
}
static void
-replace_selected_text (GtkTextBuffer *buffer,
- const gchar *replace)
+do_find (GtranslatorSearchDialog * dialog, GtranslatorWindow * window)
{
- g_return_if_fail (gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL));
- g_return_if_fail (replace != NULL);
+ GtranslatorTab *tab;
+ GList *views, *list;
+ gchar *search_text;
+ const gchar *entry_text;
+ gboolean original_text;
+ gboolean translated_text;
+ gboolean fuzzy;
+ gboolean match_case;
+ gboolean entire_word;
+ gboolean wrap_around;
+ gboolean search_backwards;
+ guint flags = 0;
+ guint old_flags = 0;
+ gboolean found;
+
+ /* Used to store search options */
+ tab = gtranslator_window_get_active_tab (window);
+
+ entry_text = gtranslator_search_dialog_get_search_text (dialog);
+
+ /* Views where find */
+ original_text = gtranslator_search_dialog_get_original_text (dialog);
+ translated_text = gtranslator_search_dialog_get_translated_text (dialog);
+ fuzzy = gtranslator_search_dialog_get_fuzzy (dialog);
+
+ /* Flags */
+ match_case = gtranslator_search_dialog_get_match_case (dialog);
+ entire_word = gtranslator_search_dialog_get_entire_word (dialog);
+ search_backwards = gtranslator_search_dialog_get_backwards (dialog);
+ wrap_around = gtranslator_search_dialog_get_wrap_around (dialog);
+
+ if (!original_text && !translated_text && !fuzzy)
+ return;
+
+ /* Get textviews */
+ views = gtranslator_window_get_all_views (window, original_text,
+ translated_text);
+
+ g_return_if_fail (views != NULL);
+
+ list = views;
+
+ GTR_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
+ GTR_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
+
+ while (list != NULL)
+ {
+ search_text =
+ gtranslator_view_get_search_text (GTR_VIEW (list->data), &old_flags);
+
+ if ((search_text == NULL) ||
+ (strcmp (search_text, entry_text) != 0) || (flags != old_flags))
+ {
+ gtranslator_view_set_search_text (GTR_VIEW (list->data), entry_text,
+ flags);
+ }
- gtk_text_buffer_begin_user_action (buffer);
+ g_free (search_text);
+ list = list->next;
+ }
- gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
+ found = find_in_list (window, views, fuzzy, wrap_around, search_backwards);
- gtk_text_buffer_insert_at_cursor (buffer, replace, strlen (replace));
+ if (found)
+ phrase_found (window, 0);
+ else
+ phrase_not_found (window);
- gtk_text_buffer_end_user_action (buffer);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ found);
+
+ restore_last_searched_data (dialog, tab);
}
static void
-do_replace (GtranslatorSearchDialog *dialog,
- GtranslatorWindow *window)
+replace_selected_text (GtkTextBuffer * buffer, const gchar * replace)
{
- GtranslatorView *view;
- const gchar *search_entry_text;
- const gchar *replace_entry_text;
- gchar *unescaped_search_text;
- gchar *unescaped_replace_text;
- gchar *selected_text = NULL;
- gboolean match_case;
- gboolean search_backwards;
-
- view = gtranslator_window_get_active_view (window);
- if (view == NULL)
- return;
-
- search_entry_text = gtranslator_search_dialog_get_search_text (dialog);
- g_return_if_fail ((search_entry_text) != NULL);
- g_return_if_fail ((*search_entry_text) != '\0');
-
- /* replace text may be "", we just delete */
- replace_entry_text = gtranslator_search_dialog_get_replace_text (dialog);
- g_return_if_fail ((replace_entry_text) != NULL);
-
- unescaped_search_text = gtranslator_utils_unescape_search_text (search_entry_text);
-
- gtranslator_view_get_selected_text (view,
- &selected_text,
- NULL);
-
- match_case = gtranslator_search_dialog_get_match_case (dialog);
- search_backwards = gtranslator_search_dialog_get_backwards (dialog);
-
- if ((selected_text == NULL) ||
- (match_case && (strcmp (selected_text, unescaped_search_text) != 0)) ||
- (!match_case && !g_utf8_caselessnmatch (selected_text,
- unescaped_search_text,
- strlen (selected_text),
- strlen (unescaped_search_text)) != 0))
- {
- do_find (dialog, window);
- g_free (unescaped_search_text);
- g_free (selected_text);
+ g_return_if_fail (gtk_text_buffer_get_selection_bounds
+ (buffer, NULL, NULL));
+ g_return_if_fail (replace != NULL);
- return;
- }
+ gtk_text_buffer_begin_user_action (buffer);
- unescaped_replace_text = gtranslator_utils_unescape_search_text (replace_entry_text);
- replace_selected_text (gtk_text_view_get_buffer(GTK_TEXT_VIEW (view)),
- unescaped_replace_text);
+ gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
- g_free (unescaped_search_text);
- g_free (selected_text);
- g_free (unescaped_replace_text);
-
- do_find (dialog, window);
-}
+ gtk_text_buffer_insert_at_cursor (buffer, replace, strlen (replace));
-static void
-do_replace_all (GtranslatorSearchDialog *dialog,
- GtranslatorWindow *window)
-{
- GtranslatorTab *tab;
- GList *views, *l;
- GList *current_msg, *aux;
- const gchar *search_entry_text;
- const gchar *replace_entry_text;
- gboolean match_case;
- gboolean entire_word;
- guint flags = 0;
- gint count = 0;
-
- tab = gtranslator_window_get_active_tab(window);
-
- /* Get only translated textviews */
- views = gtranslator_window_get_all_views(window, FALSE,
- TRUE);
-
- current_msg = gtranslator_po_get_current_message(gtranslator_tab_get_po(tab));
-
- g_return_if_fail(views != NULL);
- g_return_if_fail(current_msg != NULL);
-
- l = views;
- aux = current_msg;
-
- search_entry_text = gtranslator_search_dialog_get_search_text (dialog);
- g_return_if_fail ((search_entry_text) != NULL);
- g_return_if_fail ((*search_entry_text) != '\0');
-
- /* replace text may be "", we just delete all occurrencies */
- replace_entry_text = gtranslator_search_dialog_get_replace_text (dialog);
- g_return_if_fail ((replace_entry_text) != NULL);
-
- match_case = gtranslator_search_dialog_get_match_case (dialog);
- entire_word = gtranslator_search_dialog_get_entire_word (dialog);
-
- GTR_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
- GTR_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
-
-
- do
- {
- while(l)
- {
- count += gtranslator_view_replace_all (GTR_VIEW(l->data),
- search_entry_text,
- replace_entry_text,
- flags);
- l = l->next;
- }
-
- l = views;
-
- if(aux->next == NULL)
- aux = g_list_first(aux);
- else aux = aux->next;
- gtranslator_tab_message_go_to(tab, aux, TRUE, GTR_TAB_MOVE_NONE);
- }while(current_msg != aux);
-
- gtranslator_tab_message_go_to(tab, aux, FALSE, GTR_TAB_MOVE_NONE);
-
- if (count > 0)
- {
- phrase_found (window, count);
- }
- else
- {
- phrase_not_found (window);
- }
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
- FALSE);
-
- restore_last_searched_data (dialog, tab);
+ gtk_text_buffer_end_user_action (buffer);
}
static void
-search_dialog_response_cb (GtranslatorSearchDialog *dialog,
- gint response_id,
- GtranslatorWindow *window)
+do_replace (GtranslatorSearchDialog * dialog, GtranslatorWindow * window)
{
- switch (response_id)
- {
- case GTR_SEARCH_DIALOG_FIND_RESPONSE:
- do_find (dialog, window);
- break;
- case GTR_SEARCH_DIALOG_REPLACE_RESPONSE:
- do_replace (dialog, window);
- break;
- case GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
- do_replace_all (dialog, window);
- break;
- default:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- }
+ GtranslatorView *view;
+ const gchar *search_entry_text;
+ const gchar *replace_entry_text;
+ gchar *unescaped_search_text;
+ gchar *unescaped_replace_text;
+ gchar *selected_text = NULL;
+ gboolean match_case;
+ gboolean search_backwards;
+
+ view = gtranslator_window_get_active_view (window);
+ if (view == NULL)
+ return;
+
+ search_entry_text = gtranslator_search_dialog_get_search_text (dialog);
+ g_return_if_fail ((search_entry_text) != NULL);
+ g_return_if_fail ((*search_entry_text) != '\0');
+
+ /* replace text may be "", we just delete */
+ replace_entry_text = gtranslator_search_dialog_get_replace_text (dialog);
+ g_return_if_fail ((replace_entry_text) != NULL);
+
+ unescaped_search_text =
+ gtranslator_utils_unescape_search_text (search_entry_text);
+
+ gtranslator_view_get_selected_text (view, &selected_text, NULL);
+
+ match_case = gtranslator_search_dialog_get_match_case (dialog);
+ search_backwards = gtranslator_search_dialog_get_backwards (dialog);
+
+ if ((selected_text == NULL) ||
+ (match_case && (strcmp (selected_text, unescaped_search_text) != 0)) ||
+ (!match_case && !g_utf8_caselessnmatch (selected_text,
+ unescaped_search_text,
+ strlen (selected_text),
+ strlen (unescaped_search_text))
+ != 0))
+ {
+ do_find (dialog, window);
+ g_free (unescaped_search_text);
+ g_free (selected_text);
+
+ return;
+ }
+
+ unescaped_replace_text =
+ gtranslator_utils_unescape_search_text (replace_entry_text);
+ replace_selected_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)),
+ unescaped_replace_text);
+
+ g_free (unescaped_search_text);
+ g_free (selected_text);
+ g_free (unescaped_replace_text);
+
+ do_find (dialog, window);
}
static void
-search_dialog_destroyed (GtranslatorWindow *window,
- GtranslatorSearchDialog *dialog)
+do_replace_all (GtranslatorSearchDialog * dialog, GtranslatorWindow * window)
{
- g_object_set_data (G_OBJECT (window),
- GTR_SEARCH_DIALOG_KEY,
- NULL);
-}
+ GtranslatorTab *tab;
+ GList *views, *l;
+ GList *current_msg, *aux;
+ const gchar *search_entry_text;
+ const gchar *replace_entry_text;
+ gboolean match_case;
+ gboolean entire_word;
+ guint flags = 0;
+ gint count = 0;
-void
-_gtranslator_actions_search_find (GtkAction *action,
- GtranslatorWindow *window)
-{
- gpointer data;
- GtkWidget *search_dialog;
- GtranslatorTab *tab;
- GtranslatorView *view;
- gboolean selection_exists;
- gchar *find_text = NULL;
- gint sel_len;
- LastSearchData *last_search_data;
-
- data = g_object_get_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY);
-
- if (data != NULL)
- {
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (data));
+ tab = gtranslator_window_get_active_tab (window);
- /* note that we rise a search&replace dialog if
- * it is already open
- */
+ /* Get only translated textviews */
+ views = gtranslator_window_get_all_views (window, FALSE, TRUE);
- gtranslator_search_dialog_present_with_time (GTR_SEARCH_DIALOG (data),
- GDK_CURRENT_TIME);
+ current_msg =
+ gtranslator_po_get_current_message (gtranslator_tab_get_po (tab));
- return;
- }
+ g_return_if_fail (views != NULL);
+ g_return_if_fail (current_msg != NULL);
- search_dialog = gtranslator_search_dialog_new (GTK_WINDOW (window),
- FALSE);
+ l = views;
+ aux = current_msg;
- g_object_set_data (G_OBJECT (window),
- GTR_SEARCH_DIALOG_KEY,
- search_dialog);
+ search_entry_text = gtranslator_search_dialog_get_search_text (dialog);
+ g_return_if_fail ((search_entry_text) != NULL);
+ g_return_if_fail ((*search_entry_text) != '\0');
- g_object_weak_ref (G_OBJECT (search_dialog),
- (GWeakNotify) search_dialog_destroyed,
- window);
+ /* replace text may be "", we just delete all occurrencies */
+ replace_entry_text = gtranslator_search_dialog_get_replace_text (dialog);
+ g_return_if_fail ((replace_entry_text) != NULL);
- tab = gtranslator_window_get_active_tab (window);
- view = gtranslator_window_get_active_view(window);
- g_return_if_fail (tab != NULL);
- g_return_if_fail (view != NULL);
+ match_case = gtranslator_search_dialog_get_match_case (dialog);
+ entire_word = gtranslator_search_dialog_get_entire_word (dialog);
- last_search_data = g_object_get_data (G_OBJECT (tab),
- GTR_LAST_SEARCH_DATA_KEY);
+ GTR_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
+ GTR_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
- selection_exists = gtranslator_view_get_selected_text (view,
- &find_text,
- &sel_len);
- if (selection_exists && find_text != NULL && sel_len < 80)
+ do
+ {
+ while (l)
{
- gtranslator_search_dialog_set_search_text (GTR_SEARCH_DIALOG (search_dialog),
- find_text);
- g_free (find_text);
+ count += gtranslator_view_replace_all (GTR_VIEW (l->data),
+ search_entry_text,
+ replace_entry_text, flags);
+ l = l->next;
}
- else
- {
- g_free (find_text);
- if (last_search_data != NULL)
- search_dialog_set_last_find_text (GTR_SEARCH_DIALOG (search_dialog),
- last_search_data);
- }
+ l = views;
+
+ if (aux->next == NULL)
+ aux = g_list_first (aux);
+ else
+ aux = aux->next;
+ gtranslator_tab_message_go_to (tab, aux, TRUE, GTR_TAB_MOVE_NONE);
+ }
+ while (current_msg != aux);
+
+ gtranslator_tab_message_go_to (tab, aux, FALSE, GTR_TAB_MOVE_NONE);
- if (last_search_data != NULL)
- search_dialog_set_last_replace_text (GTR_SEARCH_DIALOG (search_dialog),
- last_search_data);
+ if (count > 0)
+ {
+ phrase_found (window, count);
+ }
+ else
+ {
+ phrase_not_found (window);
+ }
- if (last_search_data != NULL)
- search_dialog_set_last_options (GTR_SEARCH_DIALOG (search_dialog),
- last_search_data);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ FALSE);
- g_signal_connect (search_dialog,
- "response",
- G_CALLBACK (search_dialog_response_cb),
- window);
+ restore_last_searched_data (dialog, tab);
+}
+
+static void
+search_dialog_response_cb (GtranslatorSearchDialog * dialog,
+ gint response_id, GtranslatorWindow * window)
+{
+ switch (response_id)
+ {
+ case GTR_SEARCH_DIALOG_FIND_RESPONSE:
+ do_find (dialog, window);
+ break;
+ case GTR_SEARCH_DIALOG_REPLACE_RESPONSE:
+ do_replace (dialog, window);
+ break;
+ case GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
+ do_replace_all (dialog, window);
+ break;
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+}
- gtk_widget_show (search_dialog);
+static void
+search_dialog_destroyed (GtranslatorWindow * window,
+ GtranslatorSearchDialog * dialog)
+{
+ g_object_set_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY, NULL);
}
void
-_gtranslator_actions_search_replace (GtkAction *action,
- GtranslatorWindow *window)
+_gtranslator_actions_search_find (GtkAction * action,
+ GtranslatorWindow * window)
{
- gpointer data;
- GtkWidget *replace_dialog;
- GtranslatorTab *tab;
- GtranslatorView *view;
- gboolean selection_exists;
- gchar *find_text = NULL;
- gint sel_len;
- LastSearchData *last_search_data;
-
- data = g_object_get_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY);
-
- if (data != NULL)
- {
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (data));
+ gpointer data;
+ GtkWidget *search_dialog;
+ GtranslatorTab *tab;
+ GtranslatorView *view;
+ gboolean selection_exists;
+ gchar *find_text = NULL;
+ gint sel_len;
+ LastSearchData *last_search_data;
+
+ data = g_object_get_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY);
+
+ if (data != NULL)
+ {
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (data));
+
+ /* note that we rise a search&replace dialog if
+ * it is already open
+ */
+
+ gtranslator_search_dialog_present_with_time (GTR_SEARCH_DIALOG (data),
+ GDK_CURRENT_TIME);
+
+ return;
+ }
+
+ search_dialog = gtranslator_search_dialog_new (GTK_WINDOW (window), FALSE);
+
+ g_object_set_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY, search_dialog);
+
+ g_object_weak_ref (G_OBJECT (search_dialog),
+ (GWeakNotify) search_dialog_destroyed, window);
+
+ tab = gtranslator_window_get_active_tab (window);
+ view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (tab != NULL);
+ g_return_if_fail (view != NULL);
+
+ last_search_data = g_object_get_data (G_OBJECT (tab),
+ GTR_LAST_SEARCH_DATA_KEY);
+
+ selection_exists = gtranslator_view_get_selected_text (view,
+ &find_text,
+ &sel_len);
+
+ if (selection_exists && find_text != NULL && sel_len < 80)
+ {
+ gtranslator_search_dialog_set_search_text (GTR_SEARCH_DIALOG
+ (search_dialog), find_text);
+ g_free (find_text);
+ }
+ else
+ {
+ g_free (find_text);
+
+ if (last_search_data != NULL)
+ search_dialog_set_last_find_text (GTR_SEARCH_DIALOG (search_dialog),
+ last_search_data);
+ }
+
+ if (last_search_data != NULL)
+ search_dialog_set_last_replace_text (GTR_SEARCH_DIALOG (search_dialog),
+ last_search_data);
+
+ if (last_search_data != NULL)
+ search_dialog_set_last_options (GTR_SEARCH_DIALOG (search_dialog),
+ last_search_data);
+
+ g_signal_connect (search_dialog,
+ "response",
+ G_CALLBACK (search_dialog_response_cb), window);
+
+ gtk_widget_show (search_dialog);
+}
- /* turn the dialog into a replace dialog if needed */
- if (!gtranslator_search_dialog_get_show_replace (GTR_SEARCH_DIALOG (data)))
- gtranslator_search_dialog_set_show_replace (GTR_SEARCH_DIALOG (data),
- TRUE);
+void
+_gtranslator_actions_search_replace (GtkAction * action,
+ GtranslatorWindow * window)
+{
+ gpointer data;
+ GtkWidget *replace_dialog;
+ GtranslatorTab *tab;
+ GtranslatorView *view;
+ gboolean selection_exists;
+ gchar *find_text = NULL;
+ gint sel_len;
+ LastSearchData *last_search_data;
- gtranslator_search_dialog_present_with_time (GTR_SEARCH_DIALOG (data),
- GDK_CURRENT_TIME);
+ data = g_object_get_data (G_OBJECT (window), GTR_SEARCH_DIALOG_KEY);
- return;
- }
+ if (data != NULL)
+ {
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (data));
- replace_dialog = gtranslator_search_dialog_new (GTK_WINDOW (window),
- TRUE);
+ /* turn the dialog into a replace dialog if needed */
+ if (!gtranslator_search_dialog_get_show_replace
+ (GTR_SEARCH_DIALOG (data)))
+ gtranslator_search_dialog_set_show_replace (GTR_SEARCH_DIALOG (data),
+ TRUE);
- g_object_set_data (G_OBJECT (window),
- GTR_SEARCH_DIALOG_KEY,
- replace_dialog);
+ gtranslator_search_dialog_present_with_time (GTR_SEARCH_DIALOG (data),
+ GDK_CURRENT_TIME);
- g_object_weak_ref (G_OBJECT (replace_dialog),
- (GWeakNotify) search_dialog_destroyed,
- window);
+ return;
+ }
- tab = gtranslator_window_get_active_tab (window);
- view = gtranslator_window_get_active_view(window);
- g_return_if_fail (tab != NULL);
+ replace_dialog = gtranslator_search_dialog_new (GTK_WINDOW (window), TRUE);
- last_search_data = g_object_get_data (G_OBJECT (tab),
- GTR_LAST_SEARCH_DATA_KEY);
+ g_object_set_data (G_OBJECT (window),
+ GTR_SEARCH_DIALOG_KEY, replace_dialog);
+ g_object_weak_ref (G_OBJECT (replace_dialog),
+ (GWeakNotify) search_dialog_destroyed, window);
- selection_exists = gtranslator_view_get_selected_text (view,
- &find_text,
- &sel_len);
+ tab = gtranslator_window_get_active_tab (window);
+ view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (tab != NULL);
- if (selection_exists && find_text != NULL && sel_len < 80)
- {
- gtranslator_search_dialog_set_search_text (GTR_SEARCH_DIALOG (replace_dialog),
- find_text);
- g_free (find_text);
- }
- else
- {
- g_free (find_text);
+ last_search_data = g_object_get_data (G_OBJECT (tab),
+ GTR_LAST_SEARCH_DATA_KEY);
- if (last_search_data != NULL)
- search_dialog_set_last_find_text (GTR_SEARCH_DIALOG (replace_dialog),
- last_search_data);
- }
- if (last_search_data != NULL)
- search_dialog_set_last_replace_text (GTR_SEARCH_DIALOG (replace_dialog),
- last_search_data);
+ selection_exists = gtranslator_view_get_selected_text (view,
+ &find_text,
+ &sel_len);
+
+ if (selection_exists && find_text != NULL && sel_len < 80)
+ {
+ gtranslator_search_dialog_set_search_text (GTR_SEARCH_DIALOG
+ (replace_dialog), find_text);
+ g_free (find_text);
+ }
+ else
+ {
+ g_free (find_text);
+
+ if (last_search_data != NULL)
+ search_dialog_set_last_find_text (GTR_SEARCH_DIALOG (replace_dialog),
+ last_search_data);
+ }
- if (last_search_data != NULL)
- search_dialog_set_last_options (GTR_SEARCH_DIALOG (replace_dialog),
- last_search_data);
+ if (last_search_data != NULL)
+ search_dialog_set_last_replace_text (GTR_SEARCH_DIALOG (replace_dialog),
+ last_search_data);
- g_signal_connect (replace_dialog,
- "response",
- G_CALLBACK (search_dialog_response_cb),
- window);
+ if (last_search_data != NULL)
+ search_dialog_set_last_options (GTR_SEARCH_DIALOG (replace_dialog),
+ last_search_data);
- gtk_widget_show (replace_dialog);
+ g_signal_connect (replace_dialog,
+ "response",
+ G_CALLBACK (search_dialog_response_cb), window);
+
+ gtk_widget_show (replace_dialog);
}
static void
-do_find_again (GtranslatorWindow *window,
- gboolean backward)
+do_find_again (GtranslatorWindow * window, gboolean backward)
{
- GtranslatorView *active_view;
- GtkTextBuffer *buffer;
- gboolean wrap_around = TRUE;
- LastSearchData *data;
-
- active_view = gtranslator_window_get_active_view (window);
- g_return_if_fail (active_view != NULL);
+ GtranslatorView *active_view;
+ GtkTextBuffer *buffer;
+ gboolean wrap_around = TRUE;
+ LastSearchData *data;
+
+ active_view = gtranslator_window_get_active_view (window);
+ g_return_if_fail (active_view != NULL);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view));
- data = g_object_get_data (G_OBJECT (buffer),
- GTR_LAST_SEARCH_DATA_KEY);
+ data = g_object_get_data (G_OBJECT (buffer), GTR_LAST_SEARCH_DATA_KEY);
- if (data != NULL)
- wrap_around = data->wrap_around;
+ if (data != NULL)
+ wrap_around = data->wrap_around;
- //run_search (active_view);
+ //run_search (active_view);
}
void
-_gtranslator_actions_search_find_next (GtkAction *action,
- GtranslatorWindow *window)
+_gtranslator_actions_search_find_next (GtkAction * action,
+ GtranslatorWindow * window)
{
- do_find_again (window, FALSE);
+ do_find_again (window, FALSE);
}
void
-_gtranslator_actions_search_find_prev (GtkAction *action,
- GtranslatorWindow *window)
+_gtranslator_actions_search_find_prev (GtkAction * action,
+ GtranslatorWindow * window)
{
- do_find_again (window, TRUE);
+ do_find_again (window, TRUE);
}
diff --git a/src/actions-view.c b/src/actions-view.c
index f6a00a8..549835f 100644
--- a/src/actions-view.c
+++ b/src/actions-view.c
@@ -18,27 +18,27 @@
#include "actions.h"
void
-gtranslator_actions_view_context (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_view_context (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *tab;
- GtkWidget *context;
-
- tab = gtranslator_window_get_active_tab (window);
- context = GTK_WIDGET (gtranslator_tab_get_context_panel (tab));
-
- gtranslator_tab_show_lateral_panel_widget (tab, context);
+ GtranslatorTab *tab;
+ GtkWidget *context;
+
+ tab = gtranslator_window_get_active_tab (window);
+ context = GTK_WIDGET (gtranslator_tab_get_context_panel (tab));
+
+ gtranslator_tab_show_lateral_panel_widget (tab, context);
}
void
-gtranslator_actions_view_translation_memory (GtkAction *action,
- GtranslatorWindow *window)
+gtranslator_actions_view_translation_memory (GtkAction * action,
+ GtranslatorWindow * window)
{
- GtranslatorTab *tab;
- GtkWidget *tm_ui;
-
- tab = gtranslator_window_get_active_tab (window);
- tm_ui = GTK_WIDGET (gtranslator_tab_get_translation_memory_ui (tab));
-
- gtranslator_tab_show_lateral_panel_widget (tab, tm_ui);
+ GtranslatorTab *tab;
+ GtkWidget *tm_ui;
+
+ tab = gtranslator_window_get_active_tab (window);
+ tm_ui = GTK_WIDGET (gtranslator_tab_get_translation_memory_ui (tab));
+
+ gtranslator_tab_show_lateral_panel_widget (tab, tm_ui);
}
diff --git a/src/actions.h b/src/actions.h
index 6c47f66..e3b9a48 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -24,149 +24,133 @@
#include "window.h"
G_BEGIN_DECLS
-
/*File*/
-void gtranslator_open_file_dialog (GtkAction * action,
- GtranslatorWindow *window);
+void gtranslator_open_file_dialog (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_save_current_file_dialog (GtkWidget * widget,
- GtranslatorWindow *window);
+void gtranslator_save_current_file_dialog (GtkWidget * widget,
+ GtranslatorWindow * window);
-void gtranslator_save_file_as_dialog (GtkAction * action,
- GtranslatorWindow *window);
+void gtranslator_save_file_as_dialog (GtkAction * action,
+ GtranslatorWindow * window);
-gboolean gtranslator_open (GFile *location,
- GtranslatorWindow *window,
- GError **error);
+gboolean gtranslator_open (GFile * location,
+ GtranslatorWindow * window, GError ** error);
-void gtranslator_close_tab (GtranslatorTab *tab,
- GtranslatorWindow *window);
+void gtranslator_close_tab (GtranslatorTab * tab, GtranslatorWindow * window);
-void gtranslator_file_close (GtkAction * widget,
- GtranslatorWindow *window);
+void gtranslator_file_close (GtkAction * widget, GtranslatorWindow * window);
-void gtranslator_file_quit (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_file_quit (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_actions_load_locations (GtranslatorWindow *window,
- const GSList *locations);
+void gtranslator_actions_load_locations (GtranslatorWindow * window,
+ const GSList * locations);
-void _gtranslator_actions_file_close_all (GtkAction *action,
- GtranslatorWindow *window);
+void _gtranslator_actions_file_close_all (GtkAction * action,
+ GtranslatorWindow * window);
-void _gtranslator_actions_file_save_all (GtkAction *action,
- GtranslatorWindow *window);
+void _gtranslator_actions_file_save_all (GtkAction * action,
+ GtranslatorWindow * window);
/*Edit*/
-void gtranslator_actions_edit_undo (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_undo (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_edit_redo (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_redo (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_edit_cut (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_cut (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_edit_copy (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_copy (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_edit_paste (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_paste (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_edit_header (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_header (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_edit_message_comment (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_edit_message_comment (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_copy_to_translation
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_copy_to_translation
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_message_status_toggle_fuzzy
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_status_toggle_fuzzy
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_actions_edit_preferences (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_preferences (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_edit_clear (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_edit_clear (GtkAction * action,
+ GtranslatorWindow * window);
/* View */
-void gtranslator_actions_view_context (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_view_context (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_actions_view_translation_memory
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_actions_view_translation_memory
+ (GtkAction * action, GtranslatorWindow * window);
/*Go*/
-void gtranslator_message_go_to_first (GtkAction * action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_first (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_go_to_previous (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_previous (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_go_to_next (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_next (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_go_to_last (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_last (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_go_to_next_fuzzy (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_next_fuzzy (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_go_to_prev_fuzzy (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_prev_fuzzy (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_message_go_to_next_untranslated
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_next_untranslated
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_message_go_to_prev_untranslated
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_prev_untranslated
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_message_go_to_next_fuzzy_or_untranslated
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_next_fuzzy_or_untranslated
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_message_go_to_prev_fuzzy_or_untranslated
- (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_go_to_prev_fuzzy_or_untranslated
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_message_jump (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_message_jump (GtkAction * action,
+ GtranslatorWindow * window);
/*Search*/
-void _gtranslator_actions_search_find (GtkAction *action,
- GtranslatorWindow *window);
+void _gtranslator_actions_search_find (GtkAction * action,
+ GtranslatorWindow * window);
-void _gtranslator_actions_search_replace (GtkAction *action,
- GtranslatorWindow *window);
+void _gtranslator_actions_search_replace (GtkAction * action,
+ GtranslatorWindow * window);
/*Documents*/
-void gtranslator_actions_documents_next_document
- (GtkAction * action,
- GtranslatorWindow *window);
+void gtranslator_actions_documents_next_document
+ (GtkAction * action, GtranslatorWindow * window);
-void gtranslator_actions_documents_previous_document
- (GtkAction * action,
- GtranslatorWindow *window);
+void gtranslator_actions_documents_previous_document
+ (GtkAction * action, GtranslatorWindow * window);
/*Help*/
-void gtranslator_window_show_home_page (GtkAction *action,
- gpointer useless);
+void gtranslator_window_show_home_page (GtkAction * action, gpointer useless);
-void gtranslator_cmd_help_contents (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_cmd_help_contents (GtkAction * action,
+ GtranslatorWindow * window);
-void gtranslator_about_dialog (GtkAction *action,
- GtranslatorWindow *window);
+void gtranslator_about_dialog (GtkAction * action,
+ GtranslatorWindow * window);
G_END_DECLS
-
#endif
diff --git a/src/application.c b/src/application.c
index 83d0ec5..b24d223 100644
--- a/src/application.c
+++ b/src/application.c
@@ -31,7 +31,7 @@
#include "dialogs/assistant.h"
#include "./translation-memory/translation-memory.h"
#include "./translation-memory/berkeley/berkeley.h"
-
+
#include <glib.h>
@@ -45,227 +45,224 @@
GTR_TYPE_APPLICATION, \
GtranslatorApplicationPrivate))
-G_DEFINE_TYPE(GtranslatorApplication, gtranslator_application, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GtranslatorApplication, gtranslator_application, G_TYPE_OBJECT)
+ struct _GtranslatorApplicationPrivate
+ {
+ GList *windows;
+ GtranslatorWindow *active_window;
-struct _GtranslatorApplicationPrivate
-{
- GList *windows;
- GtranslatorWindow *active_window;
-
- GList *profiles;
- GtranslatorProfile *active_profile;
-
- gchar *toolbars_file;
- EggToolbarsModel *toolbars_model;
-
- GtkIconFactory *icon_factory;
-
- gchar *last_dir;
-
- GtranslatorTranslationMemory *tm;
-
- gboolean first_run;
-};
-
-static gchar *
-get_accel_file (void)
+ GList *profiles;
+ GtranslatorProfile *active_profile;
+
+ gchar *toolbars_file;
+ EggToolbarsModel *toolbars_model;
+
+ GtkIconFactory *icon_factory;
+
+ gchar *last_dir;
+
+ GtranslatorTranslationMemory *tm;
+
+ gboolean first_run;
+ };
+
+ static gchar *get_accel_file (void)
{
- gchar *config;
+ gchar *config;
- config = gtranslator_utils_get_user_config_dir ();
+ config = gtranslator_utils_get_user_config_dir ();
- if (config != NULL)
- {
- return g_build_filename (config,
- "gtranslator-accels",
- NULL);
- g_free (config);
- }
+ if (config != NULL)
+ {
+ return g_build_filename (config, "gtranslator-accels", NULL);
+ g_free (config);
+ }
- return NULL;
+ return NULL;
}
static void
load_accels (void)
{
- gchar *filename;
-
- filename = get_accel_file ();
- if (filename != NULL)
- {
- gtk_accel_map_load (filename);
- g_free (filename);
- }
+ gchar *filename;
+
+ filename = get_accel_file ();
+ if (filename != NULL)
+ {
+ gtk_accel_map_load (filename);
+ g_free (filename);
+ }
}
static void
save_accels (void)
{
- gchar *filename;
-
- filename = get_accel_file ();
- if (filename != NULL)
- {
- gtk_accel_map_save (filename);
- g_free (filename);
- }
+ gchar *filename;
+
+ filename = get_accel_file ();
+ if (filename != NULL)
+ {
+ gtk_accel_map_save (filename);
+ g_free (filename);
+ }
}
static gboolean
-on_window_delete_event_cb(GtranslatorWindow *window,
- GdkEvent *event,
- GtranslatorApplication *app)
+on_window_delete_event_cb (GtranslatorWindow * window,
+ GdkEvent * event, GtranslatorApplication * app)
{
- gtranslator_file_quit(NULL, window);
- return TRUE;
+ gtranslator_file_quit (NULL, window);
+ return TRUE;
}
static void
-on_window_destroy_cb(GtranslatorWindow *window,
- GtranslatorApplication *app)
+on_window_destroy_cb (GtranslatorWindow * window,
+ GtranslatorApplication * app)
{
- save_accels ();
- //if(app->priv->active_window == NULL)
- g_object_unref(app);
+ save_accels ();
+ //if(app->priv->active_window == NULL)
+ g_object_unref (app);
}
static void
-gtranslator_application_init (GtranslatorApplication *application)
+gtranslator_application_init (GtranslatorApplication * application)
{
- gchar *gtranslator_folder;
- gchar *path_default_gtr_toolbar;
- gchar *profiles_file;
-
- GtranslatorApplicationPrivate * priv;
-
- application->priv = GTR_APPLICATION_GET_PRIVATE (application);
- priv = application->priv;
-
- priv->windows = NULL;
- priv->last_dir = NULL;
- priv->first_run = FALSE;
- priv->profiles = NULL;
-
- /*
- * Creating config folder
- */
- gtranslator_folder = gtranslator_utils_get_user_config_dir ();
-
- if (!g_file_test (gtranslator_folder, G_FILE_TEST_IS_DIR))
+ gchar *gtranslator_folder;
+ gchar *path_default_gtr_toolbar;
+ gchar *profiles_file;
+
+ GtranslatorApplicationPrivate *priv;
+
+ application->priv = GTR_APPLICATION_GET_PRIVATE (application);
+ priv = application->priv;
+
+ priv->windows = NULL;
+ priv->last_dir = NULL;
+ priv->first_run = FALSE;
+ priv->profiles = NULL;
+
+ /*
+ * Creating config folder
+ */
+ gtranslator_folder = gtranslator_utils_get_user_config_dir ();
+
+ if (!g_file_test (gtranslator_folder, G_FILE_TEST_IS_DIR))
+ {
+ GFile *file;
+ GError *error = NULL;
+
+ file = g_file_new_for_path (gtranslator_folder);
+
+ if (g_file_test (gtranslator_folder, G_FILE_TEST_IS_REGULAR))
{
- GFile *file;
- GError *error = NULL;
-
- file = g_file_new_for_path (gtranslator_folder);
-
- if (g_file_test (gtranslator_folder, G_FILE_TEST_IS_REGULAR))
- {
- if (!g_file_delete (file, NULL, &error))
- {
- g_warning ("There was an error deleting the "
- "old gtranslator file: %s", error->message);
- g_error_free (error);
- g_object_unref (file);
- g_free (gtranslator_folder);
- gtranslator_application_shutdown (application);
- }
- }
-
- if (!g_file_make_directory (file, NULL, &error))
- {
- g_warning ("There was an error making the gtranslator config directory: %s",
- error->message);
-
- g_error_free (error);
- g_object_unref (file);
- g_free (gtranslator_folder);
- gtranslator_application_shutdown (application);
- }
-
- priv->first_run = TRUE;
- g_object_unref (file);
+ if (!g_file_delete (file, NULL, &error))
+ {
+ g_warning ("There was an error deleting the "
+ "old gtranslator file: %s", error->message);
+ g_error_free (error);
+ g_object_unref (file);
+ g_free (gtranslator_folder);
+ gtranslator_application_shutdown (application);
+ }
}
- /*
- * If the config folder exists but there is no profile
- */
- profiles_file = g_build_filename (gtranslator_folder, "profiles.xml", NULL);
- if (!g_file_test (profiles_file, G_FILE_TEST_EXISTS))
- priv->first_run = TRUE;
- g_free (profiles_file);
-
- priv->toolbars_model = egg_toolbars_model_new ();
-
- priv->toolbars_file = g_build_filename (gtranslator_folder,
- "gtr-toolbar.xml",
- NULL);
- path_default_gtr_toolbar = gtranslator_utils_get_file_from_pkgdatadir ("gtr-toolbar.xml");
-
- g_free (gtranslator_folder);
-
- egg_toolbars_model_load_names (priv->toolbars_model,
- path_default_gtr_toolbar);
-
- if (!egg_toolbars_model_load_toolbars (priv->toolbars_model,
- priv->toolbars_file))
+ if (!g_file_make_directory (file, NULL, &error))
{
- egg_toolbars_model_load_toolbars (priv->toolbars_model,
- path_default_gtr_toolbar);
+ g_warning
+ ("There was an error making the gtranslator config directory: %s",
+ error->message);
+
+ g_error_free (error);
+ g_object_unref (file);
+ g_free (gtranslator_folder);
+ gtranslator_application_shutdown (application);
}
-
- g_free (path_default_gtr_toolbar);
-
- egg_toolbars_model_set_flags (priv->toolbars_model, 0,
- EGG_TB_MODEL_NOT_REMOVABLE);
-
- load_accels ();
-
- /* Create Icon factory */
- application->priv->icon_factory = gtk_icon_factory_new ();
- gtk_icon_factory_add_default (application->priv->icon_factory);
-
- /* Creating translation memory */
- application->priv->tm = GTR_TRANSLATION_MEMORY (gtranslator_berkeley_new ());
- gtranslator_translation_memory_set_max_omits (application->priv->tm,
- gtranslator_prefs_manager_get_max_missing_words ());
- gtranslator_translation_memory_set_max_delta (application->priv->tm,
- gtranslator_prefs_manager_get_max_length_diff ());
- gtranslator_translation_memory_set_max_items (application->priv->tm,
- 10);
+
+ priv->first_run = TRUE;
+ g_object_unref (file);
+ }
+
+ /*
+ * If the config folder exists but there is no profile
+ */
+ profiles_file = g_build_filename (gtranslator_folder, "profiles.xml", NULL);
+ if (!g_file_test (profiles_file, G_FILE_TEST_EXISTS))
+ priv->first_run = TRUE;
+ g_free (profiles_file);
+
+ priv->toolbars_model = egg_toolbars_model_new ();
+
+ priv->toolbars_file = g_build_filename (gtranslator_folder,
+ "gtr-toolbar.xml", NULL);
+ path_default_gtr_toolbar =
+ gtranslator_utils_get_file_from_pkgdatadir ("gtr-toolbar.xml");
+
+ g_free (gtranslator_folder);
+
+ egg_toolbars_model_load_names (priv->toolbars_model,
+ path_default_gtr_toolbar);
+
+ if (!egg_toolbars_model_load_toolbars (priv->toolbars_model,
+ priv->toolbars_file))
+ {
+ egg_toolbars_model_load_toolbars (priv->toolbars_model,
+ path_default_gtr_toolbar);
+ }
+
+ g_free (path_default_gtr_toolbar);
+
+ egg_toolbars_model_set_flags (priv->toolbars_model, 0,
+ EGG_TB_MODEL_NOT_REMOVABLE);
+
+ load_accels ();
+
+ /* Create Icon factory */
+ application->priv->icon_factory = gtk_icon_factory_new ();
+ gtk_icon_factory_add_default (application->priv->icon_factory);
+
+ /* Creating translation memory */
+ application->priv->tm =
+ GTR_TRANSLATION_MEMORY (gtranslator_berkeley_new ());
+ gtranslator_translation_memory_set_max_omits (application->priv->tm,
+ gtranslator_prefs_manager_get_max_missing_words
+ ());
+ gtranslator_translation_memory_set_max_delta (application->priv->tm,
+ gtranslator_prefs_manager_get_max_length_diff
+ ());
+ gtranslator_translation_memory_set_max_items (application->priv->tm, 10);
}
static void
-gtranslator_application_finalize (GObject *object)
+gtranslator_application_finalize (GObject * object)
{
- GtranslatorApplication *app = GTR_APPLICATION (object);
-
- if (app->priv->icon_factory)
- g_object_unref (app->priv->icon_factory);
+ GtranslatorApplication *app = GTR_APPLICATION (object);
+
+ if (app->priv->icon_factory)
+ g_object_unref (app->priv->icon_factory);
+
+ g_free (app->priv->last_dir);
- g_free (app->priv->last_dir);
-
- if (app->priv->tm)
- g_object_unref (app->priv->tm);
+ if (app->priv->tm)
+ g_object_unref (app->priv->tm);
- G_OBJECT_CLASS (gtranslator_application_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_application_parent_class)->finalize (object);
}
static void
-gtranslator_application_class_init (GtranslatorApplicationClass *klass)
+gtranslator_application_class_init (GtranslatorApplicationClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorApplicationPrivate));
-
- object_class->finalize = gtranslator_application_finalize;
+ g_type_class_add_private (klass, sizeof (GtranslatorApplicationPrivate));
+
+ object_class->finalize = gtranslator_application_finalize;
}
static void
-app_weak_notify (gpointer data,
- GObject *where_the_app_was)
+app_weak_notify (gpointer data, GObject * where_the_app_was)
{
- gtk_main_quit ();
+ gtk_main_quit ();
}
/**
@@ -278,17 +275,15 @@ app_weak_notify (gpointer data,
GtranslatorApplication *
gtranslator_application_get_default (void)
{
- static GtranslatorApplication *instance = NULL;
-
- if(!instance)
- {
- instance = GTR_APPLICATION(g_object_new (GTR_TYPE_APPLICATION, NULL));
-
- g_object_weak_ref (G_OBJECT (instance),
- app_weak_notify,
- NULL);
- }
- return instance;
+ static GtranslatorApplication *instance = NULL;
+
+ if (!instance)
+ {
+ instance = GTR_APPLICATION (g_object_new (GTR_TYPE_APPLICATION, NULL));
+
+ g_object_weak_ref (G_OBJECT (instance), app_weak_notify, NULL);
+ }
+ return instance;
}
/**
@@ -300,47 +295,48 @@ gtranslator_application_get_default (void)
* Returns: the #GtranslatorWindow to be opened
*/
GtranslatorWindow *
-gtranslator_application_open_window (GtranslatorApplication *app)
+gtranslator_application_open_window (GtranslatorApplication * app)
{
- GtranslatorWindow *window;
- GdkWindowState state;
- gint w,h;
-
- app->priv->active_window = window = GTR_WINDOW(g_object_new(GTR_TYPE_WINDOW, NULL));
-
- state = gtranslator_prefs_manager_get_window_state();
-
- if((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
- {
- gtranslator_prefs_manager_get_default_window_size(&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
- gtk_window_maximize (GTK_WINDOW (window));
- }
- else
- {
- gtranslator_prefs_manager_get_window_size(&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
- gtk_window_unmaximize (GTK_WINDOW (window));
- }
-
- g_signal_connect(window, "delete-event",
- G_CALLBACK(on_window_delete_event_cb), app);
-
- g_signal_connect(window, "destroy",
- G_CALLBACK(on_window_destroy_cb), app);
-
- gtk_widget_show(GTK_WIDGET(window));
-
- /*
- * If it is the first run, the default directory was created in this
- * run, then we show the First run Assistant
- */
- if (app->priv->first_run)
- gtranslator_show_assistant (window);
-
- return window;
+ GtranslatorWindow *window;
+ GdkWindowState state;
+ gint w, h;
+
+ app->priv->active_window = window =
+ GTR_WINDOW (g_object_new (GTR_TYPE_WINDOW, NULL));
+
+ state = gtranslator_prefs_manager_get_window_state ();
+
+ if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+ {
+ gtranslator_prefs_manager_get_default_window_size (&w, &h);
+ gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+ gtk_window_maximize (GTK_WINDOW (window));
+ }
+ else
+ {
+ gtranslator_prefs_manager_get_window_size (&w, &h);
+ gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+ gtk_window_unmaximize (GTK_WINDOW (window));
+ }
+
+ g_signal_connect (window, "delete-event",
+ G_CALLBACK (on_window_delete_event_cb), app);
+
+ g_signal_connect (window, "destroy",
+ G_CALLBACK (on_window_destroy_cb), app);
+
+ gtk_widget_show (GTK_WIDGET (window));
+
+ /*
+ * If it is the first run, the default directory was created in this
+ * run, then we show the First run Assistant
+ */
+ if (app->priv->first_run)
+ gtranslator_show_assistant (window);
+
+ return window;
}
-
+
/**
* _gtranslator_application_get_toolbars_model:
* @application: a #GtranslatorApplication
@@ -350,9 +346,10 @@ gtranslator_application_open_window (GtranslatorApplication *app)
* Retuns: the toolbar model.
*/
GObject *
-_gtranslator_application_get_toolbars_model (GtranslatorApplication *application)
+_gtranslator_application_get_toolbars_model (GtranslatorApplication *
+ application)
{
- return G_OBJECT (application->priv->toolbars_model);
+ return G_OBJECT (application->priv->toolbars_model);
}
/**
@@ -362,10 +359,11 @@ _gtranslator_application_get_toolbars_model (GtranslatorApplication *application
* Saves the toolbar model.
*/
void
-_gtranslator_application_save_toolbars_model (GtranslatorApplication *application)
+_gtranslator_application_save_toolbars_model (GtranslatorApplication *
+ application)
{
- egg_toolbars_model_save_toolbars (application->priv->toolbars_model,
- application->priv->toolbars_file, "1.0");
+ egg_toolbars_model_save_toolbars (application->priv->toolbars_model,
+ application->priv->toolbars_file, "1.0");
}
/**
@@ -375,17 +373,17 @@ _gtranslator_application_save_toolbars_model (GtranslatorApplication *applicatio
* Shutdowns the application.
*/
void
-gtranslator_application_shutdown(GtranslatorApplication *app)
+gtranslator_application_shutdown (GtranslatorApplication * app)
{
- if(app->priv->toolbars_model)
- {
- g_object_unref(app->priv->toolbars_model);
- g_free(app->priv->toolbars_file);
- app->priv->toolbars_model = NULL;
- app->priv->toolbars_file = NULL;
- }
-
- g_object_unref(app);
+ if (app->priv->toolbars_model)
+ {
+ g_object_unref (app->priv->toolbars_model);
+ g_free (app->priv->toolbars_file);
+ app->priv->toolbars_model = NULL;
+ app->priv->toolbars_file = NULL;
+ }
+
+ g_object_unref (app);
}
/**
@@ -399,20 +397,21 @@ gtranslator_application_shutdown(GtranslatorApplication *app)
* Return value: a newly allocated list of #GtranslationApplication objects
*/
GList *
-gtranslator_application_get_views (GtranslatorApplication *app,
- gboolean original,
- gboolean translated)
+gtranslator_application_get_views (GtranslatorApplication * app,
+ gboolean original, gboolean translated)
{
- GList *res = NULL;
+ GList *res = NULL;
+
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+ res = g_list_concat (res,
+ gtranslator_window_get_all_views (GTR_WINDOW
+ (app->priv->
+ active_window),
+ original,
+ translated));
- res = g_list_concat (res,
- gtranslator_window_get_all_views (GTR_WINDOW (app->priv->active_window),
- original,
- translated));
-
- return res;
+ return res;
}
/**
@@ -422,9 +421,9 @@ gtranslator_application_get_views (GtranslatorApplication *app,
* Return value: the active #GtranslatorWindow
**/
GtranslatorWindow *
-gtranslator_application_get_active_window(GtranslatorApplication * app)
+gtranslator_application_get_active_window (GtranslatorApplication * app)
{
- return GTR_WINDOW(app->priv->active_window);
+ return GTR_WINDOW (app->priv->active_window);
}
/**
@@ -434,14 +433,15 @@ gtranslator_application_get_active_window(GtranslatorApplication * app)
* Return value: a list of all opened windows.
**/
const GList *
-gtranslator_application_get_windows (GtranslatorApplication *app)
+gtranslator_application_get_windows (GtranslatorApplication * app)
{
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+
+ if (!app->priv->windows)
+ app->priv->windows =
+ g_list_prepend (app->priv->windows, app->priv->active_window);
- if(!app->priv->windows)
- app->priv->windows = g_list_prepend(app->priv->windows, app->priv->active_window);
-
- return app->priv->windows;
+ return app->priv->windows;
}
/**
@@ -451,9 +451,9 @@ gtranslator_application_get_windows (GtranslatorApplication *app)
* Return value: the active #GtranslatorProfile
**/
GtranslatorProfile *
-gtranslator_application_get_active_profile (GtranslatorApplication *app)
+gtranslator_application_get_active_profile (GtranslatorApplication * app)
{
- return app->priv->active_profile;
+ return app->priv->active_profile;
}
/**
@@ -463,8 +463,9 @@ gtranslator_application_get_active_profile (GtranslatorApplication *app)
*
**/
void
-gtranslator_application_set_active_profile (GtranslatorApplication *app,
- GtranslatorProfile *profile) {
+gtranslator_application_set_active_profile (GtranslatorApplication * app,
+ GtranslatorProfile * profile)
+{
app->priv->active_profile = profile;
}
@@ -475,11 +476,11 @@ gtranslator_application_set_active_profile (GtranslatorApplication *app,
* Return value: a list of all profiles.
**/
GList *
-gtranslator_application_get_profiles (GtranslatorApplication *app)
+gtranslator_application_get_profiles (GtranslatorApplication * app)
{
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
- return app->priv->profiles;
+ return app->priv->profiles;
}
/**
@@ -489,9 +490,10 @@ gtranslator_application_get_profiles (GtranslatorApplication *app)
*
**/
void
-gtranslator_application_set_profiles (GtranslatorApplication *app,
- GList *profiles) {
- app->priv->profiles = profiles;
+gtranslator_application_set_profiles (GtranslatorApplication * app,
+ GList * profiles)
+{
+ app->priv->profiles = profiles;
}
/**
@@ -503,26 +505,26 @@ gtranslator_application_set_profiles (GtranslatorApplication *app,
* Registers a new @icon with the @stock_id.
*/
void
-gtranslator_application_register_icon (GtranslatorApplication *app,
- const gchar *icon,
- const gchar *stock_id)
+gtranslator_application_register_icon (GtranslatorApplication * app,
+ const gchar * icon,
+ const gchar * stock_id)
{
- GtkIconSet *icon_set;
- GtkIconSource * icon_source = gtk_icon_source_new ();
- gchar *path;
-
- path = gtranslator_utils_get_file_from_pixmapsdir (icon);
-
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file (path, NULL);
- if (pixbuf)
- {
- icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
- gtk_icon_factory_add (app->priv->icon_factory, stock_id, icon_set);
- g_object_unref (pixbuf);
- }
-
- g_free (path);
- gtk_icon_source_free (icon_source);
+ GtkIconSet *icon_set;
+ GtkIconSource *icon_source = gtk_icon_source_new ();
+ gchar *path;
+
+ path = gtranslator_utils_get_file_from_pixmapsdir (icon);
+
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+ if (pixbuf)
+ {
+ icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
+ gtk_icon_factory_add (app->priv->icon_factory, stock_id, icon_set);
+ g_object_unref (pixbuf);
+ }
+
+ g_free (path);
+ gtk_icon_source_free (icon_source);
}
/**
@@ -532,11 +534,11 @@ gtranslator_application_register_icon (GtranslatorApplication *app,
* Return value: the last dir where a file was opened in the GtkFileChooser
*/
const gchar *
-_gtranslator_application_get_last_dir (GtranslatorApplication *app)
+_gtranslator_application_get_last_dir (GtranslatorApplication * app)
{
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
- return app->priv->last_dir;
+ return app->priv->last_dir;
}
/**
@@ -546,18 +548,18 @@ _gtranslator_application_get_last_dir (GtranslatorApplication *app)
* GtkFileChooser.
*/
void
-_gtranslator_application_set_last_dir (GtranslatorApplication *app,
- const gchar *last_dir)
+_gtranslator_application_set_last_dir (GtranslatorApplication * app,
+ const gchar * last_dir)
{
- g_return_if_fail (GTR_IS_APPLICATION (app));
+ g_return_if_fail (GTR_IS_APPLICATION (app));
- app->priv->last_dir = g_strdup (last_dir);
+ app->priv->last_dir = g_strdup (last_dir);
}
GObject *
-gtranslator_application_get_translation_memory (GtranslatorApplication *app)
+gtranslator_application_get_translation_memory (GtranslatorApplication * app)
{
- g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
-
- return G_OBJECT (app->priv->tm);
+ g_return_val_if_fail (GTR_IS_APPLICATION (app), NULL);
+
+ return G_OBJECT (app->priv->tm);
}
diff --git a/src/application.h b/src/application.h
index face283..519045a 100644
--- a/src/application.h
+++ b/src/application.h
@@ -31,7 +31,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -41,80 +40,94 @@ G_BEGIN_DECLS
#define GTR_IS_APPLICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_APPLICATION))
#define GTR_IS_APPLICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_APPLICATION))
#define GTR_APPLICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_APPLIAPPLICATION, GtranslatorApplicationClass))
-
#define GTR_APP (gtranslator_application_get_default())
-
/* Private structure type */
-typedef struct _GtranslatorApplicationPrivate GtranslatorApplicationPrivate;
+typedef struct _GtranslatorApplicationPrivate GtranslatorApplicationPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorApplication GtranslatorApplication;
+typedef struct _GtranslatorApplication GtranslatorApplication;
struct _GtranslatorApplication
{
- GObject base_instance;
-
- /*< private > */
- GtranslatorApplicationPrivate *priv;
+ GObject base_instance;
+
+ /*< private > */
+ GtranslatorApplicationPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorApplicationClass GtranslatorApplicationClass;
+typedef struct _GtranslatorApplicationClass GtranslatorApplicationClass;
struct _GtranslatorApplicationClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_application_get_type (void) G_GNUC_CONST;
-GtranslatorApplication *gtranslator_application_get_default (void);
+GType
+gtranslator_application_get_type (void)
+ G_GNUC_CONST;
+ GtranslatorApplication *gtranslator_application_get_default (void);
+
+ void gtranslator_application_shutdown (GtranslatorApplication * app);
-void gtranslator_application_shutdown (GtranslatorApplication *app);
+ GList *gtranslator_application_get_views (GtranslatorApplication * app,
+ gboolean original,
+ gboolean translated);
-GList *gtranslator_application_get_views (GtranslatorApplication *app,
- gboolean original,
- gboolean translated);
+ GtranslatorWindow
+ *gtranslator_application_open_window (GtranslatorApplication * app);
-GtranslatorWindow *gtranslator_application_open_window (GtranslatorApplication *app);
+ GtranslatorWindow
+ *gtranslator_application_get_active_window (GtranslatorApplication *
+ app);
-GtranslatorWindow *gtranslator_application_get_active_window (GtranslatorApplication * app);
+ const GList *gtranslator_application_get_windows (GtranslatorApplication
+ * app);
-const GList *gtranslator_application_get_windows (GtranslatorApplication *app);
+ GtranslatorProfile
+ *gtranslator_application_get_active_profile (GtranslatorApplication *
+ app);
-GtranslatorProfile *gtranslator_application_get_active_profile (GtranslatorApplication *app);
+ void gtranslator_application_set_active_profile (GtranslatorApplication *
+ app,
+ GtranslatorProfile *
+ profile);
-void gtranslator_application_set_active_profile (GtranslatorApplication *app,
- GtranslatorProfile *profile);
+ GList *gtranslator_application_get_profiles (GtranslatorApplication *
+ app);
-GList *gtranslator_application_get_profiles (GtranslatorApplication *app);
+ void gtranslator_application_set_profiles (GtranslatorApplication * app,
+ GList * profiles);
-void gtranslator_application_set_profiles (GtranslatorApplication *app,
- GList *profiles);
+ void gtranslator_application_register_icon (GtranslatorApplication * app,
+ const gchar * icon,
+ const gchar * stock_id);
-void gtranslator_application_register_icon (GtranslatorApplication *app,
- const gchar *icon,
- const gchar *stock_id);
-
-GObject *gtranslator_application_get_translation_memory (GtranslatorApplication *app);
+ GObject
+ *gtranslator_application_get_translation_memory (GtranslatorApplication
+ * app);
/* Non exported funcs */
-GObject *_gtranslator_application_get_toolbars_model (GtranslatorApplication *application);
+ GObject
+ *_gtranslator_application_get_toolbars_model (GtranslatorApplication *
+ application);
-void _gtranslator_application_save_toolbars_model (GtranslatorApplication *application);
+ void _gtranslator_application_save_toolbars_model (GtranslatorApplication
+ * application);
-const gchar * _gtranslator_application_get_last_dir (GtranslatorApplication *app);
+ const gchar
+ *_gtranslator_application_get_last_dir (GtranslatorApplication * app);
-void _gtranslator_application_set_last_dir (GtranslatorApplication *app,
- const gchar *last_dir);
+ void _gtranslator_application_set_last_dir (GtranslatorApplication * app,
+ const gchar * last_dir);
G_END_DECLS
-
#endif /* __APPLICATION_H__ */
diff --git a/src/context.c b/src/context.c
index e2dc744..b78323d 100644
--- a/src/context.c
+++ b/src/context.c
@@ -32,102 +32,104 @@
GTR_TYPE_CONTEXT_PANEL, \
GtranslatorContextPanelPrivate))
-G_DEFINE_TYPE(GtranslatorContextPanel, gtranslator_context_panel, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (GtranslatorContextPanel, gtranslator_context_panel,
+ GTK_TYPE_VBOX)
+ struct _GtranslatorContextPanelPrivate
+ {
+ GtkWidget *context;
+
+ GtranslatorTab *tab;
+ };
+
+ static void
+ showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg,
+ GtranslatorContextPanel * panel)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+ gchar *extracted;
+ gchar *context;
+ gchar *format;
+ gchar *toset;
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
+ gtk_text_buffer_set_text (buffer, "", 0);
+ gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
-struct _GtranslatorContextPanelPrivate
-{
- GtkWidget *context;
+ format = g_strconcat (_("Format:"), gtranslator_msg_get_format (msg), NULL);
+ context =
+ g_strconcat (_("Context:"), gtranslator_msg_get_msgctxt (msg), NULL);
+ extracted =
+ g_strconcat (_("Extracted comments:"),
+ gtranslator_msg_get_extracted_comments (msg), NULL);
- GtranslatorTab *tab;
-};
+ toset = g_strdup_printf ("%s\n%s\n%s", format, context, extracted);
-static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorContextPanel *panel)
-{
- GtkTextBuffer *buffer;
- GtkTextIter iter;
- gchar *extracted;
- gchar *context;
- gchar *format;
- gchar *toset;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
- gtk_text_buffer_set_text (buffer, "", 0);
- gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
-
- format = g_strconcat (_("Format:"), gtranslator_msg_get_format (msg), NULL);
- context = g_strconcat (_("Context:"), gtranslator_msg_get_msgctxt (msg), NULL);
- extracted = g_strconcat (_("Extracted comments:"),
- gtranslator_msg_get_extracted_comments(msg), NULL);
-
- toset = g_strdup_printf("%s\n%s\n%s", format, context, extracted);
-
- g_free (format);
- g_free (context);
- g_free (extracted);
-
- gtk_text_buffer_insert (buffer, &iter, toset, -1);
-
- g_free (toset);
+ g_free (format);
+ g_free (context);
+ g_free (extracted);
+
+ gtk_text_buffer_insert (buffer, &iter, toset, -1);
+
+ g_free (toset);
}
static void
-gtranslator_context_panel_draw (GtranslatorContextPanel *panel)
+gtranslator_context_panel_draw (GtranslatorContextPanel * panel)
{
- GtranslatorContextPanelPrivate *priv = panel->priv;
- GtkWidget *context_scrolled_window;
-
- /*
- * Set up the scrolling window for the extracted context display
- */
- context_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (context_scrolled_window),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (context_scrolled_window),
- GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (panel), context_scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show (context_scrolled_window);
-
- /*
- * Context
- */
- priv->context = gtk_text_view_new();
-
- gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->context), FALSE);
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->context),
- GTK_WRAP_WORD);
- gtk_container_add (GTK_CONTAINER (context_scrolled_window),
- GTK_WIDGET (priv->context));
- gtk_widget_show (priv->context);
+ GtranslatorContextPanelPrivate *priv = panel->priv;
+ GtkWidget *context_scrolled_window;
+
+ /*
+ * Set up the scrolling window for the extracted context display
+ */
+ context_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
+ (context_scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
+ (context_scrolled_window),
+ GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (panel), context_scrolled_window, TRUE, TRUE,
+ 0);
+ gtk_widget_show (context_scrolled_window);
+
+ /*
+ * Context
+ */
+ priv->context = gtk_text_view_new ();
+
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->context), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->context), GTK_WRAP_WORD);
+ gtk_container_add (GTK_CONTAINER (context_scrolled_window),
+ GTK_WIDGET (priv->context));
+ gtk_widget_show (priv->context);
}
static void
-gtranslator_context_panel_init (GtranslatorContextPanel *panel)
+gtranslator_context_panel_init (GtranslatorContextPanel * panel)
{
- panel->priv = GTR_CONTEXT_PANEL_GET_PRIVATE (panel);
-
- gtranslator_context_panel_draw (panel);
+ panel->priv = GTR_CONTEXT_PANEL_GET_PRIVATE (panel);
+
+ gtranslator_context_panel_draw (panel);
}
static void
-gtranslator_context_panel_finalize (GObject *object)
+gtranslator_context_panel_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_context_panel_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_context_panel_parent_class)->finalize (object);
}
static void
-gtranslator_context_panel_class_init (GtranslatorContextPanelClass *klass)
+gtranslator_context_panel_class_init (GtranslatorContextPanelClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorContextPanelPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorContextPanelPrivate));
- object_class->finalize = gtranslator_context_panel_finalize;
+ object_class->finalize = gtranslator_context_panel_finalize;
}
/**
@@ -139,18 +141,17 @@ gtranslator_context_panel_class_init (GtranslatorContextPanelClass *klass)
* Returns: a new #GtranslatorContextPanel object
*/
GtkWidget *
-gtranslator_context_panel_new (GtkWidget *tab)
+gtranslator_context_panel_new (GtkWidget * tab)
{
- GtranslatorContextPanel *context;
- context = g_object_new (GTR_TYPE_CONTEXT_PANEL, NULL);
-
- context->priv->tab = GTR_TAB (tab);
- g_signal_connect (tab,
- "showed-message",
- G_CALLBACK (showed_message_cb),
- context);
-
- return GTK_WIDGET (context);
+ GtranslatorContextPanel *context;
+ context = g_object_new (GTR_TYPE_CONTEXT_PANEL, NULL);
+
+ context->priv->tab = GTR_TAB (tab);
+ g_signal_connect (tab,
+ "showed-message",
+ G_CALLBACK (showed_message_cb), context);
+
+ return GTK_WIDGET (context);
}
/**
@@ -160,10 +161,10 @@ gtranslator_context_panel_new (GtkWidget *tab)
* Returns: the context #GtkTextView
*/
GtkTextView *
-gtranslator_context_panel_get_context_text_view (GtranslatorContextPanel *panel)
+gtranslator_context_panel_get_context_text_view (GtranslatorContextPanel *
+ panel)
{
- g_return_val_if_fail (GTR_IS_CONTEXT_PANEL (panel), NULL);
-
- return GTK_TEXT_VIEW (panel->priv->context);
+ g_return_val_if_fail (GTR_IS_CONTEXT_PANEL (panel), NULL);
+
+ return GTK_TEXT_VIEW (panel->priv->context);
}
-
diff --git a/src/context.h b/src/context.h
index e3be0ad..155c436 100644
--- a/src/context.h
+++ b/src/context.h
@@ -23,7 +23,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -33,44 +32,46 @@ G_BEGIN_DECLS
#define GTR_IS_CONTEXT_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CONTEXT_PANEL))
#define GTR_IS_CONTEXT_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CONTEXT_PANEL))
#define GTR_CONTEXT_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CONTEXT_PANEL, GtranslatorContextPanelClass))
-
/* Private structure type */
-typedef struct _GtranslatorContextPanelPrivate GtranslatorContextPanelPrivate;
+typedef struct _GtranslatorContextPanelPrivate GtranslatorContextPanelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorContextPanel GtranslatorContextPanel;
+typedef struct _GtranslatorContextPanel GtranslatorContextPanel;
struct _GtranslatorContextPanel
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorContextPanelPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorContextPanelPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorContextPanelClass GtranslatorContextPanelClass;
+typedef struct _GtranslatorContextPanelClass GtranslatorContextPanelClass;
struct _GtranslatorContextPanelClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_context_panel_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_context_panel_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_context_panel_register_type (GTypeModule * module);
+ GType gtranslator_context_panel_register_type (GTypeModule * module);
-GtkWidget *gtranslator_context_panel_new (GtkWidget *tab);
-
-GtkTextView *gtranslator_context_panel_get_context_text_view (GtranslatorContextPanel *panel);
+ GtkWidget *gtranslator_context_panel_new (GtkWidget * tab);
-G_END_DECLS
+ GtkTextView
+ *gtranslator_context_panel_get_context_text_view
+ (GtranslatorContextPanel * panel);
+G_END_DECLS
#endif /* __CONTEXT_PANEL_H__ */
diff --git a/src/debug.h b/src/debug.h
index 773a2e3..fb25611 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -21,27 +21,23 @@
* @short_description: Debug functions
* @include: gtranslator/debug.h
*/
-
+
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <glib.h>
G_BEGIN_DECLS
-
/**
* DEBUG_PRINT:
*
* Equivalent to g_message(), except it has only effect when DEBUG is
* defined. Used for printing debug messages.
*/
-
#ifdef DEBUG
# define DEBUG_PRINT g_message
#else
# define DEBUG_PRINT(...)
#endif
-
-G_END_DECLS
-
+ G_END_DECLS
#endif /* __DEBUG_H__ */
diff --git a/src/dialogs/assistant.c b/src/dialogs/assistant.c
index 5d3fb47..31d3bdd 100644
--- a/src/dialogs/assistant.c
+++ b/src/dialogs/assistant.c
@@ -45,798 +45,820 @@
GtranslatorAssistantPrivate))
-G_DEFINE_TYPE(GtranslatorAssistant, gtranslator_assistant, GTK_TYPE_ASSISTANT)
-
-struct _GtranslatorAssistantPrivate
-{
- /* Profiles Page 1 */
- GtkWidget *profile_name;
- GtkWidget *name;
- GtkWidget *email;
- GtkWidget *language;
- GtkWidget *team_email;
-
- /* Profiles Page 2 */
- GtkWidget *lang_code;
- GtkWidget *charset;
- GtkWidget *trans_enc;
- GtkWidget *plural_form;
-
- /* Database Page */
- GtkWidget *path;
- GtkWidget *search_button;
- GtkWidget *po_name;
-
- /* Confirmation Page */
- GtkWidget *finish_box;
- GtkWidget *confirm_label;
- GtkWidget *add_db_progressbar;
-};
-
-typedef struct _IdleData
-{
- GSList *list;
- GtkProgressBar *progress;
- GtranslatorTranslationMemory *tm;
- GtkWindow *parent;
-}IdleData;
-
-static gboolean
-add_to_database (gpointer data_pointer)
+G_DEFINE_TYPE (GtranslatorAssistant, gtranslator_assistant,
+ GTK_TYPE_ASSISTANT)
+ struct _GtranslatorAssistantPrivate
+ {
+ /* Profiles Page 1 */
+ GtkWidget *profile_name;
+ GtkWidget *name;
+ GtkWidget *email;
+ GtkWidget *language;
+ GtkWidget *team_email;
+
+ /* Profiles Page 2 */
+ GtkWidget *lang_code;
+ GtkWidget *charset;
+ GtkWidget *trans_enc;
+ GtkWidget *plural_form;
+
+ /* Database Page */
+ GtkWidget *path;
+ GtkWidget *search_button;
+ GtkWidget *po_name;
+
+ /* Confirmation Page */
+ GtkWidget *finish_box;
+ GtkWidget *confirm_label;
+ GtkWidget *add_db_progressbar;
+ };
+
+ typedef struct _IdleData
+ {
+ GSList *list;
+ GtkProgressBar *progress;
+ GtranslatorTranslationMemory *tm;
+ GtkWindow *parent;
+ } IdleData;
+
+ static gboolean add_to_database (gpointer data_pointer)
{
- IdleData *data = (IdleData *)data_pointer;
- static GSList *l = NULL;
- gdouble percentage;
-
- if (l == NULL)
- l = data->list;
- else
- l = g_slist_next (l);
-
- if (l)
- {
- GList *msg_list = NULL;
- GList *l2 = NULL;
- GFile *location;
- GError *error = NULL;
- GtranslatorPo *po;
-
- po = gtranslator_po_new ();
- location = (GFile *)l->data;
-
- gtranslator_po_parse (po, location, &error);
- if (error)
- return TRUE;
-
- msg_list = gtranslator_po_get_messages (po);
-
- for (l2 = msg_list; l2; l2 = g_list_next (l2))
- {
- GtranslatorMsg *msg;
-
- msg = GTR_MSG (l2->data);
- if (gtranslator_msg_is_translated (msg))
- gtranslator_translation_memory_store (data->tm,
- gtranslator_msg_get_msgid (msg),
- gtranslator_msg_get_msgstr (msg));
- }
-
- g_object_unref (po);
- }
- else
- {
- GtkWidget *dialog;
-
- gtk_progress_bar_set_fraction (data->progress,
- 1.0);
-
- dialog = gtk_message_dialog_new (data->parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- NULL);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
- }
-
- percentage = (gdouble)g_slist_position (data->list, l) / (gdouble) g_slist_length (data->list);
+ IdleData *data = (IdleData *) data_pointer;
+ static GSList *l = NULL;
+ gdouble percentage;
+
+ if (l == NULL)
+ l = data->list;
+ else
+ l = g_slist_next (l);
+
+ if (l)
+ {
+ GList *msg_list = NULL;
+ GList *l2 = NULL;
+ GFile *location;
+ GError *error = NULL;
+ GtranslatorPo *po;
+
+ po = gtranslator_po_new ();
+ location = (GFile *) l->data;
+
+ gtranslator_po_parse (po, location, &error);
+ if (error)
+ return TRUE;
+
+ msg_list = gtranslator_po_get_messages (po);
- /*
- * Set the progress only if the values are reasonable.
- */
- if(percentage > 0.0 || percentage < 1.0)
+ for (l2 = msg_list; l2; l2 = g_list_next (l2))
{
- /*
- * Set the progressbar status.
- */
- gtk_progress_bar_set_fraction (data->progress,
- percentage);
+ GtranslatorMsg *msg;
+
+ msg = GTR_MSG (l2->data);
+ if (gtranslator_msg_is_translated (msg))
+ gtranslator_translation_memory_store (data->tm,
+ gtranslator_msg_get_msgid
+ (msg),
+ gtranslator_msg_get_msgstr
+ (msg));
}
-
- return TRUE;
+
+ g_object_unref (po);
+ }
+ else
+ {
+ GtkWidget *dialog;
+
+ gtk_progress_bar_set_fraction (data->progress, 1.0);
+
+ dialog = gtk_message_dialog_new (data->parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return FALSE;
+ }
+
+ percentage =
+ (gdouble) g_slist_position (data->list,
+ l) / (gdouble) g_slist_length (data->list);
+
+ /*
+ * Set the progress only if the values are reasonable.
+ */
+ if (percentage > 0.0 || percentage < 1.0)
+ {
+ /*
+ * Set the progressbar status.
+ */
+ gtk_progress_bar_set_fraction (data->progress, percentage);
+ }
+
+ return TRUE;
}
static void
destroy_idle_data (gpointer data)
{
- IdleData *d = (IdleData *)data;
-
- gtk_widget_hide (GTK_WIDGET (d->progress));
-
- g_slist_foreach (d->list, (GFunc)g_object_unref, NULL);
- g_slist_free (d->list);
-
- gtk_widget_destroy (GTK_WIDGET (d->parent));
-
- g_free (d);
+ IdleData *d = (IdleData *) data;
+
+ gtk_widget_hide (GTK_WIDGET (d->progress));
+
+ g_slist_foreach (d->list, (GFunc) g_object_unref, NULL);
+ g_slist_free (d->list);
+
+ gtk_widget_destroy (GTK_WIDGET (d->parent));
+
+ g_free (d);
}
static void
-on_assistant_close (GtkAssistant *assistant)
+on_assistant_close (GtkAssistant * assistant)
{
gtk_widget_destroy (GTK_WIDGET (assistant));
}
static void
-on_assistant_apply (GtkAssistant *assistant)
+on_assistant_apply (GtkAssistant * assistant)
{
- GFile *dir;
- const gchar *dir_name;
- IdleData *data;
- GtranslatorAssistant *as = GTR_ASSISTANT (assistant);
- const gchar *po_name;
- GtranslatorProfile *profile;
- GList *profiles_list;
- gulong close_signal_id;
-
- profile = gtranslator_profile_new ();
-
- gtranslator_profile_set_name (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->profile_name)));
-
- gtranslator_profile_set_author_name (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->name)));
-
- gtranslator_profile_set_author_email (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->email)));
-
- gtranslator_profile_set_language_name (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->language)));
-
- gtranslator_profile_set_language_code (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->lang_code)));
-
- gtranslator_profile_set_group_email (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->team_email)));
-
- gtranslator_profile_set_charset (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->charset)));
-
- gtranslator_profile_set_encoding (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->trans_enc)));
-
- gtranslator_profile_set_plurals (profile,
- gtk_entry_get_text (GTK_ENTRY (as->priv->plural_form)));
-
- gtranslator_application_set_active_profile (GTR_APP, profile);
-
- profiles_list = gtranslator_application_get_profiles (GTR_APP);
-
- gtranslator_application_set_profiles (GTR_APP,
- g_list_append (profiles_list, profile));
-
- close_signal_id = g_signal_connect (as,
- "close",
- G_CALLBACK (on_assistant_close),
- NULL);
-
- dir_name = gtk_entry_get_text (GTK_ENTRY (as->priv->path));
- if (strcmp (dir_name, "") == 0)
- return;
-
- g_signal_handler_block (as, close_signal_id);
-
- data = g_new0 (IdleData, 1);
- data->list = NULL;
-
- dir = g_file_new_for_path (dir_name);
-
- po_name = gtk_entry_get_text (GTK_ENTRY (as->priv->po_name));
-
- gtranslator_utils_scan_dir (dir, &data->list, po_name);
-
- data->tm = GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory (GTR_APP));
- data->progress = GTK_PROGRESS_BAR (as->priv->add_db_progressbar);
- data->parent = GTK_WINDOW (as);
-
- gtk_widget_show (as->priv->add_db_progressbar);
-
- g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
- (GSourceFunc)add_to_database,
- data,
- (GDestroyNotify)destroy_idle_data);
-
- g_object_unref (dir);
+ GFile *dir;
+ const gchar *dir_name;
+ IdleData *data;
+ GtranslatorAssistant *as = GTR_ASSISTANT (assistant);
+ const gchar *po_name;
+ GtranslatorProfile *profile;
+ GList *profiles_list;
+ gulong close_signal_id;
+
+ profile = gtranslator_profile_new ();
+
+ gtranslator_profile_set_name (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ profile_name)));
+
+ gtranslator_profile_set_author_name (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->name)));
+
+ gtranslator_profile_set_author_email (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ email)));
+
+ gtranslator_profile_set_language_name (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ language)));
+
+ gtranslator_profile_set_language_code (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ lang_code)));
+
+ gtranslator_profile_set_group_email (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ team_email)));
+
+ gtranslator_profile_set_charset (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->charset)));
+
+ gtranslator_profile_set_encoding (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ trans_enc)));
+
+ gtranslator_profile_set_plurals (profile,
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->
+ plural_form)));
+
+ gtranslator_application_set_active_profile (GTR_APP, profile);
+
+ profiles_list = gtranslator_application_get_profiles (GTR_APP);
+
+ gtranslator_application_set_profiles (GTR_APP,
+ g_list_append (profiles_list,
+ profile));
+
+ close_signal_id = g_signal_connect (as,
+ "close",
+ G_CALLBACK (on_assistant_close), NULL);
+
+ dir_name = gtk_entry_get_text (GTK_ENTRY (as->priv->path));
+ if (strcmp (dir_name, "") == 0)
+ return;
+
+ g_signal_handler_block (as, close_signal_id);
+
+ data = g_new0 (IdleData, 1);
+ data->list = NULL;
+
+ dir = g_file_new_for_path (dir_name);
+
+ po_name = gtk_entry_get_text (GTK_ENTRY (as->priv->po_name));
+
+ gtranslator_utils_scan_dir (dir, &data->list, po_name);
+
+ data->tm =
+ GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory
+ (GTR_APP));
+ data->progress = GTK_PROGRESS_BAR (as->priv->add_db_progressbar);
+ data->parent = GTK_WINDOW (as);
+
+ gtk_widget_show (as->priv->add_db_progressbar);
+
+ g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
+ (GSourceFunc) add_to_database,
+ data, (GDestroyNotify) destroy_idle_data);
+
+ g_object_unref (dir);
}
static void
-on_assistant_prepare (GtkAssistant *assistant,
- GtkWidget *page)
+on_assistant_prepare (GtkAssistant * assistant, GtkWidget * page)
{
- GtranslatorAssistant *as = GTR_ASSISTANT (assistant);
- gchar *string;
- const gchar *database_path;
-
- if (page != as->priv->finish_box)
- return;
-
- database_path = gtk_entry_get_text (GTK_ENTRY (as->priv->path));
-
- string = g_strdup_printf (_("Profile name: %s\n"
- "Translator name: %s\n"
- "Translator email: %s\n"
- "Language name: %s\n"
- "Team email: %s\n"
- "Language code: %s\n"
- "Character set: %s\n"
- "Transfer encoding: %s\n"
- "Plural form: %s\n"
- "Database path: %s"),
- gtk_entry_get_text (GTK_ENTRY (as->priv->profile_name)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->name)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->email)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->language)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->team_email)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->lang_code)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->charset)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->trans_enc)),
- gtk_entry_get_text (GTK_ENTRY (as->priv->plural_form)),
- (strcmp (database_path, "") != 0) ? database_path : _("None"));
-
- gtk_label_set_text (GTK_LABEL (as->priv->confirm_label), string);
- g_free (string);
+ GtranslatorAssistant *as = GTR_ASSISTANT (assistant);
+ gchar *string;
+ const gchar *database_path;
+
+ if (page != as->priv->finish_box)
+ return;
+
+ database_path = gtk_entry_get_text (GTK_ENTRY (as->priv->path));
+
+ string = g_strdup_printf (_("Profile name: %s\n"
+ "Translator name: %s\n"
+ "Translator email: %s\n"
+ "Language name: %s\n"
+ "Team email: %s\n"
+ "Language code: %s\n"
+ "Character set: %s\n"
+ "Transfer encoding: %s\n"
+ "Plural form: %s\n"
+ "Database path: %s"),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->profile_name)),
+ gtk_entry_get_text (GTK_ENTRY (as->priv->name)),
+ gtk_entry_get_text (GTK_ENTRY (as->priv->email)),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->language)),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->team_email)),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->lang_code)),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->charset)),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->trans_enc)),
+ gtk_entry_get_text (GTK_ENTRY
+ (as->priv->plural_form)),
+ (strcmp (database_path, "") !=
+ 0) ? database_path : _("None"));
+
+ gtk_label_set_text (GTK_LABEL (as->priv->confirm_label), string);
+ g_free (string);
}
static void
-on_assistant_cancel (GtkAssistant* assistant)
+on_assistant_cancel (GtkAssistant * assistant)
{
- gtk_widget_destroy (GTK_WIDGET (assistant));
+ gtk_widget_destroy (GTK_WIDGET (assistant));
}
static void
-create_start_page (GtranslatorAssistant *as)
+create_start_page (GtranslatorAssistant * as)
{
- GtkWidget *box, *label;
-
- box = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (box);
- gtk_container_set_border_width (GTK_CONTAINER (box), 12);
-
- label = gtk_label_new (_("This assistant will help you to create the main profile\n"
- "and generate your translation memory database."));
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
-
- gtk_assistant_append_page (GTK_ASSISTANT (as), box);
- gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Assistant"));
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), box, TRUE);
- gtk_assistant_set_page_type (GTK_ASSISTANT (as), box, GTK_ASSISTANT_PAGE_INTRO);
+ GtkWidget *box, *label;
+
+ box = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (box);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 12);
+
+ label =
+ gtk_label_new (_
+ ("This assistant will help you to create the main profile\n"
+ "and generate your translation memory database."));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), box);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Assistant"));
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), box, TRUE);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (as), box,
+ GTK_ASSISTANT_PAGE_INTRO);
}
static void
-on_profile1_entry_changed (GtkWidget *widget,
- GtranslatorAssistant *as)
+on_profile1_entry_changed (GtkWidget * widget, GtranslatorAssistant * as)
{
- const gchar *text;
- GtkWidget *current_page;
- gint page_number;
-
- page_number = gtk_assistant_get_current_page (GTK_ASSISTANT (as));
- current_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (as), page_number);
-
- /* Profile name */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->profile_name));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Translator name */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->name));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Translator email */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->email));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Language */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->language));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Team email */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->team_email));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
+ const gchar *text;
+ GtkWidget *current_page;
+ gint page_number;
+
+ page_number = gtk_assistant_get_current_page (GTK_ASSISTANT (as));
+ current_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (as), page_number);
+
+ /* Profile name */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->profile_name));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Translator name */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->name));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Translator email */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->email));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Language */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->language));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Team email */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->team_email));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
}
static void
-create_profiles_page1 (GtranslatorAssistant *as)
+create_profiles_page1 (GtranslatorAssistant * as)
{
- GtkWidget *box, *hbox;
- GtkWidget *label;
- GtranslatorAssistantPrivate *priv = as->priv;
-
- box = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (box);
- gtk_container_set_border_width (GTK_CONTAINER (box), 5);
-
- /*
- * Profile name:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Profile name:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->profile_name = gtk_entry_new ();
- gtk_widget_show (priv->profile_name);
- gtk_box_pack_start (GTK_BOX (hbox), priv->profile_name, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->profile_name), "changed",
- G_CALLBACK (on_profile1_entry_changed), as);
-
- /*
- * Translator name:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Translator name:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->name = gtk_entry_new ();
- gtk_widget_show (priv->name);
- gtk_box_pack_start (GTK_BOX (hbox), priv->name, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->name), "changed",
- G_CALLBACK (on_profile1_entry_changed), as);
-
- /*
- * Translator email:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Translator email:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->email = gtk_entry_new ();
- gtk_widget_show (priv->email);
- gtk_box_pack_start (GTK_BOX (hbox), priv->email, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->email), "changed",
- G_CALLBACK (on_profile1_entry_changed), as);
-
- /*
- * Translator language:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Language:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->language = gtk_entry_new ();
- gtk_widget_show (priv->language);
- gtk_box_pack_start (GTK_BOX (hbox), priv->language, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->language), "changed",
- G_CALLBACK (on_profile1_entry_changed), as);
-
- /*
- * Translator team email:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Team email:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->team_email = gtk_entry_new ();
- gtk_widget_show (priv->team_email);
- gtk_box_pack_start (GTK_BOX (hbox), priv->team_email, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->team_email), "changed",
- G_CALLBACK (on_profile1_entry_changed), as);
-
- gtk_assistant_append_page (GTK_ASSISTANT (as), box);
- gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Profile"));
+ GtkWidget *box, *hbox;
+ GtkWidget *label;
+ GtranslatorAssistantPrivate *priv = as->priv;
+
+ box = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (box);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 5);
+
+ /*
+ * Profile name:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Profile name:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->profile_name = gtk_entry_new ();
+ gtk_widget_show (priv->profile_name);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->profile_name, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->profile_name), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ /*
+ * Translator name:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Translator name:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->name = gtk_entry_new ();
+ gtk_widget_show (priv->name);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->name, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->name), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ /*
+ * Translator email:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Translator email:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->email = gtk_entry_new ();
+ gtk_widget_show (priv->email);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->email, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->email), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ /*
+ * Translator language:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Language:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->language = gtk_entry_new ();
+ gtk_widget_show (priv->language);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->language, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->language), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ /*
+ * Translator team email:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Team email:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->team_email = gtk_entry_new ();
+ gtk_widget_show (priv->team_email);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->team_email, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->team_email), "changed",
+ G_CALLBACK (on_profile1_entry_changed), as);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), box);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Profile"));
}
static void
-on_profile2_entry_changed (GtkWidget *widget,
- GtranslatorAssistant *as)
+on_profile2_entry_changed (GtkWidget * widget, GtranslatorAssistant * as)
{
- const gchar *text;
- GtkWidget *current_page;
- gint page_number;
-
- page_number = gtk_assistant_get_current_page (GTK_ASSISTANT (as));
- current_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (as), page_number);
-
- /* Lang code */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->lang_code));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Charset */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->charset));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Trans encoding */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->trans_enc));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- {
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
- return;
- }
-
- /* Plural form */
- text = gtk_entry_get_text (GTK_ENTRY (as->priv->plural_form));
-
- if (text && *text)
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
- else
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
+ const gchar *text;
+ GtkWidget *current_page;
+ gint page_number;
+
+ page_number = gtk_assistant_get_current_page (GTK_ASSISTANT (as));
+ current_page = gtk_assistant_get_nth_page (GTK_ASSISTANT (as), page_number);
+
+ /* Lang code */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->lang_code));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Charset */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->charset));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Trans encoding */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->trans_enc));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ {
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page,
+ FALSE);
+ return;
+ }
+
+ /* Plural form */
+ text = gtk_entry_get_text (GTK_ENTRY (as->priv->plural_form));
+
+ if (text && *text)
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, TRUE);
+ else
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), current_page, FALSE);
}
static void
-create_profiles_page2 (GtranslatorAssistant *as)
+create_profiles_page2 (GtranslatorAssistant * as)
{
- GtkWidget *box, *hbox;
- GtkWidget *label;
- GtranslatorAssistantPrivate *priv = as->priv;
-
- box = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (box);
- gtk_container_set_border_width (GTK_CONTAINER (box), 5);
-
- /*
- * Language code:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Language code:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->lang_code = gtk_entry_new ();
- gtk_widget_show (priv->lang_code);
- gtk_box_pack_start (GTK_BOX (hbox), priv->lang_code, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->lang_code), "changed",
- G_CALLBACK (on_profile2_entry_changed), as);
-
- /*
- * Charset:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Character set:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->charset = gtk_entry_new ();
- gtk_widget_show (priv->charset);
- gtk_box_pack_start (GTK_BOX (hbox), priv->charset, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->charset), "changed",
- G_CALLBACK (on_profile2_entry_changed), as);
-
- /*
- * Transfer enconding:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Transfer encoding:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->trans_enc = gtk_entry_new ();
- gtk_widget_show (priv->trans_enc);
- gtk_box_pack_start (GTK_BOX (hbox), priv->trans_enc, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->trans_enc), "changed",
- G_CALLBACK (on_profile2_entry_changed), as);
-
- /*
- * Plural form:
- */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Plural forms:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- priv->plural_form = gtk_entry_new ();
- gtk_widget_show (priv->plural_form);
- gtk_box_pack_start (GTK_BOX (hbox), priv->plural_form, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->plural_form), "changed",
- G_CALLBACK (on_profile2_entry_changed), as);
-
- gtk_assistant_append_page (GTK_ASSISTANT (as), box);
- gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Profile"));
+ GtkWidget *box, *hbox;
+ GtkWidget *label;
+ GtranslatorAssistantPrivate *priv = as->priv;
+
+ box = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (box);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 5);
+
+ /*
+ * Language code:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Language code:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->lang_code = gtk_entry_new ();
+ gtk_widget_show (priv->lang_code);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->lang_code, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->lang_code), "changed",
+ G_CALLBACK (on_profile2_entry_changed), as);
+
+ /*
+ * Charset:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Character set:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->charset = gtk_entry_new ();
+ gtk_widget_show (priv->charset);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->charset, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->charset), "changed",
+ G_CALLBACK (on_profile2_entry_changed), as);
+
+ /*
+ * Transfer enconding:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Transfer encoding:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->trans_enc = gtk_entry_new ();
+ gtk_widget_show (priv->trans_enc);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->trans_enc, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->trans_enc), "changed",
+ G_CALLBACK (on_profile2_entry_changed), as);
+
+ /*
+ * Plural form:
+ */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), _("<b>Plural forms:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ priv->plural_form = gtk_entry_new ();
+ gtk_widget_show (priv->plural_form);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->plural_form, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (priv->plural_form), "changed",
+ G_CALLBACK (on_profile2_entry_changed), as);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), box);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Profile"));
}
static void
-on_dir_find_button_clicked (GtkButton *button,
- GtranslatorAssistant *as)
+on_dir_find_button_clicked (GtkButton * button, GtranslatorAssistant * as)
{
- GtkWidget *dialog;
- gint res;
-
- dialog = gtk_file_chooser_dialog_new (_("Checkout directory"),
- GTK_WINDOW (as),
- GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (res)
- {
- case GTK_RESPONSE_OK:
- {
- gchar *filename;
-
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- gtk_entry_set_text (GTK_ENTRY (as->priv->path),
- filename);
- g_free (filename);
- break;
- }
- default:
- break;
- }
- gtk_widget_destroy (dialog);
+ GtkWidget *dialog;
+ gint res;
+
+ dialog = gtk_file_chooser_dialog_new (_("Checkout directory"),
+ GTK_WINDOW (as),
+ GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ switch (res)
+ {
+ case GTK_RESPONSE_OK:
+ {
+ gchar *filename;
+
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ gtk_entry_set_text (GTK_ENTRY (as->priv->path), filename);
+ g_free (filename);
+ break;
+ }
+ default:
+ break;
+ }
+ gtk_widget_destroy (dialog);
}
static void
-create_database_page (GtranslatorAssistant *as)
+create_database_page (GtranslatorAssistant * as)
{
- GtkWidget *box, *hbox;
- GtkWidget *label;
- GtranslatorAssistantPrivate *priv = as->priv;
-
- box = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (box);
- gtk_container_set_border_width (GTK_CONTAINER (box), 5);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Select the path to generate the database:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
-
- /* hbox */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- /* Path entry */
- priv->path = gtk_entry_new ();
- gtk_widget_show (priv->path);
- gtk_box_pack_start (GTK_BOX (hbox), priv->path, TRUE, TRUE, 0);
-
- /* Search button */
- priv->search_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
- gtk_widget_show (priv->search_button);
- gtk_box_pack_start (GTK_BOX (hbox), priv->search_button,
- FALSE, FALSE, 0);
- g_signal_connect (priv->search_button, "clicked",
- G_CALLBACK (on_dir_find_button_clicked), as);
-
- /* Po name label */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Look for a specific PO filename:</b>"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- /* Po name entry */
- priv->po_name = gtk_entry_new ();
- gtk_widget_show (priv->po_name);
- gtk_box_pack_start (GTK_BOX (hbox), priv->po_name, TRUE, TRUE, 0);
- gtk_widget_set_tooltip_text (priv->po_name, _("E.g.: gl.po"));
-
- gtk_assistant_append_page (GTK_ASSISTANT (as), box);
- gtk_assistant_set_page_title (GTK_ASSISTANT (as), box, _("Generate Database"));
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), box, TRUE);
+ GtkWidget *box, *hbox;
+ GtkWidget *label;
+ GtranslatorAssistantPrivate *priv = as->priv;
+
+ box = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (box);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 5);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label),
+ _
+ ("<b>Select the path to generate the database:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
+
+ /* hbox */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ /* Path entry */
+ priv->path = gtk_entry_new ();
+ gtk_widget_show (priv->path);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->path, TRUE, TRUE, 0);
+
+ /* Search button */
+ priv->search_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
+ gtk_widget_show (priv->search_button);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->search_button, FALSE, FALSE, 0);
+ g_signal_connect (priv->search_button, "clicked",
+ G_CALLBACK (on_dir_find_button_clicked), as);
+
+ /* Po name label */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label),
+ _("<b>Look for a specific PO filename:</b>"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ /* Po name entry */
+ priv->po_name = gtk_entry_new ();
+ gtk_widget_show (priv->po_name);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->po_name, TRUE, TRUE, 0);
+ gtk_widget_set_tooltip_text (priv->po_name, _("E.g.: gl.po"));
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), box);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), box,
+ _("Generate Database"));
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), box, TRUE);
}
static void
-create_finish_page (GtranslatorAssistant *as)
+create_finish_page (GtranslatorAssistant * as)
{
- as->priv->finish_box = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (as->priv->finish_box);
-
- as->priv->confirm_label = gtk_label_new (NULL);
- gtk_widget_show (as->priv->confirm_label);
- gtk_box_pack_start (GTK_BOX (as->priv->finish_box), as->priv->confirm_label,
- TRUE, TRUE, 0);
-
- as->priv->add_db_progressbar = gtk_progress_bar_new ();
- gtk_widget_show (as->priv->add_db_progressbar);
- gtk_box_pack_start (GTK_BOX (as->priv->finish_box), as->priv->add_db_progressbar,
- FALSE, FALSE, 0);
-
- gtk_assistant_append_page (GTK_ASSISTANT (as), as->priv->finish_box);
- gtk_assistant_set_page_type (GTK_ASSISTANT (as), as->priv->finish_box,
- GTK_ASSISTANT_PAGE_CONFIRM);
- gtk_assistant_set_page_complete (GTK_ASSISTANT (as), as->priv->finish_box, TRUE);
- gtk_assistant_set_page_title (GTK_ASSISTANT (as), as->priv->finish_box, _("Confirmation"));
+ as->priv->finish_box = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (as->priv->finish_box);
+
+ as->priv->confirm_label = gtk_label_new (NULL);
+ gtk_widget_show (as->priv->confirm_label);
+ gtk_box_pack_start (GTK_BOX (as->priv->finish_box), as->priv->confirm_label,
+ TRUE, TRUE, 0);
+
+ as->priv->add_db_progressbar = gtk_progress_bar_new ();
+ gtk_widget_show (as->priv->add_db_progressbar);
+ gtk_box_pack_start (GTK_BOX (as->priv->finish_box),
+ as->priv->add_db_progressbar, FALSE, FALSE, 0);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (as), as->priv->finish_box);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (as), as->priv->finish_box,
+ GTK_ASSISTANT_PAGE_CONFIRM);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (as), as->priv->finish_box,
+ TRUE);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (as), as->priv->finish_box,
+ _("Confirmation"));
}
static void
-gtranslator_assistant_init (GtranslatorAssistant *as)
-{
- as->priv = GTR_ASSISTANT_GET_PRIVATE (as);
-
- //gtk_window_set_default_size (GTK_WINDOW (as), 300, 200);
- gtk_window_set_resizable (GTK_WINDOW (as), TRUE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (as), TRUE);
-
- create_start_page (as);
- create_profiles_page1 (as);
- create_profiles_page2 (as);
- create_database_page (as);
- create_finish_page (as);
+gtranslator_assistant_init (GtranslatorAssistant * as)
+{
+ as->priv = GTR_ASSISTANT_GET_PRIVATE (as);
+
+ //gtk_window_set_default_size (GTK_WINDOW (as), 300, 200);
+ gtk_window_set_resizable (GTK_WINDOW (as), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (as), TRUE);
+
+ create_start_page (as);
+ create_profiles_page1 (as);
+ create_profiles_page2 (as);
+ create_database_page (as);
+ create_finish_page (as);
}
static void
-gtranslator_assistant_finalize (GObject *object)
+gtranslator_assistant_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_assistant_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_assistant_parent_class)->finalize (object);
}
static void
-gtranslator_assistant_class_init (GtranslatorAssistantClass *klass)
+gtranslator_assistant_class_init (GtranslatorAssistantClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkAssistantClass *assistant_class = GTK_ASSISTANT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkAssistantClass *assistant_class = GTK_ASSISTANT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorAssistantPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorAssistantPrivate));
- object_class->finalize = gtranslator_assistant_finalize;
- assistant_class->prepare = on_assistant_prepare;
- assistant_class->apply = on_assistant_apply;
- assistant_class->cancel = on_assistant_cancel;
- //assistant_class->close = on_assistant_close;
+ object_class->finalize = gtranslator_assistant_finalize;
+ assistant_class->prepare = on_assistant_prepare;
+ assistant_class->apply = on_assistant_apply;
+ assistant_class->cancel = on_assistant_cancel;
+ //assistant_class->close = on_assistant_close;
}
void
-gtranslator_show_assistant (GtranslatorWindow *window)
+gtranslator_show_assistant (GtranslatorWindow * window)
{
- static GtranslatorAssistant *assist = NULL;
-
- g_return_if_fail(GTR_IS_WINDOW(window));
-
- if(assist == NULL)
- {
- assist = g_object_new (GTR_TYPE_ASSISTANT, NULL);
- g_signal_connect (assist,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &assist);
+ static GtranslatorAssistant *assist = NULL;
- gtk_widget_show (GTK_WIDGET(assist));
- }
+ g_return_if_fail (GTR_IS_WINDOW (window));
- /*
- * Make asssitant modal preventing using application without profile
- */
- gtk_window_set_modal (GTK_WINDOW (assist), TRUE);
-
- if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (assist)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (assist),
- GTK_WINDOW (window));
- }
+ if (assist == NULL)
+ {
+ assist = g_object_new (GTR_TYPE_ASSISTANT, NULL);
+ g_signal_connect (assist,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &assist);
+
+ gtk_widget_show (GTK_WIDGET (assist));
+ }
+
+ /*
+ * Make asssitant modal preventing using application without profile
+ */
+ gtk_window_set_modal (GTK_WINDOW (assist), TRUE);
+
+ if (GTK_WINDOW (window) !=
+ gtk_window_get_transient_for (GTK_WINDOW (assist)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (assist), GTK_WINDOW (window));
+ }
- gtk_window_present (GTK_WINDOW (assist));
+ gtk_window_present (GTK_WINDOW (assist));
}
diff --git a/src/dialogs/assistant.h b/src/dialogs/assistant.h
index 63a8cc0..7d97d79 100644
--- a/src/dialogs/assistant.h
+++ b/src/dialogs/assistant.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,42 +34,42 @@ G_BEGIN_DECLS
#define GTR_IS_ASSISTANT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_ASSISTANT))
#define GTR_IS_ASSISTANT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_ASSISTANT))
#define GTR_ASSISTANT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_ASSISTANT, GtranslatorAssistantClass))
-
/* Private structure type */
-typedef struct _GtranslatorAssistantPrivate GtranslatorAssistantPrivate;
+typedef struct _GtranslatorAssistantPrivate GtranslatorAssistantPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorAssistant GtranslatorAssistant;
+typedef struct _GtranslatorAssistant GtranslatorAssistant;
struct _GtranslatorAssistant
{
- GtkAssistant parent_instance;
-
- /*< private > */
- GtranslatorAssistantPrivate *priv;
+ GtkAssistant parent_instance;
+
+ /*< private > */
+ GtranslatorAssistantPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorAssistantClass GtranslatorAssistantClass;
+typedef struct _GtranslatorAssistantClass GtranslatorAssistantClass;
struct _GtranslatorAssistantClass
{
- GtkAssistantClass parent_class;
+ GtkAssistantClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_assistant_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_assistant_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_assistant_register_type (GTypeModule * module);
+ GType gtranslator_assistant_register_type (GTypeModule * module);
-void gtranslator_show_assistant (GtranslatorWindow *window);
+ void gtranslator_show_assistant (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __ASSISTANT_H__ */
diff --git a/src/dialogs/close-confirmation-dialog.c b/src/dialogs/close-confirmation-dialog.c
index e301e17..8dd9e4a 100644
--- a/src/dialogs/close-confirmation-dialog.c
+++ b/src/dialogs/close-confirmation-dialog.c
@@ -35,40 +35,40 @@
/* Properties */
-enum
+enum
{
- PROP_0,
- PROP_UNSAVED_DOCUMENTS,
- PROP_LOGOUT_MODE
+ PROP_0,
+ PROP_UNSAVED_DOCUMENTS,
+ PROP_LOGOUT_MODE
};
/* Mode */
enum
{
- SINGLE_DOC_MODE,
- MULTIPLE_DOCS_MODE
+ SINGLE_DOC_MODE,
+ MULTIPLE_DOCS_MODE
};
/* Columns */
enum
{
- SAVE_COLUMN,
- NAME_COLUMN,
- DOC_COLUMN, /* a handy pointer to the document */
- N_COLUMNS
+ SAVE_COLUMN,
+ NAME_COLUMN,
+ DOC_COLUMN, /* a handy pointer to the document */
+ N_COLUMNS
};
-struct _GtranslatorCloseConfirmationDialogPrivate
+struct _GtranslatorCloseConfirmationDialogPrivate
{
- gboolean logout_mode;
+ gboolean logout_mode;
+
+ GList *unsaved_documents;
- GList *unsaved_documents;
-
- GList *selected_documents;
+ GList *selected_documents;
- GtkTreeModel *list_store;
-
- gboolean disable_save_to_disk;
+ GtkTreeModel *list_store;
+
+ gboolean disable_save_to_disk;
};
#define GTR_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
@@ -79,566 +79,562 @@ struct _GtranslatorCloseConfirmationDialogPrivate
(priv->unsaved_documents->next == NULL)) ? \
SINGLE_DOC_MODE : MULTIPLE_DOCS_MODE)
-G_DEFINE_TYPE(GtranslatorCloseConfirmationDialog, gtranslator_close_confirmation_dialog, GTK_TYPE_DIALOG)
-
-static void set_unsaved_document (GtranslatorCloseConfirmationDialog *dlg,
- const GList *list);
+G_DEFINE_TYPE (GtranslatorCloseConfirmationDialog,
+ gtranslator_close_confirmation_dialog, GTK_TYPE_DIALOG)
+ static void set_unsaved_document (GtranslatorCloseConfirmationDialog *
+ dlg, const GList * list);
-static GList *get_selected_docs (GtkTreeModel *store);
+ static GList *get_selected_docs (GtkTreeModel * store);
/* Since we connect in the costructor we are sure this handler will be called
* before the user ones
*/
-static void
-response_cb (GtranslatorCloseConfirmationDialog *dlg,
- gint response_id,
- gpointer data)
+ static void
+ response_cb (GtranslatorCloseConfirmationDialog * dlg,
+ gint response_id, gpointer data)
{
- GtranslatorCloseConfirmationDialogPrivate *priv;
+ GtranslatorCloseConfirmationDialogPrivate *priv;
+
+ g_return_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg));
- g_return_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg));
+ priv = dlg->priv;
- priv = dlg->priv;
-
- if (priv->selected_documents != NULL)
- g_list_free (priv->selected_documents);
+ if (priv->selected_documents != NULL)
+ g_list_free (priv->selected_documents);
- if (response_id == GTK_RESPONSE_YES)
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ if (GET_MODE (priv) == SINGLE_DOC_MODE)
{
- if (GET_MODE (priv) == SINGLE_DOC_MODE)
- {
- priv->selected_documents =
- g_list_copy (priv->unsaved_documents);
- }
- else
- {
- g_return_if_fail (priv->list_store);
-
- priv->selected_documents =
- get_selected_docs (priv->list_store);
- }
+ priv->selected_documents = g_list_copy (priv->unsaved_documents);
}
- else
- priv->selected_documents = NULL;
+ else
+ {
+ g_return_if_fail (priv->list_store);
+
+ priv->selected_documents = get_selected_docs (priv->list_store);
+ }
+ }
+ else
+ priv->selected_documents = NULL;
}
static void
-set_logout_mode (GtranslatorCloseConfirmationDialog *dlg,
+set_logout_mode (GtranslatorCloseConfirmationDialog * dlg,
gboolean logout_mode)
{
-
- gtk_dialog_add_button (GTK_DIALOG (dlg),
- _("Close _without Saving"),
- GTK_RESPONSE_NO);
-
- gtk_dialog_add_button (GTK_DIALOG (dlg),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (GTK_DIALOG (dlg),
- GTK_STOCK_SAVE,
- GTK_RESPONSE_YES);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dlg),
- GTK_RESPONSE_YES);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ _("Close _without Saving"), GTK_RESPONSE_NO);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (GTK_DIALOG (dlg), GTK_STOCK_SAVE, GTK_RESPONSE_YES);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_YES);
}
-static void
-gtranslator_close_confirmation_dialog_init (GtranslatorCloseConfirmationDialog *dlg)
+static void
+gtranslator_close_confirmation_dialog_init (GtranslatorCloseConfirmationDialog
+ * dlg)
{
- AtkObject *atk_obj;
-
- dlg->priv = GTR_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 14);
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dlg), TRUE);
-
- gtk_window_set_title (GTK_WINDOW (dlg), "");
-
- gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- atk_obj = gtk_widget_get_accessible (GTK_WIDGET (dlg));
- atk_object_set_role (atk_obj, ATK_ROLE_ALERT);
- atk_object_set_name (atk_obj, _("Question"));
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (response_cb),
- NULL);
+ AtkObject *atk_obj;
+
+ dlg->priv = GTR_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 14);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dlg), TRUE);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), "");
+
+ gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ atk_obj = gtk_widget_get_accessible (GTK_WIDGET (dlg));
+ atk_object_set_role (atk_obj, ATK_ROLE_ALERT);
+ atk_object_set_name (atk_obj, _("Question"));
+
+ g_signal_connect (dlg, "response", G_CALLBACK (response_cb), NULL);
}
-static void
-gtranslator_close_confirmation_dialog_finalize (GObject *object)
+static void
+gtranslator_close_confirmation_dialog_finalize (GObject * object)
{
- GtranslatorCloseConfirmationDialogPrivate *priv;
+ GtranslatorCloseConfirmationDialogPrivate *priv;
- priv = GTR_CLOSE_CONFIRMATION_DIALOG (object)->priv;
+ priv = GTR_CLOSE_CONFIRMATION_DIALOG (object)->priv;
- if (priv->unsaved_documents != NULL)
- g_list_free (priv->unsaved_documents);
+ if (priv->unsaved_documents != NULL)
+ g_list_free (priv->unsaved_documents);
- if (priv->selected_documents != NULL)
- g_list_free (priv->selected_documents);
+ if (priv->selected_documents != NULL)
+ g_list_free (priv->selected_documents);
- /* Call the parent's destructor */
- G_OBJECT_CLASS (gtranslator_close_confirmation_dialog_parent_class)->finalize (object);
+ /* Call the parent's destructor */
+ G_OBJECT_CLASS (gtranslator_close_confirmation_dialog_parent_class)->
+ finalize (object);
}
static void
-gtranslator_close_confirmation_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gtranslator_close_confirmation_dialog_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec)
{
- GtranslatorCloseConfirmationDialog *dlg;
+ GtranslatorCloseConfirmationDialog *dlg;
- dlg = GTR_CLOSE_CONFIRMATION_DIALOG (object);
+ dlg = GTR_CLOSE_CONFIRMATION_DIALOG (object);
- switch (prop_id)
- {
- case PROP_UNSAVED_DOCUMENTS:
- set_unsaved_document (dlg, g_value_get_pointer (value));
- break;
-
- case PROP_LOGOUT_MODE:
- set_logout_mode (dlg, g_value_get_boolean (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_UNSAVED_DOCUMENTS:
+ set_unsaved_document (dlg, g_value_get_pointer (value));
+ break;
+
+ case PROP_LOGOUT_MODE:
+ set_logout_mode (dlg, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gtranslator_close_confirmation_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gtranslator_close_confirmation_dialog_get_property (GObject * object,
+ guint prop_id,
+ GValue * value,
+ GParamSpec * pspec)
{
- GtranslatorCloseConfirmationDialogPrivate *priv;
+ GtranslatorCloseConfirmationDialogPrivate *priv;
- priv = GTR_CLOSE_CONFIRMATION_DIALOG (object)->priv;
+ priv = GTR_CLOSE_CONFIRMATION_DIALOG (object)->priv;
- switch( prop_id )
- {
- case PROP_UNSAVED_DOCUMENTS:
- g_value_set_pointer (value, priv->unsaved_documents);
- break;
+ switch (prop_id)
+ {
+ case PROP_UNSAVED_DOCUMENTS:
+ g_value_set_pointer (value, priv->unsaved_documents);
+ break;
- case PROP_LOGOUT_MODE:
- g_value_set_boolean (value, priv->logout_mode);
- break;
+ case PROP_LOGOUT_MODE:
+ g_value_set_boolean (value, priv->logout_mode);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static void
-gtranslator_close_confirmation_dialog_class_init (GtranslatorCloseConfirmationDialogClass *klass)
+static void
+gtranslator_close_confirmation_dialog_class_init
+ (GtranslatorCloseConfirmationDialogClass * klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = gtranslator_close_confirmation_dialog_set_property;
- gobject_class->get_property = gtranslator_close_confirmation_dialog_get_property;
- gobject_class->finalize = gtranslator_close_confirmation_dialog_finalize;
-
- g_type_class_add_private (klass, sizeof (GtranslatorCloseConfirmationDialogPrivate));
-
- g_object_class_install_property (gobject_class,
- PROP_UNSAVED_DOCUMENTS,
- g_param_spec_pointer ("unsaved_documents",
- "Unsaved Documents",
- "List of Unsaved Documents",
- (G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY)));
-
- g_object_class_install_property (gobject_class,
- PROP_LOGOUT_MODE,
- g_param_spec_boolean ("logout_mode",
- "Logout Mode",
- "Whether the dialog is in logout mode",
- FALSE,
- (G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY)));
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->set_property =
+ gtranslator_close_confirmation_dialog_set_property;
+ gobject_class->get_property =
+ gtranslator_close_confirmation_dialog_get_property;
+ gobject_class->finalize = gtranslator_close_confirmation_dialog_finalize;
+
+ g_type_class_add_private (klass,
+ sizeof
+ (GtranslatorCloseConfirmationDialogPrivate));
+
+ g_object_class_install_property (gobject_class,
+ PROP_UNSAVED_DOCUMENTS,
+ g_param_spec_pointer ("unsaved_documents",
+ "Unsaved Documents",
+ "List of Unsaved Documents",
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY)));
+
+ g_object_class_install_property (gobject_class,
+ PROP_LOGOUT_MODE,
+ g_param_spec_boolean ("logout_mode",
+ "Logout Mode",
+ "Whether the dialog is in logout mode",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY)));
}
static GList *
-get_selected_docs (GtkTreeModel *store)
+get_selected_docs (GtkTreeModel * store)
{
- GList *list;
- gboolean valid;
- GtkTreeIter iter;
+ GList *list;
+ gboolean valid;
+ GtkTreeIter iter;
- list = NULL;
- valid = gtk_tree_model_get_iter_first (store, &iter);
+ list = NULL;
+ valid = gtk_tree_model_get_iter_first (store, &iter);
- while (valid)
- {
- gboolean to_save;
- GtranslatorPo *doc;
+ while (valid)
+ {
+ gboolean to_save;
+ GtranslatorPo *doc;
- gtk_tree_model_get (store, &iter,
- SAVE_COLUMN, &to_save,
- DOC_COLUMN, &doc,
- -1);
- if (to_save)
- list = g_list_prepend (list, doc);
+ gtk_tree_model_get (store, &iter,
+ SAVE_COLUMN, &to_save, DOC_COLUMN, &doc, -1);
+ if (to_save)
+ list = g_list_prepend (list, doc);
- valid = gtk_tree_model_iter_next (store, &iter);
- }
+ valid = gtk_tree_model_iter_next (store, &iter);
+ }
- list = g_list_reverse (list);
+ list = g_list_reverse (list);
- return list;
+ return list;
}
GList *
-gtranslator_close_confirmation_dialog_get_selected_documents (GtranslatorCloseConfirmationDialog *dlg)
+gtranslator_close_confirmation_dialog_get_selected_documents
+ (GtranslatorCloseConfirmationDialog * dlg)
{
- g_return_val_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
+ g_return_val_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
- return g_list_copy (dlg->priv->selected_documents);
+ return g_list_copy (dlg->priv->selected_documents);
}
GtkWidget *
-gtranslator_close_confirmation_dialog_new (GtkWindow *parent,
- GList *unsaved_documents,
- gboolean logout_mode)
+gtranslator_close_confirmation_dialog_new (GtkWindow * parent,
+ GList * unsaved_documents,
+ gboolean logout_mode)
{
- GtkWidget *dlg;
- g_return_val_if_fail (unsaved_documents != NULL, NULL);
-
- dlg = GTK_WIDGET (g_object_new (GTR_TYPE_CLOSE_CONFIRMATION_DIALOG,
- "unsaved_documents", unsaved_documents,
- "logout_mode", logout_mode,
- NULL));
- g_return_val_if_fail (dlg != NULL, NULL);
-
- if (parent != NULL)
- {
- gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
- }
+ GtkWidget *dlg;
+ g_return_val_if_fail (unsaved_documents != NULL, NULL);
+
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_CLOSE_CONFIRMATION_DIALOG,
+ "unsaved_documents", unsaved_documents,
+ "logout_mode", logout_mode, NULL));
+ g_return_val_if_fail (dlg != NULL, NULL);
- return dlg;
+ if (parent != NULL)
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
+ }
+
+ return dlg;
}
GtkWidget *
-gtranslator_close_confirmation_dialog_new_single (GtkWindow *parent,
- GtranslatorPo *doc,
- gboolean logout_mode)
+gtranslator_close_confirmation_dialog_new_single (GtkWindow * parent,
+ GtranslatorPo * doc,
+ gboolean logout_mode)
{
- GtkWidget *dlg;
- GList *unsaved_documents;
- g_return_val_if_fail (doc != NULL, NULL);
-
- unsaved_documents = g_list_prepend (NULL, doc);
-
- dlg = gtranslator_close_confirmation_dialog_new (parent,
- unsaved_documents,
- logout_mode);
-
- g_list_free (unsaved_documents);
-
- return dlg;
+ GtkWidget *dlg;
+ GList *unsaved_documents;
+ g_return_val_if_fail (doc != NULL, NULL);
+
+ unsaved_documents = g_list_prepend (NULL, doc);
+
+ dlg = gtranslator_close_confirmation_dialog_new (parent,
+ unsaved_documents,
+ logout_mode);
+
+ g_list_free (unsaved_documents);
+
+ return dlg;
}
static void
-build_single_doc_dialog (GtranslatorCloseConfirmationDialog *dlg)
+build_single_doc_dialog (GtranslatorCloseConfirmationDialog * dlg)
{
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *primary_label;
- GtkWidget *image;
- GtranslatorPo *doc;
- GFile *location;
- gchar *doc_name;
- gchar *str;
- gchar *markup_str;
-
- g_return_if_fail (dlg->priv->unsaved_documents->data != NULL);
- doc = GTR_PO (dlg->priv->unsaved_documents->data);
-
- /* Image */
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
-
- /* Primary label */
- primary_label = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
- gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
- gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
-
- location = gtranslator_po_get_location (doc);
- doc_name = g_file_get_path (location);
- g_object_unref (location);
-
- str = g_markup_printf_escaped (_("Save the changes to document \"%s\" before closing?"),
- doc_name);
- g_free (doc_name);
-
- markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
- g_free (str);
-
- gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
- g_free (markup_str);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
-
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
- vbox = gtk_vbox_new (FALSE, 12);
-
- gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- hbox,
- FALSE,
- FALSE,
- 0);
-
- gtk_widget_show_all (hbox);
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *primary_label;
+ GtkWidget *image;
+ GtranslatorPo *doc;
+ GFile *location;
+ gchar *doc_name;
+ gchar *str;
+ gchar *markup_str;
+
+ g_return_if_fail (dlg->priv->unsaved_documents->data != NULL);
+ doc = GTR_PO (dlg->priv->unsaved_documents->data);
+
+ /* Image */
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+
+ /* Primary label */
+ primary_label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
+
+ location = gtranslator_po_get_location (doc);
+ doc_name = g_file_get_path (location);
+ g_object_unref (location);
+
+ str =
+ g_markup_printf_escaped (_
+ ("Save the changes to document \"%s\" before closing?"),
+ doc_name);
+ g_free (doc_name);
+
+ markup_str =
+ g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>",
+ NULL);
+ g_free (str);
+
+ gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
+ g_free (markup_str);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ hbox, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (hbox);
}
static void
-populate_model (GtkTreeModel *store,
- GList *docs)
+populate_model (GtkTreeModel * store, GList * docs)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- while (docs != NULL)
- {
- GtranslatorPo *po;
- GFile *location;
- gchar *name;
+ while (docs != NULL)
+ {
+ GtranslatorPo *po;
+ GFile *location;
+ gchar *name;
- po = GTR_PO (docs->data);
+ po = GTR_PO (docs->data);
- location = gtranslator_po_get_location (po);
- name = g_file_get_path (location);
- g_object_unref (location);
+ location = gtranslator_po_get_location (po);
+ name = g_file_get_path (location);
+ g_object_unref (location);
- gtk_list_store_append (GTK_LIST_STORE (store), &iter);
- gtk_list_store_set (GTK_LIST_STORE (store), &iter,
- SAVE_COLUMN, TRUE,
- NAME_COLUMN, name,
- DOC_COLUMN, po,
- -1);
+ gtk_list_store_append (GTK_LIST_STORE (store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (store), &iter,
+ SAVE_COLUMN, TRUE,
+ NAME_COLUMN, name, DOC_COLUMN, po, -1);
- g_free (name);
- docs = g_list_next (docs);
- }
+ g_free (name);
+ docs = g_list_next (docs);
+ }
}
static void
-save_toggled (GtkCellRendererToggle *renderer,
- gchar *path_str,
- GtkTreeModel *store)
+save_toggled (GtkCellRendererToggle * renderer,
+ gchar * path_str, GtkTreeModel * store)
{
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeIter iter;
- gboolean active;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeIter iter;
+ gboolean active;
- gtk_tree_model_get_iter (store, &iter, path);
- gtk_tree_model_get (store, &iter, SAVE_COLUMN, &active, -1);
+ gtk_tree_model_get_iter (store, &iter, path);
+ gtk_tree_model_get (store, &iter, SAVE_COLUMN, &active, -1);
- active ^= 1;
+ active ^= 1;
- gtk_list_store_set (GTK_LIST_STORE (store), &iter,
- SAVE_COLUMN, active, -1);
+ gtk_list_store_set (GTK_LIST_STORE (store), &iter, SAVE_COLUMN, active, -1);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
}
static GtkWidget *
-create_treeview (GtranslatorCloseConfirmationDialogPrivate *priv)
+create_treeview (GtranslatorCloseConfirmationDialogPrivate * priv)
{
- GtkListStore *store;
- GtkWidget *treeview;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- treeview = gtk_tree_view_new ();
- gtk_widget_set_size_request (treeview, 260, 120);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
-
- /* Create and populate the model */
- store = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_POINTER);
- populate_model (GTK_TREE_MODEL (store), priv->unsaved_documents);
-
- /* Set model to the treeview */
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
- GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- priv->list_store = GTK_TREE_MODEL (store);
-
- /* Add columns */
- if (!priv->disable_save_to_disk)
- {
- renderer = gtk_cell_renderer_toggle_new ();
- g_signal_connect (renderer, "toggled",
- G_CALLBACK (save_toggled), store);
-
- column = gtk_tree_view_column_new_with_attributes ("Save?",
- renderer,
- "active",
- SAVE_COLUMN,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
- }
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Name",
- renderer,
- "text",
- NAME_COLUMN,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
-
- return treeview;
+ GtkListStore *store;
+ GtkWidget *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ treeview = gtk_tree_view_new ();
+ gtk_widget_set_size_request (treeview, 260, 120);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
+
+ /* Create and populate the model */
+ store = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_POINTER);
+ populate_model (GTK_TREE_MODEL (store), priv->unsaved_documents);
+
+ /* Set model to the treeview */
+ gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ priv->list_store = GTK_TREE_MODEL (store);
+
+ /* Add columns */
+ if (!priv->disable_save_to_disk)
+ {
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (save_toggled), store);
+
+ column = gtk_tree_view_column_new_with_attributes ("Save?",
+ renderer,
+ "active",
+ SAVE_COLUMN, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+ }
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes ("Name",
+ renderer,
+ "text",
+ NAME_COLUMN, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ return treeview;
}
static void
-build_multiple_docs_dialog (GtranslatorCloseConfirmationDialog *dlg)
+build_multiple_docs_dialog (GtranslatorCloseConfirmationDialog * dlg)
{
- GtranslatorCloseConfirmationDialogPrivate *priv;
- GtkWidget *hbox;
- GtkWidget *image;
- GtkWidget *vbox;
- GtkWidget *primary_label;
- GtkWidget *vbox2;
- GtkWidget *select_label;
- GtkWidget *scrolledwindow;
- GtkWidget *treeview;
- GtkWidget *secondary_label;
- gchar *str;
- gchar *markup_str;
-
- priv = dlg->priv;
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- hbox, TRUE, TRUE, 0);
-
- /* Image */
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
- vbox = gtk_vbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
- /* Primary label */
- primary_label = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
- gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
- gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
-
- if (priv->disable_save_to_disk)
- str = g_strdup_printf (
- ngettext ("Changes to %d document will be permanently lost.",
- "Changes to %d documents will be permanently lost.",
- g_list_length (priv->unsaved_documents)),
- g_list_length (priv->unsaved_documents));
- else
- str = g_strdup_printf (
- ngettext ("There is %d document with unsaved changes. "
- "Save changes before closing?",
- "There are %d documents with unsaved changes. "
- "Save changes before closing?",
- g_list_length (priv->unsaved_documents)),
- g_list_length (priv->unsaved_documents));
-
- markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
- g_free (str);
-
- gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
- g_free (markup_str);
- gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
-
- vbox2 = gtk_vbox_new (FALSE, 8);
- gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
-
- if (priv->disable_save_to_disk)
- select_label = gtk_label_new_with_mnemonic (_("Docum_ents with unsaved changes:"));
- else
- select_label = gtk_label_new_with_mnemonic (_("S_elect the documents you want to save:"));
-
- gtk_box_pack_start (GTK_BOX (vbox2), select_label, FALSE, FALSE, 0);
- gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (select_label), 0.0, 0.5);
-
- scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow, TRUE, TRUE, 0);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
- GTK_SHADOW_IN);
-
- treeview = create_treeview (priv);
- gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
-
- /* Secondary label */
- if (priv->disable_save_to_disk)
- secondary_label = gtk_label_new (_("Saving has been disabled by the system administrator."));
- else
- secondary_label = gtk_label_new (_("If you don't save, "
- "all your changes will be permanently lost."));
-
- gtk_box_pack_start (GTK_BOX (vbox2), secondary_label, FALSE, FALSE, 0);
- gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
- gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (select_label), treeview);
-
- gtk_widget_show_all (hbox);
+ GtranslatorCloseConfirmationDialogPrivate *priv;
+ GtkWidget *hbox;
+ GtkWidget *image;
+ GtkWidget *vbox;
+ GtkWidget *primary_label;
+ GtkWidget *vbox2;
+ GtkWidget *select_label;
+ GtkWidget *scrolledwindow;
+ GtkWidget *treeview;
+ GtkWidget *secondary_label;
+ gchar *str;
+ gchar *markup_str;
+
+ priv = dlg->priv;
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, TRUE, TRUE, 0);
+
+ /* Image */
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ /* Primary label */
+ primary_label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
+
+ if (priv->disable_save_to_disk)
+ str =
+ g_strdup_printf (ngettext
+ ("Changes to %d document will be permanently lost.",
+ "Changes to %d documents will be permanently lost.",
+ g_list_length (priv->unsaved_documents)),
+ g_list_length (priv->unsaved_documents));
+ else
+ str =
+ g_strdup_printf (ngettext
+ ("There is %d document with unsaved changes. "
+ "Save changes before closing?",
+ "There are %d documents with unsaved changes. "
+ "Save changes before closing?",
+ g_list_length (priv->unsaved_documents)),
+ g_list_length (priv->unsaved_documents));
+
+ markup_str =
+ g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>",
+ NULL);
+ g_free (str);
+
+ gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
+ g_free (markup_str);
+ gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
+
+ vbox2 = gtk_vbox_new (FALSE, 8);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
+
+ if (priv->disable_save_to_disk)
+ select_label =
+ gtk_label_new_with_mnemonic (_("Docum_ents with unsaved changes:"));
+ else
+ select_label =
+ gtk_label_new_with_mnemonic (_
+ ("S_elect the documents you want to save:"));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), select_label, FALSE, FALSE, 0);
+ gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (select_label), 0.0, 0.5);
+
+ scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_SHADOW_IN);
+
+ treeview = create_treeview (priv);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
+
+ /* Secondary label */
+ if (priv->disable_save_to_disk)
+ secondary_label =
+ gtk_label_new (_
+ ("Saving has been disabled by the system administrator."));
+ else
+ secondary_label = gtk_label_new (_("If you don't save, "
+ "all your changes will be permanently lost."));
+
+ gtk_box_pack_start (GTK_BOX (vbox2), secondary_label, FALSE, FALSE, 0);
+ gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (select_label), treeview);
+
+ gtk_widget_show_all (hbox);
}
static void
-set_unsaved_document (GtranslatorCloseConfirmationDialog *dlg,
- const GList *list)
+set_unsaved_document (GtranslatorCloseConfirmationDialog * dlg,
+ const GList * list)
{
- GtranslatorCloseConfirmationDialogPrivate *priv;
+ GtranslatorCloseConfirmationDialogPrivate *priv;
- g_return_if_fail (list != NULL);
+ g_return_if_fail (list != NULL);
- priv = dlg->priv;
- g_return_if_fail (priv->unsaved_documents == NULL);
+ priv = dlg->priv;
+ g_return_if_fail (priv->unsaved_documents == NULL);
- priv->unsaved_documents = g_list_copy ((GList *)list);
+ priv->unsaved_documents = g_list_copy ((GList *) list);
- if (GET_MODE (priv) == SINGLE_DOC_MODE)
- {
- build_single_doc_dialog (dlg);
- }
- else
- {
- build_multiple_docs_dialog (dlg);
- }
+ if (GET_MODE (priv) == SINGLE_DOC_MODE)
+ {
+ build_single_doc_dialog (dlg);
+ }
+ else
+ {
+ build_multiple_docs_dialog (dlg);
+ }
}
const GList *
-gtranslator_close_confirmation_dialog_get_unsaved_documents (GtranslatorCloseConfirmationDialog *dlg)
+gtranslator_close_confirmation_dialog_get_unsaved_documents
+ (GtranslatorCloseConfirmationDialog * dlg)
{
- g_return_val_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
+ g_return_val_if_fail (GTR_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
- return dlg->priv->unsaved_documents;
+ return dlg->priv->unsaved_documents;
}
diff --git a/src/dialogs/close-confirmation-dialog.h b/src/dialogs/close-confirmation-dialog.h
index 5c01576..b755a28 100644
--- a/src/dialogs/close-confirmation-dialog.h
+++ b/src/dialogs/close-confirmation-dialog.h
@@ -41,35 +41,48 @@
#define GTR_IS_CLOSE_CONFIRMATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_CLOSE_CONFIRMATION_DIALOG))
#define GTR_CLOSE_CONFIRMATION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GTR_TYPE_CLOSE_CONFIRMATION_DIALOG, GtranslatorCloseConfirmationDialogClass))
-typedef struct _GtranslatorCloseConfirmationDialog GtranslatorCloseConfirmationDialog;
-typedef struct _GtranslatorCloseConfirmationDialogClass GtranslatorCloseConfirmationDialogClass;
-typedef struct _GtranslatorCloseConfirmationDialogPrivate GtranslatorCloseConfirmationDialogPrivate;
+typedef struct _GtranslatorCloseConfirmationDialog
+ GtranslatorCloseConfirmationDialog;
+typedef struct _GtranslatorCloseConfirmationDialogClass
+ GtranslatorCloseConfirmationDialogClass;
+typedef struct _GtranslatorCloseConfirmationDialogPrivate
+ GtranslatorCloseConfirmationDialogPrivate;
-struct _GtranslatorCloseConfirmationDialog
+struct _GtranslatorCloseConfirmationDialog
{
- GtkDialog parent;
+ GtkDialog parent;
- /*< private > */
- GtranslatorCloseConfirmationDialogPrivate *priv;
+ /*< private > */
+ GtranslatorCloseConfirmationDialogPrivate *priv;
};
-struct _GtranslatorCloseConfirmationDialogClass
+struct _GtranslatorCloseConfirmationDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
-GType gtranslator_close_confirmation_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_close_confirmation_dialog_get_type (void)
+ G_GNUC_CONST;
-GtkWidget *gtranslator_close_confirmation_dialog_new (GtkWindow *parent,
- GList *unsaved_documents,
- gboolean logout_mode);
-GtkWidget *gtranslator_close_confirmation_dialog_new_single (GtkWindow *parent,
- GtranslatorPo *doc,
- gboolean logout_mode);
+ GtkWidget *gtranslator_close_confirmation_dialog_new (GtkWindow * parent,
+ GList *
+ unsaved_documents,
+ gboolean
+ logout_mode);
+ GtkWidget *gtranslator_close_confirmation_dialog_new_single (GtkWindow *
+ parent,
+ GtranslatorPo
+ * doc,
+ gboolean
+ logout_mode);
-const GList *gtranslator_close_confirmation_dialog_get_unsaved_documents (GtranslatorCloseConfirmationDialog *dlg);
+ const GList
+ *gtranslator_close_confirmation_dialog_get_unsaved_documents
+ (GtranslatorCloseConfirmationDialog * dlg);
-GList *gtranslator_close_confirmation_dialog_get_selected_documents (GtranslatorCloseConfirmationDialog *dlg);
+ GList
+ *gtranslator_close_confirmation_dialog_get_selected_documents
+ (GtranslatorCloseConfirmationDialog * dlg);
#endif /* __GTR_CLOSE_CONFIRMATION_DIALOG_H__ */
-
diff --git a/src/dialogs/comment-dialog.c b/src/dialogs/comment-dialog.c
index acfca2d..e82eda6 100644
--- a/src/dialogs/comment-dialog.c
+++ b/src/dialogs/comment-dialog.c
@@ -38,162 +38,147 @@
GtranslatorCommentDialogPrivate))
-G_DEFINE_TYPE(GtranslatorCommentDialog, gtranslator_comment_dialog, GTK_TYPE_DIALOG)
-
-struct _GtranslatorCommentDialogPrivate
-{
- GtkWidget *main_box;
- GtkWidget *comment;
-};
-
-static void
-comment_changed_cb (GtkTextBuffer *buffer,
- GtranslatorWindow *window)
+G_DEFINE_TYPE (GtranslatorCommentDialog, gtranslator_comment_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorCommentDialogPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *comment;
+ };
+
+ static void
+ comment_changed_cb (GtkTextBuffer * buffer, GtranslatorWindow * window)
{
- gchar *text;
- GtkTextIter start, end;
- GtranslatorTab *tab;
- GtranslatorPo *po;
- GList *msg;
-
- tab = gtranslator_window_get_active_tab(window);
- po = gtranslator_tab_get_po(tab);
- msg = gtranslator_po_get_current_message(po);
-
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
-
- gtranslator_msg_set_comment(msg->data, text);
- gtranslator_po_set_state (po, GTR_PO_STATE_MODIFIED);
+ gchar *text;
+ GtkTextIter start, end;
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ GList *msg;
+
+ tab = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (tab);
+ msg = gtranslator_po_get_current_message (po);
+
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
+
+ gtranslator_msg_set_comment (msg->data, text);
+ gtranslator_po_set_state (po, GTR_PO_STATE_MODIFIED);
}
static void
-dialog_response_handler (GtkDialog *dlg,
- gint res_id)
+dialog_response_handler (GtkDialog * dlg, gint res_id)
{
- switch (res_id)
- {
- default:
- gtk_widget_destroy (GTK_WIDGET(dlg));
- }
+ switch (res_id)
+ {
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
}
static void
-gtranslator_comment_dialog_init (GtranslatorCommentDialog *dlg)
+gtranslator_comment_dialog_init (GtranslatorCommentDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "main_box",
- NULL
- };
- gchar *path;
-
- dlg->priv = GTR_COMMENT_DIALOG_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Edit Comment"));
- gtk_window_set_default_size(GTK_WINDOW(dlg), 300, 200);
- gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Glade*/
- path = gtranslator_utils_get_file_from_pkgdatadir("comment-dialog.ui");
- ret = gtranslator_utils_get_ui_objects (path,
- root_objects,
- &error_widget,
-
- "main_box", &dlg->priv->main_box,
- "comment", &dlg->priv->comment,
-
- NULL);
- g_free(path);
-
- if(!ret)
- {
- gtk_widget_show(error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "main_box",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_COMMENT_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Edit Comment"));
+ gtk_window_set_default_size (GTK_WINDOW (dlg), 300, 200);
+ gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+ path = gtranslator_utils_get_file_from_pkgdatadir ("comment-dialog.ui");
+ ret = gtranslator_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "comment", &dlg->priv->comment,
+ NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
}
static void
-gtranslator_comment_dialog_finalize (GObject *object)
+gtranslator_comment_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_comment_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_comment_dialog_parent_class)->finalize (object);
}
static void
-gtranslator_comment_dialog_class_init (GtranslatorCommentDialogClass *klass)
+gtranslator_comment_dialog_class_init (GtranslatorCommentDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorCommentDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorCommentDialogPrivate));
- object_class->finalize = gtranslator_comment_dialog_finalize;
+ object_class->finalize = gtranslator_comment_dialog_finalize;
}
void
-gtranslator_show_comment_dialog (GtranslatorWindow *window)
+gtranslator_show_comment_dialog (GtranslatorWindow * window)
{
- static GtranslatorCommentDialog *dlg = NULL;
- static GtkTextBuffer *buf;
- GtranslatorTab *tab = gtranslator_window_get_active_tab(window);
- GtranslatorPo *po = gtranslator_tab_get_po(tab);
- GList *msg = gtranslator_po_get_current_message(po);
-
- g_return_if_fail(GTR_IS_WINDOW(window));
-
- if(dlg == NULL)
- {
- dlg = g_object_new (GTR_TYPE_COMMENT_DIALOG, NULL);
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dlg->priv->comment));
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
- g_signal_connect (buf,
- "changed",
- G_CALLBACK (comment_changed_cb),
- window);
-
- gtk_widget_show (GTK_WIDGET(dlg));
- }
-
- gtk_text_buffer_set_text(buf, gtranslator_msg_get_comment(msg->data), -1);
-
- 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_present (GTK_WINDOW (dlg));
+ static GtranslatorCommentDialog *dlg = NULL;
+ static GtkTextBuffer *buf;
+ GtranslatorTab *tab = gtranslator_window_get_active_tab (window);
+ GtranslatorPo *po = gtranslator_tab_get_po (tab);
+ GList *msg = gtranslator_po_get_current_message (po);
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_COMMENT_DIALOG, NULL);
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->comment));
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+ g_signal_connect (buf,
+ "changed", G_CALLBACK (comment_changed_cb), window);
+
+ gtk_widget_show (GTK_WIDGET (dlg));
+ }
+
+ gtk_text_buffer_set_text (buf, gtranslator_msg_get_comment (msg->data), -1);
+
+ 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_present (GTK_WINDOW (dlg));
}
diff --git a/src/dialogs/comment-dialog.h b/src/dialogs/comment-dialog.h
index a47eafc..8e86c3f 100644
--- a/src/dialogs/comment-dialog.h
+++ b/src/dialogs/comment-dialog.h
@@ -26,7 +26,6 @@
#include "msg.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -36,42 +35,43 @@ G_BEGIN_DECLS
#define GTR_IS_COMMENT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_COMMENT_DIALOG))
#define GTR_IS_COMMENT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_COMMENT_DIALOG))
#define GTR_COMMENT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_COMMENT_DIALOG, GtranslatorCommentDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorCommentDialogPrivate GtranslatorCommentDialogPrivate;
+typedef struct _GtranslatorCommentDialogPrivate
+ GtranslatorCommentDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorCommentDialog GtranslatorCommentDialog;
+typedef struct _GtranslatorCommentDialog GtranslatorCommentDialog;
struct _GtranslatorCommentDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorCommentDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorCommentDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorCommentDialogClass GtranslatorCommentDialogClass;
+typedef struct _GtranslatorCommentDialogClass GtranslatorCommentDialogClass;
struct _GtranslatorCommentDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_comment_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_comment_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_comment_dialog_register_type (GTypeModule * module);
+ GType gtranslator_comment_dialog_register_type (GTypeModule * module);
-void gtranslator_show_comment_dialog (GtranslatorWindow *window);
+ void gtranslator_show_comment_dialog (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __COMMENT_DIALOG_H__ */
diff --git a/src/dialogs/file-dialogs.c b/src/dialogs/file-dialogs.c
index a36de48..e04875b 100644
--- a/src/dialogs/file-dialogs.c
+++ b/src/dialogs/file-dialogs.c
@@ -29,54 +29,56 @@
* File chooser dialog
*/
GtkWidget *
-gtranslator_file_chooser_new (GtkWindow *parent,
+gtranslator_file_chooser_new (GtkWindow * parent,
FileselMode mode,
- const gchar *title,
- const gchar *dir)
+ const gchar * title, const gchar * dir)
{
- GtkWidget *dialog;
- GtkFileFilter *filter;
-
- dialog = gtk_file_chooser_dialog_new(title,
- parent,
- (mode == FILESEL_SAVE) ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- (mode == FILESEL_SAVE) ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog),GTK_RESPONSE_ACCEPT);
+ GtkWidget *dialog;
+ GtkFileFilter *filter;
- if (dir)
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
- dir);
+ dialog = gtk_file_chooser_dialog_new (title,
+ parent,
+ (mode ==
+ FILESEL_SAVE) ?
+ GTK_FILE_CHOOSER_ACTION_SAVE :
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ (mode ==
+ FILESEL_SAVE) ? GTK_STOCK_SAVE :
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- if (mode != FILESEL_SAVE)
- {
- /* We set a multi selection dialog */
- gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog),
- TRUE);
-
- /* Now we set the filters */
- filter = gtk_file_filter_new();
- gtk_file_filter_set_name(filter,_("Gettext translation"));
+ if (dir)
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), dir);
+
+ if (mode != FILESEL_SAVE)
+ {
+ /* We set a multi selection dialog */
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ /* Now we set the filters */
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Gettext translation"));
#ifndef G_OS_WIN32
- gtk_file_filter_add_mime_type(filter,"text/x-gettext-translation");
+ gtk_file_filter_add_mime_type (filter, "text/x-gettext-translation");
#else
- gtk_file_filter_add_pattern (filter,"*.po");
+ gtk_file_filter_add_pattern (filter, "*.po");
#endif
- gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
-
- filter = gtk_file_filter_new();
- gtk_file_filter_set_name(filter,_("Gettext translation template"));
- gtk_file_filter_add_pattern(filter,"*.pot");
- gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
-
- filter = gtk_file_filter_new();
- gtk_file_filter_set_name(filter,_("All files"));
- gtk_file_filter_add_pattern(filter,"*");
- gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
- }
-
- gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
-
- return dialog;
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Gettext translation template"));
+ gtk_file_filter_add_pattern (filter, "*.pot");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ }
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+
+ return dialog;
}
diff --git a/src/dialogs/file-dialogs.h b/src/dialogs/file-dialogs.h
index aa1919a..99d5e74 100644
--- a/src/dialogs/file-dialogs.h
+++ b/src/dialogs/file-dialogs.h
@@ -22,14 +22,15 @@
#include <gtk/gtk.h>
#include "window.h"
-typedef enum {
- FILESEL_OPEN,
- FILESEL_SAVE
+typedef enum
+{
+ FILESEL_OPEN,
+ FILESEL_SAVE
} FileselMode;
-GtkWidget *gtranslator_file_chooser_new (GtkWindow *parent,
- FileselMode mode,
- const gchar *title,
- const gchar *dir);
+GtkWidget *gtranslator_file_chooser_new (GtkWindow * parent,
+ FileselMode mode,
+ const gchar * title,
+ const gchar * dir);
#endif
diff --git a/src/dialogs/header-dialog.c b/src/dialogs/header-dialog.c
index c8f5506..81f87a9 100644
--- a/src/dialogs/header-dialog.c
+++ b/src/dialogs/header-dialog.c
@@ -37,394 +37,415 @@
GTR_TYPE_HEADER_DIALOG, \
GtranslatorHeaderDialogPrivate))
-G_DEFINE_TYPE(GtranslatorHeaderDialog, gtranslator_header_dialog, GTK_TYPE_DIALOG)
-
-struct _GtranslatorHeaderDialogPrivate
-{
- GtkWidget *main_box;
- GtkWidget *notebook;
-
- GtkWidget *prj_page;
- GtkWidget *lang_page;
- GtkWidget *lang_vbox;
-
- GtkWidget *prj_id_version;
- GtkWidget *rmbt;
- GtkWidget *prj_comment;
- GtkWidget *take_my_options;
-
- GtkWidget *translator;
- GtkWidget *tr_email;
- GtkWidget *pot_date;
- GtkWidget *po_date;
- GtkWidget *language;
- GtkWidget *lg_email;
- GtkWidget *charset;
- GtkWidget *encoding;
-};
-
-static void gtranslator_header_dialog_finalize (GObject *object)
+G_DEFINE_TYPE (GtranslatorHeaderDialog, gtranslator_header_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorHeaderDialogPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *notebook;
+
+ GtkWidget *prj_page;
+ GtkWidget *lang_page;
+ GtkWidget *lang_vbox;
+
+ GtkWidget *prj_id_version;
+ GtkWidget *rmbt;
+ GtkWidget *prj_comment;
+ GtkWidget *take_my_options;
+
+ GtkWidget *translator;
+ GtkWidget *tr_email;
+ GtkWidget *pot_date;
+ GtkWidget *po_date;
+ GtkWidget *language;
+ GtkWidget *lg_email;
+ GtkWidget *charset;
+ GtkWidget *encoding;
+ };
+
+ static void gtranslator_header_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_header_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_header_dialog_parent_class)->finalize (object);
}
-static void gtranslator_header_dialog_class_init (GtranslatorHeaderDialogClass *klass)
+static void
+gtranslator_header_dialog_class_init (GtranslatorHeaderDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorHeaderDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorHeaderDialogPrivate));
- object_class->finalize = gtranslator_header_dialog_finalize;
+ object_class->finalize = gtranslator_header_dialog_finalize;
}
static void
-take_my_options_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorHeaderDialog *dlg)
+take_my_options_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorHeaderDialog * dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->take_my_options));
-
-
- gtranslator_prefs_manager_set_use_profile_values(gtk_toggle_button_get_active(button));
-
- gtk_widget_set_sensitive(dlg->priv->translator, !gtk_toggle_button_get_active(button));
- gtk_widget_set_sensitive(dlg->priv->tr_email, !gtk_toggle_button_get_active(button));
- gtk_widget_set_sensitive(dlg->priv->language, !gtk_toggle_button_get_active(button));
- gtk_widget_set_sensitive(dlg->priv->lg_email, !gtk_toggle_button_get_active(button));
- gtk_widget_set_sensitive(dlg->priv->encoding, !gtk_toggle_button_get_active(button));
-
+ g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->take_my_options));
+
+
+ gtranslator_prefs_manager_set_use_profile_values
+ (gtk_toggle_button_get_active (button));
+
+ gtk_widget_set_sensitive (dlg->priv->translator,
+ !gtk_toggle_button_get_active (button));
+ gtk_widget_set_sensitive (dlg->priv->tr_email,
+ !gtk_toggle_button_get_active (button));
+ gtk_widget_set_sensitive (dlg->priv->language,
+ !gtk_toggle_button_get_active (button));
+ gtk_widget_set_sensitive (dlg->priv->lg_email,
+ !gtk_toggle_button_get_active (button));
+ gtk_widget_set_sensitive (dlg->priv->encoding,
+ !gtk_toggle_button_get_active (button));
+
}
static void
-prj_comment_changed (GtkTextBuffer *buffer,
- GtranslatorHeader *header)
+prj_comment_changed (GtkTextBuffer * buffer, GtranslatorHeader * header)
{
- const gchar *text;
- GtkTextIter start, end;
-
- gtranslator_header_set_header_changed (header, TRUE);
+ const gchar *text;
+ GtkTextIter start, end;
+
+ gtranslator_header_set_header_changed (header, TRUE);
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
- if (text)
- gtranslator_header_set_comment(header, g_strdup(text));
+ if (text)
+ gtranslator_header_set_comment (header, g_strdup (text));
}
static void
-prj_id_version_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorHeader *header)
+prj_id_version_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorHeader * header)
{
- const gchar *text;
+ const gchar *text;
- gtranslator_header_set_header_changed (header, TRUE);
+ gtranslator_header_set_header_changed (header, TRUE);
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
- if (text)
- gtranslator_header_set_prj_id_version(header, g_strdup(text));
+ if (text)
+ gtranslator_header_set_prj_id_version (header, g_strdup (text));
}
static void
-rmbt_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorHeader *header)
+rmbt_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorHeader * header)
{
- const gchar *text;
+ const gchar *text;
- gtranslator_header_set_header_changed (header, TRUE);
+ gtranslator_header_set_header_changed (header, TRUE);
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
- if (text)
- gtranslator_header_set_rmbt(header, g_strdup(text));
+ if (text)
+ gtranslator_header_set_rmbt (header, g_strdup (text));
}
static void
-translator_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorHeader *header)
+translator_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorHeader * header)
{
- const gchar *text;
+ const gchar *text;
- gtranslator_header_set_header_changed (header, TRUE);
+ gtranslator_header_set_header_changed (header, TRUE);
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
- if (text)
- gtranslator_header_set_translator(header, g_strdup(text));
+ if (text)
+ gtranslator_header_set_translator (header, g_strdup (text));
}
static void
-tr_email_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorHeader *header)
+tr_email_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorHeader * header)
{
- const gchar *text;
+ const gchar *text;
- gtranslator_header_set_header_changed (header, TRUE);
+ gtranslator_header_set_header_changed (header, TRUE);
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
- if (text)
- gtranslator_header_set_tr_email(header, g_strdup(text));
+ if (text)
+ gtranslator_header_set_tr_email (header, g_strdup (text));
}
static void
-language_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorHeader *header)
+language_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorHeader * header)
{
- const gchar *text;
+ const gchar *text;
- gtranslator_header_set_header_changed (header, TRUE);
+ gtranslator_header_set_header_changed (header, TRUE);
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
- if (text)
- gtranslator_header_set_language(header, g_strdup(text));
+ if (text)
+ gtranslator_header_set_language (header, g_strdup (text));
}
static void
-lg_email_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorHeader *header)
+lg_email_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorHeader * header)
{
- const gchar *text;
+ const gchar *text;
- gtranslator_header_set_header_changed (header, TRUE);
+ gtranslator_header_set_header_changed (header, TRUE);
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
-
- if (text)
- gtranslator_header_set_lg_email(header, g_strdup(text));
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_header_set_lg_email (header, g_strdup (text));
}
-static void
-gtranslator_header_dialog_fill_from_header (GtranslatorHeaderDialog *dlg, GtranslatorHeader *header)
+static void
+gtranslator_header_dialog_fill_from_header (GtranslatorHeaderDialog * dlg,
+ GtranslatorHeader * header)
{
- GtkTextBuffer *buffer;
-
- /*
- * Project Information
- */
- buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(dlg->priv->prj_comment));
- gtk_text_buffer_set_text(buffer, gtranslator_header_get_comment(header),
- strlen(gtranslator_header_get_comment(header)));
-
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->prj_id_version), gtranslator_header_get_prj_id_version(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->pot_date), gtranslator_header_get_pot_date(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->po_date), gtranslator_header_get_po_date(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->rmbt), gtranslator_header_get_rmbt(header));
-
- /*
- * Translator and Language Information
- */
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->translator), gtranslator_header_get_translator(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->tr_email), gtranslator_header_get_tr_email(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->language), gtranslator_header_get_language(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->lg_email), gtranslator_header_get_lg_email(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->charset), gtranslator_header_get_charset(header));
- gtk_entry_set_text(GTK_ENTRY(dlg->priv->encoding), gtranslator_header_get_encoding(header));
+ GtkTextBuffer *buffer;
+
+ /*
+ * Project Information
+ */
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dlg->priv->prj_comment));
+ gtk_text_buffer_set_text (buffer, gtranslator_header_get_comment (header),
+ strlen (gtranslator_header_get_comment (header)));
+
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->prj_id_version),
+ gtranslator_header_get_prj_id_version (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->pot_date),
+ gtranslator_header_get_pot_date (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->po_date),
+ gtranslator_header_get_po_date (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->rmbt),
+ gtranslator_header_get_rmbt (header));
+
+ /*
+ * Translator and Language Information
+ */
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->translator),
+ gtranslator_header_get_translator (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->tr_email),
+ gtranslator_header_get_tr_email (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->language),
+ gtranslator_header_get_language (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->lg_email),
+ gtranslator_header_get_lg_email (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->charset),
+ gtranslator_header_get_charset (header));
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->encoding),
+ gtranslator_header_get_encoding (header));
}
-static void save_header(GtranslatorPo *po)
+static void
+save_header (GtranslatorPo * po)
{
- GtranslatorHeader *header;
+ GtranslatorHeader *header;
- header = gtranslator_po_get_header (po);
+ header = gtranslator_po_get_header (po);
- if (gtranslator_header_get_header_changed (header))
- gtranslator_po_set_state (po, GTR_PO_STATE_MODIFIED);
-}
+ if (gtranslator_header_get_header_changed (header))
+ gtranslator_po_set_state (po, GTR_PO_STATE_MODIFIED);
+}
-static void gtranslator_header_dialog_init (GtranslatorHeaderDialog *dlg)
+static void
+gtranslator_header_dialog_init (GtranslatorHeaderDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "main_box",
- NULL
- };
- gchar *path;
-
- dlg->priv = GTR_HEADER_DIALOG_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Edit Header"));
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
-
- path = gtranslator_utils_get_file_from_pkgdatadir("header-dialog.ui");
-
- ret = gtranslator_utils_get_ui_objects (path,
- root_objects,
- &error_widget,
- "main_box", &dlg->priv->main_box,
- "notebook", &dlg->priv->notebook,
- "lang_vbox", &dlg->priv->lang_vbox,
- "prj_id_version", &dlg->priv->prj_id_version,
- "rmbt", &dlg->priv->rmbt,
- "prj_comment", &dlg->priv->prj_comment,
- "take_my_options", &dlg->priv->take_my_options,
- "tr_name", &dlg->priv->translator,
- "tr_email", &dlg->priv->tr_email,
- "pot_date", &dlg->priv->pot_date,
- "po_date", &dlg->priv->po_date,
- "language_entry", &dlg->priv->language,
- "lg_email_entry", &dlg->priv->lg_email,
- "charset_entry", &dlg->priv->charset,
- "encoding_entry", &dlg->priv->encoding,
- NULL);
- g_free(path);
-
- if(!ret)
- {
- gtk_widget_show(error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, FALSE, FALSE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
-
- if (gtranslator_application_get_profiles (GTR_APP) == NULL)
- {
- gtk_widget_set_sensitive (dlg->priv->take_my_options, FALSE);
- }
- else
- {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->take_my_options),
- gtranslator_prefs_manager_get_use_profile_values());
- }
- gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->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);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dlg->priv->take_my_options))) {
-
- gtk_widget_set_sensitive(dlg->priv->translator, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)));
- gtk_widget_set_sensitive(dlg->priv->tr_email, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)));
- gtk_widget_set_sensitive(dlg->priv->language, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)));
- gtk_widget_set_sensitive(dlg->priv->lg_email, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)));
- gtk_widget_set_sensitive(dlg->priv->encoding, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)));
- }
-
- /*Connect signals*/
- g_signal_connect(dlg->priv->take_my_options, "toggled",
- G_CALLBACK(take_my_options_checkbutton_toggled),
- dlg);
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "main_box",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_HEADER_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Edit Header"));
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2);
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+
+ path = gtranslator_utils_get_file_from_pkgdatadir ("header-dialog.ui");
+
+ ret = gtranslator_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "notebook", &dlg->priv->notebook,
+ "lang_vbox", &dlg->priv->lang_vbox,
+ "prj_id_version",
+ &dlg->priv->prj_id_version, "rmbt",
+ &dlg->priv->rmbt, "prj_comment",
+ &dlg->priv->prj_comment,
+ "take_my_options",
+ &dlg->priv->take_my_options,
+ "tr_name", &dlg->priv->translator,
+ "tr_email", &dlg->priv->tr_email,
+ "pot_date", &dlg->priv->pot_date,
+ "po_date", &dlg->priv->po_date,
+ "language_entry",
+ &dlg->priv->language,
+ "lg_email_entry",
+ &dlg->priv->lg_email,
+ "charset_entry",
+ &dlg->priv->charset,
+ "encoding_entry",
+ &dlg->priv->encoding, NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, FALSE, FALSE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+
+ if (gtranslator_application_get_profiles (GTR_APP) == NULL)
+ {
+ gtk_widget_set_sensitive (dlg->priv->take_my_options, FALSE);
+ }
+ else
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options),
+ gtranslator_prefs_manager_get_use_profile_values
+ ());
+ }
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (dlg->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);
+
+ if (gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (dlg->priv->take_my_options)))
+ {
+
+ gtk_widget_set_sensitive (dlg->priv->translator,
+ !gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options)));
+ gtk_widget_set_sensitive (dlg->priv->tr_email,
+ !gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options)));
+ gtk_widget_set_sensitive (dlg->priv->language,
+ !gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options)));
+ gtk_widget_set_sensitive (dlg->priv->lg_email,
+ !gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options)));
+ gtk_widget_set_sensitive (dlg->priv->encoding,
+ !gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON
+ (dlg->priv->take_my_options)));
+ }
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->take_my_options, "toggled",
+ G_CALLBACK (take_my_options_checkbutton_toggled), dlg);
}
-void gtranslator_show_header_dialog (GtranslatorWindow *window)
+void
+gtranslator_show_header_dialog (GtranslatorWindow * window)
{
-
- static GtkWidget *dlg = NULL;
-
- GtranslatorPo *po;
- GtranslatorTab *tab;
- GtranslatorHeader *header;
- GtkTextBuffer *buffer;
-
- tab = gtranslator_window_get_active_tab (window);
- g_return_if_fail (tab != NULL);
- po = gtranslator_tab_get_po (tab);
-
- g_return_if_fail(GTR_IS_WINDOW(window));
-
- /*
- * Get header's values from tab in window
- */
- header = gtranslator_window_get_header_from_active_tab(window);
-
- if(dlg == NULL)
- {
- dlg = GTK_WIDGET (g_object_new (GTR_TYPE_HEADER_DIALOG, NULL));
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
- gtk_widget_show_all(dlg);
- }
-
- /*
- * Connect signal to save header in msg
- */
- g_signal_connect_swapped (dlg, "destroy",
- G_CALLBACK(save_header),
- po);
-
- /*
- * Write header's values on Header dialog
- */
- gtranslator_header_dialog_fill_from_header(GTR_HEADER_DIALOG(dlg), header);
-
- 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_present (GTK_WINDOW (dlg));
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (GTR_HEADER_DIALOG (dlg)->priv->prj_comment));
-
- g_signal_connect(buffer, "changed",
- G_CALLBACK(prj_comment_changed),
- header);
-
- /*
- * Connect signals to edit Project information on Header dialog
- */
- g_signal_connect(GTR_HEADER_DIALOG(dlg)->priv->prj_id_version, "notify::text",
- G_CALLBACK(prj_id_version_changed),
- header);
-
- g_signal_connect(GTR_HEADER_DIALOG(dlg)->priv->rmbt, "notify::text",
- G_CALLBACK(rmbt_changed),
- header);
- /*
- * Connect signals to edit Translator and Language information on Header dialog
- */
- g_signal_connect(GTR_HEADER_DIALOG(dlg)->priv->translator, "notify::text",
- G_CALLBACK(translator_changed),
- header);
-
- g_signal_connect(GTR_HEADER_DIALOG(dlg)->priv->tr_email, "notify::text",
- G_CALLBACK(tr_email_changed),
- header);
-
- g_signal_connect(GTR_HEADER_DIALOG(dlg)->priv->language, "notify::text",
- G_CALLBACK(language_changed),
- header);
-
- g_signal_connect(GTR_HEADER_DIALOG(dlg)->priv->lg_email, "notify::text",
- G_CALLBACK(lg_email_changed),
- header);
-}
+ static GtkWidget *dlg = NULL;
+
+ GtranslatorPo *po;
+ GtranslatorTab *tab;
+ GtranslatorHeader *header;
+ GtkTextBuffer *buffer;
+
+ tab = gtranslator_window_get_active_tab (window);
+ g_return_if_fail (tab != NULL);
+ po = gtranslator_tab_get_po (tab);
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ /*
+ * Get header's values from tab in window
+ */
+ header = gtranslator_window_get_header_from_active_tab (window);
+
+ if (dlg == NULL)
+ {
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_HEADER_DIALOG, NULL));
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+ gtk_widget_show_all (dlg);
+ }
+
+ /*
+ * Connect signal to save header in msg
+ */
+ g_signal_connect_swapped (dlg, "destroy", G_CALLBACK (save_header), po);
+
+ /*
+ * Write header's values on Header dialog
+ */
+ gtranslator_header_dialog_fill_from_header (GTR_HEADER_DIALOG (dlg),
+ header);
+
+ 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_present (GTK_WINDOW (dlg));
+
+ buffer =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (GTR_HEADER_DIALOG (dlg)->priv->prj_comment));
+
+ g_signal_connect (buffer, "changed",
+ G_CALLBACK (prj_comment_changed), header);
+
+ /*
+ * Connect signals to edit Project information on Header dialog
+ */
+ g_signal_connect (GTR_HEADER_DIALOG (dlg)->priv->prj_id_version,
+ "notify::text", G_CALLBACK (prj_id_version_changed),
+ header);
+
+ g_signal_connect (GTR_HEADER_DIALOG (dlg)->priv->rmbt, "notify::text",
+ G_CALLBACK (rmbt_changed), header);
+ /*
+ * Connect signals to edit Translator and Language information on Header dialog
+ */
+ g_signal_connect (GTR_HEADER_DIALOG (dlg)->priv->translator, "notify::text",
+ G_CALLBACK (translator_changed), header);
+
+ g_signal_connect (GTR_HEADER_DIALOG (dlg)->priv->tr_email, "notify::text",
+ G_CALLBACK (tr_email_changed), header);
+
+ g_signal_connect (GTR_HEADER_DIALOG (dlg)->priv->language, "notify::text",
+ G_CALLBACK (language_changed), header);
+
+ g_signal_connect (GTR_HEADER_DIALOG (dlg)->priv->lg_email, "notify::text",
+ G_CALLBACK (lg_email_changed), header);
+}
diff --git a/src/dialogs/header-dialog.h b/src/dialogs/header-dialog.h
index 420f6a9..dcc1f6e 100644
--- a/src/dialogs/header-dialog.h
+++ b/src/dialogs/header-dialog.h
@@ -36,38 +36,40 @@
#define GTR_HEADER_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_HEADER_DIALOG, GtranslatorHeaderDialogClass))
/* Private structure type */
-typedef struct _GtranslatorHeaderDialogPrivate GtranslatorHeaderDialogPrivate;
+typedef struct _GtranslatorHeaderDialogPrivate GtranslatorHeaderDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorHeaderDialog GtranslatorHeaderDialog;
+typedef struct _GtranslatorHeaderDialog GtranslatorHeaderDialog;
struct _GtranslatorHeaderDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorHeaderDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorHeaderDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorHeaderDialogClass GtranslatorHeaderDialogClass;
+typedef struct _GtranslatorHeaderDialogClass GtranslatorHeaderDialogClass;
struct _GtranslatorHeaderDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_header_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_header_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_header_dialog_register_type (GTypeModule * module);
+ GType gtranslator_header_dialog_register_type (GTypeModule * module);
-void gtranslator_show_header_dialog (GtranslatorWindow *window);
+ void gtranslator_show_header_dialog (GtranslatorWindow * window);
#endif
diff --git a/src/dialogs/jump-dialog.c b/src/dialogs/jump-dialog.c
index 8afcd33..da777f8 100644
--- a/src/dialogs/jump-dialog.c
+++ b/src/dialogs/jump-dialog.c
@@ -37,164 +37,151 @@
GtranslatorJumpDialogPrivate))
-G_DEFINE_TYPE(GtranslatorJumpDialog, gtranslator_jump_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GtranslatorJumpDialog, gtranslator_jump_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorJumpDialogPrivate
+ {
+ GtkWidget *main_box;
+ GtkWidget *jump;
-struct _GtranslatorJumpDialogPrivate
-{
- GtkWidget *main_box;
- GtkWidget *jump;
-
- GtranslatorWindow *window;
-};
+ GtranslatorWindow *window;
+ };
-static void
-dialog_response_handler (GtkDialog *dlg,
- gint res_id)
+ static void dialog_response_handler (GtkDialog * dlg, gint res_id)
{
- GtranslatorJumpDialog *dialog = GTR_JUMP_DIALOG (dlg);
- GtranslatorTab *tab;
- gint number;
-
- switch (res_id)
- {
- case GTK_RESPONSE_OK:
- number = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->priv->jump));
- tab = gtranslator_window_get_active_tab (dialog->priv->window);
- gtranslator_tab_go_to_number (tab, number - 1);
- gtk_widget_destroy (GTK_WIDGET (dlg));
- break;
-
- default:
- gtk_widget_destroy (GTK_WIDGET (dlg));
- }
+ GtranslatorJumpDialog *dialog = GTR_JUMP_DIALOG (dlg);
+ GtranslatorTab *tab;
+ gint number;
+
+ switch (res_id)
+ {
+ case GTK_RESPONSE_OK:
+ number =
+ gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
+ (dialog->priv->jump));
+ tab = gtranslator_window_get_active_tab (dialog->priv->window);
+ gtranslator_tab_go_to_number (tab, number - 1);
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ break;
+
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
}
static void
-gtranslator_jump_dialog_init (GtranslatorJumpDialog *dlg)
+gtranslator_jump_dialog_init (GtranslatorJumpDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "adjustment1",
- "main_box",
- NULL
- };
- gchar *path;
-
- dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- GTK_STOCK_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_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Glade*/
- path = gtranslator_utils_get_file_from_pkgdatadir("jump-dialog.ui");
- ret = gtranslator_utils_get_ui_objects (path,
- root_objects,
- &error_widget,
-
- "main_box", &dlg->priv->main_box,
- "jump", &dlg->priv->jump,
-
- NULL);
- g_free(path);
-
- if(!ret)
- {
- gtk_widget_show(error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
-
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "adjustment1",
+ "main_box",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_OK,
+ GTK_RESPONSE_OK,
+ GTK_STOCK_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_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+ path = gtranslator_utils_get_file_from_pkgdatadir ("jump-dialog.ui");
+ ret = gtranslator_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "main_box", &dlg->priv->main_box,
+ "jump", &dlg->priv->jump, NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+
+
}
static void
-gtranslator_jump_dialog_finalize (GObject *object)
+gtranslator_jump_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_jump_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_jump_dialog_parent_class)->finalize (object);
}
static void
-gtranslator_jump_dialog_class_init (GtranslatorJumpDialogClass *klass)
+gtranslator_jump_dialog_class_init (GtranslatorJumpDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorJumpDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorJumpDialogPrivate));
- object_class->finalize = gtranslator_jump_dialog_finalize;
+ object_class->finalize = gtranslator_jump_dialog_finalize;
}
void
-gtranslator_show_jump_dialog (GtranslatorWindow *window)
+gtranslator_show_jump_dialog (GtranslatorWindow * window)
{
- static GtranslatorJumpDialog *dlg = NULL;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- if(dlg == NULL)
- {
- GtranslatorTab *tab;
- GtranslatorPo *po;
- gint messages;
-
- dlg = g_object_new (GTR_TYPE_JUMP_DIALOG, NULL);
-
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
-
- dlg->priv->window = window;
-
- /* Set the maximum number of the spin button */
- tab = gtranslator_window_get_active_tab (window);
- po = gtranslator_tab_get_po (tab);
- messages = gtranslator_po_get_messages_count (po);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (dlg->priv->jump),
- 1.0,
- (gdouble)messages);
-
- gtk_widget_show (GTK_WIDGET(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_present (GTK_WINDOW (dlg));
+ static GtranslatorJumpDialog *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ GtranslatorTab *tab;
+ GtranslatorPo *po;
+ gint messages;
+
+ dlg = g_object_new (GTR_TYPE_JUMP_DIALOG, NULL);
+
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+
+ dlg->priv->window = window;
+
+ /* Set the maximum number of the spin button */
+ tab = gtranslator_window_get_active_tab (window);
+ po = gtranslator_tab_get_po (tab);
+ messages = gtranslator_po_get_messages_count (po);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (dlg->priv->jump),
+ 1.0, (gdouble) messages);
+
+ gtk_widget_show (GTK_WIDGET (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_present (GTK_WINDOW (dlg));
}
diff --git a/src/dialogs/jump-dialog.h b/src/dialogs/jump-dialog.h
index 02d522c..29a2a79 100644
--- a/src/dialogs/jump-dialog.h
+++ b/src/dialogs/jump-dialog.h
@@ -25,7 +25,6 @@
#include "window.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,42 +34,42 @@ 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, GtranslatorJumpDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorJumpDialogPrivate GtranslatorJumpDialogPrivate;
+typedef struct _GtranslatorJumpDialogPrivate GtranslatorJumpDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorJumpDialog GtranslatorJumpDialog;
+typedef struct _GtranslatorJumpDialog GtranslatorJumpDialog;
struct _GtranslatorJumpDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorJumpDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorJumpDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorJumpDialogClass GtranslatorJumpDialogClass;
+typedef struct _GtranslatorJumpDialogClass GtranslatorJumpDialogClass;
struct _GtranslatorJumpDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_jump_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_jump_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_jump_dialog_register_type (GTypeModule * module);
+ GType gtranslator_jump_dialog_register_type (GTypeModule * module);
-void gtranslator_show_jump_dialog (GtranslatorWindow *window);
+ void gtranslator_show_jump_dialog (GtranslatorWindow * window);
G_END_DECLS
-
#endif /* __JUMP_DIALOG_H__ */
diff --git a/src/dialogs/preferences-dialog.c b/src/dialogs/preferences-dialog.c
index 812d2fc..f203b4d 100644
--- a/src/dialogs/preferences-dialog.c
+++ b/src/dialogs/preferences-dialog.c
@@ -50,340 +50,380 @@
GtranslatorPreferencesDialogPrivate))
-G_DEFINE_TYPE(GtranslatorPreferencesDialog, gtranslator_preferences_dialog, GTK_TYPE_DIALOG)
-
-struct _GtranslatorPreferencesDialogPrivate
-{
- GtkWidget *notebook;
-
- /* Files->General */
- GtkWidget *warn_if_contains_fuzzy_checkbutton;
- GtkWidget *delete_compiled_checkbutton;
-
- /* Files->Autosave */
- GtkWidget *autosave_checkbutton;
- GtkWidget *autosave_interval_spinbutton;
- GtkWidget *autosave_hbox;
- GtkWidget *create_backup_checkbutton;
-
- /* 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;
- GtkWidget *spellcheck_checkbutton;
-
- /*Profiles*/
- GtkWidget *profile_treeview;
- GtkWidget *add_button;
- GtkWidget *edit_button;
- GtkWidget *delete_button;
-
- /*Translation Memory*/
- GtkWidget *directory_entry;
- GtkWidget *search_button;
- GtkWidget *add_database_button;
- GtkWidget *add_database_progressbar;
-
- GtkWidget *use_lang_profile_in_tm;
- GtkWidget *tm_lang_entry;
- GtkWidget *missing_words_spinbutton;
- GtkWidget *sentence_length_spinbutton;
-
- /*PO header->Personal information*/
- GtkWidget *name_entry;
- GtkWidget *email_entry;
-
- /*PO header->Language settings*/
- GtkWidget *language_comboentry;
- GtkWidget *langcode_comboentry;
- GtkWidget *charset_comboentry;
- GtkWidget *encoding_comboentry;
- GtkWidget *team_email_comboentry;
- GtkWidget *plurals_entry;
- GtkWidget *number_plurals_spinbutton;
-
- /*Inteface*/
- GtkWidget *gdl_combobox;
- GtkWidget *scheme_color_combobox;
-
- /*Plugins*/
- GtkWidget *plugins_box;
-};
-
-static void setup_profile_pages (GtranslatorPreferencesDialog *dlg);
-
-GtkWidget *
-gtranslator_preferences_dialog_get_treeview (GtranslatorPreferencesDialog *dlg)
+G_DEFINE_TYPE (GtranslatorPreferencesDialog, gtranslator_preferences_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorPreferencesDialogPrivate
+ {
+ GtkWidget *notebook;
+
+ /* Files->General */
+ GtkWidget *warn_if_contains_fuzzy_checkbutton;
+ GtkWidget *delete_compiled_checkbutton;
+
+ /* Files->Autosave */
+ GtkWidget *autosave_checkbutton;
+ GtkWidget *autosave_interval_spinbutton;
+ GtkWidget *autosave_hbox;
+ GtkWidget *create_backup_checkbutton;
+
+ /* 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;
+ GtkWidget *spellcheck_checkbutton;
+
+ /*Profiles */
+ GtkWidget *profile_treeview;
+ GtkWidget *add_button;
+ GtkWidget *edit_button;
+ GtkWidget *delete_button;
+
+ /*Translation Memory */
+ GtkWidget *directory_entry;
+ GtkWidget *search_button;
+ GtkWidget *add_database_button;
+ GtkWidget *add_database_progressbar;
+
+ GtkWidget *use_lang_profile_in_tm;
+ GtkWidget *tm_lang_entry;
+ GtkWidget *missing_words_spinbutton;
+ GtkWidget *sentence_length_spinbutton;
+
+ /*PO header->Personal information */
+ GtkWidget *name_entry;
+ GtkWidget *email_entry;
+
+ /*PO header->Language settings */
+ GtkWidget *language_comboentry;
+ GtkWidget *langcode_comboentry;
+ GtkWidget *charset_comboentry;
+ GtkWidget *encoding_comboentry;
+ GtkWidget *team_email_comboentry;
+ GtkWidget *plurals_entry;
+ GtkWidget *number_plurals_spinbutton;
+
+ /*Inteface */
+ GtkWidget *gdl_combobox;
+ GtkWidget *scheme_color_combobox;
+
+ /*Plugins */
+ GtkWidget *plugins_box;
+ };
+
+ static void setup_profile_pages (GtranslatorPreferencesDialog * dlg);
+
+ GtkWidget
+ *gtranslator_preferences_dialog_get_treeview
+ (GtranslatorPreferencesDialog * dlg)
{
- g_return_val_if_fail (GTR_IS_PREFERENCES_DIALOG (dlg), NULL);
-
- return dlg->priv->profile_treeview;
+ g_return_val_if_fail (GTR_IS_PREFERENCES_DIALOG (dlg), NULL);
+
+ return dlg->priv->profile_treeview;
}
/***************Files pages****************/
static void
-warn_if_contains_fuzzy_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+warn_if_contains_fuzzy_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog *
+ dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->warn_if_contains_fuzzy_checkbutton));
-
- gtranslator_prefs_manager_set_warn_if_contains_fuzzy(gtk_toggle_button_get_active(button));
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->
+ warn_if_contains_fuzzy_checkbutton));
+
+ gtranslator_prefs_manager_set_warn_if_contains_fuzzy
+ (gtk_toggle_button_get_active (button));
}
static void
-delete_compiled_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+delete_compiled_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->delete_compiled_checkbutton));
-
- gtranslator_prefs_manager_set_delete_compiled(gtk_toggle_button_get_active(button));
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->
+ delete_compiled_checkbutton));
+
+ gtranslator_prefs_manager_set_delete_compiled (gtk_toggle_button_get_active
+ (button));
}
static void
-setup_files_general_page(GtranslatorPreferencesDialog *dlg)
-{
- /*Set initial value*/
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->warn_if_contains_fuzzy_checkbutton),
- gtranslator_prefs_manager_get_warn_if_contains_fuzzy());
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->delete_compiled_checkbutton),
- gtranslator_prefs_manager_get_delete_compiled());
-
- /*Connect signals*/
- g_signal_connect(dlg->priv->warn_if_contains_fuzzy_checkbutton, "toggled",
- G_CALLBACK(warn_if_contains_fuzzy_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->delete_compiled_checkbutton, "toggled",
- G_CALLBACK(delete_compiled_checkbutton_toggled),
- dlg);
+setup_files_general_page (GtranslatorPreferencesDialog * dlg)
+{
+ /*Set initial value */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->
+ warn_if_contains_fuzzy_checkbutton),
+ gtranslator_prefs_manager_get_warn_if_contains_fuzzy
+ ());
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->delete_compiled_checkbutton),
+ gtranslator_prefs_manager_get_delete_compiled
+ ());
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->warn_if_contains_fuzzy_checkbutton, "toggled",
+ G_CALLBACK (warn_if_contains_fuzzy_checkbutton_toggled),
+ dlg);
+ g_signal_connect (dlg->priv->delete_compiled_checkbutton, "toggled",
+ G_CALLBACK (delete_compiled_checkbutton_toggled), dlg);
}
static void
-autosave_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+autosave_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- gboolean autosave;
-
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->autosave_checkbutton));
-
- autosave = gtk_toggle_button_get_active(button);
-
- gtk_widget_set_sensitive(dlg->priv->autosave_interval_spinbutton, autosave);
- gtranslator_prefs_manager_set_autosave(autosave);
+ gboolean autosave;
+
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->autosave_checkbutton));
+
+ autosave = gtk_toggle_button_get_active (button);
+
+ gtk_widget_set_sensitive (dlg->priv->autosave_interval_spinbutton,
+ autosave);
+ gtranslator_prefs_manager_set_autosave (autosave);
}
static void
-create_backup_checkbutton_toggled (GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+create_backup_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- gboolean create_backup;
-
- g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->create_backup_checkbutton));
-
- create_backup = gtk_toggle_button_get_active (button);
-
- gtranslator_prefs_manager_set_create_backup (create_backup);
+ gboolean create_backup;
+
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->create_backup_checkbutton));
+
+ create_backup = gtk_toggle_button_get_active (button);
+
+ gtranslator_prefs_manager_set_create_backup (create_backup);
}
static void
-autosave_interval_spinbutton_value_changed(GtkSpinButton *spin_button,
- GtranslatorPreferencesDialog *dlg)
+autosave_interval_spinbutton_value_changed (GtkSpinButton * spin_button,
+ GtranslatorPreferencesDialog *
+ dlg)
{
- g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->autosave_interval_spinbutton));
-
- gtranslator_prefs_manager_set_autosave_interval(gtk_spin_button_get_value_as_int(spin_button));
+ g_return_if_fail (spin_button ==
+ GTK_SPIN_BUTTON (dlg->priv->
+ autosave_interval_spinbutton));
+
+ gtranslator_prefs_manager_set_autosave_interval
+ (gtk_spin_button_get_value_as_int (spin_button));
}
static void
-setup_files_autosave_page(GtranslatorPreferencesDialog *dlg)
+setup_files_autosave_page (GtranslatorPreferencesDialog * dlg)
{
- gboolean autosave, backup;
- gint autosave_interval;
-
- /*Set initial value*/
- autosave = gtranslator_prefs_manager_get_autosave();
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->autosave_checkbutton),
- autosave);
- backup = gtranslator_prefs_manager_get_create_backup ();
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->create_backup_checkbutton),
- backup);
-
- autosave_interval = gtranslator_prefs_manager_get_autosave_interval();
-
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(dlg->priv->autosave_interval_spinbutton),
- autosave_interval);
-
- /*Set sensitive*/
- gtk_widget_set_sensitive(dlg->priv->autosave_interval_spinbutton,
- autosave);
-
- /*Connect signals*/
- g_signal_connect(dlg->priv->autosave_checkbutton, "toggled",
- G_CALLBACK(autosave_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->create_backup_checkbutton, "toggled",
- G_CALLBACK(create_backup_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->autosave_interval_spinbutton, "value-changed",
- G_CALLBACK(autosave_interval_spinbutton_value_changed),
- dlg);
+ gboolean autosave, backup;
+ gint autosave_interval;
+
+ /*Set initial value */
+ autosave = gtranslator_prefs_manager_get_autosave ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->autosave_checkbutton), autosave);
+ backup = gtranslator_prefs_manager_get_create_backup ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->create_backup_checkbutton),
+ backup);
+
+ autosave_interval = gtranslator_prefs_manager_get_autosave_interval ();
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON
+ (dlg->priv->autosave_interval_spinbutton),
+ autosave_interval);
+
+ /*Set sensitive */
+ gtk_widget_set_sensitive (dlg->priv->autosave_interval_spinbutton,
+ autosave);
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->autosave_checkbutton, "toggled",
+ G_CALLBACK (autosave_checkbutton_toggled), dlg);
+ g_signal_connect (dlg->priv->create_backup_checkbutton, "toggled",
+ G_CALLBACK (create_backup_checkbutton_toggled), dlg);
+ g_signal_connect (dlg->priv->autosave_interval_spinbutton, "value-changed",
+ G_CALLBACK (autosave_interval_spinbutton_value_changed),
+ dlg);
}
static void
-setup_files_pages(GtranslatorPreferencesDialog *dlg)
-{
- /*Children*/
- setup_files_general_page(dlg);
- setup_files_autosave_page(dlg);
+setup_files_pages (GtranslatorPreferencesDialog * dlg)
+{
+ /*Children */
+ setup_files_general_page (dlg);
+ setup_files_autosave_page (dlg);
}
/***************Editor pages****************/
static void
-highlight_syntax_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+highlight_syntax_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->highlight_syntax_checkbutton));
-
- gtranslator_prefs_manager_set_highlight_syntax (gtk_toggle_button_get_active(button));
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->
+ highlight_syntax_checkbutton));
+
+ gtranslator_prefs_manager_set_highlight_syntax (gtk_toggle_button_get_active
+ (button));
}
static void
-visible_whitespace_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+visible_whitespace_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->visible_whitespace_checkbutton));
-
- gtranslator_prefs_manager_set_visible_whitespace(gtk_toggle_button_get_active(button));
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->
+ visible_whitespace_checkbutton));
+
+ gtranslator_prefs_manager_set_visible_whitespace
+ (gtk_toggle_button_get_active (button));
}
static void
-use_custom_font_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+use_custom_font_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- gboolean use_custom_font;
-
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->use_custom_font_checkbutton));
-
- use_custom_font = gtk_toggle_button_get_active(button);
-
- gtranslator_prefs_manager_set_use_custom_font(use_custom_font);
-
- gtk_widget_set_sensitive(dlg->priv->editor_font_hbox, use_custom_font);
+ gboolean use_custom_font;
+
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->
+ use_custom_font_checkbutton));
+
+ use_custom_font = gtk_toggle_button_get_active (button);
+
+ gtranslator_prefs_manager_set_use_custom_font (use_custom_font);
+
+ gtk_widget_set_sensitive (dlg->priv->editor_font_hbox, use_custom_font);
}
static void
-editor_font_set(GtkFontButton *button,
- GtranslatorPreferencesDialog *dlg)
+editor_font_set (GtkFontButton * button, GtranslatorPreferencesDialog * dlg)
{
- const gchar *editor_font;
-
- g_return_if_fail(button == GTK_FONT_BUTTON(dlg->priv->editor_font_fontbutton));
-
- editor_font = gtk_font_button_get_font_name(GTK_FONT_BUTTON(dlg->priv->editor_font_fontbutton));
-
- if(editor_font)
- gtranslator_prefs_manager_set_editor_font(editor_font);
- //FIXME:else set default font
+ const gchar *editor_font;
+
+ g_return_if_fail (button ==
+ GTK_FONT_BUTTON (dlg->priv->editor_font_fontbutton));
+
+ editor_font =
+ gtk_font_button_get_font_name (GTK_FONT_BUTTON
+ (dlg->priv->editor_font_fontbutton));
+
+ if (editor_font)
+ gtranslator_prefs_manager_set_editor_font (editor_font);
+ //FIXME:else set default font
}
static void
-setup_editor_text_display_page(GtranslatorPreferencesDialog *dlg)
+setup_editor_text_display_page (GtranslatorPreferencesDialog * dlg)
{
- gboolean use_custom_font;
- const gchar *editor_font;
-
- /*Set initial value*/
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->highlight_syntax_checkbutton),
- gtranslator_prefs_manager_get_highlight_syntax ());
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->visible_whitespace_checkbutton),
- gtranslator_prefs_manager_get_visible_whitespace());
-
- use_custom_font = gtranslator_prefs_manager_get_use_custom_font();
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->use_custom_font_checkbutton),
- use_custom_font);
-
- if(use_custom_font)
- {
- editor_font = gtranslator_prefs_manager_get_editor_font();
- if(editor_font)
- gtk_font_button_set_font_name(GTK_FONT_BUTTON(dlg->priv->editor_font_fontbutton),
- editor_font);
- //else FIXME: I think i need to set the system font (maybe Sans 12?)
- }
-
- /*Set sensitive*/
- gtk_widget_set_sensitive(dlg->priv->editor_font_hbox, use_custom_font);
-
- /*Connect signals*/
- g_signal_connect(dlg->priv->highlight_syntax_checkbutton, "toggled",
- G_CALLBACK(highlight_syntax_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->visible_whitespace_checkbutton, "toggled",
- G_CALLBACK(visible_whitespace_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->use_custom_font_checkbutton, "toggled",
- G_CALLBACK(use_custom_font_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->editor_font_fontbutton, "font-set",
- G_CALLBACK(editor_font_set),
- dlg);
+ gboolean use_custom_font;
+ const gchar *editor_font;
+
+ /*Set initial value */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->highlight_syntax_checkbutton),
+ gtranslator_prefs_manager_get_highlight_syntax
+ ());
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->visible_whitespace_checkbutton),
+ gtranslator_prefs_manager_get_visible_whitespace
+ ());
+
+ use_custom_font = gtranslator_prefs_manager_get_use_custom_font ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->use_custom_font_checkbutton),
+ use_custom_font);
+
+ if (use_custom_font)
+ {
+ editor_font = gtranslator_prefs_manager_get_editor_font ();
+ if (editor_font)
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON
+ (dlg->priv->editor_font_fontbutton),
+ editor_font);
+ //else FIXME: I think i need to set the system font (maybe Sans 12?)
+ }
+
+ /*Set sensitive */
+ gtk_widget_set_sensitive (dlg->priv->editor_font_hbox, use_custom_font);
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->highlight_syntax_checkbutton, "toggled",
+ G_CALLBACK (highlight_syntax_checkbutton_toggled), dlg);
+ g_signal_connect (dlg->priv->visible_whitespace_checkbutton, "toggled",
+ G_CALLBACK (visible_whitespace_checkbutton_toggled), dlg);
+ g_signal_connect (dlg->priv->use_custom_font_checkbutton, "toggled",
+ G_CALLBACK (use_custom_font_checkbutton_toggled), dlg);
+ g_signal_connect (dlg->priv->editor_font_fontbutton, "font-set",
+ G_CALLBACK (editor_font_set), dlg);
}
static void
-unmark_fuzzy_when_changed_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+unmark_fuzzy_when_changed_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog *
+ dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->unmark_fuzzy_when_changed_checkbutton));
-
- gtranslator_prefs_manager_set_unmark_fuzzy_when_changed (gtk_toggle_button_get_active(button));
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->
+ unmark_fuzzy_when_changed_checkbutton));
+
+ gtranslator_prefs_manager_set_unmark_fuzzy_when_changed
+ (gtk_toggle_button_get_active (button));
}
static void
-spellcheck_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorPreferencesDialog *dlg)
+spellcheck_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
- g_return_if_fail(button == GTK_TOGGLE_BUTTON(dlg->priv->spellcheck_checkbutton));
-
- gtranslator_prefs_manager_set_spellcheck(gtk_toggle_button_get_active(button));
+ g_return_if_fail (button ==
+ GTK_TOGGLE_BUTTON (dlg->priv->spellcheck_checkbutton));
+
+ gtranslator_prefs_manager_set_spellcheck (gtk_toggle_button_get_active
+ (button));
}
static void
-setup_editor_contents(GtranslatorPreferencesDialog *dlg)
-{
- /*Set initial values*/
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->unmark_fuzzy_when_changed_checkbutton),
- gtranslator_prefs_manager_get_unmark_fuzzy_when_changed());
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->spellcheck_checkbutton),
- gtranslator_prefs_manager_get_spellcheck());
-
- /*Connect signals*/
- g_signal_connect(dlg->priv->unmark_fuzzy_when_changed_checkbutton, "toggled",
- G_CALLBACK(unmark_fuzzy_when_changed_checkbutton_toggled),
- dlg);
- g_signal_connect(dlg->priv->spellcheck_checkbutton, "toggled",
- G_CALLBACK(spellcheck_checkbutton_toggled),
- dlg);
+setup_editor_contents (GtranslatorPreferencesDialog * dlg)
+{
+ /*Set initial values */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->
+ unmark_fuzzy_when_changed_checkbutton),
+ gtranslator_prefs_manager_get_unmark_fuzzy_when_changed
+ ());
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->spellcheck_checkbutton),
+ gtranslator_prefs_manager_get_spellcheck ());
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->unmark_fuzzy_when_changed_checkbutton,
+ "toggled",
+ G_CALLBACK
+ (unmark_fuzzy_when_changed_checkbutton_toggled), dlg);
+ g_signal_connect (dlg->priv->spellcheck_checkbutton, "toggled",
+ G_CALLBACK (spellcheck_checkbutton_toggled), dlg);
}
static void
-setup_editor_pages(GtranslatorPreferencesDialog *dlg)
-{
- /*Children*/
- setup_editor_text_display_page(dlg);
- setup_editor_contents(dlg);
+setup_editor_pages (GtranslatorPreferencesDialog * dlg)
+{
+ /*Children */
+ setup_editor_text_display_page (dlg);
+ setup_editor_contents (dlg);
}
/***************Profile pages****************/
static void
-active_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path_str,
- GtranslatorPreferencesDialog *dlg)
+active_toggled_cb (GtkCellRendererToggle * cell_renderer,
+ gchar * path_str, GtranslatorPreferencesDialog * dlg)
{
GtkTreeIter iter;
GtkTreePath *path;
@@ -398,366 +438,366 @@ active_toggled_cb (GtkCellRendererToggle *cell_renderer,
config_folder = gtranslator_utils_get_user_config_dir ();
- filename = g_build_filename (config_folder,
- "profiles.xml",
- NULL);
+ filename = g_build_filename (config_folder, "profiles.xml", NULL);
file = g_file_new_for_path (filename);
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 (dlg->priv->profile_treeview));
g_return_if_fail (model != NULL);
-
+
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, TOGGLE_COL, &active, -1);
-
- if (!active) {
-
- old_profile_active = gtranslator_application_get_active_profile (GTR_APP);
-
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- TRUE,
- TOGGLE_COL,
- -1);
-
- gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
- profiles_list = gtranslator_application_get_profiles (GTR_APP);
-
- for (l = profiles_list; l; l = l->next) {
- GtranslatorProfile *profile;
- profile = (GtranslatorProfile *)l->data;
- if (!strcmp (gtranslator_profile_get_name (profile), profile_row)) {
- gtranslator_application_set_active_profile (GTR_APP, profile);
- }
+
+ if (!active)
+ {
+
+ old_profile_active =
+ gtranslator_application_get_active_profile (GTR_APP);
+
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter, TRUE, TOGGLE_COL, -1);
+
+ gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
+ profiles_list = gtranslator_application_get_profiles (GTR_APP);
+
+ for (l = profiles_list; l; l = l->next)
+ {
+ GtranslatorProfile *profile;
+ profile = (GtranslatorProfile *) l->data;
+ if (!strcmp (gtranslator_profile_get_name (profile), profile_row))
+ {
+ gtranslator_application_set_active_profile (GTR_APP, profile);
+ }
+ }
}
- }
- gtk_list_store_clear (GTK_LIST_STORE(model));
+ gtk_list_store_clear (GTK_LIST_STORE (model));
gtranslator_preferences_fill_profile_treeview (dlg, model);
gtk_tree_path_free (path);
}
-void gtranslator_preferences_fill_profile_treeview (GtranslatorPreferencesDialog *dlg,
- GtkTreeModel *model)
+void
+gtranslator_preferences_fill_profile_treeview (GtranslatorPreferencesDialog *
+ dlg, GtkTreeModel * model)
{
GtkTreeIter iter;
GtranslatorProfile *active_profile;
GList *l = NULL, *profiles_list = NULL;
gtk_list_store_clear (GTK_LIST_STORE (model));
-
+
profiles_list = gtranslator_application_get_profiles (GTR_APP);
-
+
active_profile = gtranslator_application_get_active_profile (GTR_APP);
-
- for (l = profiles_list; l; l = l->next) {
-
- GtranslatorProfile *profile;
- const gchar *profile_name;
-
- profile = (GtranslatorProfile *)l->data;
-
- profile_name = gtranslator_profile_get_name (profile);
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
- if (!strcmp (gtranslator_profile_get_name (active_profile), profile_name)) {
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- PROFILE_NAME_COL,
- profile_name,
- TOGGLE_COL,
- TRUE,
- -1);
- } else {
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- PROFILE_NAME_COL,
- profile_name,
- -1);
+
+ for (l = profiles_list; l; l = l->next)
+ {
+
+ GtranslatorProfile *profile;
+ const gchar *profile_name;
+
+ profile = (GtranslatorProfile *) l->data;
+
+ profile_name = gtranslator_profile_get_name (profile);
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ if (!strcmp
+ (gtranslator_profile_get_name (active_profile), profile_name))
+ {
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ PROFILE_NAME_COL,
+ profile_name, TOGGLE_COL, TRUE, -1);
+ }
+ else
+ {
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter, PROFILE_NAME_COL, profile_name, -1);
+ }
}
- }
}
static void
-setup_profile_pages (GtranslatorPreferencesDialog *dlg)
+setup_profile_pages (GtranslatorPreferencesDialog * dlg)
{
-
+
GtkTreeViewColumn *name_column, *toggle_column;
GtkCellRenderer *text_renderer, *toggle_renderer;
GtkListStore *model;
-
- model = gtk_list_store_new (N_COLUMNS_PROFILES, G_TYPE_STRING, G_TYPE_BOOLEAN);
+
+ model =
+ gtk_list_store_new (N_COLUMNS_PROFILES, G_TYPE_STRING, G_TYPE_BOOLEAN);
gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->profile_treeview),
- GTK_TREE_MODEL (model));
+ GTK_TREE_MODEL (model));
g_object_unref (model);
-
+
text_renderer = gtk_cell_renderer_text_new ();
toggle_renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect (toggle_renderer,
- "toggled",
- G_CALLBACK (active_toggled_cb),
- dlg);
+ "toggled", G_CALLBACK (active_toggled_cb), dlg);
g_object_set (toggle_renderer,
- "mode",
- GTK_CELL_RENDERER_MODE_ACTIVATABLE,
- NULL);
+ "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
name_column = gtk_tree_view_column_new_with_attributes (_("Profile"),
- text_renderer,
- "text",
- PROFILE_NAME_COL,
- NULL);
-
+ text_renderer,
+ "text",
+ PROFILE_NAME_COL,
+ NULL);
+
toggle_column = gtk_tree_view_column_new_with_attributes (_("Active"),
toggle_renderer,
"active",
- TOGGLE_COL,
- NULL);
+ TOGGLE_COL, NULL);
gtk_tree_view_column_set_resizable (toggle_column, TRUE);
gtk_tree_view_column_set_resizable (name_column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview), name_column);
- gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview), toggle_column);
-
- g_object_set (name_column,
- "expand",
- TRUE,
- NULL);
-
- gtranslator_preferences_fill_profile_treeview (dlg,GTK_TREE_MODEL(model));
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview),
+ name_column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->profile_treeview),
+ toggle_column);
+
+ g_object_set (name_column, "expand", TRUE, NULL);
+
+ gtranslator_preferences_fill_profile_treeview (dlg, GTK_TREE_MODEL (model));
}
/***************Interface pages****************/
static void
-style_changed_cb (GtkComboBox *combobox,
- GtranslatorPreferencesDialog *dlg)
+style_changed_cb (GtkComboBox * combobox, GtranslatorPreferencesDialog * dlg)
{
- g_return_if_fail(combobox == GTK_COMBO_BOX(dlg->priv->gdl_combobox));
-
- gtranslator_prefs_manager_set_color_scheme (gtk_combo_box_get_active_text (combobox));
+ g_return_if_fail (combobox == GTK_COMBO_BOX (dlg->priv->gdl_combobox));
+
+ gtranslator_prefs_manager_set_color_scheme (gtk_combo_box_get_active_text
+ (combobox));
}
static void
-scheme_color_changed_cb (GtkComboBox *combobox,
- GtranslatorPreferencesDialog *dlg)
+scheme_color_changed_cb (GtkComboBox * combobox,
+ GtranslatorPreferencesDialog * dlg)
{
- g_return_if_fail (combobox == GTK_COMBO_BOX (dlg->priv->scheme_color_combobox));
-
- gtranslator_prefs_manager_set_color_scheme (gtk_combo_box_get_active_text (combobox));
+ g_return_if_fail (combobox ==
+ GTK_COMBO_BOX (dlg->priv->scheme_color_combobox));
+
+ gtranslator_prefs_manager_set_color_scheme (gtk_combo_box_get_active_text
+ (combobox));
}
static void
-setup_interface_pages(GtranslatorPreferencesDialog *dlg)
+setup_interface_pages (GtranslatorPreferencesDialog * dlg)
{
- gint pane_switcher_style;
- GtkSourceStyleSchemeManager *manager;
- const gchar * const *scheme_ids;
- const gchar * scheme_active;
- gint i = 0;
- GtkListStore *store;
- GtkCellRenderer *cell;
-
- /*Set initial value*/
- pane_switcher_style = gtranslator_prefs_manager_get_pane_switcher_style ();
- if (pane_switcher_style)
- gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->priv->gdl_combobox),
- pane_switcher_style);
- /*
- * Scheme color
- */
- store = gtk_list_store_new (1, G_TYPE_STRING);
- gtk_combo_box_set_model (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
- GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dlg->priv->scheme_color_combobox),
- cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dlg->priv->scheme_color_combobox),
- cell, "text", 0,
- NULL);
-
- manager = gtk_source_style_scheme_manager_get_default ();
- scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
- scheme_active = gtranslator_prefs_manager_get_color_scheme ();
- while (scheme_ids [i] != NULL)
- {
- gtk_combo_box_append_text (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
- scheme_ids[i]);
- if (g_strcmp0 (scheme_ids[i], scheme_active) == 0)
- gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
- i);
- i++;
- }
-
- /*Connect signals*/
- g_signal_connect (dlg->priv->gdl_combobox, "changed",
- G_CALLBACK (style_changed_cb),
- dlg);
- g_signal_connect (dlg->priv->scheme_color_combobox, "changed",
- G_CALLBACK (scheme_color_changed_cb),
- dlg);
+ gint pane_switcher_style;
+ GtkSourceStyleSchemeManager *manager;
+ const gchar *const *scheme_ids;
+ const gchar *scheme_active;
+ gint i = 0;
+ GtkListStore *store;
+ GtkCellRenderer *cell;
+
+ /*Set initial value */
+ pane_switcher_style = gtranslator_prefs_manager_get_pane_switcher_style ();
+ if (pane_switcher_style)
+ gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->priv->gdl_combobox),
+ pane_switcher_style);
+ /*
+ * Scheme color
+ */
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
+ GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT
+ (dlg->priv->scheme_color_combobox), cell, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT
+ (dlg->priv->scheme_color_combobox), cell,
+ "text", 0, NULL);
+
+ manager = gtk_source_style_scheme_manager_get_default ();
+ scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
+ scheme_active = gtranslator_prefs_manager_get_color_scheme ();
+ while (scheme_ids[i] != NULL)
+ {
+ gtk_combo_box_append_text (GTK_COMBO_BOX
+ (dlg->priv->scheme_color_combobox),
+ scheme_ids[i]);
+ if (g_strcmp0 (scheme_ids[i], scheme_active) == 0)
+ gtk_combo_box_set_active (GTK_COMBO_BOX
+ (dlg->priv->scheme_color_combobox), i);
+ i++;
+ }
+
+ /*Connect signals */
+ g_signal_connect (dlg->priv->gdl_combobox, "changed",
+ G_CALLBACK (style_changed_cb), dlg);
+ g_signal_connect (dlg->priv->scheme_color_combobox, "changed",
+ G_CALLBACK (scheme_color_changed_cb), dlg);
}
/***************Translation Memory pages****************/
static void
-response_filechooser_cb (GtkDialog *dialog,
- gint response_id,
- gpointer user_data)
+response_filechooser_cb (GtkDialog * dialog,
+ gint response_id, gpointer user_data)
{
GtranslatorPreferencesDialog *dlg;
- dlg = (GtranslatorPreferencesDialog *)user_data;
-
-
- if (response_id == GTK_RESPONSE_YES) {
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->directory_entry),
- gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)));
- gtranslator_prefs_manager_set_po_directory (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)));
- gtk_widget_destroy (GTK_WIDGET (dialog));
- } else {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- }
+ dlg = (GtranslatorPreferencesDialog *) user_data;
+
+
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->directory_entry),
+ gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
+ (dialog)));
+ gtranslator_prefs_manager_set_po_directory
+ (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+ else
+ {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
}
static void
-on_search_button_pulsed (GtkButton *button,
- gpointer data)
+on_search_button_pulsed (GtkButton * button, gpointer data)
{
GtkWidget *filechooser;
GtranslatorPreferencesDialog *dlg;
- dlg = (GtranslatorPreferencesDialog *)data;
-
+ dlg = (GtranslatorPreferencesDialog *) data;
+
filechooser = gtk_file_chooser_dialog_new ("Select PO directory",
GTK_WINDOW (dlg),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OK,
- GTK_RESPONSE_YES,
- NULL);
-
+ GTK_RESPONSE_YES, NULL);
+
g_signal_connect (GTK_DIALOG (filechooser), "response",
- G_CALLBACK (response_filechooser_cb),
- dlg);
+ G_CALLBACK (response_filechooser_cb), dlg);
gtk_dialog_run (GTK_DIALOG (filechooser));
}
typedef struct _IdleData
{
- GSList *list;
- GtkProgressBar *progress;
- GtranslatorTranslationMemory *tm;
- GtkWindow *parent;
-}IdleData;
+ GSList *list;
+ GtkProgressBar *progress;
+ GtranslatorTranslationMemory *tm;
+ GtkWindow *parent;
+} IdleData;
static gboolean
add_to_database (gpointer data_pointer)
{
- IdleData *data = (IdleData *)data_pointer;
- static GSList *l = NULL;
- gdouble percentage;
-
- if (l == NULL)
- l = data->list;
- else
- l = g_slist_next (l);
-
- if (l)
- {
- GList *msg_list = NULL;
- GList *l2 = NULL;
- GFile *location;
- GError *error = NULL;
- GtranslatorPo *po;
-
- po = gtranslator_po_new ();
- location = (GFile *)l->data;
-
- gtranslator_po_parse (po, location, &error);
- if (error)
- return TRUE;
-
- msg_list = gtranslator_po_get_messages (po);
-
- for (l2 = msg_list; l2; l2 = l2->next) {
- GtranslatorMsg *msg;
- msg = GTR_MSG (l2->data);
- if (gtranslator_msg_is_translated (msg))
- gtranslator_translation_memory_store (data->tm,
- gtranslator_msg_get_msgid (msg),
- gtranslator_msg_get_msgstr (msg));
- }
-
- g_object_unref (po);
- }
- else
- {
- GtkWidget *dialog;
-
- gtk_progress_bar_set_fraction (data->progress,
- 1.0);
-
- dialog = gtk_message_dialog_new (data->parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- NULL);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return FALSE;
- }
-
- percentage = (gdouble)g_slist_position (data->list, l) / (gdouble) g_slist_length (data->list);
+ IdleData *data = (IdleData *) data_pointer;
+ static GSList *l = NULL;
+ gdouble percentage;
+
+ if (l == NULL)
+ l = data->list;
+ else
+ l = g_slist_next (l);
+
+ if (l)
+ {
+ GList *msg_list = NULL;
+ GList *l2 = NULL;
+ GFile *location;
+ GError *error = NULL;
+ GtranslatorPo *po;
- /*
- * Set the progress only if the values are reasonable.
- */
- if(percentage > 0.0 || percentage < 1.0)
+ po = gtranslator_po_new ();
+ location = (GFile *) l->data;
+
+ gtranslator_po_parse (po, location, &error);
+ if (error)
+ return TRUE;
+
+ msg_list = gtranslator_po_get_messages (po);
+
+ for (l2 = msg_list; l2; l2 = l2->next)
{
- /*
- * Set the progressbar status.
- */
- gtk_progress_bar_set_fraction (data->progress,
- percentage);
+ GtranslatorMsg *msg;
+ msg = GTR_MSG (l2->data);
+ if (gtranslator_msg_is_translated (msg))
+ gtranslator_translation_memory_store (data->tm,
+ gtranslator_msg_get_msgid
+ (msg),
+ gtranslator_msg_get_msgstr
+ (msg));
}
-
- return TRUE;
+
+ g_object_unref (po);
+ }
+ else
+ {
+ GtkWidget *dialog;
+
+ gtk_progress_bar_set_fraction (data->progress, 1.0);
+
+ dialog = gtk_message_dialog_new (data->parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("<span weight=\"bold\" size=\"large\">Strings added to database</span>"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return FALSE;
+ }
+
+ percentage =
+ (gdouble) g_slist_position (data->list,
+ l) / (gdouble) g_slist_length (data->list);
+
+ /*
+ * Set the progress only if the values are reasonable.
+ */
+ if (percentage > 0.0 || percentage < 1.0)
+ {
+ /*
+ * Set the progressbar status.
+ */
+ gtk_progress_bar_set_fraction (data->progress, percentage);
+ }
+
+ return TRUE;
}
static void
destroy_idle_data (gpointer data)
{
- IdleData *d = (IdleData *)data;
-
- gtk_widget_hide (GTK_WIDGET (d->progress));
- g_slist_foreach (d->list, (GFunc)g_object_unref, NULL);
- g_slist_free (d->list);
-
- g_free (d);
+ IdleData *d = (IdleData *) data;
+
+ gtk_widget_hide (GTK_WIDGET (d->progress));
+ g_slist_foreach (d->list, (GFunc) g_object_unref, NULL);
+ g_slist_free (d->list);
+
+ g_free (d);
}
static void
-on_add_database_button_pulsed (GtkButton *button,
- GtranslatorPreferencesDialog *dlg)
+on_add_database_button_pulsed (GtkButton * button,
+ GtranslatorPreferencesDialog * dlg)
{
GFile *dir;
const gchar *dir_name;
IdleData *data;
-
+
data = g_new0 (IdleData, 1);
data->list = NULL;
@@ -766,49 +806,53 @@ on_add_database_button_pulsed (GtkButton *button,
dir = g_file_new_for_path (dir_name);
if (gtranslator_prefs_manager_get_restrict_to_filename ())
- gtranslator_utils_scan_dir (dir, &data->list, gtranslator_prefs_manager_get_filename_restriction());
+ gtranslator_utils_scan_dir (dir, &data->list,
+ gtranslator_prefs_manager_get_filename_restriction
+ ());
else
gtranslator_utils_scan_dir (dir, &data->list, NULL);
-
- data->tm = GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory (GTR_APP));
+
+ data->tm =
+ GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory
+ (GTR_APP));
data->progress = GTK_PROGRESS_BAR (dlg->priv->add_database_progressbar);
data->parent = GTK_WINDOW (dlg);
gtk_widget_show (dlg->priv->add_database_progressbar);
g_idle_add_full (G_PRIORITY_HIGH_IDLE + 30,
- (GSourceFunc)add_to_database,
- data,
- (GDestroyNotify)destroy_idle_data);
-
- g_object_unref (dir);
+ (GSourceFunc) add_to_database,
+ data, (GDestroyNotify) destroy_idle_data);
+
+ g_object_unref (dir);
}
static void
-on_use_lang_profile_checkbutton_changed (GtkToggleButton *button,
+on_use_lang_profile_checkbutton_changed (GtkToggleButton * button,
gpointer user_data)
-{
- gtranslator_prefs_manager_set_restrict_to_filename (gtk_toggle_button_get_active(button));
+{
+ gtranslator_prefs_manager_set_restrict_to_filename
+ (gtk_toggle_button_get_active (button));
}
static void
-tm_lang_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorPreferencesDialog *dlg)
+tm_lang_entry_changed (GObject * gobject,
+ GParamSpec * arg1, GtranslatorPreferencesDialog * dlg)
{
- const gchar *text;
-
- g_return_if_fail(GTK_ENTRY(gobject) == GTK_ENTRY(dlg->priv->tm_lang_entry));
-
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
-
- if(text)
- gtranslator_prefs_manager_set_filename_restriction (text);
+ const gchar *text;
+
+ g_return_if_fail (GTK_ENTRY (gobject) ==
+ GTK_ENTRY (dlg->priv->tm_lang_entry));
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_prefs_manager_set_filename_restriction (text);
}
static void
-on_missing_words_spinbutton_changed (GtkSpinButton *spinbutton,
- gpointer data)
+on_missing_words_spinbutton_changed (GtkSpinButton * spinbutton,
+ gpointer data)
{
gint value;
@@ -818,8 +862,8 @@ on_missing_words_spinbutton_changed (GtkSpinButton *spinbutton,
}
static void
-on_sentence_length_spinbutton_changed (GtkSpinButton *spinbutton,
- gpointer data)
+on_sentence_length_spinbutton_changed (GtkSpinButton * spinbutton,
+ gpointer data)
{
gint value;
@@ -829,129 +873,129 @@ on_sentence_length_spinbutton_changed (GtkSpinButton *spinbutton,
}
static void
-directory_entry_changed(GObject *gobject,
- GParamSpec *arg1,
- GtranslatorPreferencesDialog *dlg)
+directory_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorPreferencesDialog * dlg)
{
- const gchar *text;
-
- g_return_if_fail(GTK_ENTRY(gobject) == GTK_ENTRY(dlg->priv->directory_entry));
-
- text = gtk_entry_get_text(GTK_ENTRY(gobject));
-
- if(text)
- gtranslator_prefs_manager_set_po_directory (text);
+ const gchar *text;
+
+ g_return_if_fail (GTK_ENTRY (gobject) ==
+ GTK_ENTRY (dlg->priv->directory_entry));
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_prefs_manager_set_po_directory (text);
}
static void
-setup_tm_pages(GtranslatorPreferencesDialog *dlg)
+setup_tm_pages (GtranslatorPreferencesDialog * dlg)
{
GtranslatorProfile *profile;
const gchar *language_code;
const gchar *filename = NULL;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->use_lang_profile_in_tm),
- gtranslator_prefs_manager_get_restrict_to_filename ());
-
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->use_lang_profile_in_tm),
+ gtranslator_prefs_manager_get_restrict_to_filename
+ ());
+
profile = gtranslator_application_get_active_profile (GTR_APP);
-
- if (profile != NULL) {
- language_code = gtranslator_profile_get_language_code (profile);
- filename = (const gchar*)g_strconcat (language_code, ".po", NULL);
-
- gtk_entry_set_text (GTK_ENTRY (dlg->priv->tm_lang_entry),
- filename);
- }
-
+
+ if (profile != NULL)
+ {
+ language_code = gtranslator_profile_get_language_code (profile);
+ filename = (const gchar *) g_strconcat (language_code, ".po", NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (dlg->priv->tm_lang_entry), filename);
+ }
+
if (filename != NULL)
gtranslator_prefs_manager_set_filename_restriction (filename);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->missing_words_spinbutton),
- (gdouble) gtranslator_prefs_manager_get_max_missing_words ());
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->sentence_length_spinbutton),
- (gdouble) gtranslator_prefs_manager_get_max_length_diff ());
-
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON
+ (dlg->priv->missing_words_spinbutton),
+ (gdouble)
+ gtranslator_prefs_manager_get_max_missing_words
+ ());
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON
+ (dlg->priv->sentence_length_spinbutton),
+ (gdouble)
+ gtranslator_prefs_manager_get_max_length_diff
+ ());
+
g_signal_connect (GTK_BUTTON (dlg->priv->search_button), "clicked",
- G_CALLBACK (on_search_button_pulsed),
- dlg);
+ G_CALLBACK (on_search_button_pulsed), dlg);
+
+ g_signal_connect (dlg->priv->directory_entry, "notify::text",
+ G_CALLBACK (directory_entry_changed), dlg);
+
+ g_signal_connect (dlg->priv->tm_lang_entry, "notify::text",
+ G_CALLBACK (tm_lang_entry_changed), dlg);
- g_signal_connect(dlg->priv->directory_entry, "notify::text",
- G_CALLBACK(directory_entry_changed),
- dlg);
-
- g_signal_connect(dlg->priv->tm_lang_entry, "notify::text",
- G_CALLBACK(tm_lang_entry_changed),
- dlg);
-
g_signal_connect (GTK_BUTTON (dlg->priv->add_database_button), "clicked",
- G_CALLBACK (on_add_database_button_pulsed),
- dlg);
+ G_CALLBACK (on_add_database_button_pulsed), dlg);
- g_signal_connect (GTK_TOGGLE_BUTTON (dlg->priv->use_lang_profile_in_tm), "toggled",
+ g_signal_connect (GTK_TOGGLE_BUTTON (dlg->priv->use_lang_profile_in_tm),
+ "toggled",
G_CALLBACK (on_use_lang_profile_checkbutton_changed),
dlg);
- g_signal_connect (GTK_SPIN_BUTTON (dlg->priv->missing_words_spinbutton), "value-changed",
- G_CALLBACK (on_missing_words_spinbutton_changed),
- dlg);
-
- g_signal_connect (GTK_SPIN_BUTTON (dlg->priv->sentence_length_spinbutton), "value-changed",
- G_CALLBACK (on_sentence_length_spinbutton_changed),
- dlg);
+ g_signal_connect (GTK_SPIN_BUTTON (dlg->priv->missing_words_spinbutton),
+ "value-changed",
+ G_CALLBACK (on_missing_words_spinbutton_changed), dlg);
- g_free ((gpointer)filename);
+ g_signal_connect (GTK_SPIN_BUTTON (dlg->priv->sentence_length_spinbutton),
+ "value-changed",
+ G_CALLBACK (on_sentence_length_spinbutton_changed), dlg);
+
+ g_free ((gpointer) filename);
}
/***************Plugins pages****************/
static void
-setup_plugin_pages(GtranslatorPreferencesDialog *dlg)
+setup_plugin_pages (GtranslatorPreferencesDialog * dlg)
{
- GtkWidget *alignment;
- GtkWidget *page_content;
+ GtkWidget *alignment;
+ GtkWidget *page_content;
+
+ alignment = gtk_alignment_new (0., 0., 1., 1.);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
- alignment = gtk_alignment_new (0., 0., 1., 1.);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);
-
- page_content = gtranslator_plugin_manager_new ();
- g_return_if_fail (page_content != NULL);
+ page_content = gtranslator_plugin_manager_new ();
+ g_return_if_fail (page_content != NULL);
- gtk_container_add (GTK_CONTAINER (alignment), page_content);
+ gtk_container_add (GTK_CONTAINER (alignment), page_content);
- gtk_box_pack_start (GTK_BOX (dlg->priv->plugins_box),
- alignment,
- TRUE,
- TRUE,
- 0);
+ gtk_box_pack_start (GTK_BOX (dlg->priv->plugins_box),
+ alignment, TRUE, TRUE, 0);
- gtk_widget_show_all (page_content);
+ gtk_widget_show_all (page_content);
}
static void
-dialog_response_handler (GtkDialog *dlg,
- gint res_id)
+dialog_response_handler (GtkDialog * dlg, gint res_id)
{
- switch (res_id)
- {
- default:
- gtk_widget_destroy (GTK_WIDGET(dlg));
- }
+ switch (res_id)
+ {
+ default:
+ gtk_widget_destroy (GTK_WIDGET (dlg));
+ }
}
static void
-add_button_pulsed (GtkWidget *button,
- GtranslatorPreferencesDialog *dlg)
+add_button_pulsed (GtkWidget * button, GtranslatorPreferencesDialog * dlg)
{
GtranslatorProfile *profile;
profile = gtranslator_profile_new ();
- gtranslator_show_profile_dialog(dlg, profile, NEW_PROFILE);
+ gtranslator_show_profile_dialog (dlg, profile, NEW_PROFILE);
}
static void
-edit_button_pulsed (GtkWidget *button,
- GtranslatorPreferencesDialog *dlg)
+edit_button_pulsed (GtkWidget * button, GtranslatorPreferencesDialog * dlg)
{
GtkTreeIter iter;
GtkTreeModel *model;
@@ -961,35 +1005,40 @@ edit_button_pulsed (GtkWidget *button,
GtranslatorProfile *edited_profile = NULL;
GtranslatorProfile *active_profile;
GList *profiles_list = NULL, *l = NULL;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ model =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
g_return_if_fail (model != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-
- gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
-
- profiles_list = gtranslator_application_get_profiles (GTR_APP);
- active_profile = gtranslator_application_get_active_profile (GTR_APP);
-
- for (l = profiles_list; l; l = l->next) {
- GtranslatorProfile *profile;
- profile = (GtranslatorProfile *)l->data;
- if (!strcmp (gtranslator_profile_get_name (profile), profile_row)) {
- old_profile_name = gtranslator_profile_get_name (profile);
- edited_profile = profile;
- }
+
+ selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+
+ gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
+
+ profiles_list = gtranslator_application_get_profiles (GTR_APP);
+ active_profile = gtranslator_application_get_active_profile (GTR_APP);
+
+ for (l = profiles_list; l; l = l->next)
+ {
+ GtranslatorProfile *profile;
+ profile = (GtranslatorProfile *) l->data;
+ if (!strcmp (gtranslator_profile_get_name (profile), profile_row))
+ {
+ old_profile_name = gtranslator_profile_get_name (profile);
+ edited_profile = profile;
+ }
+ }
+ gtranslator_show_profile_dialog (dlg, edited_profile, EDIT_PROFILE);
}
- gtranslator_show_profile_dialog (dlg, edited_profile, EDIT_PROFILE);
- }
}
static void
-delete_confirm_dialog_cb (GtkWidget *dialog,
+delete_confirm_dialog_cb (GtkWidget * dialog,
gint response_id,
- GtranslatorPreferencesDialog *dlg)
+ GtranslatorPreferencesDialog * dlg)
{
GtkTreeIter iter;
GtkTreeModel *model;
@@ -998,37 +1047,47 @@ delete_confirm_dialog_cb (GtkWidget *dialog,
GList *profiles_list = NULL, *l = NULL;
GList *new_list = NULL;
- if (response_id == GTK_RESPONSE_YES) {
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
- g_return_if_fail (model != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-
- gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
-
- profiles_list = gtranslator_application_get_profiles (GTR_APP);
-
- for (l = profiles_list; l; l = l->next) {
- GtranslatorProfile *profile;
- profile = (GtranslatorProfile *)l->data;
- if (!strcmp (gtranslator_profile_get_name (profile), profile_row)) {
- new_list = g_list_remove (profiles_list, profile);
- gtranslator_application_set_profiles (GTR_APP, new_list);
+ if (response_id == GTK_RESPONSE_YES)
+ {
+ model =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ g_return_if_fail (model != NULL);
+
+ selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW
+ (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+
+ gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row,
+ -1);
+
+ profiles_list = gtranslator_application_get_profiles (GTR_APP);
+
+ for (l = profiles_list; l; l = l->next)
+ {
+ GtranslatorProfile *profile;
+ profile = (GtranslatorProfile *) l->data;
+ if (!strcmp
+ (gtranslator_profile_get_name (profile), profile_row))
+ {
+ new_list = g_list_remove (profiles_list, profile);
+ gtranslator_application_set_profiles (GTR_APP, new_list);
+ }
+ }
+ gtranslator_preferences_fill_profile_treeview (dlg, model);
}
- }
- gtranslator_preferences_fill_profile_treeview (dlg, model);
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ gtk_widget_destroy (dialog);
}
- gtk_widget_destroy (dialog);
- } else {
- gtk_widget_destroy (dialog);
- }
}
static void
-delete_button_pulsed (GtkWidget *button,
- GtranslatorPreferencesDialog *dlg)
+delete_button_pulsed (GtkWidget * button, GtranslatorPreferencesDialog * dlg)
{
GtkTreeIter iter;
GtkTreeModel *model;
@@ -1037,227 +1096,250 @@ delete_button_pulsed (GtkWidget *button,
GtranslatorProfile *active_profile;
GtkWidget *dialog;
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+ model =
+ gtk_tree_view_get_model (GTK_TREE_VIEW (dlg->priv->profile_treeview));
g_return_if_fail (model != NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-
- gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
-
- active_profile = gtranslator_application_get_active_profile (GTR_APP);
-
- if (!strcmp (gtranslator_profile_get_name (active_profile), profile_row)) {
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- NULL);
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _("<span weight=\"bold\" size=\"large\">Impossible to remove the active profile</span>"));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Another profile should be selected as active before"));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- } else {
- dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- NULL);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _("<span weight=\"bold\" size=\"large\">Are you sure you want to delete this profile?</span>"));
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_DELETE,
- GTK_RESPONSE_YES);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
- g_signal_connect (GTK_DIALOG (dialog), "response",
- G_CALLBACK (delete_confirm_dialog_cb),
- dlg);
+ selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->profile_treeview));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+
+ gtk_tree_model_get (model, &iter, PROFILE_NAME_COL, &profile_row, -1);
+
+ active_profile = gtranslator_application_get_active_profile (GTR_APP);
+
+ if (!strcmp
+ (gtranslator_profile_get_name (active_profile), profile_row))
+ {
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("<span weight=\"bold\" size=\"large\">Impossible to remove the active profile</span>"));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG
+ (dialog),
+ _
+ ("Another profile should be selected as active before"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (dlg),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("<span weight=\"bold\" size=\"large\">Are you sure you want to delete this profile?</span>"));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_DELETE, GTK_RESPONSE_YES);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ g_signal_connect (GTK_DIALOG (dialog), "response",
+ G_CALLBACK (delete_confirm_dialog_cb), dlg);
+ }
}
- }
}
static void
-gtranslator_preferences_dialog_init (GtranslatorPreferencesDialog *dlg)
+gtranslator_preferences_dialog_init (GtranslatorPreferencesDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects[] = {
- "notebook",
- "adjustment1",
- "adjustment2",
- "adjustment3",
- "model1",
- NULL
- };
- gchar *path;
-
- dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dlg),
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- GTK_STOCK_HELP,
- GTK_RESPONSE_HELP,
- NULL);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Preferences"));
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (dialog_response_handler),
- NULL);
-
- /*Glade*/
-
- path = gtranslator_utils_get_file_from_pkgdatadir("preferences-dialog.ui");
- ret = gtranslator_utils_get_ui_objects (path,
- root_objects,
- &error_widget,
-
- "notebook", &dlg->priv->notebook,
-
- "warn_if_fuzzy_checkbutton", &dlg->priv->warn_if_contains_fuzzy_checkbutton,
- "delete_compiled_checkbutton", &dlg->priv->delete_compiled_checkbutton,
- "autosave_checkbutton", &dlg->priv->autosave_checkbutton,
- "autosave_interval_spinbutton", &dlg->priv->autosave_interval_spinbutton,
- "autosave_hbox", &dlg->priv->autosave_hbox,
- "create_backup_checkbutton", &dlg->priv->create_backup_checkbutton,
-
- "highlight_checkbutton", &dlg->priv->highlight_syntax_checkbutton,
- "visible_whitespace_checkbutton", &dlg->priv->visible_whitespace_checkbutton,
- "use_custom_font_checkbutton", &dlg->priv->use_custom_font_checkbutton,
- "editor_font_fontbutton", &dlg->priv->editor_font_fontbutton,
- "editor_font_hbox", &dlg->priv->editor_font_hbox,
-
- "unmark_fuzzy_checkbutton", &dlg->priv->unmark_fuzzy_when_changed_checkbutton,
- "spellcheck_checkbutton", &dlg->priv->spellcheck_checkbutton,
-
- "profile_treeview", &dlg->priv->profile_treeview,
- "add_button", &dlg->priv->add_button,
- "edit_button", &dlg->priv->edit_button,
- "delete_button", &dlg->priv->delete_button,
-
- "directory_entry", &dlg->priv->directory_entry,
- "search_button", &dlg->priv->search_button,
- "add_database_button", &dlg->priv->add_database_button,
- "add_database_progressbar", &dlg->priv->add_database_progressbar,
-
- "use_lang_profile_in_tm", &dlg->priv->use_lang_profile_in_tm,
- "tm_lang_entry", &dlg->priv->tm_lang_entry,
- "missing_words_spinbutton", &dlg->priv->missing_words_spinbutton,
- "sentence_length_spinbutton", &dlg->priv->sentence_length_spinbutton,
-
- "gdl_combobox", &dlg->priv->gdl_combobox,
- "scheme_color_combobox", &dlg->priv->scheme_color_combobox,
-
- "plugins_box", &dlg->priv->plugins_box,
- NULL);
- g_free(path);
-
- if(!ret)
- {
- gtk_widget_show(error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
-
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->notebook, FALSE, FALSE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
-
- g_signal_connect (dlg->priv->add_button,
- "clicked",
- G_CALLBACK (add_button_pulsed),
- dlg);
-
- g_signal_connect (dlg->priv->delete_button,
- "clicked",
- G_CALLBACK (delete_button_pulsed),
- dlg);
-
- g_signal_connect (dlg->priv->edit_button,
- "clicked",
- G_CALLBACK (edit_button_pulsed),
- dlg);
-
- setup_files_pages(dlg);
- setup_editor_pages(dlg);
- setup_profile_pages(dlg);
- setup_interface_pages(dlg);
- setup_tm_pages (dlg);
- setup_plugin_pages(dlg);
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "notebook",
+ "adjustment1",
+ "adjustment2",
+ "adjustment3",
+ "model1",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Preferences"));
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+
+ g_signal_connect (dlg,
+ "response", G_CALLBACK (dialog_response_handler), NULL);
+
+ /*Glade */
+
+ path = gtranslator_utils_get_file_from_pkgdatadir ("preferences-dialog.ui");
+ ret = gtranslator_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "notebook", &dlg->priv->notebook,
+ "warn_if_fuzzy_checkbutton",
+ &dlg->priv->
+ warn_if_contains_fuzzy_checkbutton,
+ "delete_compiled_checkbutton",
+ &dlg->priv->
+ delete_compiled_checkbutton,
+ "autosave_checkbutton",
+ &dlg->priv->autosave_checkbutton,
+ "autosave_interval_spinbutton",
+ &dlg->priv->
+ autosave_interval_spinbutton,
+ "autosave_hbox",
+ &dlg->priv->autosave_hbox,
+ "create_backup_checkbutton",
+ &dlg->priv->
+ create_backup_checkbutton,
+ "highlight_checkbutton",
+ &dlg->priv->
+ highlight_syntax_checkbutton,
+ "visible_whitespace_checkbutton",
+ &dlg->priv->
+ visible_whitespace_checkbutton,
+ "use_custom_font_checkbutton",
+ &dlg->priv->
+ use_custom_font_checkbutton,
+ "editor_font_fontbutton",
+ &dlg->priv->editor_font_fontbutton,
+ "editor_font_hbox",
+ &dlg->priv->editor_font_hbox,
+ "unmark_fuzzy_checkbutton",
+ &dlg->priv->
+ unmark_fuzzy_when_changed_checkbutton,
+ "spellcheck_checkbutton",
+ &dlg->priv->spellcheck_checkbutton,
+ "profile_treeview",
+ &dlg->priv->profile_treeview,
+ "add_button",
+ &dlg->priv->add_button,
+ "edit_button",
+ &dlg->priv->edit_button,
+ "delete_button",
+ &dlg->priv->delete_button,
+ "directory_entry",
+ &dlg->priv->directory_entry,
+ "search_button",
+ &dlg->priv->search_button,
+ "add_database_button",
+ &dlg->priv->add_database_button,
+ "add_database_progressbar",
+ &dlg->priv->
+ add_database_progressbar,
+ "use_lang_profile_in_tm",
+ &dlg->priv->use_lang_profile_in_tm,
+ "tm_lang_entry",
+ &dlg->priv->tm_lang_entry,
+ "missing_words_spinbutton",
+ &dlg->priv->
+ missing_words_spinbutton,
+ "sentence_length_spinbutton",
+ &dlg->priv->
+ sentence_length_spinbutton,
+ "gdl_combobox",
+ &dlg->priv->gdl_combobox,
+ "scheme_color_combobox",
+ &dlg->priv->scheme_color_combobox,
+ "plugins_box",
+ &dlg->priv->plugins_box, NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->notebook, FALSE, FALSE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->notebook), 5);
+
+ g_signal_connect (dlg->priv->add_button,
+ "clicked", G_CALLBACK (add_button_pulsed), dlg);
+
+ g_signal_connect (dlg->priv->delete_button,
+ "clicked", G_CALLBACK (delete_button_pulsed), dlg);
+
+ g_signal_connect (dlg->priv->edit_button,
+ "clicked", G_CALLBACK (edit_button_pulsed), dlg);
+
+ setup_files_pages (dlg);
+ setup_editor_pages (dlg);
+ setup_profile_pages (dlg);
+ setup_interface_pages (dlg);
+ setup_tm_pages (dlg);
+ setup_plugin_pages (dlg);
}
static void
-gtranslator_preferences_dialog_finalize (GObject *object)
+gtranslator_preferences_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_preferences_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_preferences_dialog_parent_class)->
+ finalize (object);
}
static void
-gtranslator_preferences_dialog_class_init (GtranslatorPreferencesDialogClass *klass)
+gtranslator_preferences_dialog_class_init (GtranslatorPreferencesDialogClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorPreferencesDialogPrivate));
+ g_type_class_add_private (klass,
+ sizeof (GtranslatorPreferencesDialogPrivate));
- object_class->finalize = gtranslator_preferences_dialog_finalize;
+ object_class->finalize = gtranslator_preferences_dialog_finalize;
}
void
-gtranslator_show_preferences_dialog (GtranslatorWindow *window)
+gtranslator_show_preferences_dialog (GtranslatorWindow * window)
{
- static GtkWidget *dlg = NULL;
-
- g_return_if_fail(GTR_IS_WINDOW(window));
-
- if(dlg == NULL)
- {
- dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG, 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));
- }
+ static GtkWidget *dlg = NULL;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ if (dlg == NULL)
+ {
+ dlg = GTK_WIDGET (g_object_new (GTR_TYPE_PREFERENCES_DIALOG, 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_present (GTK_WINDOW (dlg));
+ gtk_window_present (GTK_WINDOW (dlg));
}
diff --git a/src/dialogs/preferences-dialog.h b/src/dialogs/preferences-dialog.h
index f2d6a89..cf2af2e 100644
--- a/src/dialogs/preferences-dialog.h
+++ b/src/dialogs/preferences-dialog.h
@@ -25,14 +25,14 @@
#include <gtk/gtk.h>
#include "window.h"
-enum {
- PROFILE_NAME_COL,
- TOGGLE_COL,
- N_COLUMNS_PROFILES
- };
+enum
+{
+ PROFILE_NAME_COL,
+ TOGGLE_COL,
+ N_COLUMNS_PROFILES
+};
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -42,47 +42,53 @@ G_BEGIN_DECLS
#define GTR_IS_PREFERENCES_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_PREFERENCES_DIALOG))
#define GTR_IS_PREFERENCES_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_PREFERENCES_DIALOG))
#define GTR_PREFERENCES_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PREFERENCES_DIALOG, GtranslatorPreferencesDialogClass))
-
/* Private structure type */
-typedef struct _GtranslatorPreferencesDialogPrivate GtranslatorPreferencesDialogPrivate;
+typedef struct _GtranslatorPreferencesDialogPrivate
+ GtranslatorPreferencesDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorPreferencesDialog GtranslatorPreferencesDialog;
+typedef struct _GtranslatorPreferencesDialog GtranslatorPreferencesDialog;
struct _GtranslatorPreferencesDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorPreferencesDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorPreferencesDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorPreferencesDialogClass GtranslatorPreferencesDialogClass;
+typedef struct _GtranslatorPreferencesDialogClass
+ GtranslatorPreferencesDialogClass;
struct _GtranslatorPreferencesDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_preferences_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_preferences_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_preferences_dialog_register_type (GTypeModule * module);
+ GType gtranslator_preferences_dialog_register_type (GTypeModule *
+ module);
-void gtranslator_show_preferences_dialog (GtranslatorWindow *window);
+ void gtranslator_show_preferences_dialog (GtranslatorWindow * window);
-GtkWidget *gtranslator_preferences_dialog_get_treeview (GtranslatorPreferencesDialog *dlg);
+ GtkWidget
+ *gtranslator_preferences_dialog_get_treeview
+ (GtranslatorPreferencesDialog * dlg);
-void gtranslator_preferences_fill_profile_treeview (GtranslatorPreferencesDialog *dlg,
- GtkTreeModel *model);
+ void
+ gtranslator_preferences_fill_profile_treeview
+ (GtranslatorPreferencesDialog * dlg, GtkTreeModel * model);
G_END_DECLS
-
#endif /* __PREFERENCES_DIALOG_H__ */
diff --git a/src/dialogs/profile-dialog.c b/src/dialogs/profile-dialog.c
index 42aaed7..c205c23 100644
--- a/src/dialogs/profile-dialog.c
+++ b/src/dialogs/profile-dialog.c
@@ -42,191 +42,192 @@
GTR_TYPE_PROFILE_DIALOG, \
GtranslatorProfileDialogPrivate))
-G_DEFINE_TYPE(GtranslatorProfileDialog, gtranslator_profile_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GtranslatorProfileDialog, gtranslator_profile_dialog,
+ GTK_TYPE_DIALOG)
+ struct _GtranslatorProfileDialogPrivate
+ {
+ GtkWidget *main_box;
-struct _GtranslatorProfileDialogPrivate
-{
- GtkWidget *main_box;
-
- GtkWidget *profile_name_entry;
-
- GtkWidget *author_name_entry;
- GtkWidget *author_email_entry;
-
- GtkWidget *language_name_entry;
- GtkWidget *language_code_entry;
- GtkWidget *charset_entry;
- GtkWidget *encoding_entry;
- GtkWidget *language_email_entry;
- GtkWidget *plurals_forms_entry;
-
- GtranslatorPreferencesDialog *prefs_dlg;
-
- GtranslatorProfile *new_profile;
- GtranslatorProfile *old_profile;
-};
-
-static void gtranslator_profile_dialog_finalize (GObject *object)
+ GtkWidget *profile_name_entry;
+
+ GtkWidget *author_name_entry;
+ GtkWidget *author_email_entry;
+
+ GtkWidget *language_name_entry;
+ GtkWidget *language_code_entry;
+ GtkWidget *charset_entry;
+ GtkWidget *encoding_entry;
+ GtkWidget *language_email_entry;
+ GtkWidget *plurals_forms_entry;
+
+ GtranslatorPreferencesDialog *prefs_dlg;
+
+ GtranslatorProfile *new_profile;
+ GtranslatorProfile *old_profile;
+ };
+
+ static void gtranslator_profile_dialog_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_profile_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_profile_dialog_parent_class)->finalize (object);
}
-static void gtranslator_profile_dialog_class_init (GtranslatorProfileDialogClass *klass)
+static void
+gtranslator_profile_dialog_class_init (GtranslatorProfileDialogClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorProfileDialogPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorProfileDialogPrivate));
- object_class->finalize = gtranslator_profile_dialog_finalize;
+ object_class->finalize = gtranslator_profile_dialog_finalize;
}
/***************PROFILES****************/
static void
-profile_name_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+profile_name_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_name (profile_dlg->priv->new_profile,
- (gchar *)text);
-}
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_name (profile_dlg->priv->new_profile,
+ (gchar *) text);
+}
static void
-author_name_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+author_name_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->author_name_entry));*/
+ const gchar *text;
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_author_name (profile_dlg->priv->new_profile,
- (gchar *)text);
-}
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->author_name_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_author_name (profile_dlg->priv->new_profile,
+ (gchar *) text);
+}
static void
-author_email_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+author_email_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->author_email_entry));*/
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_author_email (profile_dlg->priv->new_profile,
- (gchar *)text);
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->author_email_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_author_email (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
static void
-language_name_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+language_name_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_language_name (profile_dlg->priv->new_profile,
- (gchar *)text);
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_language_name (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
static void
-language_code_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+language_code_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_language_code (profile_dlg->priv->new_profile,
- (gchar *)text);
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_language_code (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
static void
-charset_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+charset_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_charset (profile_dlg->priv->new_profile,
- (gchar *)text);
+ if (text)
+ gtranslator_profile_set_charset (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
static void
-encoding_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+encoding_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_encoding (profile_dlg->priv->new_profile,
- (gchar *)text);
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_encoding (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
static void
-group_email_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+group_email_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_group_email (profile_dlg->priv->new_profile,
- (gchar *)text);
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_group_email (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
static void
-plurals_entry_changed (GObject *gobject,
- GParamSpec *arg1,
- GtranslatorProfileDialog *profile_dlg)
+plurals_entry_changed (GObject * gobject,
+ GParamSpec * arg1,
+ GtranslatorProfileDialog * profile_dlg)
{
- const gchar *text;
-
- /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry));*/
-
- text = gtk_entry_get_text (GTK_ENTRY (gobject));
-
- if (text)
- gtranslator_profile_set_plurals (profile_dlg->priv->new_profile,
- (gchar *)text);
+ const gchar *text;
+
+ /*g_return_if_fail (GTK_ENTRY (gobject) == GTK_ENTRY (dlg->priv->profile_name_entry)); */
+
+ text = gtk_entry_get_text (GTK_ENTRY (gobject));
+
+ if (text)
+ gtranslator_profile_set_plurals (profile_dlg->priv->new_profile,
+ (gchar *) text);
}
-static void save_new_profile (GtkWidget *widget,
- GtranslatorProfileDialog *profile_dlg)
+static void
+save_new_profile (GtkWidget * widget, GtranslatorProfileDialog * profile_dlg)
{
GList *profiles_list = NULL, *l = NULL;
GtranslatorPreferencesDialog *dlg;
@@ -234,308 +235,378 @@ static void save_new_profile (GtkWidget *widget,
GtkWidget *treeview;
GtkTreeModel *model;
profile_exists = FALSE;
-
+
profiles_list = gtranslator_application_get_profiles (GTR_APP);
-
- for (l = profiles_list; l; l = l->next) {
- GtranslatorProfile *profile_in_list;
- profile_in_list = (GtranslatorProfile *)l->data;
- if (!strcmp (gtranslator_profile_get_name (profile_in_list),
- gtranslator_profile_get_name (profile_dlg->priv->new_profile)))
- profile_exists = TRUE;
- }
-
- if (profile_exists) {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_ancestor (widget, GTK_TYPE_DIALOG)),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- NULL);
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
- _("<span weight=\"bold\" size=\"large\">The profile name already exists</span>"));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- } else {
- /*
- * Add new profile to profiles list in memory
- */
- if (profiles_list == NULL) {
- GList *initial_list = NULL;
- initial_list = g_list_append (profiles_list, profile_dlg->priv->new_profile);
- gtranslator_application_set_active_profile (GTR_APP, profile_dlg->priv->new_profile);
- gtranslator_application_set_profiles (GTR_APP, initial_list);
- } else {
- profiles_list = g_list_append (profiles_list, profile_dlg->priv->new_profile);
- }
- }
-
+
+ for (l = profiles_list; l; l = l->next)
+ {
+ GtranslatorProfile *profile_in_list;
+ profile_in_list = (GtranslatorProfile *) l->data;
+ if (!strcmp (gtranslator_profile_get_name (profile_in_list),
+ gtranslator_profile_get_name (profile_dlg->priv->
+ new_profile)))
+ profile_exists = TRUE;
+ }
+
+ if (profile_exists)
+ {
+ GtkWidget *dialog;
+ dialog =
+ gtk_message_dialog_new (GTK_WINDOW
+ (gtk_widget_get_ancestor
+ (widget, GTK_TYPE_DIALOG)), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, NULL);
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("<span weight=\"bold\" size=\"large\">The profile name already exists</span>"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ /*
+ * Add new profile to profiles list in memory
+ */
+ if (profiles_list == NULL)
+ {
+ GList *initial_list = NULL;
+ initial_list =
+ g_list_append (profiles_list, profile_dlg->priv->new_profile);
+ gtranslator_application_set_active_profile (GTR_APP,
+ profile_dlg->priv->
+ new_profile);
+ gtranslator_application_set_profiles (GTR_APP, initial_list);
+ }
+ else
+ {
+ profiles_list =
+ g_list_append (profiles_list, profile_dlg->priv->new_profile);
+ }
+ }
+
/*
*Reload the preferences dialog
*/
dlg = profile_dlg->priv->prefs_dlg;
treeview = gtranslator_preferences_dialog_get_treeview (dlg);
-
+
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
g_return_if_fail (GTK_IS_LIST_STORE (model));
-
+
gtranslator_preferences_fill_profile_treeview (dlg, model);
-
+
gtk_widget_destroy (gtk_widget_get_ancestor (widget, GTK_TYPE_DIALOG));
}
static void
-save_modified_profile (GtkWidget *widget,
- GtranslatorProfileDialog *profile_dlg)
+save_modified_profile (GtkWidget * widget,
+ GtranslatorProfileDialog * profile_dlg)
{
- GtkWidget *treeview;
- GtkTreeModel *model;
-
- g_return_if_fail (GTR_IS_PREFERENCES_DIALOG (profile_dlg->priv->prefs_dlg));
-
- treeview = gtranslator_preferences_dialog_get_treeview (profile_dlg->priv->prefs_dlg);
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- g_return_if_fail (GTK_IS_LIST_STORE (model));
-
- gtranslator_preferences_fill_profile_treeview (profile_dlg->priv->prefs_dlg, model);
- gtk_widget_destroy (gtk_widget_get_ancestor (widget, GTK_TYPE_DIALOG));
+ GtkWidget *treeview;
+ GtkTreeModel *model;
+
+ g_return_if_fail (GTR_IS_PREFERENCES_DIALOG (profile_dlg->priv->prefs_dlg));
+
+ treeview =
+ gtranslator_preferences_dialog_get_treeview (profile_dlg->priv->
+ prefs_dlg);
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
+ g_return_if_fail (GTK_IS_LIST_STORE (model));
+
+ gtranslator_preferences_fill_profile_treeview (profile_dlg->priv->prefs_dlg,
+ model);
+ gtk_widget_destroy (gtk_widget_get_ancestor (widget, GTK_TYPE_DIALOG));
}
static void
-destroy_without_changes (GtkWidget *widget,
- GtranslatorProfileDialog *dlg)
+destroy_without_changes (GtkWidget * widget, GtranslatorProfileDialog * dlg)
{
- gtranslator_profile_set_name (dlg->priv->new_profile,
- gtranslator_profile_get_name (dlg->priv->old_profile));
- gtranslator_profile_set_author_name (dlg->priv->new_profile,
- gtranslator_profile_get_author_name (dlg->priv->old_profile));
- gtranslator_profile_set_author_email (dlg->priv->new_profile,
- gtranslator_profile_get_author_email (dlg->priv->old_profile));
- gtranslator_profile_set_language_name (dlg->priv->new_profile,
- gtranslator_profile_get_language_name (dlg->priv->old_profile));
- gtranslator_profile_set_language_code (dlg->priv->new_profile,
- gtranslator_profile_get_language_code (dlg->priv->old_profile));
- gtranslator_profile_set_charset (dlg->priv->new_profile,
- gtranslator_profile_get_charset (dlg->priv->old_profile));
- gtranslator_profile_set_encoding (dlg->priv->new_profile,
- gtranslator_profile_get_encoding (dlg->priv->old_profile));
- gtranslator_profile_set_group_email (dlg->priv->new_profile,
- gtranslator_profile_get_group_email (dlg->priv->old_profile));
- gtranslator_profile_set_plurals (dlg->priv->new_profile,
- gtranslator_profile_get_plurals (dlg->priv->old_profile));
-
- gtk_widget_destroy (gtk_widget_get_ancestor (widget, GTK_TYPE_DIALOG));
+ gtranslator_profile_set_name (dlg->priv->new_profile,
+ gtranslator_profile_get_name (dlg->priv->
+ old_profile));
+ gtranslator_profile_set_author_name (dlg->priv->new_profile,
+ gtranslator_profile_get_author_name
+ (dlg->priv->old_profile));
+ gtranslator_profile_set_author_email (dlg->priv->new_profile,
+ gtranslator_profile_get_author_email
+ (dlg->priv->old_profile));
+ gtranslator_profile_set_language_name (dlg->priv->new_profile,
+ gtranslator_profile_get_language_name
+ (dlg->priv->old_profile));
+ gtranslator_profile_set_language_code (dlg->priv->new_profile,
+ gtranslator_profile_get_language_code
+ (dlg->priv->old_profile));
+ gtranslator_profile_set_charset (dlg->priv->new_profile,
+ gtranslator_profile_get_charset (dlg->
+ priv->
+ old_profile));
+ gtranslator_profile_set_encoding (dlg->priv->new_profile,
+ gtranslator_profile_get_encoding (dlg->
+ priv->
+ old_profile));
+ gtranslator_profile_set_group_email (dlg->priv->new_profile,
+ gtranslator_profile_get_group_email
+ (dlg->priv->old_profile));
+ gtranslator_profile_set_plurals (dlg->priv->new_profile,
+ gtranslator_profile_get_plurals (dlg->
+ priv->
+ old_profile));
+
+ gtk_widget_destroy (gtk_widget_get_ancestor (widget, GTK_TYPE_DIALOG));
}
-static void gtranslator_profile_dialog_init (GtranslatorProfileDialog *dlg)
+static void
+gtranslator_profile_dialog_init (GtranslatorProfileDialog * dlg)
{
- gboolean ret;
- GtkWidget *error_widget;
- gchar *root_objects [] = {
- "profiles_dialog",
- NULL
- };
- gchar *path;
-
- dlg->priv = GTR_PROFILE_DIALOG_GET_PRIVATE (dlg);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Profile"));
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2);
-
- path = gtranslator_utils_get_file_from_pkgdatadir("profile-dialog.ui");
- ret = gtranslator_utils_get_ui_objects (path,
- root_objects,
- &error_widget,
- "profiles_dialog", &dlg->priv->main_box,
- "profile_entry", &dlg->priv->profile_name_entry,
- "name_entry", &dlg->priv->author_name_entry,
- "email_entry", &dlg->priv->author_email_entry,
- "language_entry", &dlg->priv->language_name_entry,
- "langcode_entry", &dlg->priv->language_code_entry,
- "charset_entry", &dlg->priv->charset_entry,
- "encoding_entry", &dlg->priv->encoding_entry,
- "team_email_entry", &dlg->priv->language_email_entry,
- "plurals_entry", &dlg->priv->plurals_forms_entry,
- NULL);
- g_free(path);
-
- if(!ret)
- {
- gtk_widget_show(error_widget);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget,
- TRUE,
- TRUE,
- 0);
-
- return;
- }
-
- gtk_widget_set_tooltip_text (dlg->priv->plurals_forms_entry,
- _("Example: nplurals=2; plural=(n != 1);"));
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- dlg->priv->main_box, FALSE, FALSE, 0);
- gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
-
+ gboolean ret;
+ GtkWidget *error_widget;
+ gchar *root_objects[] = {
+ "profiles_dialog",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_PROFILE_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Profile"));
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2);
+
+ path = gtranslator_utils_get_file_from_pkgdatadir ("profile-dialog.ui");
+ ret = gtranslator_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "profiles_dialog",
+ &dlg->priv->main_box,
+ "profile_entry",
+ &dlg->priv->profile_name_entry,
+ "name_entry",
+ &dlg->priv->author_name_entry,
+ "email_entry",
+ &dlg->priv->author_email_entry,
+ "language_entry",
+ &dlg->priv->language_name_entry,
+ "langcode_entry",
+ &dlg->priv->language_code_entry,
+ "charset_entry",
+ &dlg->priv->charset_entry,
+ "encoding_entry",
+ &dlg->priv->encoding_entry,
+ "team_email_entry",
+ &dlg->priv->language_email_entry,
+ "plurals_entry",
+ &dlg->priv->plurals_forms_entry,
+ NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ return;
+ }
+
+ gtk_widget_set_tooltip_text (dlg->priv->plurals_forms_entry,
+ _("Example: nplurals=2; plural=(n != 1);"));
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ dlg->priv->main_box, FALSE, FALSE, 0);
+ gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
+
}
-void gtranslator_show_profile_dialog (GtranslatorPreferencesDialog *dialog,
- GtranslatorProfile *profile,
- gint action)
-{
- static GtranslatorProfileDialog *dlg = NULL;
- GtkButton *ok_button, *cancel_button;
- GtranslatorProfile *old_profile;
-
- old_profile = gtranslator_profile_new ();
-
- cancel_button = GTK_BUTTON (gtk_button_new_from_stock (GTK_STOCK_CANCEL));
- gtk_widget_show (GTK_WIDGET (cancel_button));
- ok_button = GTK_BUTTON (gtk_button_new_from_stock (GTK_STOCK_OK));
- gtk_widget_show (GTK_WIDGET (ok_button));
-
- g_return_if_fail (GTR_IS_PREFERENCES_DIALOG (dialog));
-
- if(dlg == NULL)
- {
- dlg = g_object_new (GTR_TYPE_PROFILE_DIALOG, NULL);
- g_signal_connect (dlg,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &dlg);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), GTK_WIDGET (cancel_button));
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), GTK_WIDGET (ok_button));
-
- dlg->priv->prefs_dlg = dialog;
-
- gtk_widget_show (GTK_WIDGET (dlg));
- }
-
- if (GTK_WINDOW (dialog) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (dlg),
- GTK_WINDOW (dialog));
- }
-
- if (gtranslator_profile_get_name (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->profile_name_entry),
+void
+gtranslator_show_profile_dialog (GtranslatorPreferencesDialog * dialog,
+ GtranslatorProfile * profile, gint action)
+{
+ static GtranslatorProfileDialog *dlg = NULL;
+ GtkButton *ok_button, *cancel_button;
+ GtranslatorProfile *old_profile;
+
+ old_profile = gtranslator_profile_new ();
+
+ cancel_button = GTK_BUTTON (gtk_button_new_from_stock (GTK_STOCK_CANCEL));
+ gtk_widget_show (GTK_WIDGET (cancel_button));
+ ok_button = GTK_BUTTON (gtk_button_new_from_stock (GTK_STOCK_OK));
+ gtk_widget_show (GTK_WIDGET (ok_button));
+
+ g_return_if_fail (GTR_IS_PREFERENCES_DIALOG (dialog));
+
+ if (dlg == NULL)
+ {
+ dlg = g_object_new (GTR_TYPE_PROFILE_DIALOG, NULL);
+ g_signal_connect (dlg,
+ "destroy", G_CALLBACK (gtk_widget_destroyed), &dlg);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area),
+ GTK_WIDGET (cancel_button));
+
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area),
+ GTK_WIDGET (ok_button));
+
+ dlg->priv->prefs_dlg = dialog;
+
+ gtk_widget_show (GTK_WIDGET (dlg));
+ }
+
+ if (GTK_WINDOW (dialog) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (dialog));
+ }
+
+ if (gtranslator_profile_get_name (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->
+ profile_name_entry),
+ gtranslator_profile_get_name (profile));
+ gtranslator_profile_set_name (old_profile,
gtranslator_profile_get_name (profile));
- gtranslator_profile_set_name (old_profile, gtranslator_profile_get_name (profile));
- }
-
- if (gtranslator_profile_get_author_name (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->author_name_entry),
- gtranslator_profile_get_author_name (profile));
- gtranslator_profile_set_author_name (old_profile, gtranslator_profile_get_author_name (profile));
- }
-
- if (gtranslator_profile_get_author_email (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->author_email_entry),
- gtranslator_profile_get_author_email (profile));
- gtranslator_profile_set_author_email (old_profile, gtranslator_profile_get_author_email (profile));
- }
-
- if (gtranslator_profile_get_language_name (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->language_name_entry),
- gtranslator_profile_get_language_name (profile));
- gtranslator_profile_set_language_name (old_profile, gtranslator_profile_get_language_name (profile));
- }
-
- if (gtranslator_profile_get_language_code (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->language_code_entry),
- gtranslator_profile_get_language_code (profile));
- gtranslator_profile_set_language_code (old_profile, gtranslator_profile_get_language_code (profile));
- }
-
- if (gtranslator_profile_get_charset (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->charset_entry),
- gtranslator_profile_get_charset (profile));
- gtranslator_profile_set_charset (old_profile, gtranslator_profile_get_charset (profile));
- }
-
- if (gtranslator_profile_get_encoding (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->encoding_entry),
- gtranslator_profile_get_encoding (profile));
- gtranslator_profile_set_encoding (old_profile, gtranslator_profile_get_encoding (profile));
- }
-
- if (gtranslator_profile_get_group_email (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->language_email_entry),
- gtranslator_profile_get_group_email (profile));
- gtranslator_profile_set_group_email (old_profile, gtranslator_profile_get_group_email (profile));
- }
-
- if (gtranslator_profile_get_plurals (profile) != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GTR_PROFILE_DIALOG (dlg)->priv->plurals_forms_entry),
- gtranslator_profile_get_plurals (profile));
- gtranslator_profile_set_plurals (old_profile, gtranslator_profile_get_plurals (profile));
- }
-
- dlg->priv->old_profile = old_profile;
- dlg->priv->new_profile = profile;
-
- /* Connect entry signals */
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->profile_name_entry, "notify::text",
- G_CALLBACK (profile_name_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->author_name_entry, "notify::text",
- G_CALLBACK (author_name_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->author_email_entry, "notify::text",
- G_CALLBACK (author_email_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->language_name_entry, "notify::text",
- G_CALLBACK (language_name_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->language_code_entry, "notify::text",
- G_CALLBACK (language_code_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->charset_entry, "notify::text",
- G_CALLBACK (charset_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->encoding_entry, "notify::text",
- G_CALLBACK (encoding_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->language_email_entry, "notify::text",
- G_CALLBACK (group_email_entry_changed),
- dlg);
- g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->plurals_forms_entry, "notify::text",
- G_CALLBACK (plurals_entry_changed),
- dlg);
-
- /*
- * Connect signals to dialog buttons.
- */
-
- g_signal_connect (cancel_button,
- "clicked",
- G_CALLBACK (destroy_without_changes),
- dlg);
-
- if (action == NEW_PROFILE) {
- g_signal_connect (ok_button,
- "clicked",
- G_CALLBACK (save_new_profile),
- dlg);
- } else {
- if (action == EDIT_PROFILE) {
- g_signal_connect (ok_button,
- "clicked",
- G_CALLBACK (save_modified_profile),
- dlg);
- }
+ }
+
+ if (gtranslator_profile_get_author_name (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->author_name_entry),
+ gtranslator_profile_get_author_name (profile));
+ gtranslator_profile_set_author_name (old_profile,
+ gtranslator_profile_get_author_name
+ (profile));
+ }
+
+ if (gtranslator_profile_get_author_email (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->
+ author_email_entry),
+ gtranslator_profile_get_author_email (profile));
+ gtranslator_profile_set_author_email (old_profile,
+ gtranslator_profile_get_author_email
+ (profile));
+ }
+
+ if (gtranslator_profile_get_language_name (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->
+ language_name_entry),
+ gtranslator_profile_get_language_name (profile));
+ gtranslator_profile_set_language_name (old_profile,
+ gtranslator_profile_get_language_name
+ (profile));
+ }
+
+ if (gtranslator_profile_get_language_code (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->
+ language_code_entry),
+ gtranslator_profile_get_language_code (profile));
+ gtranslator_profile_set_language_code (old_profile,
+ gtranslator_profile_get_language_code
+ (profile));
+ }
+
+ if (gtranslator_profile_get_charset (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->charset_entry),
+ gtranslator_profile_get_charset (profile));
+ gtranslator_profile_set_charset (old_profile,
+ gtranslator_profile_get_charset
+ (profile));
+ }
+
+ if (gtranslator_profile_get_encoding (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->encoding_entry),
+ gtranslator_profile_get_encoding (profile));
+ gtranslator_profile_set_encoding (old_profile,
+ gtranslator_profile_get_encoding
+ (profile));
+ }
+
+ if (gtranslator_profile_get_group_email (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->
+ language_email_entry),
+ gtranslator_profile_get_group_email (profile));
+ gtranslator_profile_set_group_email (old_profile,
+ gtranslator_profile_get_group_email
+ (profile));
+ }
+
+ if (gtranslator_profile_get_plurals (profile) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY
+ (GTR_PROFILE_DIALOG (dlg)->priv->
+ plurals_forms_entry),
+ gtranslator_profile_get_plurals (profile));
+ gtranslator_profile_set_plurals (old_profile,
+ gtranslator_profile_get_plurals
+ (profile));
+ }
+
+ dlg->priv->old_profile = old_profile;
+ dlg->priv->new_profile = profile;
+
+ /* Connect entry signals */
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->profile_name_entry,
+ "notify::text", G_CALLBACK (profile_name_entry_changed),
+ dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->author_name_entry,
+ "notify::text", G_CALLBACK (author_name_entry_changed),
+ dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->author_email_entry,
+ "notify::text", G_CALLBACK (author_email_entry_changed),
+ dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->language_name_entry,
+ "notify::text", G_CALLBACK (language_name_entry_changed),
+ dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->language_code_entry,
+ "notify::text", G_CALLBACK (language_code_entry_changed),
+ dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->charset_entry,
+ "notify::text", G_CALLBACK (charset_entry_changed), dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->encoding_entry,
+ "notify::text", G_CALLBACK (encoding_entry_changed), dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->language_email_entry,
+ "notify::text", G_CALLBACK (group_email_entry_changed),
+ dlg);
+ g_signal_connect (GTR_PROFILE_DIALOG (dlg)->priv->plurals_forms_entry,
+ "notify::text", G_CALLBACK (plurals_entry_changed), dlg);
+
+ /*
+ * Connect signals to dialog buttons.
+ */
+
+ g_signal_connect (cancel_button,
+ "clicked", G_CALLBACK (destroy_without_changes), dlg);
+
+ if (action == NEW_PROFILE)
+ {
+ g_signal_connect (ok_button,
+ "clicked", G_CALLBACK (save_new_profile), dlg);
+ }
+ else
+ {
+ if (action == EDIT_PROFILE)
+ {
+ g_signal_connect (ok_button,
+ "clicked",
+ G_CALLBACK (save_modified_profile), dlg);
}
+ }
}
-
diff --git a/src/dialogs/profile-dialog.h b/src/dialogs/profile-dialog.h
index 85b9961..d75e0d2 100644
--- a/src/dialogs/profile-dialog.h
+++ b/src/dialogs/profile-dialog.h
@@ -30,10 +30,11 @@
#include "window.h"
#include "preferences-dialog.h"
-enum {
- NEW_PROFILE,
- EDIT_PROFILE
- };
+enum
+{
+ NEW_PROFILE,
+ EDIT_PROFILE
+};
/*
* Type checking and casting macros
@@ -46,40 +47,44 @@ enum {
#define GTR_PROFILE_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PROFILE_DIALOG, GtranslatorProfileDialogClass))
/* Private structure type */
-typedef struct _GtranslatorProfileDialogPrivate GtranslatorProfileDialogPrivate;
+typedef struct _GtranslatorProfileDialogPrivate
+ GtranslatorProfileDialogPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorProfileDialog GtranslatorProfileDialog;
+typedef struct _GtranslatorProfileDialog GtranslatorProfileDialog;
struct _GtranslatorProfileDialog
{
- GtkDialog parent_instance;
-
- /*< private > */
- GtranslatorProfileDialogPrivate *priv;
+ GtkDialog parent_instance;
+
+ /*< private > */
+ GtranslatorProfileDialogPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorProfileDialogClass GtranslatorProfileDialogClass;
+typedef struct _GtranslatorProfileDialogClass GtranslatorProfileDialogClass;
struct _GtranslatorProfileDialogClass
{
- GtkDialogClass parent_class;
+ GtkDialogClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_profile_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_profile_dialog_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_profile_dialog_register_type (GTypeModule * module);
+ GType gtranslator_profile_dialog_register_type (GTypeModule * module);
-void gtranslator_show_profile_dialog (GtranslatorPreferencesDialog *dialog,
- GtranslatorProfile *profile,
- gint action);
+ void gtranslator_show_profile_dialog (GtranslatorPreferencesDialog *
+ dialog,
+ GtranslatorProfile * profile,
+ gint action);
#endif
diff --git a/src/dialogs/search-dialog.c b/src/dialogs/search-dialog.c
index d5178bc..e93df57 100644
--- a/src/dialogs/search-dialog.c
+++ b/src/dialogs/search-dialog.c
@@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gedit Team, 2005. See the AUTHORS file for a
* list of people on the gedit Team.
@@ -49,687 +49,719 @@
/* Signals */
enum
{
- SHOW_REPLACE,
- LAST_SIGNAL
+ SHOW_REPLACE,
+ LAST_SIGNAL
};
-static guint dialog_signals [LAST_SIGNAL] = { 0 };
-
-struct _GtranslatorSearchDialogPrivate
-{
- gboolean show_replace;
-
- GtkWidget *table;
- GtkWidget *search_label;
- GtkWidget *search_entry;
- GtkWidget *search_text_entry;
- GtkWidget *replace_label;
- GtkWidget *replace_entry;
- GtkWidget *replace_text_entry;
- GtkWidget *original_text_checkbutton;
- GtkWidget *translated_text_checkbutton;
- GtkWidget *fuzzy_checkbutton;
- GtkWidget *match_case_checkbutton;
- GtkWidget *entire_word_checkbutton;
- GtkWidget *backwards_checkbutton;
- GtkWidget *wrap_around_checkbutton;
- GtkWidget *find_button;
- GtkWidget *replace_button;
- GtkWidget *replace_all_button;
-
- gboolean glade_error;
+static guint dialog_signals[LAST_SIGNAL] = { 0 };
+
+struct _GtranslatorSearchDialogPrivate
+{
+ gboolean show_replace;
+
+ GtkWidget *table;
+ GtkWidget *search_label;
+ GtkWidget *search_entry;
+ GtkWidget *search_text_entry;
+ GtkWidget *replace_label;
+ GtkWidget *replace_entry;
+ GtkWidget *replace_text_entry;
+ GtkWidget *original_text_checkbutton;
+ GtkWidget *translated_text_checkbutton;
+ GtkWidget *fuzzy_checkbutton;
+ GtkWidget *match_case_checkbutton;
+ GtkWidget *entire_word_checkbutton;
+ GtkWidget *backwards_checkbutton;
+ GtkWidget *wrap_around_checkbutton;
+ GtkWidget *find_button;
+ GtkWidget *replace_button;
+ GtkWidget *replace_all_button;
+
+ gboolean glade_error;
};
-G_DEFINE_TYPE(GtranslatorSearchDialog, gtranslator_search_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GtranslatorSearchDialog, gtranslator_search_dialog,
+ GTK_TYPE_DIALOG)
+ enum
+ {
+ PROP_0,
+ PROP_SHOW_REPLACE
+ };
+
+ static void
+ gtranslator_search_dialog_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
+ GtranslatorSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_REPLACE:
+ gtranslator_search_dialog_set_show_replace (dlg,
+ g_value_get_boolean
+ (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
-enum
+static void
+gtranslator_search_dialog_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- PROP_0,
- PROP_SHOW_REPLACE
-};
+ GtranslatorSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
-static void
-gtranslator_search_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ switch (prop_id)
+ {
+ case PROP_SHOW_REPLACE:
+ g_value_set_boolean (value, dlg->priv->show_replace);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+show_replace (GtranslatorSearchDialog * dlg)
{
- GtranslatorSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
+ gtranslator_search_dialog_set_show_replace (dlg, TRUE);
- switch (prop_id)
- {
- case PROP_SHOW_REPLACE:
- gtranslator_search_dialog_set_show_replace (dlg,
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ return TRUE;
}
static void
-gtranslator_search_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gtranslator_search_dialog_class_init (GtranslatorSearchDialogClass * klass)
{
- GtranslatorSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkBindingSet *binding_set;
- switch (prop_id)
- {
- case PROP_SHOW_REPLACE:
- g_value_set_boolean (value, dlg->priv->show_replace);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
+ object_class->set_property = gtranslator_search_dialog_set_property;
+ object_class->get_property = gtranslator_search_dialog_get_property;
-static gboolean
-show_replace (GtranslatorSearchDialog *dlg)
-{
- gtranslator_search_dialog_set_show_replace (dlg, TRUE);
-
- return TRUE;
-}
-
-static void
-gtranslator_search_dialog_class_init (GtranslatorSearchDialogClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkBindingSet *binding_set;
-
- object_class->set_property = gtranslator_search_dialog_set_property;
- object_class->get_property = gtranslator_search_dialog_get_property;
-
- klass->show_replace = show_replace;
-
- dialog_signals[SHOW_REPLACE] =
- g_signal_new ("show_replace",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GtranslatorSearchDialogClass, show_replace),
- NULL, NULL,
- gtranslator_marshal_BOOLEAN__NONE,
- G_TYPE_BOOLEAN, 0);
-
- g_object_class_install_property (object_class, PROP_SHOW_REPLACE,
- g_param_spec_boolean ("show-replace",
- "Show Replace",
- "Whether the dialog is used for Search&Replace",
- FALSE,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (GtranslatorSearchDialogPrivate));
-
- binding_set = gtk_binding_set_by_class (klass);
-
- /* Note: we cannot use the keyval/modifier associated with the
- * GTK_STOCK_FIND_AND_REPLACE stock item since GNOME HIG suggests Ctrl+h
- * for Replace while gtk+ uses Ctrl+r */
- gtk_binding_entry_add_signal (binding_set, GDK_h, GDK_CONTROL_MASK, "show_replace", 0);
- gtk_binding_entry_add_signal (binding_set, GDK_H, GDK_CONTROL_MASK, "show_replace", 0);
+ klass->show_replace = show_replace;
+
+ dialog_signals[SHOW_REPLACE] =
+ g_signal_new ("show_replace",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtranslatorSearchDialogClass,
+ show_replace), NULL, NULL,
+ gtranslator_marshal_BOOLEAN__NONE, G_TYPE_BOOLEAN, 0);
+
+ g_object_class_install_property (object_class, PROP_SHOW_REPLACE,
+ g_param_spec_boolean ("show-replace",
+ "Show Replace",
+ "Whether the dialog is used for Search&Replace",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorSearchDialogPrivate));
+
+ binding_set = gtk_binding_set_by_class (klass);
+
+ /* Note: we cannot use the keyval/modifier associated with the
+ * GTK_STOCK_FIND_AND_REPLACE stock item since GNOME HIG suggests Ctrl+h
+ * for Replace while gtk+ uses Ctrl+r */
+ gtk_binding_entry_add_signal (binding_set, GDK_h, GDK_CONTROL_MASK,
+ "show_replace", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_H, GDK_CONTROL_MASK,
+ "show_replace", 0);
}
static void
-insert_text_handler (GtkEditable *editable,
- const gchar *text,
- gint length,
- gint *position,
- gpointer data)
+insert_text_handler (GtkEditable * editable,
+ const gchar * text,
+ gint length, gint * position, gpointer data)
{
- static gboolean insert_text = FALSE;
- gchar *escaped_text;
- gint new_len;
+ static gboolean insert_text = FALSE;
+ gchar *escaped_text;
+ gint new_len;
- /* To avoid recursive behavior */
- if (insert_text)
- return;
+ /* To avoid recursive behavior */
+ if (insert_text)
+ return;
- escaped_text = gtranslator_utils_escape_search_text (text);
+ escaped_text = gtranslator_utils_escape_search_text (text);
- new_len = strlen (escaped_text);
+ new_len = strlen (escaped_text);
- if (new_len == length)
- {
- g_free (escaped_text);
- return;
- }
+ if (new_len == length)
+ {
+ g_free (escaped_text);
+ return;
+ }
- insert_text = TRUE;
+ insert_text = TRUE;
- g_signal_stop_emission_by_name (editable, "insert_text");
+ g_signal_stop_emission_by_name (editable, "insert_text");
- gtk_editable_insert_text (editable, escaped_text, new_len, position);
+ gtk_editable_insert_text (editable, escaped_text, new_len, position);
- insert_text = FALSE;
+ insert_text = FALSE;
- g_free (escaped_text);
+ g_free (escaped_text);
}
static void
-search_entry_changed (GtkComboBox *combo,
- GtranslatorSearchDialog *dialog)
+search_entry_changed (GtkComboBox * combo, GtranslatorSearchDialog * dialog)
{
- GtkWidget *entry;
- const gchar *search_string;
+ GtkWidget *entry;
+ const gchar *search_string;
- entry = gtk_bin_get_child (GTK_BIN (combo));
- search_string = gtk_entry_get_text (GTK_ENTRY (entry));
- g_return_if_fail (search_string != NULL);
+ entry = gtk_bin_get_child (GTK_BIN (combo));
+ search_string = gtk_entry_get_text (GTK_ENTRY (entry));
+ g_return_if_fail (search_string != NULL);
- if (*search_string != '\0')
- {
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_FIND_RESPONSE, TRUE);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, TRUE);
- }
- else
- {
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE, FALSE);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, FALSE);
- }
+ if (*search_string != '\0')
+ {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE,
+ TRUE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ TRUE);
+ }
+ else
+ {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE,
+ FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ FALSE);
+ }
}
/*
* Function to manage the sensitive of fuzzy checkbutton.
*/
static void
-original_translated_checkbutton_toggled(GtkToggleButton *button,
- GtranslatorSearchDialog *dialog)
-{
- gboolean original_text;
- gboolean translated_text;
-
- original_text = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->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->fuzzy_checkbutton), FALSE);
- gtk_widget_set_sensitive(dialog->priv->fuzzy_checkbutton, FALSE);
- }
- else gtk_widget_set_sensitive(dialog->priv->fuzzy_checkbutton, TRUE);
+original_translated_checkbutton_toggled (GtkToggleButton * button,
+ GtranslatorSearchDialog * dialog)
+{
+ gboolean original_text;
+ gboolean translated_text;
+
+ original_text =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->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->fuzzy_checkbutton), FALSE);
+ gtk_widget_set_sensitive (dialog->priv->fuzzy_checkbutton, FALSE);
+ }
+ else
+ gtk_widget_set_sensitive (dialog->priv->fuzzy_checkbutton, TRUE);
}
static void
-response_handler (GtranslatorSearchDialog *dialog,
- gint response_id,
- gpointer data)
+response_handler (GtranslatorSearchDialog * dialog,
+ gint response_id, gpointer data)
{
- const gchar *str;
+ const gchar *str;
- switch (response_id)
+ 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));
+ if (*str != '\0')
{
- 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));
- if (*str != '\0')
- {
- gchar *text;
-
- text = gtranslator_utils_unescape_search_text (str);
- gtranslator_history_entry_prepend_text
- (GTR_HISTORY_ENTRY (dialog->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));
- if (*str != '\0')
- {
- gchar *text;
-
- text = gtranslator_utils_unescape_search_text (str);
- gtranslator_history_entry_prepend_text
- (GTR_HISTORY_ENTRY (dialog->priv->search_entry),
- text);
-
- g_free (text);
- }
- }
-}
+ gchar *text;
-static void
-show_replace_widgets (GtranslatorSearchDialog *dlg,
- gboolean show_replace)
-{
- if (show_replace)
- {
- gtk_widget_hide(dlg->priv->original_text_checkbutton);
- gtk_widget_hide(dlg->priv->translated_text_checkbutton);
-
- /*
- * Set the default value of checkbutton
- */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->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_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 12);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Replace"));
+ text = gtranslator_utils_unescape_search_text (str);
+ gtranslator_history_entry_prepend_text
+ (GTR_HISTORY_ENTRY (dialog->priv->replace_entry), text);
+
+ g_free (text);
}
- else
+ /* 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));
+ if (*str != '\0')
{
- gtk_widget_show(dlg->priv->original_text_checkbutton);
- gtk_widget_show(dlg->priv->translated_text_checkbutton);
-
- /*
- * Set the default value of checkbuttons
- */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->priv->original_text_checkbutton), TRUE);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dlg->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_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 0);
-
- gtk_window_set_title (GTK_WINDOW (dlg), _("Find"));
- }
+ gchar *text;
+
+ text = gtranslator_utils_unescape_search_text (str);
+ gtranslator_history_entry_prepend_text
+ (GTR_HISTORY_ENTRY (dialog->priv->search_entry), text);
- gtk_widget_show (dlg->priv->find_button);
+ g_free (text);
+ }
+ }
}
static void
-gtranslator_search_dialog_init (GtranslatorSearchDialog *dlg)
-{
- GtkWidget *content;
- GtkWidget *error_widget;
- gboolean ret;
- gchar *root_objects [] = {
- "search_dialog_content",
- NULL
- };
- gchar *path;
-
- dlg->priv = GTR_SEARCH_DIALOG_GET_PRIVATE (dlg);
-
- gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (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);
-
- /* HIG defaults */
- gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 6);
-
- path = gtranslator_utils_get_file_from_pkgdatadir("search-dialog.ui");
- ret = gtranslator_utils_get_ui_objects (path,
- root_objects,
- &error_widget,
- "search_dialog_content", &content,
- "table", &dlg->priv->table,
- "search_label", &dlg->priv->search_label,
- "replace_with_label", &dlg->priv->replace_label,
- "original_text_checkbutton", &dlg->priv->original_text_checkbutton,
- "translated_text_checkbutton", &dlg->priv->translated_text_checkbutton,
- "fuzzy_checkbutton", &dlg->priv->fuzzy_checkbutton,
- "match_case_checkbutton", &dlg->priv->match_case_checkbutton,
- "entire_word_checkbutton", &dlg->priv->entire_word_checkbutton,
- "search_backwards_checkbutton", &dlg->priv->backwards_checkbutton,
- "wrap_around_checkbutton", &dlg->priv->wrap_around_checkbutton,
- NULL);
- g_free(path);
-
- if (!ret)
- {
- gtk_widget_show (error_widget);
+show_replace_widgets (GtranslatorSearchDialog * dlg, gboolean show_replace)
+{
+ if (show_replace)
+ {
+ gtk_widget_hide (dlg->priv->original_text_checkbutton);
+ gtk_widget_hide (dlg->priv->translated_text_checkbutton);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- error_widget, TRUE, TRUE, 0);
+ /*
+ * Set the default value of checkbutton
+ */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->translated_text_checkbutton),
+ TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (error_widget), 5);
+ 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);
- dlg->priv->glade_error = TRUE;
+ gtk_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 12);
- return;
- }
+ 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);
- dlg->priv->search_entry = gtranslator_history_entry_new ("gtranslator_search_for_entry",
- TRUE);
- gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
- gtranslator_history_entry_set_escape_func
- (GTR_HISTORY_ENTRY (dlg->priv->search_entry),
- (GtranslatorHistoryEntryEscapeFunc) gtranslator_utils_escape_search_text);
+ /*
+ * Set the default value of checkbuttons
+ */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->original_text_checkbutton),
+ TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dlg->priv->translated_text_checkbutton),
+ TRUE);
- dlg->priv->search_text_entry = gtranslator_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_table_attach_defaults (GTK_TABLE (dlg->priv->table),
- dlg->priv->search_entry,
- 1, 2, 0, 1);
-
- dlg->priv->replace_entry = gtranslator_history_entry_new ("gtranslator_replace_with_entry",
- TRUE);
- gtranslator_history_entry_set_escape_func
- (GTR_HISTORY_ENTRY (dlg->priv->replace_entry),
- (GtranslatorHistoryEntryEscapeFunc) gtranslator_utils_escape_search_text);
-
- dlg->priv->replace_text_entry = gtranslator_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_table_attach_defaults (GTK_TABLE (dlg->priv->table),
- dlg->priv->replace_entry,
- 1, 2, 1, 2);
-
- 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);
-
- dlg->priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
- dlg->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),
- _("_Replace"));
-
- gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- dlg->priv->replace_all_button,
- GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
- gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- dlg->priv->replace_button,
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE);
- gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
- dlg->priv->find_button,
- GTR_SEARCH_DIALOG_FIND_RESPONSE);
- g_object_set (G_OBJECT (dlg->priv->find_button),
- "can-default", TRUE,
- NULL);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dlg),
- GTR_SEARCH_DIALOG_FIND_RESPONSE);
-
- /* insensitive by default */
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
- GTR_SEARCH_DIALOG_FIND_RESPONSE,
- FALSE);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
- FALSE);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
- GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
- FALSE);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
- content, FALSE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (content), 5);
-
- g_signal_connect (dlg->priv->search_text_entry,
- "insert_text",
- G_CALLBACK (insert_text_handler),
- NULL);
- g_signal_connect (dlg->priv->replace_text_entry,
- "insert_text",
- G_CALLBACK (insert_text_handler),
- NULL);
- g_signal_connect (dlg->priv->search_entry,
- "changed",
- G_CALLBACK (search_entry_changed),
- dlg);
-
- g_signal_connect (dlg->priv->original_text_checkbutton,
- "toggled",
- G_CALLBACK (original_translated_checkbutton_toggled),
- dlg);
-
- g_signal_connect (dlg->priv->translated_text_checkbutton,
- "toggled",
- G_CALLBACK (original_translated_checkbutton_toggled),
- dlg);
-
- g_signal_connect (dlg,
- "response",
- G_CALLBACK (response_handler),
- NULL);
+ 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_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 0);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), _("Find"));
+ }
+
+ gtk_widget_show (dlg->priv->find_button);
+}
+
+static void
+gtranslator_search_dialog_init (GtranslatorSearchDialog * dlg)
+{
+ GtkWidget *content;
+ GtkWidget *error_widget;
+ gboolean ret;
+ gchar *root_objects[] = {
+ "search_dialog_content",
+ NULL
+ };
+ gchar *path;
+
+ dlg->priv = GTR_SEARCH_DIALOG_GET_PRIVATE (dlg);
+
+ gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (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);
+
+ /* HIG defaults */
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (GTK_DIALOG (dlg)->action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 6);
+
+ path = gtranslator_utils_get_file_from_pkgdatadir ("search-dialog.ui");
+ ret = gtranslator_utils_get_ui_objects (path,
+ root_objects,
+ &error_widget,
+ "search_dialog_content", &content,
+ "table", &dlg->priv->table,
+ "search_label",
+ &dlg->priv->search_label,
+ "replace_with_label",
+ &dlg->priv->replace_label,
+ "original_text_checkbutton",
+ &dlg->priv->
+ original_text_checkbutton,
+ "translated_text_checkbutton",
+ &dlg->priv->
+ translated_text_checkbutton,
+ "fuzzy_checkbutton",
+ &dlg->priv->fuzzy_checkbutton,
+ "match_case_checkbutton",
+ &dlg->priv->match_case_checkbutton,
+ "entire_word_checkbutton",
+ &dlg->priv->entire_word_checkbutton,
+ "search_backwards_checkbutton",
+ &dlg->priv->backwards_checkbutton,
+ "wrap_around_checkbutton",
+ &dlg->priv->wrap_around_checkbutton,
+ NULL);
+ g_free (path);
+
+ if (!ret)
+ {
+ gtk_widget_show (error_widget);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ error_widget, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (error_widget), 5);
+
+ dlg->priv->glade_error = TRUE;
+
+ return;
+ }
+
+ dlg->priv->search_entry =
+ gtranslator_history_entry_new ("gtranslator_search_for_entry", TRUE);
+ gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
+ gtranslator_history_entry_set_escape_func
+ (GTR_HISTORY_ENTRY (dlg->priv->search_entry),
+ (GtranslatorHistoryEntryEscapeFunc)
+ gtranslator_utils_escape_search_text);
+
+ dlg->priv->search_text_entry = gtranslator_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_table_attach_defaults (GTK_TABLE (dlg->priv->table),
+ dlg->priv->search_entry, 1, 2, 0, 1);
+
+ dlg->priv->replace_entry =
+ gtranslator_history_entry_new ("gtranslator_replace_with_entry", TRUE);
+ gtranslator_history_entry_set_escape_func (GTR_HISTORY_ENTRY
+ (dlg->priv->replace_entry),
+ (GtranslatorHistoryEntryEscapeFunc)
+ gtranslator_utils_escape_search_text);
+
+ dlg->priv->replace_text_entry = gtranslator_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_table_attach_defaults (GTK_TABLE (dlg->priv->table),
+ dlg->priv->replace_entry, 1, 2, 1, 2);
+
+ 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);
+
+ dlg->priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
+ dlg->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),
+ _("_Replace"));
+
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ dlg->priv->replace_all_button,
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ dlg->priv->replace_button,
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
+ dlg->priv->find_button,
+ GTR_SEARCH_DIALOG_FIND_RESPONSE);
+ g_object_set (G_OBJECT (dlg->priv->find_button), "can-default", TRUE, NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE);
+
+ /* insensitive by default */
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ FALSE);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ FALSE);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+ content, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (content), 5);
+
+ g_signal_connect (dlg->priv->search_text_entry,
+ "insert_text", G_CALLBACK (insert_text_handler), NULL);
+ g_signal_connect (dlg->priv->replace_text_entry,
+ "insert_text", G_CALLBACK (insert_text_handler), NULL);
+ g_signal_connect (dlg->priv->search_entry,
+ "changed", G_CALLBACK (search_entry_changed), dlg);
+
+ g_signal_connect (dlg->priv->original_text_checkbutton,
+ "toggled",
+ G_CALLBACK (original_translated_checkbutton_toggled),
+ dlg);
+
+ g_signal_connect (dlg->priv->translated_text_checkbutton,
+ "toggled",
+ G_CALLBACK (original_translated_checkbutton_toggled),
+ dlg);
+
+ g_signal_connect (dlg, "response", G_CALLBACK (response_handler), NULL);
}
GtkWidget *
-gtranslator_search_dialog_new (GtkWindow *parent,
- gboolean show_replace)
+gtranslator_search_dialog_new (GtkWindow * parent, gboolean show_replace)
{
- GtranslatorSearchDialog *dlg;
+ GtranslatorSearchDialog *dlg;
- dlg = g_object_new (GTR_TYPE_SEARCH_DIALOG,
- "show-replace", show_replace,
- NULL);
+ dlg = g_object_new (GTR_TYPE_SEARCH_DIALOG,
+ "show-replace", show_replace, NULL);
- if (parent != NULL)
- gtk_window_set_transient_for (GTK_WINDOW (dlg),
- parent);
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
- return GTK_WIDGET (dlg);
+ return GTK_WIDGET (dlg);
}
void
-gtranslator_search_dialog_present_with_time (GtranslatorSearchDialog *dialog,
- guint32 timestamp)
+gtranslator_search_dialog_present_with_time (GtranslatorSearchDialog * dialog,
+ guint32 timestamp)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
+ gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
- gtk_widget_grab_focus (dialog->priv->search_text_entry);
+ gtk_widget_grab_focus (dialog->priv->search_text_entry);
}
gboolean
-gtranslator_search_dialog_get_show_replace (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_show_replace (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
- return dialog->priv->show_replace;
+ return dialog->priv->show_replace;
}
void
-gtranslator_search_dialog_set_show_replace (GtranslatorSearchDialog *dialog,
- gboolean show_replace)
+gtranslator_search_dialog_set_show_replace (GtranslatorSearchDialog * dialog,
+ gboolean show_replace)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- if (dialog->priv->glade_error)
- return;
+ if (dialog->priv->glade_error)
+ return;
- dialog->priv->show_replace = show_replace != FALSE;
- show_replace_widgets (dialog, dialog->priv->show_replace);
+ dialog->priv->show_replace = show_replace != FALSE;
+ show_replace_widgets (dialog, dialog->priv->show_replace);
- g_object_notify (G_OBJECT (dialog), "show-replace");
+ g_object_notify (G_OBJECT (dialog), "show-replace");
}
void
-gtranslator_search_dialog_set_search_text (GtranslatorSearchDialog *dialog,
- const gchar *text)
+gtranslator_search_dialog_set_search_text (GtranslatorSearchDialog * dialog,
+ const gchar * text)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- g_return_if_fail (text != NULL);
+ 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 (dialog->priv->search_text_entry),
- text);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_FIND_RESPONSE,
+ (text != '\0'));
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_FIND_RESPONSE,
- (text != '\0'));
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
- (text != '\0'));
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
+ (text != '\0'));
}
/*
* The text must be unescaped before searching.
*/
const gchar *
-gtranslator_search_dialog_get_search_text (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_search_text (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), NULL);
+ 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 (dialog->priv->search_text_entry));
}
void
-gtranslator_search_dialog_set_replace_text (GtranslatorSearchDialog *dialog,
- const gchar *text)
+gtranslator_search_dialog_set_replace_text (GtranslatorSearchDialog * dialog,
+ const gchar * text)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- g_return_if_fail (text != NULL);
+ 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 (dialog->priv->replace_text_entry), text);
}
const gchar *
-gtranslator_search_dialog_get_replace_text (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_replace_text (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), NULL);
+ 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 (dialog->priv->replace_text_entry));
}
void
-gtranslator_search_dialog_set_original_text (GtranslatorSearchDialog *dialog,
- gboolean match_case)
+gtranslator_search_dialog_set_original_text (GtranslatorSearchDialog * dialog,
+ gboolean match_case)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->original_text_checkbutton),
- match_case);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->original_text_checkbutton),
+ match_case);
}
gboolean
-gtranslator_search_dialog_get_original_text (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_original_text (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ 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));
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->original_text_checkbutton));
}
void
-gtranslator_search_dialog_set_translated_text (GtranslatorSearchDialog *dialog,
- gboolean match_case)
+gtranslator_search_dialog_set_translated_text (GtranslatorSearchDialog *
+ dialog, gboolean match_case)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->translated_text_checkbutton),
- match_case);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->translated_text_checkbutton),
+ match_case);
}
gboolean
-gtranslator_search_dialog_get_translated_text (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_translated_text (GtranslatorSearchDialog *
+ dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ 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
+ (dialog->priv->
+ translated_text_checkbutton));
}
void
-gtranslator_search_dialog_set_fuzzy (GtranslatorSearchDialog *dialog,
- gboolean match_case)
+gtranslator_search_dialog_set_fuzzy (GtranslatorSearchDialog * dialog,
+ gboolean match_case)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->fuzzy_checkbutton),
- match_case);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->fuzzy_checkbutton),
+ match_case);
}
gboolean
-gtranslator_search_dialog_get_fuzzy (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_fuzzy (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ 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
+ (dialog->priv->fuzzy_checkbutton));
}
void
-gtranslator_search_dialog_set_match_case (GtranslatorSearchDialog *dialog,
- gboolean match_case)
+gtranslator_search_dialog_set_match_case (GtranslatorSearchDialog * dialog,
+ gboolean match_case)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton),
- match_case);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->match_case_checkbutton),
+ match_case);
}
gboolean
-gtranslator_search_dialog_get_match_case (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_match_case (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ 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));
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->match_case_checkbutton));
}
void
-gtranslator_search_dialog_set_entire_word (GtranslatorSearchDialog *dialog,
- gboolean entire_word)
+gtranslator_search_dialog_set_entire_word (GtranslatorSearchDialog * dialog,
+ gboolean entire_word)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton),
- entire_word);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->entire_word_checkbutton),
+ entire_word);
}
gboolean
-gtranslator_search_dialog_get_entire_word (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_entire_word (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ 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));
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->entire_word_checkbutton));
}
void
-gtranslator_search_dialog_set_backwards (GtranslatorSearchDialog *dialog,
- gboolean backwards)
+gtranslator_search_dialog_set_backwards (GtranslatorSearchDialog * dialog,
+ gboolean backwards)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton),
- backwards);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->backwards_checkbutton),
+ backwards);
}
gboolean
-gtranslator_search_dialog_get_backwards (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_backwards (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
- return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton));
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->backwards_checkbutton));
}
void
-gtranslator_search_dialog_set_wrap_around (GtranslatorSearchDialog *dialog,
- gboolean wrap_around)
+gtranslator_search_dialog_set_wrap_around (GtranslatorSearchDialog * dialog,
+ gboolean wrap_around)
{
- g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
+ g_return_if_fail (GTR_IS_SEARCH_DIALOG (dialog));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton),
- wrap_around);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->wrap_around_checkbutton),
+ wrap_around);
}
gboolean
-gtranslator_search_dialog_get_wrap_around (GtranslatorSearchDialog *dialog)
+gtranslator_search_dialog_get_wrap_around (GtranslatorSearchDialog * dialog)
{
- g_return_val_if_fail (GTR_IS_SEARCH_DIALOG (dialog), FALSE);
+ 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));
+ return
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (dialog->priv->wrap_around_checkbutton));
}
diff --git a/src/dialogs/search-dialog.h b/src/dialogs/search-dialog.h
index 7d333a8..2385010 100644
--- a/src/dialogs/search-dialog.h
+++ b/src/dialogs/search-dialog.h
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -38,7 +37,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, GtranslatorSearchDialogClass))
-
/* Private structure type */
typedef struct _GtranslatorSearchDialogPrivate GtranslatorSearchDialogPrivate;
@@ -47,12 +45,12 @@ typedef struct _GtranslatorSearchDialogPrivate GtranslatorSearchDialogPrivate;
*/
typedef struct _GtranslatorSearchDialog GtranslatorSearchDialog;
-struct _GtranslatorSearchDialog
+struct _GtranslatorSearchDialog
{
- GtkDialog dialog;
+ GtkDialog dialog;
- /*< private > */
- GtranslatorSearchDialogPrivate *priv;
+ /*< private > */
+ GtranslatorSearchDialogPrivate *priv;
};
/*
@@ -60,82 +58,112 @@ struct _GtranslatorSearchDialog
*/
typedef struct _GtranslatorSearchDialogClass GtranslatorSearchDialogClass;
-struct _GtranslatorSearchDialogClass
+struct _GtranslatorSearchDialogClass
{
- GtkDialogClass parent_class;
-
- /* Key bindings */
- gboolean (* show_replace) (GtranslatorSearchDialog *dlg);
+ GtkDialogClass parent_class;
+
+ /* Key bindings */
+ gboolean (*show_replace) (GtranslatorSearchDialog * dlg);
};
enum
{
- GTR_SEARCH_DIALOG_FIND_RESPONSE = 100,
- GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
- GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE
+ GTR_SEARCH_DIALOG_FIND_RESPONSE = 100,
+ GTR_SEARCH_DIALOG_REPLACE_RESPONSE,
+ GTR_SEARCH_DIALOG_REPLACE_ALL_RESPONSE
};
/*
* Public methods
*/
-GType gtranslator_search_dialog_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_search_dialog_get_type (void)
+ G_GNUC_CONST;
-GtkWidget *gtranslator_search_dialog_new (GtkWindow *parent,
- gboolean show_replace);
+ GtkWidget *gtranslator_search_dialog_new (GtkWindow * parent,
+ gboolean show_replace);
-void gtranslator_search_dialog_present_with_time (GtranslatorSearchDialog *dialog,
- guint32 timestamp);
+ void gtranslator_search_dialog_present_with_time (GtranslatorSearchDialog
+ * dialog,
+ guint32 timestamp);
-gboolean gtranslator_search_dialog_get_show_replace (GtranslatorSearchDialog *dialog);
+ gboolean
+ gtranslator_search_dialog_get_show_replace (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_show_replace (GtranslatorSearchDialog *dialog,
- gboolean show_replace);
+ void gtranslator_search_dialog_set_show_replace (GtranslatorSearchDialog
+ * dialog,
+ gboolean show_replace);
-void gtranslator_search_dialog_set_search_text (GtranslatorSearchDialog *dialog,
- const gchar *text);
+ void gtranslator_search_dialog_set_search_text (GtranslatorSearchDialog *
+ dialog,
+ const gchar * text);
-const gchar *gtranslator_search_dialog_get_search_text (GtranslatorSearchDialog *dialog);
+ const gchar
+ *gtranslator_search_dialog_get_search_text (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_replace_text (GtranslatorSearchDialog *dialog,
- const gchar *text);
+ void gtranslator_search_dialog_set_replace_text (GtranslatorSearchDialog
+ * dialog,
+ const gchar * text);
-const gchar *gtranslator_search_dialog_get_replace_text (GtranslatorSearchDialog *dialog);
+ const gchar
+ *gtranslator_search_dialog_get_replace_text (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_original_text (GtranslatorSearchDialog *dialog,
- gboolean match_case);
+ void gtranslator_search_dialog_set_original_text (GtranslatorSearchDialog
+ * dialog,
+ gboolean match_case);
-gboolean gtranslator_search_dialog_get_original_text (GtranslatorSearchDialog *dialog);
+ gboolean
+ gtranslator_search_dialog_get_original_text (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_translated_text (GtranslatorSearchDialog *dialog,
- gboolean match_case);
+ void
+ gtranslator_search_dialog_set_translated_text (GtranslatorSearchDialog
+ * dialog,
+ gboolean match_case);
-gboolean gtranslator_search_dialog_get_translated_text (GtranslatorSearchDialog *dialog);
+ gboolean
+ gtranslator_search_dialog_get_translated_text (GtranslatorSearchDialog
+ * dialog);
-void gtranslator_search_dialog_set_fuzzy (GtranslatorSearchDialog *dialog,
- gboolean match_case);
+ void gtranslator_search_dialog_set_fuzzy (GtranslatorSearchDialog *
+ dialog, gboolean match_case);
-gboolean gtranslator_search_dialog_get_fuzzy (GtranslatorSearchDialog *dialog);
+ gboolean gtranslator_search_dialog_get_fuzzy (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_match_case (GtranslatorSearchDialog *dialog,
- gboolean match_case);
+ void gtranslator_search_dialog_set_match_case (GtranslatorSearchDialog *
+ dialog,
+ gboolean match_case);
-gboolean gtranslator_search_dialog_get_match_case (GtranslatorSearchDialog *dialog);
+ gboolean
+ gtranslator_search_dialog_get_match_case (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_entire_word (GtranslatorSearchDialog *dialog,
- gboolean entire_word);
+ void gtranslator_search_dialog_set_entire_word (GtranslatorSearchDialog *
+ dialog,
+ gboolean entire_word);
-gboolean gtranslator_search_dialog_get_entire_word (GtranslatorSearchDialog *dialog);
+ gboolean
+ gtranslator_search_dialog_get_entire_word (GtranslatorSearchDialog *
+ dialog);
-void gtranslator_search_dialog_set_backwards (GtranslatorSearchDialog *dialog,
- gboolean backwards);
+ void gtranslator_search_dialog_set_backwards (GtranslatorSearchDialog *
+ dialog,
+ gboolean backwards);
-gboolean gtranslator_search_dialog_get_backwards (GtranslatorSearchDialog *dialog);
+ gboolean gtranslator_search_dialog_get_backwards (GtranslatorSearchDialog
+ * dialog);
-void gtranslator_search_dialog_set_wrap_around (GtranslatorSearchDialog *dialog,
- gboolean wrap_around);
+ void gtranslator_search_dialog_set_wrap_around (GtranslatorSearchDialog *
+ dialog,
+ gboolean wrap_around);
-gboolean gtranslator_search_dialog_get_wrap_around (GtranslatorSearchDialog *dialog);
-
-G_END_DECLS
+ gboolean
+ gtranslator_search_dialog_get_wrap_around (GtranslatorSearchDialog *
+ dialog);
-#endif /* __SEARCH_DIALOG_H__ */
+G_END_DECLS
+#endif /* __SEARCH_DIALOG_H__ */
diff --git a/src/header.c b/src/header.c
index 48916e9..285670c 100644
--- a/src/header.c
+++ b/src/header.c
@@ -35,306 +35,346 @@
GTR_TYPE_HEADER, \
GtranslatorHeaderPrivate))
-G_DEFINE_TYPE(GtranslatorHeader, gtranslator_header, G_TYPE_OBJECT)
-
-struct _GtranslatorHeaderPrivate
-{
- gchar *comment;
-
- /*
- * Project-ID-Version
- */
- gchar *prj_id_version;
-
- /*
- * Report msgid bugs to
- */
- gchar *rmbt;
-
- /*
- * POT-Creation-Date
- */
- gchar *pot_date;
-
- /*
- * PO-Revision-Date
- */
- gchar *po_date;
-
- /*
- * Translator Name
- */
- gchar *translator;
-
- /*
- * Translator Email
- */
- gchar *tr_email;
-
- /*
- * Previous Translator Name and Email
- */
- gchar *prev_translator;
-
- /*
- * Language Name
- */
- gchar *language;
-
- /*
- * Traslation group email
- */
- gchar *lg_email;
-
- gchar *mime_version;
-
- /*
- * Content-Type
- */
- gchar *charset;
-
- /*
- * Content-Transfer-Encoding
- */
- gchar *encoding;
-
- /*
- * Plural forms and number of plurals
- */
- gchar *plural_forms;
- gint nplurals;
-
- /*
- * Check if header has changed
- */
- gboolean header_changed;
-};
+G_DEFINE_TYPE (GtranslatorHeader, gtranslator_header, G_TYPE_OBJECT)
+ struct _GtranslatorHeaderPrivate
+ {
+ gchar *comment;
+
+ /*
+ * Project-ID-Version
+ */
+ gchar *prj_id_version;
+
+ /*
+ * Report msgid bugs to
+ */
+ gchar *rmbt;
+
+ /*
+ * POT-Creation-Date
+ */
+ gchar *pot_date;
+
+ /*
+ * PO-Revision-Date
+ */
+ gchar *po_date;
+
+ /*
+ * Translator Name
+ */
+ gchar *translator;
+
+ /*
+ * Translator Email
+ */
+ gchar *tr_email;
+
+ /*
+ * Previous Translator Name and Email
+ */
+ gchar *prev_translator;
+
+ /*
+ * Language Name
+ */
+ gchar *language;
+
+ /*
+ * Traslation group email
+ */
+ gchar *lg_email;
+
+ gchar *mime_version;
+
+ /*
+ * Content-Type
+ */
+ gchar *charset;
+
+ /*
+ * Content-Transfer-Encoding
+ */
+ gchar *encoding;
+
+ /*
+ * Plural forms and number of plurals
+ */
+ gchar *plural_forms;
+ gint nplurals;
+
+ /*
+ * Check if header has changed
+ */
+ gboolean header_changed;
+ };
/*
* Set nplurals variable
*/
-static void
-parse_nplurals (GtranslatorHeader *header)
+ static void parse_nplurals (GtranslatorHeader * header)
{
- gchar *pointer;
-
- g_return_if_fail (header->priv->plural_forms != NULL);
-
- pointer = header->priv->plural_forms;
-
- while (*pointer != '=')
- pointer++;
- pointer++;
-
- //if there are any space between '=' and nplural number pointer++
- while(*pointer == ' ')
- pointer++;
-
- header->priv->nplurals = g_ascii_digit_value(*pointer);
+ gchar *pointer;
+
+ g_return_if_fail (header->priv->plural_forms != NULL);
+
+ pointer = header->priv->plural_forms;
+
+ while (*pointer != '=')
+ pointer++;
+ pointer++;
+
+ //if there are any space between '=' and nplural number pointer++
+ while (*pointer == ' ')
+ pointer++;
+
+ header->priv->nplurals = g_ascii_digit_value (*pointer);
}
-static void gtranslator_header_init (GtranslatorHeader *header)
+static void
+gtranslator_header_init (GtranslatorHeader * header)
{
- header->priv = GTR_HEADER_GET_PRIVATE (header);
+ header->priv = GTR_HEADER_GET_PRIVATE (header);
}
-static void gtranslator_header_finalize (GObject *object)
+static void
+gtranslator_header_finalize (GObject * object)
{
- GtranslatorHeader *header = GTR_HEADER(object);
-
- g_free(header->priv->comment);
- g_free(header->priv->prj_id_version);
- g_free(header->priv->rmbt);
- g_free(header->priv->pot_date);
- g_free(header->priv->po_date);
- g_free(header->priv->translator);
- g_free(header->priv->tr_email);
- g_free(header->priv->language);
- g_free(header->priv->lg_email);
- g_free(header->priv->mime_version);
- g_free(header->priv->charset);
- g_free(header->priv->encoding);
- g_free(header->priv->plural_forms);
+ GtranslatorHeader *header = GTR_HEADER (object);
+
+ g_free (header->priv->comment);
+ g_free (header->priv->prj_id_version);
+ g_free (header->priv->rmbt);
+ g_free (header->priv->pot_date);
+ g_free (header->priv->po_date);
+ g_free (header->priv->translator);
+ g_free (header->priv->tr_email);
+ g_free (header->priv->language);
+ g_free (header->priv->lg_email);
+ g_free (header->priv->mime_version);
+ g_free (header->priv->charset);
+ g_free (header->priv->encoding);
+ g_free (header->priv->plural_forms);
- G_OBJECT_CLASS (gtranslator_header_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_header_parent_class)->finalize (object);
}
-static void gtranslator_header_class_init (GtranslatorHeaderClass *klass)
+static void
+gtranslator_header_class_init (GtranslatorHeaderClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorHeaderPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorHeaderPrivate));
- object_class->finalize = gtranslator_header_finalize;
+ object_class->finalize = gtranslator_header_finalize;
}
/*
* Public methods
*/
-GtranslatorHeader *gtranslator_header_new(void)
+GtranslatorHeader *
+gtranslator_header_new (void)
{
- GtranslatorHeader *header;
-
- header = g_object_new(GTR_TYPE_HEADER, NULL);
-
- return header;
+ GtranslatorHeader *header;
+
+ header = g_object_new (GTR_TYPE_HEADER, NULL);
+
+ return header;
}
-const gchar *gtranslator_header_get_comment (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_comment (GtranslatorHeader * header)
{
- return header->priv->comment;
+ return header->priv->comment;
}
-void gtranslator_header_set_comment (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_comment (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->comment)
- g_free(header->priv->comment);
- header->priv->comment = g_strdup(data);
+ if (header->priv->comment)
+ g_free (header->priv->comment);
+ header->priv->comment = g_strdup (data);
}
-const gchar *gtranslator_header_get_prj_id_version (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_prj_id_version (GtranslatorHeader * header)
{
- return header->priv->prj_id_version;
+ return header->priv->prj_id_version;
}
-void gtranslator_header_set_prj_id_version (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_prj_id_version (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->prj_id_version)
- g_free(header->priv->prj_id_version);
- header->priv->prj_id_version = g_strdup(data);
+ if (header->priv->prj_id_version)
+ g_free (header->priv->prj_id_version);
+ header->priv->prj_id_version = g_strdup (data);
}
-const gchar *gtranslator_header_get_rmbt (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_rmbt (GtranslatorHeader * header)
{
- return header->priv->rmbt;
+ return header->priv->rmbt;
}
-void gtranslator_header_set_rmbt (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_rmbt (GtranslatorHeader * header, const gchar * data)
{
- if(header->priv->rmbt)
- g_free(header->priv->rmbt);
- header->priv->rmbt = g_strdup(data);
+ if (header->priv->rmbt)
+ g_free (header->priv->rmbt);
+ header->priv->rmbt = g_strdup (data);
}
-const gchar *gtranslator_header_get_pot_date (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_pot_date (GtranslatorHeader * header)
{
- return header->priv->pot_date;
+ return header->priv->pot_date;
}
-void gtranslator_header_set_pot_date (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_pot_date (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->pot_date)
- g_free(header->priv->pot_date);
- header->priv->pot_date = g_strdup(data);
+ if (header->priv->pot_date)
+ g_free (header->priv->pot_date);
+ header->priv->pot_date = g_strdup (data);
}
-const gchar *gtranslator_header_get_po_date (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_po_date (GtranslatorHeader * header)
{
- return header->priv->po_date;
+ return header->priv->po_date;
}
-void gtranslator_header_set_po_date (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_po_date (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->po_date)
- g_free(header->priv->po_date);
- header->priv->po_date = g_strdup(data);
+ if (header->priv->po_date)
+ g_free (header->priv->po_date);
+ header->priv->po_date = g_strdup (data);
}
-const gchar *gtranslator_header_get_translator (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_translator (GtranslatorHeader * header)
{
- return header->priv->translator;
+ return header->priv->translator;
}
-void gtranslator_header_set_translator (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_translator (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->translator)
- g_free(header->priv->translator);
- header->priv->translator = g_strdup(data);
+ if (header->priv->translator)
+ g_free (header->priv->translator);
+ header->priv->translator = g_strdup (data);
}
-const gchar *gtranslator_header_get_tr_email (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_tr_email (GtranslatorHeader * header)
{
- return header->priv->tr_email;
+ return header->priv->tr_email;
}
-void gtranslator_header_set_tr_email (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_tr_email (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->tr_email)
- g_free(header->priv->tr_email);
- header->priv->tr_email = g_strdup(data);
+ if (header->priv->tr_email)
+ g_free (header->priv->tr_email);
+ header->priv->tr_email = g_strdup (data);
}
-const gchar *gtranslator_header_get_prev_translator (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_prev_translator (GtranslatorHeader * header)
{
- return header->priv->prev_translator;
+ return header->priv->prev_translator;
}
-void gtranslator_header_set_prev_translator (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_prev_translator (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->prev_translator)
- g_free(header->priv->prev_translator);
- header->priv->prev_translator = g_strdup(data);
+ if (header->priv->prev_translator)
+ g_free (header->priv->prev_translator);
+ header->priv->prev_translator = g_strdup (data);
}
-const gchar *gtranslator_header_get_language (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_language (GtranslatorHeader * header)
{
- return header->priv->language;
+ return header->priv->language;
}
-void gtranslator_header_set_language (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_language (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->language)
- g_free(header->priv->language);
- header->priv->language = g_strdup(data);
+ if (header->priv->language)
+ g_free (header->priv->language);
+ header->priv->language = g_strdup (data);
}
-const gchar *gtranslator_header_get_lg_email (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_lg_email (GtranslatorHeader * header)
{
- return header->priv->lg_email;
+ return header->priv->lg_email;
}
-void gtranslator_header_set_lg_email (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_lg_email (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->lg_email)
- g_free(header->priv->lg_email);
- header->priv->lg_email = g_strdup(data);
+ if (header->priv->lg_email)
+ g_free (header->priv->lg_email);
+ header->priv->lg_email = g_strdup (data);
}
-const gchar *gtranslator_header_get_mime_version (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_mime_version (GtranslatorHeader * header)
{
- return header->priv->mime_version;
+ return header->priv->mime_version;
}
-void gtranslator_header_set_mime_version (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_mime_version (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->mime_version)
- g_free(header->priv->mime_version);
- header->priv->mime_version = g_strdup(data);
+ if (header->priv->mime_version)
+ g_free (header->priv->mime_version);
+ header->priv->mime_version = g_strdup (data);
}
-const gchar *gtranslator_header_get_charset (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_charset (GtranslatorHeader * header)
{
- return header->priv->charset;
+ return header->priv->charset;
}
-void gtranslator_header_set_charset (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_charset (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->charset)
- g_free(header->priv->charset);
- header->priv->charset = g_strdup(data);
+ if (header->priv->charset)
+ g_free (header->priv->charset);
+ header->priv->charset = g_strdup (data);
}
-const gchar *gtranslator_header_get_encoding (GtranslatorHeader *header)
+const gchar *
+gtranslator_header_get_encoding (GtranslatorHeader * header)
{
- return header->priv->encoding;
+ return header->priv->encoding;
}
-void gtranslator_header_set_encoding (GtranslatorHeader *header, const gchar *data)
+void
+gtranslator_header_set_encoding (GtranslatorHeader * header,
+ const gchar * data)
{
- if(header->priv->encoding)
- g_free(header->priv->encoding);
- header->priv->encoding = g_strdup(data);
+ if (header->priv->encoding)
+ g_free (header->priv->encoding);
+ header->priv->encoding = g_strdup (data);
}
/**
@@ -344,11 +384,11 @@ void gtranslator_header_set_encoding (GtranslatorHeader *header, const gchar *da
* Return value: the plural form of the po file.
*/
const gchar *
-gtranslator_header_get_plural_forms (GtranslatorHeader *header)
+gtranslator_header_get_plural_forms (GtranslatorHeader * header)
{
- g_return_val_if_fail (GTR_IS_HEADER (header), NULL);
-
- return (const gchar *)header->priv->plural_forms;
+ g_return_val_if_fail (GTR_IS_HEADER (header), NULL);
+
+ return (const gchar *) header->priv->plural_forms;
}
/**
@@ -359,24 +399,24 @@ gtranslator_header_get_plural_forms (GtranslatorHeader *header)
* Sets the plural form string in the @header and it sets the number of plurals.
*/
void
-gtranslator_header_set_plural_forms (GtranslatorHeader *header,
- const gchar *plural_forms)
-{
- g_return_if_fail (GTR_IS_HEADER (header));
-
- if (header->priv->plural_forms)
- g_free (header->priv->plural_forms);
-
- if (!plural_forms)
- {
- header->priv->plural_forms = NULL;
- return;
- }
-
- header->priv->plural_forms = g_strdup (plural_forms);
-
- /*Now we parse the plural forms to know the number of plurals*/
- parse_nplurals (header);
+gtranslator_header_set_plural_forms (GtranslatorHeader * header,
+ const gchar * plural_forms)
+{
+ g_return_if_fail (GTR_IS_HEADER (header));
+
+ if (header->priv->plural_forms)
+ g_free (header->priv->plural_forms);
+
+ if (!plural_forms)
+ {
+ header->priv->plural_forms = NULL;
+ return;
+ }
+
+ header->priv->plural_forms = g_strdup (plural_forms);
+
+ /*Now we parse the plural forms to know the number of plurals */
+ parse_nplurals (header);
}
/**
@@ -387,7 +427,7 @@ gtranslator_header_set_plural_forms (GtranslatorHeader *header,
*/
gboolean
-gtranslator_header_get_header_changed (GtranslatorHeader *header)
+gtranslator_header_get_header_changed (GtranslatorHeader * header)
{
g_return_val_if_fail (GTR_IS_HEADER (header), FALSE);
@@ -403,7 +443,8 @@ gtranslator_header_get_header_changed (GtranslatorHeader *header)
*/
void
-gtranslator_header_set_header_changed (GtranslatorHeader *header, gboolean change)
+gtranslator_header_set_header_changed (GtranslatorHeader * header,
+ gboolean change)
{
header->priv->header_changed = change;
}
@@ -416,32 +457,34 @@ gtranslator_header_set_header_changed (GtranslatorHeader *header, gboolean chang
* form in the po file it returns the predefined by user number of plurals
* or 0 if there is not a plural form string stored.
*/
-gint
-gtranslator_header_get_nplurals (GtranslatorHeader *header)
-{
- const gchar *plural_form;
- GtranslatorProfile *profile;
-
- profile = gtranslator_application_get_active_profile (GTR_APP);
-
- g_return_val_if_fail (GTR_IS_HEADER (header), -1);
- g_return_val_if_fail (profile, -1);
-
- /*
- * If the priv->plural_forms exists that means that there is a plural
- * form in our po file, If not we have to use the predefined plural form
- * by the user.
- */
- if (header->priv->plural_forms)
- return header->priv->nplurals;
- else if (plural_form = (const gchar *)gtranslator_profile_get_plurals (profile))
- {
- gtranslator_header_set_plural_forms (header, plural_form);
- /*
- * FIXME: To don't produce a gettext error maybe we have to set the
- * plural form in the gettext header field too.
- */
- return header->priv->nplurals;
- }
- else return 1;
+gint
+gtranslator_header_get_nplurals (GtranslatorHeader * header)
+{
+ const gchar *plural_form;
+ GtranslatorProfile *profile;
+
+ profile = gtranslator_application_get_active_profile (GTR_APP);
+
+ g_return_val_if_fail (GTR_IS_HEADER (header), -1);
+ g_return_val_if_fail (profile, -1);
+
+ /*
+ * If the priv->plural_forms exists that means that there is a plural
+ * form in our po file, If not we have to use the predefined plural form
+ * by the user.
+ */
+ if (header->priv->plural_forms)
+ return header->priv->nplurals;
+ else if (plural_form =
+ (const gchar *) gtranslator_profile_get_plurals (profile))
+ {
+ gtranslator_header_set_plural_forms (header, plural_form);
+ /*
+ * FIXME: To don't produce a gettext error maybe we have to set the
+ * plural form in the gettext header field too.
+ */
+ return header->priv->nplurals;
+ }
+ else
+ return 1;
}
diff --git a/src/header.h b/src/header.h
index 668a877..d73a01b 100644
--- a/src/header.h
+++ b/src/header.h
@@ -38,12 +38,12 @@
#define GTR_HEADER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_HEADER, GtranslatorHeaderClass))
/* Private structure type */
-typedef struct _GtranslatorHeaderPrivate GtranslatorHeaderPrivate;
+typedef struct _GtranslatorHeaderPrivate GtranslatorHeaderPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorHeader GtranslatorHeader;
+typedef struct _GtranslatorHeader GtranslatorHeader;
struct _GtranslatorHeader
{
@@ -55,7 +55,7 @@ struct _GtranslatorHeader
/*
* Class definition
*/
-typedef struct _GtranslatorHeaderClass GtranslatorHeaderClass;
+typedef struct _GtranslatorHeaderClass GtranslatorHeaderClass;
struct _GtranslatorHeaderClass
{
@@ -65,60 +65,105 @@ struct _GtranslatorHeaderClass
/*
* Public methods
*/
-GType gtranslator_header_get_type (void) G_GNUC_CONST;
-
-GType gtranslator_header_register_type (GTypeModule * module);
-
-GtranslatorHeader
-*gtranslator_header_new (void);
-
-const gchar *gtranslator_header_get_comment (GtranslatorHeader *header);
-void gtranslator_header_set_comment (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_prj_id_version (GtranslatorHeader *header);
-void gtranslator_header_set_prj_id_version (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_rmbt (GtranslatorHeader *header);
-void gtranslator_header_set_rmbt (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_pot_date (GtranslatorHeader *header);
-void gtranslator_header_set_pot_date (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_po_date (GtranslatorHeader *header);
-void gtranslator_header_set_po_date (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_translator (GtranslatorHeader *header);
-void gtranslator_header_set_translator (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_tr_email (GtranslatorHeader *header);
-void gtranslator_header_set_tr_email (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_prev_translator (GtranslatorHeader *header);
-void gtranslator_header_set_prev_translator (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_language (GtranslatorHeader *header);
-void gtranslator_header_set_language (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_lg_email (GtranslatorHeader *header);
-void gtranslator_header_set_lg_email (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_mime_version (GtranslatorHeader *header);
-void gtranslator_header_set_mime_version (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_charset (GtranslatorHeader *header);
-void gtranslator_header_set_charset (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_encoding (GtranslatorHeader *header);
-void gtranslator_header_set_encoding (GtranslatorHeader *header, const gchar *data);
-
-const gchar *gtranslator_header_get_plural_forms (GtranslatorHeader *header);
-void gtranslator_header_set_plural_forms (GtranslatorHeader *header,
- const gchar *plural_forms);
-
-gboolean gtranslator_header_get_header_changed (GtranslatorHeader *header);
-void gtranslator_header_set_header_changed (GtranslatorHeader *header,
- gboolean change);
-
-gint gtranslator_header_get_nplurals (GtranslatorHeader *header);
+GType
+gtranslator_header_get_type (void)
+ G_GNUC_CONST;
+
+ GType gtranslator_header_register_type (GTypeModule * module);
+
+GtranslatorHeader * gtranslator_header_new (void);
+
+ const gchar *
+ gtranslator_header_get_comment (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_comment (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_prj_id_version (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_prj_id_version (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_rmbt (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_rmbt (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_pot_date (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_pot_date (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_po_date (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_po_date (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_translator (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_translator (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_tr_email (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_tr_email (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_prev_translator (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_prev_translator (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_language (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_language (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_lg_email (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_lg_email (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_mime_version (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_mime_version (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_charset (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_charset (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_encoding (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_encoding (GtranslatorHeader * header,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_header_get_plural_forms (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_plural_forms (GtranslatorHeader * header,
+ const gchar * plural_forms);
+
+ gboolean
+ gtranslator_header_get_header_changed (GtranslatorHeader * header);
+ void
+ gtranslator_header_set_header_changed (GtranslatorHeader * header,
+ gboolean change);
+
+ gint
+ gtranslator_header_get_nplurals (GtranslatorHeader * header);
#endif /* __HEADER_H__ */
diff --git a/src/history-entry.c b/src/history-entry.c
index 873b073..1aaa743 100644
--- a/src/history-entry.c
+++ b/src/history-entry.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2006. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -39,10 +39,11 @@
#include "history-entry.h"
-enum {
- PROP_0,
- PROP_HISTORY_ID,
- PROP_HISTORY_LENGTH
+enum
+{
+ PROP_0,
+ PROP_HISTORY_ID,
+ PROP_HISTORY_LENGTH
};
#define MIN_ITEM_LEN 3
@@ -55,517 +56,492 @@ enum {
struct _GtranslatorHistoryEntryPrivate
{
- gchar *history_id;
- guint history_length;
-
- GtkEntryCompletion *completion;
-
- GConfClient *gconf_client;
-};
+ gchar *history_id;
+ guint history_length;
-G_DEFINE_TYPE(GtranslatorHistoryEntry, gtranslator_history_entry, GTK_TYPE_COMBO_BOX_ENTRY)
+ GtkEntryCompletion *completion;
-static void
-gtranslator_history_entry_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *spec)
+ GConfClient *gconf_client;
+};
+
+G_DEFINE_TYPE (GtranslatorHistoryEntry, gtranslator_history_entry,
+ GTK_TYPE_COMBO_BOX_ENTRY)
+ static void gtranslator_history_entry_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * spec)
{
- GtranslatorHistoryEntry *entry;
-
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (object));
-
- entry = GTR_HISTORY_ENTRY (object);
-
- switch (prop_id) {
- case PROP_HISTORY_ID:
- entry->priv->history_id = g_value_dup_string (value);
- break;
- case PROP_HISTORY_LENGTH:
- gtranslator_history_entry_set_history_length (entry,
- g_value_get_uint (value));
- break;
- default:
- break;
- }
+ GtranslatorHistoryEntry *entry;
+
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (object));
+
+ entry = GTR_HISTORY_ENTRY (object);
+
+ switch (prop_id)
+ {
+ case PROP_HISTORY_ID:
+ entry->priv->history_id = g_value_dup_string (value);
+ break;
+ case PROP_HISTORY_LENGTH:
+ gtranslator_history_entry_set_history_length (entry,
+ g_value_get_uint (value));
+ break;
+ default:
+ break;
+ }
}
static void
-gtranslator_history_entry_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *spec)
+gtranslator_history_entry_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * spec)
{
- GtranslatorHistoryEntryPrivate *priv;
-
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (object));
-
- priv = GTR_HISTORY_ENTRY (object)->priv;
-
- switch (prop_id) {
- case PROP_HISTORY_ID:
- g_value_set_string (value, priv->history_id);
- break;
- case PROP_HISTORY_LENGTH:
- g_value_set_uint (value, priv->history_length);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
- }
+ GtranslatorHistoryEntryPrivate *priv;
+
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (object));
+
+ priv = GTR_HISTORY_ENTRY (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_HISTORY_ID:
+ g_value_set_string (value, priv->history_id);
+ break;
+ case PROP_HISTORY_LENGTH:
+ g_value_set_uint (value, priv->history_length);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
+ }
}
static void
-gtranslator_history_entry_destroy (GtkObject *object)
+gtranslator_history_entry_destroy (GtkObject * object)
{
- gtranslator_history_entry_set_enable_completion (GTR_HISTORY_ENTRY (object),
+ gtranslator_history_entry_set_enable_completion (GTR_HISTORY_ENTRY (object),
FALSE);
- GTK_OBJECT_CLASS (gtranslator_history_entry_parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (gtranslator_history_entry_parent_class)->destroy (object);
}
static void
-gtranslator_history_entry_finalize (GObject *object)
+gtranslator_history_entry_finalize (GObject * object)
{
- GtranslatorHistoryEntryPrivate *priv;
+ GtranslatorHistoryEntryPrivate *priv;
- priv = GTR_HISTORY_ENTRY (object)->priv;
-
- g_free (priv->history_id);
+ priv = GTR_HISTORY_ENTRY (object)->priv;
- if (priv->gconf_client != NULL)
- {
- g_object_unref (G_OBJECT (priv->gconf_client));
- priv->gconf_client = NULL;
- }
+ g_free (priv->history_id);
- G_OBJECT_CLASS (gtranslator_history_entry_parent_class)->finalize (object);
+ if (priv->gconf_client != NULL)
+ {
+ g_object_unref (G_OBJECT (priv->gconf_client));
+ priv->gconf_client = NULL;
+ }
+
+ G_OBJECT_CLASS (gtranslator_history_entry_parent_class)->finalize (object);
}
-static void
-gtranslator_history_entry_class_init (GtranslatorHistoryEntryClass *klass)
+static void
+gtranslator_history_entry_class_init (GtranslatorHistoryEntryClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
-
- object_class->set_property = gtranslator_history_entry_set_property;
- object_class->get_property = gtranslator_history_entry_get_property;
- object_class->finalize = gtranslator_history_entry_finalize;
- gtkobject_class->destroy = gtranslator_history_entry_destroy;
-
- g_object_class_install_property (object_class,
- PROP_HISTORY_ID,
- g_param_spec_string ("history-id",
- "History ID",
- "History ID",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_HISTORY_LENGTH,
- g_param_spec_uint ("history-length",
- "Max History Length",
- "Max History Length",
- 0,
- G_MAXUINT,
- GTR_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- /* TODO: Add enable-completion property */
-
- g_type_class_add_private (object_class, sizeof(GtranslatorHistoryEntryPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
+
+ object_class->set_property = gtranslator_history_entry_set_property;
+ object_class->get_property = gtranslator_history_entry_get_property;
+ object_class->finalize = gtranslator_history_entry_finalize;
+ gtkobject_class->destroy = gtranslator_history_entry_destroy;
+
+ g_object_class_install_property (object_class,
+ PROP_HISTORY_ID,
+ g_param_spec_string ("history-id",
+ "History ID",
+ "History ID",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_HISTORY_LENGTH,
+ g_param_spec_uint ("history-length",
+ "Max History Length",
+ "Max History Length",
+ 0,
+ G_MAXUINT,
+ GTR_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ /* TODO: Add enable-completion property */
+
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorHistoryEntryPrivate));
}
static GtkListStore *
-get_history_store (GtranslatorHistoryEntry *entry)
+get_history_store (GtranslatorHistoryEntry * entry)
{
- GtkTreeModel *store;
+ GtkTreeModel *store;
- store = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
- g_return_val_if_fail (GTK_IS_LIST_STORE (store), NULL);
+ store = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
+ g_return_val_if_fail (GTK_IS_LIST_STORE (store), NULL);
- return (GtkListStore *) store;
+ return (GtkListStore *) store;
}
static char *
-get_history_key (GtranslatorHistoryEntry *entry)
+get_history_key (GtranslatorHistoryEntry * entry)
{
- gchar *tmp;
- gchar *key;
-
- /*
- * We store the data under /apps/gnome-settings/
- * like the old GnomeEntry did. Maybe we should
- * consider moving it to the /gtranslator GConf prefix...
- * Or maybe we should just switch away from GConf.
- */
-
- tmp = gconf_escape_key (entry->priv->history_id, -1);
- key = g_strconcat ("/apps/gnome-settings/",
- "gtranslator",
- "/history-",
- tmp,
- NULL);
- g_free (tmp);
-
- return key;
+ gchar *tmp;
+ gchar *key;
+
+ /*
+ * We store the data under /apps/gnome-settings/
+ * like the old GnomeEntry did. Maybe we should
+ * consider moving it to the /gtranslator GConf prefix...
+ * Or maybe we should just switch away from GConf.
+ */
+
+ tmp = gconf_escape_key (entry->priv->history_id, -1);
+ key = g_strconcat ("/apps/gnome-settings/",
+ "gtranslator", "/history-", tmp, NULL);
+ g_free (tmp);
+
+ return key;
}
static GSList *
-get_history_list (GtranslatorHistoryEntry *entry)
+get_history_list (GtranslatorHistoryEntry * entry)
{
- GtkListStore *store;
- GtkTreeIter iter;
- gboolean valid;
- GSList *list = NULL;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ gboolean valid;
+ GSList *list = NULL;
- store = get_history_store (entry);
+ store = get_history_store (entry);
- valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store),
- &iter);
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
- while (valid)
- {
- gchar *str;
+ while (valid)
+ {
+ gchar *str;
- gtk_tree_model_get (GTK_TREE_MODEL (store),
- &iter,
- 0, &str,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &str, -1);
- list = g_slist_prepend (list, str);
+ list = g_slist_prepend (list, str);
- valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store),
- &iter);
- }
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
+ }
- return g_slist_reverse (list);
+ return g_slist_reverse (list);
}
static void
-gtranslator_history_entry_save_history (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_save_history (GtranslatorHistoryEntry * entry)
{
- GSList *gconf_items;
- gchar *key;
+ GSList *gconf_items;
+ gchar *key;
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- gconf_items = get_history_list (entry);
- key = get_history_key (entry);
+ gconf_items = get_history_list (entry);
+ key = get_history_key (entry);
- gconf_client_set_list (entry->priv->gconf_client,
- key,
- GCONF_VALUE_STRING,
- gconf_items,
- NULL);
+ gconf_client_set_list (entry->priv->gconf_client,
+ key, GCONF_VALUE_STRING, gconf_items, NULL);
- g_slist_foreach (gconf_items, (GFunc) g_free, NULL);
- g_slist_free (gconf_items);
- g_free (key);
+ g_slist_foreach (gconf_items, (GFunc) g_free, NULL);
+ g_slist_free (gconf_items);
+ g_free (key);
}
static gboolean
-remove_item (GtkListStore *store,
- const gchar *text)
+remove_item (GtkListStore * store, const gchar * text)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- g_return_val_if_fail (text != NULL, FALSE);
+ g_return_val_if_fail (text != NULL, FALSE);
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
- return FALSE;
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
+ return FALSE;
- do
- {
- gchar *item_text;
+ do
+ {
+ gchar *item_text;
- gtk_tree_model_get (GTK_TREE_MODEL (store),
- &iter,
- 0,
- &item_text,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &item_text, -1);
- if (item_text != NULL &&
- strcmp (item_text, text) == 0)
- {
- gtk_list_store_remove (store, &iter);
- g_free (item_text);
- return TRUE;
- }
+ if (item_text != NULL && strcmp (item_text, text) == 0)
+ {
+ gtk_list_store_remove (store, &iter);
+ g_free (item_text);
+ return TRUE;
+ }
- g_free (item_text);
+ g_free (item_text);
- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
+ }
+ while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
- return FALSE;
+ return FALSE;
}
static void
-clamp_list_store (GtkListStore *store,
- guint max)
+clamp_list_store (GtkListStore * store, guint max)
{
- GtkTreePath *path;
- GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- /* -1 because TreePath counts from 0 */
- path = gtk_tree_path_new_from_indices (max - 1, -1);
+ /* -1 because TreePath counts from 0 */
+ path = gtk_tree_path_new_from_indices (max - 1, -1);
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
+ {
+ while (1)
{
- while (1)
- {
- if (!gtk_list_store_remove (store, &iter))
- break;
- }
+ if (!gtk_list_store_remove (store, &iter))
+ break;
}
+ }
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
}
static void
-insert_history_item (GtranslatorHistoryEntry *entry,
- const gchar *text,
- gboolean prepend)
+insert_history_item (GtranslatorHistoryEntry * entry,
+ const gchar * text, gboolean prepend)
{
- GtkListStore *store;
- GtkTreeIter iter;
-
- if (g_utf8_strlen (text, -1) <= MIN_ITEM_LEN)
- return;
-
- store = get_history_store (entry);
-
- /* remove the text from the store if it was already
- * present. If it wasn't, clamp to max history - 1
- * before inserting the new row, otherwise appending
- * would not work */
-
- if (!remove_item (store, text))
- clamp_list_store (store,
- entry->priv->history_length - 1);
-
- if (prepend)
- gtk_list_store_insert (store, &iter, 0);
- else
- gtk_list_store_append (store, &iter);
-
- gtk_list_store_set (store,
- &iter,
- 0,
- text,
- -1);
-
- gtranslator_history_entry_save_history (entry);
+ GtkListStore *store;
+ GtkTreeIter iter;
+
+ if (g_utf8_strlen (text, -1) <= MIN_ITEM_LEN)
+ return;
+
+ store = get_history_store (entry);
+
+ /* remove the text from the store if it was already
+ * present. If it wasn't, clamp to max history - 1
+ * before inserting the new row, otherwise appending
+ * would not work */
+
+ if (!remove_item (store, text))
+ clamp_list_store (store, entry->priv->history_length - 1);
+
+ if (prepend)
+ gtk_list_store_insert (store, &iter, 0);
+ else
+ gtk_list_store_append (store, &iter);
+
+ gtk_list_store_set (store, &iter, 0, text, -1);
+
+ gtranslator_history_entry_save_history (entry);
}
void
-gtranslator_history_entry_prepend_text (GtranslatorHistoryEntry *entry,
- const gchar *text)
+gtranslator_history_entry_prepend_text (GtranslatorHistoryEntry * entry,
+ const gchar * text)
{
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- g_return_if_fail (text != NULL);
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (text != NULL);
- insert_history_item (entry, text, TRUE);
+ insert_history_item (entry, text, TRUE);
}
void
-gtranslator_history_entry_append_text (GtranslatorHistoryEntry *entry,
- const gchar *text)
+gtranslator_history_entry_append_text (GtranslatorHistoryEntry * entry,
+ const gchar * text)
{
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- g_return_if_fail (text != NULL);
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (text != NULL);
- insert_history_item (entry, text, FALSE);
+ insert_history_item (entry, text, FALSE);
}
static void
-gtranslator_history_entry_load_history (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_load_history (GtranslatorHistoryEntry * entry)
{
- GSList *gconf_items, *l;
- GtkListStore *store;
- GtkTreeIter iter;
- gchar *key;
- gint i;
+ GSList *gconf_items, *l;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ gchar *key;
+ gint i;
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- store = get_history_store (entry);
- key = get_history_key (entry);
+ store = get_history_store (entry);
+ key = get_history_key (entry);
- gconf_items = gconf_client_get_list (entry->priv->gconf_client,
- key,
- GCONF_VALUE_STRING,
- NULL);
+ gconf_items = gconf_client_get_list (entry->priv->gconf_client,
+ key, GCONF_VALUE_STRING, NULL);
- gtk_list_store_clear (store);
+ gtk_list_store_clear (store);
- for (l = gconf_items, i = 0;
- l != NULL && i < entry->priv->history_length;
- l = l->next, i++)
- {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store,
- &iter,
- 0,
- l->data,
- -1);
- }
+ for (l = gconf_items, i = 0;
+ l != NULL && i < entry->priv->history_length; l = l->next, i++)
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, l->data, -1);
+ }
- g_slist_foreach (gconf_items, (GFunc) g_free, NULL);
- g_slist_free (gconf_items);
- g_free (key);
+ g_slist_foreach (gconf_items, (GFunc) g_free, NULL);
+ g_slist_free (gconf_items);
+ g_free (key);
}
void
-gtranslator_history_entry_clear (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_clear (GtranslatorHistoryEntry * entry)
{
- GtkListStore *store;
+ GtkListStore *store;
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- store = get_history_store (entry);
- gtk_list_store_clear (store);
+ store = get_history_store (entry);
+ gtk_list_store_clear (store);
- gtranslator_history_entry_save_history (entry);
+ gtranslator_history_entry_save_history (entry);
}
static void
-gtranslator_history_entry_init (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_init (GtranslatorHistoryEntry * entry)
{
- GtranslatorHistoryEntryPrivate *priv;
+ GtranslatorHistoryEntryPrivate *priv;
+
+ priv = GTR_HISTORY_ENTRY_GET_PRIVATE (entry);
+ entry->priv = priv;
- priv = GTR_HISTORY_ENTRY_GET_PRIVATE (entry);
- entry->priv = priv;
+ priv->history_id = NULL;
+ priv->history_length = GTR_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT;
- priv->history_id = NULL;
- priv->history_length = GTR_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT;
+ priv->completion = NULL;
- priv->completion = NULL;
-
- priv->gconf_client = gconf_client_get_default ();
+ priv->gconf_client = gconf_client_get_default ();
}
void
-gtranslator_history_entry_set_history_length (GtranslatorHistoryEntry *entry,
- guint history_length)
+gtranslator_history_entry_set_history_length (GtranslatorHistoryEntry * entry,
+ guint history_length)
{
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- g_return_if_fail (history_length > 0);
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (history_length > 0);
- entry->priv->history_length = history_length;
+ entry->priv->history_length = history_length;
- /* TODO: update if we currently have more items than max */
+ /* TODO: update if we currently have more items than max */
}
guint
-gtranslator_history_entry_get_history_length (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_get_history_length (GtranslatorHistoryEntry * entry)
{
- g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), 0);
+ g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), 0);
- return entry->priv->history_length;
+ return entry->priv->history_length;
}
gchar *
-gtranslator_history_entry_get_history_id (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_get_history_id (GtranslatorHistoryEntry * entry)
{
- g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), NULL);
+ g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), NULL);
- return g_strdup (entry->priv->history_id);
+ return g_strdup (entry->priv->history_id);
}
void
-gtranslator_history_entry_set_enable_completion (GtranslatorHistoryEntry *entry,
- gboolean enable)
+gtranslator_history_entry_set_enable_completion (GtranslatorHistoryEntry *
+ entry, gboolean enable)
{
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
-
- if (enable)
- {
- if (entry->priv->completion != NULL)
- return;
-
- entry->priv->completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (entry->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_minimum_key_length (entry->priv->completion,
- MIN_ITEM_LEN);
-
- gtk_entry_completion_set_popup_completion (entry->priv->completion, FALSE);
- gtk_entry_completion_set_inline_completion (entry->priv->completion, TRUE);
-
- /* Assign the completion to the entry */
- gtk_entry_set_completion (GTK_ENTRY (gtranslator_history_entry_get_entry(entry)),
- entry->priv->completion);
- }
- else
- {
- if (entry->priv->completion == NULL)
- return;
-
- gtk_entry_set_completion (GTK_ENTRY (gtranslator_history_entry_get_entry (entry)),
- NULL);
-
- g_object_unref (entry->priv->completion);
-
- entry->priv->completion = NULL;
- }
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+
+ if (enable)
+ {
+ if (entry->priv->completion != NULL)
+ return;
+
+ entry->priv->completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (entry->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_minimum_key_length (entry->priv->completion,
+ MIN_ITEM_LEN);
+
+ gtk_entry_completion_set_popup_completion (entry->priv->completion,
+ FALSE);
+ gtk_entry_completion_set_inline_completion (entry->priv->completion,
+ TRUE);
+
+ /* Assign the completion to the entry */
+ gtk_entry_set_completion (GTK_ENTRY
+ (gtranslator_history_entry_get_entry (entry)),
+ entry->priv->completion);
+ }
+ else
+ {
+ if (entry->priv->completion == NULL)
+ return;
+
+ gtk_entry_set_completion (GTK_ENTRY
+ (gtranslator_history_entry_get_entry (entry)),
+ NULL);
+
+ g_object_unref (entry->priv->completion);
+
+ entry->priv->completion = NULL;
+ }
}
-
+
gboolean
-gtranslator_history_entry_get_enable_completion (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_get_enable_completion (GtranslatorHistoryEntry *
+ entry)
{
- g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), FALSE);
-
- return entry->priv->completion != NULL;
+ g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), FALSE);
+
+ return entry->priv->completion != NULL;
}
GtkWidget *
-gtranslator_history_entry_new (const gchar *history_id,
- gboolean enable_completion)
+gtranslator_history_entry_new (const gchar * history_id,
+ gboolean enable_completion)
{
- GtkWidget *ret;
- GtkListStore *store;
-
- g_return_val_if_fail (history_id != NULL, NULL);
-
- /* Note that we are setting the model, so
- * user must be careful to always manipulate
- * data in the history through gtranslator_history_entry_
- * functions.
- */
-
- store = gtk_list_store_new (1, G_TYPE_STRING);
-
- ret = g_object_new (GTR_TYPE_HISTORY_ENTRY,
- "history-id", history_id,
- "model", store,
- "text-column", 0,
- NULL);
-
- g_object_unref (store);
-
- /* loading has to happen after the model
- * has been set. However the model is not a
- * G_PARAM_CONSTRUCT property of GtkComboBox
- * so we cannot do this in the constructor.
- * For now we simply do here since this widget is
- * not bound to other programming languages.
- * A maybe better alternative is to override the
- * model property of combobox and mark CONTRUCT_ONLY.
- * This would also ensure that the model cannot be
- * set explicitely at a later time.
- */
- gtranslator_history_entry_load_history (GTR_HISTORY_ENTRY (ret));
-
- gtranslator_history_entry_set_enable_completion (GTR_HISTORY_ENTRY (ret),
+ GtkWidget *ret;
+ GtkListStore *store;
+
+ g_return_val_if_fail (history_id != NULL, NULL);
+
+ /* Note that we are setting the model, so
+ * user must be careful to always manipulate
+ * data in the history through gtranslator_history_entry_
+ * functions.
+ */
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+
+ ret = g_object_new (GTR_TYPE_HISTORY_ENTRY,
+ "history-id", history_id,
+ "model", store, "text-column", 0, NULL);
+
+ g_object_unref (store);
+
+ /* loading has to happen after the model
+ * has been set. However the model is not a
+ * G_PARAM_CONSTRUCT property of GtkComboBox
+ * so we cannot do this in the constructor.
+ * For now we simply do here since this widget is
+ * not bound to other programming languages.
+ * A maybe better alternative is to override the
+ * model property of combobox and mark CONTRUCT_ONLY.
+ * This would also ensure that the model cannot be
+ * set explicitely at a later time.
+ */
+ gtranslator_history_entry_load_history (GTR_HISTORY_ENTRY (ret));
+
+ gtranslator_history_entry_set_enable_completion (GTR_HISTORY_ENTRY (ret),
enable_completion);
-
- return ret;
+
+ return ret;
}
/*
@@ -577,56 +553,55 @@ gtranslator_history_entry_new (const gchar *history_id,
* handle the conflict.
*/
GtkWidget *
-gtranslator_history_entry_get_entry (GtranslatorHistoryEntry *entry)
+gtranslator_history_entry_get_entry (GtranslatorHistoryEntry * entry)
{
- g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), NULL);
+ g_return_val_if_fail (GTR_IS_HISTORY_ENTRY (entry), NULL);
- return gtk_bin_get_child (GTK_BIN (entry));
+ return gtk_bin_get_child (GTK_BIN (entry));
}
static void
-escape_cell_data_func (GtkTreeViewColumn *col,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- GtranslatorHistoryEntryEscapeFunc escape_func)
+escape_cell_data_func (GtkTreeViewColumn * col,
+ GtkCellRenderer * renderer,
+ GtkTreeModel * model,
+ GtkTreeIter * iter,
+ GtranslatorHistoryEntryEscapeFunc escape_func)
{
- gchar *str;
- gchar *escaped;
+ gchar *str;
+ gchar *escaped;
- gtk_tree_model_get (model, iter, 0, &str, -1);
- escaped = escape_func (str);
- g_object_set (renderer, "text", escaped, NULL);
+ gtk_tree_model_get (model, iter, 0, &str, -1);
+ escaped = escape_func (str);
+ g_object_set (renderer, "text", escaped, NULL);
- g_free (str);
- g_free (escaped);
+ g_free (str);
+ g_free (escaped);
}
void
-gtranslator_history_entry_set_escape_func (GtranslatorHistoryEntry *entry,
- GtranslatorHistoryEntryEscapeFunc escape_func)
+gtranslator_history_entry_set_escape_func (GtranslatorHistoryEntry * entry,
+ GtranslatorHistoryEntryEscapeFunc
+ escape_func)
{
- GList *cells;
+ GList *cells;
- g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
+ g_return_if_fail (GTR_IS_HISTORY_ENTRY (entry));
- cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (entry));
+ cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (entry));
- /* We only have one cell renderer */
- g_return_if_fail (cells->data != NULL && cells->next == NULL);
+ /* We only have one cell renderer */
+ g_return_if_fail (cells->data != NULL && cells->next == NULL);
- if (escape_func != NULL)
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
- GTK_CELL_RENDERER (cells->data),
- (GtkCellLayoutDataFunc) escape_cell_data_func,
- escape_func,
- NULL);
- else
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
- GTK_CELL_RENDERER (cells->data),
- NULL,
- NULL,
- NULL);
+ if (escape_func != NULL)
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
+ GTK_CELL_RENDERER (cells->data),
+ (GtkCellLayoutDataFunc)
+ escape_cell_data_func, escape_func,
+ NULL);
+ else
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
+ GTK_CELL_RENDERER (cells->data),
+ NULL, NULL, NULL);
- g_list_free (cells);
+ g_list_free (cells);
}
diff --git a/src/history-entry.h b/src/history-entry.h
index 81a5f8a..fb9fd71 100644
--- a/src/history-entry.h
+++ b/src/history-entry.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2006. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -33,64 +33,68 @@
G_BEGIN_DECLS
-
#define GTR_TYPE_HISTORY_ENTRY (gtranslator_history_entry_get_type ())
#define GTR_HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_HISTORY_ENTRY, GtranslatorHistoryEntry))
#define GTR_HISTORY_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_HISTORY_ENTRY, GtranslatorHistoryEntryClass))
#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, GtranslatorHistoryEntryClass))
-
-
-typedef struct _GtranslatorHistoryEntry GtranslatorHistoryEntry;
-typedef struct _GtranslatorHistoryEntryClass GtranslatorHistoryEntryClass;
+typedef struct _GtranslatorHistoryEntry GtranslatorHistoryEntry;
+typedef struct _GtranslatorHistoryEntryClass GtranslatorHistoryEntryClass;
typedef struct _GtranslatorHistoryEntryPrivate GtranslatorHistoryEntryPrivate;
struct _GtranslatorHistoryEntryClass
{
- GtkComboBoxEntryClass parent_class;
+ GtkComboBoxEntryClass parent_class;
};
struct _GtranslatorHistoryEntry
{
- GtkComboBoxEntry parent_instance;
+ GtkComboBoxEntry parent_instance;
- GtranslatorHistoryEntryPrivate *priv;
+ GtranslatorHistoryEntryPrivate *priv;
};
-GType gtranslator_history_entry_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_history_entry_get_type (void)
+ G_GNUC_CONST;
-GtkWidget *gtranslator_history_entry_new (const gchar *history_id,
- gboolean enable_completion);
+ GtkWidget *gtranslator_history_entry_new (const gchar * history_id,
+ gboolean enable_completion);
-void gtranslator_history_entry_prepend_text (GtranslatorHistoryEntry *entry,
- const gchar *text);
+ void gtranslator_history_entry_prepend_text (GtranslatorHistoryEntry *
+ entry, const gchar * text);
-void gtranslator_history_entry_append_text (GtranslatorHistoryEntry *entry,
- const gchar *text);
+ void gtranslator_history_entry_append_text (GtranslatorHistoryEntry *
+ entry, const gchar * text);
-void gtranslator_history_entry_clear (GtranslatorHistoryEntry *entry);
+ void gtranslator_history_entry_clear (GtranslatorHistoryEntry * entry);
-void gtranslator_history_entry_set_history_length (GtranslatorHistoryEntry *entry,
- guint max_saved);
+ void
+ gtranslator_history_entry_set_history_length (GtranslatorHistoryEntry *
+ entry, guint max_saved);
-guint gtranslator_history_entry_get_history_length (GtranslatorHistoryEntry *gentry);
+ guint
+ gtranslator_history_entry_get_history_length (GtranslatorHistoryEntry *
+ gentry);
-gchar *gtranslator_history_entry_get_history_id (GtranslatorHistoryEntry *entry);
+ gchar *gtranslator_history_entry_get_history_id (GtranslatorHistoryEntry
+ * entry);
-void gtranslator_history_entry_set_enable_completion
- (GtranslatorHistoryEntry *entry,
- gboolean enable);
-
-gboolean gtranslator_history_entry_get_enable_completion
- (GtranslatorHistoryEntry *entry);
+ void gtranslator_history_entry_set_enable_completion
+ (GtranslatorHistoryEntry * entry, gboolean enable);
-GtkWidget *gtranslator_history_entry_get_entry (GtranslatorHistoryEntry *entry);
+ gboolean gtranslator_history_entry_get_enable_completion
+ (GtranslatorHistoryEntry * entry);
-typedef gchar * (* GtranslatorHistoryEntryEscapeFunc) (const gchar *str);
-void gtranslator_history_entry_set_escape_func (GtranslatorHistoryEntry *entry,
- GtranslatorHistoryEntryEscapeFunc escape_func);
+ GtkWidget *gtranslator_history_entry_get_entry (GtranslatorHistoryEntry *
+ entry);
-G_END_DECLS
+ typedef gchar *(*GtranslatorHistoryEntryEscapeFunc) (const gchar * str);
+ void gtranslator_history_entry_set_escape_func (GtranslatorHistoryEntry *
+ entry,
+ GtranslatorHistoryEntryEscapeFunc
+ escape_func);
+G_END_DECLS
#endif /* __GTR_HISTORY_ENTRY_H__ */
diff --git a/src/io-error-message-area.c b/src/io-error-message-area.c
index 3382598..f869367 100644
--- a/src/io-error-message-area.c
+++ b/src/io-error-message-area.c
@@ -27,100 +27,100 @@
* Message area funcs
*/
static void
-set_message_area_text_and_icon (GtranslatorMessageArea *message_area,
- const gchar *icon_stock_id,
- const gchar *primary_text,
- const gchar *secondary_text)
+set_message_area_text_and_icon (GtranslatorMessageArea * message_area,
+ const gchar * icon_stock_id,
+ const gchar * primary_text,
+ const gchar * secondary_text)
{
- GtkWidget *hbox_content;
- GtkWidget *image;
- GtkWidget *vbox;
- gchar *primary_markup;
- gchar *secondary_markup;
- GtkWidget *primary_label;
- GtkWidget *secondary_label;
+ GtkWidget *hbox_content;
+ GtkWidget *image;
+ GtkWidget *vbox;
+ gchar *primary_markup;
+ gchar *secondary_markup;
+ GtkWidget *primary_label;
+ GtkWidget *secondary_label;
- hbox_content = gtk_hbox_new (FALSE, 8);
- gtk_widget_show (hbox_content);
+ hbox_content = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox_content);
- image = gtk_image_new_from_stock (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);
+ image = gtk_image_new_from_stock (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);
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox_content), vbox, TRUE, TRUE, 0);
- primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
- primary_label = gtk_label_new (primary_markup);
- g_free (primary_markup);
+ primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
+ primary_label = gtk_label_new (primary_markup);
+ g_free (primary_markup);
- gtk_widget_show (primary_label);
+ gtk_widget_show (primary_label);
- 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_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_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS);
+ GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS);
- gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
- if (secondary_text != NULL) {
- secondary_markup = g_strdup_printf ("<small>%s</small>",
- secondary_text);
- secondary_label = gtk_label_new (secondary_markup);
- g_free (secondary_markup);
+ if (secondary_text != NULL)
+ {
+ secondary_markup = g_strdup_printf ("<small>%s</small>",
+ secondary_text);
+ secondary_label = gtk_label_new (secondary_markup);
+ g_free (secondary_markup);
- gtk_widget_show (secondary_label);
+ gtk_widget_show (secondary_label);
- gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
- GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS);
+ GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS);
- 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_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);
+ }
- gtranslator_message_area_set_contents (GTR_MESSAGE_AREA (message_area),
- hbox_content);
+ gtranslator_message_area_set_contents (GTR_MESSAGE_AREA (message_area),
+ hbox_content);
}
/*
* Callback func called when warning button is clicked
*/
-void warning_message_button_clicked(GtkWidget *widget,
- gint response_id,
- gpointer data)
+void
+warning_message_button_clicked (GtkWidget * widget,
+ gint response_id, gpointer data)
{
- if(response_id == GTK_RESPONSE_CLOSE){
- gtk_widget_hide(GTK_WIDGET(widget));
+ if (response_id == GTK_RESPONSE_CLOSE)
+ {
+ gtk_widget_hide (GTK_WIDGET (widget));
}
}
GtkWidget *
-create_error_message_area (const gchar *primary_text,
- const gchar *secondary_text)
+create_error_message_area (const gchar * primary_text,
+ const gchar * secondary_text)
{
- GtkWidget *message_area;
-
- message_area = gtranslator_message_area_new_with_buttons (
- "gtk-close", GTK_RESPONSE_CLOSE,
- NULL);
-
- set_message_area_text_and_icon (GTR_MESSAGE_AREA (message_area),
- GTK_STOCK_DIALOG_ERROR,
- primary_text,
- secondary_text);
-
- g_signal_connect(G_OBJECT(message_area), "response",
- G_CALLBACK(warning_message_button_clicked),
- NULL);
-
- gtk_widget_show(message_area);
-
- return message_area;
+ GtkWidget *message_area;
+
+ message_area =
+ gtranslator_message_area_new_with_buttons ("gtk-close",
+ GTK_RESPONSE_CLOSE, NULL);
+
+ set_message_area_text_and_icon (GTR_MESSAGE_AREA (message_area),
+ GTK_STOCK_DIALOG_ERROR,
+ primary_text, secondary_text);
+
+ g_signal_connect (G_OBJECT (message_area), "response",
+ G_CALLBACK (warning_message_button_clicked), NULL);
+
+ gtk_widget_show (message_area);
+
+ return message_area;
}
diff --git a/src/io-error-message-area.h b/src/io-error-message-area.h
index 59de020..8d2ee73 100644
--- a/src/io-error-message-area.h
+++ b/src/io-error-message-area.h
@@ -23,9 +23,7 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
-GtkWidget *create_error_message_area (const gchar *primary_text,
- const gchar *secondary_text);
+ GtkWidget * create_error_message_area (const gchar * primary_text,
+ const gchar * secondary_text);
G_END_DECLS
-
#endif
diff --git a/src/main.c b/src/main.c
index 539e4d0..15f7e9c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,43 +49,42 @@
static gchar **file_arguments = NULL;
-static const GOptionEntry options [] =
-{
- { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments,
- NULL, N_("[FILE...]") }, /* collects file arguments */
+static const GOptionEntry options[] = {
+ {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments,
+ NULL, N_("[FILE...]")}, /* collects file arguments */
- {NULL}
+ {NULL}
};
static GSList *
get_command_line_data ()
{
- GSList *file_list = NULL;
-
- if (file_arguments)
+ GSList *file_list = NULL;
+
+ if (file_arguments)
+ {
+ gint i;
+
+ for (i = 0; file_arguments[i]; i++)
{
- gint i;
-
- for (i = 0; file_arguments[i]; i++)
- {
- GFile *file;
-
- file = g_file_new_for_commandline_arg (file_arguments[i]);
-
- if (file != NULL){
- file_list = g_slist_prepend (file_list,
- file);
-
- }
- else
- g_print (_("%s: malformed file name or URI.\n"),
- file_arguments[i]);
- }
-
- file_list = g_slist_reverse (file_list);
+ GFile *file;
+
+ file = g_file_new_for_commandline_arg (file_arguments[i]);
+
+ if (file != NULL)
+ {
+ file_list = g_slist_prepend (file_list, file);
+
+ }
+ else
+ g_print (_("%s: malformed file name or URI.\n"),
+ file_arguments[i]);
}
-
- return file_list;
+
+ file_list = g_slist_reverse (file_list);
+ }
+
+ return file_list;
}
@@ -94,29 +93,26 @@ get_command_line_data ()
static void
setup_path (void)
{
- /* Set PATH to include the gedit executable's folder */
- wchar_t exe_filename[MAX_PATH];
- wchar_t *p;
- gchar *exe_folder_utf8;
- gchar *path;
-
- GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));
-
- p = wcsrchr (exe_filename, L'\\');
- g_assert (p != NULL);
-
- *p = L'\0';
- exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
-
- path = g_build_path (";",
- exe_folder_utf8,
- g_getenv ("PATH"),
- NULL);
- if (!g_setenv ("PATH", path, TRUE))
- g_warning ("Could not set PATH for gtranslator");
-
- g_free (exe_folder_utf8);
- g_free (path);
+ /* Set PATH to include the gedit executable's folder */
+ wchar_t exe_filename[MAX_PATH];
+ wchar_t *p;
+ gchar *exe_folder_utf8;
+ gchar *path;
+
+ GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));
+
+ p = wcsrchr (exe_filename, L'\\');
+ g_assert (p != NULL);
+
+ *p = L'\0';
+ exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
+
+ path = g_build_path (";", exe_folder_utf8, g_getenv ("PATH"), NULL);
+ if (!g_setenv ("PATH", path, TRUE))
+ g_warning ("Could not set PATH for gtranslator");
+
+ g_free (exe_folder_utf8);
+ g_free (path);
}
#endif
@@ -126,133 +122,135 @@ setup_path (void)
* The ubiquitous main function...
*/
gint
-main (gint argc,
- gchar *argv[])
+main (gint argc, gchar * argv[])
{
- GError *error = NULL;
- GtranslatorPluginsEngine *engine;
- GtranslatorWindow *window;
- GSList *file_list = NULL;
- GOptionContext *context;
- gchar *filename;
- gchar *config_folder;
- GList *profiles_list = NULL;
- GFile *file;
- gchar *pixmapsdir;
- gchar *window_icon;
-
- /*
- * Initialize gettext.
- */
- setlocale (LC_ALL, "");
-
- bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
-
- g_set_application_name(_("Gtranslator"));
-
- /* Setup command line options */
- context = g_option_context_new (_("- Edit PO files"));
- g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+ GError *error = NULL;
+ GtranslatorPluginsEngine *engine;
+ GtranslatorWindow *window;
+ GSList *file_list = NULL;
+ GOptionContext *context;
+ gchar *filename;
+ gchar *config_folder;
+ GList *profiles_list = NULL;
+ GFile *file;
+ gchar *pixmapsdir;
+ gchar *window_icon;
+
+ /*
+ * Initialize gettext.
+ */
+ setlocale (LC_ALL, "");
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ g_set_application_name (_("Gtranslator"));
+
+ /* Setup command line options */
+ context = g_option_context_new (_("- Edit PO files"));
+ g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
#ifdef G_OS_WIN32
- setup_path ();
+ setup_path ();
#endif
- /*
- * Initialize the GConf library.
- */
- if(!(gconf_init(argc, argv, &error)))
+ /*
+ * Initialize the GConf library.
+ */
+ if (!(gconf_init (argc, argv, &error)))
+ {
+ if (error)
{
- if(error)
- {
- g_warning(_("Error during GConf initialization: %s."),
- error->message);
- }
-
- g_clear_error(&error);
+ g_warning (_("Error during GConf initialization: %s."),
+ error->message);
}
- if (!g_thread_supported()) g_thread_init(NULL);
- gtk_init(&argc, &argv);
-
- g_option_context_parse(context, &argc, &argv, NULL);
-
- /*
- * Show the application window with icon.
- */
- window_icon = gtranslator_utils_get_file_from_pixmapsdir("gtranslator.png");
- gtk_window_set_default_icon_from_file(window_icon, &error);
- g_free (window_icon);
- if(error)
- {
- g_warning(_("Error setting the default window icon: %s"),
- error->message);
- g_clear_error(&error);
- }
-
- /*
- * We set the default icon dir
- */
-
- pixmapsdir = gtranslator_utils_get_file_from_pixmapsdir(NULL);
- gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
- pixmapsdir);
- g_free(pixmapsdir);
-
- /*
- * Init preferences manager
- */
- gtranslator_prefs_manager_app_init();
-
- /*
- * Init plugin engine
- */
- engine = gtranslator_plugins_engine_get_default ();
-
- gtk_about_dialog_set_url_hook (gtranslator_utils_activate_url, NULL, NULL);
- gtk_about_dialog_set_email_hook (gtranslator_utils_activate_email, NULL, NULL);
-
- /*
- * Load profiles list
- */
- config_folder = gtranslator_utils_get_user_config_dir ();
- filename = g_build_filename (config_folder,
- "profiles.xml",
- NULL);
- file = g_file_new_for_path (filename);
-
- if (g_file_query_exists (file, NULL)) {
- profiles_list = gtranslator_profile_get_profiles_from_xml_file (filename);
- }
-
- gtranslator_application_set_profiles (GTR_APP, profiles_list);
-
- /*
- * Create the main app-window.
- */
- window = gtranslator_application_open_window(GTR_APP);
-
- /*
- * Now we open the files passed as arguments
- */
- file_list = get_command_line_data ();
- if (file_list)
- {
- gtranslator_actions_load_locations (window, (const GSList *)file_list);
- g_slist_foreach (file_list, (GFunc) g_object_unref, NULL);
- g_slist_free (file_list);
- }
-
- g_option_context_free (context);
-
- /*
- * Enter main GTK loop
- */
- gtk_main();
-
- gtranslator_prefs_manager_app_shutdown();
-
- return 0;
+ g_clear_error (&error);
+ }
+
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+ gtk_init (&argc, &argv);
+
+ g_option_context_parse (context, &argc, &argv, NULL);
+
+ /*
+ * Show the application window with icon.
+ */
+ window_icon =
+ gtranslator_utils_get_file_from_pixmapsdir ("gtranslator.png");
+ gtk_window_set_default_icon_from_file (window_icon, &error);
+ g_free (window_icon);
+ if (error)
+ {
+ g_warning (_("Error setting the default window icon: %s"),
+ error->message);
+ g_clear_error (&error);
+ }
+
+ /*
+ * We set the default icon dir
+ */
+
+ pixmapsdir = gtranslator_utils_get_file_from_pixmapsdir (NULL);
+ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+ pixmapsdir);
+ g_free (pixmapsdir);
+
+ /*
+ * Init preferences manager
+ */
+ gtranslator_prefs_manager_app_init ();
+
+ /*
+ * Init plugin engine
+ */
+ engine = gtranslator_plugins_engine_get_default ();
+
+ gtk_about_dialog_set_url_hook (gtranslator_utils_activate_url, NULL, NULL);
+ gtk_about_dialog_set_email_hook (gtranslator_utils_activate_email, NULL,
+ NULL);
+
+ /*
+ * Load profiles list
+ */
+ config_folder = gtranslator_utils_get_user_config_dir ();
+ filename = g_build_filename (config_folder, "profiles.xml", NULL);
+ file = g_file_new_for_path (filename);
+
+ if (g_file_query_exists (file, NULL))
+ {
+ profiles_list =
+ gtranslator_profile_get_profiles_from_xml_file (filename);
+ }
+
+ gtranslator_application_set_profiles (GTR_APP, profiles_list);
+
+ /*
+ * Create the main app-window.
+ */
+ window = gtranslator_application_open_window (GTR_APP);
+
+ /*
+ * Now we open the files passed as arguments
+ */
+ file_list = get_command_line_data ();
+ if (file_list)
+ {
+ gtranslator_actions_load_locations (window, (const GSList *) file_list);
+ g_slist_foreach (file_list, (GFunc) g_object_unref, NULL);
+ g_slist_free (file_list);
+ }
+
+ g_option_context_free (context);
+
+ /*
+ * Enter main GTK loop
+ */
+ gtk_main ();
+
+ gtranslator_prefs_manager_app_shutdown ();
+
+ return 0;
}
diff --git a/src/message-area.c b/src/message-area.c
index 358118e..4baab20 100644
--- a/src/message-area.c
+++ b/src/message-area.c
@@ -47,292 +47,267 @@
struct _GtranslatorMessageAreaPrivate
{
- GtkWidget *main_hbox;
+ GtkWidget *main_hbox;
- GtkWidget *contents;
- GtkWidget *action_area;
+ GtkWidget *contents;
+ GtkWidget *action_area;
- gboolean changing_style;
+ gboolean changing_style;
};
typedef struct _ResponseData ResponseData;
struct _ResponseData
{
- gint response_id;
+ gint response_id;
};
-enum {
- RESPONSE,
- CLOSE,
- LAST_SIGNAL
+enum
+{
+ RESPONSE,
+ CLOSE,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
-G_DEFINE_TYPE(GtranslatorMessageArea, gtranslator_message_area, GTK_TYPE_HBOX)
-
-
-static void
-gtranslator_message_area_finalize (GObject *object)
+G_DEFINE_TYPE (GtranslatorMessageArea, gtranslator_message_area,
+ GTK_TYPE_HBOX)
+ static void gtranslator_message_area_finalize (GObject * object)
{
- /*
- GtranslatorMessageArea *message_area = GTR_MESSAGE_AREA (object);
- */
+ /*
+ GtranslatorMessageArea *message_area = GTR_MESSAGE_AREA (object);
+ */
- G_OBJECT_CLASS (gtranslator_message_area_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_message_area_parent_class)->finalize (object);
}
static ResponseData *
-get_response_data (GtkWidget *widget,
- gboolean create)
+get_response_data (GtkWidget * widget, gboolean create)
{
- ResponseData *ad = g_object_get_data (G_OBJECT (widget),
- "message-area-response-data");
+ ResponseData *ad = g_object_get_data (G_OBJECT (widget),
+ "message-area-response-data");
- if (ad == NULL && create)
- {
- ad = g_new (ResponseData, 1);
+ if (ad == NULL && create)
+ {
+ ad = g_new (ResponseData, 1);
- g_object_set_data_full (G_OBJECT (widget),
- "message-area-response-data",
- ad,
- g_free);
- }
+ g_object_set_data_full (G_OBJECT (widget),
+ "message-area-response-data", ad, g_free);
+ }
- return ad;
+ return ad;
}
static GtkWidget *
-find_button (GtranslatorMessageArea *message_area,
- gint response_id)
+find_button (GtranslatorMessageArea * message_area, gint response_id)
{
- GList *children, *tmp_list;
- GtkWidget *child = NULL;
+ GList *children, *tmp_list;
+ GtkWidget *child = NULL;
- children = gtk_container_get_children (
- GTK_CONTAINER (message_area->priv->action_area));
+ children =
+ gtk_container_get_children (GTK_CONTAINER
+ (message_area->priv->action_area));
- for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
- {
- ResponseData *rd = get_response_data (tmp_list->data, FALSE);
+ for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
+ {
+ ResponseData *rd = get_response_data (tmp_list->data, FALSE);
- if (rd && rd->response_id == response_id)
- {
- child = tmp_list->data;
- break;
- }
+ if (rd && rd->response_id == response_id)
+ {
+ child = tmp_list->data;
+ break;
}
+ }
- g_list_free (children);
+ g_list_free (children);
- return child;
+ return child;
}
static void
-gtranslator_message_area_close (GtranslatorMessageArea *message_area)
+gtranslator_message_area_close (GtranslatorMessageArea * message_area)
{
- if (!find_button (message_area, GTK_RESPONSE_CANCEL))
- return;
+ if (!find_button (message_area, GTK_RESPONSE_CANCEL))
+ return;
- /* emit response signal */
- gtranslator_message_area_response (GTR_MESSAGE_AREA (message_area),
+ /* emit response signal */
+ gtranslator_message_area_response (GTR_MESSAGE_AREA (message_area),
GTK_RESPONSE_CANCEL);
}
static gboolean
-paint_message_area (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer user_data)
+paint_message_area (GtkWidget * widget,
+ GdkEventExpose * event, gpointer user_data)
{
- gtk_paint_flat_box (widget->style,
- widget->window,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- NULL,
- widget,
- "tooltip",
- widget->allocation.x + 1,
- widget->allocation.y + 1,
- widget->allocation.width - 2,
- widget->allocation.height - 2);
-
- return FALSE;
+ gtk_paint_flat_box (widget->style,
+ widget->window,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ NULL,
+ widget,
+ "tooltip",
+ widget->allocation.x + 1,
+ widget->allocation.y + 1,
+ widget->allocation.width - 2,
+ widget->allocation.height - 2);
+
+ return FALSE;
}
static void
-gtranslator_message_area_class_init (GtranslatorMessageAreaClass *klass)
+gtranslator_message_area_class_init (GtranslatorMessageAreaClass * klass)
{
- GObjectClass *object_class;
- GtkBindingSet *binding_set;
+ GObjectClass *object_class;
+ GtkBindingSet *binding_set;
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gtranslator_message_area_finalize;
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gtranslator_message_area_finalize;
- klass->close = gtranslator_message_area_close;
+ klass->close = gtranslator_message_area_close;
- g_type_class_add_private (object_class, sizeof(GtranslatorMessageAreaPrivate));
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorMessageAreaPrivate));
- signals[RESPONSE] = g_signal_new ("response",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorMessageAreaClass, response),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
+ signals[RESPONSE] = g_signal_new ("response",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET
+ (GtranslatorMessageAreaClass, response),
+ NULL, NULL, g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1, G_TYPE_INT);
- signals[CLOSE] = g_signal_new ("close",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GtranslatorMessageAreaClass, close),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ signals[CLOSE] = g_signal_new ("close",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtranslatorMessageAreaClass,
+ close), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE,
+ 0);
- binding_set = gtk_binding_set_by_class (klass);
+ binding_set = gtk_binding_set_by_class (klass);
- gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "close", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "close", 0);
}
static void
-style_set (GtkWidget *widget,
- GtkStyle *prev_style,
- GtranslatorMessageArea *message_area)
+style_set (GtkWidget * widget,
+ GtkStyle * prev_style, GtranslatorMessageArea * message_area)
{
- GtkWidget *window;
- GtkStyle *style;
+ GtkWidget *window;
+ GtkStyle *style;
- if (message_area->priv->changing_style)
- return;
+ if (message_area->priv->changing_style)
+ return;
- /* This is a hack needed to use the tooltip background color */
- window = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_widget_set_name (window, "gtk-tooltip");
- gtk_widget_ensure_style (window);
- style = gtk_widget_get_style (window);
+ /* This is a hack needed to use the tooltip background color */
+ window = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_widget_set_name (window, "gtk-tooltip");
+ gtk_widget_ensure_style (window);
+ style = gtk_widget_get_style (window);
- message_area->priv->changing_style = TRUE;
- gtk_widget_set_style (GTK_WIDGET (message_area), style);
- message_area->priv->changing_style = FALSE;
+ message_area->priv->changing_style = TRUE;
+ gtk_widget_set_style (GTK_WIDGET (message_area), style);
+ message_area->priv->changing_style = FALSE;
- gtk_widget_destroy (window);
+ gtk_widget_destroy (window);
- gtk_widget_queue_draw (GTK_WIDGET (message_area));
+ gtk_widget_queue_draw (GTK_WIDGET (message_area));
}
static void
-gtranslator_message_area_init (GtranslatorMessageArea *message_area)
+gtranslator_message_area_init (GtranslatorMessageArea * message_area)
{
- message_area->priv = GTR_MESSAGE_AREA_GET_PRIVATE (message_area);
-
- message_area->priv->main_hbox = gtk_hbox_new (FALSE, 16); /* FIXME: use style properties */
- gtk_widget_show (message_area->priv->main_hbox);
- gtk_container_set_border_width (GTK_CONTAINER (message_area->priv->main_hbox),
- 8); /* FIXME: use style properties */
-
- message_area->priv->action_area = gtk_vbox_new (TRUE, 10); /* FIXME: use style properties */
- gtk_widget_show (message_area->priv->action_area);
- gtk_box_pack_end (GTK_BOX (message_area->priv->main_hbox),
- message_area->priv->action_area,
- FALSE,
- TRUE,
- 0);
-
- gtk_box_pack_start (GTK_BOX (message_area),
- message_area->priv->main_hbox,
- TRUE,
- TRUE,
- 0);
-
- gtk_widget_set_app_paintable (GTK_WIDGET (message_area), TRUE);
-
- g_signal_connect (message_area,
- "expose-event",
- G_CALLBACK (paint_message_area),
- NULL);
-
- /* Note that we connect to style-set on one of the internal
- * widgets, not on the message area itself, since gtk does
- * not deliver any further style-set signals for a widget on
- * which the style has been forced with gtk_widget_set_style() */
- g_signal_connect (message_area->priv->main_hbox,
- "style-set",
- G_CALLBACK (style_set),
- message_area);
+ message_area->priv = GTR_MESSAGE_AREA_GET_PRIVATE (message_area);
+
+ message_area->priv->main_hbox = gtk_hbox_new (FALSE, 16); /* FIXME: use style properties */
+ gtk_widget_show (message_area->priv->main_hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (message_area->priv->main_hbox), 8); /* FIXME: use style properties */
+
+ message_area->priv->action_area = gtk_vbox_new (TRUE, 10); /* FIXME: use style properties */
+ gtk_widget_show (message_area->priv->action_area);
+ gtk_box_pack_end (GTK_BOX (message_area->priv->main_hbox),
+ message_area->priv->action_area, FALSE, TRUE, 0);
+
+ gtk_box_pack_start (GTK_BOX (message_area),
+ message_area->priv->main_hbox, TRUE, TRUE, 0);
+
+ gtk_widget_set_app_paintable (GTK_WIDGET (message_area), TRUE);
+
+ g_signal_connect (message_area,
+ "expose-event", G_CALLBACK (paint_message_area), NULL);
+
+ /* Note that we connect to style-set on one of the internal
+ * widgets, not on the message area itself, since gtk does
+ * not deliver any further style-set signals for a widget on
+ * which the style has been forced with gtk_widget_set_style() */
+ g_signal_connect (message_area->priv->main_hbox,
+ "style-set", G_CALLBACK (style_set), message_area);
}
static gint
-get_response_for_widget (GtranslatorMessageArea *message_area,
- GtkWidget *widget)
+get_response_for_widget (GtranslatorMessageArea * message_area,
+ GtkWidget * widget)
{
- ResponseData *rd;
+ ResponseData *rd;
- rd = get_response_data (widget, FALSE);
- if (!rd)
- return GTK_RESPONSE_NONE;
- else
- return rd->response_id;
+ rd = get_response_data (widget, FALSE);
+ if (!rd)
+ return GTK_RESPONSE_NONE;
+ else
+ return rd->response_id;
}
static void
-action_widget_activated (GtkWidget *widget, GtranslatorMessageArea *message_area)
+action_widget_activated (GtkWidget * widget,
+ GtranslatorMessageArea * message_area)
{
- gint response_id;
+ gint response_id;
- response_id = get_response_for_widget (message_area, widget);
+ response_id = get_response_for_widget (message_area, widget);
- gtranslator_message_area_response (message_area, response_id);
+ gtranslator_message_area_response (message_area, response_id);
}
void
-gtranslator_message_area_add_action_widget (GtranslatorMessageArea *message_area,
- GtkWidget *child,
- gint response_id)
+gtranslator_message_area_add_action_widget (GtranslatorMessageArea *
+ message_area, GtkWidget * child,
+ gint response_id)
{
- ResponseData *ad;
- guint signal_id;
+ ResponseData *ad;
+ guint signal_id;
- g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
- g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
+ g_return_if_fail (GTK_IS_WIDGET (child));
- ad = get_response_data (child, TRUE);
+ ad = get_response_data (child, TRUE);
- ad->response_id = response_id;
+ ad->response_id = response_id;
- if (GTK_IS_BUTTON (child))
- signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
- else
- signal_id = GTK_WIDGET_GET_CLASS (child)->activate_signal;
+ if (GTK_IS_BUTTON (child))
+ signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
+ else
+ signal_id = GTK_WIDGET_GET_CLASS (child)->activate_signal;
- if (signal_id)
- {
- GClosure *closure;
+ if (signal_id)
+ {
+ GClosure *closure;
- closure = g_cclosure_new_object (G_CALLBACK (action_widget_activated),
- G_OBJECT (message_area));
+ closure = g_cclosure_new_object (G_CALLBACK (action_widget_activated),
+ G_OBJECT (message_area));
- g_signal_connect_closure_by_id (child,
- signal_id,
- 0,
- closure,
- FALSE);
- }
- else
- g_warning ("Only 'activatable' widgets can be packed into the action area of a GtranslatorMessageArea");
-
- if (response_id != GTK_RESPONSE_HELP)
- gtk_box_pack_start (GTK_BOX (message_area->priv->action_area),
- child,
- FALSE,
- FALSE,
- 0);
- else
- gtk_box_pack_end (GTK_BOX (message_area->priv->action_area),
- child,
- FALSE,
- FALSE,
- 0);
+ g_signal_connect_closure_by_id (child, signal_id, 0, closure, FALSE);
+ }
+ else
+ g_warning
+ ("Only 'activatable' widgets can be packed into the action area of a GtranslatorMessageArea");
+
+ if (response_id != GTK_RESPONSE_HELP)
+ gtk_box_pack_start (GTK_BOX (message_area->priv->action_area),
+ child, FALSE, FALSE, 0);
+ else
+ gtk_box_pack_end (GTK_BOX (message_area->priv->action_area),
+ child, FALSE, FALSE, 0);
}
/**
@@ -343,18 +318,15 @@ gtranslator_message_area_add_action_widget (GtranslatorMessageArea *message_area
* Adds the @contents widget to the contents area of #GtranslatorMessageArea.
*/
void
-gtranslator_message_area_set_contents (GtranslatorMessageArea *message_area,
- GtkWidget *contents)
+gtranslator_message_area_set_contents (GtranslatorMessageArea * message_area,
+ GtkWidget * contents)
{
- g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
- g_return_if_fail (GTK_IS_WIDGET (contents));
-
- message_area->priv->contents = contents;
- gtk_box_pack_start (GTK_BOX (message_area->priv->main_hbox),
- message_area->priv->contents,
- TRUE,
- TRUE,
- 0);
+ g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
+ g_return_if_fail (GTK_IS_WIDGET (contents));
+
+ message_area->priv->contents = contents;
+ gtk_box_pack_start (GTK_BOX (message_area->priv->main_hbox),
+ message_area->priv->contents, TRUE, TRUE, 0);
}
/**
@@ -370,57 +342,53 @@ gtranslator_message_area_set_contents (GtranslatorMessageArea *message_area,
*
* Returns: the button widget that was added
*/
-GtkWidget*
-gtranslator_message_area_add_button (GtranslatorMessageArea *message_area,
- const gchar *button_text,
- gint response_id)
+GtkWidget *
+gtranslator_message_area_add_button (GtranslatorMessageArea * message_area,
+ const gchar * button_text,
+ gint response_id)
{
- GtkWidget *button;
+ GtkWidget *button;
- g_return_val_if_fail (GTR_IS_MESSAGE_AREA (message_area), NULL);
- g_return_val_if_fail (button_text != NULL, NULL);
+ g_return_val_if_fail (GTR_IS_MESSAGE_AREA (message_area), NULL);
+ g_return_val_if_fail (button_text != NULL, NULL);
- button = gtk_button_new_from_stock (button_text);
+ button = gtk_button_new_from_stock (button_text);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
+ gtk_widget_show (button);
- gtranslator_message_area_add_action_widget (message_area,
- button,
- response_id);
+ gtranslator_message_area_add_action_widget (message_area,
+ button, response_id);
- return button;
+ return button;
}
static void
-add_buttons_valist (GtranslatorMessageArea *message_area,
- const gchar *first_button_text,
- va_list args)
+add_buttons_valist (GtranslatorMessageArea * message_area,
+ const gchar * first_button_text, va_list args)
{
- const gchar* text;
- gint response_id;
+ const gchar *text;
+ gint response_id;
- g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
+ g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
- if (first_button_text == NULL)
- return;
+ if (first_button_text == NULL)
+ return;
- text = first_button_text;
- response_id = va_arg (args, gint);
+ text = first_button_text;
+ response_id = va_arg (args, gint);
- while (text != NULL)
- {
- gtranslator_message_area_add_button (message_area,
- text,
- response_id);
+ while (text != NULL)
+ {
+ gtranslator_message_area_add_button (message_area, text, response_id);
- text = va_arg (args, gchar*);
- if (text == NULL)
- break;
+ text = va_arg (args, gchar *);
+ if (text == NULL)
+ break;
- response_id = va_arg (args, int);
- }
+ response_id = va_arg (args, int);
+ }
}
/**
@@ -434,19 +402,16 @@ add_buttons_valist (GtranslatorMessageArea *message_area,
* gtranslator_message_area_new_with_buttons(). Each button must have both text and response ID.
*/
void
-gtranslator_message_area_add_buttons (GtranslatorMessageArea *message_area,
- const gchar *first_button_text,
- ...)
+gtranslator_message_area_add_buttons (GtranslatorMessageArea * message_area,
+ const gchar * first_button_text, ...)
{
- va_list args;
+ va_list args;
- va_start (args, first_button_text);
+ va_start (args, first_button_text);
- add_buttons_valist (message_area,
- first_button_text,
- args);
+ add_buttons_valist (message_area, first_button_text, args);
- va_end (args);
+ va_end (args);
}
/**
@@ -459,7 +424,7 @@ gtranslator_message_area_add_buttons (GtranslatorMessageArea *message_area,
GtkWidget *
gtranslator_message_area_new (void)
{
- return g_object_new (GTR_TYPE_MESSAGE_AREA, NULL);
+ return g_object_new (GTR_TYPE_MESSAGE_AREA, NULL);
}
/**
@@ -477,23 +442,21 @@ gtranslator_message_area_new (void)
* Returns: a new #GtranslatorMessageArea
*/
GtkWidget *
-gtranslator_message_area_new_with_buttons (const gchar *first_button_text,
- ...)
+gtranslator_message_area_new_with_buttons (const gchar * first_button_text,
+ ...)
{
- GtranslatorMessageArea *message_area;
- va_list args;
+ GtranslatorMessageArea *message_area;
+ va_list args;
- message_area = GTR_MESSAGE_AREA (gtranslator_message_area_new ());
+ message_area = GTR_MESSAGE_AREA (gtranslator_message_area_new ());
- va_start (args, first_button_text);
+ va_start (args, first_button_text);
- add_buttons_valist (message_area,
- first_button_text,
- args);
+ add_buttons_valist (message_area, first_button_text, args);
- va_end (args);
+ va_end (args);
- return GTK_WIDGET (message_area);
+ return GTK_WIDGET (message_area);
}
/**
@@ -507,30 +470,33 @@ gtranslator_message_area_new_with_buttons (const gchar *first_button_text,
* dialog buttons.
*/
void
-gtranslator_message_area_set_response_sensitive (GtranslatorMessageArea *message_area,
- gint response_id,
- gboolean setting)
+gtranslator_message_area_set_response_sensitive (GtranslatorMessageArea *
+ message_area,
+ gint response_id,
+ gboolean setting)
{
- GList *children;
- GList *tmp_list;
+ GList *children;
+ GList *tmp_list;
- g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
+ g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
- children = gtk_container_get_children (GTK_CONTAINER (message_area->priv->action_area));
+ children =
+ gtk_container_get_children (GTK_CONTAINER
+ (message_area->priv->action_area));
- tmp_list = children;
- while (tmp_list != NULL)
- {
- GtkWidget *widget = tmp_list->data;
- ResponseData *rd = get_response_data (widget, FALSE);
+ tmp_list = children;
+ while (tmp_list != NULL)
+ {
+ GtkWidget *widget = tmp_list->data;
+ ResponseData *rd = get_response_data (widget, FALSE);
- if (rd && rd->response_id == response_id)
- gtk_widget_set_sensitive (widget, setting);
+ if (rd && rd->response_id == response_id)
+ gtk_widget_set_sensitive (widget, setting);
- tmp_list = g_list_next (tmp_list);
- }
+ tmp_list = g_list_next (tmp_list);
+ }
- g_list_free (children);
+ g_list_free (children);
}
/**
@@ -543,29 +509,31 @@ gtranslator_message_area_set_response_sensitive (GtranslatorMessageArea *message
* default widget.
*/
void
-gtranslator_message_area_set_default_response (GtranslatorMessageArea *message_area,
- gint response_id)
+gtranslator_message_area_set_default_response (GtranslatorMessageArea *
+ message_area, gint response_id)
{
- GList *children;
- GList *tmp_list;
+ GList *children;
+ GList *tmp_list;
- g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
+ g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
- children = gtk_container_get_children (GTK_CONTAINER (message_area->priv->action_area));
+ children =
+ gtk_container_get_children (GTK_CONTAINER
+ (message_area->priv->action_area));
- tmp_list = children;
- while (tmp_list != NULL)
- {
- GtkWidget *widget = tmp_list->data;
- ResponseData *rd = get_response_data (widget, FALSE);
+ tmp_list = children;
+ while (tmp_list != NULL)
+ {
+ GtkWidget *widget = tmp_list->data;
+ ResponseData *rd = get_response_data (widget, FALSE);
- if (rd && rd->response_id == response_id)
- gtk_widget_grab_default (widget);
+ if (rd && rd->response_id == response_id)
+ gtk_widget_grab_default (widget);
- tmp_list = g_list_next (tmp_list);
- }
+ tmp_list = g_list_next (tmp_list);
+ }
- g_list_free (children);
+ g_list_free (children);
}
/**
@@ -576,15 +544,12 @@ gtranslator_message_area_set_default_response (GtranslatorMessageArea *message_a
* Emits the 'response' signal with the given @response_id.
*/
void
-gtranslator_message_area_response (GtranslatorMessageArea *message_area,
- gint response_id)
+gtranslator_message_area_response (GtranslatorMessageArea * message_area,
+ gint response_id)
{
- g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
+ g_return_if_fail (GTR_IS_MESSAGE_AREA (message_area));
- g_signal_emit (message_area,
- signals[RESPONSE],
- 0,
- response_id);
+ g_signal_emit (message_area, signals[RESPONSE], 0, response_id);
}
/**
@@ -597,30 +562,29 @@ gtranslator_message_area_response (GtranslatorMessageArea *message_area,
* Same as gtranslator_message_area_add_button() but with a specific text.
*/
GtkWidget *
-gtranslator_message_area_add_stock_button_with_text (GtranslatorMessageArea *message_area,
- const gchar *text,
- const gchar *stock_id,
- gint response_id)
+gtranslator_message_area_add_stock_button_with_text (GtranslatorMessageArea *
+ message_area,
+ const gchar * text,
+ const gchar * stock_id,
+ gint response_id)
{
- GtkWidget *button;
+ GtkWidget *button;
- g_return_val_if_fail (GTR_IS_MESSAGE_AREA (message_area), NULL);
- g_return_val_if_fail (text != NULL, NULL);
- g_return_val_if_fail (stock_id != NULL, NULL);
+ g_return_val_if_fail (GTR_IS_MESSAGE_AREA (message_area), NULL);
+ g_return_val_if_fail (text != NULL, NULL);
+ g_return_val_if_fail (stock_id != NULL, NULL);
- button = gtk_button_new_with_mnemonic (text);
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (stock_id,
- GTK_ICON_SIZE_BUTTON));
+ button = gtk_button_new_with_mnemonic (text);
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (stock_id,
+ GTK_ICON_SIZE_BUTTON));
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
- gtk_widget_show (button);
+ gtk_widget_show (button);
- gtranslator_message_area_add_action_widget (message_area,
- button,
- response_id);
+ gtranslator_message_area_add_action_widget (message_area,
+ button, response_id);
- return button;
+ return button;
}
-
diff --git a/src/message-area.h b/src/message-area.h
index 00446db..0d4d869 100644
--- a/src/message-area.h
+++ b/src/message-area.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2005. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -34,7 +34,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -44,7 +43,6 @@ G_BEGIN_DECLS
#define GTR_IS_MESSAGE_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTR_TYPE_MESSAGE_AREA))
#define GTR_IS_MESSAGE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_MESSAGE_AREA))
#define GTR_MESSAGE_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_MESSAGE_AREA, GtranslatorMessageAreaClass))
-
/* Private structure type */
typedef struct _GtranslatorMessageAreaPrivate GtranslatorMessageAreaPrivate;
@@ -53,12 +51,12 @@ typedef struct _GtranslatorMessageAreaPrivate GtranslatorMessageAreaPrivate;
*/
typedef struct _GtranslatorMessageArea GtranslatorMessageArea;
-struct _GtranslatorMessageArea
+struct _GtranslatorMessageArea
{
- GtkHBox parent;
+ GtkHBox parent;
- /*< private > */
- GtranslatorMessageAreaPrivate *priv;
+ /*< private > */
+ GtranslatorMessageAreaPrivate *priv;
};
/*
@@ -66,64 +64,67 @@ struct _GtranslatorMessageArea
*/
typedef struct _GtranslatorMessageAreaClass GtranslatorMessageAreaClass;
-struct _GtranslatorMessageAreaClass
+struct _GtranslatorMessageAreaClass
{
- GtkHBoxClass parent_class;
+ GtkHBoxClass parent_class;
- /* Signals */
- void (* response) (GtranslatorMessageArea *message_area, gint response_id);
+ /* Signals */
+ void (*response) (GtranslatorMessageArea * message_area, gint response_id);
- /* Keybinding signals */
- void (* close) (GtranslatorMessageArea *message_area);
+ /* Keybinding signals */
+ void (*close) (GtranslatorMessageArea * message_area);
- /* Padding for future expansion */
- void (*_gtranslator_reserved1) (void);
- void (*_gtranslator_reserved2) (void);
+ /* Padding for future expansion */
+ void (*_gtranslator_reserved1) (void);
+ void (*_gtranslator_reserved2) (void);
};
/*
* Public methods
*/
-GType gtranslator_message_area_get_type (void) G_GNUC_CONST;
-
-GtkWidget *gtranslator_message_area_new (void);
-
-GtkWidget *gtranslator_message_area_new_with_buttons (const gchar *first_button_text,
- ...);
-
-void gtranslator_message_area_set_contents (GtranslatorMessageArea *message_area,
- GtkWidget *contents);
-
-void gtranslator_message_area_add_action_widget (GtranslatorMessageArea *message_area,
- GtkWidget *child,
- gint response_id);
-
-GtkWidget *gtranslator_message_area_add_button (GtranslatorMessageArea *message_area,
- const gchar *button_text,
- gint response_id);
-
-GtkWidget *gtranslator_message_area_add_stock_button_with_text
- (GtranslatorMessageArea *message_area,
- const gchar *text,
- const gchar *stock_id,
- gint response_id);
-
-void gtranslator_message_area_add_buttons (GtranslatorMessageArea *message_area,
- const gchar *first_button_text,
- ...);
-
-void gtranslator_message_area_set_response_sensitive
- (GtranslatorMessageArea *message_area,
- gint response_id,
- gboolean setting);
-void gtranslator_message_area_set_default_response
- (GtranslatorMessageArea *message_area,
- gint response_id);
+GType
+gtranslator_message_area_get_type (void)
+ G_GNUC_CONST;
+
+ GtkWidget *gtranslator_message_area_new (void);
+
+ GtkWidget *gtranslator_message_area_new_with_buttons (const gchar *
+ first_button_text,
+ ...);
+
+ void gtranslator_message_area_set_contents (GtranslatorMessageArea *
+ message_area,
+ GtkWidget * contents);
+
+ void gtranslator_message_area_add_action_widget (GtranslatorMessageArea *
+ message_area,
+ GtkWidget * child,
+ gint response_id);
+
+ GtkWidget *gtranslator_message_area_add_button (GtranslatorMessageArea *
+ message_area,
+ const gchar *
+ button_text,
+ gint response_id);
+
+ GtkWidget *gtranslator_message_area_add_stock_button_with_text
+ (GtranslatorMessageArea * message_area,
+ const gchar * text, const gchar * stock_id, gint response_id);
+
+ void gtranslator_message_area_add_buttons (GtranslatorMessageArea *
+ message_area,
+ const gchar *
+ first_button_text, ...);
+
+ void gtranslator_message_area_set_response_sensitive
+ (GtranslatorMessageArea * message_area,
+ gint response_id, gboolean setting);
+ void gtranslator_message_area_set_default_response
+ (GtranslatorMessageArea * message_area, gint response_id);
/* Emit response signal */
-void gtranslator_message_area_response (GtranslatorMessageArea *message_area,
- gint response_id);
+ void gtranslator_message_area_response (GtranslatorMessageArea *
+ message_area, gint response_id);
G_END_DECLS
-
-#endif /* __GTR_MESSAGE_AREA_H__ */
+#endif /* __GTR_MESSAGE_AREA_H__ */
diff --git a/src/message-table-model.c b/src/message-table-model.c
index b0d9871..e0ba986 100644
--- a/src/message-table-model.c
+++ b/src/message-table-model.c
@@ -37,280 +37,286 @@
static GObjectClass *parent_class;
static guint
-gtranslator_message_table_model_get_flags (GtkTreeModel *self)
+gtranslator_message_table_model_get_flags (GtkTreeModel * self)
{
- return 0;
+ return 0;
}
static gint
-gtranslator_message_table_model_get_n_columns (GtkTreeModel *self)
+gtranslator_message_table_model_get_n_columns (GtkTreeModel * self)
{
- return GTR_MESSAGE_TABLE_MODEL_N_COLUMNS;
+ return GTR_MESSAGE_TABLE_MODEL_N_COLUMNS;
}
static GType
-gtranslator_message_table_model_get_column_type (GtkTreeModel *self,
+gtranslator_message_table_model_get_column_type (GtkTreeModel * self,
gint column)
{
- GType retval;
-
- switch (column)
- {
- case GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN:
- case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:
- case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:
- retval = G_TYPE_STRING;
- break;
- case GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN:
- retval = G_TYPE_POINTER;
- break;
- case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:
- case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:
- retval = G_TYPE_INT;
- break;
- default:
- retval = G_TYPE_INVALID;
- break;
- }
-
-
- return retval;
+ GType retval;
+
+ switch (column)
+ {
+ case GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN:
+ case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:
+ case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:
+ retval = G_TYPE_STRING;
+ break;
+ case GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN:
+ retval = G_TYPE_POINTER;
+ break;
+ case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:
+ case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:
+ retval = G_TYPE_INT;
+ break;
+ default:
+ retval = G_TYPE_INVALID;
+ break;
+ }
+
+
+ return retval;
}
static gboolean
-gtranslator_message_table_model_get_iter (GtkTreeModel *self,
- GtkTreeIter *iter,
- GtkTreePath *path)
+gtranslator_message_table_model_get_iter (GtkTreeModel * self,
+ GtkTreeIter * iter,
+ GtkTreePath * path)
{
- GtranslatorMessageTableModel *list_model = GTR_MESSAGE_TABLE_MODEL (self);
- gint i;
- GList *list;
+ GtranslatorMessageTableModel *list_model = GTR_MESSAGE_TABLE_MODEL (self);
+ gint i;
+ GList *list;
- g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
+ g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
- /* Fill a GtkTreeIter using a path */
+ /* Fill a GtkTreeIter using a path */
- i = gtk_tree_path_get_indices (path)[0];
+ i = gtk_tree_path_get_indices (path)[0];
- if (G_UNLIKELY (i >= list_model->length))
- return FALSE;
+ if (G_UNLIKELY (i >= list_model->length))
+ return FALSE;
- list = g_list_nth (list_model->values, i);
+ list = g_list_nth (list_model->values, i);
- iter->stamp = list_model->stamp;
- iter->user_data = list;
+ iter->stamp = list_model->stamp;
+ iter->user_data = list;
- return TRUE;
+ return TRUE;
}
static GtkTreePath *
-gtranslator_message_table_model_get_path (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+gtranslator_message_table_model_get_path (GtkTreeModel * tree_model,
+ GtkTreeIter * iter)
{
- GList *list;
- GtkTreePath *tree_path;
- gint i = 0;
+ GList *list;
+ GtkTreePath *tree_path;
+ gint i = 0;
+
+ g_return_val_if_fail (iter->stamp ==
+ GTR_MESSAGE_TABLE_MODEL (tree_model)->stamp, NULL);
+
+ for (list = GTR_MESSAGE_TABLE_MODEL (tree_model)->values; list;
+ list = list->next)
+ {
+ if (list == iter->user_data)
+ break;
+ i++;
+ }
+ if (list == NULL)
+ return NULL;
+
+ tree_path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (tree_path, i);
+
+ return tree_path;
+}
- g_return_val_if_fail (iter->stamp == GTR_MESSAGE_TABLE_MODEL (tree_model)->stamp, NULL);
+static void
+gtranslator_message_table_model_get_value (GtkTreeModel * self,
+ GtkTreeIter * iter,
+ gint column, GValue * value)
+{
+ GtranslatorMessageTableModel *model = GTR_MESSAGE_TABLE_MODEL (self);
+ GtranslatorMsg *msg;
+ gchar *text;
+ GtranslatorMsgStatus status;
+ gint i;
+ GList *list;
- for (list = GTR_MESSAGE_TABLE_MODEL (tree_model)->values; list; list = list->next) {
- if (list == iter->user_data)
- break;
- i++;
- }
- if (list == NULL)
- return NULL;
+ g_return_if_fail (iter->stamp == GTR_MESSAGE_TABLE_MODEL (self)->stamp);
- tree_path = gtk_tree_path_new ();
- gtk_tree_path_append_index (tree_path, i);
+ list = G_LIST (iter->user_data);
+ msg = GTR_MSG (list->data);
- return tree_path;
-}
+ switch (column)
+ {
+ case GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN:
+ g_value_init (value, G_TYPE_STRING);
-static void
-gtranslator_message_table_model_get_value (GtkTreeModel *self,
- GtkTreeIter *iter,
- gint column,
- GValue *value)
-{
- GtranslatorMessageTableModel *model = GTR_MESSAGE_TABLE_MODEL (self);
- GtranslatorMsg *msg;
- gchar *text;
- GtranslatorMsgStatus status;
- gint i;
- GList *list;
-
- g_return_if_fail (iter->stamp == GTR_MESSAGE_TABLE_MODEL (self)->stamp);
-
- list = G_LIST (iter->user_data);
- msg = GTR_MSG (list->data);
-
- switch (column) {
- case GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN:
- g_value_init (value, G_TYPE_STRING);
-
- status = gtranslator_msg_get_status (msg);
-
- if (status == GTR_MSG_STATUS_UNTRANSLATED)
- text = TABLE_UNTRANSLATED_ICON;
- else if (status == GTR_MSG_STATUS_FUZZY)
- text = TABLE_FUZZY_ICON;
- else text = TABLE_TRANSLATED_ICON;
-
- g_value_set_string (value, text);
- break;
-
- case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:
- g_value_init (value, G_TYPE_INT);
-
- i = g_list_position (model->values, list);
- g_value_set_int (value, i+1);
- break;
-
- case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:
- g_value_init (value, G_TYPE_STRING);
-
- text = g_strdup (gtranslator_msg_get_msgid (msg));
- g_value_set_string (value, text);
- g_free (text);
- break;
-
- case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:
- g_value_init (value, G_TYPE_STRING);
-
- text = g_strdup (gtranslator_msg_get_msgstr (msg));
- g_value_set_string (value, text);
- g_free (text);
- break;
-
- case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:
- g_value_init (value, G_TYPE_INT);
-
- status = gtranslator_msg_get_status (msg);
- g_value_set_int (value, status);
- break;
-
- case GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN:
- g_value_init (value, G_TYPE_POINTER);
-
- g_value_set_pointer (value, iter->user_data);
- break;
-
- default:
- break;
- }
+ status = gtranslator_msg_get_status (msg);
+
+ if (status == GTR_MSG_STATUS_UNTRANSLATED)
+ text = TABLE_UNTRANSLATED_ICON;
+ else if (status == GTR_MSG_STATUS_FUZZY)
+ text = TABLE_FUZZY_ICON;
+ else
+ text = TABLE_TRANSLATED_ICON;
+
+ g_value_set_string (value, text);
+ break;
+
+ case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:
+ g_value_init (value, G_TYPE_INT);
+
+ i = g_list_position (model->values, list);
+ g_value_set_int (value, i + 1);
+ break;
+
+ case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:
+ g_value_init (value, G_TYPE_STRING);
+
+ text = g_strdup (gtranslator_msg_get_msgid (msg));
+ g_value_set_string (value, text);
+ g_free (text);
+ break;
+
+ case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:
+ g_value_init (value, G_TYPE_STRING);
+
+ text = g_strdup (gtranslator_msg_get_msgstr (msg));
+ g_value_set_string (value, text);
+ g_free (text);
+ break;
+
+ case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:
+ g_value_init (value, G_TYPE_INT);
+
+ status = gtranslator_msg_get_status (msg);
+ g_value_set_int (value, status);
+ break;
+
+ case GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN:
+ g_value_init (value, G_TYPE_POINTER);
+
+ g_value_set_pointer (value, iter->user_data);
+ break;
+
+ default:
+ break;
+ }
}
static gboolean
-gtranslator_message_table_model_iter_next (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+gtranslator_message_table_model_iter_next (GtkTreeModel * tree_model,
+ GtkTreeIter * iter)
{
- g_return_val_if_fail (iter->stamp == GTR_MESSAGE_TABLE_MODEL (tree_model)->stamp, FALSE);
+ g_return_val_if_fail (iter->stamp ==
+ GTR_MESSAGE_TABLE_MODEL (tree_model)->stamp, FALSE);
+
+ iter->user_data = G_LIST (iter->user_data)->next;
- iter->user_data = G_LIST (iter->user_data)->next;
-
- return (iter->user_data != NULL);
+ return (iter->user_data != NULL);
}
static gboolean
-gtranslator_message_table_model_iter_has_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+gtranslator_message_table_model_iter_has_child (GtkTreeModel * tree_model,
+ GtkTreeIter * iter)
{
- return FALSE;
+ return FALSE;
}
static gint
-gtranslator_message_table_model_iter_n_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter)
+gtranslator_message_table_model_iter_n_children (GtkTreeModel * tree_model,
+ GtkTreeIter * iter)
{
- /* it should ask for the root node, because we're a list */
- if (!iter)
- return g_list_length (GTR_MESSAGE_TABLE_MODEL (tree_model)->values);
+ /* it should ask for the root node, because we're a list */
+ if (!iter)
+ return g_list_length (GTR_MESSAGE_TABLE_MODEL (tree_model)->values);
- return -1;
+ return -1;
}
static gboolean
-gtranslator_message_table_model_iter_nth_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent,
- gint n)
+gtranslator_message_table_model_iter_nth_child (GtkTreeModel * tree_model,
+ GtkTreeIter * iter,
+ GtkTreeIter * parent, gint n)
{
- GList *child;
-
- if (parent)
- return FALSE;
-
- child = g_list_nth (GTR_MESSAGE_TABLE_MODEL (tree_model)->values, n);
-
- if (child) {
- iter->stamp = GTR_MESSAGE_TABLE_MODEL (tree_model)->stamp;
- iter->user_data = child;
- return TRUE;
- }
- else
- return FALSE;
+ GList *child;
+
+ if (parent)
+ return FALSE;
+
+ child = g_list_nth (GTR_MESSAGE_TABLE_MODEL (tree_model)->values, n);
+
+ if (child)
+ {
+ iter->stamp = GTR_MESSAGE_TABLE_MODEL (tree_model)->stamp;
+ iter->user_data = child;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
static gboolean
-gtranslator_message_table_model_iter_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent)
+gtranslator_message_table_model_iter_children (GtkTreeModel * tree_model,
+ GtkTreeIter * iter,
+ GtkTreeIter * parent)
{
- GtranslatorMessageTableModel *model = GTR_MESSAGE_TABLE_MODEL (tree_model);
-
- /* this is a list, nodes have no children */
- if (parent)
- return FALSE;
-
- if (g_list_length (model->values) > 0)
- {
- iter->stamp = model->stamp;
- iter->user_data = g_list_first (model->values);
- return TRUE;
- }
- else
- return FALSE;
+ GtranslatorMessageTableModel *model = GTR_MESSAGE_TABLE_MODEL (tree_model);
+
+ /* this is a list, nodes have no children */
+ if (parent)
+ return FALSE;
+
+ if (g_list_length (model->values) > 0)
+ {
+ iter->stamp = model->stamp;
+ iter->user_data = g_list_first (model->values);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
static void
-gtranslator_message_table_model_tree_model_init (GtkTreeModelIface *iface)
+gtranslator_message_table_model_tree_model_init (GtkTreeModelIface * iface)
{
- iface->get_flags = gtranslator_message_table_model_get_flags;
- iface->get_n_columns = gtranslator_message_table_model_get_n_columns;
- iface->get_column_type = gtranslator_message_table_model_get_column_type;
- iface->get_iter = gtranslator_message_table_model_get_iter;
- iface->get_path = gtranslator_message_table_model_get_path;
- iface->get_value = gtranslator_message_table_model_get_value;
- iface->iter_next = gtranslator_message_table_model_iter_next;
- iface->iter_has_child = gtranslator_message_table_model_iter_has_child;
- iface->iter_n_children = gtranslator_message_table_model_iter_n_children;
- iface->iter_nth_child = gtranslator_message_table_model_iter_nth_child;
- iface->iter_children = gtranslator_message_table_model_iter_children;
+ iface->get_flags = gtranslator_message_table_model_get_flags;
+ iface->get_n_columns = gtranslator_message_table_model_get_n_columns;
+ iface->get_column_type = gtranslator_message_table_model_get_column_type;
+ iface->get_iter = gtranslator_message_table_model_get_iter;
+ iface->get_path = gtranslator_message_table_model_get_path;
+ iface->get_value = gtranslator_message_table_model_get_value;
+ iface->iter_next = gtranslator_message_table_model_iter_next;
+ iface->iter_has_child = gtranslator_message_table_model_iter_has_child;
+ iface->iter_n_children = gtranslator_message_table_model_iter_n_children;
+ iface->iter_nth_child = gtranslator_message_table_model_iter_nth_child;
+ iface->iter_children = gtranslator_message_table_model_iter_children;
}
static void
-gtranslator_message_table_model_init (GtranslatorMessageTableModel *model)
-{
- model->length = 0;
- model->stamp = g_random_int ();
+gtranslator_message_table_model_init (GtranslatorMessageTableModel * model)
+{
+ model->length = 0;
+ model->stamp = g_random_int ();
}
static void
-gtranslator_message_table_model_finalize (GObject *object)
+gtranslator_message_table_model_finalize (GObject * object)
{
- parent_class->finalize (object);
+ parent_class->finalize (object);
}
static void
-gtranslator_message_table_model_class_init (GtranslatorMessageTableModelClass *klass)
+gtranslator_message_table_model_class_init (GtranslatorMessageTableModelClass
+ * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gtranslator_message_table_model_finalize;
-
- parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = gtranslator_message_table_model_finalize;
+
+ parent_class = g_type_class_peek_parent (klass);
}
/***************************** Public funcs ***********************************/
@@ -323,83 +329,81 @@ gtranslator_message_table_model_class_init (GtranslatorMessageTableModelClass *k
GtranslatorMessageTableModel *
gtranslator_message_table_model_new (void)
{
- GtranslatorMessageTableModel *model;
-
- model = g_object_new (GTR_TYPE_MESSAGE_TABLE_MODEL, NULL);
-
- return model;
+ GtranslatorMessageTableModel *model;
+
+ model = g_object_new (GTR_TYPE_MESSAGE_TABLE_MODEL, NULL);
+
+ return model;
}
void
-gtranslator_message_table_model_append (GtranslatorMessageTableModel *model,
- GtranslatorMsg *msg,
- GtkTreeIter *iter)
+gtranslator_message_table_model_append (GtranslatorMessageTableModel * model,
+ GtranslatorMsg * msg,
+ GtkTreeIter * iter)
{
- GList *list;
- GtkTreePath *path;
-
- //The sort stuff can be improved using a GPtrArray or gsecuence instead of a GList
- model->values = g_list_append (model->values, msg);
- model->length++;
+ GList *list;
+ GtkTreePath *path;
+
+ //The sort stuff can be improved using a GPtrArray or gsecuence instead of a GList
+ model->values = g_list_append (model->values, msg);
+ model->length++;
- model->stamp++;
+ model->stamp++;
- iter->stamp = model->stamp;
- iter->user_data = g_list_last (model->values);
+ iter->stamp = model->stamp;
+ iter->user_data = g_list_last (model->values);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, iter);
+ gtk_tree_path_free (path);
}
void
-gtranslator_message_table_model_update_row (GtranslatorMessageTableModel *model,
- GtkTreePath *path)
+gtranslator_message_table_model_update_row (GtranslatorMessageTableModel *
+ model, GtkTreePath * path)
{
- GtkTreeIter iter;
-
- gtranslator_message_table_model_get_iter (GTK_TREE_MODEL (model),
- &iter, path);
-
- gtk_tree_model_row_changed (GTK_TREE_MODEL (model),
- path, &iter);
+ GtkTreeIter iter;
+
+ gtranslator_message_table_model_get_iter (GTK_TREE_MODEL (model),
+ &iter, path);
+
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
}
GType
gtranslator_message_table_model_get_type (void)
{
- static GType object_type = 0;
-
- if (G_UNLIKELY(object_type == 0))
- {
- static const GTypeInfo object_info =
- {
- sizeof (GtranslatorMessageTableModelClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtranslator_message_table_model_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtranslatorMessageTableModel),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtranslator_message_table_model_init,
- NULL
- };
-
- static const GInterfaceInfo tree_model_info = {
- (GInterfaceInitFunc) gtranslator_message_table_model_tree_model_init,
- NULL,
- NULL
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT,
- "GtranslatorMessageTableModel", &object_info, 0);
-
- g_type_add_interface_static (object_type, GTK_TYPE_TREE_MODEL,
- &tree_model_info);
-
- }
-
- return object_type;
+ static GType object_type = 0;
+
+ if (G_UNLIKELY (object_type == 0))
+ {
+ static const GTypeInfo object_info = {
+ sizeof (GtranslatorMessageTableModelClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtranslator_message_table_model_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtranslatorMessageTableModel),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtranslator_message_table_model_init,
+ NULL
+ };
+
+ static const GInterfaceInfo tree_model_info = {
+ (GInterfaceInitFunc) gtranslator_message_table_model_tree_model_init,
+ NULL,
+ NULL
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "GtranslatorMessageTableModel",
+ &object_info, 0);
+
+ g_type_add_interface_static (object_type, GTK_TYPE_TREE_MODEL,
+ &tree_model_info);
+
+ }
+
+ return object_type;
}
-
diff --git a/src/message-table-model.h b/src/message-table-model.h
index 1e899c7..bc6b05f 100644
--- a/src/message-table-model.h
+++ b/src/message-table-model.h
@@ -26,7 +26,6 @@
#include "msg.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -36,63 +35,69 @@ G_BEGIN_DECLS
#define GTR_IS_MESSAGE_TABLE_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_MESSAGE_TABLE_MODEL))
#define GTR_IS_MESSAGE_TABLE_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_MESSAGE_TABLE_MODEL))
#define GTR_MESSAGE_TABLE_MODEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_MESSAGE_TABLE_MODEL, GtranslatorMessageTableModelClass))
-
/* Private structure type */
-typedef struct _GtranslatorMessageTableModelPrivate GtranslatorMessageTableModelPrivate;
+typedef struct _GtranslatorMessageTableModelPrivate
+ GtranslatorMessageTableModelPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorMessageTableModel GtranslatorMessageTableModel;
+typedef struct _GtranslatorMessageTableModel GtranslatorMessageTableModel;
struct _GtranslatorMessageTableModel
{
- GObject parent_instance;
-
- GList *values;
- gint stamp;
- gint length;
+ GObject parent_instance;
+
+ GList *values;
+ gint stamp;
+ gint length;
};
/*
* Class definition
*/
-typedef struct _GtranslatorMessageTableModelClass GtranslatorMessageTableModelClass;
+typedef struct _GtranslatorMessageTableModelClass
+ GtranslatorMessageTableModelClass;
struct _GtranslatorMessageTableModelClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
-typedef enum _GtranslatorMessageTableModelColumn GtranslatorMessageTableModelColumn;
+typedef enum _GtranslatorMessageTableModelColumn
+ GtranslatorMessageTableModelColumn;
enum _GtranslatorMessageTableModelColumn
{
- GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN,
- GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
- GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN,
- GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN,
- GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
- GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN,
- GTR_MESSAGE_TABLE_MODEL_N_COLUMNS
+ GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN,
+ GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
+ GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN,
+ GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN,
+ GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
+ GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN,
+ GTR_MESSAGE_TABLE_MODEL_N_COLUMNS
};
/*
* Public methods
*/
-GType gtranslator_message_table_model_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_message_table_model_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_message_table_model_register_type (GTypeModule * module);
+ GType gtranslator_message_table_model_register_type (GTypeModule *
+ module);
-GtranslatorMessageTableModel *gtranslator_message_table_model_new (void);
-
-void gtranslator_message_table_model_append (GtranslatorMessageTableModel *model,
- GtranslatorMsg *msg,
- GtkTreeIter *iter);
+ GtranslatorMessageTableModel *gtranslator_message_table_model_new (void);
-void gtranslator_message_table_model_update_row (GtranslatorMessageTableModel *model,
- GtkTreePath *path);
+ void gtranslator_message_table_model_append (GtranslatorMessageTableModel
+ * model,
+ GtranslatorMsg * msg,
+ GtkTreeIter * iter);
-G_END_DECLS
+ void
+ gtranslator_message_table_model_update_row
+ (GtranslatorMessageTableModel * model, GtkTreePath * path);
+G_END_DECLS
#endif /* __MESSAGE_TABLE_MODEL_H__ */
diff --git a/src/message-table.c b/src/message-table.c
index 9481835..71c7c96 100644
--- a/src/message-table.c
+++ b/src/message-table.c
@@ -41,350 +41,347 @@
GTR_TYPE_MESSAGE_TABLE, \
GtranslatorMessageTablePrivate))
-G_DEFINE_TYPE (GtranslatorMessageTable, gtranslator_message_table, GTK_TYPE_VBOX)
-
-struct _GtranslatorMessageTablePrivate
+G_DEFINE_TYPE (GtranslatorMessageTable, gtranslator_message_table,
+ GTK_TYPE_VBOX)
+ struct _GtranslatorMessageTablePrivate
+ {
+ GtkWidget *treeview;
+ GtranslatorMessageTableModel *store;
+ GtkTreeModel *sort_model;
+
+ GtranslatorTab *tab;
+ };
+
+ static void
+ gtranslator_message_table_selection_changed (GtkTreeSelection *
+ selection,
+ GtranslatorMessageTable *
+ table)
{
- GtkWidget *treeview;
- GtranslatorMessageTableModel *store;
- GtkTreeModel *sort_model;
-
- GtranslatorTab *tab;
-};
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GList *msg = NULL;
+ GList *current_msg = NULL;
+ GtranslatorPo *po;
-static void
-gtranslator_message_table_selection_changed (GtkTreeSelection *selection,
- GtranslatorMessageTable *table)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- GList *msg = NULL;
- GList *current_msg = NULL;
- GtranslatorPo *po;
-
- g_return_if_fail (selection != NULL);
-
- po = gtranslator_tab_get_po (table->priv->tab);
- current_msg = gtranslator_po_get_current_message (po);
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter) == TRUE)
+ g_return_if_fail (selection != NULL);
+
+ po = gtranslator_tab_get_po (table->priv->tab);
+ current_msg = gtranslator_po_get_current_message (po);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter) == TRUE)
+ {
+ gtk_tree_model_get (model, &iter,
+ GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN, &msg, -1);
+
+ if (msg != NULL
+ && g_utf8_collate (gtranslator_msg_get_msgid (msg->data),
+ gtranslator_msg_get_msgid (current_msg->data)))
{
- gtk_tree_model_get (model, &iter,
- GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN,
- &msg, -1);
-
- if (msg != NULL && g_utf8_collate (gtranslator_msg_get_msgid (msg->data),
- gtranslator_msg_get_msgid (current_msg->data)))
- {
- gtranslator_tab_message_go_to (table->priv->tab, msg,
- FALSE, GTR_TAB_MOVE_NONE);
- }
+ gtranslator_tab_message_go_to (table->priv->tab, msg,
+ FALSE, GTR_TAB_MOVE_NONE);
}
+ }
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorMessageTable *table)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg, GtranslatorMessageTable * table)
{
- GtkTreeModel *model, *sort_model;
- GtkTreePath *path, *sort_path;
- GtkTreeSelection *selection;
- GtkTreeIter iter, sort_iter;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (table->priv->treeview));
-
- path = gtk_tree_row_reference_get_path (gtranslator_msg_get_row_reference (msg));
-
- gtk_tree_model_get_iter (table->priv->sort_model,
- &iter,
- path);
-
- gtk_tree_selection_select_iter (selection, &iter);
-
- gtk_tree_path_next (path);
-
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (table->priv->treeview),
- path,
- NULL,
- FALSE,
- 0.0, 0.0);
- gtk_tree_path_free (path);
+ GtkTreeModel *model, *sort_model;
+ GtkTreePath *path, *sort_path;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter, sort_iter;
+
+ selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (table->priv->treeview));
+
+ path =
+ gtk_tree_row_reference_get_path (gtranslator_msg_get_row_reference (msg));
+
+ gtk_tree_model_get_iter (table->priv->sort_model, &iter, path);
+
+ gtk_tree_selection_select_iter (selection, &iter);
+
+ gtk_tree_path_next (path);
+
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (table->priv->treeview),
+ path, NULL, FALSE, 0.0, 0.0);
+ gtk_tree_path_free (path);
}
static void
-message_changed_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorMessageTable *table)
+message_changed_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg, GtranslatorMessageTable * table)
{
- GtkTreePath *sort_path, *path;
- GtkTreeRowReference *row;
-
- row = gtranslator_msg_get_row_reference(msg);
- sort_path = gtk_tree_row_reference_get_path(row);
-
- path = gtk_tree_model_sort_convert_path_to_child_path(GTK_TREE_MODEL_SORT(table->priv->sort_model),
- sort_path);
-
- gtranslator_message_table_model_update_row (table->priv->store,
- path);
+ GtkTreePath *sort_path, *path;
+ GtkTreeRowReference *row;
+
+ row = gtranslator_msg_get_row_reference (msg);
+ sort_path = gtk_tree_row_reference_get_path (row);
+
+ path =
+ gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT
+ (table->priv->sort_model),
+ sort_path);
+
+ gtranslator_message_table_model_update_row (table->priv->store, path);
}
gint
-compare_by_status (gint a_status,
- gint b_status,
- gint a_pos,
- gint b_pos)
+compare_by_status (gint a_status, gint b_status, gint a_pos, gint b_pos)
{
- if (a_status == b_status)
- return a_pos - b_pos;
- else
- return a_status - b_status;
+ if (a_status == b_status)
+ return a_pos - b_pos;
+ else
+ return a_status - b_status;
}
gint
-model_compare_by_status (GtkTreeModel *model,
- GtkTreeIter *a,
- GtkTreeIter *b,
- gpointer user_data)
+model_compare_by_status (GtkTreeModel * model,
+ GtkTreeIter * a, GtkTreeIter * b, gpointer user_data)
{
- gint a_status, b_status, a_pos, b_pos;
-
- gtk_tree_model_get (model, a,
- GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
- &a_status,
- GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
- &a_pos,
- -1);
- gtk_tree_model_get (model, b,
- GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
- &b_status,
- GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
- &b_pos,
- -1);
-
- return compare_by_status (a_status, b_status, a_pos, b_pos);
+ gint a_status, b_status, a_pos, b_pos;
+
+ gtk_tree_model_get (model, a,
+ GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
+ &a_status,
+ GTR_MESSAGE_TABLE_MODEL_ID_COLUMN, &a_pos, -1);
+ gtk_tree_model_get (model, b,
+ GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
+ &b_status,
+ GTR_MESSAGE_TABLE_MODEL_ID_COLUMN, &b_pos, -1);
+
+ return compare_by_status (a_status, b_status, a_pos, b_pos);
}
gint
-list_compare_by_status (gconstpointer a,
- gconstpointer b)
+list_compare_by_status (gconstpointer a, gconstpointer b)
{
- gint a_status, b_status, a_pos, b_pos;
+ gint a_status, b_status, a_pos, b_pos;
- a_status = gtranslator_msg_get_status (GTR_MSG (a));
- b_status = gtranslator_msg_get_status (GTR_MSG (b));
+ a_status = gtranslator_msg_get_status (GTR_MSG (a));
+ b_status = gtranslator_msg_get_status (GTR_MSG (b));
- a_pos = gtranslator_msg_get_po_position (GTR_MSG (a));
- b_pos = gtranslator_msg_get_po_position (GTR_MSG (b));
+ a_pos = gtranslator_msg_get_po_position (GTR_MSG (a));
+ b_pos = gtranslator_msg_get_po_position (GTR_MSG (b));
- return compare_by_status (a_status, b_status, a_pos, b_pos);
+ return compare_by_status (a_status, b_status, a_pos, b_pos);
}
gint
-list_compare_by_position (gconstpointer a,
- gconstpointer b)
+list_compare_by_position (gconstpointer a, gconstpointer b)
{
- gint a_pos, b_pos;
- a_pos = gtranslator_msg_get_po_position (GTR_MSG (a));
- b_pos = gtranslator_msg_get_po_position (GTR_MSG (b));
+ gint a_pos, b_pos;
+ a_pos = gtranslator_msg_get_po_position (GTR_MSG (a));
+ b_pos = gtranslator_msg_get_po_position (GTR_MSG (b));
- return a_pos - b_pos;
+ return a_pos - b_pos;
}
gint
-list_compare_by_original (gconstpointer a,
- gconstpointer b)
+list_compare_by_original (gconstpointer a, gconstpointer b)
{
- const gchar *a_original, *b_original;
+ const gchar *a_original, *b_original;
- a_original = gtranslator_msg_get_msgid (GTR_MSG (a));
- b_original = gtranslator_msg_get_msgid (GTR_MSG (b));
+ a_original = gtranslator_msg_get_msgid (GTR_MSG (a));
+ b_original = gtranslator_msg_get_msgid (GTR_MSG (b));
- return g_utf8_collate (a_original, b_original);
+ return g_utf8_collate (a_original, b_original);
}
gint
-list_compare_by_translation (gconstpointer a,
- gconstpointer b)
+list_compare_by_translation (gconstpointer a, gconstpointer b)
{
- const gchar *a_translated, *b_translated;
+ const gchar *a_translated, *b_translated;
- a_translated = gtranslator_msg_get_msgstr (GTR_MSG (a));
- b_translated = gtranslator_msg_get_msgstr (GTR_MSG (b));
+ a_translated = gtranslator_msg_get_msgstr (GTR_MSG (a));
+ b_translated = gtranslator_msg_get_msgstr (GTR_MSG (b));
- return g_utf8_collate (a_translated, b_translated);
+ return g_utf8_collate (a_translated, b_translated);
}
-static void sort_message_list (GtkTreeViewColumn *column,
- GtranslatorMessageTable *table)
+static void
+sort_message_list (GtkTreeViewColumn * column,
+ GtranslatorMessageTable * table)
{
- GtranslatorPo *po;
- GList *messages;
- gint sort_column;
-
- po = gtranslator_tab_get_po (table->priv->tab);
- messages = gtranslator_po_get_messages (po);
-
- sort_column = gtk_tree_view_column_get_sort_column_id (column);
- switch (sort_column) {
- case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:
- messages = g_list_sort(messages, list_compare_by_position);
- break;
- case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:
- messages = g_list_sort(messages, list_compare_by_status);
- break;
- case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:
- messages = g_list_sort(messages, list_compare_by_original);
- break;
- case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:
- messages = g_list_sort(messages, list_compare_by_translation);
- break;
- }
-
- if (gtk_tree_view_column_get_sort_order (column) == GTK_SORT_DESCENDING)
- messages = g_list_reverse(messages);
-
- gtranslator_po_set_messages (po, messages);
-
- gtranslator_tab_message_go_to (table->priv->tab,
- g_list_first (messages),
- FALSE, GTR_TAB_MOVE_NONE);
+ GtranslatorPo *po;
+ GList *messages;
+ gint sort_column;
+
+ po = gtranslator_tab_get_po (table->priv->tab);
+ messages = gtranslator_po_get_messages (po);
+
+ sort_column = gtk_tree_view_column_get_sort_column_id (column);
+ switch (sort_column)
+ {
+ case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:
+ messages = g_list_sort (messages, list_compare_by_position);
+ break;
+ case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:
+ messages = g_list_sort (messages, list_compare_by_status);
+ break;
+ case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:
+ messages = g_list_sort (messages, list_compare_by_original);
+ break;
+ case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:
+ messages = g_list_sort (messages, list_compare_by_translation);
+ break;
+ }
+
+ if (gtk_tree_view_column_get_sort_order (column) == GTK_SORT_DESCENDING)
+ messages = g_list_reverse (messages);
+
+ gtranslator_po_set_messages (po, messages);
+
+ gtranslator_tab_message_go_to (table->priv->tab,
+ g_list_first (messages),
+ FALSE, GTR_TAB_MOVE_NONE);
}
static void
-gtranslator_message_table_draw (GtranslatorMessageTable *table)
+gtranslator_message_table_draw (GtranslatorMessageTable * table)
{
- GtranslatorMessageTablePrivate *priv = table->priv;
-
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
-
- priv->store = gtranslator_message_table_model_new ();
-
- priv->sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (priv->store));
-
- priv->treeview = gtk_tree_view_new ();
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->sort_model),
- GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
- GTK_SORT_ASCENDING);
-
- gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (priv->sort_model),
- NULL, NULL, NULL);
-
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->sort_model),
- GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
- model_compare_by_status,
- NULL,
- NULL);
-
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview), TRUE);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- column = gtk_tree_view_column_new_with_attributes(_("Status"),
- renderer,
- "icon-name", GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_sort_column_id(column, GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN);
- gtk_tree_view_column_set_resizable(column, FALSE);
- gtk_tree_view_append_column (GTK_TREE_VIEW(priv->treeview), column);
-
- /* Resort underlying GList when column header clicked */
- g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(sort_message_list), table);
-
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(_("ID"),
- renderer,
- "text", GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_sort_column_id(column, GTR_MESSAGE_TABLE_MODEL_ID_COLUMN);
- gtk_tree_view_column_set_resizable(column, FALSE);
- gtk_tree_view_append_column (GTK_TREE_VIEW(priv->treeview), column);
-
- /* Resort underlying GList when column header clicked */
- g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(sort_message_list), table);
-
- renderer = gtk_cell_renderer_text_new();
- g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- if(gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
- g_object_set(renderer, "xalign", 1.0, NULL);
- column = gtk_tree_view_column_new_with_attributes(_("Original Text"),
- renderer,
- "text", GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_sort_column_id(column, GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW(priv->treeview), column);
-
- /* Resort underlying GList when column header clicked */
- g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(sort_message_list), table);
-
- renderer=gtk_cell_renderer_text_new();
- g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-
- column = gtk_tree_view_column_new_with_attributes(_("Translated Text"),
- renderer,
- "text", GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_sort_column_id(column, GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN);
- gtk_tree_view_column_set_expand(column, TRUE);
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW(priv->treeview), column);
-
- /* Resort underlying GList when column header clicked */
- g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(sort_message_list), table);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->treeview));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
- g_signal_connect (G_OBJECT(selection), "changed",
- G_CALLBACK(gtranslator_message_table_selection_changed),
- table);
+ GtranslatorMessageTablePrivate *priv = table->priv;
+
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+
+ priv->store = gtranslator_message_table_model_new ();
+
+ priv->sort_model =
+ gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (priv->store));
+
+ priv->treeview = gtk_tree_view_new ();
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->sort_model),
+ GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
+ GTK_SORT_ASCENDING);
+
+ gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE
+ (priv->sort_model), NULL, NULL,
+ NULL);
+
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->sort_model),
+ GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN,
+ model_compare_by_status, NULL, NULL);
+
+ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview), TRUE);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Status"),
+ renderer,
+ "icon-name",
+ GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_sort_column_id (column,
+ GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN);
+ gtk_tree_view_column_set_resizable (column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+
+ /* Resort underlying GList when column header clicked */
+ g_signal_connect (G_OBJECT (column), "clicked",
+ G_CALLBACK (sort_message_list), table);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("ID"),
+ renderer,
+ "text",
+ GTR_MESSAGE_TABLE_MODEL_ID_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_sort_column_id (column,
+ GTR_MESSAGE_TABLE_MODEL_ID_COLUMN);
+ gtk_tree_view_column_set_resizable (column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+
+ /* Resort underlying GList when column header clicked */
+ g_signal_connect (G_OBJECT (column), "clicked",
+ G_CALLBACK (sort_message_list), table);
+
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
+ g_object_set (renderer, "xalign", 1.0, NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Original Text"),
+ renderer,
+ "text",
+ GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_sort_column_id (column,
+ GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+
+ /* Resort underlying GList when column header clicked */
+ g_signal_connect (G_OBJECT (column), "clicked",
+ G_CALLBACK (sort_message_list), table);
+
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+
+ column = gtk_tree_view_column_new_with_attributes (_("Translated Text"),
+ renderer,
+ "text",
+ GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_sort_column_id (column,
+ GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
+
+ /* Resort underlying GList when column header clicked */
+ g_signal_connect (G_OBJECT (column), "clicked",
+ G_CALLBACK (sort_message_list), table);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (gtranslator_message_table_selection_changed),
+ table);
}
static void
-gtranslator_message_table_init (GtranslatorMessageTable *table)
+gtranslator_message_table_init (GtranslatorMessageTable * table)
{
- GtkWidget *scrolledwindow;
-
- table->priv = GTR_MESSAGE_TABLE_GET_PRIVATE (table);
-
- gtranslator_message_table_draw(table);
-
- scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(table), scrolledwindow, TRUE, TRUE, 0);
- gtk_widget_show (scrolledwindow);
-
- gtk_container_add(GTK_CONTAINER(scrolledwindow),
- table->priv->treeview);
- gtk_widget_show (table->priv->treeview);
+ GtkWidget *scrolledwindow;
+
+ table->priv = GTR_MESSAGE_TABLE_GET_PRIVATE (table);
+
+ gtranslator_message_table_draw (table);
+
+ scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start (GTK_BOX (table), scrolledwindow, TRUE, TRUE, 0);
+ gtk_widget_show (scrolledwindow);
+
+ gtk_container_add (GTK_CONTAINER (scrolledwindow), table->priv->treeview);
+ gtk_widget_show (table->priv->treeview);
}
static void
-gtranslator_message_table_finalize (GObject *object)
+gtranslator_message_table_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_message_table_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_message_table_parent_class)->finalize (object);
}
static void
-gtranslator_message_table_class_init (GtranslatorMessageTableClass *klass)
+gtranslator_message_table_class_init (GtranslatorMessageTableClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorMessageTablePrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorMessageTablePrivate));
- object_class->finalize = gtranslator_message_table_finalize;
+ object_class->finalize = gtranslator_message_table_finalize;
}
/**
@@ -396,20 +393,17 @@ gtranslator_message_table_class_init (GtranslatorMessageTableClass *klass)
* Returns: the newly created #GtranslatorMessageTable
*/
GtkWidget *
-gtranslator_message_table_new (GtkWidget *tab)
+gtranslator_message_table_new (GtkWidget * tab)
{
- GtranslatorMessageTable *obj = GTR_MESSAGE_TABLE(g_object_new (GTR_TYPE_MESSAGE_TABLE, NULL));
- obj->priv->tab = GTR_TAB(tab);
- g_signal_connect(obj->priv->tab,
- "showed-message",
- G_CALLBACK(showed_message_cb),
- obj);
- g_signal_connect(obj->priv->tab,
- "message-changed",
- G_CALLBACK(message_changed_cb),
- obj);
-
- return GTK_WIDGET(obj);
+ GtranslatorMessageTable *obj =
+ GTR_MESSAGE_TABLE (g_object_new (GTR_TYPE_MESSAGE_TABLE, NULL));
+ obj->priv->tab = GTR_TAB (tab);
+ g_signal_connect (obj->priv->tab,
+ "showed-message", G_CALLBACK (showed_message_cb), obj);
+ g_signal_connect (obj->priv->tab,
+ "message-changed", G_CALLBACK (message_changed_cb), obj);
+
+ return GTK_WIDGET (obj);
}
/**
@@ -420,36 +414,37 @@ gtranslator_message_table_new (GtkWidget *tab)
* Populates the #GtranslatorMessageTable with the list of #GtranslatorMsg and
* sort them.
*/
-void
-gtranslator_message_table_populate(GtranslatorMessageTable *table,
- GList *messages)
+void
+gtranslator_message_table_populate (GtranslatorMessageTable * table,
+ GList * messages)
{
- GtkTreeIter iter, sort_iter;
- GtkTreePath *path;
- GtkTreeRowReference *row;
-
- g_return_if_fail(table != NULL);
- g_return_if_fail(messages != NULL);
-
- while (messages)
- {
- gtranslator_message_table_model_append (table->priv->store,
- messages->data,
- &iter);
-
- gtk_tree_model_sort_convert_child_iter_to_iter(GTK_TREE_MODEL_SORT(table->priv->sort_model),
- &sort_iter, &iter);
- path = gtk_tree_model_get_path(table->priv->sort_model, &sort_iter);
- row = gtk_tree_row_reference_new(table->priv->sort_model, path);
- gtk_tree_path_free(path);
-
- gtranslator_msg_set_row_reference(GTR_MSG(messages->data), row);
-
- messages = g_list_next(messages);
- }
- /*
- * It is much faster set the model after list population
- */
- gtk_tree_view_set_model (GTK_TREE_VIEW (table->priv->treeview),
- table->priv->sort_model);
+ GtkTreeIter iter, sort_iter;
+ GtkTreePath *path;
+ GtkTreeRowReference *row;
+
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (messages != NULL);
+
+ while (messages)
+ {
+ gtranslator_message_table_model_append (table->priv->store,
+ messages->data, &iter);
+
+ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT
+ (table->priv->
+ sort_model),
+ &sort_iter, &iter);
+ path = gtk_tree_model_get_path (table->priv->sort_model, &sort_iter);
+ row = gtk_tree_row_reference_new (table->priv->sort_model, path);
+ gtk_tree_path_free (path);
+
+ gtranslator_msg_set_row_reference (GTR_MSG (messages->data), row);
+
+ messages = g_list_next (messages);
+ }
+ /*
+ * It is much faster set the model after list population
+ */
+ gtk_tree_view_set_model (GTK_TREE_VIEW (table->priv->treeview),
+ table->priv->sort_model);
}
diff --git a/src/message-table.h b/src/message-table.h
index 2178f34..8da486b 100644
--- a/src/message-table.h
+++ b/src/message-table.h
@@ -25,7 +25,6 @@
#include "msg.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,49 +34,51 @@ G_BEGIN_DECLS
#define GTR_IS_MESSAGE_TABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_MESSAGE_TABLE))
#define GTR_IS_MESSAGE_TABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_MESSAGE_TABLE))
#define GTR_MESSAGE_TABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_MESSAGE_TABLE, GtranslatorMessageTableClass))
-
/* Private structure type */
-typedef struct _GtranslatorMessageTablePrivate GtranslatorMessageTablePrivate;
+typedef struct _GtranslatorMessageTablePrivate GtranslatorMessageTablePrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorMessageTable GtranslatorMessageTable;
+typedef struct _GtranslatorMessageTable GtranslatorMessageTable;
struct _GtranslatorMessageTable
{
- GtkVBox parent_instance;
-
- /* < private > */
- GtranslatorMessageTablePrivate *priv;
+ GtkVBox parent_instance;
+
+ /* < private > */
+ GtranslatorMessageTablePrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorMessageTableClass GtranslatorMessageTableClass;
+typedef struct _GtranslatorMessageTableClass GtranslatorMessageTableClass;
struct _GtranslatorMessageTableClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_message_table_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_message_table_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_message_table_register_type (GTypeModule * module);
+ GType gtranslator_message_table_register_type (GTypeModule * module);
-GtkWidget *gtranslator_message_table_new (GtkWidget *tab);
+ GtkWidget *gtranslator_message_table_new (GtkWidget * tab);
-void gtranslator_message_table_populate (GtranslatorMessageTable *table,
- GList *messages);
+ void gtranslator_message_table_populate (GtranslatorMessageTable * table,
+ GList * messages);
-void gtranslator_message_table_update_translation (GtranslatorMessageTable *table,
- GtranslatorMsg *msg,
- gchar *translation);
+ void
+ gtranslator_message_table_update_translation (GtranslatorMessageTable *
+ table,
+ GtranslatorMsg * msg,
+ gchar * translation);
G_END_DECLS
-
#endif /* __MESSAGE_TABLE_H__ */
diff --git a/src/msg.c b/src/msg.c
index b851894..6e0231a 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -38,114 +38,107 @@
GtranslatorMsgPrivate))
-G_DEFINE_TYPE(GtranslatorMsg, gtranslator_msg, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GtranslatorMsg, gtranslator_msg, G_TYPE_OBJECT)
+ struct _GtranslatorMsgPrivate
+ {
+ po_message_iterator_t iterator;
-struct _GtranslatorMsgPrivate
-{
- po_message_iterator_t iterator;
-
- po_message_t message;
-
- GtranslatorMsgStatus status;
+ po_message_t message;
- GtkTreeRowReference *row_reference;
+ GtranslatorMsgStatus status;
- gint po_position;
-};
+ GtkTreeRowReference *row_reference;
-enum
-{
- PROP_0,
- PROP_GETTEXT_ITER,
- PROP_GETTEXT_MSG
-};
+ gint po_position;
+ };
-static gchar *message_error = NULL;
+ enum
+ {
+ PROP_0,
+ PROP_GETTEXT_ITER,
+ PROP_GETTEXT_MSG
+ };
-static void
-gtranslator_msg_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ static gchar *message_error = NULL;
+
+ static void
+ gtranslator_msg_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GtranslatorMsg *msg = GTR_MSG (object);
+ GtranslatorMsg *msg = GTR_MSG (object);
- switch (prop_id)
- {
- case PROP_GETTEXT_ITER:
- gtranslator_msg_set_iterator (msg,
- g_value_get_pointer (value));
- break;
- case PROP_GETTEXT_MSG:
- gtranslator_msg_set_message (msg,
- g_value_get_pointer (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_GETTEXT_ITER:
+ gtranslator_msg_set_iterator (msg, g_value_get_pointer (value));
+ break;
+ case PROP_GETTEXT_MSG:
+ gtranslator_msg_set_message (msg, g_value_get_pointer (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gtranslator_msg_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtranslatorMsg *msg = GTR_MSG (object);
-
- switch (prop_id)
- {
- case PROP_GETTEXT_ITER:
- g_value_set_pointer (value,
- gtranslator_msg_get_iterator (msg));
- break;
- case PROP_GETTEXT_MSG:
- g_value_set_pointer (value,
- gtranslator_msg_get_message (msg));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+gtranslator_msg_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GtranslatorMsg *msg = GTR_MSG (object);
+
+ switch (prop_id)
+ {
+ case PROP_GETTEXT_ITER:
+ g_value_set_pointer (value, gtranslator_msg_get_iterator (msg));
+ break;
+ case PROP_GETTEXT_MSG:
+ g_value_set_pointer (value, gtranslator_msg_get_message (msg));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gtranslator_msg_init (GtranslatorMsg *msg)
+gtranslator_msg_init (GtranslatorMsg * msg)
{
- msg->priv = GTR_MSG_GET_PRIVATE (msg);
+ msg->priv = GTR_MSG_GET_PRIVATE (msg);
}
static void
-gtranslator_msg_finalize (GObject *object)
-{
- G_OBJECT_CLASS (gtranslator_msg_parent_class)->finalize (object);
+gtranslator_msg_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (gtranslator_msg_parent_class)->finalize (object);
}
static void
-gtranslator_msg_class_init (GtranslatorMsgClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GtranslatorMsgPrivate));
-
- object_class->finalize = gtranslator_msg_finalize;
- object_class->set_property = gtranslator_msg_set_property;
- object_class->get_property = gtranslator_msg_get_property;
-
- g_object_class_install_property (object_class,
- PROP_GETTEXT_MSG,
- g_param_spec_pointer ("gettext-iter",
- "Gettext iterator",
- "The po_message_iterator_t pointer",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_GETTEXT_MSG,
- g_param_spec_pointer ("gettext-msg",
- "Gettext msg",
- "The po_message_t pointer",
- G_PARAM_READWRITE));
+gtranslator_msg_class_init (GtranslatorMsgClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorMsgPrivate));
+
+ object_class->finalize = gtranslator_msg_finalize;
+ object_class->set_property = gtranslator_msg_set_property;
+ object_class->get_property = gtranslator_msg_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_GETTEXT_MSG,
+ g_param_spec_pointer ("gettext-iter",
+ "Gettext iterator",
+ "The po_message_iterator_t pointer",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_GETTEXT_MSG,
+ g_param_spec_pointer ("gettext-msg",
+ "Gettext msg",
+ "The po_message_t pointer",
+ G_PARAM_READWRITE));
}
/***************************** Public funcs ***********************************/
@@ -158,24 +151,24 @@ gtranslator_msg_class_init (GtranslatorMsgClass *klass)
* Return value: a new #GtranslatorMsg object
**/
GtranslatorMsg *
-gtranslator_msg_new (po_message_iterator_t iter,
- po_message_t message)
-{
- GtranslatorMsg *msg;
-
- msg = g_object_new (GTR_TYPE_MSG, NULL);
-
- gtranslator_msg_set_iterator (msg, iter);
- gtranslator_msg_set_message (msg, message);
-
- /* Set the status */
- if (gtranslator_msg_is_fuzzy (msg))
- gtranslator_msg_set_status (msg, GTR_MSG_STATUS_FUZZY);
- else if (gtranslator_msg_is_translated (msg))
- gtranslator_msg_set_status (msg, GTR_MSG_STATUS_TRANSLATED);
- else gtranslator_msg_set_status (msg, GTR_MSG_STATUS_UNTRANSLATED);
-
- return msg;
+gtranslator_msg_new (po_message_iterator_t iter, po_message_t message)
+{
+ GtranslatorMsg *msg;
+
+ msg = g_object_new (GTR_TYPE_MSG, NULL);
+
+ gtranslator_msg_set_iterator (msg, iter);
+ gtranslator_msg_set_message (msg, message);
+
+ /* Set the status */
+ if (gtranslator_msg_is_fuzzy (msg))
+ gtranslator_msg_set_status (msg, GTR_MSG_STATUS_FUZZY);
+ else if (gtranslator_msg_is_translated (msg))
+ gtranslator_msg_set_status (msg, GTR_MSG_STATUS_TRANSLATED);
+ else
+ gtranslator_msg_set_status (msg, GTR_MSG_STATUS_UNTRANSLATED);
+
+ return msg;
}
/**
@@ -185,11 +178,11 @@ gtranslator_msg_new (po_message_iterator_t iter,
* Return value: the message iterator in gettext format
**/
po_message_iterator_t
-gtranslator_msg_get_iterator (GtranslatorMsg *msg)
+gtranslator_msg_get_iterator (GtranslatorMsg * msg)
{
- g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
-
- return msg->priv->iterator;
+ g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
+
+ return msg->priv->iterator;
}
/**
@@ -200,14 +193,14 @@ gtranslator_msg_get_iterator (GtranslatorMsg *msg)
* Sets the iterator into the #GtranslatorMsg class.
**/
void
-gtranslator_msg_set_iterator (GtranslatorMsg *msg,
+gtranslator_msg_set_iterator (GtranslatorMsg * msg,
po_message_iterator_t iter)
{
- g_return_if_fail (GTR_IS_MSG (msg));
-
- msg->priv->iterator = iter;
-
- g_object_notify (G_OBJECT (msg), "gettext-iter");
+ g_return_if_fail (GTR_IS_MSG (msg));
+
+ msg->priv->iterator = iter;
+
+ g_object_notify (G_OBJECT (msg), "gettext-iter");
}
/**
@@ -217,11 +210,11 @@ gtranslator_msg_set_iterator (GtranslatorMsg *msg,
* Return value: the message in gettext format
**/
po_message_t
-gtranslator_msg_get_message (GtranslatorMsg *msg)
+gtranslator_msg_get_message (GtranslatorMsg * msg)
{
- g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
-
- return msg->priv->message;
+ g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
+
+ return msg->priv->message;
}
/**
@@ -232,12 +225,11 @@ gtranslator_msg_get_message (GtranslatorMsg *msg)
* Sets the message into the #GtranslatorMsg class.
**/
void
-gtranslator_msg_set_message(GtranslatorMsg *msg,
- po_message_t message)
+gtranslator_msg_set_message (GtranslatorMsg * msg, po_message_t message)
{
- msg->priv->message = message;
-
- g_object_notify (G_OBJECT (msg), "gettext-msg");
+ msg->priv->message = message;
+
+ g_object_notify (G_OBJECT (msg), "gettext-msg");
}
/**
@@ -248,9 +240,9 @@ gtranslator_msg_set_message(GtranslatorMsg *msg,
* in the message table
*/
GtkTreeRowReference *
-gtranslator_msg_get_row_reference(GtranslatorMsg *msg)
+gtranslator_msg_get_row_reference (GtranslatorMsg * msg)
{
- return msg->priv->row_reference;
+ return msg->priv->row_reference;
}
/**
@@ -261,10 +253,10 @@ gtranslator_msg_get_row_reference(GtranslatorMsg *msg)
* Sets the GtkTreeRowReference from the messages table for the given message
**/
void
-gtranslator_msg_set_row_reference(GtranslatorMsg *msg,
- GtkTreeRowReference *row_reference)
+gtranslator_msg_set_row_reference (GtranslatorMsg * msg,
+ GtkTreeRowReference * row_reference)
{
- msg->priv->row_reference = row_reference;
+ msg->priv->row_reference = row_reference;
}
/**
@@ -274,25 +266,26 @@ gtranslator_msg_set_row_reference(GtranslatorMsg *msg,
* Return value: TRUE if the message is translated
**/
gboolean
-gtranslator_msg_is_translated (GtranslatorMsg *msg)
+gtranslator_msg_is_translated (GtranslatorMsg * msg)
{
- if (po_message_msgid_plural(msg->priv->message) == NULL)
- return po_message_msgstr(msg->priv->message)[0] != '\0';
- else
+ if (po_message_msgid_plural (msg->priv->message) == NULL)
+ return po_message_msgstr (msg->priv->message)[0] != '\0';
+ else
+ {
+ gint i;
+
+ for (i = 0;; i++)
{
- gint i;
-
- for (i = 0; ; i++)
- {
- const gchar *str_i = po_message_msgstr_plural(msg->priv->message, i);
- if (str_i == NULL)
- break;
- if (str_i[0] == '\0')
- return FALSE;
- }
-
- return TRUE;
+ const gchar *str_i =
+ po_message_msgstr_plural (msg->priv->message, i);
+ if (str_i == NULL)
+ break;
+ if (str_i[0] == '\0')
+ return FALSE;
}
+
+ return TRUE;
+ }
}
/**
@@ -302,9 +295,9 @@ gtranslator_msg_is_translated (GtranslatorMsg *msg)
* Return value: TRUE if the message is fuzzy
**/
gboolean
-gtranslator_msg_is_fuzzy(GtranslatorMsg *msg)
+gtranslator_msg_is_fuzzy (GtranslatorMsg * msg)
{
- return po_message_is_fuzzy(msg->priv->message);
+ return po_message_is_fuzzy (msg->priv->message);
}
@@ -316,10 +309,9 @@ gtranslator_msg_is_fuzzy(GtranslatorMsg *msg)
* Change the fuzzy mark of a message.
**/
void
-gtranslator_msg_set_fuzzy(GtranslatorMsg *msg,
- gboolean fuzzy)
+gtranslator_msg_set_fuzzy (GtranslatorMsg * msg, gboolean fuzzy)
{
- po_message_set_fuzzy(msg->priv->message, fuzzy);
+ po_message_set_fuzzy (msg->priv->message, fuzzy);
}
/**
@@ -330,10 +322,9 @@ gtranslator_msg_set_fuzzy(GtranslatorMsg *msg,
* Sets the status for a message.
*/
void
-gtranslator_msg_set_status(GtranslatorMsg *msg,
- GtranslatorMsgStatus status)
+gtranslator_msg_set_status (GtranslatorMsg * msg, GtranslatorMsgStatus status)
{
- msg->priv->status = status;
+ msg->priv->status = status;
}
/**
@@ -343,9 +334,9 @@ gtranslator_msg_set_status(GtranslatorMsg *msg,
* Return value: the message's status.
*/
GtranslatorMsgStatus
-gtranslator_msg_get_status(GtranslatorMsg *msg)
+gtranslator_msg_get_status (GtranslatorMsg * msg)
{
- return msg->priv->status;
+ return msg->priv->status;
}
/**
@@ -355,9 +346,9 @@ gtranslator_msg_get_status(GtranslatorMsg *msg)
* Return value: the msgid (untranslated English string) of a message.
**/
const gchar *
-gtranslator_msg_get_msgid(GtranslatorMsg *msg)
+gtranslator_msg_get_msgid (GtranslatorMsg * msg)
{
- return po_message_msgid(msg->priv->message);
+ return po_message_msgid (msg->priv->message);
}
@@ -369,9 +360,9 @@ gtranslator_msg_get_msgid(GtranslatorMsg *msg)
* message, or NULL for a message without plural.
**/
const gchar *
-gtranslator_msg_get_msgid_plural(GtranslatorMsg *msg)
+gtranslator_msg_get_msgid_plural (GtranslatorMsg * msg)
{
- return po_message_msgid_plural(msg->priv->message);
+ return po_message_msgid_plural (msg->priv->message);
}
@@ -383,9 +374,9 @@ gtranslator_msg_get_msgid_plural(GtranslatorMsg *msg)
* Return the empty string for an untranslated message.
**/
const gchar *
-gtranslator_msg_get_msgstr(GtranslatorMsg *msg)
+gtranslator_msg_get_msgstr (GtranslatorMsg * msg)
{
- return po_message_msgstr(msg->priv->message);
+ return po_message_msgstr (msg->priv->message);
}
@@ -398,10 +389,9 @@ gtranslator_msg_get_msgstr(GtranslatorMsg *msg)
* Use an empty string to denote an untranslated message.
**/
void
-gtranslator_msg_set_msgstr(GtranslatorMsg *msg,
- const gchar *msgstr)
+gtranslator_msg_set_msgstr (GtranslatorMsg * msg, const gchar * msgstr)
{
- po_message_set_msgstr(msg->priv->message, msgstr);
+ po_message_set_msgstr (msg->priv->message, msgstr);
}
@@ -414,10 +404,9 @@ gtranslator_msg_set_msgstr(GtranslatorMsg *msg,
* NULL when the index is out of range or for a message without plural.
**/
const gchar *
-gtranslator_msg_get_msgstr_plural(GtranslatorMsg *msg,
- gint index)
+gtranslator_msg_get_msgstr_plural (GtranslatorMsg * msg, gint index)
{
- return po_message_msgstr_plural(msg->priv->message, index);
+ return po_message_msgstr_plural (msg->priv->message, index);
}
/**
@@ -430,13 +419,10 @@ gtranslator_msg_get_msgstr_plural(GtranslatorMsg *msg,
* Use a NULL value at the end to reduce the number of plural forms.
**/
void
-gtranslator_msg_set_msgstr_plural(GtranslatorMsg *msg,
- gint index,
- const gchar *msgstr)
+gtranslator_msg_set_msgstr_plural (GtranslatorMsg * msg,
+ gint index, const gchar * msgstr)
{
- po_message_set_msgstr_plural(msg->priv->message,
- index,
- msgstr);
+ po_message_set_msgstr_plural (msg->priv->message, index, msgstr);
}
@@ -447,9 +433,9 @@ gtranslator_msg_set_msgstr_plural(GtranslatorMsg *msg,
* Return value: the comments for a message.
**/
const gchar *
-gtranslator_msg_get_comment(GtranslatorMsg *msg)
+gtranslator_msg_get_comment (GtranslatorMsg * msg)
{
- return po_message_comments(msg->priv->message);
+ return po_message_comments (msg->priv->message);
}
/**
@@ -462,10 +448,9 @@ gtranslator_msg_get_comment(GtranslatorMsg *msg)
* ending in a newline, or empty.
**/
void
-gtranslator_msg_set_comment(GtranslatorMsg *msg,
- const gchar *comment)
+gtranslator_msg_set_comment (GtranslatorMsg * msg, const gchar * comment)
{
- po_message_set_comments(msg->priv->message, comment);
+ po_message_set_comments (msg->priv->message, comment);
}
/**
@@ -478,9 +463,9 @@ gtranslator_msg_set_comment(GtranslatorMsg *msg,
* messages.
**/
gint
-gtranslator_msg_get_po_position (GtranslatorMsg *msg)
+gtranslator_msg_get_po_position (GtranslatorMsg * msg)
{
- return msg->priv->po_position;
+ return msg->priv->po_position;
}
/**
@@ -491,10 +476,9 @@ gtranslator_msg_get_po_position (GtranslatorMsg *msg)
* Sets the numerical position of this message in relation to other messages.
**/
void
-gtranslator_msg_set_po_position (GtranslatorMsg *msg,
- gint po_position)
+gtranslator_msg_set_po_position (GtranslatorMsg * msg, gint po_position)
{
- msg->priv->po_position = po_position;
+ msg->priv->po_position = po_position;
}
/**
@@ -504,9 +488,9 @@ gtranslator_msg_set_po_position (GtranslatorMsg *msg,
* Return value: the extracted comments for a message.
**/
const gchar *
-gtranslator_msg_get_extracted_comments(GtranslatorMsg *msg)
+gtranslator_msg_get_extracted_comments (GtranslatorMsg * msg)
{
- return po_message_extracted_comments(msg->priv->message);
+ return po_message_extracted_comments (msg->priv->message);
}
/**
@@ -518,17 +502,16 @@ gtranslator_msg_get_extracted_comments(GtranslatorMsg *msg)
* of range.
*/
const gchar *
-gtranslator_msg_get_filename(GtranslatorMsg *msg,
- gint i)
+gtranslator_msg_get_filename (GtranslatorMsg * msg, gint i)
{
- po_filepos_t filepos;
-
- filepos = po_message_filepos(msg->priv->message, i);
-
- if(filepos == NULL)
- return NULL;
-
- return po_filepos_file(filepos);
+ po_filepos_t filepos;
+
+ filepos = po_message_filepos (msg->priv->message, i);
+
+ if (filepos == NULL)
+ return NULL;
+
+ return po_filepos_file (filepos);
}
/**
@@ -540,17 +523,16 @@ gtranslator_msg_get_filename(GtranslatorMsg *msg,
* of range.
*/
gint *
-gtranslator_msg_get_file_line(GtranslatorMsg *msg,
- gint i)
+gtranslator_msg_get_file_line (GtranslatorMsg * msg, gint i)
{
- po_filepos_t filepos;
-
- filepos = po_message_filepos(msg->priv->message, i);
-
- if(filepos == NULL)
- return NULL;
-
- return (gint *)po_filepos_start_line(filepos);
+ po_filepos_t filepos;
+
+ filepos = po_message_filepos (msg->priv->message, i);
+
+ if (filepos == NULL)
+ return NULL;
+
+ return (gint *) po_filepos_start_line (filepos);
}
/**
@@ -561,11 +543,11 @@ gtranslator_msg_get_file_line(GtranslatorMsg *msg,
* message not restricted to a context.
*/
const gchar *
-gtranslator_msg_get_msgctxt(GtranslatorMsg *msg)
+gtranslator_msg_get_msgctxt (GtranslatorMsg * msg)
{
- g_return_val_if_fail(GTR_IS_MSG(msg), NULL);
+ g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
- return po_message_msgctxt(msg->priv->message);
+ return po_message_msgctxt (msg->priv->message);
}
/**
@@ -580,48 +562,50 @@ gtranslator_msg_get_msgctxt(GtranslatorMsg *msg)
* if the message hasn't any format type.
*/
const gchar *
-gtranslator_msg_get_format (GtranslatorMsg *msg)
-{
- const gchar * const *format_list;
- gint i;
-
- g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
-
- format_list = po_format_list ();
-
- for (i = 0; format_list[i] != NULL; i++)
- {
- if (po_message_is_format (msg->priv->message, format_list[i]))
- return po_format_pretty_name (format_list[i]);
- }
-
- return NULL;
+gtranslator_msg_get_format (GtranslatorMsg * msg)
+{
+ const gchar *const *format_list;
+ gint i;
+
+ g_return_val_if_fail (GTR_IS_MSG (msg), NULL);
+
+ format_list = po_format_list ();
+
+ for (i = 0; format_list[i] != NULL; i++)
+ {
+ if (po_message_is_format (msg->priv->message, format_list[i]))
+ return po_format_pretty_name (format_list[i]);
+ }
+
+ return NULL;
}
/*
* Functions to manage the gettext errors
*/
static void
-on_gettext_po_xerror(gint severity,
- po_message_t message,
- const gchar *filename, size_t lineno, size_t column,
- gint multiline_p, const gchar *message_text)
+on_gettext_po_xerror (gint severity,
+ po_message_t message,
+ const gchar * filename, size_t lineno, size_t column,
+ gint multiline_p, const gchar * message_text)
{
- if (message_text)
- message_error = g_strdup (message_text);
- else message_error = NULL;
+ if (message_text)
+ message_error = g_strdup (message_text);
+ else
+ message_error = NULL;
}
static void
-on_gettext_po_xerror2(gint severity,
- po_message_t message1,
- const gchar *filename1, size_t lineno1, size_t column1,
- gint multiline_p1, const gchar *message_text1,
- po_message_t message2,
- const gchar *filename2, size_t lineno2, size_t column2,
- gint multiline_p2, const gchar *message_text2)
+on_gettext_po_xerror2 (gint severity,
+ po_message_t message1,
+ const gchar * filename1, size_t lineno1,
+ size_t column1, gint multiline_p1,
+ const gchar * message_text1, po_message_t message2,
+ const gchar * filename2, size_t lineno2,
+ size_t column2, gint multiline_p2,
+ const gchar * message_text2)
{
- g_warning("Error: %s.\n %s", message_text1, message_text2);
+ g_warning ("Error: %s.\n %s", message_text1, message_text2);
}
@@ -636,29 +620,29 @@ on_gettext_po_xerror2(gint severity,
* is marked as being a format string.
**/
gchar *
-gtranslator_msg_check(GtranslatorMsg *msg)
-{
- struct po_xerror_handler handler;
-
- g_return_val_if_fail(msg != NULL, NULL);
-
- /* We are not freeing the message_error so at start should be NULL
- * always for us
- */
- message_error = NULL;
-
- handler.xerror = &on_gettext_po_xerror;
- handler.xerror2 = &on_gettext_po_xerror2;
-
- po_message_check_all(msg->priv->message, msg->priv->iterator, &handler);
-
- if(gtranslator_msg_is_fuzzy(msg) || !gtranslator_msg_is_translated(msg))
- {
- if (message_error)
- g_free (message_error);
- message_error = NULL;
- }
+gtranslator_msg_check (GtranslatorMsg * msg)
+{
+ struct po_xerror_handler handler;
+
+ g_return_val_if_fail (msg != NULL, NULL);
+
+ /* We are not freeing the message_error so at start should be NULL
+ * always for us
+ */
+ message_error = NULL;
+
+ handler.xerror = &on_gettext_po_xerror;
+ handler.xerror2 = &on_gettext_po_xerror2;
+
+ po_message_check_all (msg->priv->message, msg->priv->iterator, &handler);
+
+ if (gtranslator_msg_is_fuzzy (msg) || !gtranslator_msg_is_translated (msg))
+ {
+ if (message_error)
+ g_free (message_error);
+ message_error = NULL;
+ }
- /*Are there any other way to do this?*/
- return message_error;
+ /*Are there any other way to do this? */
+ return message_error;
}
diff --git a/src/msg.h b/src/msg.h
index 5172e7d..6a0f270 100644
--- a/src/msg.h
+++ b/src/msg.h
@@ -29,7 +29,6 @@
#include <gettext-po.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -39,119 +38,118 @@ G_BEGIN_DECLS
#define GTR_IS_MSG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_MSG))
#define GTR_IS_MSG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_MSG))
#define GTR_MSG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_MSG, GtranslatorMsgClass))
-
/* Private structure type */
-typedef struct _GtranslatorMsgPrivate GtranslatorMsgPrivate;
+typedef struct _GtranslatorMsgPrivate GtranslatorMsgPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorMsg GtranslatorMsg;
+typedef struct _GtranslatorMsg GtranslatorMsg;
struct _GtranslatorMsg
{
- GObject parent_instance;
-
- /*< private > */
- GtranslatorMsgPrivate *priv;
+ GObject parent_instance;
+
+ /*< private > */
+ GtranslatorMsgPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorMsgClass GtranslatorMsgClass;
+typedef struct _GtranslatorMsgClass GtranslatorMsgClass;
struct _GtranslatorMsgClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
typedef enum
{
- GTR_MSG_STATUS_UNTRANSLATED,
- GTR_MSG_STATUS_FUZZY,
- GTR_MSG_STATUS_TRANSLATED
+ GTR_MSG_STATUS_UNTRANSLATED,
+ GTR_MSG_STATUS_FUZZY,
+ GTR_MSG_STATUS_TRANSLATED
} GtranslatorMsgStatus;
/*
* Public methods
*/
-GType gtranslator_msg_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_msg_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_msg_register_type (GTypeModule * module);
+ GType gtranslator_msg_register_type (GTypeModule * module);
-GtranslatorMsg *gtranslator_msg_new (po_message_iterator_t iter,
- po_message_t message);
+ GtranslatorMsg *gtranslator_msg_new (po_message_iterator_t iter,
+ po_message_t message);
po_message_iterator_t
- gtranslator_msg_get_iterator (GtranslatorMsg *msg);
+gtranslator_msg_get_iterator (GtranslatorMsg * msg);
-void gtranslator_msg_set_iterator (GtranslatorMsg *msg,
- po_message_iterator_t iter);
+ void gtranslator_msg_set_iterator (GtranslatorMsg * msg,
+ po_message_iterator_t iter);
-po_message_t gtranslator_msg_get_message (GtranslatorMsg *msg);
+ po_message_t gtranslator_msg_get_message (GtranslatorMsg * msg);
-void gtranslator_msg_set_message (GtranslatorMsg *msg,
- po_message_t message);
+ void gtranslator_msg_set_message (GtranslatorMsg * msg,
+ po_message_t message);
-GtkTreeRowReference *gtranslator_msg_get_row_reference (GtranslatorMsg *msg);
+ GtkTreeRowReference *gtranslator_msg_get_row_reference (GtranslatorMsg *
+ msg);
-void gtranslator_msg_set_row_reference (GtranslatorMsg *msg,
- GtkTreeRowReference *row_reference);
+ void gtranslator_msg_set_row_reference (GtranslatorMsg * msg,
+ GtkTreeRowReference *
+ row_reference);
-gboolean gtranslator_msg_is_translated (GtranslatorMsg *msg);
+ gboolean gtranslator_msg_is_translated (GtranslatorMsg * msg);
-gboolean gtranslator_msg_is_fuzzy (GtranslatorMsg *msg);
+ gboolean gtranslator_msg_is_fuzzy (GtranslatorMsg * msg);
-void gtranslator_msg_set_fuzzy (GtranslatorMsg *msg,
- gboolean fuzzy);
+ void gtranslator_msg_set_fuzzy (GtranslatorMsg * msg, gboolean fuzzy);
-void gtranslator_msg_set_status (GtranslatorMsg *msg,
- GtranslatorMsgStatus status);
+ void gtranslator_msg_set_status (GtranslatorMsg * msg,
+ GtranslatorMsgStatus status);
-GtranslatorMsgStatus gtranslator_msg_get_status (GtranslatorMsg *msg);
+ GtranslatorMsgStatus gtranslator_msg_get_status (GtranslatorMsg * msg);
-const gchar *gtranslator_msg_get_msgid (GtranslatorMsg *msg);
+ const gchar *gtranslator_msg_get_msgid (GtranslatorMsg * msg);
-const gchar *gtranslator_msg_get_msgid_plural (GtranslatorMsg *msg);
+ const gchar *gtranslator_msg_get_msgid_plural (GtranslatorMsg * msg);
-const gchar *gtranslator_msg_get_msgstr (GtranslatorMsg *msg);
+ const gchar *gtranslator_msg_get_msgstr (GtranslatorMsg * msg);
-void gtranslator_msg_set_msgstr (GtranslatorMsg *msg,
- const gchar *msgstr);
+ void gtranslator_msg_set_msgstr (GtranslatorMsg * msg,
+ const gchar * msgstr);
-const gchar *gtranslator_msg_get_msgstr_plural (GtranslatorMsg *msg,
- gint index);
+ const gchar *gtranslator_msg_get_msgstr_plural (GtranslatorMsg * msg,
+ gint index);
-void gtranslator_msg_set_msgstr_plural (GtranslatorMsg *msg,
- gint index,
- const gchar *msgstr);
+ void gtranslator_msg_set_msgstr_plural (GtranslatorMsg * msg,
+ gint index,
+ const gchar * msgstr);
-const gchar *gtranslator_msg_get_comment (GtranslatorMsg *msg);
+ const gchar *gtranslator_msg_get_comment (GtranslatorMsg * msg);
-void gtranslator_msg_set_comment (GtranslatorMsg *msg,
- const gchar *comment);
+ void gtranslator_msg_set_comment (GtranslatorMsg * msg,
+ const gchar * comment);
-gint gtranslator_msg_get_po_position (GtranslatorMsg *msg);
+ gint gtranslator_msg_get_po_position (GtranslatorMsg * msg);
-void gtranslator_msg_set_po_position (GtranslatorMsg *msg,
- gint po_position);
+ void gtranslator_msg_set_po_position (GtranslatorMsg * msg,
+ gint po_position);
-const gchar *gtranslator_msg_get_extracted_comments
- (GtranslatorMsg *msg);
-
-const gchar *gtranslator_msg_get_filename (GtranslatorMsg *msg,
- gint i);
+ const gchar *gtranslator_msg_get_extracted_comments
+ (GtranslatorMsg * msg);
-gint *gtranslator_msg_get_file_line (GtranslatorMsg *msg,
- gint i);
+ const gchar *gtranslator_msg_get_filename (GtranslatorMsg * msg, gint i);
-const gchar *gtranslator_msg_get_msgctxt (GtranslatorMsg *msg);
+ gint *gtranslator_msg_get_file_line (GtranslatorMsg * msg, gint i);
-const gchar *gtranslator_msg_get_format (GtranslatorMsg *msg);
+ const gchar *gtranslator_msg_get_msgctxt (GtranslatorMsg * msg);
-gchar *gtranslator_msg_check (GtranslatorMsg *msg);
+ const gchar *gtranslator_msg_get_format (GtranslatorMsg * msg);
-G_END_DECLS
+ gchar *gtranslator_msg_check (GtranslatorMsg * msg);
+G_END_DECLS
#endif /* __MSG_H__ */
diff --git a/src/notebook.c b/src/notebook.c
index 643a44c..4fadd30 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -33,203 +33,189 @@
GTR_TYPE_NOTEBOOK, \
GtranslatorNotebookPrivate))
-G_DEFINE_TYPE(GtranslatorNotebook, gtranslator_notebook, GTK_TYPE_NOTEBOOK)
+G_DEFINE_TYPE (GtranslatorNotebook, gtranslator_notebook, GTK_TYPE_NOTEBOOK)
+ struct _GtranslatorNotebookPrivate
+ {
+ GList *pages;
-struct _GtranslatorNotebookPrivate
-{
- GList *pages;
-
-};
+ };
/* Signals */
-enum
-{
- TAB_CLOSE_REQUEST,
- LAST_SIGNAL
-};
+ enum
+ {
+ TAB_CLOSE_REQUEST,
+ LAST_SIGNAL
+ };
-static guint signals[LAST_SIGNAL] = { 0 };
+ static guint signals[LAST_SIGNAL] = { 0 };
static void
-tab_label_style_set_cb (GtkWidget *hbox,
- GtkStyle *previous_style,
- gpointer user_data)
+tab_label_style_set_cb (GtkWidget * hbox,
+ GtkStyle * previous_style, gpointer user_data)
{
- GtkWidget *button;
- gint h, w;
+ GtkWidget *button;
+ gint h, w;
- gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
- GTK_ICON_SIZE_MENU, &w, &h);
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
+ GTK_ICON_SIZE_MENU, &w, &h);
- button = g_object_get_data (G_OBJECT (hbox), "close-button");
- gtk_widget_set_size_request (button, w + 2, h + 2);
+ button = g_object_get_data (G_OBJECT (hbox), "close-button");
+ gtk_widget_set_size_request (button, w + 2, h + 2);
}
static void
-sync_name (GtranslatorPo *po,
- GParamSpec *pspec,
- GtkWidget *hbox)
+sync_name (GtranslatorPo * po, GParamSpec * pspec, GtkWidget * hbox)
{
- gchar *str;
- GtkWidget *label;
- GtkWidget *ebox;
- gchar *tooltip;
- GtranslatorTab *tab;
- GFile *location;
- gchar *path;
-
- label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
- ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label-ebox"));
- tab = gtranslator_tab_get_from_document (po);
-
- str = gtranslator_tab_get_name (tab);
- g_return_if_fail (str != NULL);
-
- gtk_label_set_text (GTK_LABEL (label), str);
-
- location = gtranslator_po_get_location (po);
- path = g_file_get_path (location);
- g_object_unref (location);
-
- tooltip = g_strdup_printf (_("<b>Path:</b> %s"),
- path);
-
- gtk_widget_set_tooltip_markup (ebox, tooltip);
-
- g_free (path);
- g_free (tooltip);
- g_free (str);
+ gchar *str;
+ GtkWidget *label;
+ GtkWidget *ebox;
+ gchar *tooltip;
+ GtranslatorTab *tab;
+ GFile *location;
+ gchar *path;
+
+ label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
+ ebox = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label-ebox"));
+ tab = gtranslator_tab_get_from_document (po);
+
+ str = gtranslator_tab_get_name (tab);
+ g_return_if_fail (str != NULL);
+
+ gtk_label_set_text (GTK_LABEL (label), str);
+
+ location = gtranslator_po_get_location (po);
+ path = g_file_get_path (location);
+ g_object_unref (location);
+
+ tooltip = g_strdup_printf (_("<b>Path:</b> %s"), path);
+
+ gtk_widget_set_tooltip_markup (ebox, tooltip);
+
+ g_free (path);
+ g_free (tooltip);
+ g_free (str);
}
static void
-close_button_clicked_cb (GtkWidget *widget,
- GtkWidget *tab)
+close_button_clicked_cb (GtkWidget * widget, GtkWidget * tab)
{
- GtranslatorNotebook *notebook;
+ GtranslatorNotebook *notebook;
- notebook = GTR_NOTEBOOK (gtk_widget_get_parent (tab));
- g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
+ notebook = GTR_NOTEBOOK (gtk_widget_get_parent (tab));
+ g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
}
static GtkWidget *
-build_tab_label (GtranslatorNotebook *nb,
- GtranslatorTab *tab)
+build_tab_label (GtranslatorNotebook * nb, GtranslatorTab * tab)
{
- GtkWidget *hbox, *label_hbox, *label_ebox;
- GtkWidget *label, *dummy_label;
- GtkWidget *close_button;
- GtkRcStyle *rcstyle;
- GtkWidget *image;
- GtkWidget *spinner;
- GtkWidget *icon;
-
- hbox = gtk_hbox_new (FALSE, 4);
-
- label_ebox = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (label_ebox), FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), label_ebox, TRUE, TRUE, 0);
-
- label_hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_add (GTK_CONTAINER (label_ebox), label_hbox);
-
- /* setup close button */
- close_button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (close_button),
- GTK_RELIEF_NONE);
- /* don't allow focus on the close button */
- gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
-
- /* make it as small as possible */
- rcstyle = gtk_rc_style_new ();
- rcstyle->xthickness = rcstyle->ythickness = 0;
- gtk_widget_modify_style (close_button, rcstyle);
- g_object_unref (G_OBJECT(rcstyle)),
-
- image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
- GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (close_button), image);
- gtk_box_pack_start (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
-
- gtk_widget_set_tooltip_text(close_button, _("Close document"));
-
- g_signal_connect (close_button,
- "clicked",
- G_CALLBACK (close_button_clicked_cb),
- tab);
-
- /* setup site icon, empty by default */
- icon = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (label_hbox), icon, FALSE, FALSE, 0);
-
- /* setup label */
- 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_box_pack_start (GTK_BOX (label_hbox), label, FALSE, FALSE, 0);
-
- dummy_label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (label_hbox), dummy_label, TRUE, TRUE, 0);
-
- /* Set minimal size */
- g_signal_connect(hbox, "style-set",
- G_CALLBACK (tab_label_style_set_cb), NULL);
-
- gtk_widget_show (hbox);
- gtk_widget_show (label_ebox);
- gtk_widget_show (label_hbox);
- gtk_widget_show (label);
- gtk_widget_show (dummy_label);
- gtk_widget_show (image);
- gtk_widget_show (close_button);
- gtk_widget_show (icon);
-
- g_object_set_data (G_OBJECT (hbox), "label", label);
- g_object_set_data (G_OBJECT (hbox), "label-ebox", label_ebox);
- g_object_set_data (G_OBJECT (hbox), "close-button", close_button);
- g_object_set_data (G_OBJECT (tab), "close-button", close_button);
-
- return hbox;
+ GtkWidget *hbox, *label_hbox, *label_ebox;
+ GtkWidget *label, *dummy_label;
+ GtkWidget *close_button;
+ GtkRcStyle *rcstyle;
+ GtkWidget *image;
+ GtkWidget *spinner;
+ GtkWidget *icon;
+
+ hbox = gtk_hbox_new (FALSE, 4);
+
+ label_ebox = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (label_ebox), FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), label_ebox, TRUE, TRUE, 0);
+
+ label_hbox = gtk_hbox_new (FALSE, 4);
+ gtk_container_add (GTK_CONTAINER (label_ebox), label_hbox);
+
+ /* setup close button */
+ close_button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
+ /* don't allow focus on the close button */
+ gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
+
+ /* make it as small as possible */
+ rcstyle = gtk_rc_style_new ();
+ rcstyle->xthickness = rcstyle->ythickness = 0;
+ gtk_widget_modify_style (close_button, rcstyle);
+ g_object_unref (G_OBJECT (rcstyle)),
+ image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_container_add (GTK_CONTAINER (close_button), image);
+ gtk_box_pack_start (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
+
+ gtk_widget_set_tooltip_text (close_button, _("Close document"));
+
+ g_signal_connect (close_button,
+ "clicked", G_CALLBACK (close_button_clicked_cb), tab);
+
+ /* setup site icon, empty by default */
+ icon = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (label_hbox), icon, FALSE, FALSE, 0);
+
+ /* setup label */
+ 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_box_pack_start (GTK_BOX (label_hbox), label, FALSE, FALSE, 0);
+
+ dummy_label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (label_hbox), dummy_label, TRUE, TRUE, 0);
+
+ /* Set minimal size */
+ g_signal_connect (hbox, "style-set",
+ G_CALLBACK (tab_label_style_set_cb), NULL);
+
+ gtk_widget_show (hbox);
+ gtk_widget_show (label_ebox);
+ gtk_widget_show (label_hbox);
+ gtk_widget_show (label);
+ gtk_widget_show (dummy_label);
+ gtk_widget_show (image);
+ gtk_widget_show (close_button);
+ gtk_widget_show (icon);
+
+ g_object_set_data (G_OBJECT (hbox), "label", label);
+ g_object_set_data (G_OBJECT (hbox), "label-ebox", label_ebox);
+ g_object_set_data (G_OBJECT (hbox), "close-button", close_button);
+ g_object_set_data (G_OBJECT (tab), "close-button", close_button);
+
+ return hbox;
}
static void
-gtranslator_notebook_init (GtranslatorNotebook *notebook)
+gtranslator_notebook_init (GtranslatorNotebook * notebook)
{
- notebook->priv = GTR_NOTEBOOK_GET_PRIVATE (notebook);
- GtranslatorNotebookPrivate *priv = notebook->priv;
-
- priv->pages = NULL;
+ notebook->priv = GTR_NOTEBOOK_GET_PRIVATE (notebook);
+ GtranslatorNotebookPrivate *priv = notebook->priv;
+
+ priv->pages = NULL;
}
static void
-gtranslator_notebook_finalize (GObject *object)
+gtranslator_notebook_finalize (GObject * object)
{
- GtranslatorNotebook *notebook = GTR_NOTEBOOK (object);
-
- if (notebook->priv->pages)
- g_list_free (notebook->priv->pages);
-
- G_OBJECT_CLASS (gtranslator_notebook_parent_class)->finalize (object);
+ GtranslatorNotebook *notebook = GTR_NOTEBOOK (object);
+
+ if (notebook->priv->pages)
+ g_list_free (notebook->priv->pages);
+
+ G_OBJECT_CLASS (gtranslator_notebook_parent_class)->finalize (object);
}
static void
-gtranslator_notebook_class_init (GtranslatorNotebookClass *klass)
+gtranslator_notebook_class_init (GtranslatorNotebookClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GtranslatorNotebookPrivate));
-
- object_class->finalize = gtranslator_notebook_finalize;
-
- signals[TAB_CLOSE_REQUEST] =
- g_signal_new ("tab-close-request",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorNotebookClass, tab_close_request),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GTR_TYPE_TAB);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorNotebookPrivate));
+
+ object_class->finalize = gtranslator_notebook_finalize;
+
+ signals[TAB_CLOSE_REQUEST] =
+ g_signal_new ("tab-close-request",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtranslatorNotebookClass,
+ tab_close_request), NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ GTR_TYPE_TAB);
}
/***************************** Public funcs ***********************************/
@@ -242,9 +228,9 @@ gtranslator_notebook_class_init (GtranslatorNotebookClass *klass)
* Returns: a new #GtranslatorNotebook object
*/
GtkWidget *
-gtranslator_notebook_new()
+gtranslator_notebook_new ()
{
- return GTK_WIDGET(g_object_new(GTR_TYPE_NOTEBOOK, NULL));
+ return GTK_WIDGET (g_object_new (GTR_TYPE_NOTEBOOK, NULL));
}
/**
@@ -255,36 +241,32 @@ gtranslator_notebook_new()
* Adds a new #GtranslatorTab to @notebook.
*/
void
-gtranslator_notebook_add_page (GtranslatorNotebook *notebook,
- GtranslatorTab *tab)
+gtranslator_notebook_add_page (GtranslatorNotebook * notebook,
+ GtranslatorTab * tab)
{
- GtranslatorNotebookPrivate *priv = notebook->priv;
- GtranslatorPo *po;
- GtkWidget *label;
-
- g_return_if_fail (GTR_IS_NOTEBOOK (notebook));
- g_return_if_fail (GTR_IS_TAB (tab));
-
- po = gtranslator_tab_get_po (tab);
-
- label = build_tab_label (notebook, tab);
-
- sync_name (po, NULL, label);
-
- g_signal_connect_object (po,
- "notify::state",
- G_CALLBACK (sync_name),
- label,
- 0);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
- GTK_WIDGET (tab), label);
- priv->pages = g_list_append (priv->pages, tab);
-
- if (g_list_length (notebook->priv->pages) == 1)
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
- else
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE);
+ GtranslatorNotebookPrivate *priv = notebook->priv;
+ GtranslatorPo *po;
+ GtkWidget *label;
+
+ g_return_if_fail (GTR_IS_NOTEBOOK (notebook));
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ po = gtranslator_tab_get_po (tab);
+
+ label = build_tab_label (notebook, tab);
+
+ sync_name (po, NULL, label);
+
+ g_signal_connect_object (po,
+ "notify::state", G_CALLBACK (sync_name), label, 0);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), GTK_WIDGET (tab), label);
+ priv->pages = g_list_append (priv->pages, tab);
+
+ if (g_list_length (notebook->priv->pages) == 1)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+ else
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE);
}
/**
@@ -295,23 +277,22 @@ gtranslator_notebook_add_page (GtranslatorNotebook *notebook,
* Removes a page from the notebook given its index in the notebook.
*/
void
-gtranslator_notebook_remove_page (GtranslatorNotebook *notebook,
+gtranslator_notebook_remove_page (GtranslatorNotebook * notebook,
gint page_num)
{
- GtkWidget *tab;
-
- g_return_if_fail (GTR_IS_NOTEBOOK (notebook));
-
- tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page_num);
-
- if (page_num != -1)
- gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page_num);
-
- notebook->priv->pages = g_list_remove (notebook->priv->pages,
- tab);
-
- if (g_list_length (notebook->priv->pages) == 1)
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+ GtkWidget *tab;
+
+ g_return_if_fail (GTR_IS_NOTEBOOK (notebook));
+
+ tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page_num);
+
+ if (page_num != -1)
+ gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page_num);
+
+ notebook->priv->pages = g_list_remove (notebook->priv->pages, tab);
+
+ if (g_list_length (notebook->priv->pages) == 1)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
}
/**
@@ -323,11 +304,11 @@ gtranslator_notebook_remove_page (GtranslatorNotebook *notebook,
* Returns: the selected page in the @notebook
*/
GtranslatorTab *
-gtranslator_notebook_get_page(GtranslatorNotebook *notebook)
+gtranslator_notebook_get_page (GtranslatorNotebook * notebook)
{
- gint num;
-
- num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
-
- return GTR_TAB(gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), num));
+ gint num;
+
+ num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+
+ return GTR_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), num));
}
diff --git a/src/notebook.h b/src/notebook.h
index 294a657..fdcc51a 100644
--- a/src/notebook.h
+++ b/src/notebook.h
@@ -26,7 +26,6 @@
#include "tab.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -36,54 +35,54 @@ G_BEGIN_DECLS
#define GTR_IS_NOTEBOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_NOTEBOOK))
#define GTR_IS_NOTEBOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_NOTEBOOK))
#define GTR_NOTEBOOK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_NOTEBOOK, GtranslatorNotebookClass))
-
/* Private structure type */
-typedef struct _GtranslatorNotebookPrivate GtranslatorNotebookPrivate;
+typedef struct _GtranslatorNotebookPrivate GtranslatorNotebookPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorNotebook GtranslatorNotebook;
+typedef struct _GtranslatorNotebook GtranslatorNotebook;
struct _GtranslatorNotebook
{
- GtkNotebook parent_instance;
-
- /*< private > */
- GtranslatorNotebookPrivate *priv;
+ GtkNotebook parent_instance;
+
+ /*< private > */
+ GtranslatorNotebookPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorNotebookClass GtranslatorNotebookClass;
+typedef struct _GtranslatorNotebookClass GtranslatorNotebookClass;
struct _GtranslatorNotebookClass
{
- GtkNotebookClass parent_class;
+ GtkNotebookClass parent_class;
- void (* tab_close_request)
- (GtranslatorNotebook *notebook,
- GtranslatorTab *tab);
+ void (*tab_close_request)
+ (GtranslatorNotebook * notebook, GtranslatorTab * tab);
};
/*
* Public methods
*/
-GType gtranslator_notebook_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_notebook_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_notebook_register_type (GTypeModule * module);
+ GType gtranslator_notebook_register_type (GTypeModule * module);
-GtkWidget *gtranslator_notebook_new (void);
+ GtkWidget *gtranslator_notebook_new (void);
-void gtranslator_notebook_add_page (GtranslatorNotebook *notebook,
- GtranslatorTab *pax);
+ void gtranslator_notebook_add_page (GtranslatorNotebook * notebook,
+ GtranslatorTab * pax);
-void gtranslator_notebook_remove_page (GtranslatorNotebook *notebook,
- gint i);
+ void gtranslator_notebook_remove_page (GtranslatorNotebook * notebook,
+ gint i);
-GtranslatorTab *gtranslator_notebook_get_page (GtranslatorNotebook *notebook);
+ GtranslatorTab *gtranslator_notebook_get_page (GtranslatorNotebook *
+ notebook);
G_END_DECLS
-
#endif /* __NOTEBOOK_H__ */
diff --git a/src/plugin-system/module.c b/src/plugin-system/module.c
index 7a0e19b..ef70bbd 100644
--- a/src/plugin-system/module.c
+++ b/src/plugin-system/module.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/* This is a modified version of ephy-module.c from Epiphany source code.
* Here the original copyright assignment:
*
@@ -43,216 +43,214 @@
typedef GType (*GtranslatorModuleRegisterFunc) (GTypeModule *);
-enum {
- PROP_0,
- PROP_MODULE_NAME,
- PROP_PATH
+enum
+{
+ PROP_0,
+ PROP_MODULE_NAME,
+ PROP_PATH
};
G_DEFINE_TYPE (GtranslatorModule, gtranslator_module, G_TYPE_TYPE_MODULE);
static gboolean
-gtranslator_module_load (GTypeModule *gmodule)
+gtranslator_module_load (GTypeModule * gmodule)
{
- GtranslatorModule *module = GTR_MODULE (gmodule);
- GtranslatorModuleRegisterFunc register_func;
- gchar *path;
+ GtranslatorModule *module = GTR_MODULE (gmodule);
+ GtranslatorModuleRegisterFunc register_func;
+ gchar *path;
- DEBUG_PRINT ( "Loading %s module from %s",
- module->module_name, module->path);
+ DEBUG_PRINT ("Loading %s module from %s",
+ module->module_name, module->path);
- path = g_module_build_path (module->path, module->module_name);
- g_return_val_if_fail (path != NULL, FALSE);
- DEBUG_PRINT ( "Module filename: %s", path);
+ path = g_module_build_path (module->path, module->module_name);
+ g_return_val_if_fail (path != NULL, FALSE);
+ DEBUG_PRINT ("Module filename: %s", path);
- module->library = g_module_open (path, 0);
- g_free (path);
+ module->library = g_module_open (path, 0);
+ g_free (path);
- if (module->library == NULL)
- {
- g_warning ("%s", g_module_error());
+ if (module->library == NULL)
+ {
+ g_warning ("%s", g_module_error ());
- return FALSE;
- }
+ return FALSE;
+ }
- /* extract symbols from the lib */
- if (!g_module_symbol (module->library, "register_gtranslator_plugin",
- (void *) ®ister_func))
- {
- g_warning ("%s", g_module_error());
- g_module_close (module->library);
+ /* extract symbols from the lib */
+ if (!g_module_symbol (module->library, "register_gtranslator_plugin",
+ (void *) ®ister_func))
+ {
+ g_warning ("%s", g_module_error ());
+ g_module_close (module->library);
- return FALSE;
- }
+ return FALSE;
+ }
- /* symbol can still be NULL even though g_module_symbol
- * returned TRUE */
- if (register_func == NULL)
- {
- g_warning ("Symbol 'register_gtranslator_plugin' should not be NULL");
- g_module_close (module->library);
+ /* symbol can still be NULL even though g_module_symbol
+ * returned TRUE */
+ if (register_func == NULL)
+ {
+ g_warning ("Symbol 'register_gtranslator_plugin' should not be NULL");
+ g_module_close (module->library);
- return FALSE;
- }
+ return FALSE;
+ }
- module->type = register_func (gmodule);
+ module->type = register_func (gmodule);
- if (module->type == 0)
- {
- g_warning ("Invalid gtranslator plugin contained by module %s", module->module_name);
- return FALSE;
- }
+ if (module->type == 0)
+ {
+ g_warning ("Invalid gtranslator plugin contained by module %s",
+ module->module_name);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static void
-gtranslator_module_unload (GTypeModule *gmodule)
+gtranslator_module_unload (GTypeModule * gmodule)
{
- GtranslatorModule *module = GTR_MODULE (gmodule);
+ GtranslatorModule *module = GTR_MODULE (gmodule);
- DEBUG_PRINT ( "Unloading %s", module->path);
+ DEBUG_PRINT ("Unloading %s", module->path);
- g_module_close (module->library);
+ g_module_close (module->library);
- module->library = NULL;
- module->type = 0;
+ module->library = NULL;
+ module->type = 0;
}
static void
gtranslator_module_class_real_garbage_collect (void)
{
- /* Do nothing */
+ /* Do nothing */
}
static void
-gtranslator_module_init (GtranslatorModule *module)
+gtranslator_module_init (GtranslatorModule * module)
{
- DEBUG_PRINT ( "GtranslatorModule %p initialising", module);
+ DEBUG_PRINT ("GtranslatorModule %p initialising", module);
}
static void
-gtranslator_module_finalize (GObject *object)
+gtranslator_module_finalize (GObject * object)
{
- GtranslatorModule *module = GTR_MODULE (object);
+ GtranslatorModule *module = GTR_MODULE (object);
- DEBUG_PRINT ( "GtranslatorModule %p finalising", module);
+ DEBUG_PRINT ("GtranslatorModule %p finalising", module);
- g_free (module->path);
- g_free (module->module_name);
+ g_free (module->path);
+ g_free (module->module_name);
- G_OBJECT_CLASS (gtranslator_module_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_module_parent_class)->finalize (object);
}
static void
-gtranslator_module_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gtranslator_module_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GtranslatorModule *module = GTR_MODULE (object);
-
- switch (prop_id)
- {
- case PROP_MODULE_NAME:
- g_value_set_string (value, module->module_name);
- break;
- case PROP_PATH:
- g_value_set_string (value, module->path);
- break;
- default:
- g_return_if_reached ();
- }
+ GtranslatorModule *module = GTR_MODULE (object);
+
+ switch (prop_id)
+ {
+ case PROP_MODULE_NAME:
+ g_value_set_string (value, module->module_name);
+ break;
+ case PROP_PATH:
+ g_value_set_string (value, module->path);
+ break;
+ default:
+ g_return_if_reached ();
+ }
}
static void
-gtranslator_module_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gtranslator_module_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GtranslatorModule *module = GTR_MODULE (object);
-
- switch (prop_id)
- {
- case PROP_MODULE_NAME:
- module->module_name = g_value_dup_string (value);
- g_type_module_set_name (G_TYPE_MODULE (object),
- module->module_name);
- break;
- case PROP_PATH:
- module->path = g_value_dup_string (value);
- break;
- default:
- g_return_if_reached ();
- }
+ GtranslatorModule *module = GTR_MODULE (object);
+
+ switch (prop_id)
+ {
+ case PROP_MODULE_NAME:
+ module->module_name = g_value_dup_string (value);
+ g_type_module_set_name (G_TYPE_MODULE (object), module->module_name);
+ break;
+ case PROP_PATH:
+ module->path = g_value_dup_string (value);
+ break;
+ default:
+ g_return_if_reached ();
+ }
}
static void
-gtranslator_module_class_init (GtranslatorModuleClass *klass)
+gtranslator_module_class_init (GtranslatorModuleClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
-
- object_class->set_property = gtranslator_module_set_property;
- object_class->get_property = gtranslator_module_get_property;
- object_class->finalize = gtranslator_module_finalize;
-
- module_class->load = gtranslator_module_load;
- module_class->unload = gtranslator_module_unload;
-
- klass->garbage_collect = gtranslator_module_class_real_garbage_collect;
-
- g_object_class_install_property (object_class,
- PROP_MODULE_NAME,
- g_param_spec_string ("module-name",
- "Module Name",
- "The module to load for this plugin",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_PATH,
- g_param_spec_string ("path",
- "Path",
- "The path to use when loading this module",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
+
+ object_class->set_property = gtranslator_module_set_property;
+ object_class->get_property = gtranslator_module_get_property;
+ object_class->finalize = gtranslator_module_finalize;
+
+ module_class->load = gtranslator_module_load;
+ module_class->unload = gtranslator_module_unload;
+
+ klass->garbage_collect = gtranslator_module_class_real_garbage_collect;
+
+ g_object_class_install_property (object_class,
+ PROP_MODULE_NAME,
+ g_param_spec_string ("module-name",
+ "Module Name",
+ "The module to load for this plugin",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
+ PROP_PATH,
+ g_param_spec_string ("path",
+ "Path",
+ "The path to use when loading this module",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
void
-gtranslator_module_class_garbage_collect (GtranslatorModuleClass *klass)
+gtranslator_module_class_garbage_collect (GtranslatorModuleClass * klass)
{
- g_return_if_fail (GTR_IS_MODULE_CLASS (klass));
+ g_return_if_fail (GTR_IS_MODULE_CLASS (klass));
- GTR_MODULE_CLASS (klass)->garbage_collect ();
+ GTR_MODULE_CLASS (klass)->garbage_collect ();
}
GObject *
-gtranslator_module_new_object (GtranslatorModule *module)
+gtranslator_module_new_object (GtranslatorModule * module)
{
- g_return_val_if_fail (module->type != 0, NULL);
+ g_return_val_if_fail (module->type != 0, NULL);
- DEBUG_PRINT ( "Creating object of type %s",
- g_type_name (module->type));
+ DEBUG_PRINT ("Creating object of type %s", g_type_name (module->type));
- return g_object_new (module->type, NULL);
+ return g_object_new (module->type, NULL);
}
const gchar *
-gtranslator_module_get_path (GtranslatorModule *module)
+gtranslator_module_get_path (GtranslatorModule * module)
{
- g_return_val_if_fail (GTR_IS_MODULE (module), NULL);
+ g_return_val_if_fail (GTR_IS_MODULE (module), NULL);
- return module->path;
+ return module->path;
}
const gchar *
-gtranslator_module_get_module_name (GtranslatorModule *module)
+gtranslator_module_get_module_name (GtranslatorModule * module)
{
- g_return_val_if_fail (GTR_IS_MODULE (module), NULL);
+ g_return_val_if_fail (GTR_IS_MODULE (module), NULL);
- return module->module_name;
+ return module->module_name;
}
diff --git a/src/plugin-system/module.h b/src/plugin-system/module.h
index 40fee11..543686f 100644
--- a/src/plugin-system/module.h
+++ b/src/plugin-system/module.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/* This is a modified version of module.h from Epiphany source code.
* Here the original copyright assignment:
*
@@ -35,7 +35,7 @@
*
* $Id: module.h 6263 2008-05-05 10:52:10Z sfre $
*/
-
+
#ifndef __GTR_MODULE_H__
#define __GTR_MODULE_H__
@@ -43,48 +43,48 @@
#include <gmodule.h>
G_BEGIN_DECLS
-
#define GTR_TYPE_MODULE (gtranslator_module_get_type ())
#define GTR_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_MODULE, GtranslatorModule))
#define GTR_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTR_TYPE_MODULE, GtranslatorModuleClass))
#define GTR_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_MODULE))
#define GTR_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_MODULE))
#define GTR_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_MODULE, GtranslatorModuleClass))
-
typedef struct _GtranslatorModule GtranslatorModule;
struct _GtranslatorModule
{
- GTypeModule parent;
+ GTypeModule parent;
- GModule *library;
+ GModule *library;
- gchar *path;
- gchar *module_name;
- GType type;
+ gchar *path;
+ gchar *module_name;
+ GType type;
};
typedef struct _GtranslatorModuleClass GtranslatorModuleClass;
struct _GtranslatorModuleClass
{
- GTypeModuleClass parent_class;
+ GTypeModuleClass parent_class;
- /* Virtual class methods */
- void (* garbage_collect) ();
+ /* Virtual class methods */
+ void (*garbage_collect) ();
};
-GType gtranslator_module_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_module_get_type (void)
+ G_GNUC_CONST;
-const gchar *gtranslator_module_get_path (GtranslatorModule *module);
+ const gchar *gtranslator_module_get_path (GtranslatorModule * module);
-const gchar *gtranslator_module_get_module_name (GtranslatorModule *module);
+ const gchar *gtranslator_module_get_module_name (GtranslatorModule *
+ module);
-GObject *gtranslator_module_new_object (GtranslatorModule *module);
+ GObject *gtranslator_module_new_object (GtranslatorModule * module);
-void gtranslator_module_class_garbage_collect
- (GtranslatorModuleClass *klass);
+ void gtranslator_module_class_garbage_collect
+ (GtranslatorModuleClass * klass);
G_END_DECLS
-
#endif
diff --git a/src/plugin-system/plugin-info-priv.h b/src/plugin-system/plugin-info-priv.h
index cb19837..4be1b7a 100644
--- a/src/plugin-system/plugin-info-priv.h
+++ b/src/plugin-system/plugin-info-priv.h
@@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2002-2007. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -37,36 +37,36 @@
struct _GtranslatorPluginInfo
{
- gint refcount;
+ gint refcount;
- gchar *file;
+ gchar *file;
- gchar *module_name;
- GType module_type;
- GtranslatorModule *module;
- gchar **dependencies;
+ gchar *module_name;
+ GType module_type;
+ GtranslatorModule *module;
+ gchar **dependencies;
- gchar *name;
- gchar *desc;
- gchar *icon_name;
- gchar **authors;
- gchar *copyright;
- gchar *website;
- gchar *license;
+ gchar *name;
+ gchar *desc;
+ gchar *icon_name;
+ gchar **authors;
+ gchar *copyright;
+ gchar *website;
+ gchar *license;
- GtranslatorPlugin *plugin;
+ GtranslatorPlugin *plugin;
- gint active : 1;
+ gint active:1;
- /* A plugin is unavailable if it is not possible to activate it
- due to an error loading the plugin module (e.g. for Python plugins
- when the interpreter has not been correctly initializated) */
- gint available : 1;
+ /* A plugin is unavailable if it is not possible to activate it
+ due to an error loading the plugin module (e.g. for Python plugins
+ when the interpreter has not been correctly initializated) */
+ gint available:1;
};
-GtranslatorPluginInfo *_gtranslator_plugin_info_new (const gchar *file);
-void _gtranslator_plugin_info_ref (GtranslatorPluginInfo *info);
-void _gtranslator_plugin_info_unref (GtranslatorPluginInfo *info);
+GtranslatorPluginInfo *_gtranslator_plugin_info_new (const gchar * file);
+void _gtranslator_plugin_info_ref (GtranslatorPluginInfo * info);
+void _gtranslator_plugin_info_unref (GtranslatorPluginInfo * info);
#endif /* __GTR_PLUGIN_INFO_PRIV_H__ */
diff --git a/src/plugin-system/plugin-info.c b/src/plugin-system/plugin-info.c
index 1cba885..cd1aa0d 100644
--- a/src/plugin-system/plugin-info.c
+++ b/src/plugin-system/plugin-info.c
@@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2002-2007. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -47,45 +47,45 @@
#endif
void
-_gtranslator_plugin_info_ref (GtranslatorPluginInfo *info)
+_gtranslator_plugin_info_ref (GtranslatorPluginInfo * info)
{
- g_atomic_int_inc (&info->refcount);
+ g_atomic_int_inc (&info->refcount);
}
static GtranslatorPluginInfo *
-gtranslator_plugin_info_copy (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_copy (GtranslatorPluginInfo * info)
{
- _gtranslator_plugin_info_ref (info);
- return info;
+ _gtranslator_plugin_info_ref (info);
+ return info;
}
void
-_gtranslator_plugin_info_unref (GtranslatorPluginInfo *info)
+_gtranslator_plugin_info_unref (GtranslatorPluginInfo * info)
{
- if (!g_atomic_int_dec_and_test (&info->refcount))
- return;
-
- if (info->plugin != NULL)
- {
- DEBUG_PRINT ( "Unref plugin %s", info->name);
-
- g_object_unref (info->plugin);
-
- /* info->module must not be unref since it is not possible to finalize
- * a type module */
- }
-
- g_free (info->file);
- g_free (info->module_name);
- g_strfreev (info->dependencies);
- g_free (info->name);
- g_free (info->desc);
- g_free (info->icon_name);
- g_free (info->website);
- g_free (info->copyright);
- g_strfreev (info->authors);
-
- g_free (info);
+ if (!g_atomic_int_dec_and_test (&info->refcount))
+ return;
+
+ if (info->plugin != NULL)
+ {
+ DEBUG_PRINT ("Unref plugin %s", info->name);
+
+ g_object_unref (info->plugin);
+
+ /* info->module must not be unref since it is not possible to finalize
+ * a type module */
+ }
+
+ g_free (info->file);
+ g_free (info->module_name);
+ g_strfreev (info->dependencies);
+ g_free (info->name);
+ g_free (info->desc);
+ g_free (info->icon_name);
+ g_free (info->website);
+ g_free (info->copyright);
+ g_strfreev (info->authors);
+
+ g_free (info);
}
/**
@@ -99,16 +99,17 @@ _gtranslator_plugin_info_unref (GtranslatorPluginInfo *info)
GType
gtranslator_plugin_info_get_type (void)
{
- static GType the_type = 0;
+ static GType the_type = 0;
- if (G_UNLIKELY (!the_type))
- the_type = g_boxed_type_register_static (
- "GtranslatorPluginInfo",
- (GBoxedCopyFunc) gtranslator_plugin_info_copy,
- (GBoxedFreeFunc) _gtranslator_plugin_info_unref);
+ if (G_UNLIKELY (!the_type))
+ the_type = g_boxed_type_register_static ("GtranslatorPluginInfo",
+ (GBoxedCopyFunc)
+ gtranslator_plugin_info_copy,
+ (GBoxedFreeFunc)
+ _gtranslator_plugin_info_unref);
- return the_type;
-}
+ return the_type;
+}
/**
* gtranslator_plugin_info_new:
@@ -119,277 +120,253 @@ gtranslator_plugin_info_get_type (void)
* Return value: a newly created #GtranslatorPluginInfo.
*/
GtranslatorPluginInfo *
-_gtranslator_plugin_info_new (const gchar *file)
+_gtranslator_plugin_info_new (const gchar * file)
{
- GtranslatorPluginInfo *info;
- GKeyFile *plugin_file = NULL;
- gchar *str;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- DEBUG_PRINT ( "Loading plugin: %s", file);
-
- info = g_new0 (GtranslatorPluginInfo, 1);
- info->refcount = 1;
- info->file = g_strdup (file);
-
- plugin_file = g_key_file_new ();
- if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL))
- {
- g_warning ("Bad plugin file: %s", file);
- goto error;
- }
-
- if (!g_key_file_has_key (plugin_file,
- "Gtranslator Plugin",
- "IAge",
- NULL))
- {
- DEBUG_PRINT (
- "IAge key does not exist in file: %s", file);
- goto error;
- }
-
- /* Check IAge=2 */
- if (g_key_file_get_integer (plugin_file,
- "Gtranslator Plugin",
- "IAge",
- NULL) != 2)
- {
- DEBUG_PRINT (
- "Wrong IAge in file: %s", file);
- goto error;
- }
-
- /* Get module name */
- str = g_key_file_get_string (plugin_file,
- "Gtranslator Plugin",
- "Module",
- NULL);
-
- if ((str != NULL) && (*str != '\0'))
- {
- info->module_name = str;
- }
- else
- {
- g_warning ("Could not find 'Module' in %s", file);
- goto error;
- }
-
- /* Get the dependency list */
- info->dependencies = g_key_file_get_string_list (plugin_file,
- "Gtranslator Plugin",
- "Depends",
- NULL,
- NULL);
- if (info->dependencies == NULL)
- {
- DEBUG_PRINT ( "Could not find 'Depends' in %s", file);
- info->dependencies = g_new0 (gchar *, 1);
- }
-
- /* Get the loader for this plugin */
- str = g_key_file_get_string (plugin_file,
- "Gtranslator Plugin",
- "Loader",
- NULL);
- if (str && strcmp(str, "python") == 0)
- {
+ GtranslatorPluginInfo *info;
+ GKeyFile *plugin_file = NULL;
+ gchar *str;
+
+ g_return_val_if_fail (file != NULL, NULL);
+
+ DEBUG_PRINT ("Loading plugin: %s", file);
+
+ info = g_new0 (GtranslatorPluginInfo, 1);
+ info->refcount = 1;
+ info->file = g_strdup (file);
+
+ plugin_file = g_key_file_new ();
+ if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL))
+ {
+ g_warning ("Bad plugin file: %s", file);
+ goto error;
+ }
+
+ if (!g_key_file_has_key (plugin_file, "Gtranslator Plugin", "IAge", NULL))
+ {
+ DEBUG_PRINT ("IAge key does not exist in file: %s", file);
+ goto error;
+ }
+
+ /* Check IAge=2 */
+ if (g_key_file_get_integer (plugin_file,
+ "Gtranslator Plugin", "IAge", NULL) != 2)
+ {
+ DEBUG_PRINT ("Wrong IAge in file: %s", file);
+ goto error;
+ }
+
+ /* Get module name */
+ str = g_key_file_get_string (plugin_file,
+ "Gtranslator Plugin", "Module", NULL);
+
+ if ((str != NULL) && (*str != '\0'))
+ {
+ info->module_name = str;
+ }
+ else
+ {
+ g_warning ("Could not find 'Module' in %s", file);
+ goto error;
+ }
+
+ /* Get the dependency list */
+ info->dependencies = g_key_file_get_string_list (plugin_file,
+ "Gtranslator Plugin",
+ "Depends", NULL, NULL);
+ if (info->dependencies == NULL)
+ {
+ DEBUG_PRINT ("Could not find 'Depends' in %s", file);
+ info->dependencies = g_new0 (gchar *, 1);
+ }
+
+ /* Get the loader for this plugin */
+ str = g_key_file_get_string (plugin_file,
+ "Gtranslator Plugin", "Loader", NULL);
+ if (str && strcmp (str, "python") == 0)
+ {
#ifndef ENABLE_PYTHON
- g_warning ("Cannot load Python plugin '%s' since gtranslator was not "
- "compiled with Python support.", file);
- goto error;
+ g_warning ("Cannot load Python plugin '%s' since gtranslator was not "
+ "compiled with Python support.", file);
+ goto error;
#else
- info->module_type = GTR_TYPE_PYTHON_MODULE;
+ info->module_type = GTR_TYPE_PYTHON_MODULE;
#endif
- }
- else
- {
- info->module_type = GTR_TYPE_MODULE;
- }
- g_free (str);
-
- /* Get Name */
- str = g_key_file_get_locale_string (plugin_file,
- "Gtranslator Plugin",
- "Name",
- NULL, NULL);
- if (str)
- info->name = str;
- else
- {
- g_warning ("Could not find 'Name' in %s", file);
- goto error;
- }
-
- /* Get Description */
- str = g_key_file_get_locale_string (plugin_file,
- "Gtranslator Plugin",
- "Description",
- NULL, NULL);
- if (str)
- info->desc = str;
- else
- DEBUG_PRINT ( "Could not find 'Description' in %s", file);
-
- /* Get Icon */
- str = g_key_file_get_locale_string (plugin_file,
- "Gtranslator Plugin",
- "Icon",
- NULL, NULL);
- if (str)
- info->icon_name = str;
- else
- DEBUG_PRINT ( "Could not find 'Icon' in %s, using 'plugin'", file);
-
-
- /* Get Authors */
- info->authors = g_key_file_get_string_list (plugin_file,
- "Gtranslator Plugin",
- "Authors",
- NULL,
- NULL);
- if (info->authors == NULL)
- DEBUG_PRINT ( "Could not find 'Authors' in %s", file);
-
-
- /* Get Copyright */
- str = g_key_file_get_string (plugin_file,
- "Gtranslator Plugin",
- "Copyright",
- NULL);
- if (str)
- info->copyright = str;
- else
- DEBUG_PRINT ( "Could not find 'Copyright' in %s", file);
-
- /* Get License */
- str = g_key_file_get_string (plugin_file,
- "Gtranslator Plugin",
- "License",
- NULL);
- if (str)
- info->license = str;
- else
- DEBUG_PRINT ( "Could not find 'Copyright' in %s", file);
-
- /* Get Website */
- str = g_key_file_get_string (plugin_file,
- "Gtranslator Plugin",
- "Website",
- NULL);
- if (str)
- info->website = str;
- else
- DEBUG_PRINT ( "Could not find 'Website' in %s", file);
-
- g_key_file_free (plugin_file);
-
- /* If we know nothing about the availability of the plugin,
- set it as available */
- info->available = TRUE;
-
- return info;
+ }
+ else
+ {
+ info->module_type = GTR_TYPE_MODULE;
+ }
+ g_free (str);
+
+ /* Get Name */
+ str = g_key_file_get_locale_string (plugin_file,
+ "Gtranslator Plugin",
+ "Name", NULL, NULL);
+ if (str)
+ info->name = str;
+ else
+ {
+ g_warning ("Could not find 'Name' in %s", file);
+ goto error;
+ }
+
+ /* Get Description */
+ str = g_key_file_get_locale_string (plugin_file,
+ "Gtranslator Plugin",
+ "Description", NULL, NULL);
+ if (str)
+ info->desc = str;
+ else
+ DEBUG_PRINT ("Could not find 'Description' in %s", file);
+
+ /* Get Icon */
+ str = g_key_file_get_locale_string (plugin_file,
+ "Gtranslator Plugin",
+ "Icon", NULL, NULL);
+ if (str)
+ info->icon_name = str;
+ else
+ DEBUG_PRINT ("Could not find 'Icon' in %s, using 'plugin'", file);
+
+
+ /* Get Authors */
+ info->authors = g_key_file_get_string_list (plugin_file,
+ "Gtranslator Plugin",
+ "Authors", NULL, NULL);
+ if (info->authors == NULL)
+ DEBUG_PRINT ("Could not find 'Authors' in %s", file);
+
+
+ /* Get Copyright */
+ str = g_key_file_get_string (plugin_file,
+ "Gtranslator Plugin", "Copyright", NULL);
+ if (str)
+ info->copyright = str;
+ else
+ DEBUG_PRINT ("Could not find 'Copyright' in %s", file);
+
+ /* Get License */
+ str = g_key_file_get_string (plugin_file,
+ "Gtranslator Plugin", "License", NULL);
+ if (str)
+ info->license = str;
+ else
+ DEBUG_PRINT ("Could not find 'Copyright' in %s", file);
+
+ /* Get Website */
+ str = g_key_file_get_string (plugin_file,
+ "Gtranslator Plugin", "Website", NULL);
+ if (str)
+ info->website = str;
+ else
+ DEBUG_PRINT ("Could not find 'Website' in %s", file);
+
+ g_key_file_free (plugin_file);
+
+ /* If we know nothing about the availability of the plugin,
+ set it as available */
+ info->available = TRUE;
+
+ return info;
error:
- g_free (info->file);
- g_free (info->module_name);
- g_free (info->name);
- g_free (info);
- g_key_file_free (plugin_file);
+ g_free (info->file);
+ g_free (info->module_name);
+ g_free (info->name);
+ g_free (info);
+ g_key_file_free (plugin_file);
- return NULL;
+ return NULL;
}
gboolean
-gtranslator_plugin_info_is_active (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_is_active (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- return info->available && info->active;
+ return info->available && info->active;
}
gboolean
-gtranslator_plugin_info_is_available (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_is_available (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- return info->available != FALSE;
+ return info->available != FALSE;
}
gboolean
-gtranslator_plugin_info_is_configurable (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_is_configurable (GtranslatorPluginInfo * info)
{
- DEBUG_PRINT ( "Is '%s' configurable?", info->name);
+ DEBUG_PRINT ("Is '%s' configurable?", info->name);
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- if (info->plugin == NULL || !info->active || !info->available)
- return FALSE;
+ if (info->plugin == NULL || !info->active || !info->available)
+ return FALSE;
- return gtranslator_plugin_is_configurable (info->plugin);
+ return gtranslator_plugin_is_configurable (info->plugin);
}
const gchar *
-gtranslator_plugin_info_get_name (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_name (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->name;
+ return info->name;
}
const gchar *
-gtranslator_plugin_info_get_description (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_description (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->desc;
+ return info->desc;
}
const gchar *
-gtranslator_plugin_info_get_icon_name (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_icon_name (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, NULL);
-
- /* use the plugin icon as a default if the plugin does not
- have its own */
- if (info->icon_name != NULL &&
- gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
- info->icon_name))
- return info->icon_name;
- else
- return "gtranslator-plugin";
+ g_return_val_if_fail (info != NULL, NULL);
+
+ /* use the plugin icon as a default if the plugin does not
+ have its own */
+ if (info->icon_name != NULL &&
+ gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
+ info->icon_name))
+ return info->icon_name;
+ else
+ return "gtranslator-plugin";
}
const gchar **
-gtranslator_plugin_info_get_authors (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_authors (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, (const gchar **)NULL);
+ g_return_val_if_fail (info != NULL, (const gchar **) NULL);
- return (const gchar **) info->authors;
+ return (const gchar **) info->authors;
}
const gchar *
-gtranslator_plugin_info_get_website (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_website (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->website;
+ return info->website;
}
const gchar *
-gtranslator_plugin_info_get_copyright (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_copyright (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->copyright;
+ return info->copyright;
}
const gchar *
-gtranslator_plugin_info_get_license (GtranslatorPluginInfo *info)
+gtranslator_plugin_info_get_license (GtranslatorPluginInfo * info)
{
- g_return_val_if_fail (info != NULL, NULL);
-
- return info->license;
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->license;
}
diff --git a/src/plugin-system/plugin-info.h b/src/plugin-system/plugin-info.h
index 2be6b3b..c7015dc 100644
--- a/src/plugin-system/plugin-info.h
+++ b/src/plugin-system/plugin-info.h
@@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2002-2007. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -36,27 +36,36 @@
#include "module.h"
G_BEGIN_DECLS
-
#define GTR_TYPE_PLUGIN_INFO (gtranslator_plugin_info_get_type ())
#define GTR_PLUGIN_INFO(obj) ((GtranslatorPluginInfo *) (obj))
+typedef struct _GtranslatorPluginInfo GtranslatorPluginInfo;
-typedef struct _GtranslatorPluginInfo GtranslatorPluginInfo;
-
-GType gtranslator_plugin_info_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_plugin_info_get_type (void)
+ G_GNUC_CONST;
-gboolean gtranslator_plugin_info_is_active (GtranslatorPluginInfo *info);
-gboolean gtranslator_plugin_info_is_available (GtranslatorPluginInfo *info);
-gboolean gtranslator_plugin_info_is_configurable (GtranslatorPluginInfo *info);
+ gboolean gtranslator_plugin_info_is_active (GtranslatorPluginInfo *
+ info);
+ gboolean gtranslator_plugin_info_is_available (GtranslatorPluginInfo *
+ info);
+ gboolean gtranslator_plugin_info_is_configurable (GtranslatorPluginInfo *
+ info);
-const gchar *gtranslator_plugin_info_get_name (GtranslatorPluginInfo *info);
-const gchar *gtranslator_plugin_info_get_description (GtranslatorPluginInfo *info);
-const gchar *gtranslator_plugin_info_get_icon_name (GtranslatorPluginInfo *info);
-const gchar **gtranslator_plugin_info_get_authors (GtranslatorPluginInfo *info);
-const gchar *gtranslator_plugin_info_get_website (GtranslatorPluginInfo *info);
-const gchar *gtranslator_plugin_info_get_copyright (GtranslatorPluginInfo *info);
-const gchar *gtranslator_plugin_info_get_license (GtranslatorPluginInfo *info);
+ const gchar *gtranslator_plugin_info_get_name (GtranslatorPluginInfo *
+ info);
+ const gchar
+ *gtranslator_plugin_info_get_description (GtranslatorPluginInfo *
+ info);
+ const gchar *gtranslator_plugin_info_get_icon_name (GtranslatorPluginInfo
+ * info);
+ const gchar **gtranslator_plugin_info_get_authors (GtranslatorPluginInfo
+ * info);
+ const gchar *gtranslator_plugin_info_get_website (GtranslatorPluginInfo *
+ info);
+ const gchar *gtranslator_plugin_info_get_copyright (GtranslatorPluginInfo
+ * info);
+ const gchar *gtranslator_plugin_info_get_license (GtranslatorPluginInfo *
+ info);
G_END_DECLS
-
#endif /* __GTR_PLUGIN_INFO_H__ */
-
diff --git a/src/plugin-system/plugin-manager.c b/src/plugin-system/plugin-manager.c
index dda89ad..635022f 100644
--- a/src/plugin-system/plugin-manager.c
+++ b/src/plugin-system/plugin-manager.c
@@ -45,10 +45,10 @@
enum
{
- ACTIVE_COLUMN,
- AVAILABLE_COLUMN,
- INFO_COLUMN,
- N_COLUMNS
+ ACTIVE_COLUMN,
+ AVAILABLE_COLUMN,
+ INFO_COLUMN,
+ N_COLUMNS
};
#define PLUGIN_MANAGER_NAME_TITLE _("Plugin")
@@ -58,832 +58,808 @@ enum
struct _GtranslatorPluginManagerPrivate
{
- GtkWidget *tree;
+ GtkWidget *tree;
- GtkWidget *about_button;
- GtkWidget *configure_button;
+ GtkWidget *about_button;
+ GtkWidget *configure_button;
- GtranslatorPluginsEngine *engine;
+ GtranslatorPluginsEngine *engine;
- GtkWidget *about;
-
- GtkWidget *popup_menu;
-};
-
-G_DEFINE_TYPE(GtranslatorPluginManager, gtranslator_plugin_manager, GTK_TYPE_VBOX)
+ GtkWidget *about;
-static GtranslatorPluginInfo *plugin_manager_get_selected_plugin (GtranslatorPluginManager *pm);
-static void plugin_manager_toggle_active (GtranslatorPluginManager *pm, GtkTreeIter *iter, GtkTreeModel *model);
-static void gtranslator_plugin_manager_finalize (GObject *object);
+ GtkWidget *popup_menu;
+};
-static void
-gtranslator_plugin_manager_class_init (GtranslatorPluginManagerClass *klass)
+G_DEFINE_TYPE (GtranslatorPluginManager, gtranslator_plugin_manager,
+ GTK_TYPE_VBOX)
+ static GtranslatorPluginInfo
+ *plugin_manager_get_selected_plugin (GtranslatorPluginManager * pm);
+ static void plugin_manager_toggle_active (GtranslatorPluginManager * pm,
+ GtkTreeIter * iter,
+ GtkTreeModel * model);
+ static void gtranslator_plugin_manager_finalize (GObject * object);
+
+ static void
+ gtranslator_plugin_manager_class_init (GtranslatorPluginManagerClass *
+ klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gtranslator_plugin_manager_finalize;
+ object_class->finalize = gtranslator_plugin_manager_finalize;
- g_type_class_add_private (object_class, sizeof (GtranslatorPluginManagerPrivate));
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorPluginManagerPrivate));
}
static void
-about_button_cb (GtkWidget *button,
- GtranslatorPluginManager *pm)
+about_button_cb (GtkWidget * button, GtranslatorPluginManager * pm)
{
- GtranslatorPluginInfo *info;
-
- //gtranslator_debug (DEBUG_PLUGINS);
-
- info = plugin_manager_get_selected_plugin (pm);
-
- g_return_if_fail (info != NULL);
-
- /* if there is another about dialog already open destroy it */
- if (pm->priv->about)
- gtk_widget_destroy (pm->priv->about);
-
- pm->priv->about = g_object_new (GTK_TYPE_ABOUT_DIALOG,
- "program-name", gtranslator_plugin_info_get_name (info),
- "copyright", gtranslator_plugin_info_get_copyright (info),
- "authors", gtranslator_plugin_info_get_authors (info),
- "license", gtranslator_plugin_info_get_license (info),
- "comments", gtranslator_plugin_info_get_description (info),
- "website", gtranslator_plugin_info_get_website (info),
- "logo-icon-name", gtranslator_plugin_info_get_icon_name (info),
- NULL);
-
- gtk_window_set_destroy_with_parent (GTK_WINDOW (pm->priv->about),
- TRUE);
-
- g_signal_connect (pm->priv->about,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- g_signal_connect (pm->priv->about,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &pm->priv->about);
-
- gtk_window_set_transient_for (GTK_WINDOW (pm->priv->about),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(pm))));
- gtk_widget_show (pm->priv->about);
+ GtranslatorPluginInfo *info;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ info = plugin_manager_get_selected_plugin (pm);
+
+ g_return_if_fail (info != NULL);
+
+ /* if there is another about dialog already open destroy it */
+ if (pm->priv->about)
+ gtk_widget_destroy (pm->priv->about);
+
+ pm->priv->about = g_object_new (GTK_TYPE_ABOUT_DIALOG,
+ "program-name",
+ gtranslator_plugin_info_get_name (info),
+ "copyright",
+ gtranslator_plugin_info_get_copyright
+ (info), "authors",
+ gtranslator_plugin_info_get_authors (info),
+ "license",
+ gtranslator_plugin_info_get_license (info),
+ "comments",
+ gtranslator_plugin_info_get_description
+ (info), "website",
+ gtranslator_plugin_info_get_website (info),
+ "logo-icon-name",
+ gtranslator_plugin_info_get_icon_name
+ (info), NULL);
+
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (pm->priv->about), TRUE);
+
+ g_signal_connect (pm->priv->about,
+ "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (pm->priv->about,
+ "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &pm->priv->about);
+
+ gtk_window_set_transient_for (GTK_WINDOW (pm->priv->about),
+ GTK_WINDOW (gtk_widget_get_toplevel
+ (GTK_WIDGET (pm))));
+ gtk_widget_show (pm->priv->about);
}
static void
-configure_button_cb (GtkWidget *button,
- GtranslatorPluginManager *pm)
+configure_button_cb (GtkWidget * button, GtranslatorPluginManager * pm)
{
- GtranslatorPluginInfo *info;
- GtkWindow *toplevel;
+ GtranslatorPluginInfo *info;
+ GtkWindow *toplevel;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- info = plugin_manager_get_selected_plugin (pm);
+ info = plugin_manager_get_selected_plugin (pm);
- g_return_if_fail (info != NULL);
+ g_return_if_fail (info != NULL);
- DEBUG_PRINT ( "Configuring: %s\n",
- gtranslator_plugin_info_get_name (info));
+ DEBUG_PRINT ("Configuring: %s\n", gtranslator_plugin_info_get_name (info));
- toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(pm)));
+ toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (pm)));
- gtranslator_plugins_engine_configure_plugin (pm->priv->engine,
+ gtranslator_plugins_engine_configure_plugin (pm->priv->engine,
info, toplevel);
- DEBUG_PRINT ( "Done");
+ DEBUG_PRINT ("Done");
}
static void
-plugin_manager_view_info_cell_cb (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+plugin_manager_view_info_cell_cb (GtkTreeViewColumn * tree_column,
+ GtkCellRenderer * cell,
+ GtkTreeModel * tree_model,
+ GtkTreeIter * iter, gpointer data)
{
- GtranslatorPluginInfo *info;
- gchar *text;
-
- g_return_if_fail (tree_model != NULL);
- g_return_if_fail (tree_column != NULL);
-
- gtk_tree_model_get (tree_model, iter, INFO_COLUMN, &info, -1);
-
- if (info == NULL)
- return;
-
- text = g_markup_printf_escaped ("<b>%s</b>\n%s",
- gtranslator_plugin_info_get_name (info),
- gtranslator_plugin_info_get_description (info));
- g_object_set (G_OBJECT (cell),
- "markup", text,
- "sensitive", gtranslator_plugin_info_is_available (info),
- NULL);
-
- g_free (text);
+ GtranslatorPluginInfo *info;
+ gchar *text;
+
+ g_return_if_fail (tree_model != NULL);
+ g_return_if_fail (tree_column != NULL);
+
+ gtk_tree_model_get (tree_model, iter, INFO_COLUMN, &info, -1);
+
+ if (info == NULL)
+ return;
+
+ text = g_markup_printf_escaped ("<b>%s</b>\n%s",
+ gtranslator_plugin_info_get_name (info),
+ gtranslator_plugin_info_get_description
+ (info));
+ g_object_set (G_OBJECT (cell), "markup", text, "sensitive",
+ gtranslator_plugin_info_is_available (info), NULL);
+
+ g_free (text);
}
static void
-plugin_manager_view_icon_cell_cb (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+plugin_manager_view_icon_cell_cb (GtkTreeViewColumn * tree_column,
+ GtkCellRenderer * cell,
+ GtkTreeModel * tree_model,
+ GtkTreeIter * iter, gpointer data)
{
- GtranslatorPluginInfo *info;
-
- g_return_if_fail (tree_model != NULL);
- g_return_if_fail (tree_column != NULL);
+ GtranslatorPluginInfo *info;
+
+ g_return_if_fail (tree_model != NULL);
+ g_return_if_fail (tree_column != NULL);
- gtk_tree_model_get (tree_model, iter, INFO_COLUMN, &info, -1);
+ gtk_tree_model_get (tree_model, iter, INFO_COLUMN, &info, -1);
- if (info == NULL)
- return;
+ if (info == NULL)
+ return;
- g_object_set (G_OBJECT (cell),
- "icon-name", gtranslator_plugin_info_get_icon_name (info),
- "sensitive", gtranslator_plugin_info_is_available (info),
- NULL);
+ g_object_set (G_OBJECT (cell),
+ "icon-name", gtranslator_plugin_info_get_icon_name (info),
+ "sensitive", gtranslator_plugin_info_is_available (info),
+ NULL);
}
static void
-active_toggled_cb (GtkCellRendererToggle *cell,
- gchar *path_str,
- GtranslatorPluginManager *pm)
+active_toggled_cb (GtkCellRendererToggle * cell,
+ gchar * path_str, GtranslatorPluginManager * pm)
{
- GtkTreeIter iter;
- GtkTreePath *path;
- GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeModel *model;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- path = gtk_tree_path_new_from_string (path_str);
+ path = gtk_tree_path_new_from_string (path_str);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
- g_return_if_fail (model != NULL);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
+ g_return_if_fail (model != NULL);
- gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get_iter (model, &iter, path);
- if (&iter != NULL)
- plugin_manager_toggle_active (pm, &iter, model);
+ if (&iter != NULL)
+ plugin_manager_toggle_active (pm, &iter, model);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
}
static void
-cursor_changed_cb (GtkTreeView *view,
- gpointer data)
+cursor_changed_cb (GtkTreeView * view, gpointer data)
{
- GtranslatorPluginManager *pm = data;
- GtranslatorPluginInfo *info;
+ GtranslatorPluginManager *pm = data;
+ GtranslatorPluginInfo *info;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- info = plugin_manager_get_selected_plugin (pm);
+ info = plugin_manager_get_selected_plugin (pm);
- gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->about_button),
- info != NULL);
- gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->configure_button),
- (info != NULL) &&
- gtranslator_plugin_info_is_configurable (info));
+ gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->about_button),
+ info != NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->configure_button),
+ (info != NULL) &&
+ gtranslator_plugin_info_is_configurable (info));
}
static void
-row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- gpointer data)
+row_activated_cb (GtkTreeView * tree_view,
+ GtkTreePath * path,
+ GtkTreeViewColumn * column, gpointer data)
{
- GtranslatorPluginManager *pm = data;
- GtkTreeIter iter;
- GtkTreeModel *model;
+ GtranslatorPluginManager *pm = data;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get_iter (model, &iter, path);
- g_return_if_fail (&iter != NULL);
+ g_return_if_fail (&iter != NULL);
- plugin_manager_toggle_active (pm, &iter, model);
+ plugin_manager_toggle_active (pm, &iter, model);
}
static void
-plugin_manager_populate_lists (GtranslatorPluginManager *pm)
+plugin_manager_populate_lists (GtranslatorPluginManager * pm)
{
- const GList *plugins;
- GtkListStore *model;
- GtkTreeIter iter;
+ const GList *plugins;
+ GtkListStore *model;
+ GtkTreeIter iter;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- plugins = gtranslator_plugins_engine_get_plugin_list (pm->priv->engine);
+ plugins = gtranslator_plugins_engine_get_plugin_list (pm->priv->engine);
- model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)));
+ model =
+ GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)));
- while (plugins)
- {
- GtranslatorPluginInfo *info;
- info = (GtranslatorPluginInfo *)plugins->data;
+ while (plugins)
+ {
+ GtranslatorPluginInfo *info;
+ info = (GtranslatorPluginInfo *) plugins->data;
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model, &iter,
- ACTIVE_COLUMN, gtranslator_plugin_info_is_active (info),
- AVAILABLE_COLUMN, gtranslator_plugin_info_is_available (info),
- INFO_COLUMN, info,
- -1);
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter,
+ ACTIVE_COLUMN,
+ gtranslator_plugin_info_is_active (info),
+ AVAILABLE_COLUMN,
+ gtranslator_plugin_info_is_available (info),
+ INFO_COLUMN, info, -1);
- plugins = plugins->next;
- }
+ plugins = plugins->next;
+ }
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
- {
- GtkTreeSelection *selection;
- GtranslatorPluginInfo* info;
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
+ {
+ GtkTreeSelection *selection;
+ GtranslatorPluginInfo *info;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
- g_return_if_fail (selection != NULL);
-
- gtk_tree_selection_select_iter (selection, &iter);
+ selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
+ g_return_if_fail (selection != NULL);
- gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
- INFO_COLUMN, &info, -1);
+ gtk_tree_selection_select_iter (selection, &iter);
- gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->configure_button),
- gtranslator_plugin_info_is_configurable (info));
- }
+ gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
+ INFO_COLUMN, &info, -1);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->configure_button),
+ gtranslator_plugin_info_is_configurable
+ (info));
+ }
}
static gboolean
-plugin_manager_set_active (GtranslatorPluginManager *pm,
- GtkTreeIter *iter,
- GtkTreeModel *model,
- gboolean active)
+plugin_manager_set_active (GtranslatorPluginManager * pm,
+ GtkTreeIter * iter,
+ GtkTreeModel * model, gboolean active)
{
- GtranslatorPluginInfo *info;
- gboolean res = TRUE;
-
- //gtranslator_debug (DEBUG_PLUGINS);
+ GtranslatorPluginInfo *info;
+ gboolean res = TRUE;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
- gtk_tree_model_get (model, iter, INFO_COLUMN, &info, -1);
+ gtk_tree_model_get (model, iter, INFO_COLUMN, &info, -1);
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- if (active)
+ if (active)
+ {
+ /* activate the plugin */
+ if (!gtranslator_plugins_engine_activate_plugin
+ (pm->priv->engine, info))
{
- /* activate the plugin */
- if (!gtranslator_plugins_engine_activate_plugin (pm->priv->engine, info)) {
- DEBUG_PRINT ( "Could not activate %s.\n",
- gtranslator_plugin_info_get_name (info));
+ DEBUG_PRINT ("Could not activate %s.\n",
+ gtranslator_plugin_info_get_name (info));
- res = FALSE;
- }
+ res = FALSE;
}
- else
+ }
+ else
+ {
+ /* deactivate the plugin */
+ if (!gtranslator_plugins_engine_deactivate_plugin
+ (pm->priv->engine, info))
{
- /* deactivate the plugin */
- if (!gtranslator_plugins_engine_deactivate_plugin (pm->priv->engine, info)) {
- DEBUG_PRINT ( "Could not deactivate %s.\n",
- gtranslator_plugin_info_get_name (info));
+ DEBUG_PRINT ("Could not deactivate %s.\n",
+ gtranslator_plugin_info_get_name (info));
- res = FALSE;
- }
+ res = FALSE;
}
+ }
- return res;
+ return res;
}
static void
-plugin_manager_toggle_active (GtranslatorPluginManager *pm,
- GtkTreeIter *iter,
- GtkTreeModel *model)
+plugin_manager_toggle_active (GtranslatorPluginManager * pm,
+ GtkTreeIter * iter, GtkTreeModel * model)
{
- gboolean active;
-
- //gtranslator_debug (DEBUG_PLUGINS);
+ gboolean active;
- gtk_tree_model_get (model, iter, ACTIVE_COLUMN, &active, -1);
+ //gtranslator_debug (DEBUG_PLUGINS);
- active ^= 1;
+ gtk_tree_model_get (model, iter, ACTIVE_COLUMN, &active, -1);
- plugin_manager_set_active (pm, iter, model, active);
+ active ^= 1;
+
+ plugin_manager_set_active (pm, iter, model, active);
}
static GtranslatorPluginInfo *
-plugin_manager_get_selected_plugin (GtranslatorPluginManager *pm)
+plugin_manager_get_selected_plugin (GtranslatorPluginManager * pm)
{
- GtranslatorPluginInfo *info = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
+ GtranslatorPluginInfo *info = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
- g_return_val_if_fail (model != NULL, NULL);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
+ g_return_val_if_fail (model != NULL, NULL);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
- g_return_val_if_fail (selection != NULL, NULL);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
+ g_return_val_if_fail (selection != NULL, NULL);
- if (gtk_tree_selection_get_selected (selection, NULL, &iter))
- {
- gtk_tree_model_get (model, &iter, INFO_COLUMN, &info, -1);
- }
-
- return info;
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ gtk_tree_model_get (model, &iter, INFO_COLUMN, &info, -1);
+ }
+
+ return info;
}
static void
-plugin_manager_set_active_all (GtranslatorPluginManager *pm,
- gboolean active)
+plugin_manager_set_active_all (GtranslatorPluginManager * pm, gboolean active)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gtk_tree_model_get_iter_first (model, &iter);
+ gtk_tree_model_get_iter_first (model, &iter);
- do {
- plugin_manager_set_active (pm, &iter, model, active);
- }
- while (gtk_tree_model_iter_next (model, &iter));
+ do
+ {
+ plugin_manager_set_active (pm, &iter, model, active);
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
}
/* Callback used as the interactive search comparison function */
static gboolean
-name_search_cb (GtkTreeModel *model,
- gint column,
- const gchar *key,
- GtkTreeIter *iter,
- gpointer data)
+name_search_cb (GtkTreeModel * model,
+ gint column,
+ const gchar * key, GtkTreeIter * iter, gpointer data)
{
- GtranslatorPluginInfo *info;
- gchar *normalized_string;
- gchar *normalized_key;
- gchar *case_normalized_string;
- gchar *case_normalized_key;
- gint key_len;
- gboolean retval;
-
- gtk_tree_model_get (model, iter, INFO_COLUMN, &info, -1);
- if (!info)
- return FALSE;
-
- normalized_string = g_utf8_normalize (gtranslator_plugin_info_get_name (info), -1, G_NORMALIZE_ALL);
- normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL);
- case_normalized_string = g_utf8_casefold (normalized_string, -1);
- case_normalized_key = g_utf8_casefold (normalized_key, -1);
-
- key_len = strlen (case_normalized_key);
-
- /* Oddly enough, this callback must return whether to stop the search
- * because we found a match, not whether we actually matched.
- */
- retval = (strncmp (case_normalized_key, case_normalized_string, key_len) != 0);
-
- g_free (normalized_key);
- g_free (normalized_string);
- g_free (case_normalized_key);
- g_free (case_normalized_string);
-
- return retval;
+ GtranslatorPluginInfo *info;
+ gchar *normalized_string;
+ gchar *normalized_key;
+ gchar *case_normalized_string;
+ gchar *case_normalized_key;
+ gint key_len;
+ gboolean retval;
+
+ gtk_tree_model_get (model, iter, INFO_COLUMN, &info, -1);
+ if (!info)
+ return FALSE;
+
+ normalized_string =
+ g_utf8_normalize (gtranslator_plugin_info_get_name (info), -1,
+ G_NORMALIZE_ALL);
+ normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL);
+ case_normalized_string = g_utf8_casefold (normalized_string, -1);
+ case_normalized_key = g_utf8_casefold (normalized_key, -1);
+
+ key_len = strlen (case_normalized_key);
+
+ /* Oddly enough, this callback must return whether to stop the search
+ * because we found a match, not whether we actually matched.
+ */
+ retval =
+ (strncmp (case_normalized_key, case_normalized_string, key_len) != 0);
+
+ g_free (normalized_key);
+ g_free (normalized_string);
+ g_free (case_normalized_key);
+ g_free (case_normalized_string);
+
+ return retval;
}
static void
-enable_plugin_menu_cb (GtkMenu *menu,
- GtranslatorPluginManager *pm)
+enable_plugin_menu_cb (GtkMenu * menu, GtranslatorPluginManager * pm)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
- g_return_if_fail (model != NULL);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree));
+ g_return_if_fail (model != NULL);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
- g_return_if_fail (selection != NULL);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
+ g_return_if_fail (selection != NULL);
- if (gtk_tree_selection_get_selected (selection, NULL, &iter))
- plugin_manager_toggle_active (pm, &iter, model);
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ plugin_manager_toggle_active (pm, &iter, model);
}
static void
-enable_all_menu_cb (GtkMenu *menu,
- GtranslatorPluginManager *pm)
+enable_all_menu_cb (GtkMenu * menu, GtranslatorPluginManager * pm)
{
- plugin_manager_set_active_all (pm, TRUE);
+ plugin_manager_set_active_all (pm, TRUE);
}
static void
-disable_all_menu_cb (GtkMenu *menu,
- GtranslatorPluginManager *pm)
+disable_all_menu_cb (GtkMenu * menu, GtranslatorPluginManager * pm)
{
- plugin_manager_set_active_all (pm, FALSE);
+ plugin_manager_set_active_all (pm, FALSE);
}
static GtkWidget *
-create_tree_popup_menu (GtranslatorPluginManager *pm)
+create_tree_popup_menu (GtranslatorPluginManager * pm)
{
- GtkWidget *menu;
- GtkWidget *item;
- GtkWidget *image;
- GtranslatorPluginInfo *info;
-
- info = plugin_manager_get_selected_plugin (pm);
-
- menu = gtk_menu_new ();
-
- item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
- image = gtk_image_new_from_stock (GTK_STOCK_ABOUT,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- g_signal_connect (item, "activate",
- G_CALLBACK (about_button_cb), pm);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_image_menu_item_new_with_mnemonic (_("C_onfigure"));
- image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- g_signal_connect (item, "activate",
- G_CALLBACK (configure_button_cb), pm);
- gtk_widget_set_sensitive (item, gtranslator_plugin_info_is_configurable (info));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_check_menu_item_new_with_mnemonic (_("A_ctivate"));
- gtk_widget_set_sensitive (item, gtranslator_plugin_info_is_available (info));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
- gtranslator_plugin_info_is_active (info));
- g_signal_connect (item, "toggled",
- G_CALLBACK (enable_plugin_menu_cb), pm);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_menu_item_new_with_mnemonic (_("Ac_tivate All"));
- g_signal_connect (item, "activate",
- G_CALLBACK (enable_all_menu_cb), pm);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_menu_item_new_with_mnemonic (_("_Deactivate All"));
- g_signal_connect (item, "activate",
- G_CALLBACK (disable_all_menu_cb), pm);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- gtk_widget_show_all (menu);
-
- return menu;
+ GtkWidget *menu;
+ GtkWidget *item;
+ GtkWidget *image;
+ GtranslatorPluginInfo *info;
+
+ info = plugin_manager_get_selected_plugin (pm);
+
+ menu = gtk_menu_new ();
+
+ item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
+ image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ g_signal_connect (item, "activate", G_CALLBACK (about_button_cb), pm);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_image_menu_item_new_with_mnemonic (_("C_onfigure"));
+ image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES,
+ GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ g_signal_connect (item, "activate", G_CALLBACK (configure_button_cb), pm);
+ gtk_widget_set_sensitive (item,
+ gtranslator_plugin_info_is_configurable (info));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_check_menu_item_new_with_mnemonic (_("A_ctivate"));
+ gtk_widget_set_sensitive (item,
+ gtranslator_plugin_info_is_available (info));
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
+ gtranslator_plugin_info_is_active (info));
+ g_signal_connect (item, "toggled", G_CALLBACK (enable_plugin_menu_cb), pm);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_mnemonic (_("Ac_tivate All"));
+ g_signal_connect (item, "activate", G_CALLBACK (enable_all_menu_cb), pm);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_mnemonic (_("_Deactivate All"));
+ g_signal_connect (item, "activate", G_CALLBACK (disable_all_menu_cb), pm);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ gtk_widget_show_all (menu);
+
+ return menu;
}
static void
-tree_popup_menu_detach (GtranslatorPluginManager *pm,
- GtkMenu *menu)
+tree_popup_menu_detach (GtranslatorPluginManager * pm, GtkMenu * menu)
{
- pm->priv->popup_menu = NULL;
+ pm->priv->popup_menu = NULL;
}
static void
-show_tree_popup_menu (GtkTreeView *tree,
- GtranslatorPluginManager *pm,
- GdkEventButton *event)
+show_tree_popup_menu (GtkTreeView * tree,
+ GtranslatorPluginManager * pm, GdkEventButton * event)
{
- if (pm->priv->popup_menu)
- gtk_widget_destroy (pm->priv->popup_menu);
-
- pm->priv->popup_menu = create_tree_popup_menu (pm);
-
- gtk_menu_attach_to_widget (GTK_MENU (pm->priv->popup_menu),
- GTK_WIDGET (pm),
- (GtkMenuDetachFunc) tree_popup_menu_detach);
-
- if (event != NULL)
- {
- gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL,
- NULL, NULL,
- event->button, event->time);
- }
- else
- {
- gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL,
- gtranslator_utils_menu_position_under_tree_view, tree,
- 0, gtk_get_current_event_time ());
-
- gtk_menu_shell_select_first (GTK_MENU_SHELL (pm->priv->popup_menu),
- FALSE);
- }
+ if (pm->priv->popup_menu)
+ gtk_widget_destroy (pm->priv->popup_menu);
+
+ pm->priv->popup_menu = create_tree_popup_menu (pm);
+
+ gtk_menu_attach_to_widget (GTK_MENU (pm->priv->popup_menu),
+ GTK_WIDGET (pm),
+ (GtkMenuDetachFunc) tree_popup_menu_detach);
+
+ if (event != NULL)
+ {
+ gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL,
+ NULL, NULL, event->button, event->time);
+ }
+ else
+ {
+ gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL,
+ gtranslator_utils_menu_position_under_tree_view, tree,
+ 0, gtk_get_current_event_time ());
+
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (pm->priv->popup_menu),
+ FALSE);
+ }
}
static gboolean
-button_press_event_cb (GtkWidget *tree,
- GdkEventButton *event,
- GtranslatorPluginManager *pm)
+button_press_event_cb (GtkWidget * tree,
+ GdkEventButton * event, GtranslatorPluginManager * pm)
{
- /* We want the treeview selection to be updated before showing the menu.
- * This code is evil, thanks to Federico Mena Quintero's black magic.
- * See: http://mail.gnome.org/archives/gtk-devel-list/2006-February/msg00168.html
- * FIXME: Let's remove it asap.
- */
-
- static gboolean in_press = FALSE;
- gboolean handled;
-
- if (in_press)
- return FALSE; /* we re-entered */
-
- if (GDK_BUTTON_PRESS != event->type || 3 != event->button)
- return FALSE; /* let the normal handler run */
-
- in_press = TRUE;
- handled = gtk_widget_event (tree, (GdkEvent *) event);
- in_press = FALSE;
-
- if (!handled)
- return FALSE;
-
- /* The selection is fully updated by now */
- show_tree_popup_menu (GTK_TREE_VIEW (tree), pm, event);
- return TRUE;
+ /* We want the treeview selection to be updated before showing the menu.
+ * This code is evil, thanks to Federico Mena Quintero's black magic.
+ * See: http://mail.gnome.org/archives/gtk-devel-list/2006-February/msg00168.html
+ * FIXME: Let's remove it asap.
+ */
+
+ static gboolean in_press = FALSE;
+ gboolean handled;
+
+ if (in_press)
+ return FALSE; /* we re-entered */
+
+ if (GDK_BUTTON_PRESS != event->type || 3 != event->button)
+ return FALSE; /* let the normal handler run */
+
+ in_press = TRUE;
+ handled = gtk_widget_event (tree, (GdkEvent *) event);
+ in_press = FALSE;
+
+ if (!handled)
+ return FALSE;
+
+ /* The selection is fully updated by now */
+ show_tree_popup_menu (GTK_TREE_VIEW (tree), pm, event);
+ return TRUE;
}
static gboolean
-popup_menu_cb (GtkTreeView *tree,
- GtranslatorPluginManager *pm)
+popup_menu_cb (GtkTreeView * tree, GtranslatorPluginManager * pm)
{
- show_tree_popup_menu (tree, pm, NULL);
- return TRUE;
+ show_tree_popup_menu (tree, pm, NULL);
+ return TRUE;
}
-static gint
-model_name_sort_func (GtkTreeModel *model,
- GtkTreeIter *iter1,
- GtkTreeIter *iter2,
- gpointer user_data)
+static gint
+model_name_sort_func (GtkTreeModel * model,
+ GtkTreeIter * iter1,
+ GtkTreeIter * iter2, gpointer user_data)
{
- GtranslatorPluginInfo *info1, *info2;
-
- gtk_tree_model_get (model, iter1, INFO_COLUMN, &info1, -1);
- gtk_tree_model_get (model, iter2, INFO_COLUMN, &info2, -1);
+ GtranslatorPluginInfo *info1, *info2;
+
+ gtk_tree_model_get (model, iter1, INFO_COLUMN, &info1, -1);
+ gtk_tree_model_get (model, iter2, INFO_COLUMN, &info2, -1);
- return g_utf8_collate (gtranslator_plugin_info_get_name (info1),
- gtranslator_plugin_info_get_name (info2));
+ return g_utf8_collate (gtranslator_plugin_info_get_name (info1),
+ gtranslator_plugin_info_get_name (info2));
}
static void
-plugin_manager_construct_tree (GtranslatorPluginManager *pm)
+plugin_manager_construct_tree (GtranslatorPluginManager * pm)
{
- GtkTreeViewColumn *column;
- GtkCellRenderer *cell;
- GtkListStore *model;
-
- //gtranslator_debug (DEBUG_PLUGINS);
-
- model = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, GTR_TYPE_PLUGIN_INFO);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (pm->priv->tree),
- GTK_TREE_MODEL (model));
- g_object_unref (model);
-
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (pm->priv->tree), TRUE);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pm->priv->tree), FALSE);
-
- /* first column */
- cell = gtk_cell_renderer_toggle_new ();
- g_object_set (cell, "xpad", 6, NULL);
- g_signal_connect (cell,
- "toggled",
- G_CALLBACK (active_toggled_cb),
- pm);
- column = gtk_tree_view_column_new_with_attributes (PLUGIN_MANAGER_ACTIVE_TITLE,
- cell,
- "active",
- ACTIVE_COLUMN,
- "activatable",
- AVAILABLE_COLUMN,
- "sensitive",
- AVAILABLE_COLUMN,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column);
-
- /* second column */
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, PLUGIN_MANAGER_NAME_TITLE);
- gtk_tree_view_column_set_resizable (column, TRUE);
-
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, cell, FALSE);
- g_object_set (cell, "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
- gtk_tree_view_column_set_cell_data_func (column, cell,
- plugin_manager_view_icon_cell_cb,
- pm, NULL);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_tree_view_column_set_cell_data_func (column, cell,
- plugin_manager_view_info_cell_cb,
- pm, NULL);
-
-
- gtk_tree_view_column_set_spacing (column, 6);
- gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column);
-
- /* Sort on the plugin names */
- gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model),
- model_name_sort_func,
- NULL,
- NULL);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
- GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
- GTK_SORT_ASCENDING);
-
- /* Enable search for our non-string column */
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (pm->priv->tree),
- INFO_COLUMN);
- gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (pm->priv->tree),
- name_search_cb,
- NULL,
- NULL);
-
- g_signal_connect (pm->priv->tree,
- "cursor_changed",
- G_CALLBACK (cursor_changed_cb),
- pm);
- g_signal_connect (pm->priv->tree,
- "row_activated",
- G_CALLBACK (row_activated_cb),
- pm);
-
- g_signal_connect (pm->priv->tree,
- "button-press-event",
- G_CALLBACK (button_press_event_cb),
- pm);
- g_signal_connect (pm->priv->tree,
- "popup-menu",
- G_CALLBACK (popup_menu_cb),
- pm);
- gtk_widget_show (pm->priv->tree);
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *cell;
+ GtkListStore *model;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ model =
+ gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
+ GTR_TYPE_PLUGIN_INFO);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (pm->priv->tree),
+ GTK_TREE_MODEL (model));
+ g_object_unref (model);
+
+ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (pm->priv->tree), TRUE);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pm->priv->tree), FALSE);
+
+ /* first column */
+ cell = gtk_cell_renderer_toggle_new ();
+ g_object_set (cell, "xpad", 6, NULL);
+ g_signal_connect (cell, "toggled", G_CALLBACK (active_toggled_cb), pm);
+ column =
+ gtk_tree_view_column_new_with_attributes (PLUGIN_MANAGER_ACTIVE_TITLE,
+ cell, "active", ACTIVE_COLUMN,
+ "activatable", AVAILABLE_COLUMN,
+ "sensitive", AVAILABLE_COLUMN,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column);
+
+ /* second column */
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_title (column, PLUGIN_MANAGER_NAME_TITLE);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, cell, FALSE);
+ g_object_set (cell, "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
+ gtk_tree_view_column_set_cell_data_func (column, cell,
+ plugin_manager_view_icon_cell_cb,
+ pm, NULL);
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, cell, TRUE);
+ g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ gtk_tree_view_column_set_cell_data_func (column, cell,
+ plugin_manager_view_info_cell_cb,
+ pm, NULL);
+
+
+ gtk_tree_view_column_set_spacing (column, 6);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column);
+
+ /* Sort on the plugin names */
+ gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model),
+ model_name_sort_func, NULL, NULL);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+ GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+ GTK_SORT_ASCENDING);
+
+ /* Enable search for our non-string column */
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (pm->priv->tree),
+ INFO_COLUMN);
+ gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (pm->priv->tree),
+ name_search_cb, NULL, NULL);
+
+ g_signal_connect (pm->priv->tree,
+ "cursor_changed", G_CALLBACK (cursor_changed_cb), pm);
+ g_signal_connect (pm->priv->tree,
+ "row_activated", G_CALLBACK (row_activated_cb), pm);
+
+ g_signal_connect (pm->priv->tree,
+ "button-press-event",
+ G_CALLBACK (button_press_event_cb), pm);
+ g_signal_connect (pm->priv->tree,
+ "popup-menu", G_CALLBACK (popup_menu_cb), pm);
+ gtk_widget_show (pm->priv->tree);
}
static void
-plugin_toggled_cb (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info,
- GtranslatorPluginManager *pm)
+plugin_toggled_cb (GtranslatorPluginsEngine * engine,
+ GtranslatorPluginInfo * info,
+ GtranslatorPluginManager * pm)
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean info_found = FALSE;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- /* There is an item selected: it's probably the one we want! */
- GtranslatorPluginInfo *tinfo;
- gtk_tree_model_get (model, &iter, INFO_COLUMN, &tinfo, -1);
- info_found = info == tinfo;
- }
-
- if (!info_found)
- {
- gtk_tree_model_get_iter_first (model, &iter);
-
- do
- {
- GtranslatorPluginInfo *tinfo;
- gtk_tree_model_get (model, &iter, INFO_COLUMN, &tinfo, -1);
- info_found = info == tinfo;
- }
- while (!info_found && gtk_tree_model_iter_next (model, &iter));
- }
-
- if (!info_found)
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean info_found = FALSE;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree));
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ /* There is an item selected: it's probably the one we want! */
+ GtranslatorPluginInfo *tinfo;
+ gtk_tree_model_get (model, &iter, INFO_COLUMN, &tinfo, -1);
+ info_found = info == tinfo;
+ }
+
+ if (!info_found)
+ {
+ gtk_tree_model_get_iter_first (model, &iter);
+
+ do
{
- g_warning ("GtranslatorPluginManager: plugin '%s' not found in the tree model",
- gtranslator_plugin_info_get_name (info));
- return;
+ GtranslatorPluginInfo *tinfo;
+ gtk_tree_model_get (model, &iter, INFO_COLUMN, &tinfo, -1);
+ info_found = info == tinfo;
}
-
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, ACTIVE_COLUMN, gtranslator_plugin_info_is_active (info), -1);
+ while (!info_found && gtk_tree_model_iter_next (model, &iter));
+ }
+
+ if (!info_found)
+ {
+ g_warning
+ ("GtranslatorPluginManager: plugin '%s' not found in the tree model",
+ gtranslator_plugin_info_get_name (info));
+ return;
+ }
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, ACTIVE_COLUMN,
+ gtranslator_plugin_info_is_active (info), -1);
}
-static void
-gtranslator_plugin_manager_init (GtranslatorPluginManager *pm)
+static void
+gtranslator_plugin_manager_init (GtranslatorPluginManager * pm)
{
- GtkWidget *label;
- GtkWidget *alignment;
- GtkWidget *viewport;
- GtkWidget *hbuttonbox;
- gchar *markup;
-
- //gtranslator_debug (DEBUG_PLUGINS);
-
- pm->priv = GTR_PLUGIN_MANAGER_GET_PRIVATE (pm);
-
- gtk_box_set_spacing (GTK_BOX (pm), 6);
-
- label = gtk_label_new (NULL);
- markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
- _("Active plugins"));
- gtk_label_set_markup (GTK_LABEL (label), markup);
- g_free (markup);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-
- gtk_box_pack_start (GTK_BOX (pm), label, FALSE, TRUE, 0);
-
- alignment = gtk_alignment_new (0., 0., 1., 1.);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
- gtk_box_pack_start (GTK_BOX (pm), alignment, TRUE, TRUE, 0);
-
- viewport = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (viewport),
- GTK_SHADOW_IN);
-
- gtk_container_add (GTK_CONTAINER (alignment), viewport);
-
- pm->priv->tree = gtk_tree_view_new ();
- gtk_container_add (GTK_CONTAINER (viewport), pm->priv->tree);
-
- hbuttonbox = gtk_hbutton_box_new ();
- gtk_box_pack_start (GTK_BOX (pm), hbuttonbox, FALSE, FALSE, 0);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
- gtk_box_set_spacing (GTK_BOX (hbuttonbox), 8);
-
- pm->priv->about_button = gtranslator_gtk_button_new_with_stock_icon (_("_About Plugin"),
- GTK_STOCK_ABOUT);
- gtk_container_add (GTK_CONTAINER (hbuttonbox), pm->priv->about_button);
-
- pm->priv->configure_button = gtranslator_gtk_button_new_with_stock_icon (_("C_onfigure Plugin"),
- GTK_STOCK_PREFERENCES);
- gtk_container_add (GTK_CONTAINER (hbuttonbox), pm->priv->configure_button);
-
- /* setup a window of a sane size. */
- gtk_widget_set_size_request (GTK_WIDGET (viewport), 270, 100);
-
- g_signal_connect (pm->priv->about_button,
- "clicked",
- G_CALLBACK (about_button_cb),
- pm);
- g_signal_connect (pm->priv->configure_button,
- "clicked",
- G_CALLBACK (configure_button_cb),
- pm);
-
- plugin_manager_construct_tree (pm);
-
- /* get the plugin engine and populate the treeview */
- pm->priv->engine = gtranslator_plugins_engine_get_default ();
-
- g_signal_connect_after (pm->priv->engine,
- "activate-plugin",
- G_CALLBACK (plugin_toggled_cb),
- pm);
- g_signal_connect_after (pm->priv->engine,
- "deactivate-plugin",
- G_CALLBACK (plugin_toggled_cb),
- pm);
-
- if (gtranslator_plugins_engine_get_plugin_list (pm->priv->engine) != NULL)
- {
- plugin_manager_populate_lists (pm);
- }
- else
- {
- gtk_widget_set_sensitive (pm->priv->about_button, FALSE);
- gtk_widget_set_sensitive (pm->priv->configure_button, FALSE);
- }
+ GtkWidget *label;
+ GtkWidget *alignment;
+ GtkWidget *viewport;
+ GtkWidget *hbuttonbox;
+ gchar *markup;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ pm->priv = GTR_PLUGIN_MANAGER_GET_PRIVATE (pm);
+
+ gtk_box_set_spacing (GTK_BOX (pm), 6);
+
+ label = gtk_label_new (NULL);
+ markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
+ _("Active plugins"));
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ g_free (markup);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+
+ gtk_box_pack_start (GTK_BOX (pm), label, FALSE, TRUE, 0);
+
+ alignment = gtk_alignment_new (0., 0., 1., 1.);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
+ gtk_box_pack_start (GTK_BOX (pm), alignment, TRUE, TRUE, 0);
+
+ viewport = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (viewport),
+ GTK_SHADOW_IN);
+
+ gtk_container_add (GTK_CONTAINER (alignment), viewport);
+
+ pm->priv->tree = gtk_tree_view_new ();
+ gtk_container_add (GTK_CONTAINER (viewport), pm->priv->tree);
+
+ hbuttonbox = gtk_hbutton_box_new ();
+ gtk_box_pack_start (GTK_BOX (pm), hbuttonbox, FALSE, FALSE, 0);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
+ gtk_box_set_spacing (GTK_BOX (hbuttonbox), 8);
+
+ pm->priv->about_button =
+ gtranslator_gtk_button_new_with_stock_icon (_("_About Plugin"),
+ GTK_STOCK_ABOUT);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), pm->priv->about_button);
+
+ pm->priv->configure_button =
+ gtranslator_gtk_button_new_with_stock_icon (_("C_onfigure Plugin"),
+ GTK_STOCK_PREFERENCES);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), pm->priv->configure_button);
+
+ /* setup a window of a sane size. */
+ gtk_widget_set_size_request (GTK_WIDGET (viewport), 270, 100);
+
+ g_signal_connect (pm->priv->about_button,
+ "clicked", G_CALLBACK (about_button_cb), pm);
+ g_signal_connect (pm->priv->configure_button,
+ "clicked", G_CALLBACK (configure_button_cb), pm);
+
+ plugin_manager_construct_tree (pm);
+
+ /* get the plugin engine and populate the treeview */
+ pm->priv->engine = gtranslator_plugins_engine_get_default ();
+
+ g_signal_connect_after (pm->priv->engine,
+ "activate-plugin",
+ G_CALLBACK (plugin_toggled_cb), pm);
+ g_signal_connect_after (pm->priv->engine,
+ "deactivate-plugin",
+ G_CALLBACK (plugin_toggled_cb), pm);
+
+ if (gtranslator_plugins_engine_get_plugin_list (pm->priv->engine) != NULL)
+ {
+ plugin_manager_populate_lists (pm);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (pm->priv->about_button, FALSE);
+ gtk_widget_set_sensitive (pm->priv->configure_button, FALSE);
+ }
}
static void
-gtranslator_plugin_manager_finalize (GObject *object)
+gtranslator_plugin_manager_finalize (GObject * object)
{
- GtranslatorPluginManager *pm = GTR_PLUGIN_MANAGER (object);
+ GtranslatorPluginManager *pm = GTR_PLUGIN_MANAGER (object);
- g_signal_handlers_disconnect_by_func (pm->priv->engine,
- plugin_toggled_cb,
- pm);
+ g_signal_handlers_disconnect_by_func (pm->priv->engine,
+ plugin_toggled_cb, pm);
- if (pm->priv->popup_menu)
- gtk_widget_destroy (pm->priv->popup_menu);
+ if (pm->priv->popup_menu)
+ gtk_widget_destroy (pm->priv->popup_menu);
- G_OBJECT_CLASS (gtranslator_plugin_manager_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_plugin_manager_parent_class)->finalize (object);
}
-GtkWidget *gtranslator_plugin_manager_new (void)
+GtkWidget *
+gtranslator_plugin_manager_new (void)
{
- return g_object_new (GTR_TYPE_PLUGIN_MANAGER,0);
+ return g_object_new (GTR_TYPE_PLUGIN_MANAGER, 0);
}
diff --git a/src/plugin-system/plugin-manager.h b/src/plugin-system/plugin-manager.h
index d634414..1b005ae 100644
--- a/src/plugin-system/plugin-manager.h
+++ b/src/plugin-system/plugin-manager.h
@@ -34,7 +34,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -44,21 +43,21 @@ G_BEGIN_DECLS
#define GTR_IS_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTR_TYPE_PLUGIN_MANAGER))
#define GTR_IS_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_PLUGIN_MANAGER))
#define GTR_PLUGIN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_PLUGIN_MANAGER, GtranslatorPluginManagerClass))
-
/* Private structure type */
-typedef struct _GtranslatorPluginManagerPrivate GtranslatorPluginManagerPrivate;
+typedef struct _GtranslatorPluginManagerPrivate
+ GtranslatorPluginManagerPrivate;
/*
* Main object structure
*/
typedef struct _GtranslatorPluginManager GtranslatorPluginManager;
-struct _GtranslatorPluginManager
+struct _GtranslatorPluginManager
{
- GtkVBox vbox;
+ GtkVBox vbox;
- /*< private > */
- GtranslatorPluginManagerPrivate *priv;
+ /*< private > */
+ GtranslatorPluginManagerPrivate *priv;
};
/*
@@ -66,18 +65,19 @@ struct _GtranslatorPluginManager
*/
typedef struct _GtranslatorPluginManagerClass GtranslatorPluginManagerClass;
-struct _GtranslatorPluginManagerClass
+struct _GtranslatorPluginManagerClass
{
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_plugin_manager_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_plugin_manager_get_type (void)
+ G_GNUC_CONST;
-GtkWidget *gtranslator_plugin_manager_new (void);
-
-G_END_DECLS
+ GtkWidget *gtranslator_plugin_manager_new (void);
-#endif /* __GTR_PLUGIN_MANAGER_H__ */
+G_END_DECLS
+#endif /* __GTR_PLUGIN_MANAGER_H__ */
diff --git a/src/plugin-system/plugin.c b/src/plugin-system/plugin.c
index 4f167f6..2cdb570 100644
--- a/src/plugin-system/plugin.c
+++ b/src/plugin-system/plugin.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2002-2005. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -34,42 +34,41 @@
#include "plugin.h"
-G_DEFINE_TYPE(GtranslatorPlugin, gtranslator_plugin, G_TYPE_OBJECT)
-
-static void
-dummy (GtranslatorPlugin *plugin, GtranslatorWindow *window)
+G_DEFINE_TYPE (GtranslatorPlugin, gtranslator_plugin, G_TYPE_OBJECT)
+ static void
+ dummy (GtranslatorPlugin * plugin, GtranslatorWindow * window)
{
- /* Empty */
+ /* Empty */
}
static GtkWidget *
-create_configure_dialog (GtranslatorPlugin *plugin)
+create_configure_dialog (GtranslatorPlugin * plugin)
{
- return NULL;
+ return NULL;
}
static gboolean
-is_configurable (GtranslatorPlugin *plugin)
+is_configurable (GtranslatorPlugin * plugin)
{
- return (GTR_PLUGIN_GET_CLASS (plugin)->create_configure_dialog !=
- create_configure_dialog);
+ return (GTR_PLUGIN_GET_CLASS (plugin)->create_configure_dialog !=
+ create_configure_dialog);
}
-static void
-gtranslator_plugin_class_init (GtranslatorPluginClass *klass)
+static void
+gtranslator_plugin_class_init (GtranslatorPluginClass * klass)
{
- klass->activate = dummy;
- klass->deactivate = dummy;
- klass->update_ui = dummy;
-
- klass->create_configure_dialog = create_configure_dialog;
- klass->is_configurable = is_configurable;
+ klass->activate = dummy;
+ klass->deactivate = dummy;
+ klass->update_ui = dummy;
+
+ klass->create_configure_dialog = create_configure_dialog;
+ klass->is_configurable = is_configurable;
}
static void
-gtranslator_plugin_init (GtranslatorPlugin *plugin)
+gtranslator_plugin_init (GtranslatorPlugin * plugin)
{
- /* Empty */
+ /* Empty */
}
/**
@@ -80,13 +79,13 @@ gtranslator_plugin_init (GtranslatorPlugin *plugin)
* Activates the plugin.
*/
void
-gtranslator_plugin_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+gtranslator_plugin_activate (GtranslatorPlugin * plugin,
+ GtranslatorWindow * window)
{
- g_return_if_fail (GTR_IS_PLUGIN (plugin));
- g_return_if_fail (GTR_IS_WINDOW (window));
-
- GTR_PLUGIN_GET_CLASS (plugin)->activate (plugin, window);
+ g_return_if_fail (GTR_IS_PLUGIN (plugin));
+ g_return_if_fail (GTR_IS_WINDOW (window));
+
+ GTR_PLUGIN_GET_CLASS (plugin)->activate (plugin, window);
}
/**
@@ -97,13 +96,13 @@ gtranslator_plugin_activate (GtranslatorPlugin *plugin,
* Deactivates the plugin.
*/
void
-gtranslator_plugin_deactivate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+gtranslator_plugin_deactivate (GtranslatorPlugin * plugin,
+ GtranslatorWindow * window)
{
- g_return_if_fail (GTR_IS_PLUGIN (plugin));
- g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTR_IS_PLUGIN (plugin));
+ g_return_if_fail (GTR_IS_WINDOW (window));
- GTR_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window);
+ GTR_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window);
}
/**
@@ -113,15 +112,15 @@ gtranslator_plugin_deactivate (GtranslatorPlugin *plugin,
*
* Triggers an update of the user interface to take into account state changes
* caused by the plugin.
- */
+ */
void
-gtranslator_plugin_update_ui (GtranslatorPlugin *plugin,
- GtranslatorWindow *window)
+gtranslator_plugin_update_ui (GtranslatorPlugin * plugin,
+ GtranslatorWindow * window)
{
- g_return_if_fail (GTR_IS_PLUGIN (plugin));
- g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTR_IS_PLUGIN (plugin));
+ g_return_if_fail (GTR_IS_WINDOW (window));
- GTR_PLUGIN_GET_CLASS (plugin)->update_ui (plugin, window);
+ GTR_PLUGIN_GET_CLASS (plugin)->update_ui (plugin, window);
}
/**
@@ -133,11 +132,11 @@ gtranslator_plugin_update_ui (GtranslatorPlugin *plugin,
* Returns: TRUE if the plugin is configurable:
*/
gboolean
-gtranslator_plugin_is_configurable (GtranslatorPlugin *plugin)
+gtranslator_plugin_is_configurable (GtranslatorPlugin * plugin)
{
- g_return_val_if_fail (GTR_IS_PLUGIN (plugin), FALSE);
+ g_return_val_if_fail (GTR_IS_PLUGIN (plugin), FALSE);
- return GTR_PLUGIN_GET_CLASS (plugin)->is_configurable (plugin);
+ return GTR_PLUGIN_GET_CLASS (plugin)->is_configurable (plugin);
}
/**
@@ -149,9 +148,9 @@ gtranslator_plugin_is_configurable (GtranslatorPlugin *plugin)
* Returns: the configure dialog widget for the plugin.
*/
GtkWidget *
-gtranslator_plugin_create_configure_dialog (GtranslatorPlugin *plugin)
+gtranslator_plugin_create_configure_dialog (GtranslatorPlugin * plugin)
{
- g_return_val_if_fail (GTR_IS_PLUGIN (plugin), NULL);
-
- return GTR_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin);
+ g_return_val_if_fail (GTR_IS_PLUGIN (plugin), NULL);
+
+ return GTR_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin);
}
diff --git a/src/plugin-system/plugin.h b/src/plugin-system/plugin.h
index 33f5be1..2405f8b 100644
--- a/src/plugin-system/plugin.h
+++ b/src/plugin-system/plugin.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2002-2005. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -37,10 +37,9 @@
#include "debug.h"
/* TODO: add a .h file that includes all the .h files normally needed to
- * develop a plugin */
+ * develop a plugin */
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -50,15 +49,14 @@ G_BEGIN_DECLS
#define GTR_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTR_TYPE_PLUGIN))
#define GTR_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_PLUGIN))
#define GTR_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_PLUGIN, GtranslatorPluginClass))
-
/*
* Main object structure
*/
typedef struct _GtranslatorPlugin GtranslatorPlugin;
-struct _GtranslatorPlugin
+struct _GtranslatorPlugin
{
- GObject parent;
+ GObject parent;
};
/*
@@ -66,51 +64,48 @@ struct _GtranslatorPlugin
*/
typedef struct _GtranslatorPluginClass GtranslatorPluginClass;
-struct _GtranslatorPluginClass
+struct _GtranslatorPluginClass
{
- GObjectClass parent_class;
-
- /* Virtual public methods */
-
- void (*activate) (GtranslatorPlugin *plugin,
- GtranslatorWindow *window);
- void (*deactivate) (GtranslatorPlugin *plugin,
- GtranslatorWindow *window);
-
- void (*update_ui) (GtranslatorPlugin *plugin,
- GtranslatorWindow *window);
-
- GtkWidget *(*create_configure_dialog)
- (GtranslatorPlugin *plugin);
-
- /* Plugins should not override this, it's handled automatically by
- the GtranslatorPluginClass */
- gboolean (*is_configurable)
- (GtranslatorPlugin *plugin);
-
- /* Padding for future expansion */
- void (*_gtranslator_reserved1) (void);
- void (*_gtranslator_reserved2) (void);
- void (*_gtranslator_reserved3) (void);
- void (*_gtranslator_reserved4) (void);
+ GObjectClass parent_class;
+
+ /* Virtual public methods */
+
+ void (*activate) (GtranslatorPlugin * plugin, GtranslatorWindow * window);
+ void (*deactivate) (GtranslatorPlugin * plugin, GtranslatorWindow * window);
+
+ void (*update_ui) (GtranslatorPlugin * plugin, GtranslatorWindow * window);
+
+ GtkWidget *(*create_configure_dialog) (GtranslatorPlugin * plugin);
+
+ /* Plugins should not override this, it's handled automatically by
+ the GtranslatorPluginClass */
+ gboolean (*is_configurable) (GtranslatorPlugin * plugin);
+
+ /* Padding for future expansion */
+ void (*_gtranslator_reserved1) (void);
+ void (*_gtranslator_reserved2) (void);
+ void (*_gtranslator_reserved3) (void);
+ void (*_gtranslator_reserved4) (void);
};
/*
* Public methods
*/
-GType gtranslator_plugin_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_plugin_get_type (void)
+ G_GNUC_CONST;
+
+ void gtranslator_plugin_activate (GtranslatorPlugin * plugin,
+ GtranslatorWindow * window);
+ void gtranslator_plugin_deactivate (GtranslatorPlugin * plugin,
+ GtranslatorWindow * window);
-void gtranslator_plugin_activate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window);
-void gtranslator_plugin_deactivate (GtranslatorPlugin *plugin,
- GtranslatorWindow *window);
-
-void gtranslator_plugin_update_ui (GtranslatorPlugin *plugin,
- GtranslatorWindow *window);
+ void gtranslator_plugin_update_ui (GtranslatorPlugin * plugin,
+ GtranslatorWindow * window);
-gboolean gtranslator_plugin_is_configurable (GtranslatorPlugin *plugin);
-GtkWidget *gtranslator_plugin_create_configure_dialog
- (GtranslatorPlugin *plugin);
+ gboolean gtranslator_plugin_is_configurable (GtranslatorPlugin * plugin);
+ GtkWidget *gtranslator_plugin_create_configure_dialog
+ (GtranslatorPlugin * plugin);
/**
* GTR_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE):
@@ -239,7 +234,4 @@ object_name##_register_type (GTypeModule *module) \
GTR_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;)
G_END_DECLS
-
-#endif /* __GTR_PLUGIN_H__ */
-
-
+#endif /* __GTR_PLUGIN_H__ */
diff --git a/src/plugin-system/plugins-engine.c b/src/plugin-system/plugins-engine.c
index 394edb4..f25752c 100644
--- a/src/plugin-system/plugins-engine.c
+++ b/src/plugin-system/plugins-engine.c
@@ -59,601 +59,604 @@
/* Signals */
enum
{
- ACTIVATE_PLUGIN,
- DEACTIVATE_PLUGIN,
- LAST_SIGNAL
+ ACTIVATE_PLUGIN,
+ DEACTIVATE_PLUGIN,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
-G_DEFINE_TYPE(GtranslatorPluginsEngine, gtranslator_plugins_engine, G_TYPE_OBJECT)
-
-struct _GtranslatorPluginsEnginePrivate
+G_DEFINE_TYPE (GtranslatorPluginsEngine, gtranslator_plugins_engine,
+ G_TYPE_OBJECT)
+ struct _GtranslatorPluginsEnginePrivate
+ {
+ GList *plugin_list;
+ GConfClient *gconf_client;
+ };
+
+ GtranslatorPluginsEngine *default_engine = NULL;
+
+ static void
+ gtranslator_plugins_engine_active_plugins_changed (GConfClient *
+ client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data);
+ static void
+ gtranslator_plugins_engine_activate_plugin_real
+ (GtranslatorPluginsEngine * engine, GtranslatorPluginInfo * info);
+ static void
+ gtranslator_plugins_engine_deactivate_plugin_real
+ (GtranslatorPluginsEngine * engine, GtranslatorPluginInfo * info);
+
+ static void
+ gtranslator_plugins_engine_load_dir (GtranslatorPluginsEngine * engine,
+ const gchar * dir,
+ GSList * active_plugins)
{
- GList *plugin_list;
- GConfClient *gconf_client;
-};
+ GError *error = NULL;
+ GDir *d;
+ const gchar *dirent;
+
+ g_return_if_fail (engine->priv->gconf_client != NULL);
+ g_return_if_fail (dir != NULL);
+
+ DEBUG_PRINT ("DIR: %s", dir);
+
+ d = g_dir_open (dir, 0, &error);
+ if (!d)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ while ((dirent = g_dir_read_name (d)))
+ {
+ if (g_str_has_suffix (dirent, PLUGIN_EXT))
+ {
+ gchar *plugin_file;
+ GtranslatorPluginInfo *info;
-GtranslatorPluginsEngine *default_engine = NULL;
+ plugin_file = g_build_filename (dir, dirent, NULL);
+ info = _gtranslator_plugin_info_new (plugin_file);
+ g_free (plugin_file);
-static void gtranslator_plugins_engine_active_plugins_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-static void gtranslator_plugins_engine_activate_plugin_real (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info);
-static void gtranslator_plugins_engine_deactivate_plugin_real (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info);
+ if (info == NULL)
+ continue;
-static void
-gtranslator_plugins_engine_load_dir (GtranslatorPluginsEngine *engine,
- const gchar *dir,
- GSList *active_plugins)
-{
- GError *error = NULL;
- GDir *d;
- const gchar *dirent;
+ /* If a plugin with this name has already been loaded
+ * drop this one (user plugins override system plugins) */
+ if (gtranslator_plugins_engine_get_plugin_info
+ (engine, info->module_name) != NULL)
+ {
+ g_warning ("Two or more plugins named '%s'. "
+ "Only the first will be considered.\n",
+ info->module_name);
- g_return_if_fail (engine->priv->gconf_client != NULL);
- g_return_if_fail (dir != NULL);
+ _gtranslator_plugin_info_unref (info);
- DEBUG_PRINT ( "DIR: %s", dir);
+ continue;
+ }
- d = g_dir_open (dir, 0, &error);
- if (!d)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- return;
- }
+ /* Actually, the plugin will be activated when reactivate_all
+ * will be called for the first time. */
+ info->active = g_slist_find_custom (active_plugins,
+ info->module_name,
+ (GCompareFunc) strcmp) != NULL;
- while ((dirent = g_dir_read_name (d)))
- {
- if (g_str_has_suffix (dirent, PLUGIN_EXT))
- {
- gchar *plugin_file;
- GtranslatorPluginInfo *info;
-
- plugin_file = g_build_filename (dir, dirent, NULL);
- info = _gtranslator_plugin_info_new (plugin_file);
- g_free (plugin_file);
-
- if (info == NULL)
- continue;
-
- /* If a plugin with this name has already been loaded
- * drop this one (user plugins override system plugins) */
- if (gtranslator_plugins_engine_get_plugin_info (engine, info->module_name) != NULL)
- {
- g_warning ("Two or more plugins named '%s'. "
- "Only the first will be considered.\n",
- info->module_name);
-
- _gtranslator_plugin_info_unref (info);
-
- continue;
- }
-
- /* Actually, the plugin will be activated when reactivate_all
- * will be called for the first time. */
- info->active = g_slist_find_custom (active_plugins,
- info->module_name,
- (GCompareFunc)strcmp) != NULL;
-
- engine->priv->plugin_list = g_list_prepend (engine->priv->plugin_list, info);
-
- DEBUG_PRINT ( "Plugin %s loaded", info->name);
- }
+ engine->priv->plugin_list =
+ g_list_prepend (engine->priv->plugin_list, info);
+
+ DEBUG_PRINT ("Plugin %s loaded", info->name);
}
+ }
- g_dir_close (d);
+ g_dir_close (d);
}
static void
-gtranslator_plugins_engine_load_all (GtranslatorPluginsEngine *engine)
+gtranslator_plugins_engine_load_all (GtranslatorPluginsEngine * engine)
{
- GSList *active_plugins = NULL;
- const gchar *home;
- const gchar *pdirs_env;
- gchar **pdirs;
- int i;
-
- active_plugins = gconf_client_get_list (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- GCONF_VALUE_STRING,
- NULL);
-
- /* load user's plugins */
- home = g_get_home_dir ();
- if (home == NULL)
- {
- g_warning ("Could not get HOME directory\n");
- }
- else
- {
- gchar *pdir;
-
- pdir = g_build_filename (home,
- USER_GTR_PLUGINS_LOCATION,
- NULL);
-
- if (g_file_test (pdir, G_FILE_TEST_IS_DIR))
- gtranslator_plugins_engine_load_dir (engine, pdir, active_plugins);
-
- g_free (pdir);
- }
-
- pdirs_env = g_getenv ("GTR_PLUGINS_PATH");
- /* What if no env var is set? We use the default location(s)! */
- if (pdirs_env == NULL)
- pdirs_env=GTR_PLUGINDIR;
-
- /* FIXME, workaround to avoid enviroment variables on windows */
+ GSList *active_plugins = NULL;
+ const gchar *home;
+ const gchar *pdirs_env;
+ gchar **pdirs;
+ int i;
+
+ active_plugins = gconf_client_get_list (engine->priv->gconf_client,
+ GTR_PLUGINS_ENGINE_KEY,
+ GCONF_VALUE_STRING, NULL);
+
+ /* load user's plugins */
+ home = g_get_home_dir ();
+ if (home == NULL)
+ {
+ g_warning ("Could not get HOME directory\n");
+ }
+ else
+ {
+ gchar *pdir;
+
+ pdir = g_build_filename (home, USER_GTR_PLUGINS_LOCATION, NULL);
+
+ if (g_file_test (pdir, G_FILE_TEST_IS_DIR))
+ gtranslator_plugins_engine_load_dir (engine, pdir, active_plugins);
+
+ g_free (pdir);
+ }
+
+ pdirs_env = g_getenv ("GTR_PLUGINS_PATH");
+ /* What if no env var is set? We use the default location(s)! */
+ if (pdirs_env == NULL)
+ pdirs_env = GTR_PLUGINDIR;
+
+ /* FIXME, workaround to avoid enviroment variables on windows */
#ifdef G_OS_WIN32
- pdirs_env = gtranslator_utils_get_win32_plugindir();
+ pdirs_env = gtranslator_utils_get_win32_plugindir ();
#endif
- DEBUG_PRINT ( "GTR_PLUGINS_PATH=%s", pdirs_env);
- pdirs = g_strsplit (pdirs_env, G_SEARCHPATH_SEPARATOR_S, 0);
+ DEBUG_PRINT ("GTR_PLUGINS_PATH=%s", pdirs_env);
+ pdirs = g_strsplit (pdirs_env, G_SEARCHPATH_SEPARATOR_S, 0);
- for (i = 0; pdirs[i] != NULL; i++)
- gtranslator_plugins_engine_load_dir (engine, pdirs[i], active_plugins);
+ for (i = 0; pdirs[i] != NULL; i++)
+ gtranslator_plugins_engine_load_dir (engine, pdirs[i], active_plugins);
- g_strfreev (pdirs);
- g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
- g_slist_free (active_plugins);
+ g_strfreev (pdirs);
+ g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
+ g_slist_free (active_plugins);
}
static void
-gtranslator_plugins_engine_init (GtranslatorPluginsEngine *engine)
+gtranslator_plugins_engine_init (GtranslatorPluginsEngine * engine)
{
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- if (!g_module_supported ())
- {
- g_warning ("gtranslator is not able to initialize the plugins engine.");
- return;
- }
+ if (!g_module_supported ())
+ {
+ g_warning ("gtranslator is not able to initialize the plugins engine.");
+ return;
+ }
- engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
- GTR_TYPE_PLUGINS_ENGINE,
- GtranslatorPluginsEnginePrivate);
+ engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
+ GTR_TYPE_PLUGINS_ENGINE,
+ GtranslatorPluginsEnginePrivate);
- engine->priv->gconf_client = gconf_client_get_default ();
- g_return_if_fail (engine->priv->gconf_client != NULL);
+ engine->priv->gconf_client = gconf_client_get_default ();
+ g_return_if_fail (engine->priv->gconf_client != NULL);
- gconf_client_add_dir (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
+ gconf_client_add_dir (engine->priv->gconf_client,
+ GTR_PLUGINS_ENGINE_BASE_KEY,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- gconf_client_notify_add (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- gtranslator_plugins_engine_active_plugins_changed,
- engine, NULL, NULL);
+ gconf_client_notify_add (engine->priv->gconf_client,
+ GTR_PLUGINS_ENGINE_KEY,
+ gtranslator_plugins_engine_active_plugins_changed,
+ engine, NULL, NULL);
- gtranslator_plugins_engine_load_all (engine);
+ gtranslator_plugins_engine_load_all (engine);
}
void
-gtranslator_plugins_engine_garbage_collect (GtranslatorPluginsEngine *engine)
+gtranslator_plugins_engine_garbage_collect (GtranslatorPluginsEngine * engine)
{
- GType *module_types = g_type_children (GTR_TYPE_MODULE, NULL);
- unsigned i;
- for (i = 0; module_types[i] != 0; i++)
- {
- gpointer klass = g_type_class_peek (module_types[i]);
- if (klass != NULL)
- gtranslator_module_class_garbage_collect (klass);
- }
- g_free (module_types);
+ GType *module_types = g_type_children (GTR_TYPE_MODULE, NULL);
+ unsigned i;
+ for (i = 0; module_types[i] != 0; i++)
+ {
+ gpointer klass = g_type_class_peek (module_types[i]);
+ if (klass != NULL)
+ gtranslator_module_class_garbage_collect (klass);
+ }
+ g_free (module_types);
}
static void
-gtranslator_plugins_engine_finalize (GObject *object)
+gtranslator_plugins_engine_finalize (GObject * object)
{
- GtranslatorPluginsEngine *engine = GTR_PLUGINS_ENGINE (object);
+ GtranslatorPluginsEngine *engine = GTR_PLUGINS_ENGINE (object);
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
#ifdef ENABLE_PYTHON
- /* Note: that this may cause finalization of objects (typically
- * the GtranslatorWindow) by running the garbage collector. Since some
- * of the plugin may have installed callbacks upon object
- * finalization (typically they need to free the WindowData)
- * it must run before we get rid of the plugins.
- */
- gtranslator_python_shutdown ();
+ /* Note: that this may cause finalization of objects (typically
+ * the GtranslatorWindow) by running the garbage collector. Since some
+ * of the plugin may have installed callbacks upon object
+ * finalization (typically they need to free the WindowData)
+ * it must run before we get rid of the plugins.
+ */
+ gtranslator_python_shutdown ();
#endif
- g_return_if_fail (engine->priv->gconf_client != NULL);
+ g_return_if_fail (engine->priv->gconf_client != NULL);
- g_list_foreach (engine->priv->plugin_list,
- (GFunc) _gtranslator_plugin_info_unref, NULL);
- g_list_free (engine->priv->plugin_list);
+ g_list_foreach (engine->priv->plugin_list,
+ (GFunc) _gtranslator_plugin_info_unref, NULL);
+ g_list_free (engine->priv->plugin_list);
- g_object_unref (engine->priv->gconf_client);
+ g_object_unref (engine->priv->gconf_client);
}
static void
-gtranslator_plugins_engine_class_init (GtranslatorPluginsEngineClass *klass)
+gtranslator_plugins_engine_class_init (GtranslatorPluginsEngineClass * klass)
{
- GType the_type = G_TYPE_FROM_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gtranslator_plugins_engine_finalize;
- klass->activate_plugin = gtranslator_plugins_engine_activate_plugin_real;
- klass->deactivate_plugin = gtranslator_plugins_engine_deactivate_plugin_real;
-
- signals[ACTIVATE_PLUGIN] =
- g_signal_new ("activate-plugin",
- the_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorPluginsEngineClass, activate_plugin),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- 1,
- GTR_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- signals[DEACTIVATE_PLUGIN] =
- g_signal_new ("deactivate-plugin",
- the_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorPluginsEngineClass, deactivate_plugin),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- 1,
- GTR_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- g_type_class_add_private (klass, sizeof (GtranslatorPluginsEnginePrivate));
+ GType the_type = G_TYPE_FROM_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtranslator_plugins_engine_finalize;
+ klass->activate_plugin = gtranslator_plugins_engine_activate_plugin_real;
+ klass->deactivate_plugin =
+ gtranslator_plugins_engine_deactivate_plugin_real;
+
+ signals[ACTIVATE_PLUGIN] =
+ g_signal_new ("activate-plugin",
+ the_type,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtranslatorPluginsEngineClass,
+ activate_plugin), NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1,
+ GTR_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ signals[DEACTIVATE_PLUGIN] =
+ g_signal_new ("deactivate-plugin",
+ the_type,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtranslatorPluginsEngineClass,
+ deactivate_plugin), NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1,
+ GTR_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorPluginsEnginePrivate));
}
GtranslatorPluginsEngine *
gtranslator_plugins_engine_get_default (void)
{
- if (default_engine != NULL)
- return default_engine;
-
- default_engine = GTR_PLUGINS_ENGINE (g_object_new (GTR_TYPE_PLUGINS_ENGINE, NULL));
- g_object_add_weak_pointer (G_OBJECT (default_engine),
- (gpointer) &default_engine);
- return default_engine;
+ if (default_engine != NULL)
+ return default_engine;
+
+ default_engine =
+ GTR_PLUGINS_ENGINE (g_object_new (GTR_TYPE_PLUGINS_ENGINE, NULL));
+ g_object_add_weak_pointer (G_OBJECT (default_engine),
+ (gpointer) & default_engine);
+ return default_engine;
}
const GList *
-gtranslator_plugins_engine_get_plugin_list (GtranslatorPluginsEngine *engine)
+gtranslator_plugins_engine_get_plugin_list (GtranslatorPluginsEngine * engine)
{
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- return engine->priv->plugin_list;
+ return engine->priv->plugin_list;
}
static gint
-compare_plugin_info_and_name (GtranslatorPluginInfo *info,
- const gchar *module_name)
+compare_plugin_info_and_name (GtranslatorPluginInfo * info,
+ const gchar * module_name)
{
- return strcmp (info->module_name, module_name);
+ return strcmp (info->module_name, module_name);
}
GtranslatorPluginInfo *
-gtranslator_plugins_engine_get_plugin_info (GtranslatorPluginsEngine *engine,
- const gchar *name)
+gtranslator_plugins_engine_get_plugin_info (GtranslatorPluginsEngine * engine,
+ const gchar * name)
{
- GList *l = g_list_find_custom (engine->priv->plugin_list,
- name,
- (GCompareFunc) compare_plugin_info_and_name);
- return l == NULL ? NULL : (GtranslatorPluginInfo *) l->data;
+ GList *l = g_list_find_custom (engine->priv->plugin_list,
+ name,
+ (GCompareFunc) compare_plugin_info_and_name);
+ return l == NULL ? NULL : (GtranslatorPluginInfo *) l->data;
}
static gboolean
-load_plugin_module (GtranslatorPluginInfo *info)
+load_plugin_module (GtranslatorPluginInfo * info)
{
- gchar *dirname;
+ gchar *dirname;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- g_return_val_if_fail (info != NULL, FALSE);
- g_return_val_if_fail (info->file != NULL, FALSE);
- g_return_val_if_fail (info->module_name != NULL, FALSE);
- g_return_val_if_fail (info->plugin == NULL, FALSE);
- g_return_val_if_fail (info->available, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info->file != NULL, FALSE);
+ g_return_val_if_fail (info->module_name != NULL, FALSE);
+ g_return_val_if_fail (info->plugin == NULL, FALSE);
+ g_return_val_if_fail (info->available, FALSE);
- dirname = g_path_get_dirname (info->file);
- g_return_val_if_fail (dirname != NULL, FALSE);
+ dirname = g_path_get_dirname (info->file);
+ g_return_val_if_fail (dirname != NULL, FALSE);
#ifdef ENABLE_PYTHON
- if (info->module_type == GTR_TYPE_PYTHON_MODULE)
+ if (info->module_type == GTR_TYPE_PYTHON_MODULE)
+ {
+ if (!gtranslator_python_init ())
{
- if (!gtranslator_python_init ())
- {
- /* Mark plugin as unavailable and fail */
- info->available = FALSE;
- g_warning ("Cannot load Python plugin '%s' since gtranslator "
- "was not able to initialize the Python interpreter.",
- info->name);
- }
+ /* Mark plugin as unavailable and fail */
+ info->available = FALSE;
+ g_warning ("Cannot load Python plugin '%s' since gtranslator "
+ "was not able to initialize the Python interpreter.",
+ info->name);
}
+ }
#endif
- info->module = GTR_MODULE (g_object_new (info->module_type,
- "path", dirname,
- "module-name", info->module_name,
- NULL));
+ info->module = GTR_MODULE (g_object_new (info->module_type,
+ "path", dirname,
+ "module-name", info->module_name,
+ NULL));
- g_free (dirname);
+ g_free (dirname);
- if (!g_type_module_use (G_TYPE_MODULE (info->module)))
- {
- g_warning ("Cannot load plugin '%s' since file '%s' cannot be read.",
- gtranslator_module_get_module_name (info->module),
- gtranslator_module_get_path (info->module));
+ if (!g_type_module_use (G_TYPE_MODULE (info->module)))
+ {
+ g_warning ("Cannot load plugin '%s' since file '%s' cannot be read.",
+ gtranslator_module_get_module_name (info->module),
+ gtranslator_module_get_path (info->module));
- g_object_unref (G_OBJECT (info->module));
- info->module = NULL;
+ g_object_unref (G_OBJECT (info->module));
+ info->module = NULL;
- /* Mark plugin as unavailable and fail. */
- info->available = FALSE;
-
- return FALSE;
- }
+ /* Mark plugin as unavailable and fail. */
+ info->available = FALSE;
+
+ return FALSE;
+ }
- info->plugin = GTR_PLUGIN (gtranslator_module_new_object (info->module));
+ info->plugin = GTR_PLUGIN (gtranslator_module_new_object (info->module));
- g_type_module_unuse (G_TYPE_MODULE (info->module));
+ g_type_module_unuse (G_TYPE_MODULE (info->module));
- DEBUG_PRINT ( "End");
+ DEBUG_PRINT ("End");
- return TRUE;
+ return TRUE;
}
static void
-save_active_plugin_list (GtranslatorPluginsEngine *engine)
+save_active_plugin_list (GtranslatorPluginsEngine * engine)
{
- GSList *active_plugins = NULL;
- GList *l;
- gboolean res;
-
- for (l = engine->priv->plugin_list; l != NULL; l = l->next)
+ GSList *active_plugins = NULL;
+ GList *l;
+ gboolean res;
+
+ for (l = engine->priv->plugin_list; l != NULL; l = l->next)
+ {
+ const GtranslatorPluginInfo *info =
+ (const GtranslatorPluginInfo *) l->data;
+ if (info->active)
{
- const GtranslatorPluginInfo *info = (const GtranslatorPluginInfo *) l->data;
- if (info->active)
- {
- active_plugins = g_slist_prepend (active_plugins,
- info->module_name);
- }
+ active_plugins = g_slist_prepend (active_plugins,
+ info->module_name);
}
+ }
- res = gconf_client_set_list (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- GCONF_VALUE_STRING,
- active_plugins,
- NULL);
+ res = gconf_client_set_list (engine->priv->gconf_client,
+ GTR_PLUGINS_ENGINE_KEY,
+ GCONF_VALUE_STRING, active_plugins, NULL);
- if (!res)
- g_warning ("Error saving the list of active plugins.");
+ if (!res)
+ g_warning ("Error saving the list of active plugins.");
- g_slist_free (active_plugins);
+ g_slist_free (active_plugins);
}
static void
-gtranslator_plugins_engine_activate_plugin_real (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info)
+gtranslator_plugins_engine_activate_plugin_real (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorPluginInfo * info)
{
- gboolean res = TRUE;
-
- if (info->active || !info->available)
- return;
-
- if (info->plugin == NULL)
- res = load_plugin_module (info);
-
- if (res)
- {
- const GList *wins = gtranslator_application_get_windows (gtranslator_application_get_default ());
- for (; wins != NULL; wins = wins->next)
- gtranslator_plugin_activate (info->plugin, GTR_WINDOW (wins->data));
-
- info->active = TRUE;
- }
- else
- g_warning ("Error activating plugin '%s'", info->name);
+ gboolean res = TRUE;
+
+ if (info->active || !info->available)
+ return;
+
+ if (info->plugin == NULL)
+ res = load_plugin_module (info);
+
+ if (res)
+ {
+ const GList *wins =
+ gtranslator_application_get_windows
+ (gtranslator_application_get_default ());
+ for (; wins != NULL; wins = wins->next)
+ gtranslator_plugin_activate (info->plugin, GTR_WINDOW (wins->data));
+
+ info->active = TRUE;
+ }
+ else
+ g_warning ("Error activating plugin '%s'", info->name);
}
gboolean
-gtranslator_plugins_engine_activate_plugin (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info)
+gtranslator_plugins_engine_activate_plugin (GtranslatorPluginsEngine * engine,
+ GtranslatorPluginInfo * info)
{
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- if (!info->available)
- return FALSE;
-
- if (info->active)
- return TRUE;
+ if (!info->available)
+ return FALSE;
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
- if (info->active)
- save_active_plugin_list (engine);
+ if (info->active)
+ return TRUE;
+
+ g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
+ if (info->active)
+ save_active_plugin_list (engine);
- return info->active;
+ return info->active;
}
static void
-gtranslator_plugins_engine_deactivate_plugin_real (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info)
+gtranslator_plugins_engine_deactivate_plugin_real (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorPluginInfo *
+ info)
{
- const GList *wins;
+ const GList *wins;
- if (!info->active || !info->available)
- return;
+ if (!info->active || !info->available)
+ return;
- wins = gtranslator_application_get_windows (gtranslator_application_get_default ());
- for (; wins != NULL; wins = wins->next)
- gtranslator_plugin_deactivate (info->plugin, GTR_WINDOW (wins->data));
+ wins =
+ gtranslator_application_get_windows (gtranslator_application_get_default
+ ());
+ for (; wins != NULL; wins = wins->next)
+ gtranslator_plugin_deactivate (info->plugin, GTR_WINDOW (wins->data));
- info->active = FALSE;
+ info->active = FALSE;
}
gboolean
-gtranslator_plugins_engine_deactivate_plugin (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info)
+gtranslator_plugins_engine_deactivate_plugin (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorPluginInfo * info)
{
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- if (!info->active || !info->available)
- return TRUE;
+ if (!info->active || !info->available)
+ return TRUE;
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
- if (!info->active)
- save_active_plugin_list (engine);
+ g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
+ if (!info->active)
+ save_active_plugin_list (engine);
- return !info->active;
+ return !info->active;
}
static void
-reactivate_all (GtranslatorPluginsEngine *engine,
- GtranslatorWindow *window)
+reactivate_all (GtranslatorPluginsEngine * engine, GtranslatorWindow * window)
{
- GList *pl;
+ GList *pl;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
- //gtranslator_debug (DEBUG_PLUGINS);
+ for (pl = engine->priv->plugin_list; pl; pl = pl->next)
+ {
+ gboolean res = TRUE;
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
+ GtranslatorPluginInfo *info = (GtranslatorPluginInfo *) pl->data;
+
+ /* If plugin is not available, don't try to activate/load it */
+ if (info->available && info->active)
{
- gboolean res = TRUE;
-
- GtranslatorPluginInfo *info = (GtranslatorPluginInfo*)pl->data;
-
- /* If plugin is not available, don't try to activate/load it */
- if (info->available && info->active)
- {
- if (info->plugin == NULL)
- res = load_plugin_module (info);
-
- if (res)
- gtranslator_plugin_activate (info->plugin,
- window);
- }
+ if (info->plugin == NULL)
+ res = load_plugin_module (info);
+
+ if (res)
+ gtranslator_plugin_activate (info->plugin, window);
}
-
- DEBUG_PRINT ( "End");
+ }
+
+ DEBUG_PRINT ("End");
}
void
-gtranslator_plugins_engine_update_plugins_ui (GtranslatorPluginsEngine *engine,
- GtranslatorWindow *window,
- gboolean new_window)
+gtranslator_plugins_engine_update_plugins_ui (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorWindow * window,
+ gboolean new_window)
{
- GList *pl;
+ GList *pl;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTR_IS_WINDOW (window));
- if (new_window)
- reactivate_all (engine, window);
+ if (new_window)
+ reactivate_all (engine, window);
- /* updated ui of all the plugins that implement update_ui */
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- GtranslatorPluginInfo *info = (GtranslatorPluginInfo*)pl->data;
-
- if (!info->available || !info->active)
- continue;
-
- DEBUG_PRINT ( "Updating UI of %s", info->name);
-
- gtranslator_plugin_update_ui (info->plugin, window);
- }
+ /* updated ui of all the plugins that implement update_ui */
+ for (pl = engine->priv->plugin_list; pl; pl = pl->next)
+ {
+ GtranslatorPluginInfo *info = (GtranslatorPluginInfo *) pl->data;
+
+ if (!info->available || !info->active)
+ continue;
+
+ DEBUG_PRINT ("Updating UI of %s", info->name);
+
+ gtranslator_plugin_update_ui (info->plugin, window);
+ }
}
-void
-gtranslator_plugins_engine_configure_plugin (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info,
- GtkWindow *parent)
+void
+gtranslator_plugins_engine_configure_plugin (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorPluginInfo * info,
+ GtkWindow * parent)
{
- GtkWidget *conf_dlg;
-
- GtkWindowGroup *wg;
-
- //gtranslator_debug (DEBUG_PLUGINS);
+ GtkWidget *conf_dlg;
- g_return_if_fail (info != NULL);
+ GtkWindowGroup *wg;
- conf_dlg = gtranslator_plugin_create_configure_dialog (info->plugin);
- g_return_if_fail (conf_dlg != NULL);
- gtk_window_set_transient_for (GTK_WINDOW (conf_dlg),
- parent);
+ //gtranslator_debug (DEBUG_PLUGINS);
- wg = parent->group;
- if (wg == NULL)
- {
- wg = gtk_window_group_new ();
- gtk_window_group_add_window (wg, parent);
- }
-
- gtk_window_group_add_window (wg,
- GTK_WINDOW (conf_dlg));
-
- gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);
- gtk_widget_show (conf_dlg);
+ g_return_if_fail (info != NULL);
+
+ conf_dlg = gtranslator_plugin_create_configure_dialog (info->plugin);
+ g_return_if_fail (conf_dlg != NULL);
+ gtk_window_set_transient_for (GTK_WINDOW (conf_dlg), parent);
+
+ wg = parent->group;
+ if (wg == NULL)
+ {
+ wg = gtk_window_group_new ();
+ gtk_window_group_add_window (wg, parent);
+ }
+
+ gtk_window_group_add_window (wg, GTK_WINDOW (conf_dlg));
+
+ gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);
+ gtk_widget_show (conf_dlg);
}
-static void
-gtranslator_plugins_engine_active_plugins_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+static void
+gtranslator_plugins_engine_active_plugins_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GtranslatorPluginsEngine *engine;
- GList *pl;
- gboolean to_activate;
- GSList *active_plugins;
+ GtranslatorPluginsEngine *engine;
+ GList *pl;
+ gboolean to_activate;
+ GSList *active_plugins;
- //gtranslator_debug (DEBUG_PLUGINS);
+ //gtranslator_debug (DEBUG_PLUGINS);
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
+ g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (entry->value != NULL);
- engine = GTR_PLUGINS_ENGINE (user_data);
-
- if (!((entry->value->type == GCONF_VALUE_LIST) &&
- (gconf_value_get_list_type (entry->value) == GCONF_VALUE_STRING)))
- {
- g_warning ("The gconf key '%s' may be corrupted.", GTR_PLUGINS_ENGINE_KEY);
- return;
- }
-
- active_plugins = gconf_client_get_list (engine->priv->gconf_client,
- GTR_PLUGINS_ENGINE_KEY,
- GCONF_VALUE_STRING,
- NULL);
+ engine = GTR_PLUGINS_ENGINE (user_data);
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- GtranslatorPluginInfo *info = (GtranslatorPluginInfo*)pl->data;
+ if (!((entry->value->type == GCONF_VALUE_LIST) &&
+ (gconf_value_get_list_type (entry->value) == GCONF_VALUE_STRING)))
+ {
+ g_warning ("The gconf key '%s' may be corrupted.",
+ GTR_PLUGINS_ENGINE_KEY);
+ return;
+ }
- if (!info->available)
- continue;
+ active_plugins = gconf_client_get_list (engine->priv->gconf_client,
+ GTR_PLUGINS_ENGINE_KEY,
+ GCONF_VALUE_STRING, NULL);
- to_activate = (g_slist_find_custom (active_plugins,
- info->module_name,
- (GCompareFunc)strcmp) != NULL);
+ for (pl = engine->priv->plugin_list; pl; pl = pl->next)
+ {
+ GtranslatorPluginInfo *info = (GtranslatorPluginInfo *) pl->data;
- if (!info->active && to_activate)
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
- else if (info->active && !to_activate)
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
- }
+ if (!info->available)
+ continue;
- g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
- g_slist_free (active_plugins);
-}
+ to_activate = (g_slist_find_custom (active_plugins,
+ info->module_name,
+ (GCompareFunc) strcmp) != NULL);
+ if (!info->active && to_activate)
+ g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
+ else if (info->active && !to_activate)
+ g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
+ }
+ g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
+ g_slist_free (active_plugins);
+}
diff --git a/src/plugin-system/plugins-engine.h b/src/plugin-system/plugins-engine.h
index 898aab3..a18da8b 100644
--- a/src/plugin-system/plugins-engine.h
+++ b/src/plugin-system/plugins-engine.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
/*
* Modified by the gtranslator Team, 2002-2005. See the AUTHORS file for a
* list of people on the gtranslator Team.
@@ -37,64 +37,80 @@
#include "plugin.h"
G_BEGIN_DECLS
-
#define GTR_TYPE_PLUGINS_ENGINE (gtranslator_plugins_engine_get_type ())
#define GTR_PLUGINS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTR_TYPE_PLUGINS_ENGINE, GtranslatorPluginsEngine))
#define GTR_PLUGINS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTR_TYPE_PLUGINS_ENGINE, GtranslatorPluginsEngineClass))
#define GTR_IS_PLUGINS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTR_TYPE_PLUGINS_ENGINE))
#define GTR_IS_PLUGINS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_PLUGINS_ENGINE))
#define GTR_PLUGINS_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTR_TYPE_PLUGINS_ENGINE, GtranslatorPluginsEngineClass))
-
-typedef struct _GtranslatorPluginsEngine GtranslatorPluginsEngine;
-typedef struct _GtranslatorPluginsEnginePrivate GtranslatorPluginsEnginePrivate;
+typedef struct _GtranslatorPluginsEngine GtranslatorPluginsEngine;
+typedef struct _GtranslatorPluginsEnginePrivate
+ GtranslatorPluginsEnginePrivate;
struct _GtranslatorPluginsEngine
{
- GObject parent;
- GtranslatorPluginsEnginePrivate *priv;
+ GObject parent;
+ GtranslatorPluginsEnginePrivate *priv;
};
-typedef struct _GtranslatorPluginsEngineClass GtranslatorPluginsEngineClass;
+typedef struct _GtranslatorPluginsEngineClass GtranslatorPluginsEngineClass;
struct _GtranslatorPluginsEngineClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* activate_plugin) (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info);
+ void (*activate_plugin) (GtranslatorPluginsEngine * engine,
+ GtranslatorPluginInfo * info);
- void (* deactivate_plugin) (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info);
+ void (*deactivate_plugin) (GtranslatorPluginsEngine * engine,
+ GtranslatorPluginInfo * info);
};
-GType gtranslator_plugins_engine_get_type (void) G_GNUC_CONST;
-
-GtranslatorPluginsEngine *gtranslator_plugins_engine_get_default (void);
-
-void gtranslator_plugins_engine_garbage_collect (GtranslatorPluginsEngine *engine);
-
-const GList *gtranslator_plugins_engine_get_plugin_list (GtranslatorPluginsEngine *engine);
-
-GtranslatorPluginInfo *gtranslator_plugins_engine_get_plugin_info (GtranslatorPluginsEngine *engine,
- const gchar *name);
-
-gboolean gtranslator_plugins_engine_activate_plugin (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info);
-gboolean gtranslator_plugins_engine_deactivate_plugin (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info);
-
-void gtranslator_plugins_engine_configure_plugin (GtranslatorPluginsEngine *engine,
- GtranslatorPluginInfo *info,
- GtkWindow *parent);
+GType
+gtranslator_plugins_engine_get_type (void)
+ G_GNUC_CONST;
+
+ GtranslatorPluginsEngine *gtranslator_plugins_engine_get_default (void);
+
+ void gtranslator_plugins_engine_garbage_collect (GtranslatorPluginsEngine
+ * engine);
+
+ const GList
+ *gtranslator_plugins_engine_get_plugin_list (GtranslatorPluginsEngine *
+ engine);
+
+ GtranslatorPluginInfo
+ *gtranslator_plugins_engine_get_plugin_info (GtranslatorPluginsEngine *
+ engine,
+ const gchar * name);
+
+ gboolean
+ gtranslator_plugins_engine_activate_plugin (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorPluginInfo *
+ info);
+ gboolean
+ gtranslator_plugins_engine_deactivate_plugin (GtranslatorPluginsEngine
+ * engine,
+ GtranslatorPluginInfo *
+ info);
+
+ void
+ gtranslator_plugins_engine_configure_plugin (GtranslatorPluginsEngine *
+ engine,
+ GtranslatorPluginInfo *
+ info, GtkWindow * parent);
/*
* new_window == TRUE if this function is called because a new top window
* has been created
*/
-void gtranslator_plugins_engine_update_plugins_ui (GtranslatorPluginsEngine *engine,
- GtranslatorWindow *window,
- gboolean new_window);
+ void
+ gtranslator_plugins_engine_update_plugins_ui (GtranslatorPluginsEngine
+ * engine,
+ GtranslatorWindow *
+ window,
+ gboolean new_window);
G_END_DECLS
-
-#endif /* __GTR_PLUGINS_ENGINE_H__ */
+#endif /* __GTR_PLUGINS_ENGINE_H__ */
diff --git a/src/po.c b/src/po.c
index 6b9056f..c648d80 100644
--- a/src/po.c
+++ b/src/po.c
@@ -57,101 +57,98 @@
GtranslatorPoPrivate))
-G_DEFINE_TYPE(GtranslatorPo, gtranslator_po, G_TYPE_OBJECT)
-
-struct _GtranslatorPoPrivate
-{
- GFile *location;
-
- /*
- * Gettext's file handle
- */
- po_file_t gettext_po_file;
-
- /*
- * Message iter
- */
- po_message_iterator_t iter;
-
- /*
- * The message domains in this file
- */
- GList *domains;
-
- /*
- * Parsed list of GtrMsgs for the current domains' messagelist
- */
- GList *messages;
-
- /*
- * A pointer to the currently displayed message
- */
- GList *current;
-
- /*
- * The obsolete messages are stored within this gchar.
- */
- gchar *obsolete;
-
- /*
- * Marks if the file was changed;
- */
- guint file_changed : 1;
-
- /*
- * Is the file write-permitted? (read-only)
- */
- gboolean no_write_perms;
-
- /*
- * Translated entries count
- */
- guint translated;
-
- /*
- * Fuzzy entries count
- */
- guint fuzzy;
-
- /*
- * Autosave timeout timer
- */
- guint autosave_timeout;
-
- /*
- * Header object
- */
- GtranslatorHeader *header;
-
- GtranslatorPoState state;
-};
-
-enum
-{
- PROP_0,
- PROP_STATE
-};
-
-static gchar *message_error = NULL;
-
-static void
-gtranslator_po_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+G_DEFINE_TYPE (GtranslatorPo, gtranslator_po, G_TYPE_OBJECT)
+ struct _GtranslatorPoPrivate
+ {
+ GFile *location;
+
+ /*
+ * Gettext's file handle
+ */
+ po_file_t gettext_po_file;
+
+ /*
+ * Message iter
+ */
+ po_message_iterator_t iter;
+
+ /*
+ * The message domains in this file
+ */
+ GList *domains;
+
+ /*
+ * Parsed list of GtrMsgs for the current domains' messagelist
+ */
+ GList *messages;
+
+ /*
+ * A pointer to the currently displayed message
+ */
+ GList *current;
+
+ /*
+ * The obsolete messages are stored within this gchar.
+ */
+ gchar *obsolete;
+
+ /*
+ * Marks if the file was changed;
+ */
+ guint file_changed:1;
+
+ /*
+ * Is the file write-permitted? (read-only)
+ */
+ gboolean no_write_perms;
+
+ /*
+ * Translated entries count
+ */
+ guint translated;
+
+ /*
+ * Fuzzy entries count
+ */
+ guint fuzzy;
+
+ /*
+ * Autosave timeout timer
+ */
+ guint autosave_timeout;
+
+ /*
+ * Header object
+ */
+ GtranslatorHeader *header;
+
+ GtranslatorPoState state;
+ };
+
+ enum
+ {
+ PROP_0,
+ PROP_STATE
+ };
+
+ static gchar *message_error = NULL;
+
+ static void
+ gtranslator_po_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GtranslatorPo *po = GTR_PO (object);
-
- switch (prop_id)
- {
- case PROP_STATE:
- g_value_set_enum (value,
- gtranslator_po_get_state (po));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GtranslatorPo *po = GTR_PO (object);
+
+ switch (prop_id)
+ {
+ case PROP_STATE:
+ g_value_set_enum (value, gtranslator_po_get_state (po));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/*
@@ -159,80 +156,79 @@ gtranslator_po_get_property (GObject *object,
* po-file.
*/
static void
-determine_translation_status(GtranslatorMsg *msg,
- GtranslatorPo *po)
+determine_translation_status (GtranslatorMsg * msg, GtranslatorPo * po)
{
- if(gtranslator_msg_is_fuzzy(msg))
- po->priv->fuzzy++;
- else if(gtranslator_msg_is_translated(msg))
- po->priv->translated++;
+ if (gtranslator_msg_is_fuzzy (msg))
+ po->priv->fuzzy++;
+ else if (gtranslator_msg_is_translated (msg))
+ po->priv->translated++;
}
/*
* Update the count of the completed translated entries.
*/
static void
-gtranslator_po_update_translated_count(GtranslatorPo *po)
+gtranslator_po_update_translated_count (GtranslatorPo * po)
{
- po->priv->translated = 0;
- po->priv->fuzzy = 0;
- g_list_foreach(po->priv->messages,
- (GFunc) determine_translation_status,
- po);
+ po->priv->translated = 0;
+ po->priv->fuzzy = 0;
+ g_list_foreach (po->priv->messages,
+ (GFunc) determine_translation_status, po);
}
static void
-gtranslator_po_init (GtranslatorPo *po)
+gtranslator_po_init (GtranslatorPo * po)
{
- po->priv = GTR_PO_GET_PRIVATE (po);
+ po->priv = GTR_PO_GET_PRIVATE (po);
- po->priv->location = NULL;
- po->priv->gettext_po_file = NULL;
+ po->priv->location = NULL;
+ po->priv->gettext_po_file = NULL;
}
static void
-gtranslator_po_finalize (GObject *object)
+gtranslator_po_finalize (GObject * object)
{
- GtranslatorPo *po = GTR_PO(object);
-
- if (po->priv->messages) {
- g_list_foreach (po->priv->messages, (GFunc)g_object_unref, NULL);
- g_list_free (po->priv->messages);
- }
- if (po->priv->domains)
- {
- g_list_foreach (po->priv->domains, (GFunc)g_free, NULL);
- g_list_free (po->priv->domains);
- }
-
- if (po->priv->location)
- g_object_unref (po->priv->location);
- g_free (po->priv->obsolete);
-
- if (po->priv->gettext_po_file)
- po_file_free (po->priv->gettext_po_file);
-
- G_OBJECT_CLASS (gtranslator_po_parent_class)->finalize(object);
+ GtranslatorPo *po = GTR_PO (object);
+
+ if (po->priv->messages)
+ {
+ g_list_foreach (po->priv->messages, (GFunc) g_object_unref, NULL);
+ g_list_free (po->priv->messages);
+ }
+ if (po->priv->domains)
+ {
+ g_list_foreach (po->priv->domains, (GFunc) g_free, NULL);
+ g_list_free (po->priv->domains);
+ }
+
+ if (po->priv->location)
+ g_object_unref (po->priv->location);
+ g_free (po->priv->obsolete);
+
+ if (po->priv->gettext_po_file)
+ po_file_free (po->priv->gettext_po_file);
+
+ G_OBJECT_CLASS (gtranslator_po_parent_class)->finalize (object);
}
static void
-gtranslator_po_class_init (GtranslatorPoClass *klass)
+gtranslator_po_class_init (GtranslatorPoClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorPoPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorPoPrivate));
- object_class->finalize = gtranslator_po_finalize;
- object_class->get_property = gtranslator_po_get_property;
+ object_class->finalize = gtranslator_po_finalize;
+ object_class->get_property = gtranslator_po_get_property;
- g_object_class_install_property (object_class,
- PROP_STATE,
- g_param_spec_enum ("state",
- "State",
- "The po's state",
- GTR_TYPE_PO_STATE,
- GTR_PO_STATE_SAVED,
- G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_STATE,
+ g_param_spec_enum ("state",
+ "State",
+ "The po's state",
+ GTR_TYPE_PO_STATE,
+ GTR_PO_STATE_SAVED,
+ G_PARAM_READABLE));
}
/*
@@ -241,49 +237,50 @@ gtranslator_po_class_init (GtranslatorPoClass *klass)
GQuark
gtranslator_po_error_quark (void)
{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("gtranslator_po_parser_error");
- return quark;
+ static GQuark quark = 0;
+ if (!quark)
+ quark = g_quark_from_static_string ("gtranslator_po_parser_error");
+ return quark;
}
static void
-on_gettext_po_xerror(gint severity,
- po_message_t message,
- const gchar *filename, size_t lineno, size_t column,
- gint multiline_p, const gchar *message_text)
+on_gettext_po_xerror (gint severity,
+ po_message_t message,
+ const gchar * filename, size_t lineno, size_t column,
+ gint multiline_p, const gchar * message_text)
{
- message_error = g_strdup(message_text);
+ message_error = g_strdup (message_text);
}
static void
-on_gettext_po_xerror2(gint severity,
- po_message_t message1,
- const gchar *filename1, size_t lineno1, size_t column1,
- gint multiline_p1, const gchar *message_text1,
- po_message_t message2,
- const gchar *filename2, size_t lineno2, size_t column2,
- gint multiline_p2, const gchar *message_text2)
+on_gettext_po_xerror2 (gint severity,
+ po_message_t message1,
+ const gchar * filename1, size_t lineno1,
+ size_t column1, gint multiline_p1,
+ const gchar * message_text1, po_message_t message2,
+ const gchar * filename2, size_t lineno2,
+ size_t column2, gint multiline_p2,
+ const gchar * message_text2)
{
- message_error = g_strdup_printf("%s.\n %s",message_text1, message_text2);
+ message_error = g_strdup_printf ("%s.\n %s", message_text1, message_text2);
}
static gboolean
po_file_is_empty (po_file_t file)
{
- const gchar * const * domains = po_file_domains (file);
+ const gchar *const *domains = po_file_domains (file);
- for (; *domains != NULL; domains++)
+ for (; *domains != NULL; domains++)
+ {
+ po_message_iterator_t iter = po_message_iterator (file, *domains);
+ if (po_next_message (iter) != NULL)
{
- po_message_iterator_t iter = po_message_iterator (file, *domains);
- if (po_next_message (iter) != NULL)
- {
- po_message_iterator_free (iter);
- return FALSE;
- }
- po_message_iterator_free (iter);
+ po_message_iterator_free (iter);
+ return FALSE;
}
- return TRUE;
+ po_message_iterator_free (iter);
+ }
+ return TRUE;
}
/***************************** Public funcs ***********************************/
@@ -296,13 +293,13 @@ po_file_is_empty (po_file_t file)
* Returns: a new #GtranslatorPo object
**/
GtranslatorPo *
-gtranslator_po_new(void)
+gtranslator_po_new (void)
{
- GtranslatorPo *po;
+ GtranslatorPo *po;
- po = g_object_new(GTR_TYPE_PO, NULL);
+ po = g_object_new (GTR_TYPE_PO, NULL);
- return po;
+ return po;
}
/**
@@ -315,256 +312,261 @@ gtranslator_po_new(void)
* variables.
**/
void
-gtranslator_po_parse (GtranslatorPo *po,
- GFile *location,
- GError **error)
+gtranslator_po_parse (GtranslatorPo * po, GFile * location, GError ** error)
{
- GtranslatorPoPrivate *priv = po->priv;
- gchar *filename;
- GtranslatorMsg *msg;
- struct po_xerror_handler handler;
- po_message_t message;
- po_message_iterator_t iter;
- const gchar *msgstr;
- const gchar * const *domains;
- gchar *base;
- gint i = 0;
- gint pos = 1;
-
- g_return_if_fail (GTR_IS_PO (po));
- g_return_if_fail (location != NULL);
-
- /*
- * Initialice the handler error.
- */
- handler.xerror = &on_gettext_po_xerror;
- handler.xerror2 = &on_gettext_po_xerror2;
-
- if(message_error != NULL)
+ GtranslatorPoPrivate *priv = po->priv;
+ gchar *filename;
+ GtranslatorMsg *msg;
+ struct po_xerror_handler handler;
+ po_message_t message;
+ po_message_iterator_t iter;
+ const gchar *msgstr;
+ const gchar *const *domains;
+ gchar *base;
+ gint i = 0;
+ gint pos = 1;
+
+ g_return_if_fail (GTR_IS_PO (po));
+ g_return_if_fail (location != NULL);
+
+ /*
+ * Initialice the handler error.
+ */
+ handler.xerror = &on_gettext_po_xerror;
+ handler.xerror2 = &on_gettext_po_xerror2;
+
+ if (message_error != NULL)
+ {
+ g_free (message_error);
+ message_error = NULL;
+ }
+
+ /*
+ * Get filename path.
+ */
+ po->priv->location = g_file_dup (location);
+ filename = g_file_get_path (location);
+
+ if (po->priv->gettext_po_file)
+ po_file_free (po->priv->gettext_po_file);
+
+ priv->gettext_po_file = po_file_read (filename, &handler);
+ if (priv->gettext_po_file == NULL)
+ {
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILENAME,
+ _("Failed opening file '%s': %s"),
+ filename, g_strerror (errno));
+ g_object_unref (po);
+ g_free (filename);
+ return;
+ }
+ g_free (filename);
+
+ /*
+ * No need to return; this can be corrected by the user
+ */
+ if (message_error != NULL)
+ {
+ g_set_error (error,
+ GTR_PO_ERROR, GTR_PO_ERROR_RECOVERY, "%s", message_error);
+ }
+
+ if (po_file_is_empty (priv->gettext_po_file))
+ {
+ if (*error != NULL)
+ g_clear_error (error);
+
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILE_EMPTY, _("The file is empty"));
+ g_object_unref (po);
+ return;
+ }
+
+ /*
+ * Determine the message domains to track
+ */
+ if (!(domains = po_file_domains (priv->gettext_po_file)))
+ {
+ if (*error != NULL)
+ g_clear_error (error);
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_GETTEXT,
+ _("Gettext returned a null message domain list."));
+ g_object_unref (po);
+ return;
+ }
+ while (domains[i])
+ {
+ priv->domains = g_list_append (priv->domains, g_strdup (domains[i]));
+ i++;
+ }
+
+ /*
+ * Determine whether first message is the header or not, and
+ * if so, process it seperately. Otherwise, treat as a normal
+ * message.
+ */
+ priv->messages = NULL;
+ priv->iter = iter = po_message_iterator (priv->gettext_po_file, NULL);
+ message = po_next_message (iter);
+ msgstr = po_message_msgstr (message);
+ if (!strncmp (msgstr, "Project-Id-Version: ", 20))
+ {
+
+ /* Parse into our header structure */
+
+ priv->header = gtranslator_header_new ();
+
+ gchar *comment, *prj_id_version, *rmbt, *pot_date, *po_date,
+ *translator, *tr_email, *language, *lg_email, *mime_version,
+ *charset, *encoding, *plural_forms;
+
+ gchar *space1, *space2, *space3;
+
+ comment = g_strdup (po_message_comments (message));
+ gtranslator_header_set_comment (priv->header, (const gchar *) comment);
+
+ prj_id_version = po_header_field (msgstr, "Project-Id-Version");
+ rmbt = po_header_field (msgstr, "Report-Msgid-Bugs-To");
+ pot_date = po_header_field (msgstr, "POT-Creation-Date");
+ po_date = po_header_field (msgstr, "PO-Revision-Date");
+
+ gchar *translator_temp = po_header_field (msgstr, "Last-Translator");
+ space1 = g_strrstr (translator_temp, " <");
+
+ if (!space1)
{
- g_free(message_error);
- message_error = NULL;
+ translator = g_strdup (translator_temp);
+ tr_email = g_strdup ("");
+ }
+ else
+ {
+ translator = g_strndup (translator_temp, space1 - translator_temp);
+ tr_email = g_strndup (space1 + 2, strlen (space1) - 3);
}
- /*
- * Get filename path.
- */
- po->priv->location = g_file_dup (location);
- filename = g_file_get_path (location);
-
- if (po->priv->gettext_po_file)
- po_file_free (po->priv->gettext_po_file);
+ gchar *language_temp = po_header_field (msgstr, "Language-Team");
+ space2 = g_strrstr (language_temp, " <");
- priv->gettext_po_file = po_file_read (filename,
- &handler);
- if (priv->gettext_po_file == NULL)
+ if (!space2)
{
- g_set_error (error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_FILENAME,
- _("Failed opening file '%s': %s"),
- filename, g_strerror (errno));
- g_object_unref(po);
- g_free (filename);
- return;
+ language = g_strdup (language_temp);
+ lg_email = g_strdup ("");
}
- g_free (filename);
-
- /*
- * No need to return; this can be corrected by the user
- */
- if(message_error != NULL) {
- g_set_error(error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_RECOVERY,
- "%s", message_error);
- }
-
- if (po_file_is_empty (priv->gettext_po_file))
+ else
{
- if (*error != NULL)
- g_clear_error (error);
-
- g_set_error (error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_FILE_EMPTY,
- _("The file is empty"));
- g_object_unref(po);
- return;
+ language = g_strndup (language_temp, space2 - language_temp);
+ lg_email = g_strndup (space2 + 2, strlen (space2) - 3);
}
- /*
- * Determine the message domains to track
- */
- if(!(domains = po_file_domains(priv->gettext_po_file))) {
- if (*error != NULL)
- g_clear_error (error);
- g_set_error(error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_GETTEXT,
- _("Gettext returned a null message domain list."));
- g_object_unref(po);
- return;
- }
- while(domains[i]) {
- priv->domains = g_list_append(priv->domains, g_strdup(domains[i]));
- i++;
- }
+ mime_version = po_header_field (msgstr, "MIME-Version");
- /*
- * Determine whether first message is the header or not, and
- * if so, process it seperately. Otherwise, treat as a normal
- * message.
- */
- priv->messages = NULL;
- priv->iter = iter = po_message_iterator(priv->gettext_po_file, NULL);
- message = po_next_message(iter);
- msgstr = po_message_msgstr(message);
- if (!strncmp(msgstr, "Project-Id-Version: ", 20)) {
-
- /* Parse into our header structure */
-
- priv->header = gtranslator_header_new();
-
- gchar *comment, *prj_id_version, *rmbt, *pot_date, *po_date,
- *translator, *tr_email, *language, *lg_email, *mime_version,
- *charset, *encoding, *plural_forms;
-
- gchar *space1, *space2, *space3;
-
- comment = g_strdup(po_message_comments(message));
- gtranslator_header_set_comment (priv->header, (const gchar *)comment);
-
- prj_id_version = po_header_field(msgstr, "Project-Id-Version");
- rmbt = po_header_field(msgstr, "Report-Msgid-Bugs-To");
- pot_date = po_header_field(msgstr, "POT-Creation-Date");
- po_date = po_header_field(msgstr, "PO-Revision-Date");
-
- gchar *translator_temp = po_header_field(msgstr, "Last-Translator");
- space1 = g_strrstr(translator_temp, " <");
-
- if (!space1)
- {
- translator = g_strdup(translator_temp);
- tr_email = g_strdup("");
- } else {
- translator = g_strndup(translator_temp, space1 - translator_temp);
- tr_email = g_strndup(space1 + 2, strlen(space1)-3);
- }
-
- gchar *language_temp = po_header_field(msgstr, "Language-Team");
- space2 = g_strrstr(language_temp, " <");
-
- if (!space2)
- {
- language = g_strdup(language_temp);
- lg_email = g_strdup("");
- }else {
- language = g_strndup(language_temp, space2 - language_temp);
- lg_email = g_strndup(space2 + 2, strlen(space2)-3);
- }
-
- mime_version = po_header_field(msgstr, "MIME-Version");
-
- gchar *charset_temp = po_header_field(msgstr, "Content-Type");
- space3 = g_strrstr(charset_temp, "=");
-
- if (!space3)
- {
- charset = g_strdup("");
- }else {
- charset = g_strdup(space3 +1);
- }
-
- encoding = po_header_field(msgstr, "Content-Transfer-Encoding");
-
- /*
- * Plural forms:
- */
- plural_forms = po_header_field (msgstr, "Plural-Forms");
-
- gtranslator_header_set_comment(priv->header, comment);
- gtranslator_header_set_prj_id_version(priv->header, prj_id_version);
- gtranslator_header_set_rmbt(priv->header, rmbt);
- gtranslator_header_set_pot_date(priv->header, pot_date);
- gtranslator_header_set_po_date(priv->header, po_date);
- gtranslator_header_set_translator(priv->header, translator);
- gtranslator_header_set_tr_email(priv->header, tr_email);
- gtranslator_header_set_prev_translator(priv->header, translator_temp);
- gtranslator_header_set_language(priv->header, language);
- gtranslator_header_set_lg_email(priv->header, lg_email);
- gtranslator_header_set_mime_version(priv->header, mime_version);
- gtranslator_header_set_charset(priv->header, charset);
- gtranslator_header_set_encoding(priv->header, encoding);
- gtranslator_header_set_plural_forms (priv->header,
- plural_forms);
-
- g_free (translator_temp);
- g_free (language_temp);
- g_free (charset_temp);
- g_free (comment);
- g_free (prj_id_version);
- g_free (rmbt);
- g_free (pot_date);
- g_free (po_date);
- g_free (translator);
- g_free (tr_email);
- g_free (language);
- g_free (lg_email);
- g_free (mime_version);
- g_free (charset);
- g_free (encoding);
- g_free (plural_forms);
- }
- else {
- /* Reset our pointer */
- iter = po_message_iterator(priv->gettext_po_file, NULL);
- }
+ gchar *charset_temp = po_header_field (msgstr, "Content-Type");
+ space3 = g_strrstr (charset_temp, "=");
- /*
- * Post-process these into a linked list of GtrMsgs.
- */
- while ((message = po_next_message (iter)))
+ if (!space3)
{
- /*FIXME: We have to change this:
- * we have to add a gtranslator_msg_is_obsolete fund msg.c
- * and detect if we want obsoletes messages in show message
- */
- if (!po_message_is_obsolete (message))
- {
- /* Unpack into a GtrMsg */
- msg = gtranslator_msg_new (iter, message);
-
- /* Set position in PO file */
- gtranslator_msg_set_po_position (msg, pos++);
-
- /* Build up messages */
- priv->messages = g_list_prepend (priv->messages, msg);
- }
+ charset = g_strdup ("");
}
-
- if (priv->messages == NULL) {
- if (*error != NULL)
- g_clear_error (error);
- g_set_error(error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_OTHER,
- _("No messages obtained from parser."));
- g_object_unref(po);
- return;
+ else
+ {
+ charset = g_strdup (space3 + 1);
}
- priv->messages = g_list_reverse (priv->messages);
-
- /*
- * Set the current message to the first message.
- */
- priv->current = g_list_first(priv->messages);
+ encoding = po_header_field (msgstr, "Content-Transfer-Encoding");
+
+ /*
+ * Plural forms:
+ */
+ plural_forms = po_header_field (msgstr, "Plural-Forms");
+
+ gtranslator_header_set_comment (priv->header, comment);
+ gtranslator_header_set_prj_id_version (priv->header, prj_id_version);
+ gtranslator_header_set_rmbt (priv->header, rmbt);
+ gtranslator_header_set_pot_date (priv->header, pot_date);
+ gtranslator_header_set_po_date (priv->header, po_date);
+ gtranslator_header_set_translator (priv->header, translator);
+ gtranslator_header_set_tr_email (priv->header, tr_email);
+ gtranslator_header_set_prev_translator (priv->header, translator_temp);
+ gtranslator_header_set_language (priv->header, language);
+ gtranslator_header_set_lg_email (priv->header, lg_email);
+ gtranslator_header_set_mime_version (priv->header, mime_version);
+ gtranslator_header_set_charset (priv->header, charset);
+ gtranslator_header_set_encoding (priv->header, encoding);
+ gtranslator_header_set_plural_forms (priv->header, plural_forms);
+
+ g_free (translator_temp);
+ g_free (language_temp);
+ g_free (charset_temp);
+ g_free (comment);
+ g_free (prj_id_version);
+ g_free (rmbt);
+ g_free (pot_date);
+ g_free (po_date);
+ g_free (translator);
+ g_free (tr_email);
+ g_free (language);
+ g_free (lg_email);
+ g_free (mime_version);
+ g_free (charset);
+ g_free (encoding);
+ g_free (plural_forms);
+ }
+ else
+ {
+ /* Reset our pointer */
+ iter = po_message_iterator (priv->gettext_po_file, NULL);
+ }
+
+ /*
+ * Post-process these into a linked list of GtrMsgs.
+ */
+ while ((message = po_next_message (iter)))
+ {
+ /*FIXME: We have to change this:
+ * we have to add a gtranslator_msg_is_obsolete fund msg.c
+ * and detect if we want obsoletes messages in show message
+ */
+ if (!po_message_is_obsolete (message))
+ {
+ /* Unpack into a GtrMsg */
+ msg = gtranslator_msg_new (iter, message);
- gtranslator_po_update_translated_count(po);
+ /* Set position in PO file */
+ gtranslator_msg_set_po_position (msg, pos++);
- /* Initialize Tab state*/
- po->priv->state = GTR_PO_STATE_SAVED;
+ /* Build up messages */
+ priv->messages = g_list_prepend (priv->messages, msg);
+ }
+ }
+
+ if (priv->messages == NULL)
+ {
+ if (*error != NULL)
+ g_clear_error (error);
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_OTHER,
+ _("No messages obtained from parser."));
+ g_object_unref (po);
+ return;
+ }
+
+ priv->messages = g_list_reverse (priv->messages);
+
+ /*
+ * Set the current message to the first message.
+ */
+ priv->current = g_list_first (priv->messages);
+
+ gtranslator_po_update_translated_count (po);
+
+ /* Initialize Tab state */
+ po->priv->state = GTR_PO_STATE_SAVED;
}
/**
@@ -574,190 +576,232 @@ gtranslator_po_parse (GtranslatorPo *po,
* It saves the header's values into the msgstr
**/
void
-gtranslator_po_save_header_in_msg (GtranslatorPo *po, GtranslatorHeader *header)
+gtranslator_po_save_header_in_msg (GtranslatorPo * po,
+ GtranslatorHeader * header)
{
- po_message_iterator_t iter;
- po_message_t message;
-
- const char *msgstr,
- *header_comment;
- const char *prev_translator;
-
- gchar *current_date;
- gchar *current_time;
- gchar *year;
- gchar *new_date;
- gchar *aux;
- gchar *aux2;
- const gchar *comments;
- gchar **comments_lines;
- gchar **comments_translator_values;
-
- gboolean use_profile_values;
-
- gint i = 0;
- gint j;
- gint k = 0;
- gint l;
-
- gchar *new_comments = "";
- gchar *old_line;
- gchar *line = "";
- gchar *comp_year;
- gchar *line_without_dot;
-
- gboolean current_translator_in_comments = FALSE;
-
- use_profile_values = gtranslator_prefs_manager_get_use_profile_values ();
-
- /*
- * Save the previous translator to update the header's comment
- */
- prev_translator = gtranslator_header_get_prev_translator(header);
-
- /*
- * Determinate the message with the header
- */
- iter = po_message_iterator(gtranslator_po_get_po_file(po), NULL);
- message = po_next_message(iter);
- /*
- * FIXME: We have to use our msg class to manage this kind of things,
- * and we have to encapsulate the funcs like po_header_set_field in
- * our header class.
- */
- msgstr = po_message_msgstr(message);
-
- /*
- * If button use_profile_values is pushed, then header's values
- * should be taking from default profile
- */
-
- if (use_profile_values) {
-
- GtranslatorProfile *active_profile;
-
- active_profile = gtranslator_application_get_active_profile (GTR_APP);
-
- gtranslator_header_set_translator (header, gtranslator_profile_get_author_name (active_profile));
- gtranslator_header_set_tr_email (header, gtranslator_profile_get_author_email (active_profile));
- gtranslator_header_set_language (header, gtranslator_profile_get_language_name (active_profile));
- gtranslator_header_set_charset (header, gtranslator_profile_get_charset (active_profile));
- gtranslator_header_set_encoding (header, gtranslator_profile_get_encoding (active_profile));
- gtranslator_header_set_lg_email (header, gtranslator_profile_get_group_email (active_profile));
- gtranslator_header_set_plural_forms (header, gtranslator_profile_get_plurals (active_profile));
- }
-
- /*
- * Update the po date
- */
- current_date = gtranslator_utils_get_current_date ();
- current_time = gtranslator_utils_get_current_time ();
- year = gtranslator_utils_get_current_year ();
-
- new_date = g_strconcat (current_date, " ", current_time, NULL);
-
- gtranslator_header_set_po_date (header, new_date);
-
- g_free (new_date);
-
- /*
- * Update the header's comment
- */
- comments = gtranslator_header_get_comment (header);
- comments_lines = g_strsplit (comments, "\n", -1);
-
- /*
- * Searching if the current translator is in comments.
- */
- while (comments_lines[i] != NULL) {
- if (g_str_has_prefix (comments_lines[i], prev_translator)) {
- current_translator_in_comments = TRUE;
- comments_translator_values = g_strsplit (comments_lines[i], ",", -1);
- j = i;
- }
- i++;
+ po_message_iterator_t iter;
+ po_message_t message;
+
+ const char *msgstr, *header_comment;
+ const char *prev_translator;
+
+ gchar *current_date;
+ gchar *current_time;
+ gchar *year;
+ gchar *new_date;
+ gchar *aux;
+ gchar *aux2;
+ const gchar *comments;
+ gchar **comments_lines;
+ gchar **comments_translator_values;
+
+ gboolean use_profile_values;
+
+ gint i = 0;
+ gint j;
+ gint k = 0;
+ gint l;
+
+ gchar *new_comments = "";
+ gchar *old_line;
+ gchar *line = "";
+ gchar *comp_year;
+ gchar *line_without_dot;
+
+ gboolean current_translator_in_comments = FALSE;
+
+ use_profile_values = gtranslator_prefs_manager_get_use_profile_values ();
+
+ /*
+ * Save the previous translator to update the header's comment
+ */
+ prev_translator = gtranslator_header_get_prev_translator (header);
+
+ /*
+ * Determinate the message with the header
+ */
+ iter = po_message_iterator (gtranslator_po_get_po_file (po), NULL);
+ message = po_next_message (iter);
+ /*
+ * FIXME: We have to use our msg class to manage this kind of things,
+ * and we have to encapsulate the funcs like po_header_set_field in
+ * our header class.
+ */
+ msgstr = po_message_msgstr (message);
+
+ /*
+ * If button use_profile_values is pushed, then header's values
+ * should be taking from default profile
+ */
+
+ if (use_profile_values)
+ {
+
+ GtranslatorProfile *active_profile;
+
+ active_profile = gtranslator_application_get_active_profile (GTR_APP);
+
+ gtranslator_header_set_translator (header,
+ gtranslator_profile_get_author_name
+ (active_profile));
+ gtranslator_header_set_tr_email (header,
+ gtranslator_profile_get_author_email
+ (active_profile));
+ gtranslator_header_set_language (header,
+ gtranslator_profile_get_language_name
+ (active_profile));
+ gtranslator_header_set_charset (header,
+ gtranslator_profile_get_charset
+ (active_profile));
+ gtranslator_header_set_encoding (header,
+ gtranslator_profile_get_encoding
+ (active_profile));
+ gtranslator_header_set_lg_email (header,
+ gtranslator_profile_get_group_email
+ (active_profile));
+ gtranslator_header_set_plural_forms (header,
+ gtranslator_profile_get_plurals
+ (active_profile));
+ }
+
+ /*
+ * Update the po date
+ */
+ current_date = gtranslator_utils_get_current_date ();
+ current_time = gtranslator_utils_get_current_time ();
+ year = gtranslator_utils_get_current_year ();
+
+ new_date = g_strconcat (current_date, " ", current_time, NULL);
+
+ gtranslator_header_set_po_date (header, new_date);
+
+ g_free (new_date);
+
+ /*
+ * Update the header's comment
+ */
+ comments = gtranslator_header_get_comment (header);
+ comments_lines = g_strsplit (comments, "\n", -1);
+
+ /*
+ * Searching if the current translator is in comments.
+ */
+ while (comments_lines[i] != NULL)
+ {
+ if (g_str_has_prefix (comments_lines[i], prev_translator))
+ {
+ current_translator_in_comments = TRUE;
+ comments_translator_values =
+ g_strsplit (comments_lines[i], ",", -1);
+ j = i;
}
- aux = g_strconcat(gtranslator_header_get_translator(header), " ", "<",
- gtranslator_header_get_tr_email(header), ">", NULL);
-
- comp_year = g_strconcat (" ", year, ".", NULL);
-
- /*
- * Current translator is already in comments but its last year < current year.
- */
- if (current_translator_in_comments) {
- if ((g_utf8_collate (prev_translator, aux) == 0) &&
- (g_utf8_collate (comments_translator_values[g_strv_length (comments_translator_values)-1], comp_year) != 0)) {
- if (g_str_has_suffix (comments_lines[j], ".")) {
- line_without_dot = g_strndup (comments_lines[j], g_utf8_strlen(comments_lines[j], -1) -1);
+ i++;
+ }
+ aux = g_strconcat (gtranslator_header_get_translator (header), " ", "<",
+ gtranslator_header_get_tr_email (header), ">", NULL);
+
+ comp_year = g_strconcat (" ", year, ".", NULL);
+
+ /*
+ * Current translator is already in comments but its last year < current year.
+ */
+ if (current_translator_in_comments)
+ {
+ if ((g_utf8_collate (prev_translator, aux) == 0) &&
+ (g_utf8_collate
+ (comments_translator_values
+ [g_strv_length (comments_translator_values) - 1],
+ comp_year) != 0))
+ {
+ if (g_str_has_suffix (comments_lines[j], "."))
+ {
+ line_without_dot =
+ g_strndup (comments_lines[j],
+ g_utf8_strlen (comments_lines[j], -1) - 1);
line = g_strconcat (line_without_dot, ", ", year, ".", NULL);
g_free (line_without_dot);
- }else {
+ }
+ else
+ {
line = g_strconcat (comments_lines[j], ", ", year, ".", NULL);
}
- for (l=j; l<(g_strv_length (comments_lines)); l++) {
- comments_lines[l] = comments_lines[l+1];
+ for (l = j; l < (g_strv_length (comments_lines)); l++)
+ {
+ comments_lines[l] = comments_lines[l + 1];
}
- comments_lines[g_strv_length (comments_lines)-1] = line;
- while (comments_lines[k] != NULL) {
- new_comments = g_strconcat (new_comments, comments_lines[k], "\n", NULL);
+ comments_lines[g_strv_length (comments_lines) - 1] = line;
+ while (comments_lines[k] != NULL)
+ {
+ new_comments =
+ g_strconcat (new_comments, comments_lines[k], "\n", NULL);
k++;
}
- gtranslator_header_set_comment (header, (const gchar *)new_comments);
- g_free (line);
- g_free (new_comments);
- }
- }
- /*
- * Current translator is not in the comments.
- */
- if ((g_utf8_collate (prev_translator, aux) != 0) || (prev_translator == NULL)) {
-
- header_comment = (const gchar *) g_strchomp((gchar *) gtranslator_header_get_comment (header));
- aux2 = g_strconcat(header_comment, "\n",gtranslator_header_get_translator(header), " ", "<",
- gtranslator_header_get_tr_email(header), ">", ",", " ", year, ".", NULL);
-
- gtranslator_header_set_comment (header, (const gchar *)aux2);
- gtranslator_header_set_prev_translator (header, aux);
- g_free (aux2);
+ gtranslator_header_set_comment (header,
+ (const gchar *) new_comments);
+ g_free (line);
+ g_free (new_comments);
}
- g_free (aux);
-
- /*
- * Write the header's fields
- */
- gtranslator_po_set_header (po, header);
-
- comments = gtranslator_header_get_comment (header);
- po_message_set_comments (message, comments);
-
- msgstr = po_header_set_field (msgstr, "Project-Id-Version",
- gtranslator_header_get_prj_id_version(header));
- msgstr = po_header_set_field (msgstr, "Report-Msgid-Bugs-To",
- gtranslator_header_get_rmbt(header));
- msgstr = po_header_set_field (msgstr, "PO-Revision-Date",
- gtranslator_header_get_po_date(header));
-
- aux = g_strconcat (gtranslator_header_get_translator(header), " ", "<",
- gtranslator_header_get_tr_email(header), ">", NULL);
- msgstr = po_header_set_field (msgstr, "Last-Translator", aux);
- g_free (aux);
-
- aux = g_strconcat (gtranslator_header_get_language(header), " ", "<",
- gtranslator_header_get_lg_email(header), ">", NULL);
- msgstr = po_header_set_field (msgstr, "Language-Team", aux);
- g_free (aux);
-
- aux = g_strconcat("text/plain;", " charset=",
- gtranslator_header_get_charset(header),NULL);
- msgstr = po_header_set_field (msgstr, "Content-Type", aux);
- g_free (aux);
-
- msgstr = po_header_set_field (msgstr, "Content-Transfer-Encoding",
- gtranslator_header_get_encoding(header));
- po_message_set_msgstr (message, msgstr);
+ }
+ /*
+ * Current translator is not in the comments.
+ */
+ if ((g_utf8_collate (prev_translator, aux) != 0)
+ || (prev_translator == NULL))
+ {
+
+ header_comment =
+ (const gchar *) g_strchomp ((gchar *)
+ gtranslator_header_get_comment (header));
+ aux2 =
+ g_strconcat (header_comment, "\n",
+ gtranslator_header_get_translator (header), " ", "<",
+ gtranslator_header_get_tr_email (header), ">", ",", " ",
+ year, ".", NULL);
+
+ gtranslator_header_set_comment (header, (const gchar *) aux2);
+ gtranslator_header_set_prev_translator (header, aux);
+ g_free (aux2);
+ }
+ g_free (aux);
+
+ /*
+ * Write the header's fields
+ */
+ gtranslator_po_set_header (po, header);
+
+ comments = gtranslator_header_get_comment (header);
+ po_message_set_comments (message, comments);
+
+ msgstr = po_header_set_field (msgstr, "Project-Id-Version",
+ gtranslator_header_get_prj_id_version
+ (header));
+ msgstr =
+ po_header_set_field (msgstr, "Report-Msgid-Bugs-To",
+ gtranslator_header_get_rmbt (header));
+ msgstr =
+ po_header_set_field (msgstr, "PO-Revision-Date",
+ gtranslator_header_get_po_date (header));
+
+ aux = g_strconcat (gtranslator_header_get_translator (header), " ", "<",
+ gtranslator_header_get_tr_email (header), ">", NULL);
+ msgstr = po_header_set_field (msgstr, "Last-Translator", aux);
+ g_free (aux);
+
+ aux = g_strconcat (gtranslator_header_get_language (header), " ", "<",
+ gtranslator_header_get_lg_email (header), ">", NULL);
+ msgstr = po_header_set_field (msgstr, "Language-Team", aux);
+ g_free (aux);
+
+ aux = g_strconcat ("text/plain;", " charset=",
+ gtranslator_header_get_charset (header), NULL);
+ msgstr = po_header_set_field (msgstr, "Content-Type", aux);
+ g_free (aux);
+
+ msgstr = po_header_set_field (msgstr, "Content-Transfer-Encoding",
+ gtranslator_header_get_encoding (header));
+ po_message_set_msgstr (message, msgstr);
}
/**
@@ -769,88 +813,85 @@ gtranslator_po_save_header_in_msg (GtranslatorPo *po, GtranslatorHeader *header)
* in @error.
**/
void
-gtranslator_po_save_file(GtranslatorPo *po,
- GError **error)
+gtranslator_po_save_file (GtranslatorPo * po, GError ** error)
{
- struct po_xerror_handler handler;
- gchar *msg_error;
- gchar *filename;
- GtranslatorHeader *header;
-
- /*
- * Initialice the handler error.
- */
- handler.xerror = &on_gettext_po_xerror;
- handler.xerror2 = &on_gettext_po_xerror2;
-
- filename = g_file_get_path (po->priv->location);
-
- if (g_str_has_suffix (filename, ".pot"))
- {
- // Remove suffix
- filename[strlen (filename) - 4] = '\0';
- g_set_error (error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_FILENAME,
- _("You are saving a file with a .pot extension.\n"
- "Pot files are generated by the compilation process.\n"
- "Your file should likely be named '%s.po'."),
- filename);
- g_free (filename);
- return;
- }
-
- /*
- * Check if the file is right
- */
- /*msg_error = gtranslator_po_check_po_file (po);
- if (msg_error != NULL)
- {
- g_set_error (error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_GETTEXT,
- _("There is an error in the PO file: %s"),
- msg_error);
- g_free (msg_error);
- }*/
-
-
- /*
- * Save header fields into msg
- */
- header = gtranslator_po_get_header (po);
- gtranslator_po_save_header_in_msg (po, header);
-
- if (!po_file_write (gtranslator_po_get_po_file (po),
- filename, &handler))
- {
- g_set_error (error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_FILENAME,
- _("There was an error writing the PO file: %s"),
- message_error);
- g_free (message_error);
- g_free (filename);
- return;
- }
- g_free (filename);
-
- /* If we are here everything is ok and we can set the state as saved */
- gtranslator_po_set_state (po, GTR_PO_STATE_SAVED);
-
- /*
- * If the warn if fuzzy option is enabled we have to show an error
- */
- /*if (gtranslator_prefs_manager_get_warn_if_fuzzy () && po->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);
- }*/
+ struct po_xerror_handler handler;
+ gchar *msg_error;
+ gchar *filename;
+ GtranslatorHeader *header;
+
+ /*
+ * Initialice the handler error.
+ */
+ handler.xerror = &on_gettext_po_xerror;
+ handler.xerror2 = &on_gettext_po_xerror2;
+
+ filename = g_file_get_path (po->priv->location);
+
+ if (g_str_has_suffix (filename, ".pot"))
+ {
+ // Remove suffix
+ filename[strlen (filename) - 4] = '\0';
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILENAME,
+ _("You are saving a file with a .pot extension.\n"
+ "Pot files are generated by the compilation process.\n"
+ "Your file should likely be named '%s.po'."), filename);
+ g_free (filename);
+ return;
+ }
+
+ /*
+ * Check if the file is right
+ */
+ /*msg_error = gtranslator_po_check_po_file (po);
+ if (msg_error != NULL)
+ {
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_GETTEXT,
+ _("There is an error in the PO file: %s"),
+ msg_error);
+ g_free (msg_error);
+ } */
+
+
+ /*
+ * Save header fields into msg
+ */
+ header = gtranslator_po_get_header (po);
+ gtranslator_po_save_header_in_msg (po, header);
+
+ if (!po_file_write (gtranslator_po_get_po_file (po), filename, &handler))
+ {
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILENAME,
+ _("There was an error writing the PO file: %s"),
+ message_error);
+ g_free (message_error);
+ g_free (filename);
+ return;
+ }
+ g_free (filename);
+
+ /* If we are here everything is ok and we can set the state as saved */
+ gtranslator_po_set_state (po, GTR_PO_STATE_SAVED);
+
+ /*
+ * If the warn if fuzzy option is enabled we have to show an error
+ */
+ /*if (gtranslator_prefs_manager_get_warn_if_fuzzy () && po->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);
+ } */
}
/**
@@ -863,11 +904,11 @@ gtranslator_po_save_file(GtranslatorPo *po,
* with g_object_unref.
**/
GFile *
-gtranslator_po_get_location (GtranslatorPo *po)
+gtranslator_po_get_location (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), NULL);
+ g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return g_file_dup (po->priv->location);
+ return g_file_dup (po->priv->location);
}
/**
@@ -878,15 +919,14 @@ gtranslator_po_get_location (GtranslatorPo *po)
* Sets the GFile location within the #GtranslatorPo object.
**/
void
-gtranslator_po_set_location (GtranslatorPo *po,
- GFile *location)
+gtranslator_po_set_location (GtranslatorPo * po, GFile * location)
{
- g_return_if_fail(GTR_IS_PO(po));
+ g_return_if_fail (GTR_IS_PO (po));
- if (po->priv->location)
- g_object_unref (po->priv->location);
+ if (po->priv->location)
+ g_object_unref (po->priv->location);
- po->priv->location = g_file_dup (location);
+ po->priv->location = g_file_dup (location);
}
/**
@@ -896,9 +936,9 @@ gtranslator_po_set_location (GtranslatorPo *po,
* Return value: the #GtranslatorPoState value of the @po.
*/
GtranslatorPoState
-gtranslator_po_get_state(GtranslatorPo *po)
+gtranslator_po_get_state (GtranslatorPo * po)
{
- return po->priv->state;
+ return po->priv->state;
}
/**
@@ -909,21 +949,20 @@ gtranslator_po_get_state(GtranslatorPo *po)
* Sets the state for a #GtranslatorPo
*/
void
-gtranslator_po_set_state(GtranslatorPo *po,
- GtranslatorPoState state)
+gtranslator_po_set_state (GtranslatorPo * po, GtranslatorPoState state)
{
- po->priv->state = state;
+ po->priv->state = state;
- g_object_notify (G_OBJECT (po), "state");
+ g_object_notify (G_OBJECT (po), "state");
}
/*
* FIXME: We are not using this func.
*/
gboolean
-gtranslator_po_get_write_perms(GtranslatorPo *po)
+gtranslator_po_get_write_perms (GtranslatorPo * po)
{
- return po->priv->no_write_perms;
+ return po->priv->no_write_perms;
}
/**
@@ -933,9 +972,9 @@ gtranslator_po_get_write_perms(GtranslatorPo *po)
* Return value: a pointer to the messages list
**/
GList *
-gtranslator_po_get_messages(GtranslatorPo *po)
+gtranslator_po_get_messages (GtranslatorPo * po)
{
- return po->priv->messages;
+ return po->priv->messages;
}
/**
@@ -946,10 +985,9 @@ gtranslator_po_get_messages(GtranslatorPo *po)
* Sets an updated list of messages.
**/
void
-gtranslator_po_set_messages (GtranslatorPo *po,
- GList *messages)
+gtranslator_po_set_messages (GtranslatorPo * po, GList * messages)
{
- po->priv->messages = messages;
+ po->priv->messages = messages;
}
/**
@@ -959,9 +997,9 @@ gtranslator_po_set_messages (GtranslatorPo *po,
* Return value: a pointer to the current message
**/
GList *
-gtranslator_po_get_current_message(GtranslatorPo *po)
+gtranslator_po_get_current_message (GtranslatorPo * po)
{
- return po->priv->current;
+ return po->priv->current;
}
@@ -974,12 +1012,12 @@ gtranslator_po_get_current_message(GtranslatorPo *po)
* the argument.
**/
void
-gtranslator_po_update_current_message(GtranslatorPo *po,
- GtranslatorMsg *msg)
+gtranslator_po_update_current_message (GtranslatorPo * po,
+ GtranslatorMsg * msg)
{
- gint i;
- i = g_list_index(po->priv->messages, msg);
- po->priv->current = g_list_nth(po->priv->messages, i);
+ gint i;
+ i = g_list_index (po->priv->messages, msg);
+ po->priv->current = g_list_nth (po->priv->messages, i);
}
/**
@@ -989,9 +1027,9 @@ gtranslator_po_update_current_message(GtranslatorPo *po,
* Return value: a pointer to the domains list
**/
GList *
-gtranslator_po_get_domains(GtranslatorPo *po)
+gtranslator_po_get_domains (GtranslatorPo * po)
{
- return po->priv->domains;
+ return po->priv->domains;
}
/**
@@ -1001,9 +1039,9 @@ gtranslator_po_get_domains(GtranslatorPo *po)
* Return value: the gettext file
**/
po_file_t
-gtranslator_po_get_po_file(GtranslatorPo *po)
+gtranslator_po_get_po_file (GtranslatorPo * po)
{
- return po->priv->gettext_po_file;
+ return po->priv->gettext_po_file;
}
/**
@@ -1013,18 +1051,18 @@ gtranslator_po_get_po_file(GtranslatorPo *po)
* Return value: a pointer to the next fuzzy message
**/
GList *
-gtranslator_po_get_next_fuzzy(GtranslatorPo *po)
+gtranslator_po_get_next_fuzzy (GtranslatorPo * po)
{
- GList *msg;
+ GList *msg;
- msg = po->priv->current;
- while (msg = g_list_next(msg))
- {
- if (gtranslator_msg_is_fuzzy(msg->data))
- return msg;
- }
+ msg = po->priv->current;
+ while (msg = g_list_next (msg))
+ {
+ if (gtranslator_msg_is_fuzzy (msg->data))
+ return msg;
+ }
- return NULL;
+ return NULL;
}
@@ -1035,18 +1073,18 @@ gtranslator_po_get_next_fuzzy(GtranslatorPo *po)
* Return value: a pointer to the previously fuzzy message
**/
GList *
-gtranslator_po_get_prev_fuzzy(GtranslatorPo *po)
+gtranslator_po_get_prev_fuzzy (GtranslatorPo * po)
{
- GList *msg;
+ GList *msg;
- msg = po->priv->current;
- while (msg = g_list_previous(msg))
- {
- if (gtranslator_msg_is_fuzzy(msg->data))
- return msg;
- }
+ msg = po->priv->current;
+ while (msg = g_list_previous (msg))
+ {
+ if (gtranslator_msg_is_fuzzy (msg->data))
+ return msg;
+ }
- return NULL;
+ return NULL;
}
@@ -1057,18 +1095,18 @@ gtranslator_po_get_prev_fuzzy(GtranslatorPo *po)
* Return value: a pointer to the next untranslated message
**/
GList *
-gtranslator_po_get_next_untrans(GtranslatorPo *po)
+gtranslator_po_get_next_untrans (GtranslatorPo * po)
{
- GList *msg;
+ GList *msg;
- msg = po->priv->current;
- while (msg = g_list_next(msg))
- {
- if(!gtranslator_msg_is_translated(msg->data))
- return msg;
- }
+ msg = po->priv->current;
+ while (msg = g_list_next (msg))
+ {
+ if (!gtranslator_msg_is_translated (msg->data))
+ return msg;
+ }
- return NULL;
+ return NULL;
}
@@ -1080,18 +1118,18 @@ gtranslator_po_get_next_untrans(GtranslatorPo *po)
* or NULL if there are not previously untranslated message.
**/
GList *
-gtranslator_po_get_prev_untrans (GtranslatorPo *po)
+gtranslator_po_get_prev_untrans (GtranslatorPo * po)
{
- GList *msg;
+ GList *msg;
- msg = po->priv->current;
- while (msg = g_list_previous (msg))
- {
- if(!gtranslator_msg_is_translated (msg->data))
- return msg;
- }
+ msg = po->priv->current;
+ while (msg = g_list_previous (msg))
+ {
+ if (!gtranslator_msg_is_translated (msg->data))
+ return msg;
+ }
- return NULL;
+ return NULL;
}
/**
@@ -1102,19 +1140,19 @@ gtranslator_po_get_prev_untrans (GtranslatorPo *po)
* or NULL if there is not next fuzzy or untranslated message.
**/
GList *
-gtranslator_po_get_next_fuzzy_or_untrans (GtranslatorPo *po)
+gtranslator_po_get_next_fuzzy_or_untrans (GtranslatorPo * po)
{
- GList *msg;
+ GList *msg;
- msg = po->priv->current;
- while (msg = g_list_next (msg))
- {
- if (gtranslator_msg_is_fuzzy (msg->data) ||
- !gtranslator_msg_is_translated (msg->data))
- return msg;
- }
+ msg = po->priv->current;
+ while (msg = g_list_next (msg))
+ {
+ if (gtranslator_msg_is_fuzzy (msg->data) ||
+ !gtranslator_msg_is_translated (msg->data))
+ return msg;
+ }
- return NULL;
+ return NULL;
}
/**
@@ -1125,19 +1163,19 @@ gtranslator_po_get_next_fuzzy_or_untrans (GtranslatorPo *po)
* or NULL if there is not previously fuzzy or untranslated message.
**/
GList *
-gtranslator_po_get_prev_fuzzy_or_untrans (GtranslatorPo *po)
+gtranslator_po_get_prev_fuzzy_or_untrans (GtranslatorPo * po)
{
- GList *msg;
+ GList *msg;
- msg = po->priv->current;
- while (msg = g_list_previous (msg))
- {
- if (gtranslator_msg_is_fuzzy (msg->data) ||
- !gtranslator_msg_is_translated (msg->data))
- return msg;
- }
+ msg = po->priv->current;
+ while (msg = g_list_previous (msg))
+ {
+ if (gtranslator_msg_is_fuzzy (msg->data) ||
+ !gtranslator_msg_is_translated (msg->data))
+ return msg;
+ }
- return NULL;
+ return NULL;
}
/**
@@ -1148,12 +1186,11 @@ gtranslator_po_get_prev_fuzzy_or_untrans (GtranslatorPo *po)
* Gets the message at the given position.
*/
GList *
-gtranslator_po_get_msg_from_number (GtranslatorPo *po,
- gint number)
+gtranslator_po_get_msg_from_number (GtranslatorPo * po, gint number)
{
- g_return_val_if_fail (GTR_IS_PO (po), NULL);
+ g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return g_list_nth (po->priv->messages, number);
+ return g_list_nth (po->priv->messages, number);
}
/**
@@ -1163,16 +1200,15 @@ gtranslator_po_get_msg_from_number (GtranslatorPo *po,
* Return value: The #GtranslatorHeader of the @po.
**/
GtranslatorHeader *
-gtranslator_po_get_header(GtranslatorPo *po)
+gtranslator_po_get_header (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), NULL);
+ g_return_val_if_fail (GTR_IS_PO (po), NULL);
- return po->priv->header;
+ return po->priv->header;
}
void
-gtranslator_po_set_header(GtranslatorPo *po,
- GtranslatorHeader *header)
+gtranslator_po_set_header (GtranslatorPo * po, GtranslatorHeader * header)
{
po->priv->header = header;
}
@@ -1184,11 +1220,11 @@ gtranslator_po_set_header(GtranslatorPo *po,
* Return value: the count of the translated messages.
**/
gint
-gtranslator_po_get_translated_count (GtranslatorPo *po)
+gtranslator_po_get_translated_count (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), -1);
+ g_return_val_if_fail (GTR_IS_PO (po), -1);
- return po->priv->translated;
+ return po->priv->translated;
}
/*
@@ -1197,14 +1233,15 @@ gtranslator_po_get_translated_count (GtranslatorPo *po)
* This funcs must not be exported.
*/
void
-_gtranslator_po_increase_decrease_translated (GtranslatorPo *po,
+_gtranslator_po_increase_decrease_translated (GtranslatorPo * po,
gboolean increase)
{
- g_return_if_fail (GTR_IS_PO (po));
+ g_return_if_fail (GTR_IS_PO (po));
- if (increase)
- po->priv->translated++;
- else po->priv->translated--;
+ if (increase)
+ po->priv->translated++;
+ else
+ po->priv->translated--;
}
/**
@@ -1214,11 +1251,11 @@ _gtranslator_po_increase_decrease_translated (GtranslatorPo *po,
* Return value: the count of the fuzzy messages.
**/
gint
-gtranslator_po_get_fuzzy_count (GtranslatorPo *po)
+gtranslator_po_get_fuzzy_count (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), -1);
+ g_return_val_if_fail (GTR_IS_PO (po), -1);
- return po->priv->fuzzy;
+ return po->priv->fuzzy;
}
/*
@@ -1227,14 +1264,15 @@ gtranslator_po_get_fuzzy_count (GtranslatorPo *po)
* This funcs must not be exported.
*/
void
-_gtranslator_po_increase_decrease_fuzzy (GtranslatorPo *po,
+_gtranslator_po_increase_decrease_fuzzy (GtranslatorPo * po,
gboolean increase)
{
- g_return_if_fail (GTR_IS_PO (po));
+ g_return_if_fail (GTR_IS_PO (po));
- if (increase)
- po->priv->fuzzy++;
- else po->priv->fuzzy--;
+ if (increase)
+ po->priv->fuzzy++;
+ else
+ po->priv->fuzzy--;
}
/**
@@ -1244,14 +1282,15 @@ _gtranslator_po_increase_decrease_fuzzy (GtranslatorPo *po,
* Return value: the count of the untranslated messages.
**/
gint
-gtranslator_po_get_untranslated_count (GtranslatorPo *po)
+gtranslator_po_get_untranslated_count (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), -1);
+ g_return_val_if_fail (GTR_IS_PO (po), -1);
- /*DEBUG_PRINT ("length: %d | translated: %d | fuzzy: %d | untranslated: %d", g_list_length (po->priv->messages),
- po->priv->translated, po->priv->fuzzy, (g_list_length (po->priv->messages) - po->priv->translated - po->priv->fuzzy));*/
+ /*DEBUG_PRINT ("length: %d | translated: %d | fuzzy: %d | untranslated: %d", g_list_length (po->priv->messages),
+ po->priv->translated, po->priv->fuzzy, (g_list_length (po->priv->messages) - po->priv->translated - po->priv->fuzzy)); */
- return (g_list_length (po->priv->messages) - po->priv->translated - po->priv->fuzzy);
+ return (g_list_length (po->priv->messages) - po->priv->translated -
+ po->priv->fuzzy);
}
/**
@@ -1261,11 +1300,11 @@ gtranslator_po_get_untranslated_count (GtranslatorPo *po)
* Return value: the number of messages messages.
**/
gint
-gtranslator_po_get_messages_count (GtranslatorPo *po)
+gtranslator_po_get_messages_count (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), -1);
+ g_return_val_if_fail (GTR_IS_PO (po), -1);
- return g_list_length (po->priv->messages);
+ return g_list_length (po->priv->messages);
}
/**
@@ -1275,11 +1314,11 @@ gtranslator_po_get_messages_count (GtranslatorPo *po)
* Return value: the number of the current message.
**/
gint
-gtranslator_po_get_message_position (GtranslatorPo *po)
+gtranslator_po_get_message_position (GtranslatorPo * po)
{
- g_return_val_if_fail (GTR_IS_PO (po), -1);
+ g_return_val_if_fail (GTR_IS_PO (po), -1);
- return gtranslator_msg_get_po_position (GTR_MSG (po->priv->current->data));
+ return gtranslator_msg_get_po_position (GTR_MSG (po->priv->current->data));
}
/**
@@ -1291,17 +1330,17 @@ gtranslator_po_get_message_position (GtranslatorPo *po)
* with g_free.
**/
gchar *
-gtranslator_po_check_po_file (GtranslatorPo *po)
+gtranslator_po_check_po_file (GtranslatorPo * po)
{
- struct po_xerror_handler handler;
+ struct po_xerror_handler handler;
- g_return_val_if_fail (po != NULL, NULL);
+ g_return_val_if_fail (po != NULL, NULL);
- handler.xerror = &on_gettext_po_xerror;
- handler.xerror2 = &on_gettext_po_xerror2;
- message_error = NULL;
+ handler.xerror = &on_gettext_po_xerror;
+ handler.xerror2 = &on_gettext_po_xerror2;
+ message_error = NULL;
- po_file_check_all (po->priv->gettext_po_file, &handler);
+ po_file_check_all (po->priv->gettext_po_file, &handler);
- return message_error;
+ return message_error;
}
diff --git a/src/po.h b/src/po.h
index 1e0821c..ebad674 100644
--- a/src/po.h
+++ b/src/po.h
@@ -33,7 +33,6 @@
#include "header.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -43,135 +42,138 @@ 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, GtranslatorPoClass))
-
/* Private structure type */
-typedef struct _GtranslatorPoPrivate GtranslatorPoPrivate;
+typedef struct _GtranslatorPoPrivate GtranslatorPoPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorPo GtranslatorPo;
+typedef struct _GtranslatorPo GtranslatorPo;
struct _GtranslatorPo
{
- GObject parent_instance;
-
- /*< private > */
- GtranslatorPoPrivate *priv;
+ GObject parent_instance;
+
+ /*< private > */
+ GtranslatorPoPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorPoClass GtranslatorPoClass;
+typedef struct _GtranslatorPoClass GtranslatorPoClass;
struct _GtranslatorPoClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
#define GTR_PO_ERROR gtranslator_po_error_quark()
enum
{
- GTR_PO_ERROR_GETTEXT,
- GTR_PO_ERROR_FILENAME,
- GTR_PO_ERROR_RECOVERY,
- GTR_PO_ERROR_FILE_EMPTY,
- GTR_PO_ERROR_OTHER,
+ GTR_PO_ERROR_GETTEXT,
+ GTR_PO_ERROR_FILENAME,
+ GTR_PO_ERROR_RECOVERY,
+ GTR_PO_ERROR_FILE_EMPTY,
+ GTR_PO_ERROR_OTHER,
};
typedef enum
{
- GTR_PO_STATE_SAVED,
- GTR_PO_STATE_MODIFIED
-}GtranslatorPoState;
+ GTR_PO_STATE_SAVED,
+ GTR_PO_STATE_MODIFIED
+} GtranslatorPoState;
/*
* Public methods
*/
-GQuark gtranslator_po_error_quark (void);
+GQuark gtranslator_po_error_quark (void);
-GType gtranslator_po_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_po_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_po_register_type (GTypeModule * module);
+ GType gtranslator_po_register_type (GTypeModule * module);
-GtranslatorPo *gtranslator_po_new (void);
+ GtranslatorPo *gtranslator_po_new (void);
-void gtranslator_po_parse (GtranslatorPo *po,
- GFile *filename,
- GError **error);
+ void gtranslator_po_parse (GtranslatorPo * po,
+ GFile * filename, GError ** error);
-void gtranslator_po_save_header_in_msg (GtranslatorPo *po,
- GtranslatorHeader *header);
+ void gtranslator_po_save_header_in_msg (GtranslatorPo * po,
+ GtranslatorHeader * header);
-void gtranslator_po_save_file (GtranslatorPo *po,
- GError **error);
-
-GtranslatorPoState gtranslator_po_get_state (GtranslatorPo *po);
+ void gtranslator_po_save_file (GtranslatorPo * po, GError ** error);
-void gtranslator_po_set_state (GtranslatorPo *po,
- GtranslatorPoState state);
+ GtranslatorPoState gtranslator_po_get_state (GtranslatorPo * po);
-GFile *gtranslator_po_get_location (GtranslatorPo *po);
+ void gtranslator_po_set_state (GtranslatorPo * po,
+ GtranslatorPoState state);
-void gtranslator_po_set_location (GtranslatorPo *po,
- GFile *location);
+ GFile *gtranslator_po_get_location (GtranslatorPo * po);
-gboolean gtranslator_po_get_write_perms (GtranslatorPo *po);
+ void gtranslator_po_set_location (GtranslatorPo * po, GFile * location);
-GList *gtranslator_po_get_messages (GtranslatorPo *po);
+ gboolean gtranslator_po_get_write_perms (GtranslatorPo * po);
-void gtranslator_po_set_messages (GtranslatorPo *po,
- GList *messages);
+ GList *gtranslator_po_get_messages (GtranslatorPo * po);
-GList *gtranslator_po_get_current_message (GtranslatorPo *po);
+ void gtranslator_po_set_messages (GtranslatorPo * po, GList * messages);
-GList *gtranslator_po_get_domains (GtranslatorPo *po);
+ GList *gtranslator_po_get_current_message (GtranslatorPo * po);
-po_file_t gtranslator_po_get_po_file (GtranslatorPo *po);
+ GList *gtranslator_po_get_domains (GtranslatorPo * po);
-GList *gtranslator_po_get_next_fuzzy (GtranslatorPo *po);
+ po_file_t gtranslator_po_get_po_file (GtranslatorPo * po);
-GList *gtranslator_po_get_prev_fuzzy (GtranslatorPo *po);
+ GList *gtranslator_po_get_next_fuzzy (GtranslatorPo * po);
-GList *gtranslator_po_get_next_untrans (GtranslatorPo *po);
+ GList *gtranslator_po_get_prev_fuzzy (GtranslatorPo * po);
-GList *gtranslator_po_get_prev_untrans (GtranslatorPo *po);
+ GList *gtranslator_po_get_next_untrans (GtranslatorPo * po);
-GList *gtranslator_po_get_next_fuzzy_or_untrans (GtranslatorPo *po);
+ GList *gtranslator_po_get_prev_untrans (GtranslatorPo * po);
-GList *gtranslator_po_get_prev_fuzzy_or_untrans (GtranslatorPo *po);
+ GList *gtranslator_po_get_next_fuzzy_or_untrans (GtranslatorPo * po);
-GList *gtranslator_po_get_msg_from_number (GtranslatorPo *po,
- gint number);
+ GList *gtranslator_po_get_prev_fuzzy_or_untrans (GtranslatorPo * po);
-GtranslatorHeader
- *gtranslator_po_get_header (GtranslatorPo *po);
+ GList *gtranslator_po_get_msg_from_number (GtranslatorPo * po,
+ gint number);
-void gtranslator_po_set_header (GtranslatorPo *po,
- GtranslatorHeader *header);
+GtranslatorHeader * gtranslator_po_get_header (GtranslatorPo * po);
-gint gtranslator_po_get_translated_count (GtranslatorPo *po);
+ void
+ gtranslator_po_set_header (GtranslatorPo * po,
+ GtranslatorHeader * header);
-gint gtranslator_po_get_fuzzy_count (GtranslatorPo *po);
+ gint
+ gtranslator_po_get_translated_count (GtranslatorPo * po);
-gint gtranslator_po_get_untranslated_count (GtranslatorPo *po);
+ gint
+ gtranslator_po_get_fuzzy_count (GtranslatorPo * po);
-gint gtranslator_po_get_messages_count (GtranslatorPo *po);
+ gint
+ gtranslator_po_get_untranslated_count (GtranslatorPo * po);
-gint gtranslator_po_get_message_position (GtranslatorPo *po);
+ gint
+ gtranslator_po_get_messages_count (GtranslatorPo * po);
-gchar *gtranslator_po_check_po_file (GtranslatorPo *po);
+ gint
+ gtranslator_po_get_message_position (GtranslatorPo * po);
+
+ gchar *
+ gtranslator_po_check_po_file (GtranslatorPo * po);
/* Unexported funcs */
-void _gtranslator_po_increase_decrease_translated
- (GtranslatorPo *po,
- gboolean increase);
+ void
+ _gtranslator_po_increase_decrease_translated
+ (GtranslatorPo * po, gboolean increase);
-void _gtranslator_po_increase_decrease_fuzzy(GtranslatorPo *po,
- gboolean increase);
+ void
+ _gtranslator_po_increase_decrease_fuzzy (GtranslatorPo * po,
+ gboolean increase);
G_END_DECLS
-
#endif /* __PO_H__ */
diff --git a/src/prefs-manager-app.c b/src/prefs-manager-app.c
index f310229..7baa3a1 100644
--- a/src/prefs-manager-app.c
+++ b/src/prefs-manager-app.c
@@ -42,40 +42,50 @@
#include "view.h"
#include "window.h"
-static void gtranslator_prefs_manager_editor_font_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-static void gtranslator_prefs_manager_spellcheck_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-static void gtranslator_prefs_manager_highlight_changed(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-static void gtranslator_prefs_manager_visible_whitespace_changed(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-static void gtranslator_prefs_manager_gdl_style_changed(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-static void gtranslator_prefs_manager_autosave_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
-
-static void gtranslator_prefs_manager_scheme_color_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
+static void gtranslator_prefs_manager_editor_font_changed (GConfClient *
+ client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer
+ user_data);
+
+static void gtranslator_prefs_manager_spellcheck_changed (GConfClient *
+ client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data);
+
+static void gtranslator_prefs_manager_highlight_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data);
+
+static void gtranslator_prefs_manager_visible_whitespace_changed (GConfClient
+ * client,
+ guint
+ cnxn_id,
+ GConfEntry *
+ entry,
+ gpointer
+ user_data);
+
+static void gtranslator_prefs_manager_gdl_style_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data);
+
+static void gtranslator_prefs_manager_autosave_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data);
+
+static void gtranslator_prefs_manager_scheme_color_changed (GConfClient *
+ client,
+ guint cnxn_id,
+ GConfEntry *
+ entry,
+ gpointer
+ user_data);
/* GUI state is serialized to a .desktop file, not in gconf */
@@ -103,307 +113,278 @@ static gint comment_pane_pos = -1;
static GKeyFile *
get_gtranslator_state_file ()
{
- static GKeyFile *state_file = NULL;
+ static GKeyFile *state_file = NULL;
- if (state_file == NULL)
+ if (state_file == NULL)
+ {
+ gchar *config_folder;
+ gchar *path;
+ GError *err = NULL;
+
+ state_file = g_key_file_new ();
+
+ config_folder = gtranslator_utils_get_user_config_dir ();
+ path = g_build_filename (config_folder, GTR_STATE_FILE_NAME, NULL);
+ g_free (config_folder);
+
+ if (!g_key_file_load_from_file (state_file,
+ path, G_KEY_FILE_NONE, &err))
{
- gchar *config_folder;
- gchar *path;
- GError *err = NULL;
-
- state_file = g_key_file_new ();
-
- config_folder = gtranslator_utils_get_user_config_dir ();
- path = g_build_filename (config_folder,
- GTR_STATE_FILE_NAME,
- NULL);
- g_free (config_folder);
-
- if (!g_key_file_load_from_file (state_file,
- path,
- G_KEY_FILE_NONE,
- &err))
- {
- if (err->domain != G_FILE_ERROR ||
- err->code != G_FILE_ERROR_NOENT)
- {
- g_warning ("Could not load gtranslator state file: %s\n",
- err->message);
- }
- g_error_free (err);
- }
- g_free (path);
+ if (err->domain != G_FILE_ERROR || err->code != G_FILE_ERROR_NOENT)
+ {
+ g_warning ("Could not load gtranslator state file: %s\n",
+ err->message);
+ }
+ g_error_free (err);
}
+ g_free (path);
+ }
- g_return_val_if_fail (state_file != NULL, NULL);
- return state_file;
+ g_return_val_if_fail (state_file != NULL, NULL);
+ return state_file;
}
static void
-gtranslator_state_get_int (const gchar *group,
- const gchar *key,
- gint defval,
- gint *result)
+gtranslator_state_get_int (const gchar * group,
+ const gchar * key, gint defval, gint * result)
{
- GKeyFile *state_file;
- gint res;
- GError *err = NULL;
-
- state_file = get_gtranslator_state_file ();
- res = g_key_file_get_integer (state_file,
- group,
- key,
- &err);
-
- if (err != NULL)
+ GKeyFile *state_file;
+ gint res;
+ GError *err = NULL;
+
+ state_file = get_gtranslator_state_file ();
+ res = g_key_file_get_integer (state_file, group, key, &err);
+
+ if (err != NULL)
+ {
+ if ((err->domain != G_KEY_FILE_ERROR) ||
+ ((err->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND &&
+ err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
{
- if ((err->domain != G_KEY_FILE_ERROR) ||
- ((err->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND &&
- err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
- {
- g_warning ("Could not get state value %s::%s : %s\n",
- group,
- key,
- err->message);
- }
-
- if (defval > 0)
- *result = defval;
-
- g_error_free (err);
- }
- else
- {
- *result = res;
+ g_warning ("Could not get state value %s::%s : %s\n",
+ group, key, err->message);
}
+
+ if (defval > 0)
+ *result = defval;
+
+ g_error_free (err);
+ }
+ else
+ {
+ *result = res;
+ }
}
static void
-gtranslator_state_set_int (const gchar *group,
- const gchar *key,
- gint value)
+gtranslator_state_set_int (const gchar * group, const gchar * key, gint value)
{
- GKeyFile *state_file;
+ GKeyFile *state_file;
- state_file = get_gtranslator_state_file ();
- g_key_file_set_integer (state_file,
- group,
- key,
- value);
+ state_file = get_gtranslator_state_file ();
+ g_key_file_set_integer (state_file, group, key, value);
}
static gboolean
gtranslator_state_file_sync ()
{
- GKeyFile *state_file;
- gchar *config_folder;
- gchar *path;
- gchar *content;
- gsize length;
- GError *err = NULL;
- gboolean ret = FALSE;
-
- state_file = get_gtranslator_state_file ();
- g_return_val_if_fail (state_file != NULL, FALSE);
-
- config_folder = gtranslator_utils_get_user_config_dir ();
- path = g_build_filename (config_folder,
- GTR_STATE_FILE_NAME,
- NULL);
- g_free (config_folder);
-
- content = g_key_file_to_data (state_file,
- &length,
- &err);
-
- if (err != NULL)
- {
- g_warning ("Could not get data from state file: %s\n",
- err->message);
- goto out;
- }
-
- if ((content != NULL) &&
- (!g_file_set_contents (path,
- content,
- length,
- &err)))
- {
- g_warning ("Could not write gtranslator state file: %s\n",
- err->message);
- goto out;
- }
-
- ret = TRUE;
-
- out:
- if (err != NULL)
- g_error_free (err);
-
- g_free (content);
- g_free (path);
-
- return TRUE;
+ GKeyFile *state_file;
+ gchar *config_folder;
+ gchar *path;
+ gchar *content;
+ gsize length;
+ GError *err = NULL;
+ gboolean ret = FALSE;
+
+ state_file = get_gtranslator_state_file ();
+ g_return_val_if_fail (state_file != NULL, FALSE);
+
+ config_folder = gtranslator_utils_get_user_config_dir ();
+ path = g_build_filename (config_folder, GTR_STATE_FILE_NAME, NULL);
+ g_free (config_folder);
+
+ content = g_key_file_to_data (state_file, &length, &err);
+
+ if (err != NULL)
+ {
+ g_warning ("Could not get data from state file: %s\n", err->message);
+ goto out;
+ }
+
+ if ((content != NULL) &&
+ (!g_file_set_contents (path, content, length, &err)))
+ {
+ g_warning ("Could not write gtranslator state file: %s\n",
+ err->message);
+ goto out;
+ }
+
+ ret = TRUE;
+
+out:
+ if (err != NULL)
+ g_error_free (err);
+
+ g_free (content);
+ g_free (path);
+
+ return TRUE;
}
/* Window state */
gint
gtranslator_prefs_manager_get_window_state (void)
{
- if (window_state == -1)
- {
- gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_WINDOW_STATE,
- GTR_STATE_DEFAULT_WINDOW_STATE,
- &window_state);
- }
-
- return window_state;
+ if (window_state == -1)
+ {
+ gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_WINDOW_STATE,
+ GTR_STATE_DEFAULT_WINDOW_STATE,
+ &window_state);
+ }
+
+ return window_state;
}
-
+
void
gtranslator_prefs_manager_set_window_state (gint ws)
{
- g_return_if_fail (ws > -1);
-
- window_state = ws;
+ g_return_if_fail (ws > -1);
+
+ window_state = ws;
- gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_WINDOW_STATE,
- ws);
+ gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_WINDOW_STATE, ws);
}
gboolean
gtranslator_prefs_manager_window_state_can_set (void)
{
- return TRUE;
+ return TRUE;
}
/* Window size */
void
-gtranslator_prefs_manager_get_window_size (gint *width, gint *height)
+gtranslator_prefs_manager_get_window_size (gint * width, gint * height)
{
- g_return_if_fail (width != NULL && height != NULL);
-
- if (window_width == -1)
- {
- gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_WINDOW_WIDTH,
- GTR_STATE_DEFAULT_WINDOW_WIDTH,
- &window_width);
- }
-
- if (window_height == -1)
- {
- gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_WINDOW_HEIGHT,
- GTR_STATE_DEFAULT_WINDOW_HEIGHT,
- &window_height);
- }
-
- *width = window_width;
- *height = window_height;
+ g_return_if_fail (width != NULL && height != NULL);
+
+ if (window_width == -1)
+ {
+ gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_WINDOW_WIDTH,
+ GTR_STATE_DEFAULT_WINDOW_WIDTH,
+ &window_width);
+ }
+
+ if (window_height == -1)
+ {
+ gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_WINDOW_HEIGHT,
+ GTR_STATE_DEFAULT_WINDOW_HEIGHT,
+ &window_height);
+ }
+
+ *width = window_width;
+ *height = window_height;
}
void
-gtranslator_prefs_manager_get_default_window_size (gint *width, gint *height)
+gtranslator_prefs_manager_get_default_window_size (gint * width,
+ gint * height)
{
- g_return_if_fail (width != NULL && height != NULL);
+ g_return_if_fail (width != NULL && height != NULL);
- *width = GTR_STATE_DEFAULT_WINDOW_WIDTH;
- *height = GTR_STATE_DEFAULT_WINDOW_HEIGHT;
+ *width = GTR_STATE_DEFAULT_WINDOW_WIDTH;
+ *height = GTR_STATE_DEFAULT_WINDOW_HEIGHT;
}
void
gtranslator_prefs_manager_set_window_size (gint width, gint height)
{
- g_return_if_fail (width > -1 && height > -1);
-
- window_width = width;
- window_height = height;
-
- gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_WINDOW_WIDTH,
- width);
- gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_WINDOW_HEIGHT,
- height);
+ g_return_if_fail (width > -1 && height > -1);
+
+ window_width = width;
+ window_height = height;
+
+ gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_WINDOW_WIDTH, width);
+ gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_WINDOW_HEIGHT, height);
}
-gboolean
+gboolean
gtranslator_prefs_manager_window_size_can_set (void)
{
- return TRUE;
+ return TRUE;
}
/* Content pane */
gint
gtranslator_prefs_manager_get_content_pane_pos (void)
{
- if (content_pane_pos == -1)
- {
- gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_CONTENT_PANE_POS,
- GTR_STATE_DEFAULT_CONTENT_PANE_POS,
- &content_pane_pos);
- }
-
- return content_pane_pos;
+ if (content_pane_pos == -1)
+ {
+ gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_CONTENT_PANE_POS,
+ GTR_STATE_DEFAULT_CONTENT_PANE_POS,
+ &content_pane_pos);
+ }
+
+ return content_pane_pos;
}
gint
gtranslator_prefs_manager_get_default_content_pane_pos (void)
{
- return GTR_STATE_DEFAULT_CONTENT_PANE_POS;
+ return GTR_STATE_DEFAULT_CONTENT_PANE_POS;
}
void
gtranslator_prefs_manager_set_content_pane_pos (gint new_pane_pos)
{
- g_return_if_fail (new_pane_pos > -1);
+ g_return_if_fail (new_pane_pos > -1);
- if (content_pane_pos == new_pane_pos)
- return;
+ if (content_pane_pos == new_pane_pos)
+ return;
- content_pane_pos = new_pane_pos;
- gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_CONTENT_PANE_POS,
- new_pane_pos);
+ content_pane_pos = new_pane_pos;
+ gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_CONTENT_PANE_POS, new_pane_pos);
}
/* Comment pane */
gint
gtranslator_prefs_manager_get_comment_pane_pos (void)
{
- if (comment_pane_pos == -1)
- {
- gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_COMMENT_PANE_POS,
- GTR_STATE_DEFAULT_COMMENT_PANE_POS,
- &comment_pane_pos);
- }
-
- return comment_pane_pos;
+ if (comment_pane_pos == -1)
+ {
+ gtranslator_state_get_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_COMMENT_PANE_POS,
+ GTR_STATE_DEFAULT_COMMENT_PANE_POS,
+ &comment_pane_pos);
+ }
+
+ return comment_pane_pos;
}
gint
gtranslator_prefs_manager_get_default_comment_pane_pos (void)
{
- return GTR_STATE_DEFAULT_COMMENT_PANE_POS;
+ return GTR_STATE_DEFAULT_COMMENT_PANE_POS;
}
void
gtranslator_prefs_manager_set_comment_pane_pos (gint new_pane_pos)
{
- g_return_if_fail (new_pane_pos > -1);
+ g_return_if_fail (new_pane_pos > -1);
- if (comment_pane_pos == new_pane_pos)
- return;
+ if (comment_pane_pos == new_pane_pos)
+ return;
- comment_pane_pos = new_pane_pos;
- gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
- GTR_STATE_COMMENT_PANE_POS,
- new_pane_pos);
+ comment_pane_pos = new_pane_pos;
+ gtranslator_state_set_int (GTR_STATE_WINDOW_GROUP,
+ GTR_STATE_COMMENT_PANE_POS, new_pane_pos);
}
/* Normal prefs are stored in GConf */
@@ -412,292 +393,296 @@ gboolean
gtranslator_prefs_manager_app_init (void)
{
- g_return_val_if_fail (gtranslator_prefs_manager == NULL, FALSE);
-
- gtranslator_prefs_manager_init ();
-
- if (gtranslator_prefs_manager != NULL)
- {
- /* TODO: notify, add dirs */
- gconf_client_add_dir (gtranslator_prefs_manager->gconf_client,
- GPM_PREFS_DIR,
- GCONF_CLIENT_PRELOAD_RECURSIVE,
- NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_EDITOR_FONT,
- gtranslator_prefs_manager_editor_font_changed,
- NULL, NULL, NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_SPELLCHECK,
- gtranslator_prefs_manager_spellcheck_changed,
- NULL, NULL, NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_HIGHLIGHT_SYNTAX,
- gtranslator_prefs_manager_highlight_changed,
- NULL, NULL, NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_VISIBLE_WHITESPACE,
- gtranslator_prefs_manager_visible_whitespace_changed,
- NULL, NULL, NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_PANE_SWITCHER_STYLE,
- gtranslator_prefs_manager_gdl_style_changed,
- NULL, NULL, NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_AUTOSAVE,
- gtranslator_prefs_manager_autosave_changed,
- NULL, NULL, NULL);
-
- gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
- GPM_COLOR_SCHEME,
- gtranslator_prefs_manager_scheme_color_changed,
- NULL, NULL, NULL);
- }
-
- return gtranslator_prefs_manager != NULL;
+ g_return_val_if_fail (gtranslator_prefs_manager == NULL, FALSE);
+
+ gtranslator_prefs_manager_init ();
+
+ if (gtranslator_prefs_manager != NULL)
+ {
+ /* TODO: notify, add dirs */
+ gconf_client_add_dir (gtranslator_prefs_manager->gconf_client,
+ GPM_PREFS_DIR,
+ GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_EDITOR_FONT,
+ gtranslator_prefs_manager_editor_font_changed,
+ NULL, NULL, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_SPELLCHECK,
+ gtranslator_prefs_manager_spellcheck_changed,
+ NULL, NULL, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_HIGHLIGHT_SYNTAX,
+ gtranslator_prefs_manager_highlight_changed,
+ NULL, NULL, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_VISIBLE_WHITESPACE,
+ gtranslator_prefs_manager_visible_whitespace_changed,
+ NULL, NULL, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_PANE_SWITCHER_STYLE,
+ gtranslator_prefs_manager_gdl_style_changed,
+ NULL, NULL, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_AUTOSAVE,
+ gtranslator_prefs_manager_autosave_changed,
+ NULL, NULL, NULL);
+
+ gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+ GPM_COLOR_SCHEME,
+ gtranslator_prefs_manager_scheme_color_changed,
+ NULL, NULL, NULL);
+ }
+
+ return gtranslator_prefs_manager != NULL;
}
/* This function must be called before exiting gtranslator */
void
gtranslator_prefs_manager_app_shutdown ()
{
- gtranslator_prefs_manager_shutdown ();
+ gtranslator_prefs_manager_shutdown ();
- gtranslator_state_file_sync ();
+ gtranslator_state_file_sync ();
}
-static void
-gtranslator_prefs_manager_editor_font_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+static void
+gtranslator_prefs_manager_editor_font_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GList *views;
- GList *l;
- gchar *font = NULL;
- gboolean def = TRUE;
-
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
-
- if (strcmp (entry->key, GPM_USE_CUSTOM_FONT) == 0)
- {
- def = gconf_value_get_bool (entry->value);
-
- if (!def)
- font = g_strdup("Sans 10"); // Fix to use system font
- else
- font = g_strdup(gtranslator_prefs_manager_get_editor_font ());
- }
- else if (strcmp (entry->key, GPM_EDITOR_FONT) == 0)
- {
- font = g_strdup (gconf_value_get_string (entry->value));
-
- def = gtranslator_prefs_manager_get_use_custom_font ();
- }
- else
- return;
-
- g_return_if_fail (font != NULL);
-
- views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
- l = views;
-
- while (l != NULL)
- {
- /* Note: we use def=FALSE to avoid GtranslatorView to query gconf */
- gtranslator_view_set_font (GTR_VIEW (l->data), FALSE, font);
- l = l->next;
- }
-
- g_list_free (views);
- g_free (font);
+ GList *views;
+ GList *l;
+ gchar *font = NULL;
+ gboolean def = TRUE;
+
+ g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (entry->value != NULL);
+
+ if (strcmp (entry->key, GPM_USE_CUSTOM_FONT) == 0)
+ {
+ def = gconf_value_get_bool (entry->value);
+
+ if (!def)
+ font = g_strdup ("Sans 10"); // Fix to use system font
+ else
+ font = g_strdup (gtranslator_prefs_manager_get_editor_font ());
+ }
+ else if (strcmp (entry->key, GPM_EDITOR_FONT) == 0)
+ {
+ font = g_strdup (gconf_value_get_string (entry->value));
+
+ def = gtranslator_prefs_manager_get_use_custom_font ();
+ }
+ else
+ return;
+
+ g_return_if_fail (font != NULL);
+
+ views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
+ l = views;
+
+ while (l != NULL)
+ {
+ /* Note: we use def=FALSE to avoid GtranslatorView to query gconf */
+ gtranslator_view_set_font (GTR_VIEW (l->data), FALSE, font);
+ l = l->next;
+ }
+
+ g_list_free (views);
+ g_free (font);
}
-static void
-gtranslator_prefs_manager_spellcheck_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+static void
+gtranslator_prefs_manager_spellcheck_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GList *l;
- GList *views;
-
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
-
- l = views = gtranslator_application_get_views(GTR_APP, FALSE, TRUE);
-
- while(l != NULL)
- {
- gtranslator_view_enable_spellcheck(GTR_VIEW(l->data),
- gtranslator_prefs_manager_get_spellcheck());
- l = l->next;
- }
- g_list_free(views);
+ GList *l;
+ GList *views;
+
+ g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (entry->value != NULL);
+
+ l = views = gtranslator_application_get_views (GTR_APP, FALSE, TRUE);
+
+ while (l != NULL)
+ {
+ gtranslator_view_enable_spellcheck (GTR_VIEW (l->data),
+ gtranslator_prefs_manager_get_spellcheck
+ ());
+ l = l->next;
+ }
+ g_list_free (views);
}
static void
-gtranslator_prefs_manager_highlight_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+gtranslator_prefs_manager_highlight_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
+ g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (entry->value != NULL);
- if (strcmp (entry->key, GPM_HIGHLIGHT_SYNTAX) == 0)
- {
- gboolean enable;
- GList *views;
- GList *l;
- GtkSourceBuffer *buf;
+ if (strcmp (entry->key, GPM_HIGHLIGHT_SYNTAX) == 0)
+ {
+ gboolean enable;
+ GList *views;
+ GList *l;
+ GtkSourceBuffer *buf;
- enable = gconf_value_get_bool (entry->value);
+ enable = gconf_value_get_bool (entry->value);
- views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
- l = views;
+ views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
+ l = views;
- while (l != NULL)
- {
- buf = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(l->data)));
- g_return_if_fail (GTK_IS_SOURCE_BUFFER (buf));
-
- gtk_source_buffer_set_highlight_syntax (buf, enable);
+ while (l != NULL)
+ {
+ buf =
+ GTK_SOURCE_BUFFER (gtk_text_view_get_buffer
+ (GTK_TEXT_VIEW (l->data)));
+ g_return_if_fail (GTK_IS_SOURCE_BUFFER (buf));
- l = l->next;
- }
+ gtk_source_buffer_set_highlight_syntax (buf, enable);
- g_list_free (views);
+ l = l->next;
}
+
+ g_list_free (views);
+ }
}
static void
-gtranslator_prefs_manager_visible_whitespace_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+gtranslator_prefs_manager_visible_whitespace_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
-
- if (strcmp (entry->key, GPM_VISIBLE_WHITESPACE) == 0)
- {
- gboolean enable;
- GList *views;
- GList *l;
+ g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (entry->value != NULL);
- enable = gconf_value_get_bool (entry->value);
+ if (strcmp (entry->key, GPM_VISIBLE_WHITESPACE) == 0)
+ {
+ gboolean enable;
+ GList *views;
+ GList *l;
- views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
- l = views;
+ enable = gconf_value_get_bool (entry->value);
- while (l != NULL)
- {
- gtranslator_view_enable_visible_whitespace(GTR_VIEW(l->data), enable);
+ views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
+ l = views;
- l = l->next;
- }
+ while (l != NULL)
+ {
+ gtranslator_view_enable_visible_whitespace (GTR_VIEW (l->data),
+ enable);
- g_list_free (views);
+ l = l->next;
}
+
+ g_list_free (views);
+ }
}
static void
-gtranslator_prefs_manager_gdl_style_changed(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+gtranslator_prefs_manager_gdl_style_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GtranslatorWindow *window;
- GdlSwitcherStyle style;
- GdlDockLayout *layout_manager;
-
- window = gtranslator_application_get_active_window (GTR_APP);
-
- style = gtranslator_prefs_manager_get_pane_switcher_style ();
-
- layout_manager = GDL_DOCK_LAYOUT (_gtranslator_window_get_layout_manager (window));
-
- g_object_set (G_OBJECT (layout_manager->master),
- "switcher-style", style, NULL);
+ GtranslatorWindow *window;
+ GdlSwitcherStyle style;
+ GdlDockLayout *layout_manager;
+
+ window = gtranslator_application_get_active_window (GTR_APP);
+
+ style = gtranslator_prefs_manager_get_pane_switcher_style ();
+
+ layout_manager =
+ GDL_DOCK_LAYOUT (_gtranslator_window_get_layout_manager (window));
+
+ g_object_set (G_OBJECT (layout_manager->master),
+ "switcher-style", style, NULL);
}
static void
-gtranslator_prefs_manager_autosave_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+gtranslator_prefs_manager_autosave_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GList *tabs;
- GList *l;
- GtranslatorWindow *window;
+ GList *tabs;
+ GList *l;
+ GtranslatorWindow *window;
- g_return_if_fail (entry->key != NULL);
- g_return_if_fail (entry->value != NULL);
+ g_return_if_fail (entry->key != NULL);
+ g_return_if_fail (entry->value != NULL);
- window = gtranslator_application_get_active_window (GTR_APP);
+ window = gtranslator_application_get_active_window (GTR_APP);
- if (strcmp (entry->key, GPM_AUTOSAVE) == 0)
- {
- gboolean autosave;
+ if (strcmp (entry->key, GPM_AUTOSAVE) == 0)
+ {
+ gboolean autosave;
- autosave = gconf_value_get_bool (entry->value);
+ autosave = gconf_value_get_bool (entry->value);
- tabs = gtranslator_window_get_all_tabs (window);
+ tabs = gtranslator_window_get_all_tabs (window);
- for (l = tabs; l != NULL; l = g_list_next (l))
- {
- GtranslatorTab *tab = GTR_TAB (l->data);
-
- gtranslator_tab_set_autosave_enabled (tab, autosave);
- }
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ GtranslatorTab *tab = GTR_TAB (l->data);
- g_list_free (tabs);
+ gtranslator_tab_set_autosave_enabled (tab, autosave);
}
- else if (strcmp (entry->key, GPM_AUTOSAVE_INTERVAL) == 0)
- {
- gint autosave_interval;
- autosave_interval = gconf_value_get_int (entry->value);
+ g_list_free (tabs);
+ }
+ else if (strcmp (entry->key, GPM_AUTOSAVE_INTERVAL) == 0)
+ {
+ gint autosave_interval;
- if (autosave_interval <= 0)
- autosave_interval = 1;
+ autosave_interval = gconf_value_get_int (entry->value);
- tabs = gtranslator_window_get_all_tabs (window);
+ if (autosave_interval <= 0)
+ autosave_interval = 1;
- for (l = tabs; l != NULL; l = g_list_next (l))
- {
- GtranslatorTab *tab = GTR_TAB (l->data);
+ tabs = gtranslator_window_get_all_tabs (window);
- gtranslator_tab_set_autosave_interval (tab, autosave_interval);
- }
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ GtranslatorTab *tab = GTR_TAB (l->data);
- g_list_free (tabs);
+ gtranslator_tab_set_autosave_interval (tab, autosave_interval);
}
+
+ g_list_free (tabs);
+ }
}
static void
-gtranslator_prefs_manager_scheme_color_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+gtranslator_prefs_manager_scheme_color_changed (GConfClient * client,
+ guint cnxn_id,
+ GConfEntry * entry,
+ gpointer user_data)
{
- GList *views, *l;
-
- views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
-
- for (l = views; l != NULL; l = g_list_next (l))
- {
- gtranslator_view_reload_scheme_color (GTR_VIEW (l->data));
- }
+ GList *views, *l;
+
+ views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
+
+ for (l = views; l != NULL; l = g_list_next (l))
+ {
+ gtranslator_view_reload_scheme_color (GTR_VIEW (l->data));
+ }
}
diff --git a/src/prefs-manager-app.h b/src/prefs-manager-app.h
index d619924..dc84708 100644
--- a/src/prefs-manager-app.h
+++ b/src/prefs-manager-app.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GTR_PREFS_MANAGER_APP_H__
#define __GTR_PREFS_MANAGER_APP_H__
@@ -29,39 +29,37 @@
/** LIFE CYCLE MANAGEMENT FUNCTIONS **/
-gboolean gtranslator_prefs_manager_app_init (void);
+gboolean gtranslator_prefs_manager_app_init (void);
/* This function must be called before exiting gtranslator */
-void gtranslator_prefs_manager_app_shutdown (void);
+void gtranslator_prefs_manager_app_shutdown (void);
/* Window state */
-gint gtranslator_prefs_manager_get_window_state (void);
-void gtranslator_prefs_manager_set_window_state (gint ws);
-gboolean gtranslator_prefs_manager_window_state_can_set (void);
+gint gtranslator_prefs_manager_get_window_state (void);
+void gtranslator_prefs_manager_set_window_state (gint ws);
+gboolean gtranslator_prefs_manager_window_state_can_set (void);
/* Window size */
-void gtranslator_prefs_manager_get_window_size (gint *width,
- gint *height);
-void gtranslator_prefs_manager_get_default_window_size (gint *width,
- gint *height);
-void gtranslator_prefs_manager_set_window_size (gint width,
- gint height);
-gboolean gtranslator_prefs_manager_window_size_can_set (void);
+void gtranslator_prefs_manager_get_window_size (gint * width, gint * height);
+void gtranslator_prefs_manager_get_default_window_size (gint * width,
+ gint * height);
+void gtranslator_prefs_manager_set_window_size (gint width, gint height);
+gboolean gtranslator_prefs_manager_window_size_can_set (void);
/* Side panel */
-gint gtranslator_prefs_manager_get_side_panel_size (void);
-gint gtranslator_prefs_manager_get_default_side_panel_size(void);
-void gtranslator_prefs_manager_set_side_panel_size (gint ps);
-gboolean gtranslator_prefs_manager_side_panel_size_can_set (void);
-gint gtranslator_prefs_manager_get_side_panel_active_page (void);
-void gtranslator_prefs_manager_set_side_panel_active_page (gint id);
-gboolean gtranslator_prefs_manager_side_panel_active_page_can_set (void);
+gint gtranslator_prefs_manager_get_side_panel_size (void);
+gint gtranslator_prefs_manager_get_default_side_panel_size (void);
+void gtranslator_prefs_manager_set_side_panel_size (gint ps);
+gboolean gtranslator_prefs_manager_side_panel_size_can_set (void);
+gint gtranslator_prefs_manager_get_side_panel_active_page (void);
+void gtranslator_prefs_manager_set_side_panel_active_page (gint id);
+gboolean gtranslator_prefs_manager_side_panel_active_page_can_set (void);
/* Comment pane */
-gint gtranslator_prefs_manager_get_comment_pane_pos (void);
-gint gtranslator_prefs_manager_get_default_comment_pane_pos (void);
-void gtranslator_prefs_manager_set_comment_pane_pos (gint new_pane_pos);
+gint gtranslator_prefs_manager_get_comment_pane_pos (void);
+gint gtranslator_prefs_manager_get_default_comment_pane_pos (void);
+void gtranslator_prefs_manager_set_comment_pane_pos (gint new_pane_pos);
#endif /* __GTR_PREFS_MANAGER_APP_H__ */
diff --git a/src/prefs-manager-private.h b/src/prefs-manager-private.h
index 34e236a..e4f53b9 100644
--- a/src/prefs-manager-private.h
+++ b/src/prefs-manager-private.h
@@ -28,14 +28,13 @@
#include <gconf/gconf-client.h>
-typedef struct _GtranslatorPrefsManager GtranslatorPrefsManager;
+typedef struct _GtranslatorPrefsManager GtranslatorPrefsManager;
-struct _GtranslatorPrefsManager {
- GConfClient *gconf_client;
+struct _GtranslatorPrefsManager
+{
+ GConfClient *gconf_client;
};
extern GtranslatorPrefsManager *gtranslator_prefs_manager;
#endif /* __GTR_PREFS_MANAGER_PRIVATE_H__ */
-
-
diff --git a/src/prefs-manager.c b/src/prefs-manager.c
index 334d558..61507c4 100644
--- a/src/prefs-manager.c
+++ b/src/prefs-manager.c
@@ -87,278 +87,257 @@ gtranslator_prefs_manager_set_ ## name (const gchar* v) \
\
gtranslator_prefs_manager_set_string (key, \
v); \
-}
+}
GtranslatorPrefsManager *gtranslator_prefs_manager = NULL;
-static gboolean gtranslator_prefs_manager_get_bool (const gchar* key);
+static gboolean gtranslator_prefs_manager_get_bool (const gchar * key);
-static gint gtranslator_prefs_manager_get_int (const gchar* key);
+static gint gtranslator_prefs_manager_get_int (const gchar * key);
-static gchar *gtranslator_prefs_manager_get_string (const gchar* key);
+static gchar *gtranslator_prefs_manager_get_string (const gchar * key);
void
gtranslator_prefs_manager_init (void)
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- if (gtranslator_prefs_manager == NULL)
- {
- GConfClient *gconf_client;
+ if (gtranslator_prefs_manager == NULL)
+ {
+ GConfClient *gconf_client;
- gconf_client = gconf_client_get_default ();
- if (gconf_client == NULL)
- g_error("Failed to initialize preferences manager");
+ gconf_client = gconf_client_get_default ();
+ if (gconf_client == NULL)
+ g_error ("Failed to initialize preferences manager");
- gtranslator_prefs_manager = g_new0 (GtranslatorPrefsManager, 1);
+ gtranslator_prefs_manager = g_new0 (GtranslatorPrefsManager, 1);
- gtranslator_prefs_manager->gconf_client = gconf_client;
- }
+ gtranslator_prefs_manager->gconf_client = gconf_client;
+ }
}
void
gtranslator_prefs_manager_shutdown ()
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- g_object_unref (gtranslator_prefs_manager->gconf_client);
- gtranslator_prefs_manager->gconf_client = NULL;
+ g_object_unref (gtranslator_prefs_manager->gconf_client);
+ gtranslator_prefs_manager->gconf_client = NULL;
}
-static gboolean
-gtranslator_prefs_manager_get_bool (const gchar* key)
+static gboolean
+gtranslator_prefs_manager_get_bool (const gchar * key)
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- return gconf_client_get_bool (gtranslator_prefs_manager->gconf_client,
- key,
- NULL);
+ return gconf_client_get_bool (gtranslator_prefs_manager->gconf_client,
+ key, NULL);
}
-static gint
-gtranslator_prefs_manager_get_int (const gchar* key)
+static gint
+gtranslator_prefs_manager_get_int (const gchar * key)
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- return gconf_client_get_int (gtranslator_prefs_manager->gconf_client,
- key,
- NULL);
-}
+ return gconf_client_get_int (gtranslator_prefs_manager->gconf_client,
+ key, NULL);
+}
static gchar *
-gtranslator_prefs_manager_get_string (const gchar* key)
+gtranslator_prefs_manager_get_string (const gchar * key)
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- return gconf_client_get_string (gtranslator_prefs_manager->gconf_client,
- key,
- NULL);
-}
-
-static void
-gtranslator_prefs_manager_set_bool (const gchar* key, gboolean value)
-{
- //gtranslator_debug (DEBUG_PREFS);
-
- g_return_if_fail (gconf_client_key_is_writable (
- gtranslator_prefs_manager->gconf_client, key, NULL));
-
- gconf_client_set_bool (gtranslator_prefs_manager->gconf_client, key, value, NULL);
+ return gconf_client_get_string (gtranslator_prefs_manager->gconf_client,
+ key, NULL);
}
-static void
-gtranslator_prefs_manager_set_int (const gchar* key, gint value)
+static void
+gtranslator_prefs_manager_set_bool (const gchar * key, gboolean value)
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- g_return_if_fail (gconf_client_key_is_writable (
- gtranslator_prefs_manager->gconf_client, key, NULL));
-
- gconf_client_set_int (gtranslator_prefs_manager->gconf_client, key, value, NULL);
-}
+ g_return_if_fail (gconf_client_key_is_writable
+ (gtranslator_prefs_manager->gconf_client, key, NULL));
-static void
-gtranslator_prefs_manager_set_string (const gchar* key, const gchar* value)
-{
- //gtranslator_debug (DEBUG_PREFS);
-
- g_return_if_fail (value != NULL);
-
- g_return_if_fail (gconf_client_key_is_writable (
- gtranslator_prefs_manager->gconf_client, key, NULL));
-
- gconf_client_set_string (gtranslator_prefs_manager->gconf_client, key, value, NULL);
+ gconf_client_set_bool (gtranslator_prefs_manager->gconf_client, key, value,
+ NULL);
}
-static gboolean
-gtranslator_prefs_manager_key_is_writable (const gchar* key)
+static void
+gtranslator_prefs_manager_set_int (const gchar * key, gint value)
{
- //gtranslator_debug (DEBUG_PREFS);
+ //gtranslator_debug (DEBUG_PREFS);
- return gconf_client_key_is_writable (gtranslator_prefs_manager->gconf_client, key, NULL);
+ g_return_if_fail (gconf_client_key_is_writable
+ (gtranslator_prefs_manager->gconf_client, key, NULL));
+
+ gconf_client_set_int (gtranslator_prefs_manager->gconf_client, key, value,
+ NULL);
}
-/* Files */
-DEFINE_BOOL_PREF(warn_if_contains_fuzzy,
- GPM_WARN_IF_CONTAINS_FUZZY)
+static void
+gtranslator_prefs_manager_set_string (const gchar * key, const gchar * value)
+{
+ //gtranslator_debug (DEBUG_PREFS);
-DEFINE_BOOL_PREF(delete_compiled,
- GPM_DELETE_COMPILED)
+ g_return_if_fail (value != NULL);
-DEFINE_BOOL_PREF(autosave,
- GPM_AUTOSAVE)
+ g_return_if_fail (gconf_client_key_is_writable
+ (gtranslator_prefs_manager->gconf_client, key, NULL));
-DEFINE_INT_PREF(autosave_interval,
- GPM_AUTOSAVE_INTERVAL)
+ gconf_client_set_string (gtranslator_prefs_manager->gconf_client, key,
+ value, NULL);
+}
-DEFINE_BOOL_PREF(create_backup,
- GPM_CREATE_BACKUP)
+static gboolean
+gtranslator_prefs_manager_key_is_writable (const gchar * key)
+{
+ //gtranslator_debug (DEBUG_PREFS);
-DEFINE_BOOL_PREF(use_profile_values,
- GPM_USE_PROFILE_VALUES)
+ return gconf_client_key_is_writable (gtranslator_prefs_manager->
+ gconf_client, key, NULL);
+}
+/* Files */
+DEFINE_BOOL_PREF (warn_if_contains_fuzzy,
+ GPM_WARN_IF_CONTAINS_FUZZY)
+DEFINE_BOOL_PREF (delete_compiled,
+ GPM_DELETE_COMPILED)
+DEFINE_BOOL_PREF (autosave,
+ GPM_AUTOSAVE)
+DEFINE_INT_PREF (autosave_interval,
+ GPM_AUTOSAVE_INTERVAL)
+DEFINE_BOOL_PREF (create_backup,
+ GPM_CREATE_BACKUP)
+DEFINE_BOOL_PREF (use_profile_values, GPM_USE_PROFILE_VALUES)
/* Editor */
-DEFINE_BOOL_PREF(highlight_syntax,
- GPM_HIGHLIGHT_SYNTAX)
-
-DEFINE_BOOL_PREF(visible_whitespace,
- GPM_VISIBLE_WHITESPACE)
-
-DEFINE_BOOL_PREF(use_custom_font,
- GPM_USE_CUSTOM_FONT)
-
-DEFINE_STRING_PREF(editor_font,
- GPM_EDITOR_FONT)
-
-DEFINE_BOOL_PREF(unmark_fuzzy_when_changed,
- GPM_UNMARK_FUZZY_WHEN_CHANGED)
-
-DEFINE_BOOL_PREF(spellcheck,
- GPM_SPELLCHECK)
-
+ DEFINE_BOOL_PREF (highlight_syntax,
+ GPM_HIGHLIGHT_SYNTAX)
+DEFINE_BOOL_PREF (visible_whitespace,
+ GPM_VISIBLE_WHITESPACE)
+DEFINE_BOOL_PREF (use_custom_font,
+ GPM_USE_CUSTOM_FONT)
+DEFINE_STRING_PREF (editor_font,
+ GPM_EDITOR_FONT)
+DEFINE_BOOL_PREF (unmark_fuzzy_when_changed,
+ GPM_UNMARK_FUZZY_WHEN_CHANGED)
+DEFINE_BOOL_PREF (spellcheck, GPM_SPELLCHECK)
/* Translation Memory */
-DEFINE_STRING_PREF (po_directory,
+ DEFINE_STRING_PREF (po_directory,
GPM_PO_DIRECTORY)
-
DEFINE_BOOL_PREF (restrict_to_filename,
- GPM_RESTRICT_TO_FILENAME)
-
+ GPM_RESTRICT_TO_FILENAME)
DEFINE_STRING_PREF (filename_restriction,
GPM_FILENAME_RESTRICTION)
-
DEFINE_INT_PREF (max_missing_words,
GPM_MAX_MISSING_WORDS)
-
-DEFINE_INT_PREF (max_length_diff,
- GPM_MAX_LENGTH_DIFF)
-
+DEFINE_INT_PREF (max_length_diff, GPM_MAX_LENGTH_DIFF)
/* UI */
-
/* pane_switcher_style requires custom functions to deal with conversion from a
string to an enum */
-GdlSwitcherStyle
+ GdlSwitcherStyle
gtranslator_prefs_manager_get_pane_switcher_style (void)
{
- GdlSwitcherStyle pane_switcher_style;
- const gchar *v;
-
- v = gtranslator_prefs_manager_get_string (GPM_PANE_SWITCHER_STYLE);
- if (!g_strcmp0(v, "icons"))
- pane_switcher_style = GDL_SWITCHER_STYLE_ICON;
- else if (!g_strcmp0(v, "text"))
- pane_switcher_style = GDL_SWITCHER_STYLE_TEXT;
- else if (!g_strcmp0(v, "icons_and_text"))
- pane_switcher_style = GDL_SWITCHER_STYLE_BOTH;
- else if (!g_strcmp0(v, "tabs"))
- pane_switcher_style = GDL_SWITCHER_STYLE_TABS;
- else if (!g_strcmp0(v, "system"))
- pane_switcher_style = GDL_SWITCHER_STYLE_TOOLBAR;
- else
- pane_switcher_style = GDL_SWITCHER_STYLE_BOTH;
-
- return pane_switcher_style;
+ GdlSwitcherStyle pane_switcher_style;
+ const gchar *v;
+
+ v = gtranslator_prefs_manager_get_string (GPM_PANE_SWITCHER_STYLE);
+ if (!g_strcmp0 (v, "icons"))
+ pane_switcher_style = GDL_SWITCHER_STYLE_ICON;
+ else if (!g_strcmp0 (v, "text"))
+ pane_switcher_style = GDL_SWITCHER_STYLE_TEXT;
+ else if (!g_strcmp0 (v, "icons_and_text"))
+ pane_switcher_style = GDL_SWITCHER_STYLE_BOTH;
+ else if (!g_strcmp0 (v, "tabs"))
+ pane_switcher_style = GDL_SWITCHER_STYLE_TABS;
+ else if (!g_strcmp0 (v, "system"))
+ pane_switcher_style = GDL_SWITCHER_STYLE_TOOLBAR;
+ else
+ pane_switcher_style = GDL_SWITCHER_STYLE_BOTH;
+
+ return pane_switcher_style;
}
void
-gtranslator_prefs_manager_set_pane_switcher_style (GdlSwitcherStyle pane_switcher_style)
+gtranslator_prefs_manager_set_pane_switcher_style (GdlSwitcherStyle
+ pane_switcher_style)
{
- const gchar *v;
-
- switch (pane_switcher_style) {
- case GDL_SWITCHER_STYLE_ICON:
- v = "icons";
- break;
-
- case GDL_SWITCHER_STYLE_TEXT:
- v = "text";
- break;
-
- case GDL_SWITCHER_STYLE_TABS:
- v = "tabs";
- break;
-
- case GDL_SWITCHER_STYLE_TOOLBAR:
- v = "system";
- break;
-
- case GDL_SWITCHER_STYLE_BOTH:
- default:
- v = "icons_and_text";
- }
- gtranslator_prefs_manager_set_string (GPM_PANE_SWITCHER_STYLE,
- v);
+ const gchar *v;
+
+ switch (pane_switcher_style)
+ {
+ case GDL_SWITCHER_STYLE_ICON:
+ v = "icons";
+ break;
+
+ case GDL_SWITCHER_STYLE_TEXT:
+ v = "text";
+ break;
+
+ case GDL_SWITCHER_STYLE_TABS:
+ v = "tabs";
+ break;
+
+ case GDL_SWITCHER_STYLE_TOOLBAR:
+ v = "system";
+ break;
+
+ case GDL_SWITCHER_STYLE_BOTH:
+ default:
+ v = "icons_and_text";
+ }
+ gtranslator_prefs_manager_set_string (GPM_PANE_SWITCHER_STYLE, v);
}
-DEFINE_STRING_PREF (color_scheme,
- GPM_COLOR_SCHEME)
-
+DEFINE_STRING_PREF (color_scheme, GPM_COLOR_SCHEME)
/* sort_order requires custom functions to deal with conversion from a string to
an enum */
-GtranslatorSortOrder
+ GtranslatorSortOrder
gtranslator_prefs_manager_get_sort_order (void)
{
- GtranslatorSortOrder sort_order;
- const gchar *v;
-
- v = gtranslator_prefs_manager_get_string (GPM_SORT_ORDER);
- if (!g_strcmp0(v, "status"))
- sort_order = GTR_SORT_ORDER_STATUS;
- else if (!g_strcmp0(v, "id"))
- sort_order = GTR_SORT_ORDER_ID;
- else if (!g_strcmp0(v, "original_text"))
- sort_order = GTR_SORT_ORDER_ORIGINAL_TEXT;
- else if (!g_strcmp0(v, "translated_text"))
- sort_order = GTR_SORT_ORDER_TRANSLATED_TEXT;
- else
- sort_order = GTR_SORT_ORDER_ID;
-
- return sort_order;
+ GtranslatorSortOrder sort_order;
+ const gchar *v;
+
+ v = gtranslator_prefs_manager_get_string (GPM_SORT_ORDER);
+ if (!g_strcmp0 (v, "status"))
+ sort_order = GTR_SORT_ORDER_STATUS;
+ else if (!g_strcmp0 (v, "id"))
+ sort_order = GTR_SORT_ORDER_ID;
+ else if (!g_strcmp0 (v, "original_text"))
+ sort_order = GTR_SORT_ORDER_ORIGINAL_TEXT;
+ else if (!g_strcmp0 (v, "translated_text"))
+ sort_order = GTR_SORT_ORDER_TRANSLATED_TEXT;
+ else
+ sort_order = GTR_SORT_ORDER_ID;
+
+ return sort_order;
}
void
gtranslator_prefs_manager_set_sort_order (GtranslatorSortOrder sort_order)
{
- const gchar *v;
-
- switch (sort_order) {
- case GTR_SORT_ORDER_STATUS:
- v = "status";
- break;
-
- case GTR_SORT_ORDER_ORIGINAL_TEXT:
- v = "original_text";
- break;
-
- case GTR_SORT_ORDER_TRANSLATED_TEXT:
- v = "translated_text";
- break;
-
- case GTR_SORT_ORDER_ID:
- default:
- v = "id";
- }
- gtranslator_prefs_manager_set_string (GPM_SORT_ORDER,
- v);
+ const gchar *v;
+
+ switch (sort_order)
+ {
+ case GTR_SORT_ORDER_STATUS:
+ v = "status";
+ break;
+
+ case GTR_SORT_ORDER_ORIGINAL_TEXT:
+ v = "original_text";
+ break;
+
+ case GTR_SORT_ORDER_TRANSLATED_TEXT:
+ v = "translated_text";
+ break;
+
+ case GTR_SORT_ORDER_ID:
+ default:
+ v = "id";
+ }
+ gtranslator_prefs_manager_set_string (GPM_SORT_ORDER, v);
}
diff --git a/src/prefs-manager.h b/src/prefs-manager.h
index 64126f7..237a33b 100644
--- a/src/prefs-manager.h
+++ b/src/prefs-manager.h
@@ -42,10 +42,10 @@
/* Useful enum for sort order pref */
typedef enum
{
- GTR_SORT_ORDER_STATUS,
- GTR_SORT_ORDER_ID,
- GTR_SORT_ORDER_ORIGINAL_TEXT,
- GTR_SORT_ORDER_TRANSLATED_TEXT
+ GTR_SORT_ORDER_STATUS,
+ GTR_SORT_ORDER_ID,
+ GTR_SORT_ORDER_ORIGINAL_TEXT,
+ GTR_SORT_ORDER_TRANSLATED_TEXT
} GtranslatorSortOrder;
#define GTR_BASE_KEY "/apps/gtranslator"
@@ -89,76 +89,85 @@ typedef enum
/** LIFE CYCLE MANAGEMENT FUNCTIONS **/
-void gtranslator_prefs_manager_init (void);
+void gtranslator_prefs_manager_init (void);
/* This function must be called before exiting gtranslator */
-void gtranslator_prefs_manager_shutdown (void);
+void gtranslator_prefs_manager_shutdown (void);
/** PREFS MANAGEMENT FUNCTIONS **/
/* Files */
-void gtranslator_prefs_manager_set_warn_if_contains_fuzzy (gboolean warn_if_contains_fuzzy);
-gboolean gtranslator_prefs_manager_get_warn_if_contains_fuzzy (void);
+void gtranslator_prefs_manager_set_warn_if_contains_fuzzy (gboolean
+ warn_if_contains_fuzzy);
+gboolean gtranslator_prefs_manager_get_warn_if_contains_fuzzy (void);
-void gtranslator_prefs_manager_set_delete_compiled (gboolean delete_compiled);
-gboolean gtranslator_prefs_manager_get_delete_compiled (void);
+void gtranslator_prefs_manager_set_delete_compiled (gboolean delete_compiled);
+gboolean gtranslator_prefs_manager_get_delete_compiled (void);
-void gtranslator_prefs_manager_set_autosave (gboolean autosave);
-gboolean gtranslator_prefs_manager_get_autosave (void);
+void gtranslator_prefs_manager_set_autosave (gboolean autosave);
+gboolean gtranslator_prefs_manager_get_autosave (void);
-void gtranslator_prefs_manager_set_autosave_interval (gint autosave_interval);
-gint gtranslator_prefs_manager_get_autosave_interval (void);
+void gtranslator_prefs_manager_set_autosave_interval (gint autosave_interval);
+gint gtranslator_prefs_manager_get_autosave_interval (void);
-void gtranslator_prefs_manager_set_create_backup (gboolean create_backup);
-gboolean gtranslator_prefs_manager_get_create_backup (void);
+void gtranslator_prefs_manager_set_create_backup (gboolean create_backup);
+gboolean gtranslator_prefs_manager_get_create_backup (void);
-void gtranslator_prefs_manager_set_use_profile_values (gboolean use_profile_values);
-gboolean gtranslator_prefs_manager_get_use_profile_values (void);
+void gtranslator_prefs_manager_set_use_profile_values (gboolean
+ use_profile_values);
+gboolean gtranslator_prefs_manager_get_use_profile_values (void);
/* Editor */
-void gtranslator_prefs_manager_set_highlight_syntax (gboolean highlight_syntax);
-gboolean gtranslator_prefs_manager_get_highlight_syntax (void);
+void gtranslator_prefs_manager_set_highlight_syntax (gboolean
+ highlight_syntax);
+gboolean gtranslator_prefs_manager_get_highlight_syntax (void);
-void gtranslator_prefs_manager_set_visible_whitespace (gboolean visible_whitespace);
-gboolean gtranslator_prefs_manager_get_visible_whitespace (void);
+void gtranslator_prefs_manager_set_visible_whitespace (gboolean
+ visible_whitespace);
+gboolean gtranslator_prefs_manager_get_visible_whitespace (void);
-void gtranslator_prefs_manager_set_use_custom_font (gboolean use_custom_font);
-gboolean gtranslator_prefs_manager_get_use_custom_font (void);
+void gtranslator_prefs_manager_set_use_custom_font (gboolean use_custom_font);
+gboolean gtranslator_prefs_manager_get_use_custom_font (void);
-void gtranslator_prefs_manager_set_editor_font (const gchar *editor_font);
-const gchar * gtranslator_prefs_manager_get_editor_font (void);
+void gtranslator_prefs_manager_set_editor_font (const gchar * editor_font);
+const gchar *gtranslator_prefs_manager_get_editor_font (void);
-void gtranslator_prefs_manager_set_unmark_fuzzy_when_changed (gboolean unmark_fuzzy_when_changed);
-gboolean gtranslator_prefs_manager_get_unmark_fuzzy_when_changed (void);
+void gtranslator_prefs_manager_set_unmark_fuzzy_when_changed (gboolean
+ unmark_fuzzy_when_changed);
+gboolean gtranslator_prefs_manager_get_unmark_fuzzy_when_changed (void);
-void gtranslator_prefs_manager_set_spellcheck (gboolean spellcheck);
-gboolean gtranslator_prefs_manager_get_spellcheck (void);
+void gtranslator_prefs_manager_set_spellcheck (gboolean spellcheck);
+gboolean gtranslator_prefs_manager_get_spellcheck (void);
/* Translation memory */
-void gtranslator_prefs_manager_set_po_directory (const gchar *po_directory);
-const gchar * gtranslator_prefs_manager_get_po_directory (void);
+void gtranslator_prefs_manager_set_po_directory (const gchar * po_directory);
+const gchar *gtranslator_prefs_manager_get_po_directory (void);
-void gtranslator_prefs_manager_set_restrict_to_filename (gboolean restrict_to_filename);
-gboolean gtranslator_prefs_manager_get_restrict_to_filename (void);
+void gtranslator_prefs_manager_set_restrict_to_filename (gboolean
+ restrict_to_filename);
+gboolean gtranslator_prefs_manager_get_restrict_to_filename (void);
-void gtranslator_prefs_manager_set_filename_restriction (const gchar *filename_restriction);
-const gchar * gtranslator_prefs_manager_get_filename_restriction (void);
+void gtranslator_prefs_manager_set_filename_restriction (const gchar *
+ filename_restriction);
+const gchar *gtranslator_prefs_manager_get_filename_restriction (void);
-void gtranslator_prefs_manager_set_max_missing_words (gint max_missing_words);
-gint gtranslator_prefs_manager_get_max_missing_words (void);
+void gtranslator_prefs_manager_set_max_missing_words (gint max_missing_words);
+gint gtranslator_prefs_manager_get_max_missing_words (void);
-void gtranslator_prefs_manager_set_max_length_diff (gint max_length_diff);
-gint gtranslator_prefs_manager_get_max_length_diff (void);
+void gtranslator_prefs_manager_set_max_length_diff (gint max_length_diff);
+gint gtranslator_prefs_manager_get_max_length_diff (void);
/* UI */
-void gtranslator_prefs_manager_set_pane_switcher_style (GdlSwitcherStyle pane_switcher_style);
-GdlSwitcherStyle gtranslator_prefs_manager_get_pane_switcher_style (void);
+void gtranslator_prefs_manager_set_pane_switcher_style (GdlSwitcherStyle
+ pane_switcher_style);
+GdlSwitcherStyle gtranslator_prefs_manager_get_pane_switcher_style (void);
-void gtranslator_prefs_manager_set_color_scheme (const gchar *color_scheme);
-const gchar * gtranslator_prefs_manager_get_color_scheme (void);
+void gtranslator_prefs_manager_set_color_scheme (const gchar * color_scheme);
+const gchar *gtranslator_prefs_manager_get_color_scheme (void);
-void gtranslator_prefs_manager_set_sort_order (GtranslatorSortOrder sort_order);
-GtranslatorSortOrder gtranslator_prefs_manager_get_sort_order (void);
+void gtranslator_prefs_manager_set_sort_order (GtranslatorSortOrder
+ sort_order);
+GtranslatorSortOrder gtranslator_prefs_manager_get_sort_order (void);
#endif /* __GTR_PREFS_MANAGER_H__ */
diff --git a/src/profile.c b/src/profile.c
index 3a6ede1..9f922a8 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -20,7 +20,7 @@
* Pablo Sanxiao <psanxiao gmail com>
*/
-#include "application.h"
+#include "application.h"
#include "profile.h"
#include "preferences-dialog.h"
#include "utils.h"
@@ -46,202 +46,231 @@
GTR_TYPE_PROFILE, \
GtranslatorProfilePrivate))
-G_DEFINE_TYPE(GtranslatorProfile, gtranslator_profile, G_TYPE_OBJECT)
-
-struct _GtranslatorProfilePrivate
-{
- /*
- * Identify the profile
- */
- gchar *name;
-
- /*
- * Translator's information
- */
- gchar *author_name;
- gchar *author_email;
-
- /*
- * Complete language name
- */
- gchar *language_name;
-
- /*
- * Language code. Example: "en" -> English
- */
- gchar *language_code;
-
- /*
- * Set of characters. Example: UTF-8
- */
- gchar *charset;
-
- /*
- * Encoding. Example: 8 bits
- */
- gchar *encoding;
-
- /*
- * Email of the group of translation
- */
- gchar *group_email;
-
- /*
- * Plural forms
- */
- gchar *plurals;
-};
-
-static void gtranslator_profile_init (GtranslatorProfile *profile)
+G_DEFINE_TYPE (GtranslatorProfile, gtranslator_profile, G_TYPE_OBJECT)
+ struct _GtranslatorProfilePrivate
+ {
+ /*
+ * Identify the profile
+ */
+ gchar *name;
+
+ /*
+ * Translator's information
+ */
+ gchar *author_name;
+ gchar *author_email;
+
+ /*
+ * Complete language name
+ */
+ gchar *language_name;
+
+ /*
+ * Language code. Example: "en" -> English
+ */
+ gchar *language_code;
+
+ /*
+ * Set of characters. Example: UTF-8
+ */
+ gchar *charset;
+
+ /*
+ * Encoding. Example: 8 bits
+ */
+ gchar *encoding;
+
+ /*
+ * Email of the group of translation
+ */
+ gchar *group_email;
+
+ /*
+ * Plural forms
+ */
+ gchar *plurals;
+ };
+
+ static void gtranslator_profile_init (GtranslatorProfile * profile)
{
- profile->priv = GTR_PROFILE_GET_PRIVATE (profile);
+ profile->priv = GTR_PROFILE_GET_PRIVATE (profile);
}
-static void gtranslator_profile_finalize (GObject *object)
+static void
+gtranslator_profile_finalize (GObject * object)
{
- GtranslatorProfile *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->plurals);
-
- G_OBJECT_CLASS (gtranslator_profile_parent_class)->finalize (object);
+ GtranslatorProfile *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->plurals);
+
+ G_OBJECT_CLASS (gtranslator_profile_parent_class)->finalize (object);
}
-static void gtranslator_profile_class_init (GtranslatorProfileClass *klass)
+static void
+gtranslator_profile_class_init (GtranslatorProfileClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorProfilePrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorProfilePrivate));
- object_class->finalize = gtranslator_profile_finalize;
+ object_class->finalize = gtranslator_profile_finalize;
}
/*
* Public methods
*/
-GtranslatorProfile *gtranslator_profile_new (void)
+GtranslatorProfile *
+gtranslator_profile_new (void)
{
- GtranslatorProfile *profile;
-
- profile = g_object_new (GTR_TYPE_PROFILE, NULL);
-
- return profile;
+ GtranslatorProfile *profile;
+
+ profile = g_object_new (GTR_TYPE_PROFILE, NULL);
+
+ return profile;
}
-const gchar *gtranslator_profile_get_name (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_name (GtranslatorProfile * profile)
{
- return profile->priv->name;
+ return profile->priv->name;
}
-void gtranslator_profile_set_name (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_name (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->name)
- g_free (profile->priv->name);
- profile->priv->name = g_strdup (data);
+ if (profile->priv->name)
+ g_free (profile->priv->name);
+ profile->priv->name = g_strdup (data);
}
-const gchar *gtranslator_profile_get_author_name (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_author_name (GtranslatorProfile * profile)
{
- return profile->priv->author_name;
+ return profile->priv->author_name;
}
-void gtranslator_profile_set_author_name (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_author_name (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->author_name)
- g_free (profile->priv->author_name);
- profile->priv->author_name = g_strdup (data);
+ if (profile->priv->author_name)
+ g_free (profile->priv->author_name);
+ profile->priv->author_name = g_strdup (data);
}
-const gchar *gtranslator_profile_get_author_email (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_author_email (GtranslatorProfile * profile)
{
- return profile->priv->author_email;
+ return profile->priv->author_email;
}
-void gtranslator_profile_set_author_email (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_author_email (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->author_email)
- g_free (profile->priv->author_email);
- profile->priv->author_email = g_strdup (data);
+ if (profile->priv->author_email)
+ g_free (profile->priv->author_email);
+ profile->priv->author_email = g_strdup (data);
}
-const gchar *gtranslator_profile_get_language_name (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_language_name (GtranslatorProfile * profile)
{
- return profile->priv->language_name;
+ return profile->priv->language_name;
}
-void gtranslator_profile_set_language_name (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_language_name (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->language_name)
- g_free (profile->priv->language_name);
- profile->priv->language_name = g_strdup (data);
+ if (profile->priv->language_name)
+ g_free (profile->priv->language_name);
+ profile->priv->language_name = g_strdup (data);
}
-const gchar *gtranslator_profile_get_language_code (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_language_code (GtranslatorProfile * profile)
{
- return profile->priv->language_code;
+ return profile->priv->language_code;
}
-void gtranslator_profile_set_language_code (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_language_code (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->language_code)
- g_free (profile->priv->language_code);
- profile->priv->language_code = g_strdup (data);
+ if (profile->priv->language_code)
+ g_free (profile->priv->language_code);
+ profile->priv->language_code = g_strdup (data);
}
-const gchar *gtranslator_profile_get_charset (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_charset (GtranslatorProfile * profile)
{
- return profile->priv->charset;
+ return profile->priv->charset;
}
-void gtranslator_profile_set_charset (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_charset (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->charset)
- g_free (profile->priv->charset);
- profile->priv->charset = g_strdup (data);
+ if (profile->priv->charset)
+ g_free (profile->priv->charset);
+ profile->priv->charset = g_strdup (data);
}
-const gchar *gtranslator_profile_get_encoding (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_encoding (GtranslatorProfile * profile)
{
- return profile->priv->encoding;
+ return profile->priv->encoding;
}
-void gtranslator_profile_set_encoding (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_encoding (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->encoding)
- g_free (profile->priv->encoding);
- profile->priv->encoding = g_strdup (data);
+ if (profile->priv->encoding)
+ g_free (profile->priv->encoding);
+ profile->priv->encoding = g_strdup (data);
}
-const gchar *gtranslator_profile_get_group_email (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_group_email (GtranslatorProfile * profile)
{
- return profile->priv->group_email;
+ return profile->priv->group_email;
}
-void gtranslator_profile_set_group_email (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_group_email (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->group_email)
- g_free (profile->priv->group_email);
- profile->priv->group_email = g_strdup (data);
+ if (profile->priv->group_email)
+ g_free (profile->priv->group_email);
+ profile->priv->group_email = g_strdup (data);
}
-const gchar *gtranslator_profile_get_plurals (GtranslatorProfile *profile)
+const gchar *
+gtranslator_profile_get_plurals (GtranslatorProfile * profile)
{
- return profile->priv->plurals;
+ return profile->priv->plurals;
}
-void gtranslator_profile_set_plurals (GtranslatorProfile *profile, const gchar *data)
+void
+gtranslator_profile_set_plurals (GtranslatorProfile * profile,
+ const gchar * data)
{
- if (profile->priv->plurals)
- g_free (profile->priv->plurals);
- profile->priv->plurals = g_strdup (data);
+ if (profile->priv->plurals)
+ g_free (profile->priv->plurals);
+ profile->priv->plurals = g_strdup (data);
}
/**
@@ -252,22 +281,29 @@ void gtranslator_profile_set_plurals (GtranslatorProfile *profile, const gchar *
* This function create a new #xmlNodePtr entry into #xmlDocPtr.
*
*/
-void gtranslator_profile_xml_new_entry (xmlDocPtr doc, GtranslatorProfile *profile)
+void
+gtranslator_profile_xml_new_entry (xmlDocPtr doc,
+ GtranslatorProfile * profile)
{
- xmlNodePtr root;
- xmlNodePtr profile_node;
-
- root = xmlDocGetRootElement (doc);
- profile_node = xmlNewChild (root, NULL, "profile", NULL);
- xmlNewTextChild (profile_node, NULL, "profile_name", profile->priv->name);
- xmlNewTextChild (profile_node, NULL, "author_name", profile->priv->author_name);
- xmlNewTextChild (profile_node, NULL, "author_email", profile->priv->author_email);
- xmlNewTextChild (profile_node, NULL, "language_name", profile->priv->language_name);
- xmlNewTextChild (profile_node, NULL, "language_code", profile->priv->language_code);
- xmlNewTextChild (profile_node, NULL, "charset", profile->priv->charset);
- xmlNewTextChild (profile_node, NULL, "encoding", profile->priv->encoding);
- xmlNewTextChild (profile_node, NULL, "group_email", profile->priv->group_email);
- xmlNewTextChild (profile_node, NULL, "plurals", profile->priv->plurals);
+ xmlNodePtr root;
+ xmlNodePtr profile_node;
+
+ root = xmlDocGetRootElement (doc);
+ profile_node = xmlNewChild (root, NULL, "profile", NULL);
+ xmlNewTextChild (profile_node, NULL, "profile_name", profile->priv->name);
+ xmlNewTextChild (profile_node, NULL, "author_name",
+ profile->priv->author_name);
+ xmlNewTextChild (profile_node, NULL, "author_email",
+ profile->priv->author_email);
+ xmlNewTextChild (profile_node, NULL, "language_name",
+ profile->priv->language_name);
+ xmlNewTextChild (profile_node, NULL, "language_code",
+ profile->priv->language_code);
+ xmlNewTextChild (profile_node, NULL, "charset", profile->priv->charset);
+ xmlNewTextChild (profile_node, NULL, "encoding", profile->priv->encoding);
+ xmlNewTextChild (profile_node, NULL, "group_email",
+ profile->priv->group_email);
+ xmlNewTextChild (profile_node, NULL, "plurals", profile->priv->plurals);
}
/**
@@ -278,8 +314,9 @@ void gtranslator_profile_xml_new_entry (xmlDocPtr doc, GtranslatorProfile *profi
* a #GtranslatorProfile object.
*
* Returns: a #GtranslatorProfile object.
- */
-GtranslatorProfile *gtranslator_profile_xml_get_entry (xmlNodePtr child)
+ */
+GtranslatorProfile *
+gtranslator_profile_xml_get_entry (xmlNodePtr child)
{
xmlNodePtr node;
GtranslatorProfile *profile;
@@ -317,8 +354,9 @@ GtranslatorProfile *gtranslator_profile_xml_get_entry (xmlNodePtr child)
* and return a #GList of #GtranslatorProfile objects.
*
* returns: a #GList
- */
-GList *gtranslator_profile_get_profiles_from_xml_file (gchar *filename)
+ */
+GList *
+gtranslator_profile_get_profiles_from_xml_file (gchar * filename)
{
GList *profiles_list = NULL;
GtranslatorProfile *profile;
@@ -336,44 +374,49 @@ GList *gtranslator_profile_get_profiles_from_xml_file (gchar *filename)
active_profile = xmlNodeGetContent (active);
child = child->next;
- while (child != NULL) {
- profile = gtranslator_profile_xml_get_entry (child);
- profiles_list = g_list_append (profiles_list, profile);
- child = child->next;
- }
-
- for (l = profiles_list; l; l = l->next) {
- GtranslatorProfile *profile;
- profile = (GtranslatorProfile *)l->data;
- if (!strcmp(gtranslator_profile_get_name (profile), active_profile))
- gtranslator_application_set_active_profile (GTR_APP, profile);
- }
-
+ while (child != NULL)
+ {
+ profile = gtranslator_profile_xml_get_entry (child);
+ profiles_list = g_list_append (profiles_list, profile);
+ child = child->next;
+ }
+
+ for (l = profiles_list; l; l = l->next)
+ {
+ GtranslatorProfile *profile;
+ profile = (GtranslatorProfile *) l->data;
+ if (!strcmp (gtranslator_profile_get_name (profile), active_profile))
+ gtranslator_application_set_active_profile (GTR_APP, profile);
+ }
+
return profiles_list;
}
gint
-gtranslator_profile_save_profiles_in_xml (gchar *filename) {
-
+gtranslator_profile_save_profiles_in_xml (gchar * filename)
+{
+
xmlNodePtr root;
xmlDocPtr doc;
GList *profiles_list, *l;
GtranslatorProfile *active_profile;
doc = gtranslator_xml_new_doc ("list_of_profiles");
-
+
profiles_list = gtranslator_application_get_profiles (GTR_APP);
active_profile = gtranslator_application_get_active_profile (GTR_APP);
root = xmlDocGetRootElement (doc);
- xmlNewChild (root, NULL, "active", gtranslator_profile_get_name (active_profile));
-
- for (l = profiles_list; l; l = l->next) {
- GtranslatorProfile *profile;
- profile = (GtranslatorProfile *)l->data;
- gtranslator_profile_xml_new_entry (doc, profile);
- }
-
+ xmlNewChild (root, NULL, "active",
+ gtranslator_profile_get_name (active_profile));
+
+ for (l = profiles_list; l; l = l->next)
+ {
+ GtranslatorProfile *profile;
+ profile = (GtranslatorProfile *) l->data;
+ gtranslator_profile_xml_new_entry (doc, profile);
+ }
+
return xmlSaveFile (filename, doc);
}
diff --git a/src/profile.h b/src/profile.h
index 0d63ddf..b95666f 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -19,8 +19,8 @@
* Authors:
* Pablo Sanxiao <psanxiao gmail com>
*/
-
- #ifndef __PROFILE_H__
+
+#ifndef __PROFILE_H__
#define __PROFILE_H__
#include <glib.h>
@@ -39,73 +39,104 @@
#define GTR_PROFILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_PROFILE, GtranslatorProfileClass))
/* Private structure type */
-typedef struct _GtranslatorProfilePrivate GtranslatorProfilePrivate;
+typedef struct _GtranslatorProfilePrivate GtranslatorProfilePrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorProfile GtranslatorProfile;
+typedef struct _GtranslatorProfile GtranslatorProfile;
struct _GtranslatorProfile
{
- GObject parent_instance;
- /*< private > */
- GtranslatorProfilePrivate *priv;
+ GObject parent_instance;
+ /*< private > */
+ GtranslatorProfilePrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorProfileClass GtranslatorProfileClass;
+typedef struct _GtranslatorProfileClass GtranslatorProfileClass;
struct _GtranslatorProfileClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_profile_get_type (void) G_GNUC_CONST;
-
-GType gtranslator_profile_register_type (GTypeModule * module);
-
-GtranslatorProfile
- *gtranslator_profile_new (void);
-
-const gchar *gtranslator_profile_get_name (GtranslatorProfile *profile);
-void gtranslator_profile_set_name (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_author_name (GtranslatorProfile *profile);
-void gtranslator_profile_set_author_name (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_author_email (GtranslatorProfile *profile);
-void gtranslator_profile_set_author_email (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_language_name (GtranslatorProfile *profile);
-void gtranslator_profile_set_language_name (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_language_code (GtranslatorProfile *profile);
-void gtranslator_profile_set_language_code (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_charset (GtranslatorProfile *profile);
-void gtranslator_profile_set_charset (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_encoding (GtranslatorProfile *profile);
-void gtranslator_profile_set_encoding (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_group_email (GtranslatorProfile *profile);
-void gtranslator_profile_set_group_email (GtranslatorProfile *profile, const gchar *data);
-
-const gchar *gtranslator_profile_get_plurals (GtranslatorProfile *profile);
-void gtranslator_profile_set_plurals (GtranslatorProfile *profile, const gchar *data);
-
-void gtranslator_profile_xml_new_entry (xmlDocPtr doc, GtranslatorProfile *profile);
-GtranslatorProfile
- *gtranslator_profile_xml_get_entry (xmlNodePtr child);
-
-GList *gtranslator_profile_get_profiles_from_xml_file (gchar *filename);
-
-gint gtranslator_profile_save_profiles_in_xml (gchar *filename);
+GType
+gtranslator_profile_get_type (void)
+ G_GNUC_CONST;
+
+ GType gtranslator_profile_register_type (GTypeModule * module);
+
+GtranslatorProfile * gtranslator_profile_new (void);
+
+ const gchar *
+ gtranslator_profile_get_name (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_name (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_author_name (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_author_name (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_author_email (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_author_email (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_language_name (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_language_name (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_language_code (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_language_code (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_charset (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_charset (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_encoding (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_encoding (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_group_email (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_group_email (GtranslatorProfile * profile,
+ const gchar * data);
+
+ const gchar *
+ gtranslator_profile_get_plurals (GtranslatorProfile * profile);
+ void
+ gtranslator_profile_set_plurals (GtranslatorProfile * profile,
+ const gchar * data);
+
+ void
+ gtranslator_profile_xml_new_entry (xmlDocPtr doc,
+ GtranslatorProfile * profile);
+GtranslatorProfile * gtranslator_profile_xml_get_entry (xmlNodePtr child);
+
+ GList *
+ gtranslator_profile_get_profiles_from_xml_file (gchar * filename);
+
+ gint
+ gtranslator_profile_save_profiles_in_xml (gchar * filename);
#endif /* __PROFILE_H__ */
diff --git a/src/statusbar.c b/src/statusbar.c
index 5f3b881..f2a18e0 100644
--- a/src/statusbar.c
+++ b/src/statusbar.c
@@ -34,91 +34,97 @@
struct _GtranslatorStatusbarPrivate
{
- GtkWidget *statusbar;
- GtkWidget *progress_bar;
-
- GtkWidget *overwrite_mode_label;
-
- /* default context data */
- guint default_context_id;
-
- /* tmp flash timeout data */
- guint flash_timeout;
- guint flash_context_id;
- guint flash_message_id;
-};
+ GtkWidget *statusbar;
+ GtkWidget *progress_bar;
-G_DEFINE_TYPE(GtranslatorStatusbar, gtranslator_statusbar, GTK_TYPE_HBOX)
+ GtkWidget *overwrite_mode_label;
-static void
-gtranslator_statusbar_finalize (GObject *object)
+ /* default context data */
+ guint default_context_id;
+
+ /* tmp flash timeout data */
+ guint flash_timeout;
+ guint flash_context_id;
+ guint flash_message_id;
+};
+
+G_DEFINE_TYPE (GtranslatorStatusbar, gtranslator_statusbar, GTK_TYPE_HBOX)
+ static void gtranslator_statusbar_finalize (GObject * object)
{
- GtranslatorStatusbar *statusbar = GTR_STATUSBAR (object);
+ GtranslatorStatusbar *statusbar = GTR_STATUSBAR (object);
- if (statusbar->priv->flash_timeout > 0)
- g_source_remove (statusbar->priv->flash_timeout);
+ if (statusbar->priv->flash_timeout > 0)
+ g_source_remove (statusbar->priv->flash_timeout);
- G_OBJECT_CLASS (gtranslator_statusbar_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_statusbar_parent_class)->finalize (object);
}
static void
-gtranslator_statusbar_class_init (GtranslatorStatusbarClass *klass)
+gtranslator_statusbar_class_init (GtranslatorStatusbarClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gtranslator_statusbar_finalize;
+ object_class->finalize = gtranslator_statusbar_finalize;
- g_type_class_add_private (object_class, sizeof (GtranslatorStatusbarPrivate));
+ g_type_class_add_private (object_class,
+ sizeof (GtranslatorStatusbarPrivate));
}
static void
-gtranslator_statusbar_init (GtranslatorStatusbar *statusbar)
+gtranslator_statusbar_init (GtranslatorStatusbar * statusbar)
{
- GtkWidget *frame;
- GtkShadowType shadow_type;
-
- statusbar->priv = GTR_STATUSBAR_GET_PRIVATE (statusbar);
-
- /*
- * Statusbar
- */
- statusbar->priv->statusbar = gtk_statusbar_new ();
- gtk_widget_show (statusbar->priv->statusbar);
- gtk_box_pack_end (GTK_BOX (statusbar), statusbar->priv->statusbar,
- TRUE, TRUE, 0);
- statusbar->priv->default_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar->priv->statusbar),
- "default-context-id");
-
- /*
- * Progress bar
- */
- statusbar->priv->progress_bar = gtk_progress_bar_new ();
- gtk_widget_show (statusbar->priv->progress_bar);
- gtk_box_pack_start (GTK_BOX (statusbar), statusbar->priv->progress_bar,
- FALSE, FALSE, 0);
-
- /*
- * Ins/Ovr stuff
- */
- gtk_widget_style_get (GTK_WIDGET (statusbar->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 ("");
- gtk_label_set_single_line_mode (GTK_LABEL (statusbar->priv->overwrite_mode_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (statusbar->priv->overwrite_mode_label), 0.0, 0.5);
- gtk_label_set_width_chars (GTK_LABEL (statusbar->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);
-
- gtk_box_pack_start (GTK_BOX (statusbar->priv->statusbar), frame,
- FALSE, FALSE, 0);
+ GtkWidget *frame;
+ GtkShadowType shadow_type;
+
+ statusbar->priv = GTR_STATUSBAR_GET_PRIVATE (statusbar);
+
+ /*
+ * Statusbar
+ */
+ statusbar->priv->statusbar = gtk_statusbar_new ();
+ gtk_widget_show (statusbar->priv->statusbar);
+ gtk_box_pack_end (GTK_BOX (statusbar), statusbar->priv->statusbar,
+ TRUE, TRUE, 0);
+ statusbar->priv->default_context_id =
+ gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar->priv->statusbar),
+ "default-context-id");
+
+ /*
+ * Progress bar
+ */
+ statusbar->priv->progress_bar = gtk_progress_bar_new ();
+ gtk_widget_show (statusbar->priv->progress_bar);
+ gtk_box_pack_start (GTK_BOX (statusbar), statusbar->priv->progress_bar,
+ FALSE, FALSE, 0);
+
+ /*
+ * Ins/Ovr stuff
+ */
+ gtk_widget_style_get (GTK_WIDGET (statusbar->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 ("");
+ gtk_label_set_single_line_mode (GTK_LABEL
+ (statusbar->priv->overwrite_mode_label),
+ TRUE);
+ gtk_misc_set_alignment (GTK_MISC (statusbar->priv->overwrite_mode_label),
+ 0.0, 0.5);
+ gtk_label_set_width_chars (GTK_LABEL
+ (statusbar->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);
+
+ gtk_box_pack_start (GTK_BOX (statusbar->priv->statusbar), frame,
+ FALSE, FALSE, 0);
}
/**
@@ -131,7 +137,7 @@ gtranslator_statusbar_init (GtranslatorStatusbar *statusbar)
GtkWidget *
gtranslator_statusbar_new (void)
{
- return GTK_WIDGET (g_object_new (GTR_TYPE_STATUSBAR, NULL));
+ return GTK_WIDGET (g_object_new (GTR_TYPE_STATUSBAR, NULL));
}
/**
@@ -142,13 +148,13 @@ gtranslator_statusbar_new (void)
* Pushes a text onto the statusbar in the default context id.
*/
void
-gtranslator_statusbar_push_default (GtranslatorStatusbar *statusbar,
- const gchar *text)
+gtranslator_statusbar_push_default (GtranslatorStatusbar * statusbar,
+ const gchar * text)
{
- g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
-
- gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->default_context_id, text);
+ g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
+
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
+ statusbar->priv->default_context_id, text);
}
/**
@@ -158,12 +164,12 @@ gtranslator_statusbar_push_default (GtranslatorStatusbar *statusbar,
* Pops the text in the statusbar of the default context id.
*/
void
-gtranslator_statusbar_pop_default (GtranslatorStatusbar *statusbar)
+gtranslator_statusbar_pop_default (GtranslatorStatusbar * statusbar)
{
- g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
-
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->default_context_id);
+ g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
+
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->statusbar),
+ statusbar->priv->default_context_id);
}
/**
@@ -177,14 +183,13 @@ gtranslator_statusbar_pop_default (GtranslatorStatusbar *statusbar)
* Returns: a message id that can be used with gtk_statusbar_remove()
*/
guint
-gtranslator_statusbar_push (GtranslatorStatusbar *statusbar,
- guint context_id,
- const gchar *text)
+gtranslator_statusbar_push (GtranslatorStatusbar * statusbar,
+ guint context_id, const gchar * text)
{
- g_return_val_if_fail (GTR_IS_STATUSBAR (statusbar), 0);
-
- return gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
- context_id, text);
+ g_return_val_if_fail (GTR_IS_STATUSBAR (statusbar), 0);
+
+ return gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
+ context_id, text);
}
/**
@@ -195,13 +200,11 @@ gtranslator_statusbar_push (GtranslatorStatusbar *statusbar,
* Removes the first message in the GtkStatusBar's stack with the given context id.
*/
void
-gtranslator_statusbar_pop (GtranslatorStatusbar *statusbar,
- guint context_id)
+gtranslator_statusbar_pop (GtranslatorStatusbar * statusbar, guint context_id)
{
- g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
-
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->statusbar),
- context_id);
+ g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
+
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->statusbar), context_id);
}
/**
@@ -215,11 +218,12 @@ gtranslator_statusbar_pop (GtranslatorStatusbar *statusbar,
* Returns: an integer id
*/
guint
-gtranslator_statusbar_get_context_id (GtranslatorStatusbar *statusbar,
- const gchar *context_description)
+gtranslator_statusbar_get_context_id (GtranslatorStatusbar * statusbar,
+ const gchar * context_description)
{
- return gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar->priv->statusbar),
- context_description);
+ return
+ gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar->priv->statusbar),
+ context_description);
}
/**
@@ -230,16 +234,19 @@ gtranslator_statusbar_get_context_id (GtranslatorStatusbar *statusbar,
* Sets the overwrite mode on the statusbar.
**/
void
-gtranslator_statusbar_set_overwrite (GtranslatorStatusbar *statusbar,
- gboolean overwrite)
+gtranslator_statusbar_set_overwrite (GtranslatorStatusbar * statusbar,
+ gboolean overwrite)
{
- g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
-
- if (overwrite)
- /* Translators: Overwrite mode */
- gtk_label_set_text(GTK_LABEL(statusbar->priv->overwrite_mode_label), _("OVR"));
- /* Translators: Insert mode */
- else gtk_label_set_text(GTK_LABEL(statusbar->priv->overwrite_mode_label), _("INS"));
+ g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
+
+ if (overwrite)
+ /* Translators: Overwrite mode */
+ gtk_label_set_text (GTK_LABEL (statusbar->priv->overwrite_mode_label),
+ _("OVR"));
+ /* Translators: Insert mode */
+ else
+ gtk_label_set_text (GTK_LABEL (statusbar->priv->overwrite_mode_label),
+ _("INS"));
}
/**
@@ -249,23 +256,23 @@ gtranslator_statusbar_set_overwrite (GtranslatorStatusbar *statusbar,
* Clears the statusbar overwrite label.
*/
void
-gtranslator_statusbar_clear_overwrite (GtranslatorStatusbar *statusbar)
+gtranslator_statusbar_clear_overwrite (GtranslatorStatusbar * statusbar)
{
- g_return_if_fail (GTR_IS_STATUSBAR (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 (statusbar->priv->overwrite_mode_label), "");
}
static gboolean
-remove_message_timeout (GtranslatorStatusbar *statusbar)
+remove_message_timeout (GtranslatorStatusbar * statusbar)
{
- gtk_statusbar_remove (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->flash_context_id,
- statusbar->priv->flash_message_id);
+ gtk_statusbar_remove (GTK_STATUSBAR (statusbar->priv->statusbar),
+ statusbar->priv->flash_context_id,
+ statusbar->priv->flash_message_id);
- /* remove the timeout */
- statusbar->priv->flash_timeout = 0;
- return FALSE;
+ /* remove the timeout */
+ statusbar->priv->flash_timeout = 0;
+ return FALSE;
}
/**
@@ -277,42 +284,43 @@ remove_message_timeout (GtranslatorStatusbar *statusbar)
* Flash a temporary message on the statusbar.
*/
void
-gtranslator_statusbar_flash_message (GtranslatorStatusbar *statusbar,
- guint context_id,
- const gchar *format, ...)
+gtranslator_statusbar_flash_message (GtranslatorStatusbar * statusbar,
+ guint context_id,
+ const gchar * format, ...)
{
- const guint32 flash_length = 3000; /* three seconds */
- va_list args;
- gchar *msg;
-
- g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
- g_return_if_fail (format != NULL);
-
- va_start (args, format);
- msg = g_strdup_vprintf (format, args);
- va_end (args);
-
- /* remove a currently ongoing flash message */
- if (statusbar->priv->flash_timeout > 0)
- {
- g_source_remove (statusbar->priv->flash_timeout);
- statusbar->priv->flash_timeout = 0;
-
- gtk_statusbar_remove (GTK_STATUSBAR (statusbar->priv->statusbar),
- statusbar->priv->flash_context_id,
- statusbar->priv->flash_message_id);
- }
-
- statusbar->priv->flash_context_id = context_id;
- statusbar->priv->flash_message_id = gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
- context_id,
- msg);
-
- statusbar->priv->flash_timeout = g_timeout_add (flash_length,
- (GtkFunction) remove_message_timeout,
- statusbar);
-
- g_free (msg);
+ const guint32 flash_length = 3000; /* three seconds */
+ va_list args;
+ gchar *msg;
+
+ g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
+ g_return_if_fail (format != NULL);
+
+ va_start (args, format);
+ msg = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ /* remove a currently ongoing flash message */
+ if (statusbar->priv->flash_timeout > 0)
+ {
+ g_source_remove (statusbar->priv->flash_timeout);
+ statusbar->priv->flash_timeout = 0;
+
+ gtk_statusbar_remove (GTK_STATUSBAR (statusbar->priv->statusbar),
+ statusbar->priv->flash_context_id,
+ statusbar->priv->flash_message_id);
+ }
+
+ statusbar->priv->flash_context_id = context_id;
+ statusbar->priv->flash_message_id =
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->statusbar),
+ context_id, msg);
+
+ statusbar->priv->flash_timeout = g_timeout_add (flash_length,
+ (GtkFunction)
+ remove_message_timeout,
+ statusbar);
+
+ g_free (msg);
}
/**
@@ -324,30 +332,31 @@ gtranslator_statusbar_flash_message (GtranslatorStatusbar *statusbar,
* Updates the state of the progress bar with the given values.
*/
void
-gtranslator_statusbar_update_progress_bar (GtranslatorStatusbar *statusbar,
+gtranslator_statusbar_update_progress_bar (GtranslatorStatusbar * statusbar,
gdouble translated_count,
gdouble messages_count)
{
- gdouble percentage;
-
- g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
-
- /*
- * Calculate the percentage.
- */
- percentage = translated_count / messages_count;
-
- /*
- * Set the progress only if the values are reasonable.
- */
- if(percentage > 0.0 || percentage < 1.0)
- {
- /*
- * Set the progressbar status.
- */
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (statusbar->priv->progress_bar),
- percentage);
- }
+ gdouble percentage;
+
+ g_return_if_fail (GTR_IS_STATUSBAR (statusbar));
+
+ /*
+ * Calculate the percentage.
+ */
+ percentage = translated_count / messages_count;
+
+ /*
+ * Set the progress only if the values are reasonable.
+ */
+ if (percentage > 0.0 || percentage < 1.0)
+ {
+ /*
+ * Set the progressbar status.
+ */
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
+ (statusbar->priv->progress_bar),
+ percentage);
+ }
}
/**
@@ -357,8 +366,8 @@ gtranslator_statusbar_update_progress_bar (GtranslatorStatusbar *statusbar,
* Clear the progress bar
*/
void
-gtranslator_statusbar_clear_progress_bar (GtranslatorStatusbar *statusbar)
+gtranslator_statusbar_clear_progress_bar (GtranslatorStatusbar * statusbar)
{
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (statusbar->priv->progress_bar),
- 0.0);
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
+ (statusbar->priv->progress_bar), 0.0);
}
diff --git a/src/statusbar.h b/src/statusbar.h
index d2e10ac..d88fcda 100644
--- a/src/statusbar.h
+++ b/src/statusbar.h
@@ -17,73 +17,77 @@
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef GTR_STATUSBAR_H
#define GTR_STATUSBAR_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
#define GTR_TYPE_STATUSBAR (gtranslator_statusbar_get_type ())
#define GTR_STATUSBAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_STATUSBAR, GtranslatorStatusbar))
#define GTR_STATUSBAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_STATUSBAR, GtranslatorStatusbarClass))
#define GTR_IS_STATUSBAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_STATUSBAR))
#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, GtranslatorStatusbarClass))
-
-typedef struct _GtranslatorStatusbar GtranslatorStatusbar;
-typedef struct _GtranslatorStatusbarPrivate GtranslatorStatusbarPrivate;
-typedef struct _GtranslatorStatusbarClass GtranslatorStatusbarClass;
+typedef struct _GtranslatorStatusbar GtranslatorStatusbar;
+typedef struct _GtranslatorStatusbarPrivate GtranslatorStatusbarPrivate;
+typedef struct _GtranslatorStatusbarClass GtranslatorStatusbarClass;
struct _GtranslatorStatusbar
{
- GtkHBox parent;
+ GtkHBox parent;
- /* <private/> */
- GtranslatorStatusbarPrivate *priv;
+ /* <private/> */
+ GtranslatorStatusbarPrivate *priv;
};
struct _GtranslatorStatusbarClass
{
- GtkHBoxClass parent_class;
+ GtkHBoxClass parent_class;
};
-GType gtranslator_statusbar_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_statusbar_get_type (void)
+ G_GNUC_CONST;
-GtkWidget *gtranslator_statusbar_new (void);
+ GtkWidget *gtranslator_statusbar_new (void);
-void gtranslator_statusbar_push_default (GtranslatorStatusbar *statusbar,
- const gchar *text);
+ void gtranslator_statusbar_push_default (GtranslatorStatusbar *
+ statusbar, const gchar * text);
-void gtranslator_statusbar_pop_default (GtranslatorStatusbar *statusbar);
+ void gtranslator_statusbar_pop_default (GtranslatorStatusbar *
+ statusbar);
-guint gtranslator_statusbar_push (GtranslatorStatusbar *statusbar,
- guint context_id,
- const gchar *text);
+ guint gtranslator_statusbar_push (GtranslatorStatusbar * statusbar,
+ guint context_id, const gchar * text);
-void gtranslator_statusbar_pop (GtranslatorStatusbar *statusbar,
- guint context_id);
-
-guint gtranslator_statusbar_get_context_id (GtranslatorStatusbar *statusbar,
- const gchar *context_description);
+ void gtranslator_statusbar_pop (GtranslatorStatusbar * statusbar,
+ guint context_id);
-void gtranslator_statusbar_set_overwrite (GtranslatorStatusbar *statusbar,
- gboolean overwrite);
+ guint gtranslator_statusbar_get_context_id (GtranslatorStatusbar *
+ statusbar,
+ const gchar *
+ context_description);
-void gtranslator_statusbar_clear_overwrite (GtranslatorStatusbar *statusbar);
+ void gtranslator_statusbar_set_overwrite (GtranslatorStatusbar *
+ statusbar, gboolean overwrite);
-void gtranslator_statusbar_flash_message (GtranslatorStatusbar *statusbar,
- guint context_id,
- const gchar *format,
- ...) G_GNUC_PRINTF(3, 4);
+ void gtranslator_statusbar_clear_overwrite (GtranslatorStatusbar *
+ statusbar);
-void gtranslator_statusbar_update_progress_bar (GtranslatorStatusbar *statusbar,
- gdouble translated_count,
- gdouble messages_count);
+ void gtranslator_statusbar_flash_message (GtranslatorStatusbar *
+ statusbar, guint context_id,
+ const gchar * format,
+ ...) G_GNUC_PRINTF (3, 4);
-void gtranslator_statusbar_clear_progress_bar (GtranslatorStatusbar *statusbar);
+ void gtranslator_statusbar_update_progress_bar (GtranslatorStatusbar *
+ statusbar,
+ gdouble translated_count,
+ gdouble messages_count);
-G_END_DECLS
+ void gtranslator_statusbar_clear_progress_bar (GtranslatorStatusbar *
+ statusbar);
+G_END_DECLS
#endif
diff --git a/src/tab.c b/src/tab.c
index 3abb2a0..32cd38a 100644
--- a/src/tab.c
+++ b/src/tab.c
@@ -60,352 +60,353 @@
#define GTR_TAB_KEY "GtranslatorTabFromDocument"
-G_DEFINE_TYPE(GtranslatorTab, gtranslator_tab, GTK_TYPE_VBOX)
-
-struct _GtranslatorTabPrivate
-{
- GtranslatorPo *po;
-
- GtkWidget *table_pane;
- GtkWidget *content_pane;
- GtkWidget *panel;
- GtkWidget *message_table;
- GtkWidget *lateral_panel; //TM, Context, etc.
-
- GtkWidget *comment_pane;
- GtkWidget *context;
- GtkWidget *translation_memory;
-
- /*Comment button*/
- GtkWidget *comment_button;
-
- /*Message area*/
- GtkWidget *message_area;
-
- /*Original text*/
- GtkWidget *msgid_hbox;
- GtkWidget *text_vbox;
- GtkWidget *text_msgid;
- GtkWidget *text_plural_scroll;
- GtkWidget *text_msgid_plural;
-
- /*Translated text*/
- GtkWidget *msgstr_label;
- GtkWidget *msgstr_hbox;
- GtkWidget *trans_notebook;
- GtkWidget *trans_msgstr[MAX_PLURALS];
-
- /*Status widgets*/
- GtkWidget *translated;
- GtkWidget *fuzzy;
- GtkWidget *untranslated;
-
- /* Autosave */
- GTimer *timer;
- gint autosave_interval;
- guint autosave_timeout;
- gint autosave : 1;
-
- /*Blocking movement*/
- gboolean blocking;
-};
-
-enum
-{
- SHOWED_MESSAGE,
- MESSAGE_CHANGED,
- MESSAGE_EDITION_FINISHED,
- LAST_SIGNAL
-};
-
-enum
+G_DEFINE_TYPE (GtranslatorTab, gtranslator_tab, GTK_TYPE_VBOX)
+ struct _GtranslatorTabPrivate
+ {
+ GtranslatorPo *po;
+
+ GtkWidget *table_pane;
+ GtkWidget *content_pane;
+ GtkWidget *panel;
+ GtkWidget *message_table;
+ GtkWidget *lateral_panel; //TM, Context, etc.
+
+ GtkWidget *comment_pane;
+ GtkWidget *context;
+ GtkWidget *translation_memory;
+
+ /*Comment button */
+ GtkWidget *comment_button;
+
+ /*Message area */
+ GtkWidget *message_area;
+
+ /*Original text */
+ GtkWidget *msgid_hbox;
+ GtkWidget *text_vbox;
+ GtkWidget *text_msgid;
+ GtkWidget *text_plural_scroll;
+ GtkWidget *text_msgid_plural;
+
+ /*Translated text */
+ GtkWidget *msgstr_label;
+ GtkWidget *msgstr_hbox;
+ GtkWidget *trans_notebook;
+ GtkWidget *trans_msgstr[MAX_PLURALS];
+
+ /*Status widgets */
+ GtkWidget *translated;
+ GtkWidget *fuzzy;
+ GtkWidget *untranslated;
+
+ /* Autosave */
+ GTimer *timer;
+ gint autosave_interval;
+ guint autosave_timeout;
+ gint autosave:1;
+
+ /*Blocking movement */
+ gboolean blocking;
+ };
+
+ enum
+ {
+ SHOWED_MESSAGE,
+ MESSAGE_CHANGED,
+ MESSAGE_EDITION_FINISHED,
+ LAST_SIGNAL
+ };
+
+ enum
+ {
+ PROP_0,
+ PROP_AUTOSAVE,
+ PROP_AUTOSAVE_INTERVAL
+ };
+
+ static guint signals[LAST_SIGNAL];
+
+ static gboolean gtranslator_tab_autosave (GtranslatorTab * tab);
+
+ static void install_autosave_timeout (GtranslatorTab * tab)
{
- PROP_0,
- PROP_AUTOSAVE,
- PROP_AUTOSAVE_INTERVAL
-};
+ gint timeout;
-static guint signals[LAST_SIGNAL];
+ g_return_if_fail (tab->priv->autosave_timeout <= 0);
+ g_return_if_fail (tab->priv->autosave);
+ g_return_if_fail (tab->priv->autosave_interval > 0);
-static gboolean gtranslator_tab_autosave (GtranslatorTab *tab);
+ /* Add a new timeout */
+ timeout = g_timeout_add (tab->priv->autosave_interval * 1000 * 60,
+ (GSourceFunc) gtranslator_tab_autosave, tab);
-static void
-install_autosave_timeout (GtranslatorTab *tab)
-{
- gint timeout;
-
- g_return_if_fail (tab->priv->autosave_timeout <= 0);
- g_return_if_fail (tab->priv->autosave);
- g_return_if_fail (tab->priv->autosave_interval > 0);
-
- /* Add a new timeout */
- timeout = g_timeout_add (tab->priv->autosave_interval * 1000 * 60,
- (GSourceFunc) gtranslator_tab_autosave,
- tab);
-
- tab->priv->autosave_timeout = timeout;
+ tab->priv->autosave_timeout = timeout;
}
static gboolean
-install_autosave_timeout_if_needed (GtranslatorTab *tab)
-{
- g_return_val_if_fail (tab->priv->autosave_timeout <= 0, FALSE);
-
- if (tab->priv->autosave)
- {
- install_autosave_timeout (tab);
-
- return TRUE;
- }
-
- return FALSE;
+install_autosave_timeout_if_needed (GtranslatorTab * tab)
+{
+ g_return_val_if_fail (tab->priv->autosave_timeout <= 0, FALSE);
+
+ if (tab->priv->autosave)
+ {
+ install_autosave_timeout (tab);
+
+ return TRUE;
+ }
+
+ return FALSE;
}
static gboolean
-gtranslator_tab_autosave (GtranslatorTab *tab)
+gtranslator_tab_autosave (GtranslatorTab * tab)
{
- GError *error = NULL;
-
- if (!gtranslator_po_get_state (tab->priv->po) == GTR_PO_STATE_MODIFIED)
- return TRUE;
-
- gtranslator_po_save_file (tab->priv->po, &error);
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- return TRUE;
+ GError *error = NULL;
+
+ if (!gtranslator_po_get_state (tab->priv->po) == GTR_PO_STATE_MODIFIED)
+ return TRUE;
+
+ gtranslator_po_save_file (tab->priv->po, &error);
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ return TRUE;
}
static void
-remove_autosave_timeout (GtranslatorTab *tab)
+remove_autosave_timeout (GtranslatorTab * tab)
{
- g_return_if_fail (tab->priv->autosave_timeout > 0);
-
- g_source_remove (tab->priv->autosave_timeout);
- tab->priv->autosave_timeout = 0;
+ g_return_if_fail (tab->priv->autosave_timeout > 0);
+
+ g_source_remove (tab->priv->autosave_timeout);
+ tab->priv->autosave_timeout = 0;
}
static void
-gtranslator_tab_showed_message (GtranslatorTab *tab,
- GtranslatorMsg *msg)
+gtranslator_tab_showed_message (GtranslatorTab * tab, GtranslatorMsg * msg)
{
- if (strcmp (gtranslator_msg_get_comment (msg), "") != 0)
- gtk_widget_show (tab->priv->comment_button);
- else gtk_widget_hide (tab->priv->comment_button);
+ if (strcmp (gtranslator_msg_get_comment (msg), "") != 0)
+ gtk_widget_show (tab->priv->comment_button);
+ else
+ gtk_widget_hide (tab->priv->comment_button);
}
static void
-gtranslator_tab_edition_finished (GtranslatorTab *tab,
- GtranslatorMsg *msg)
+gtranslator_tab_edition_finished (GtranslatorTab * tab, GtranslatorMsg * msg)
{
- GtranslatorTranslationMemory *tm;
- gchar *message_error;
- GtkWidget *message_area;
-
- tm = GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory (GTR_APP));
-
- if (gtranslator_msg_is_translated (msg) && !gtranslator_msg_is_fuzzy (msg))
- gtranslator_translation_memory_store (tm,
- gtranslator_msg_get_msgid (msg),
- gtranslator_msg_get_msgstr (msg));
-
- /*
- * Checking message
- */
- message_error = gtranslator_msg_check (msg);
-
- if (message_error != NULL)
- {
- gtranslator_tab_block_movement (tab);
-
- message_area = create_error_message_area (_("There is an error in the message:"),
- message_error);
- gtranslator_tab_set_message_area (tab, message_area);
- g_free (message_error);
- }
- else
- {
- gtranslator_tab_unblock_movement (tab);
- gtranslator_tab_set_message_area (tab, NULL);
- }
+ GtranslatorTranslationMemory *tm;
+ gchar *message_error;
+ GtkWidget *message_area;
+
+ tm =
+ GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory
+ (GTR_APP));
+
+ if (gtranslator_msg_is_translated (msg) && !gtranslator_msg_is_fuzzy (msg))
+ gtranslator_translation_memory_store (tm,
+ gtranslator_msg_get_msgid (msg),
+ gtranslator_msg_get_msgstr (msg));
+
+ /*
+ * Checking message
+ */
+ message_error = gtranslator_msg_check (msg);
+
+ if (message_error != NULL)
+ {
+ gtranslator_tab_block_movement (tab);
+
+ message_area =
+ create_error_message_area (_("There is an error in the message:"),
+ message_error);
+ gtranslator_tab_set_message_area (tab, message_area);
+ g_free (message_error);
+ }
+ else
+ {
+ gtranslator_tab_unblock_movement (tab);
+ gtranslator_tab_set_message_area (tab, NULL);
+ }
}
/*
* Write the change back to the gettext PO instance in memory and
* mark the page dirty
*/
-static void
-gtranslator_message_translation_update(GtkTextBuffer *textbuffer,
- GtranslatorTab *tab)
+static void
+gtranslator_message_translation_update (GtkTextBuffer * textbuffer,
+ GtranslatorTab * tab)
{
- GtranslatorHeader *header;
- GtkTextIter start, end;
- GtkTextBuffer *buf;
- GList *msg_aux;
- GtranslatorMsg *msg;
- const gchar *check;
- gchar *translation;
- gint i;
-
- /* Work out which message this is associated with */
-
- header = gtranslator_po_get_header (tab->priv->po);
-
- msg_aux = gtranslator_po_get_current_message(tab->priv->po);
- msg = msg_aux->data;
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tab->priv->trans_msgstr[0]));
-
- if(gtranslator_msg_is_fuzzy(msg) && gtranslator_prefs_manager_get_unmark_fuzzy_when_changed())
- gtranslator_msg_set_fuzzy(msg, FALSE);
-
- if(textbuffer == buf)
+ GtranslatorHeader *header;
+ GtkTextIter start, end;
+ GtkTextBuffer *buf;
+ GList *msg_aux;
+ GtranslatorMsg *msg;
+ const gchar *check;
+ gchar *translation;
+ gint i;
+
+ /* Work out which message this is associated with */
+
+ header = gtranslator_po_get_header (tab->priv->po);
+
+ msg_aux = gtranslator_po_get_current_message (tab->priv->po);
+ msg = msg_aux->data;
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[0]));
+
+ if (gtranslator_msg_is_fuzzy (msg)
+ && gtranslator_prefs_manager_get_unmark_fuzzy_when_changed ())
+ gtranslator_msg_set_fuzzy (msg, FALSE);
+
+ if (textbuffer == buf)
+ {
+ /* Get message as UTF-8 buffer */
+ gtk_text_buffer_get_bounds (textbuffer, &start, &end);
+ translation = gtk_text_buffer_get_text (textbuffer, &start, &end, TRUE);
+
+ /* TODO: convert to file's own encoding if not UTF-8 */
+
+ /* Write back to PO file in memory */
+ if (!(check = gtranslator_msg_get_msgid_plural (msg)))
+ {
+ gtranslator_msg_set_msgstr (msg, translation);
+ }
+ else
+ {
+ gtranslator_msg_set_msgstr_plural (msg, 0, translation);
+ //free(check);
+ }
+ g_free (translation);
+ return;
+ }
+ i = 1;
+ while (i < gtranslator_header_get_nplurals (header))
+ {
+ /* Know when to break out of the loop */
+ if (!tab->priv->trans_msgstr[i])
{
- /* Get message as UTF-8 buffer */
- gtk_text_buffer_get_bounds(textbuffer, &start, &end);
- translation = gtk_text_buffer_get_text(textbuffer, &start, &end, TRUE);
-
- /* TODO: convert to file's own encoding if not UTF-8 */
-
- /* Write back to PO file in memory */
- if(!(check = gtranslator_msg_get_msgid_plural(msg))) {
- gtranslator_msg_set_msgstr(msg, translation);
- }
- else {
- gtranslator_msg_set_msgstr_plural(msg, 0, translation);
- //free(check);
- }
- g_free(translation);
- return;
+ break;
}
- i=1;
- while(i < gtranslator_header_get_nplurals (header))
+
+ /* Have we reached the one we want yet? */
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[i]));
+ if (textbuffer != buf)
{
- /* Know when to break out of the loop */
- if(!tab->priv->trans_msgstr[i]) {
- break;
- }
-
- /* Have we reached the one we want yet? */
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tab->priv->trans_msgstr[i]));
- if(textbuffer != buf) {
- i++;
- continue;
- }
-
- /* Get message as UTF-8 buffer */
- gtk_text_buffer_get_bounds(textbuffer, &start, &end);
- translation = gtk_text_buffer_get_text(textbuffer, &start, &end, TRUE);
-
- /* TODO: convert to file's own encoding if not UTF-8 */
-
- /* Write back to PO file in memory */
- gtranslator_msg_set_msgstr_plural(msg, i, translation);
- return;
+ i++;
+ continue;
}
- /* Shouldn't get here */
- g_return_if_reached();
+ /* Get message as UTF-8 buffer */
+ gtk_text_buffer_get_bounds (textbuffer, &start, &end);
+ translation = gtk_text_buffer_get_text (textbuffer, &start, &end, TRUE);
+
+ /* TODO: convert to file's own encoding if not UTF-8 */
+
+ /* Write back to PO file in memory */
+ gtranslator_msg_set_msgstr_plural (msg, i, translation);
+ return;
+ }
+
+ /* Shouldn't get here */
+ g_return_if_reached ();
}
static GtkWidget *
-gtranslator_tab_append_msgstr_page (const gchar *tab_label,
- GtkWidget *box,
- gboolean spellcheck)
+gtranslator_tab_append_msgstr_page (const gchar * tab_label,
+ GtkWidget * box, gboolean spellcheck)
{
- GtkWidget *scroll;
- GtkWidget *label;
- GtkWidget *widget;
-
- label = gtk_label_new(tab_label);
-
- scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_show (scroll);
-
- widget = gtranslator_view_new();
- gtk_widget_show (widget);
-
- if(spellcheck && gtranslator_prefs_manager_get_spellcheck())
- gtranslator_view_enable_spellcheck(GTR_VIEW(widget),
- spellcheck);
-
- gtk_container_add (GTK_CONTAINER (scroll),
- widget);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
- GTK_SHADOW_IN);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (box), scroll, label);
-
- return widget;
+ GtkWidget *scroll;
+ GtkWidget *label;
+ GtkWidget *widget;
+
+ label = gtk_label_new (tab_label);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scroll);
+
+ widget = gtranslator_view_new ();
+ gtk_widget_show (widget);
+
+ if (spellcheck && gtranslator_prefs_manager_get_spellcheck ())
+ gtranslator_view_enable_spellcheck (GTR_VIEW (widget), spellcheck);
+
+ gtk_container_add (GTK_CONTAINER (scroll), widget);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_IN);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (box), scroll, label);
+
+ return widget;
}
static void
-gtranslator_message_plural_forms (GtranslatorTab *tab,
- GtranslatorMsg *msg)
+gtranslator_message_plural_forms (GtranslatorTab * tab, GtranslatorMsg * msg)
{
- GtranslatorHeader *header;
- GtkTextBuffer *buf;
- const gchar *msgstr_plural;
- gint i;
-
- g_return_if_fail (tab != NULL);
- g_return_if_fail (msg != NULL);
-
- header = gtranslator_po_get_header (tab->priv->po);
-
- for (i = 0; i < gtranslator_header_get_nplurals (header); i++)
+ GtranslatorHeader *header;
+ GtkTextBuffer *buf;
+ const gchar *msgstr_plural;
+ gint i;
+
+ g_return_if_fail (tab != NULL);
+ g_return_if_fail (msg != NULL);
+
+ header = gtranslator_po_get_header (tab->priv->po);
+
+ for (i = 0; i < gtranslator_header_get_nplurals (header); i++)
+ {
+ msgstr_plural = gtranslator_msg_get_msgstr_plural (msg, i);
+ if (msgstr_plural)
{
- msgstr_plural = gtranslator_msg_get_msgstr_plural (msg, i);
- if (msgstr_plural)
- {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[i]));
- gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (buf));
- gtk_text_buffer_set_text (buf, (gchar*)msgstr_plural, -1);
- gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
- }
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (tab->priv->trans_msgstr[i]));
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER
+ (buf));
+ gtk_text_buffer_set_text (buf, (gchar *) msgstr_plural, -1);
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
}
+ }
}
static GtkWidget *
gtranslator_tab_create_comment_button ()
{
- GtkWidget *button;
- GtkWidget *image;
-
- /* setup close button */
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button),
- GTK_RELIEF_NONE);
- /* don't allow focus on the close button */
- gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
-
- image = gtk_image_new_from_stock (GTK_STOCK_INDEX,
- GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
- gtk_container_add (GTK_CONTAINER (button), image);
-
- gtk_widget_set_tooltip_text (button, _("Open comment dialog"));
-
- return button;
+ GtkWidget *button;
+ GtkWidget *image;
+
+ /* setup close button */
+ button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ /* don't allow focus on the close button */
+ gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (button), image);
+
+ gtk_widget_set_tooltip_text (button, _("Open comment dialog"));
+
+ return button;
}
static void
-on_comment_button_clicked (GtkButton *button,
- gpointer useless)
+on_comment_button_clicked (GtkButton * button, gpointer useless)
{
- GtranslatorWindow *window = gtranslator_application_get_active_window (GTR_APP);
-
- gtranslator_show_comment_dialog (window);
+ GtranslatorWindow *window =
+ gtranslator_application_get_active_window (GTR_APP);
+
+ gtranslator_show_comment_dialog (window);
}
/*
@@ -417,508 +418,506 @@ on_comment_button_clicked (GtkButton *button,
*
*/
static void
-gtranslator_tab_show_message(GtranslatorTab *tab,
- GtranslatorMsg *msg)
+gtranslator_tab_show_message (GtranslatorTab * tab, GtranslatorMsg * msg)
{
- GtranslatorTabPrivate *priv = tab->priv;
- GtranslatorPo *po;
- GtkTextBuffer *buf;
- const gchar *msgid, *msgid_plural;
- const gchar *msgstr, *msgstr_plural;
-
- g_return_if_fail(GTR_IS_TAB(tab));
-
- po = priv->po;
- gtranslator_po_update_current_message(po, msg);
- msgid = gtranslator_msg_get_msgid(msg);
- if(msgid)
- {
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->text_msgid));
- gtk_source_buffer_begin_not_undoable_action(GTK_SOURCE_BUFFER(buf));
- gtk_text_buffer_set_text(buf, (gchar*)msgid, -1);
- gtk_source_buffer_end_not_undoable_action(GTK_SOURCE_BUFFER(buf));
- }
- msgid_plural = gtranslator_msg_get_msgid_plural(msg);
- if(!msgid_plural)
+ GtranslatorTabPrivate *priv = tab->priv;
+ GtranslatorPo *po;
+ GtkTextBuffer *buf;
+ const gchar *msgid, *msgid_plural;
+ const gchar *msgstr, *msgstr_plural;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ po = priv->po;
+ gtranslator_po_update_current_message (po, msg);
+ msgid = gtranslator_msg_get_msgid (msg);
+ if (msgid)
+ {
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->text_msgid));
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+ gtk_text_buffer_set_text (buf, (gchar *) msgid, -1);
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+ }
+ msgid_plural = gtranslator_msg_get_msgid_plural (msg);
+ if (!msgid_plural)
+ {
+ msgstr = gtranslator_msg_get_msgstr (msg);
+ /*
+ * Disable notebook tabs and hide widgets
+ */
+ gtk_widget_hide (priv->text_plural_scroll);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->trans_notebook), FALSE);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->trans_notebook), 0);
+ if (msgstr)
{
- msgstr = gtranslator_msg_get_msgstr(msg);
- /*
- * Disable notebook tabs and hide widgets
- */
- gtk_widget_hide (priv->text_plural_scroll);
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(priv->trans_notebook), FALSE);
- gtk_notebook_set_current_page(GTK_NOTEBOOK(priv->trans_notebook), 0);
- if(msgstr)
- {
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->trans_msgstr[0]));
- gtk_source_buffer_begin_not_undoable_action(GTK_SOURCE_BUFFER(buf));
- gtk_text_buffer_set_text(buf, (gchar*)msgstr, -1);
- gtk_source_buffer_end_not_undoable_action(GTK_SOURCE_BUFFER(buf));
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->msgstr_label),
- priv->trans_msgstr[0]);
- }
- }
- else {
- gtk_widget_show (priv->text_plural_scroll);
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK(tab->priv->trans_notebook), TRUE);
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tab->priv->text_msgid_plural));
- gtk_text_buffer_set_text(buf, (gchar*)msgid_plural, -1);
- gtranslator_message_plural_forms(tab, msg);
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[0]));
+ gtk_source_buffer_begin_not_undoable_action (GTK_SOURCE_BUFFER
+ (buf));
+ gtk_text_buffer_set_text (buf, (gchar *) msgstr, -1);
+ gtk_source_buffer_end_not_undoable_action (GTK_SOURCE_BUFFER (buf));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (priv->msgstr_label),
+ priv->trans_msgstr[0]);
}
+ }
+ else
+ {
+ gtk_widget_show (priv->text_plural_scroll);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (tab->priv->trans_notebook),
+ TRUE);
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (tab->priv->text_msgid_plural));
+ gtk_text_buffer_set_text (buf, (gchar *) msgid_plural, -1);
+ gtranslator_message_plural_forms (tab, msg);
+ }
}
static void
-emit_message_changed_signal(GtkTextBuffer *buf,
- GtranslatorTab *tab)
+emit_message_changed_signal (GtkTextBuffer * buf, GtranslatorTab * tab)
{
- GList *msg;
-
- msg = gtranslator_po_get_current_message(tab->priv->po);
-
- g_signal_emit(G_OBJECT(tab), signals[MESSAGE_CHANGED], 0, msg->data);
+ GList *msg;
+
+ msg = gtranslator_po_get_current_message (tab->priv->po);
+
+ g_signal_emit (G_OBJECT (tab), signals[MESSAGE_CHANGED], 0, msg->data);
}
static void
-update_status(GtranslatorTab *tab,
- GtranslatorMsg *msg,
- gpointer useless)
+update_status (GtranslatorTab * tab, GtranslatorMsg * msg, gpointer useless)
{
- GtranslatorMsgStatus status;
- GtranslatorPoState po_state;
- gboolean fuzzy, translated;
-
- status = gtranslator_msg_get_status (msg);
- po_state = gtranslator_po_get_state (tab->priv->po);
-
- fuzzy = gtranslator_msg_is_fuzzy (msg);
- translated = gtranslator_msg_is_translated (msg);
-
- if ((status == GTR_MSG_STATUS_FUZZY) && !fuzzy)
+ GtranslatorMsgStatus status;
+ GtranslatorPoState po_state;
+ gboolean fuzzy, translated;
+
+ status = gtranslator_msg_get_status (msg);
+ po_state = gtranslator_po_get_state (tab->priv->po);
+
+ fuzzy = gtranslator_msg_is_fuzzy (msg);
+ translated = gtranslator_msg_is_translated (msg);
+
+ if ((status == GTR_MSG_STATUS_FUZZY) && !fuzzy)
+ {
+ _gtranslator_po_increase_decrease_fuzzy (tab->priv->po, FALSE);
+ if (translated)
{
- _gtranslator_po_increase_decrease_fuzzy(tab->priv->po, FALSE);
- if (translated)
- {
- status = GTR_MSG_STATUS_TRANSLATED;
- _gtranslator_po_increase_decrease_translated(tab->priv->po, TRUE);
- }
- else {
- status = GTR_MSG_STATUS_UNTRANSLATED;
- }
+ status = GTR_MSG_STATUS_TRANSLATED;
+ _gtranslator_po_increase_decrease_translated (tab->priv->po, TRUE);
}
- else if ((status == GTR_MSG_STATUS_TRANSLATED) && !translated)
+ else
{
- status = GTR_MSG_STATUS_UNTRANSLATED;
- _gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
+ status = GTR_MSG_STATUS_UNTRANSLATED;
}
- else if ((status == GTR_MSG_STATUS_TRANSLATED) && fuzzy)
+ }
+ else if ((status == GTR_MSG_STATUS_TRANSLATED) && !translated)
+ {
+ status = GTR_MSG_STATUS_UNTRANSLATED;
+ _gtranslator_po_increase_decrease_translated (tab->priv->po, FALSE);
+ }
+ else if ((status == GTR_MSG_STATUS_TRANSLATED) && fuzzy)
+ {
+ status = GTR_MSG_STATUS_FUZZY;
+ _gtranslator_po_increase_decrease_translated (tab->priv->po, FALSE);
+ _gtranslator_po_increase_decrease_fuzzy (tab->priv->po, TRUE);
+ }
+ else if ((status == GTR_MSG_STATUS_UNTRANSLATED) && translated)
+ {
+ if (fuzzy)
{
- status = GTR_MSG_STATUS_FUZZY;
- _gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
- _gtranslator_po_increase_decrease_fuzzy(tab->priv->po, TRUE);
+ status = GTR_MSG_STATUS_FUZZY;
+ _gtranslator_po_increase_decrease_fuzzy (tab->priv->po, TRUE);
}
- else if ((status == GTR_MSG_STATUS_UNTRANSLATED) && translated)
+ else
{
- if (fuzzy)
- {
- status = GTR_MSG_STATUS_FUZZY;
- _gtranslator_po_increase_decrease_fuzzy(tab->priv->po, TRUE);
- }
- else {
- status = GTR_MSG_STATUS_TRANSLATED;
- _gtranslator_po_increase_decrease_translated(tab->priv->po, TRUE);
- }
+ status = GTR_MSG_STATUS_TRANSLATED;
+ _gtranslator_po_increase_decrease_translated (tab->priv->po, TRUE);
}
+ }
+
+ gtranslator_msg_set_status (msg, status);
- gtranslator_msg_set_status (msg, status);
-
- /* We need to update the tab state too if is neccessary*/
- if (po_state != GTR_PO_STATE_MODIFIED)
- gtranslator_po_set_state(tab->priv->po, GTR_PO_STATE_MODIFIED);
+ /* We need to update the tab state too if is neccessary */
+ if (po_state != GTR_PO_STATE_MODIFIED)
+ gtranslator_po_set_state (tab->priv->po, GTR_PO_STATE_MODIFIED);
}
static void
-comment_pane_position_changed (GObject *tab_gobject,
- GParamSpec *arg1,
- GtranslatorTab *tab)
+comment_pane_position_changed (GObject * tab_gobject,
+ GParamSpec * arg1, GtranslatorTab * tab)
{
- gtranslator_prefs_manager_set_comment_pane_pos(gtk_paned_get_position(GTK_PANED(tab_gobject)));
+ gtranslator_prefs_manager_set_comment_pane_pos (gtk_paned_get_position
+ (GTK_PANED (tab_gobject)));
}
static void
-content_pane_position_changed (GObject *tab_gobject,
- GParamSpec *arg1,
- GtranslatorTab *tab)
+content_pane_position_changed (GObject * tab_gobject,
+ GParamSpec * arg1, GtranslatorTab * tab)
{
- gtranslator_prefs_manager_set_content_pane_pos(gtk_paned_get_position(GTK_PANED(tab_gobject)));
+ gtranslator_prefs_manager_set_content_pane_pos (gtk_paned_get_position
+ (GTK_PANED (tab_gobject)));
}
static void
-gtranslator_tab_add_msgstr_tabs (GtranslatorTab *tab)
+gtranslator_tab_add_msgstr_tabs (GtranslatorTab * tab)
{
- GtranslatorHeader *header;
- GtranslatorTabPrivate *priv = tab->priv;
- gchar *label;
- GtkTextBuffer *buf;
- gint i = 0;
-
- /*
- * We get the header of the po file
- */
- header = gtranslator_po_get_header (tab->priv->po);
-
- do{
- label = g_strdup_printf (_("Plural %d"), i+1);
- priv->trans_msgstr[i] = gtranslator_tab_append_msgstr_page (label,
- priv->trans_notebook,
- TRUE);
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[i]));
- g_signal_connect (buf, "end-user-action",
- G_CALLBACK (gtranslator_message_translation_update),
- tab);
-
- g_signal_connect_after (buf, "end_user_action",
- G_CALLBACK (emit_message_changed_signal),
- tab);
- i++;
- g_free (label);
- }while (i < gtranslator_header_get_nplurals (header));
+ GtranslatorHeader *header;
+ GtranslatorTabPrivate *priv = tab->priv;
+ gchar *label;
+ GtkTextBuffer *buf;
+ gint i = 0;
+
+ /*
+ * We get the header of the po file
+ */
+ header = gtranslator_po_get_header (tab->priv->po);
+
+ do
+ {
+ label = g_strdup_printf (_("Plural %d"), i + 1);
+ priv->trans_msgstr[i] = gtranslator_tab_append_msgstr_page (label,
+ priv->
+ trans_notebook,
+ TRUE);
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->trans_msgstr[i]));
+ g_signal_connect (buf, "end-user-action",
+ G_CALLBACK (gtranslator_message_translation_update),
+ tab);
+
+ g_signal_connect_after (buf, "end_user_action",
+ G_CALLBACK (emit_message_changed_signal), tab);
+ i++;
+ g_free (label);
+ }
+ while (i < gtranslator_header_get_nplurals (header));
}
static void
-gtranslator_tab_draw (GtranslatorTab *tab)
+gtranslator_tab_draw (GtranslatorTab * tab)
{
- gint current_page_num;
- GtkWidget *image;
- GtkWidget *vertical_box;
- GtkWidget *label_widget;
- GtkWidget *msgid_label;
- GtkWidget *current_page;
- GtkWidget *notebook, *tm_layout, *tm, *comments_label, *tm_label, *scroll;
- GtkWidget *hbox;
- GtkWidget *label;
- GtranslatorTabPrivate *priv = tab->priv;
-
- /*
- * Panel
- */
- priv->panel = gtk_notebook_new ();
- gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->panel),
- GTK_POS_BOTTOM);
- gtk_widget_show (priv->panel);
-
- /*
- * Message table
- */
- priv->message_table = gtranslator_message_table_new(GTK_WIDGET(tab));
- gtk_widget_show (priv->message_table);
-
- label_widget = gtk_label_new (_("Message Table"));
-
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->panel),
- priv->message_table,
- label_widget);
-
- gtk_notebook_set_show_tabs(GTK_NOTEBOOK (priv->panel),
- FALSE);
-
- /*
- * Comment pane
- */
- priv->comment_pane = gtk_hpaned_new();
- gtk_paned_set_position(GTK_PANED(priv->comment_pane), gtranslator_prefs_manager_get_comment_pane_pos());
- g_signal_connect (priv->comment_pane,
- "notify::position",
- G_CALLBACK (comment_pane_position_changed),
- tab);
- gtk_widget_show (priv->comment_pane);
-
- /*
- * Lateral panel
- */
- tab->priv->lateral_panel = gtk_notebook_new ();
- gtk_widget_show (tab->priv->lateral_panel);
-
- gtk_paned_pack2(GTK_PANED(priv->comment_pane), tab->priv->lateral_panel,
- TRUE, TRUE);
-
- /*
- * Context
- */
- priv->context = gtranslator_context_panel_new (GTK_WIDGET (tab));
- gtk_widget_show (priv->context);
- gtranslator_tab_add_widget_to_lateral_panel (tab, priv->context,
- _("Context"));
-
- /*
- * TM
- */
- priv->translation_memory = gtranslator_translation_memory_ui_new (GTK_WIDGET (tab));
- gtk_widget_show (priv->translation_memory);
- gtranslator_tab_add_widget_to_lateral_panel (tab, priv->translation_memory,
- _("Translation Memory"));
-
- /*
- * Content pane; this is where the message table and message area go
- */
- priv->content_pane = gtk_vpaned_new();
- gtk_paned_set_position(GTK_PANED(priv->content_pane),
- gtranslator_prefs_manager_get_content_pane_pos());
- g_signal_connect (priv->content_pane,
- "notify::position",
- G_CALLBACK (content_pane_position_changed),
- tab);
- gtk_widget_show (priv->content_pane);
-
- /*
- * Pack the comments pane and the main content
- */
- vertical_box=gtk_vbox_new(FALSE, 0);
- gtk_paned_pack1(GTK_PANED(priv->content_pane), GTK_WIDGET(priv->panel), TRUE, FALSE);
- gtk_paned_pack2(GTK_PANED(priv->content_pane), priv->comment_pane, FALSE, TRUE);
- gtk_widget_show (vertical_box);
-
- /*
- * Orignal text widgets
- */
- priv->msgid_hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (priv->msgid_hbox);
-
- msgid_label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (msgid_label),
- _("<b>Original Text:</b>"));
- gtk_misc_set_padding (GTK_MISC (msgid_label), 0, 5);
- gtk_widget_show (msgid_label);
-
- gtk_box_pack_start(GTK_BOX(priv->msgid_hbox), msgid_label, FALSE, FALSE, 0);
-
- priv->text_vbox = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (priv->text_vbox);
-
- /* Singular */
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (scroll);
-
- priv->text_msgid = gtranslator_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->text_msgid), FALSE);
- gtk_widget_show (priv->text_msgid);
-
- gtk_container_add (GTK_CONTAINER (scroll),
- priv->text_msgid);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
- GTK_SHADOW_IN);
-
- gtk_box_pack_start (GTK_BOX (priv->text_vbox), scroll, TRUE, TRUE, 0);
-
- /* Plural */
- priv->text_plural_scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (priv->text_plural_scroll);
-
- priv->text_msgid_plural = gtranslator_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->text_msgid_plural),
- FALSE);
- gtk_widget_show (priv->text_msgid_plural);
-
- gtk_container_add (GTK_CONTAINER (priv->text_plural_scroll),
- priv->text_msgid_plural);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->text_plural_scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->text_plural_scroll),
- GTK_SHADOW_IN);
-
- gtk_box_pack_start (GTK_BOX (priv->text_vbox), priv->text_plural_scroll,
- TRUE, TRUE, 0);
-
- gtk_box_pack_start (GTK_BOX (vertical_box), priv->msgid_hbox, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vertical_box), priv->text_vbox, TRUE, TRUE, 0);
-
-
- /*
- * Translation widgets
- */
- priv->msgstr_hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (priv->msgstr_hbox);
-
- priv->msgstr_label = gtk_label_new (NULL);
- gtk_label_set_markup_with_mnemonic (GTK_LABEL (priv->msgstr_label),
- _("<b>Translate_d Text:</b>"));
- gtk_misc_set_padding (GTK_MISC (priv->msgstr_label), 0, 5);
- gtk_misc_set_alignment (GTK_MISC (priv->msgstr_label), 0, 0.5);
- gtk_widget_show (priv->msgstr_label);
-
- gtk_box_pack_start(GTK_BOX(priv->msgstr_hbox), priv->msgstr_label, TRUE, TRUE, 0);
-
- priv->comment_button = gtranslator_tab_create_comment_button ();
- gtk_box_pack_start (GTK_BOX (priv->msgstr_hbox), priv->comment_button,
- FALSE, FALSE, 0);
- g_signal_connect (priv->comment_button, "clicked",
- G_CALLBACK (on_comment_button_clicked), NULL);
-
- priv->trans_notebook = gtk_notebook_new();
- gtk_notebook_set_show_border(GTK_NOTEBOOK(priv->trans_notebook), FALSE);
- gtk_widget_show (priv->trans_notebook);
-
- gtk_box_pack_start(GTK_BOX(vertical_box), priv->msgstr_hbox, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vertical_box), priv->trans_notebook, TRUE, TRUE, 0);
-
- gtk_paned_pack1(GTK_PANED(priv->comment_pane), vertical_box, FALSE, FALSE);
-
- gtk_box_pack_start(GTK_BOX(tab), priv->content_pane, TRUE, TRUE, 0);
+ gint current_page_num;
+ GtkWidget *image;
+ GtkWidget *vertical_box;
+ GtkWidget *label_widget;
+ GtkWidget *msgid_label;
+ GtkWidget *current_page;
+ GtkWidget *notebook, *tm_layout, *tm, *comments_label, *tm_label, *scroll;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtranslatorTabPrivate *priv = tab->priv;
+
+ /*
+ * Panel
+ */
+ priv->panel = gtk_notebook_new ();
+ gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->panel), GTK_POS_BOTTOM);
+ gtk_widget_show (priv->panel);
+
+ /*
+ * Message table
+ */
+ priv->message_table = gtranslator_message_table_new (GTK_WIDGET (tab));
+ gtk_widget_show (priv->message_table);
+
+ label_widget = gtk_label_new (_("Message Table"));
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (priv->panel),
+ priv->message_table, label_widget);
+
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->panel), FALSE);
+
+ /*
+ * Comment pane
+ */
+ priv->comment_pane = gtk_hpaned_new ();
+ gtk_paned_set_position (GTK_PANED (priv->comment_pane),
+ gtranslator_prefs_manager_get_comment_pane_pos ());
+ g_signal_connect (priv->comment_pane, "notify::position",
+ G_CALLBACK (comment_pane_position_changed), tab);
+ gtk_widget_show (priv->comment_pane);
+
+ /*
+ * Lateral panel
+ */
+ tab->priv->lateral_panel = gtk_notebook_new ();
+ gtk_widget_show (tab->priv->lateral_panel);
+
+ gtk_paned_pack2 (GTK_PANED (priv->comment_pane), tab->priv->lateral_panel,
+ TRUE, TRUE);
+
+ /*
+ * Context
+ */
+ priv->context = gtranslator_context_panel_new (GTK_WIDGET (tab));
+ gtk_widget_show (priv->context);
+ gtranslator_tab_add_widget_to_lateral_panel (tab, priv->context,
+ _("Context"));
+
+ /*
+ * TM
+ */
+ priv->translation_memory =
+ gtranslator_translation_memory_ui_new (GTK_WIDGET (tab));
+ gtk_widget_show (priv->translation_memory);
+ gtranslator_tab_add_widget_to_lateral_panel (tab, priv->translation_memory,
+ _("Translation Memory"));
+
+ /*
+ * Content pane; this is where the message table and message area go
+ */
+ priv->content_pane = gtk_vpaned_new ();
+ gtk_paned_set_position (GTK_PANED (priv->content_pane),
+ gtranslator_prefs_manager_get_content_pane_pos ());
+ g_signal_connect (priv->content_pane,
+ "notify::position",
+ G_CALLBACK (content_pane_position_changed), tab);
+ gtk_widget_show (priv->content_pane);
+
+ /*
+ * Pack the comments pane and the main content
+ */
+ vertical_box = gtk_vbox_new (FALSE, 0);
+ gtk_paned_pack1 (GTK_PANED (priv->content_pane), GTK_WIDGET (priv->panel),
+ TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (priv->content_pane), priv->comment_pane, FALSE,
+ TRUE);
+ gtk_widget_show (vertical_box);
+
+ /*
+ * Orignal text widgets
+ */
+ priv->msgid_hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (priv->msgid_hbox);
+
+ msgid_label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (msgid_label), _("<b>Original Text:</b>"));
+ gtk_misc_set_padding (GTK_MISC (msgid_label), 0, 5);
+ gtk_widget_show (msgid_label);
+
+ gtk_box_pack_start (GTK_BOX (priv->msgid_hbox), msgid_label, FALSE, FALSE,
+ 0);
+
+ priv->text_vbox = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (priv->text_vbox);
+
+ /* Singular */
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scroll);
+
+ priv->text_msgid = gtranslator_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->text_msgid), FALSE);
+ gtk_widget_show (priv->text_msgid);
+
+ gtk_container_add (GTK_CONTAINER (scroll), priv->text_msgid);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_IN);
+
+ gtk_box_pack_start (GTK_BOX (priv->text_vbox), scroll, TRUE, TRUE, 0);
+
+ /* Plural */
+ priv->text_plural_scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (priv->text_plural_scroll);
+
+ priv->text_msgid_plural = gtranslator_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->text_msgid_plural), FALSE);
+ gtk_widget_show (priv->text_msgid_plural);
+
+ gtk_container_add (GTK_CONTAINER (priv->text_plural_scroll),
+ priv->text_msgid_plural);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
+ (priv->text_plural_scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
+ (priv->text_plural_scroll),
+ GTK_SHADOW_IN);
+
+ gtk_box_pack_start (GTK_BOX (priv->text_vbox), priv->text_plural_scroll,
+ TRUE, TRUE, 0);
+
+ gtk_box_pack_start (GTK_BOX (vertical_box), priv->msgid_hbox, FALSE, FALSE,
+ 0);
+ gtk_box_pack_start (GTK_BOX (vertical_box), priv->text_vbox, TRUE, TRUE, 0);
+
+
+ /*
+ * Translation widgets
+ */
+ priv->msgstr_hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (priv->msgstr_hbox);
+
+ priv->msgstr_label = gtk_label_new (NULL);
+ gtk_label_set_markup_with_mnemonic (GTK_LABEL (priv->msgstr_label),
+ _("<b>Translate_d Text:</b>"));
+ gtk_misc_set_padding (GTK_MISC (priv->msgstr_label), 0, 5);
+ gtk_misc_set_alignment (GTK_MISC (priv->msgstr_label), 0, 0.5);
+ gtk_widget_show (priv->msgstr_label);
+
+ gtk_box_pack_start (GTK_BOX (priv->msgstr_hbox), priv->msgstr_label, TRUE,
+ TRUE, 0);
+
+ priv->comment_button = gtranslator_tab_create_comment_button ();
+ gtk_box_pack_start (GTK_BOX (priv->msgstr_hbox), priv->comment_button,
+ FALSE, FALSE, 0);
+ g_signal_connect (priv->comment_button, "clicked",
+ G_CALLBACK (on_comment_button_clicked), NULL);
+
+ priv->trans_notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->trans_notebook), FALSE);
+ gtk_widget_show (priv->trans_notebook);
+
+ gtk_box_pack_start (GTK_BOX (vertical_box), priv->msgstr_hbox, FALSE, FALSE,
+ 0);
+ gtk_box_pack_start (GTK_BOX (vertical_box), priv->trans_notebook, TRUE,
+ TRUE, 0);
+
+ gtk_paned_pack1 (GTK_PANED (priv->comment_pane), vertical_box, FALSE,
+ FALSE);
+
+ gtk_box_pack_start (GTK_BOX (tab), priv->content_pane, TRUE, TRUE, 0);
}
static void
-gtranslator_tab_init (GtranslatorTab *tab)
+gtranslator_tab_init (GtranslatorTab * tab)
{
- tab->priv = GTR_TAB_GET_PRIVATE (tab);
-
- g_signal_connect(tab, "message-changed",
- G_CALLBACK(update_status), NULL);
-
- gtranslator_tab_draw(tab);
-
- /* Manage auto save data */
- tab->priv->autosave = gtranslator_prefs_manager_get_autosave ();
- tab->priv->autosave = (tab->priv->autosave != FALSE);
-
- tab->priv->autosave_interval = gtranslator_prefs_manager_get_autosave_interval ();
- if (tab->priv->autosave_interval <= 0)
- tab->priv->autosave_interval = 1;
+ tab->priv = GTR_TAB_GET_PRIVATE (tab);
+
+ g_signal_connect (tab, "message-changed", G_CALLBACK (update_status), NULL);
+
+ gtranslator_tab_draw (tab);
+
+ /* Manage auto save data */
+ tab->priv->autosave = gtranslator_prefs_manager_get_autosave ();
+ tab->priv->autosave = (tab->priv->autosave != FALSE);
+
+ tab->priv->autosave_interval =
+ gtranslator_prefs_manager_get_autosave_interval ();
+ if (tab->priv->autosave_interval <= 0)
+ tab->priv->autosave_interval = 1;
}
static void
-gtranslator_tab_finalize (GObject *object)
+gtranslator_tab_finalize (GObject * object)
{
- GtranslatorTab *tab = GTR_TAB (object);
-
- if (tab->priv->po)
- g_object_unref (tab->priv->po);
-
- if (tab->priv->timer != NULL)
- g_timer_destroy (tab->priv->timer);
-
- if (tab->priv->autosave_timeout > 0)
- remove_autosave_timeout (tab);
-
- G_OBJECT_CLASS (gtranslator_tab_parent_class)->finalize (object);
+ GtranslatorTab *tab = GTR_TAB (object);
+
+ if (tab->priv->po)
+ g_object_unref (tab->priv->po);
+
+ if (tab->priv->timer != NULL)
+ g_timer_destroy (tab->priv->timer);
+
+ if (tab->priv->autosave_timeout > 0)
+ remove_autosave_timeout (tab);
+
+ G_OBJECT_CLASS (gtranslator_tab_parent_class)->finalize (object);
}
static void
-gtranslator_tab_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gtranslator_tab_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GtranslatorTab *tab = GTR_TAB (object);
-
- switch (prop_id)
- {
- case PROP_AUTOSAVE:
- g_value_set_boolean (value,
- gtranslator_tab_get_autosave_enabled (tab));
- break;
- case PROP_AUTOSAVE_INTERVAL:
- g_value_set_int (value,
- gtranslator_tab_get_autosave_interval (tab));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GtranslatorTab *tab = GTR_TAB (object);
+
+ switch (prop_id)
+ {
+ case PROP_AUTOSAVE:
+ g_value_set_boolean (value, gtranslator_tab_get_autosave_enabled (tab));
+ break;
+ case PROP_AUTOSAVE_INTERVAL:
+ g_value_set_int (value, gtranslator_tab_get_autosave_interval (tab));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gtranslator_tab_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gtranslator_tab_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GtranslatorTab *tab = GTR_TAB (object);
-
- switch (prop_id)
- {
- case PROP_AUTOSAVE:
- gtranslator_tab_set_autosave_enabled (tab,
- g_value_get_boolean (value));
- break;
- case PROP_AUTOSAVE_INTERVAL:
- gtranslator_tab_set_autosave_interval (tab,
- g_value_get_int (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GtranslatorTab *tab = GTR_TAB (object);
+
+ switch (prop_id)
+ {
+ case PROP_AUTOSAVE:
+ gtranslator_tab_set_autosave_enabled (tab, g_value_get_boolean (value));
+ break;
+ case PROP_AUTOSAVE_INTERVAL:
+ gtranslator_tab_set_autosave_interval (tab, g_value_get_int (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gtranslator_tab_class_init (GtranslatorTabClass *klass)
+gtranslator_tab_class_init (GtranslatorTabClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GtranslatorTabPrivate));
-
- object_class->finalize = gtranslator_tab_finalize;
- object_class->set_property = gtranslator_tab_set_property;
- object_class->get_property = gtranslator_tab_get_property;
- klass->showed_message = gtranslator_tab_showed_message;
- klass->message_edition_finished = gtranslator_tab_edition_finished;
-
- /* Signals */
- signals[SHOWED_MESSAGE] =
- g_signal_new("showed-message",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorTabClass, showed_message),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- signals[MESSAGE_CHANGED] =
- g_signal_new("message-changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorTabClass, message_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- signals[MESSAGE_EDITION_FINISHED] =
- g_signal_new("message-edition-finished",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtranslatorTabClass, message_edition_finished),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- /* Properties */
- g_object_class_install_property (object_class,
- PROP_AUTOSAVE,
- g_param_spec_boolean ("autosave",
- "Autosave",
- "Autosave feature",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_AUTOSAVE_INTERVAL,
- g_param_spec_int ("autosave-interval",
- "AutosaveInterval",
- "Time between two autosaves",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorTabPrivate));
+
+ object_class->finalize = gtranslator_tab_finalize;
+ object_class->set_property = gtranslator_tab_set_property;
+ object_class->get_property = gtranslator_tab_get_property;
+ klass->showed_message = gtranslator_tab_showed_message;
+ klass->message_edition_finished = gtranslator_tab_edition_finished;
+
+ /* Signals */
+ signals[SHOWED_MESSAGE] =
+ g_signal_new ("showed-message",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtranslatorTabClass, showed_message),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ signals[MESSAGE_CHANGED] =
+ g_signal_new ("message-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtranslatorTabClass, message_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ signals[MESSAGE_EDITION_FINISHED] =
+ g_signal_new ("message-edition-finished",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtranslatorTabClass,
+ message_edition_finished), NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+
+ /* Properties */
+ g_object_class_install_property (object_class,
+ PROP_AUTOSAVE,
+ g_param_spec_boolean ("autosave",
+ "Autosave",
+ "Autosave feature",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ PROP_AUTOSAVE_INTERVAL,
+ g_param_spec_int ("autosave-interval",
+ "AutosaveInterval",
+ "Time between two autosaves",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
/***************************** Public funcs ***********************************/
@@ -932,28 +931,30 @@ gtranslator_tab_class_init (GtranslatorTabClass *klass)
* Return value: a new #GtranslatorTab object
**/
GtranslatorTab *
-gtranslator_tab_new (GtranslatorPo *po)
+gtranslator_tab_new (GtranslatorPo * po)
{
- GtranslatorTab *tab;
-
- g_return_val_if_fail(po != NULL, NULL);
-
- tab = g_object_new (GTR_TYPE_TAB, NULL);
-
- tab->priv->po = po;
- g_object_set_data (G_OBJECT (po), GTR_TAB_KEY, tab);
- install_autosave_timeout_if_needed (tab);
-
- /*
- * Now we have to initialize the number of msgstr tabs
- */
- gtranslator_tab_add_msgstr_tabs (tab);
-
- gtranslator_message_table_populate(GTR_MESSAGE_TABLE(tab->priv->message_table),
- gtranslator_po_get_messages(tab->priv->po));
-
- gtk_widget_show (GTK_WIDGET(tab));
- return tab;
+ GtranslatorTab *tab;
+
+ g_return_val_if_fail (po != NULL, NULL);
+
+ tab = g_object_new (GTR_TYPE_TAB, NULL);
+
+ tab->priv->po = po;
+ g_object_set_data (G_OBJECT (po), GTR_TAB_KEY, tab);
+ install_autosave_timeout_if_needed (tab);
+
+ /*
+ * Now we have to initialize the number of msgstr tabs
+ */
+ gtranslator_tab_add_msgstr_tabs (tab);
+
+ gtranslator_message_table_populate (GTR_MESSAGE_TABLE
+ (tab->priv->message_table),
+ gtranslator_po_get_messages (tab->priv->
+ po));
+
+ gtk_widget_show (GTK_WIDGET (tab));
+ return tab;
}
/**
@@ -963,9 +964,9 @@ gtranslator_tab_new (GtranslatorPo *po)
* Return value: the #GtranslatorPo stored in the #GtranslatorTab
**/
GtranslatorPo *
-gtranslator_tab_get_po(GtranslatorTab *tab)
+gtranslator_tab_get_po (GtranslatorTab * tab)
{
- return tab->priv->po;
+ return tab->priv->po;
}
/**
@@ -975,11 +976,11 @@ gtranslator_tab_get_po(GtranslatorTab *tab)
* Return value: the horizontal notebook of the #GtranslationTab
**/
GtkWidget *
-gtranslator_tab_get_panel(GtranslatorTab *tab)
+gtranslator_tab_get_panel (GtranslatorTab * tab)
{
- g_return_val_if_fail(tab != NULL, NULL);
-
- return tab->priv->panel;
+ g_return_val_if_fail (tab != NULL, NULL);
+
+ return tab->priv->panel;
}
/**
@@ -989,9 +990,10 @@ gtranslator_tab_get_panel(GtranslatorTab *tab)
* Return value: the number of the active translation notebook.
**/
gint
-gtranslator_tab_get_active_trans_tab(GtranslatorTab *tab)
+gtranslator_tab_get_active_trans_tab (GtranslatorTab * tab)
{
- return gtk_notebook_get_current_page(GTK_NOTEBOOK(tab->priv->trans_notebook));
+ return
+ gtk_notebook_get_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook));
}
/**
@@ -1001,9 +1003,9 @@ gtranslator_tab_get_active_trans_tab(GtranslatorTab *tab)
* Return value: the #GtranslaorContextPanel
*/
GtranslatorContextPanel *
-gtranslator_tab_get_context_panel(GtranslatorTab *tab)
+gtranslator_tab_get_context_panel (GtranslatorTab * tab)
{
- return GTR_CONTEXT_PANEL(tab->priv->context);
+ return GTR_CONTEXT_PANEL (tab->priv->context);
}
/**
@@ -1013,11 +1015,11 @@ gtranslator_tab_get_context_panel(GtranslatorTab *tab)
* Returns: the #GtranslatorTranslationMemoryUi panel.
*/
GtkWidget *
-gtranslator_tab_get_translation_memory_ui (GtranslatorTab *tab)
+gtranslator_tab_get_translation_memory_ui (GtranslatorTab * tab)
{
- g_return_val_if_fail (GTR_IS_TAB (tab), NULL);
-
- return tab->priv->translation_memory;
+ g_return_val_if_fail (GTR_IS_TAB (tab), NULL);
+
+ return tab->priv->translation_memory;
}
/**
@@ -1027,12 +1029,13 @@ gtranslator_tab_get_translation_memory_ui (GtranslatorTab *tab)
* Return value: the active page of the translation notebook.
**/
GtranslatorView *
-gtranslator_tab_get_active_view(GtranslatorTab *tab)
+gtranslator_tab_get_active_view (GtranslatorTab * tab)
{
- gint num;
-
- num = gtk_notebook_get_current_page(GTK_NOTEBOOK(tab->priv->trans_notebook));
- return GTR_VIEW(tab->priv->trans_msgstr[num]);
+ gint num;
+
+ num =
+ gtk_notebook_get_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook));
+ return GTR_VIEW (tab->priv->trans_msgstr[num]);
}
/**
@@ -1046,33 +1049,33 @@ gtranslator_tab_get_active_view(GtranslatorTab *tab)
* Return value: a newly allocated list of #GtranslationTab objects
*/
GList *
-gtranslator_tab_get_all_views(GtranslatorTab *tab,
- gboolean original,
- gboolean translated)
+gtranslator_tab_get_all_views (GtranslatorTab * tab,
+ gboolean original, gboolean translated)
{
- GList *ret = NULL;
- gint i = 0;
-
- g_return_val_if_fail(GTR_IS_TAB(tab), NULL);
-
- if(original)
- {
- ret = g_list_append(ret, tab->priv->text_msgid);
- ret = g_list_append(ret, tab->priv->text_msgid_plural);
- }
-
- if(translated)
+ GList *ret = NULL;
+ gint i = 0;
+
+ g_return_val_if_fail (GTR_IS_TAB (tab), NULL);
+
+ if (original)
+ {
+ ret = g_list_append (ret, tab->priv->text_msgid);
+ ret = g_list_append (ret, tab->priv->text_msgid_plural);
+ }
+
+ if (translated)
+ {
+ while (i < MAX_PLURALS)
{
- while(i < MAX_PLURALS)
- {
- if(tab->priv->trans_msgstr[i])
- ret = g_list_append(ret, tab->priv->trans_msgstr[i]);
- else break;
- i++;
- }
+ if (tab->priv->trans_msgstr[i])
+ ret = g_list_append (ret, tab->priv->trans_msgstr[i]);
+ else
+ break;
+ i++;
}
-
- return ret;
+ }
+
+ return ret;
}
/**
@@ -1082,25 +1085,25 @@ gtranslator_tab_get_all_views(GtranslatorTab *tab,
* Return value: a new allocated string with the name of the @tab.
*/
gchar *
-gtranslator_tab_get_name (GtranslatorTab *tab)
+gtranslator_tab_get_name (GtranslatorTab * tab)
{
- GtranslatorHeader *header;
- GtranslatorPoState state;
- const gchar *str;
- gchar *tab_name;
+ GtranslatorHeader *header;
+ GtranslatorPoState state;
+ const gchar *str;
+ gchar *tab_name;
- header = gtranslator_po_get_header (tab->priv->po);
- state = gtranslator_po_get_state (tab->priv->po);
+ header = gtranslator_po_get_header (tab->priv->po);
+ state = gtranslator_po_get_state (tab->priv->po);
- str = gtranslator_header_get_prj_id_version (header);
+ str = gtranslator_header_get_prj_id_version (header);
- if (state == GTR_PO_STATE_MODIFIED)
- {
- tab_name = g_strdup_printf ("*%s", str);
- return tab_name;
- }
-
- return g_strdup (str);
+ if (state == GTR_PO_STATE_MODIFIED)
+ {
+ tab_name = g_strdup_printf ("*%s", str);
+ return tab_name;
+ }
+
+ return g_strdup (str);
}
/**
@@ -1112,88 +1115,94 @@ gtranslator_tab_get_name (GtranslatorTab *tab)
* Jumps to the specific @to_go pointer message and show the message
* in the #GtranslatorView.
**/
-void
-gtranslator_tab_message_go_to (GtranslatorTab *tab,
+void
+gtranslator_tab_message_go_to (GtranslatorTab * tab,
GList * to_go,
- gboolean searching,
- GtranslatorTabMove move)
+ gboolean searching, GtranslatorTabMove move)
{
- GtranslatorPo *po;
- GList *current_msg;
- static gboolean first_msg = TRUE;
-
- g_return_if_fail (tab != NULL);
- g_return_if_fail (to_go != NULL);
- g_return_if_fail (GTR_IS_MSG (to_go->data));
-
- po = tab->priv->po;
-
- current_msg = gtranslator_po_get_current_message (po);
-
- /*
- * Emitting message-edition-finished signal
- */
- if (!searching && !first_msg)
- g_signal_emit (G_OBJECT (tab), signals[MESSAGE_EDITION_FINISHED],
- 0, GTR_MSG (current_msg->data));
-
- if (!tab->priv->blocking || first_msg)
+ GtranslatorPo *po;
+ GList *current_msg;
+ static gboolean first_msg = TRUE;
+
+ g_return_if_fail (tab != NULL);
+ g_return_if_fail (to_go != NULL);
+ g_return_if_fail (GTR_IS_MSG (to_go->data));
+
+ po = tab->priv->po;
+
+ current_msg = gtranslator_po_get_current_message (po);
+
+ /*
+ * Emitting message-edition-finished signal
+ */
+ if (!searching && !first_msg)
+ g_signal_emit (G_OBJECT (tab), signals[MESSAGE_EDITION_FINISHED],
+ 0, GTR_MSG (current_msg->data));
+
+ if (!tab->priv->blocking || first_msg)
+ {
+ gboolean plurals;
+ gint current_page, n_pages;
+ /*
+ * If the current message is plural and we press next/prev
+ * we have to change to the next/prev plural tab in case is not
+ * the last
+ * To implement that:
+ * if the tabs are showed then we check if we want prev or
+ * next and then if we need to change the tab we change it
+ * in other case we show the message
+ *
+ * I don't like too much this implementation so if anybody can
+ * rewrite this is a better way would be great.
+ */
+ plurals =
+ gtk_notebook_get_show_tabs (GTK_NOTEBOOK (tab->priv->trans_notebook));
+ current_page =
+ gtk_notebook_get_current_page (GTK_NOTEBOOK
+ (tab->priv->trans_notebook));
+ n_pages =
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (tab->priv->trans_notebook));
+ if ((plurals == TRUE) && (move != GTR_TAB_MOVE_NONE))
{
- gboolean plurals;
- gint current_page, n_pages;
- /*
- * If the current message is plural and we press next/prev
- * we have to change to the next/prev plural tab in case is not
- * the last
- * To implement that:
- * if the tabs are showed then we check if we want prev or
- * next and then if we need to change the tab we change it
- * in other case we show the message
- *
- * I don't like too much this implementation so if anybody can
- * rewrite this is a better way would be great.
- */
- plurals = gtk_notebook_get_show_tabs (GTK_NOTEBOOK (tab->priv->trans_notebook));
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook));
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (tab->priv->trans_notebook));
- if ((plurals == TRUE) && (move != GTR_TAB_MOVE_NONE))
- {
- if ((n_pages - 1) == current_page && move == GTR_TAB_MOVE_NEXT)
- {
- gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
- 0);
- gtranslator_tab_show_message (tab, to_go->data);
- }
- else if (current_page == 0 && move == GTR_TAB_MOVE_PREV)
- {
- gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
- n_pages - 1);
- gtranslator_tab_show_message (tab, to_go->data);
- }
- else
- {
- if (move == GTR_TAB_MOVE_NEXT)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
- current_page + 1);
- else
- gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->trans_notebook),
- current_page - 1);
- return;
- }
- }
- else
- gtranslator_tab_show_message (tab, to_go->data);
- first_msg = FALSE;
+ if ((n_pages - 1) == current_page && move == GTR_TAB_MOVE_NEXT)
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (tab->priv->trans_notebook), 0);
+ gtranslator_tab_show_message (tab, to_go->data);
+ }
+ else if (current_page == 0 && move == GTR_TAB_MOVE_PREV)
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (tab->priv->trans_notebook),
+ n_pages - 1);
+ gtranslator_tab_show_message (tab, to_go->data);
+ }
+ else
+ {
+ if (move == GTR_TAB_MOVE_NEXT)
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (tab->priv->trans_notebook),
+ current_page + 1);
+ else
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (tab->priv->trans_notebook),
+ current_page - 1);
+ return;
+ }
}
- else
- return;
-
- /*
- * Emitting showed-message signal
- */
- if (!searching)
- g_signal_emit (G_OBJECT (tab), signals[SHOWED_MESSAGE], 0,
- GTR_MSG (to_go->data));
+ else
+ gtranslator_tab_show_message (tab, to_go->data);
+ first_msg = FALSE;
+ }
+ else
+ return;
+
+ /*
+ * Emitting showed-message signal
+ */
+ if (!searching)
+ g_signal_emit (G_OBJECT (tab), signals[SHOWED_MESSAGE], 0,
+ GTR_MSG (to_go->data));
}
/**
@@ -1205,9 +1214,9 @@ gtranslator_tab_message_go_to (GtranslatorTab *tab,
* Returns: TRUE if the #GtranslatorPo of the @tab is already saved
*/
gboolean
-_gtranslator_tab_can_close (GtranslatorTab *tab)
+_gtranslator_tab_can_close (GtranslatorTab * tab)
{
- return gtranslator_po_get_state (tab->priv->po) == GTR_PO_STATE_SAVED;
+ return gtranslator_po_get_state (tab->priv->po) == GTR_PO_STATE_SAVED;
}
/**
@@ -1219,15 +1228,15 @@ _gtranslator_tab_can_close (GtranslatorTab *tab)
* Returns: the #GtranslatorTab for a specific #GtranslatorPo
*/
GtranslatorTab *
-gtranslator_tab_get_from_document (GtranslatorPo *po)
+gtranslator_tab_get_from_document (GtranslatorPo * po)
{
- gpointer res;
-
- g_return_val_if_fail (GTR_IS_PO (po), NULL);
-
- res = g_object_get_data (G_OBJECT (po), GTR_TAB_KEY);
-
- return (res != NULL) ? GTR_TAB (res) : NULL;
+ gpointer res;
+
+ g_return_val_if_fail (GTR_IS_PO (po), NULL);
+
+ res = g_object_get_data (G_OBJECT (po), GTR_TAB_KEY);
+
+ return (res != NULL) ? GTR_TAB (res) : NULL;
}
/**
@@ -1239,11 +1248,11 @@ gtranslator_tab_get_from_document (GtranslatorPo *po)
* Return value: TRUE if the autosave is enabled, else FALSE
**/
gboolean
-gtranslator_tab_get_autosave_enabled (GtranslatorTab *tab)
+gtranslator_tab_get_autosave_enabled (GtranslatorTab * tab)
{
- g_return_val_if_fail (GTR_IS_TAB (tab), FALSE);
+ g_return_val_if_fail (GTR_IS_TAB (tab), FALSE);
- return tab->priv->autosave;
+ return tab->priv->autosave;
}
/**
@@ -1255,32 +1264,30 @@ gtranslator_tab_get_autosave_enabled (GtranslatorTab *tab)
* autosave timeout if the document is new or is read-only
**/
void
-gtranslator_tab_set_autosave_enabled (GtranslatorTab *tab,
- gboolean enable)
+gtranslator_tab_set_autosave_enabled (GtranslatorTab * tab, gboolean enable)
{
- g_return_if_fail (GTR_IS_TAB (tab));
+ g_return_if_fail (GTR_IS_TAB (tab));
- if (tab->priv->autosave == enable)
- return;
+ if (tab->priv->autosave == enable)
+ return;
- tab->priv->autosave = enable;
+ tab->priv->autosave = enable;
- if (enable &&
- (tab->priv->autosave_timeout <= 0))
- {
- install_autosave_timeout (tab);
-
- return;
- }
-
- if (!enable && (tab->priv->autosave_timeout > 0))
- {
- remove_autosave_timeout (tab);
-
- return;
- }
-
- g_return_if_fail (!enable && (tab->priv->autosave_timeout <= 0));
+ if (enable && (tab->priv->autosave_timeout <= 0))
+ {
+ install_autosave_timeout (tab);
+
+ return;
+ }
+
+ if (!enable && (tab->priv->autosave_timeout > 0))
+ {
+ remove_autosave_timeout (tab);
+
+ return;
+ }
+
+ g_return_if_fail (!enable && (tab->priv->autosave_timeout <= 0));
}
/**
@@ -1291,12 +1298,12 @@ gtranslator_tab_set_autosave_enabled (GtranslatorTab *tab,
*
* Return value: the value of the autosave
**/
-gint
-gtranslator_tab_get_autosave_interval (GtranslatorTab *tab)
+gint
+gtranslator_tab_get_autosave_interval (GtranslatorTab * tab)
{
- g_return_val_if_fail (GTR_IS_TAB (tab), 0);
+ g_return_val_if_fail (GTR_IS_TAB (tab), 0);
- return tab->priv->autosave_interval;
+ return tab->priv->autosave_interval;
}
/**
@@ -1309,27 +1316,26 @@ gtranslator_tab_get_autosave_interval (GtranslatorTab *tab)
* interval timeout and adds a new one with the autosave passed as
* argument.
**/
-void
-gtranslator_tab_set_autosave_interval (GtranslatorTab *tab,
- gint interval)
+void
+gtranslator_tab_set_autosave_interval (GtranslatorTab * tab, gint interval)
{
- g_return_if_fail (GTR_IS_TAB (tab));
- g_return_if_fail (interval > 0);
+ g_return_if_fail (GTR_IS_TAB (tab));
+ g_return_if_fail (interval > 0);
- if (tab->priv->autosave_interval == interval)
- return;
+ if (tab->priv->autosave_interval == interval)
+ return;
- tab->priv->autosave_interval = interval;
-
- if (!tab->priv->autosave)
- return;
+ tab->priv->autosave_interval = interval;
- if (tab->priv->autosave_timeout > 0)
- {
- remove_autosave_timeout (tab);
+ if (!tab->priv->autosave)
+ return;
- install_autosave_timeout (tab);
- }
+ if (tab->priv->autosave_timeout > 0)
+ {
+ remove_autosave_timeout (tab);
+
+ install_autosave_timeout (tab);
+ }
}
/**
@@ -1341,19 +1347,19 @@ gtranslator_tab_set_autosave_interval (GtranslatorTab *tab,
* Adds a new widget to the laberal panel notebook.
*/
void
-gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab *tab,
- GtkWidget *widget,
- const gchar *tab_name)
+gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab * tab,
+ GtkWidget * widget,
+ const gchar * tab_name)
{
- GtkWidget *label;
-
- g_return_if_fail (GTR_IS_TAB (tab));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- label = gtk_label_new (tab_name);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
- widget, label);
+ GtkWidget *label;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ label = gtk_label_new (tab_name);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
+ widget, label);
}
/**
@@ -1364,19 +1370,18 @@ gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab *tab,
* Removes the @widget from the lateral panel notebook of @tab.
*/
void
-gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab *tab,
- GtkWidget *widget)
+gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab * tab,
+ GtkWidget * widget)
{
- gint page;
-
- g_return_if_fail (GTR_IS_TAB (tab));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
- widget);
-
- gtk_notebook_remove_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
- page);
+ gint page;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
+ widget);
+
+ gtk_notebook_remove_page (GTK_NOTEBOOK (tab->priv->lateral_panel), page);
}
/**
@@ -1387,15 +1392,15 @@ gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab *tab,
* Shows the notebook page of the @widget.
*/
void
-gtranslator_tab_show_lateral_panel_widget (GtranslatorTab *tab,
- GtkWidget *widget)
+gtranslator_tab_show_lateral_panel_widget (GtranslatorTab * tab,
+ GtkWidget * widget)
{
- gint page;
-
- page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
- widget);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
- page);
+ gint page;
+
+ page = gtk_notebook_page_num (GTK_NOTEBOOK (tab->priv->lateral_panel),
+ widget);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (tab->priv->lateral_panel),
+ page);
}
/**
@@ -1405,23 +1410,26 @@ gtranslator_tab_show_lateral_panel_widget (GtranslatorTab *tab,
* Clears all text from msgstr text views.
*/
void
-gtranslator_tab_clear_msgstr_views (GtranslatorTab *tab)
+gtranslator_tab_clear_msgstr_views (GtranslatorTab * tab)
{
- gint i = 0;
- GtranslatorHeader *header;
- GtkTextBuffer *buf;
-
- g_return_if_fail (GTR_IS_TAB (tab));
-
- header = gtranslator_po_get_header (tab->priv->po);
-
- do {
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[i]));
- gtk_text_buffer_begin_user_action (buf);
- gtk_text_buffer_set_text (buf, "", -1);
- gtk_text_buffer_end_user_action (buf);
- i++;
- }while (i < gtranslator_header_get_nplurals (header));
+ gint i = 0;
+ GtranslatorHeader *header;
+ GtkTextBuffer *buf;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ header = gtranslator_po_get_header (tab->priv->po);
+
+ do
+ {
+ buf =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[i]));
+ gtk_text_buffer_begin_user_action (buf);
+ gtk_text_buffer_set_text (buf, "", -1);
+ gtk_text_buffer_end_user_action (buf);
+ i++;
+ }
+ while (i < gtranslator_header_get_nplurals (header));
}
/**
@@ -1431,25 +1439,27 @@ gtranslator_tab_clear_msgstr_views (GtranslatorTab *tab)
* Copies the text from the original text box to the translation text box.
*/
void
-gtranslator_tab_copy_to_translation (GtranslatorTab *tab)
+gtranslator_tab_copy_to_translation (GtranslatorTab * tab)
{
- GtkTextBuffer *msgstr, *msgid;
- gint page_index;
- const gchar *text;
- GtkTextIter start, end;
-
- g_return_if_fail (GTR_IS_TAB (tab));
-
- page_index = gtranslator_tab_get_active_trans_tab (tab);
-
- msgstr = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->trans_msgstr[page_index]));
- msgid = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->text_msgid));
-
- gtk_text_buffer_begin_user_action (msgstr);
- gtk_text_buffer_get_bounds (msgid, &start, &end);
- text = gtk_text_buffer_get_text (msgid, &start, &end, FALSE);
- gtk_text_buffer_set_text (msgstr, text, -1);
- gtk_text_buffer_end_user_action (msgstr);
+ GtkTextBuffer *msgstr, *msgid;
+ gint page_index;
+ const gchar *text;
+ GtkTextIter start, end;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ page_index = gtranslator_tab_get_active_trans_tab (tab);
+
+ msgstr =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW
+ (tab->priv->trans_msgstr[page_index]));
+ msgid = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tab->priv->text_msgid));
+
+ gtk_text_buffer_begin_user_action (msgstr);
+ gtk_text_buffer_get_bounds (msgid, &start, &end);
+ text = gtk_text_buffer_get_text (msgid, &start, &end, FALSE);
+ gtk_text_buffer_set_text (msgstr, text, -1);
+ gtk_text_buffer_end_user_action (msgstr);
}
/**
@@ -1459,11 +1469,11 @@ gtranslator_tab_copy_to_translation (GtranslatorTab *tab)
* Blocks the movement to the next/prev message.
*/
void
-gtranslator_tab_block_movement (GtranslatorTab *tab)
+gtranslator_tab_block_movement (GtranslatorTab * tab)
{
- g_return_if_fail (GTR_IS_TAB (tab));
-
- tab->priv->blocking = TRUE;
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ tab->priv->blocking = TRUE;
}
/**
@@ -1473,11 +1483,11 @@ gtranslator_tab_block_movement (GtranslatorTab *tab)
* Unblocks the movement to the next/prev message.
*/
void
-gtranslator_tab_unblock_movement (GtranslatorTab *tab)
+gtranslator_tab_unblock_movement (GtranslatorTab * tab)
{
- g_return_if_fail (GTR_IS_TAB (tab));
-
- tab->priv->blocking = FALSE;
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ tab->priv->blocking = FALSE;
}
/**
@@ -1487,16 +1497,16 @@ gtranslator_tab_unblock_movement (GtranslatorTab *tab)
* Moves to the next message or plural tab in case the message has plurals.
*/
void
-gtranslator_tab_go_to_next (GtranslatorTab *tab)
+gtranslator_tab_go_to_next (GtranslatorTab * tab)
{
- GtranslatorPo *po;
-
- po = gtranslator_tab_get_po (tab);
-
- gtranslator_tab_message_go_to (tab,
- g_list_next (gtranslator_po_get_current_message (po)),
- FALSE,
- GTR_TAB_MOVE_NEXT);
+ GtranslatorPo *po;
+
+ po = gtranslator_tab_get_po (tab);
+
+ gtranslator_tab_message_go_to (tab,
+ g_list_next
+ (gtranslator_po_get_current_message (po)),
+ FALSE, GTR_TAB_MOVE_NEXT);
}
/**
@@ -1506,16 +1516,16 @@ gtranslator_tab_go_to_next (GtranslatorTab *tab)
* Moves to the previous message or plural tab in case the message has plurals.
*/
void
-gtranslator_tab_go_to_prev (GtranslatorTab *tab)
+gtranslator_tab_go_to_prev (GtranslatorTab * tab)
{
- GtranslatorPo *po;
-
- po = gtranslator_tab_get_po (tab);
-
- gtranslator_tab_message_go_to (tab,
- g_list_previous (gtranslator_po_get_current_message (po)),
- FALSE,
- GTR_TAB_MOVE_PREV);
+ GtranslatorPo *po;
+
+ po = gtranslator_tab_get_po (tab);
+
+ gtranslator_tab_message_go_to (tab,
+ g_list_previous
+ (gtranslator_po_get_current_message (po)),
+ FALSE, GTR_TAB_MOVE_PREV);
}
/**
@@ -1525,16 +1535,16 @@ gtranslator_tab_go_to_prev (GtranslatorTab *tab)
* Jumps to the first message.
*/
void
-gtranslator_tab_go_to_first (GtranslatorTab *tab)
+gtranslator_tab_go_to_first (GtranslatorTab * tab)
{
- GtranslatorPo *po;
-
- po = gtranslator_tab_get_po (tab);
-
- gtranslator_tab_message_go_to (tab,
- g_list_first (gtranslator_po_get_current_message (po)),
- FALSE,
- GTR_TAB_MOVE_NONE);
+ GtranslatorPo *po;
+
+ po = gtranslator_tab_get_po (tab);
+
+ gtranslator_tab_message_go_to (tab,
+ g_list_first
+ (gtranslator_po_get_current_message (po)),
+ FALSE, GTR_TAB_MOVE_NONE);
}
/**
@@ -1544,16 +1554,16 @@ gtranslator_tab_go_to_first (GtranslatorTab *tab)
* Jumps to the last message.
*/
void
-gtranslator_tab_go_to_last (GtranslatorTab *tab)
+gtranslator_tab_go_to_last (GtranslatorTab * tab)
{
- GtranslatorPo *po;
-
- po = gtranslator_tab_get_po (tab);
-
- gtranslator_tab_message_go_to (tab,
- g_list_last (gtranslator_po_get_current_message (po)),
- FALSE,
- GTR_TAB_MOVE_NONE);
+ GtranslatorPo *po;
+
+ po = gtranslator_tab_get_po (tab);
+
+ gtranslator_tab_message_go_to (tab,
+ g_list_last
+ (gtranslator_po_get_current_message (po)),
+ FALSE, GTR_TAB_MOVE_NONE);
}
/**
@@ -1565,22 +1575,21 @@ gtranslator_tab_go_to_last (GtranslatorTab *tab)
* Returns: TRUE if there is a next fuzzy message.
*/
gboolean
-gtranslator_tab_go_to_next_fuzzy (GtranslatorTab *tab)
+gtranslator_tab_go_to_next_fuzzy (GtranslatorTab * tab)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_next_fuzzy (po);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- return TRUE;
- }
-
- return FALSE;
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_next_fuzzy (po);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -1592,22 +1601,21 @@ gtranslator_tab_go_to_next_fuzzy (GtranslatorTab *tab)
* Returns: TRUE if there is a prev fuzzy message.
*/
gboolean
-gtranslator_tab_go_to_prev_fuzzy (GtranslatorTab *tab)
+gtranslator_tab_go_to_prev_fuzzy (GtranslatorTab * tab)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_prev_fuzzy (po);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- return TRUE;
- }
-
- return FALSE;
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_prev_fuzzy (po);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -1619,22 +1627,21 @@ gtranslator_tab_go_to_prev_fuzzy (GtranslatorTab *tab)
* Returns: TRUE if there is a next untranslated message.
*/
gboolean
-gtranslator_tab_go_to_next_untrans (GtranslatorTab *tab)
+gtranslator_tab_go_to_next_untrans (GtranslatorTab * tab)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_next_untrans (po);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- return TRUE;
- }
-
- return FALSE;
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_next_untrans (po);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -1646,22 +1653,21 @@ gtranslator_tab_go_to_next_untrans (GtranslatorTab *tab)
* Returns: TRUE if there is a prev untranslated message.
*/
gboolean
-gtranslator_tab_go_to_prev_untrans (GtranslatorTab *tab)
+gtranslator_tab_go_to_prev_untrans (GtranslatorTab * tab)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_prev_untrans (po);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- return TRUE;
- }
-
- return FALSE;
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_prev_untrans (po);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -1673,22 +1679,21 @@ gtranslator_tab_go_to_prev_untrans (GtranslatorTab *tab)
* Returns: TRUE if there is a next fuzzy or untranslated message.
*/
gboolean
-gtranslator_tab_go_to_next_fuzzy_or_untrans (GtranslatorTab *tab)
+gtranslator_tab_go_to_next_fuzzy_or_untrans (GtranslatorTab * tab)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_next_fuzzy_or_untrans (po);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- return TRUE;
- }
-
- return FALSE;
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_next_fuzzy_or_untrans (po);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -1700,22 +1705,21 @@ gtranslator_tab_go_to_next_fuzzy_or_untrans (GtranslatorTab *tab)
* Returns: TRUE if there is a prev fuzzy or untranslated message.
*/
gboolean
-gtranslator_tab_go_to_prev_fuzzy_or_untrans (GtranslatorTab *tab)
+gtranslator_tab_go_to_prev_fuzzy_or_untrans (GtranslatorTab * tab)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_prev_fuzzy_or_untrans (po);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- return TRUE;
- }
-
- return FALSE;
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_prev_fuzzy_or_untrans (po);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
@@ -1727,20 +1731,18 @@ gtranslator_tab_go_to_prev_fuzzy_or_untrans (GtranslatorTab *tab)
* exists it does not jump.
*/
void
-gtranslator_tab_go_to_number (GtranslatorTab *tab,
- gint number)
+gtranslator_tab_go_to_number (GtranslatorTab * tab, gint number)
{
- GtranslatorPo *po;
- GList *msg;
-
- po = gtranslator_tab_get_po (tab);
-
- msg = gtranslator_po_get_msg_from_number (po, number);
- if(msg != NULL)
- {
- gtranslator_tab_message_go_to (tab, msg, FALSE,
- GTR_TAB_MOVE_NONE);
- }
+ GtranslatorPo *po;
+ GList *msg;
+
+ po = gtranslator_tab_get_po (tab);
+
+ msg = gtranslator_po_get_msg_from_number (po, number);
+ if (msg != NULL)
+ {
+ gtranslator_tab_message_go_to (tab, msg, FALSE, GTR_TAB_MOVE_NONE);
+ }
}
/**
@@ -1751,28 +1753,25 @@ gtranslator_tab_go_to_number (GtranslatorTab *tab,
* Sets the @message_area to be shown in the @tab.
*/
void
-gtranslator_tab_set_message_area (GtranslatorTab *tab,
- GtkWidget *message_area)
+gtranslator_tab_set_message_area (GtranslatorTab * tab,
+ GtkWidget * message_area)
{
- g_return_if_fail (GTR_IS_TAB (tab));
-
- if (tab->priv->message_area == message_area)
- return;
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ if (tab->priv->message_area == message_area)
+ return;
- if (tab->priv->message_area != NULL)
- gtk_widget_destroy (tab->priv->message_area);
+ if (tab->priv->message_area != NULL)
+ gtk_widget_destroy (tab->priv->message_area);
- tab->priv->message_area = message_area;
+ tab->priv->message_area = message_area;
- if (message_area == NULL)
- return;
+ if (message_area == NULL)
+ return;
- gtk_box_pack_start (GTK_BOX (tab),
- tab->priv->message_area,
- FALSE,
- FALSE,
- 0);
+ gtk_box_pack_start (GTK_BOX (tab),
+ tab->priv->message_area, FALSE, FALSE, 0);
- g_object_add_weak_pointer (G_OBJECT (tab->priv->message_area),
- (gpointer *)&tab->priv->message_area);
+ g_object_add_weak_pointer (G_OBJECT (tab->priv->message_area),
+ (gpointer *) & tab->priv->message_area);
}
diff --git a/src/tab.h b/src/tab.h
index d6f9798..feeb5c0 100644
--- a/src/tab.h
+++ b/src/tab.h
@@ -33,7 +33,6 @@
#include "view.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -43,135 +42,139 @@ G_BEGIN_DECLS
#define GTR_IS_TAB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_TAB))
#define GTR_IS_TAB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_TAB))
#define GTR_TAB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_TAB, GtranslatorTabClass))
-
/* Private structure type */
-typedef struct _GtranslatorTabPrivate GtranslatorTabPrivate;
+typedef struct _GtranslatorTabPrivate GtranslatorTabPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorTab GtranslatorTab;
+typedef struct _GtranslatorTab GtranslatorTab;
struct _GtranslatorTab
{
- GtkVBox parent_instance;
-
- /*< private > */
- GtranslatorTabPrivate *priv;
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorTabPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorTabClass GtranslatorTabClass;
+typedef struct _GtranslatorTabClass GtranslatorTabClass;
struct _GtranslatorTabClass
{
- GtkVBoxClass parent_class;
-
- void (* showed_message) (GtranslatorTab *tab,
- GtranslatorMsg *msg);
- void (* message_changed) (GtranslatorTab *tab,
- GtranslatorMsg *msg);
- void (* message_edition_finished) (GtranslatorTab *tab,
- GtranslatorMsg *msg);
+ GtkVBoxClass parent_class;
+
+ void (*showed_message) (GtranslatorTab * tab, GtranslatorMsg * msg);
+ void (*message_changed) (GtranslatorTab * tab, GtranslatorMsg * msg);
+ void (*message_edition_finished) (GtranslatorTab * tab,
+ GtranslatorMsg * msg);
};
typedef enum
{
- GTR_TAB_MOVE_NONE,
- GTR_TAB_MOVE_NEXT,
- GTR_TAB_MOVE_PREV
-}GtranslatorTabMove;
+ GTR_TAB_MOVE_NONE,
+ GTR_TAB_MOVE_NEXT,
+ GTR_TAB_MOVE_PREV
+} GtranslatorTabMove;
/*
* Public methods
*/
-GType gtranslator_tab_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_tab_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_tab_register_type (GTypeModule * module);
+ GType gtranslator_tab_register_type (GTypeModule * module);
-GtranslatorTab *gtranslator_tab_new (GtranslatorPo *po);
+ GtranslatorTab *gtranslator_tab_new (GtranslatorPo * po);
-GtranslatorPo *gtranslator_tab_get_po (GtranslatorTab *tab);
+ GtranslatorPo *gtranslator_tab_get_po (GtranslatorTab * tab);
-GtkWidget *gtranslator_tab_get_panel (GtranslatorTab *tab);
+ GtkWidget *gtranslator_tab_get_panel (GtranslatorTab * tab);
-gint gtranslator_tab_get_active_trans_tab(GtranslatorTab *tab);
+ gint gtranslator_tab_get_active_trans_tab (GtranslatorTab * tab);
-GtranslatorContextPanel *gtranslator_tab_get_context_panel (GtranslatorTab *tab);
+ GtranslatorContextPanel
+ *gtranslator_tab_get_context_panel (GtranslatorTab * tab);
-GtkWidget *gtranslator_tab_get_translation_memory_ui (GtranslatorTab *tab);
+ GtkWidget *gtranslator_tab_get_translation_memory_ui (GtranslatorTab *
+ tab);
-GtranslatorView *gtranslator_tab_get_active_view (GtranslatorTab *tab);
+ GtranslatorView *gtranslator_tab_get_active_view (GtranslatorTab * tab);
-GList *gtranslator_tab_get_all_views (GtranslatorTab *tab,
- gboolean original,
- gboolean translated);
+ GList *gtranslator_tab_get_all_views (GtranslatorTab * tab,
+ gboolean original,
+ gboolean translated);
-gchar *gtranslator_tab_get_name (GtranslatorTab *tab);
+ gchar *gtranslator_tab_get_name (GtranslatorTab * tab);
-void gtranslator_tab_message_go_to (GtranslatorTab *tab,
- GList * to_go,
- gboolean searching,
- GtranslatorTabMove move);
-
-GtranslatorTab *gtranslator_tab_get_from_document (GtranslatorPo *po);
+ void gtranslator_tab_message_go_to (GtranslatorTab * tab,
+ GList * to_go,
+ gboolean searching,
+ GtranslatorTabMove move);
-gboolean gtranslator_tab_get_autosave_enabled (GtranslatorTab *tab);
+ GtranslatorTab *gtranslator_tab_get_from_document (GtranslatorPo * po);
-void gtranslator_tab_set_autosave_enabled (GtranslatorTab *tab,
- gboolean enable);
+ gboolean gtranslator_tab_get_autosave_enabled (GtranslatorTab * tab);
-gint gtranslator_tab_get_autosave_interval (GtranslatorTab *tab);
+ void gtranslator_tab_set_autosave_enabled (GtranslatorTab * tab,
+ gboolean enable);
-void gtranslator_tab_set_autosave_interval (GtranslatorTab *tab,
- gint interval);
+ gint gtranslator_tab_get_autosave_interval (GtranslatorTab * tab);
-void gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab *tab,
- GtkWidget *widget,
- const gchar *tab_name);
+ void gtranslator_tab_set_autosave_interval (GtranslatorTab * tab,
+ gint interval);
-void gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab *tab,
- GtkWidget *widget);
+ void gtranslator_tab_add_widget_to_lateral_panel (GtranslatorTab * tab,
+ GtkWidget * widget,
+ const gchar *
+ tab_name);
-void gtranslator_tab_show_lateral_panel_widget (GtranslatorTab *tab,
- GtkWidget *widget);
+ void gtranslator_tab_remove_widget_from_lateral_panel (GtranslatorTab *
+ tab,
+ GtkWidget *
+ widget);
-void gtranslator_tab_clear_msgstr_views (GtranslatorTab *tab);
+ void gtranslator_tab_show_lateral_panel_widget (GtranslatorTab * tab,
+ GtkWidget * widget);
-void gtranslator_tab_block_movement (GtranslatorTab *tab);
+ void gtranslator_tab_clear_msgstr_views (GtranslatorTab * tab);
-void gtranslator_tab_unblock_movement (GtranslatorTab *tab);
+ void gtranslator_tab_block_movement (GtranslatorTab * tab);
-void gtranslator_tab_go_to_next (GtranslatorTab *tab);
+ void gtranslator_tab_unblock_movement (GtranslatorTab * tab);
-void gtranslator_tab_go_to_prev (GtranslatorTab *tab);
+ void gtranslator_tab_go_to_next (GtranslatorTab * tab);
-void gtranslator_tab_go_to_first (GtranslatorTab *tab);
+ void gtranslator_tab_go_to_prev (GtranslatorTab * tab);
-void gtranslator_tab_go_to_last (GtranslatorTab *tab);
+ void gtranslator_tab_go_to_first (GtranslatorTab * tab);
-gboolean gtranslator_tab_go_to_next_fuzzy (GtranslatorTab *tab);
+ void gtranslator_tab_go_to_last (GtranslatorTab * tab);
-gboolean gtranslator_tab_go_to_prev_fuzzy (GtranslatorTab *tab);
+ gboolean gtranslator_tab_go_to_next_fuzzy (GtranslatorTab * tab);
-gboolean gtranslator_tab_go_to_next_untrans (GtranslatorTab *tab);
+ gboolean gtranslator_tab_go_to_prev_fuzzy (GtranslatorTab * tab);
-gboolean gtranslator_tab_go_to_prev_untrans (GtranslatorTab *tab);
+ gboolean gtranslator_tab_go_to_next_untrans (GtranslatorTab * tab);
-gboolean gtranslator_tab_go_to_next_fuzzy_or_untrans (GtranslatorTab *tab);
+ gboolean gtranslator_tab_go_to_prev_untrans (GtranslatorTab * tab);
-gboolean gtranslator_tab_go_to_prev_fuzzy_or_untrans (GtranslatorTab *tab);
+ gboolean gtranslator_tab_go_to_next_fuzzy_or_untrans (GtranslatorTab *
+ tab);
-void gtranslator_tab_go_to_number (GtranslatorTab *tab,
- gint number);
+ gboolean gtranslator_tab_go_to_prev_fuzzy_or_untrans (GtranslatorTab *
+ tab);
-void gtranslator_tab_set_message_area (GtranslatorTab *tab,
- GtkWidget *message_area);
-
-gboolean _gtranslator_tab_can_close (GtranslatorTab *tab);
+ void gtranslator_tab_go_to_number (GtranslatorTab * tab, gint number);
-G_END_DECLS
+ void gtranslator_tab_set_message_area (GtranslatorTab * tab,
+ GtkWidget * message_area);
+
+ gboolean _gtranslator_tab_can_close (GtranslatorTab * tab);
+G_END_DECLS
#endif /* __TAB_H__ */
diff --git a/src/toolbareditor/egg-editable-toolbar.c b/src/toolbareditor/egg-editable-toolbar.c
index 0719788..e2eea43 100644
--- a/src/toolbareditor/egg-editable-toolbar.c
+++ b/src/toolbareditor/egg-editable-toolbar.c
@@ -29,7 +29,7 @@
#include <glib/gi18n.h>
#include <string.h>
-static GdkPixbuf * new_separator_pixbuf (void);
+static GdkPixbuf *new_separator_pixbuf (void);
#define MIN_TOOLBAR_HEIGHT 20
#define EGG_ITEM_NAME "egg-item-name"
@@ -76,16 +76,15 @@ struct _EggEditableToolbarPrivate
char *popup_path;
- guint dnd_pending;
- GtkToolbar *dnd_toolbar;
+ guint dnd_pending;
+ GtkToolbar *dnd_toolbar;
GtkToolItem *dnd_toolitem;
};
G_DEFINE_TYPE (EggEditableToolbar, egg_editable_toolbar, GTK_TYPE_VBOX);
static int
-get_dock_position (EggEditableToolbar *etoolbar,
- GtkWidget *dock)
+get_dock_position (EggEditableToolbar * etoolbar, GtkWidget * dock)
{
GList *l;
int result;
@@ -98,13 +97,13 @@ get_dock_position (EggEditableToolbar *etoolbar,
}
static int
-get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
+get_toolbar_position (EggEditableToolbar * etoolbar, GtkWidget * toolbar)
{
return get_dock_position (etoolbar, toolbar->parent);
}
static int
-get_n_toolbars (EggEditableToolbar *etoolbar)
+get_n_toolbars (EggEditableToolbar * etoolbar)
{
GList *l;
int result;
@@ -117,8 +116,7 @@ get_n_toolbars (EggEditableToolbar *etoolbar)
}
static GtkWidget *
-get_dock_nth (EggEditableToolbar *etoolbar,
- int position)
+get_dock_nth (EggEditableToolbar * etoolbar, int position)
{
GList *l;
GtkWidget *result;
@@ -131,8 +129,7 @@ get_dock_nth (EggEditableToolbar *etoolbar,
}
static GtkWidget *
-get_toolbar_nth (EggEditableToolbar *etoolbar,
- int position)
+get_toolbar_nth (EggEditableToolbar * etoolbar, int position)
{
GList *l;
GtkWidget *dock;
@@ -149,8 +146,7 @@ get_toolbar_nth (EggEditableToolbar *etoolbar,
}
static GtkAction *
-find_action (EggEditableToolbar *etoolbar,
- const char *name)
+find_action (EggEditableToolbar * etoolbar, const char *name)
{
GList *l;
GtkAction *action = NULL;
@@ -172,9 +168,8 @@ find_action (EggEditableToolbar *etoolbar,
}
static void
-drag_data_delete_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggEditableToolbar *etoolbar)
+drag_data_delete_cb (GtkWidget * widget,
+ GdkDragContext * context, EggEditableToolbar * etoolbar)
{
int pos, toolbar_pos;
@@ -186,14 +181,12 @@ drag_data_delete_cb (GtkWidget *widget,
GTK_TOOL_ITEM (widget));
toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
- egg_toolbars_model_remove_item (etoolbar->priv->model,
- toolbar_pos, pos);
+ egg_toolbars_model_remove_item (etoolbar->priv->model, toolbar_pos, pos);
}
static void
-drag_begin_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggEditableToolbar *etoolbar)
+drag_begin_cb (GtkWidget * widget,
+ GdkDragContext * context, EggEditableToolbar * etoolbar)
{
GtkAction *action;
gint flags;
@@ -206,7 +199,8 @@ drag_begin_cb (GtkWidget *widget,
action = gtk_widget_get_action (widget);
#endif
- if (action == NULL) return;
+ if (action == NULL)
+ return;
flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model,
gtk_action_get_name (action));
@@ -214,15 +208,13 @@ drag_begin_cb (GtkWidget *widget,
{
flags &= ~EGG_TB_MODEL_NAME_USED;
egg_toolbars_model_set_name_flags (etoolbar->priv->model,
- gtk_action_get_name (action),
- flags);
+ gtk_action_get_name (action), flags);
}
}
static void
-drag_end_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggEditableToolbar *etoolbar)
+drag_end_cb (GtkWidget * widget,
+ GdkDragContext * context, EggEditableToolbar * etoolbar)
{
GtkAction *action;
gint flags;
@@ -237,12 +229,14 @@ drag_end_cb (GtkWidget *widget,
action = gtk_widget_get_action (widget);
#endif
- if (action == NULL) return;
+ if (action == NULL)
+ return;
flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model,
- gtk_action_get_name (action));
+ gtk_action_get_name
+ (action));
if (!(flags & EGG_TB_MODEL_NAME_INFINITE))
- {
+ {
flags |= EGG_TB_MODEL_NAME_USED;
egg_toolbars_model_set_name_flags (etoolbar->priv->model,
gtk_action_get_name (action),
@@ -252,12 +246,10 @@ drag_end_cb (GtkWidget *widget,
}
static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EggEditableToolbar *etoolbar)
+drag_data_get_cb (GtkWidget * widget,
+ GdkDragContext * context,
+ GtkSelectionData * selection_data,
+ guint info, guint32 time, EggEditableToolbar * etoolbar)
{
EggToolbarsModel *model;
const char *name;
@@ -269,26 +261,31 @@ drag_data_get_cb (GtkWidget *widget,
name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
if (name == NULL)
{
- name = g_object_get_data (G_OBJECT (gtk_widget_get_parent (widget)), EGG_ITEM_NAME);
+ name =
+ g_object_get_data (G_OBJECT (gtk_widget_get_parent (widget)),
+ EGG_ITEM_NAME);
g_return_if_fail (name != NULL);
}
data = egg_toolbars_model_get_data (model, selection_data->target, name);
if (data != NULL)
{
- gtk_selection_data_set (selection_data, selection_data->target, 8, (unsigned char *)data, strlen (data));
+ gtk_selection_data_set (selection_data, selection_data->target, 8,
+ (unsigned char *) data, strlen (data));
g_free (data);
}
}
static void
-move_item_cb (GtkAction *action,
- EggEditableToolbar *etoolbar)
+move_item_cb (GtkAction * action, EggEditableToolbar * etoolbar)
{
- GtkWidget *toolitem = gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar), GTK_TYPE_TOOL_ITEM);
- GtkTargetList *list = gtk_target_list_new (dest_drag_types, G_N_ELEMENTS (dest_drag_types));
+ GtkWidget *toolitem =
+ gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar),
+ GTK_TYPE_TOOL_ITEM);
+ GtkTargetList *list =
+ gtk_target_list_new (dest_drag_types, G_N_ELEMENTS (dest_drag_types));
- GdkEvent *realevent = gtk_get_current_event();
+ GdkEvent *realevent = gtk_get_current_event ();
GdkEventMotion event;
event.type = GDK_MOTION_NOTIFY;
event.window = realevent->any.window;
@@ -299,23 +296,23 @@ move_item_cb (GtkAction *action,
gdk_event_get_coords (realevent, &event.x, &event.y);
gdk_event_get_root_coords (realevent, &event.x_root, &event.y_root);
- gtk_drag_begin (toolitem, list, GDK_ACTION_MOVE, 1, (GdkEvent *)&event);
+ gtk_drag_begin (toolitem, list, GDK_ACTION_MOVE, 1, (GdkEvent *) & event);
gtk_target_list_unref (list);
}
static void
-remove_item_cb (GtkAction *action,
- EggEditableToolbar *etoolbar)
+remove_item_cb (GtkAction * action, EggEditableToolbar * etoolbar)
{
- GtkWidget *toolitem = gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar), GTK_TYPE_TOOL_ITEM);
+ GtkWidget *toolitem =
+ gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar),
+ GTK_TYPE_TOOL_ITEM);
int pos, toolbar_pos;
toolbar_pos = get_toolbar_position (etoolbar, toolitem->parent);
pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolitem->parent),
GTK_TOOL_ITEM (toolitem));
- egg_toolbars_model_remove_item (etoolbar->priv->model,
- toolbar_pos, pos);
+ egg_toolbars_model_remove_item (etoolbar->priv->model, toolbar_pos, pos);
if (egg_toolbars_model_n_items (etoolbar->priv->model, toolbar_pos) == 0)
{
@@ -324,8 +321,7 @@ remove_item_cb (GtkAction *action,
}
static void
-remove_toolbar_cb (GtkAction *action,
- EggEditableToolbar *etoolbar)
+remove_toolbar_cb (GtkAction * action, EggEditableToolbar * etoolbar)
{
GtkWidget *selected = egg_editable_toolbar_get_selected (etoolbar);
GtkWidget *toolbar = gtk_widget_get_ancestor (selected, GTK_TYPE_TOOLBAR);
@@ -336,19 +332,17 @@ remove_toolbar_cb (GtkAction *action,
}
static void
-popup_context_deactivate (GtkMenuShell *menu,
- EggEditableToolbar *etoolbar)
+popup_context_deactivate (GtkMenuShell * menu, EggEditableToolbar * etoolbar)
{
egg_editable_toolbar_set_selected (etoolbar, NULL);
g_object_notify (G_OBJECT (etoolbar), "selected");
}
static void
-popup_context_menu_cb (GtkWidget *toolbar,
- gint x,
- gint y,
- gint button_number,
- EggEditableToolbar *etoolbar)
+popup_context_menu_cb (GtkWidget * toolbar,
+ gint x,
+ gint y,
+ gint button_number, EggEditableToolbar * etoolbar)
{
if (etoolbar->priv->popup_path != NULL)
{
@@ -358,9 +352,11 @@ popup_context_menu_cb (GtkWidget *toolbar,
g_object_notify (G_OBJECT (etoolbar), "selected");
menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager,
- etoolbar->priv->popup_path));
+ etoolbar->priv->
+ popup_path));
g_return_if_fail (menu != NULL);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_number, gtk_get_current_event_time ());
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_number,
+ gtk_get_current_event_time ());
g_signal_connect_object (menu, "selection-done",
G_CALLBACK (popup_context_deactivate),
etoolbar, 0);
@@ -368,9 +364,8 @@ popup_context_menu_cb (GtkWidget *toolbar,
}
static gboolean
-button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- EggEditableToolbar *etoolbar)
+button_press_event_cb (GtkWidget * widget,
+ GdkEventButton * event, EggEditableToolbar * etoolbar)
{
if (event->button == 3 && etoolbar->priv->popup_path != NULL)
{
@@ -380,9 +375,11 @@ button_press_event_cb (GtkWidget *widget,
g_object_notify (G_OBJECT (etoolbar), "selected");
menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager,
- etoolbar->priv->popup_path));
+ etoolbar->priv->
+ popup_path));
g_return_val_if_fail (menu != NULL, FALSE);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button,
+ event->time);
g_signal_connect_object (menu, "selection-done",
G_CALLBACK (popup_context_deactivate),
etoolbar, 0);
@@ -394,7 +391,7 @@ button_press_event_cb (GtkWidget *widget,
}
static void
-configure_item_sensitivity (GtkToolItem *item, EggEditableToolbar *etoolbar)
+configure_item_sensitivity (GtkToolItem * item, EggEditableToolbar * etoolbar)
{
GtkAction *action;
char *name;
@@ -414,8 +411,7 @@ configure_item_sensitivity (GtkToolItem *item, EggEditableToolbar *etoolbar)
}
static void
-configure_item_cursor (GtkToolItem *item,
- EggEditableToolbar *etoolbar)
+configure_item_cursor (GtkToolItem * item, EggEditableToolbar * etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
GtkWidget *widget = GTK_WIDGET (item);
@@ -423,89 +419,92 @@ configure_item_cursor (GtkToolItem *item,
if (widget->window != NULL)
{
if (priv->edit_mode > 0)
- {
- GdkCursor *cursor;
+ {
+ GdkCursor *cursor;
GdkScreen *screen;
- GdkPixbuf *pixbuf = NULL;
+ GdkPixbuf *pixbuf = NULL;
screen = gtk_widget_get_screen (GTK_WIDGET (etoolbar));
- cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen),
- GDK_HAND2);
- gdk_window_set_cursor (widget->window, cursor);
- gdk_cursor_unref (cursor);
-
- gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
- G_N_ELEMENTS (dest_drag_types), GDK_ACTION_MOVE);
- if (GTK_IS_SEPARATOR_TOOL_ITEM (item))
- {
- pixbuf = new_separator_pixbuf ();
- }
- else
- {
- char *icon_name=NULL;
- char *stock_id=NULL;
- GtkAction *action;
- char *name;
-
- name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
- action = name ? find_action (etoolbar, name) : NULL;
-
- if (action)
- {
- g_object_get (action,
- "icon-name", &icon_name,
- "stock-id", &stock_id,
- NULL);
- }
- if (icon_name)
- {
- GdkScreen *screen;
- GtkIconTheme *icon_theme;
- GtkSettings *settings;
- gint width, height;
-
- screen = gtk_widget_get_screen (widget);
- icon_theme = gtk_icon_theme_get_for_screen (screen);
- settings = gtk_settings_get_for_screen (screen);
-
- if (!gtk_icon_size_lookup_for_settings (settings,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- &width, &height))
- {
- width = height = 24;
- }
-
- pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
- MIN (width, height), 0, NULL);
- }
- else if (stock_id)
- {
- pixbuf = gtk_widget_render_icon (widget, stock_id,
- GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
- }
- g_free (icon_name);
- g_free (stock_id);
- }
-
- if (G_UNLIKELY (!pixbuf))
- {
- return;
- }
- gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
- g_object_unref (pixbuf);
-
- }
+ cursor =
+ gdk_cursor_new_for_display (gdk_screen_get_display (screen),
+ GDK_HAND2);
+ gdk_window_set_cursor (widget->window, cursor);
+ gdk_cursor_unref (cursor);
+
+ gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
+ G_N_ELEMENTS (dest_drag_types),
+ GDK_ACTION_MOVE);
+ if (GTK_IS_SEPARATOR_TOOL_ITEM (item))
+ {
+ pixbuf = new_separator_pixbuf ();
+ }
+ else
+ {
+ char *icon_name = NULL;
+ char *stock_id = NULL;
+ GtkAction *action;
+ char *name;
+
+ name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
+ action = name ? find_action (etoolbar, name) : NULL;
+
+ if (action)
+ {
+ g_object_get (action,
+ "icon-name", &icon_name,
+ "stock-id", &stock_id, NULL);
+ }
+ if (icon_name)
+ {
+ GdkScreen *screen;
+ GtkIconTheme *icon_theme;
+ GtkSettings *settings;
+ gint width, height;
+
+ screen = gtk_widget_get_screen (widget);
+ icon_theme = gtk_icon_theme_get_for_screen (screen);
+ settings = gtk_settings_get_for_screen (screen);
+
+ if (!gtk_icon_size_lookup_for_settings (settings,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ &width, &height))
+ {
+ width = height = 24;
+ }
+
+ pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
+ MIN (width, height), 0,
+ NULL);
+ }
+ else if (stock_id)
+ {
+ pixbuf = gtk_widget_render_icon (widget, stock_id,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ NULL);
+ }
+ g_free (icon_name);
+ g_free (stock_id);
+ }
+
+ if (G_UNLIKELY (!pixbuf))
+ {
+ return;
+ }
+ gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
+ g_object_unref (pixbuf);
+
+ }
else
- {
- gdk_window_set_cursor (GTK_WIDGET(item)->window, NULL);
- }
+ {
+ gdk_window_set_cursor (GTK_WIDGET (item)->window, NULL);
+ }
}
}
static void
-configure_item_tooltip (GtkToolItem *item)
+configure_item_tooltip (GtkToolItem * item)
{
GtkAction *action;
@@ -523,29 +522,25 @@ configure_item_tooltip (GtkToolItem *item)
static void
-connect_widget_signals (GtkWidget *proxy, EggEditableToolbar *etoolbar)
+connect_widget_signals (GtkWidget * proxy, EggEditableToolbar * etoolbar)
{
if (GTK_IS_CONTAINER (proxy))
{
- gtk_container_forall (GTK_CONTAINER (proxy),
- (GtkCallback) connect_widget_signals,
- (gpointer) etoolbar);
+ gtk_container_forall (GTK_CONTAINER (proxy),
+ (GtkCallback) connect_widget_signals,
+ (gpointer) etoolbar);
}
if (GTK_IS_TOOL_ITEM (proxy))
{
g_signal_connect_object (proxy, "drag_begin",
- G_CALLBACK (drag_begin_cb),
- etoolbar, 0);
+ G_CALLBACK (drag_begin_cb), etoolbar, 0);
g_signal_connect_object (proxy, "drag_end",
- G_CALLBACK (drag_end_cb),
- etoolbar, 0);
+ G_CALLBACK (drag_end_cb), etoolbar, 0);
g_signal_connect_object (proxy, "drag_data_get",
- G_CALLBACK (drag_data_get_cb),
- etoolbar, 0);
+ G_CALLBACK (drag_data_get_cb), etoolbar, 0);
g_signal_connect_object (proxy, "drag_data_delete",
- G_CALLBACK (drag_data_delete_cb),
- etoolbar, 0);
+ G_CALLBACK (drag_data_delete_cb), etoolbar, 0);
}
if (GTK_IS_BUTTON (proxy) || GTK_IS_TOOL_ITEM (proxy))
@@ -557,9 +552,8 @@ connect_widget_signals (GtkWidget *proxy, EggEditableToolbar *etoolbar)
}
static void
-action_sensitive_cb (GtkAction *action,
- GParamSpec *pspec,
- GtkToolItem *item)
+action_sensitive_cb (GtkAction * action,
+ GParamSpec * pspec, GtkToolItem * item)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR
(gtk_widget_get_ancestor (GTK_WIDGET (item), EGG_TYPE_EDITABLE_TOOLBAR));
@@ -571,8 +565,7 @@ action_sensitive_cb (GtkAction *action,
}
static GtkToolItem *
-create_item_from_action (EggEditableToolbar *etoolbar,
- const char *name)
+create_item_from_action (EggEditableToolbar * etoolbar, const char *name)
{
GtkToolItem *item;
@@ -585,7 +578,8 @@ create_item_from_action (EggEditableToolbar *etoolbar,
else
{
GtkAction *action = find_action (etoolbar, name);
- if (action == NULL) return NULL;
+ if (action == NULL)
+ return NULL;
item = GTK_TOOL_ITEM (gtk_action_create_tool_item (action));
@@ -593,43 +587,43 @@ create_item_from_action (EggEditableToolbar *etoolbar,
* such demand may have been made yet, so do it ourselves.
*/
gtk_action_set_accel_group
- (action, gtk_ui_manager_get_accel_group(etoolbar->priv->manager));
+ (action, gtk_ui_manager_get_accel_group (etoolbar->priv->manager));
g_signal_connect_object (action, "notify::sensitive",
- G_CALLBACK (action_sensitive_cb), item, 0);
+ G_CALLBACK (action_sensitive_cb), item, 0);
}
gtk_widget_show (GTK_WIDGET (item));
g_object_set_data_full (G_OBJECT (item), EGG_ITEM_NAME,
- g_strdup (name), g_free);
+ g_strdup (name), g_free);
return item;
}
static GtkToolItem *
-create_item_from_position (EggEditableToolbar *etoolbar,
- int toolbar_position,
- int position)
+create_item_from_position (EggEditableToolbar * etoolbar,
+ int toolbar_position, int position)
{
GtkToolItem *item;
const char *name;
- name = egg_toolbars_model_item_nth (etoolbar->priv->model, toolbar_position, position);
+ name =
+ egg_toolbars_model_item_nth (etoolbar->priv->model, toolbar_position,
+ position);
item = create_item_from_action (etoolbar, name);
return item;
}
static void
-toolbar_drag_data_received_cb (GtkToolbar *toolbar,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EggEditableToolbar *etoolbar)
+toolbar_drag_data_received_cb (GtkToolbar * toolbar,
+ GdkDragContext * context,
+ gint x,
+ gint y,
+ GtkSelectionData * selection_data,
+ guint info,
+ guint time, EggEditableToolbar * etoolbar)
{
/* This function can be called for two reasons
*
@@ -643,7 +637,7 @@ toolbar_drag_data_received_cb (GtkToolbar *toolbar,
*/
GdkAtom type = selection_data->type;
- const char *data = (char *)selection_data->data;
+ const char *data = (char *) selection_data->data;
int ipos = -1;
char *name = NULL;
@@ -653,11 +647,15 @@ toolbar_drag_data_received_cb (GtkToolbar *toolbar,
if (selection_data->length >= 0)
{
ipos = gtk_toolbar_get_drop_index (toolbar, x, y);
- name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, FALSE);
+ name =
+ egg_toolbars_model_get_name (etoolbar->priv->model, type, data,
+ FALSE);
if (name != NULL)
{
- used = ((egg_toolbars_model_get_name_flags (etoolbar->priv->model, name) & EGG_TB_MODEL_NAME_USED) != 0);
- }
+ used =
+ ((egg_toolbars_model_get_name_flags (etoolbar->priv->model, name)
+ & EGG_TB_MODEL_NAME_USED) != 0);
+ }
}
/* If we just want a highlight item, then . */
@@ -666,11 +664,13 @@ toolbar_drag_data_received_cb (GtkToolbar *toolbar,
etoolbar->priv->dnd_pending--;
if (name != NULL && etoolbar->priv->dnd_toolbar == toolbar && !used)
- {
- etoolbar->priv->dnd_toolitem = create_item_from_action (etoolbar, name);
- gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
- etoolbar->priv->dnd_toolitem, ipos);
- }
+ {
+ etoolbar->priv->dnd_toolitem =
+ create_item_from_action (etoolbar, name);
+ gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
+ etoolbar->priv->dnd_toolitem,
+ ipos);
+ }
}
else
{
@@ -680,32 +680,35 @@ toolbar_drag_data_received_cb (GtkToolbar *toolbar,
/* If we don't have a name to use yet, try to create one. */
if (name == NULL && selection_data->length >= 0)
- {
- name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, TRUE);
- }
+ {
+ name =
+ egg_toolbars_model_get_name (etoolbar->priv->model, type, data,
+ TRUE);
+ }
if (name != NULL && !used)
- {
- gint tpos = get_toolbar_position (etoolbar, GTK_WIDGET (toolbar));
- egg_toolbars_model_add_item (etoolbar->priv->model, tpos, ipos, name);
- gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time);
- }
+ {
+ gint tpos = get_toolbar_position (etoolbar, GTK_WIDGET (toolbar));
+ egg_toolbars_model_add_item (etoolbar->priv->model, tpos, ipos,
+ name);
+ gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE,
+ time);
+ }
else
- {
- gtk_drag_finish (context, FALSE, context->action == GDK_ACTION_MOVE, time);
- }
+ {
+ gtk_drag_finish (context, FALSE, context->action == GDK_ACTION_MOVE,
+ time);
+ }
}
g_free (name);
}
static gboolean
-toolbar_drag_drop_cb (GtkToolbar *toolbar,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EggEditableToolbar *etoolbar)
+toolbar_drag_drop_cb (GtkToolbar * toolbar,
+ GdkDragContext * context,
+ gint x,
+ gint y, guint time, EggEditableToolbar * etoolbar)
{
GdkAtom target;
@@ -720,14 +723,13 @@ toolbar_drag_drop_cb (GtkToolbar *toolbar,
}
static gboolean
-toolbar_drag_motion_cb (GtkToolbar *toolbar,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EggEditableToolbar *etoolbar)
-{
- GdkAtom target = gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL);
+toolbar_drag_motion_cb (GtkToolbar * toolbar,
+ GdkDragContext * context,
+ gint x,
+ gint y, guint time, EggEditableToolbar * etoolbar)
+{
+ GdkAtom target =
+ gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL);
if (target == GDK_NONE)
{
gdk_drag_status (context, 0, time);
@@ -746,9 +748,11 @@ toolbar_drag_motion_cb (GtkToolbar *toolbar,
/* If a highlight item is available, use it. */
else if (etoolbar->priv->dnd_toolitem)
{
- gint ipos = gtk_toolbar_get_drop_index (etoolbar->priv->dnd_toolbar, x, y);
+ gint ipos =
+ gtk_toolbar_get_drop_index (etoolbar->priv->dnd_toolbar, x, y);
gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
- etoolbar->priv->dnd_toolitem, ipos);
+ etoolbar->priv->dnd_toolitem,
+ ipos);
}
gdk_drag_status (context, context->suggested_action, time);
@@ -757,10 +761,9 @@ toolbar_drag_motion_cb (GtkToolbar *toolbar,
}
static void
-toolbar_drag_leave_cb (GtkToolbar *toolbar,
- GdkDragContext *context,
- guint time,
- EggEditableToolbar *etoolbar)
+toolbar_drag_leave_cb (GtkToolbar * toolbar,
+ GdkDragContext * context,
+ guint time, EggEditableToolbar * etoolbar)
{
gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0);
@@ -773,8 +776,7 @@ toolbar_drag_leave_cb (GtkToolbar *toolbar,
}
static void
-configure_drag_dest (EggEditableToolbar *etoolbar,
- GtkToolbar *toolbar)
+configure_drag_dest (EggEditableToolbar * etoolbar, GtkToolbar * toolbar)
{
EggToolbarsItemType *type;
GtkTargetList *targets;
@@ -789,17 +791,17 @@ configure_drag_dest (EggEditableToolbar *etoolbar,
targets = gtk_drag_dest_get_target_list (GTK_WIDGET (toolbar));
list = egg_toolbars_model_get_types (etoolbar->priv->model);
while (list)
- {
- type = list->data;
- if (type->new_name != NULL || type->get_name != NULL)
- gtk_target_list_add (targets, type->type, 0, 0);
- list = list->next;
- }
+ {
+ type = list->data;
+ if (type->new_name != NULL || type->get_name != NULL)
+ gtk_target_list_add (targets, type->type, 0, 0);
+ list = list->next;
+ }
}
static void
-toggled_visibility_cb (GtkToggleAction *action,
- EggEditableToolbar *etoolbar)
+toggled_visibility_cb (GtkToggleAction * action,
+ EggEditableToolbar * etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
GtkWidget *dock;
@@ -829,12 +831,12 @@ toggled_visibility_cb (GtkToggleAction *action,
flags = egg_toolbars_model_get_flags (priv->model, i);
if (visible)
- {
+ {
flags &= ~(EGG_TB_MODEL_HIDDEN);
}
else
{
- flags |= (EGG_TB_MODEL_HIDDEN);
+ flags |= (EGG_TB_MODEL_HIDDEN);
}
egg_toolbars_model_set_flags (priv->model, i, flags);
@@ -842,7 +844,7 @@ toggled_visibility_cb (GtkToggleAction *action,
}
static void
-toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
+toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
gint n_toolbars, n_items, i, j, k;
@@ -880,23 +882,25 @@ toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
string = g_string_sized_new (0);
n_items = egg_toolbars_model_n_items (priv->model, i);
for (k = 0, j = 0; j < n_items; j++)
- {
- GValue value = { 0, };
- GtkAction *action;
- const char *name;
-
- name = egg_toolbars_model_item_nth (priv->model, i, j);
- if (name == NULL) continue;
- action = find_action (etoolbar, name);
- if (action == NULL) continue;
-
- g_value_init (&value, G_TYPE_STRING);
- g_object_get_property (G_OBJECT (action), "label", &value);
- name = g_value_get_string (&value);
- if (name == NULL)
+ {
+ GValue value = { 0, };
+ GtkAction *action;
+ const char *name;
+
+ name = egg_toolbars_model_item_nth (priv->model, i, j);
+ if (name == NULL)
+ continue;
+ action = find_action (etoolbar, name);
+ if (action == NULL)
+ continue;
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (action), "label", &value);
+ name = g_value_get_string (&value);
+ if (name == NULL)
{
- g_value_unset (&value);
- continue;
+ g_value_unset (&value);
+ continue;
}
k += g_utf8_strlen (name, -1) + 2;
if (j > 0)
@@ -912,17 +916,18 @@ toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
g_value_unset (&value);
}
if (j < n_items)
- {
+ {
g_string_append (string, " ...");
- }
+ }
tmp = g_string_free (string, FALSE);
for (j = 0, k = 0; tmp[j]; j++)
- {
- if (tmp[j] == '_') continue;
- tmp[k] = tmp[j];
- k++;
- }
+ {
+ if (tmp[j] == '_')
+ continue;
+ tmp[k] = tmp[j];
+ k++;
+ }
tmp[k] = 0;
/* Translaters: This string is for a toggle to display a toolbar.
* The name of the toolbar is automatically computed from the widgets
@@ -934,11 +939,12 @@ toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
action_label = g_strdup_printf (_("Show â??_%sâ??"), tmp);
g_free (tmp);
- sprintf(action_name, "ToolbarToggle%d", i);
+ sprintf (action_name, "ToolbarToggle%d", i);
if (i >= priv->visibility_actions->len)
- {
- action = gtk_toggle_action_new (action_name, action_label, NULL, NULL);
+ {
+ action =
+ gtk_toggle_action_new (action_name, action_label, NULL, NULL);
g_ptr_array_add (priv->visibility_actions, action);
g_signal_connect_object (action, "toggled",
G_CALLBACK (toggled_visibility_cb),
@@ -946,22 +952,24 @@ toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
gtk_action_group_add_action (priv->actions, GTK_ACTION (action));
}
else
- {
+ {
action = g_ptr_array_index (priv->visibility_actions, i);
g_object_set (action, "label", action_label, NULL);
- }
+ }
- gtk_action_set_visible (GTK_ACTION (action), (egg_toolbars_model_get_flags (priv->model, i)
- & EGG_TB_MODEL_NOT_REMOVABLE) == 0);
+ gtk_action_set_visible (GTK_ACTION (action),
+ (egg_toolbars_model_get_flags (priv->model, i) &
+ EGG_TB_MODEL_NOT_REMOVABLE) == 0);
gtk_action_set_sensitive (GTK_ACTION (action), showing);
gtk_toggle_action_set_active (action, GTK_WIDGET_VISIBLE
(get_dock_nth (etoolbar, i)));
- for (list = priv->visibility_paths; list != NULL; list = g_list_next (list))
- {
+ for (list = priv->visibility_paths; list != NULL;
+ list = g_list_next (list))
+ {
gtk_ui_manager_add_ui (priv->manager, priv->visibility_id,
- (const char *)list->data, action_name, action_name,
- GTK_UI_MANAGER_MENUITEM, FALSE);
+ (const char *) list->data, action_name,
+ action_name, GTK_UI_MANAGER_MENUITEM, FALSE);
}
g_free (action_label);
@@ -979,7 +987,7 @@ toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
}
static GtkWidget *
-create_dock (EggEditableToolbar *etoolbar)
+create_dock (EggEditableToolbar * etoolbar)
{
GtkWidget *toolbar, *hbox;
@@ -1008,24 +1016,24 @@ create_dock (EggEditableToolbar *etoolbar)
}
static void
-set_fixed_style (EggEditableToolbar *t, GtkToolbarStyle style)
+set_fixed_style (EggEditableToolbar * t, GtkToolbarStyle style)
{
g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
gtk_toolbar_set_style (GTK_TOOLBAR (t->priv->fixed_toolbar),
- style == GTK_TOOLBAR_ICONS ? GTK_TOOLBAR_BOTH_HORIZ : style);
+ style ==
+ GTK_TOOLBAR_ICONS ? GTK_TOOLBAR_BOTH_HORIZ : style);
}
static void
-unset_fixed_style (EggEditableToolbar *t)
+unset_fixed_style (EggEditableToolbar * t)
{
g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
gtk_toolbar_unset_style (GTK_TOOLBAR (t->priv->fixed_toolbar));
}
static void
-toolbar_changed_cb (EggToolbarsModel *model,
- int position,
- EggEditableToolbar *etoolbar)
+toolbar_changed_cb (EggToolbarsModel * model,
+ int position, EggEditableToolbar * etoolbar)
{
GtkWidget *toolbar;
EggTbModelFlags flags;
@@ -1035,30 +1043,30 @@ toolbar_changed_cb (EggToolbarsModel *model,
toolbar = get_toolbar_nth (etoolbar, position);
if (flags & EGG_TB_MODEL_ICONS)
- {
- style = GTK_TOOLBAR_ICONS;
- }
+ {
+ style = GTK_TOOLBAR_ICONS;
+ }
else if (flags & EGG_TB_MODEL_TEXT)
- {
- style = GTK_TOOLBAR_TEXT;
- }
+ {
+ style = GTK_TOOLBAR_TEXT;
+ }
else if (flags & EGG_TB_MODEL_BOTH)
- {
- style = GTK_TOOLBAR_BOTH;
- }
+ {
+ style = GTK_TOOLBAR_BOTH;
+ }
else if (flags & EGG_TB_MODEL_BOTH_HORIZ)
- {
- style = GTK_TOOLBAR_BOTH_HORIZ;
- }
+ {
+ style = GTK_TOOLBAR_BOTH_HORIZ;
+ }
else
- {
- gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
- if (position == 0 && etoolbar->priv->fixed_toolbar)
- {
- unset_fixed_style (etoolbar);
- }
- return;
- }
+ {
+ gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
+ if (position == 0 && etoolbar->priv->fixed_toolbar)
+ {
+ unset_fixed_style (etoolbar);
+ }
+ return;
+ }
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
if (position == 0 && etoolbar->priv->fixed_toolbar)
@@ -1070,7 +1078,7 @@ toolbar_changed_cb (EggToolbarsModel *model,
}
static void
-unparent_fixed (EggEditableToolbar *etoolbar)
+unparent_fixed (EggEditableToolbar * etoolbar)
{
GtkWidget *toolbar, *dock;
g_return_if_fail (GTK_IS_TOOLBAR (etoolbar->priv->fixed_toolbar));
@@ -1085,10 +1093,11 @@ unparent_fixed (EggEditableToolbar *etoolbar)
}
static void
-update_fixed (EggEditableToolbar *etoolbar)
+update_fixed (EggEditableToolbar * etoolbar)
{
GtkWidget *toolbar, *dock;
- if (!etoolbar->priv->fixed_toolbar) return;
+ if (!etoolbar->priv->fixed_toolbar)
+ return;
toolbar = etoolbar->priv->fixed_toolbar;
dock = get_dock_nth (etoolbar, 0);
@@ -1105,14 +1114,14 @@ update_fixed (EggEditableToolbar *etoolbar)
}
static void
-toolbar_added_cb (EggToolbarsModel *model,
- int position,
- EggEditableToolbar *etoolbar)
+toolbar_added_cb (EggToolbarsModel * model,
+ int position, EggEditableToolbar * etoolbar)
{
GtkWidget *dock;
dock = create_dock (etoolbar);
- if ((egg_toolbars_model_get_flags (model, position) & EGG_TB_MODEL_HIDDEN) == 0)
+ if ((egg_toolbars_model_get_flags (model, position) & EGG_TB_MODEL_HIDDEN)
+ == 0)
gtk_widget_show (dock);
gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
@@ -1129,9 +1138,8 @@ toolbar_added_cb (EggToolbarsModel *model,
}
static void
-toolbar_removed_cb (EggToolbarsModel *model,
- int position,
- EggEditableToolbar *etoolbar)
+toolbar_removed_cb (EggToolbarsModel * model,
+ int position, EggEditableToolbar * etoolbar)
{
GtkWidget *dock;
@@ -1149,10 +1157,8 @@ toolbar_removed_cb (EggToolbarsModel *model,
}
static void
-item_added_cb (EggToolbarsModel *model,
- int tpos,
- int ipos,
- EggEditableToolbar *etoolbar)
+item_added_cb (EggToolbarsModel * model,
+ int tpos, int ipos, EggEditableToolbar * etoolbar)
{
GtkWidget *dock;
GtkWidget *toolbar;
@@ -1160,7 +1166,8 @@ item_added_cb (EggToolbarsModel *model,
toolbar = get_toolbar_nth (etoolbar, tpos);
item = create_item_from_position (etoolbar, tpos, ipos);
- if (item == NULL) return;
+ if (item == NULL)
+ return;
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, ipos);
@@ -1177,10 +1184,9 @@ item_added_cb (EggToolbarsModel *model,
}
static void
-item_removed_cb (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- EggEditableToolbar *etoolbar)
+item_removed_cb (EggToolbarsModel * model,
+ int toolbar_position,
+ int position, EggEditableToolbar * etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1189,7 +1195,7 @@ item_removed_cb (EggToolbarsModel *model,
toolbar = get_toolbar_nth (etoolbar, toolbar_position);
item = GTK_WIDGET (gtk_toolbar_get_nth_item
- (GTK_TOOLBAR (toolbar), position));
+ (GTK_TOOLBAR (toolbar), position));
g_return_if_fail (item != NULL);
if (item == priv->selected)
@@ -1203,7 +1209,7 @@ item_removed_cb (EggToolbarsModel *model,
}
static void
-egg_editable_toolbar_build (EggEditableToolbar *etoolbar)
+egg_editable_toolbar_build (EggEditableToolbar * etoolbar)
{
int i, l, n_items, n_toolbars;
EggToolbarsModel *model = etoolbar->priv->model;
@@ -1218,50 +1224,51 @@ egg_editable_toolbar_build (EggEditableToolbar *etoolbar)
GtkWidget *toolbar, *dock;
dock = create_dock (etoolbar);
- if ((egg_toolbars_model_get_flags (model, i) & EGG_TB_MODEL_HIDDEN) == 0)
- gtk_widget_show (dock);
+ if ((egg_toolbars_model_get_flags (model, i) & EGG_TB_MODEL_HIDDEN) ==
+ 0)
+ gtk_widget_show (dock);
gtk_box_pack_start (GTK_BOX (etoolbar), dock, TRUE, TRUE, 0);
toolbar = get_toolbar_nth (etoolbar, i);
n_items = egg_toolbars_model_n_items (model, i);
for (l = 0; l < n_items; l++)
- {
- GtkToolItem *item;
+ {
+ GtkToolItem *item;
- item = create_item_from_position (etoolbar, i, l);
- if (item)
- {
+ item = create_item_from_position (etoolbar, i, l);
+ if (item)
+ {
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, l);
- connect_widget_signals (GTK_WIDGET (item), etoolbar);
+ connect_widget_signals (GTK_WIDGET (item), etoolbar);
configure_item_tooltip (item);
- configure_item_sensitivity (item, etoolbar);
- }
- else
- {
- egg_toolbars_model_remove_item (model, i, l);
- l--;
- n_items--;
- }
- }
+ configure_item_sensitivity (item, etoolbar);
+ }
+ else
+ {
+ egg_toolbars_model_remove_item (model, i, l);
+ l--;
+ n_items--;
+ }
+ }
if (n_items == 0)
- {
- gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
- }
+ {
+ gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
+ }
}
update_fixed (etoolbar);
/* apply styles */
- for (i = 0; i < n_toolbars; i ++)
+ for (i = 0; i < n_toolbars; i++)
{
toolbar_changed_cb (model, i, etoolbar);
}
}
static void
-egg_editable_toolbar_disconnect_model (EggEditableToolbar *toolbar)
+egg_editable_toolbar_disconnect_model (EggEditableToolbar * toolbar)
{
EggToolbarsModel *model = toolbar->priv->model;
@@ -1278,7 +1285,7 @@ egg_editable_toolbar_disconnect_model (EggEditableToolbar *toolbar)
}
static void
-egg_editable_toolbar_deconstruct (EggEditableToolbar *toolbar)
+egg_editable_toolbar_deconstruct (EggEditableToolbar * toolbar)
{
EggToolbarsModel *model = toolbar->priv->model;
GList *children;
@@ -1287,8 +1294,8 @@ egg_editable_toolbar_deconstruct (EggEditableToolbar *toolbar)
if (toolbar->priv->fixed_toolbar)
{
- unset_fixed_style (toolbar);
- unparent_fixed (toolbar);
+ unset_fixed_style (toolbar);
+ unparent_fixed (toolbar);
}
children = gtk_container_get_children (GTK_CONTAINER (toolbar));
@@ -1297,12 +1304,13 @@ egg_editable_toolbar_deconstruct (EggEditableToolbar *toolbar)
}
void
-egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar,
- EggToolbarsModel *model)
+egg_editable_toolbar_set_model (EggEditableToolbar * etoolbar,
+ EggToolbarsModel * model)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
- if (priv->model == model) return;
+ if (priv->model == model)
+ return;
if (priv->model)
{
@@ -1331,7 +1339,7 @@ egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar,
}
static void
-egg_editable_toolbar_init (EggEditableToolbar *etoolbar)
+egg_editable_toolbar_init (EggEditableToolbar * etoolbar)
{
EggEditableToolbarPrivate *priv;
@@ -1344,7 +1352,7 @@ egg_editable_toolbar_init (EggEditableToolbar *etoolbar)
}
static void
-egg_editable_toolbar_dispose (GObject *object)
+egg_editable_toolbar_dispose (GObject * object)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1370,7 +1378,7 @@ egg_editable_toolbar_dispose (GObject *object)
if (priv->manager != NULL)
{
if (priv->visibility_id)
- {
+ {
gtk_ui_manager_remove_ui (priv->manager, priv->visibility_id);
priv->visibility_id = 0;
}
@@ -1390,65 +1398,77 @@ egg_editable_toolbar_dispose (GObject *object)
}
static void
-egg_editable_toolbar_set_ui_manager (EggEditableToolbar *etoolbar,
- GtkUIManager *manager)
+egg_editable_toolbar_set_ui_manager (EggEditableToolbar * etoolbar,
+ GtkUIManager * manager)
{
static const GtkActionEntry actions[] = {
- { "MoveToolItem", STOCK_DRAG_MODE, N_("_Move on Toolbar"), NULL,
- N_("Move the selected item on the toolbar"), G_CALLBACK (move_item_cb) },
- { "RemoveToolItem", GTK_STOCK_REMOVE, N_("_Remove from Toolbar"), NULL,
- N_("Remove the selected item from the toolbar"), G_CALLBACK (remove_item_cb) },
- { "RemoveToolbar", GTK_STOCK_DELETE, N_("_Delete Toolbar"), NULL,
- N_("Remove the selected toolbar"), G_CALLBACK (remove_toolbar_cb) },
+ {"MoveToolItem", STOCK_DRAG_MODE, N_("_Move on Toolbar"), NULL,
+ N_("Move the selected item on the toolbar"), G_CALLBACK (move_item_cb)},
+ {"RemoveToolItem", GTK_STOCK_REMOVE, N_("_Remove from Toolbar"), NULL,
+ N_("Remove the selected item from the toolbar"),
+ G_CALLBACK (remove_item_cb)},
+ {"RemoveToolbar", GTK_STOCK_DELETE, N_("_Delete Toolbar"), NULL,
+ N_("Remove the selected toolbar"), G_CALLBACK (remove_toolbar_cb)},
};
etoolbar->priv->manager = g_object_ref (manager);
etoolbar->priv->actions = gtk_action_group_new ("ToolbarActions");
- gtk_action_group_set_translation_domain (etoolbar->priv->actions, GETTEXT_PACKAGE);
+ gtk_action_group_set_translation_domain (etoolbar->priv->actions,
+ GETTEXT_PACKAGE);
gtk_action_group_add_actions (etoolbar->priv->actions, actions,
- G_N_ELEMENTS (actions), etoolbar);
+ G_N_ELEMENTS (actions), etoolbar);
gtk_ui_manager_insert_action_group (manager, etoolbar->priv->actions, -1);
g_object_unref (etoolbar->priv->actions);
toolbar_visibility_refresh (etoolbar);
}
-GtkWidget * egg_editable_toolbar_get_selected (EggEditableToolbar *etoolbar)
+GtkWidget *
+egg_editable_toolbar_get_selected (EggEditableToolbar * etoolbar)
{
return etoolbar->priv->selected;
}
void
-egg_editable_toolbar_set_selected (EggEditableToolbar *etoolbar,
- GtkWidget *widget)
+egg_editable_toolbar_set_selected (EggEditableToolbar * etoolbar,
+ GtkWidget * widget)
{
GtkWidget *toolbar, *toolitem;
gboolean editable;
etoolbar->priv->selected = widget;
- toolbar = (widget != NULL) ? gtk_widget_get_ancestor (widget, GTK_TYPE_TOOLBAR) : NULL;
- toolitem = (widget != NULL) ? gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM) : NULL;
+ toolbar =
+ (widget != NULL) ? gtk_widget_get_ancestor (widget,
+ GTK_TYPE_TOOLBAR) : NULL;
+ toolitem =
+ (widget != NULL) ? gtk_widget_get_ancestor (widget,
+ GTK_TYPE_TOOL_ITEM) : NULL;
- if(toolbar != NULL)
+ if (toolbar != NULL)
{
gint tpos = get_toolbar_position (etoolbar, toolbar);
- editable = ((egg_toolbars_model_get_flags (etoolbar->priv->model, tpos) & EGG_TB_MODEL_NOT_EDITABLE) == 0);
+ editable =
+ ((egg_toolbars_model_get_flags (etoolbar->priv->model, tpos) &
+ EGG_TB_MODEL_NOT_EDITABLE) == 0);
}
else
{
editable = FALSE;
}
- gtk_action_set_visible (find_action (etoolbar, "RemoveToolbar"), (toolbar != NULL) && (etoolbar->priv->edit_mode > 0));
- gtk_action_set_visible (find_action (etoolbar, "RemoveToolItem"), (toolitem != NULL) && editable);
- gtk_action_set_visible (find_action (etoolbar, "MoveToolItem"), (toolitem != NULL) && editable);
+ gtk_action_set_visible (find_action (etoolbar, "RemoveToolbar"),
+ (toolbar != NULL)
+ && (etoolbar->priv->edit_mode > 0));
+ gtk_action_set_visible (find_action (etoolbar, "RemoveToolItem"),
+ (toolitem != NULL) && editable);
+ gtk_action_set_visible (find_action (etoolbar, "MoveToolItem"),
+ (toolitem != NULL) && editable);
}
static void
-set_edit_mode (EggEditableToolbar *etoolbar,
- gboolean mode)
+set_edit_mode (EggEditableToolbar * etoolbar, gboolean mode)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
int i, l, n_items;
@@ -1467,51 +1487,52 @@ set_edit_mode (EggEditableToolbar *etoolbar,
if (i == 0)
{
- for (i = get_n_toolbars (etoolbar)-1; i >= 0; i--)
- {
- GtkWidget *toolbar;
+ for (i = get_n_toolbars (etoolbar) - 1; i >= 0; i--)
+ {
+ GtkWidget *toolbar;
- toolbar = get_toolbar_nth (etoolbar, i);
- n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
+ toolbar = get_toolbar_nth (etoolbar, i);
+ n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
- if (n_items == 0 && priv->edit_mode == 0)
- {
- egg_toolbars_model_remove_toolbar (priv->model, i);
- }
- else
- {
- for (l = 0; l < n_items; l++)
- {
- GtkToolItem *item;
+ if (n_items == 0 && priv->edit_mode == 0)
+ {
+ egg_toolbars_model_remove_toolbar (priv->model, i);
+ }
+ else
+ {
+ for (l = 0; l < n_items; l++)
+ {
+ GtkToolItem *item;
- item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
+ item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
- configure_item_cursor (item, etoolbar);
- configure_item_sensitivity (item, etoolbar);
- }
- }
- }
+ configure_item_cursor (item, etoolbar);
+ configure_item_sensitivity (item, etoolbar);
+ }
+ }
+ }
}
}
static void
-egg_editable_toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+egg_editable_toolbar_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
switch (prop_id)
{
case PROP_UI_MANAGER:
- egg_editable_toolbar_set_ui_manager (etoolbar, g_value_get_object (value));
+ egg_editable_toolbar_set_ui_manager (etoolbar,
+ g_value_get_object (value));
break;
case PROP_TOOLBARS_MODEL:
egg_editable_toolbar_set_model (etoolbar, g_value_get_object (value));
break;
case PROP_SELECTED:
- egg_editable_toolbar_set_selected (etoolbar, g_value_get_object (value));
+ egg_editable_toolbar_set_selected (etoolbar,
+ g_value_get_object (value));
break;
case PROP_POPUP_PATH:
etoolbar->priv->popup_path = g_strdup (g_value_get_string (value));
@@ -1526,10 +1547,9 @@ egg_editable_toolbar_set_property (GObject *object,
}
static void
-egg_editable_toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+egg_editable_toolbar_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
@@ -1545,7 +1565,7 @@ egg_editable_toolbar_get_property (GObject *object,
g_value_set_object (value, etoolbar->priv->selected);
break;
case PROP_EDIT_MODE:
- g_value_set_boolean (value, etoolbar->priv->edit_mode>0);
+ g_value_set_boolean (value, etoolbar->priv->edit_mode > 0);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1554,7 +1574,7 @@ egg_editable_toolbar_get_property (GObject *object,
}
static void
-egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
+egg_editable_toolbar_class_init (EggEditableToolbarClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1576,21 +1596,27 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
"UI-Mmanager",
"UI Manager",
GTK_TYPE_UI_MANAGER,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class,
- PROP_TOOLBARS_MODEL,
- g_param_spec_object ("model",
- "Model",
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class, PROP_TOOLBARS_MODEL,
+ g_param_spec_object ("model", "Model",
"Toolbars Model",
EGG_TYPE_TOOLBARS_MODEL,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class,
- PROP_SELECTED,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class, PROP_SELECTED,
g_param_spec_object ("selected",
"Selected",
"Selected toolitem",
GTK_TYPE_TOOL_ITEM,
- G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_POPUP_PATH,
@@ -1598,7 +1624,10 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
"popup-path",
"popup-path",
NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_EDIT_MODE,
@@ -1606,35 +1635,35 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
"Edit-Mode",
"Edit Mode",
FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
g_type_class_add_private (object_class, sizeof (EggEditableToolbarPrivate));
}
GtkWidget *
-egg_editable_toolbar_new (GtkUIManager *manager,
- const char *popup_path)
+egg_editable_toolbar_new (GtkUIManager * manager, const char *popup_path)
{
- return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
- "ui-manager", manager,
- "popup-path", popup_path,
- NULL));
+ return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
+ "ui-manager", manager,
+ "popup-path", popup_path, NULL));
}
GtkWidget *
-egg_editable_toolbar_new_with_model (GtkUIManager *manager,
- EggToolbarsModel *model,
- const char *popup_path)
+egg_editable_toolbar_new_with_model (GtkUIManager * manager,
+ EggToolbarsModel * model,
+ const char *popup_path)
{
return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
- "ui-manager", manager,
- "model", model,
- "popup-path", popup_path,
- NULL));
+ "ui-manager", manager,
+ "model", model,
+ "popup-path", popup_path, NULL));
}
gboolean
-egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar)
+egg_editable_toolbar_get_edit_mode (EggEditableToolbar * etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1642,7 +1671,7 @@ egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar)
}
void
-egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
+egg_editable_toolbar_set_edit_mode (EggEditableToolbar * etoolbar,
gboolean mode)
{
set_edit_mode (etoolbar, mode);
@@ -1650,16 +1679,15 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
}
void
-egg_editable_toolbar_add_visibility (EggEditableToolbar *etoolbar,
+egg_editable_toolbar_add_visibility (EggEditableToolbar * etoolbar,
const char *path)
{
etoolbar->priv->visibility_paths = g_list_prepend
- (etoolbar->priv->visibility_paths, g_strdup (path));
+ (etoolbar->priv->visibility_paths, g_strdup (path));
}
void
-egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
- const char *name)
+egg_editable_toolbar_show (EggEditableToolbar * etoolbar, const char *name)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
EggToolbarsModel *model = priv->model;
@@ -1672,15 +1700,14 @@ egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
if (strcmp (toolbar_name, name) == 0)
- {
- gtk_widget_show (get_dock_nth (etoolbar, i));
- }
+ {
+ gtk_widget_show (get_dock_nth (etoolbar, i));
+ }
}
}
void
-egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
- const char *name)
+egg_editable_toolbar_hide (EggEditableToolbar * etoolbar, const char *name)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
EggToolbarsModel *model = priv->model;
@@ -1693,15 +1720,15 @@ egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
if (strcmp (toolbar_name, name) == 0)
- {
- gtk_widget_hide (get_dock_nth (etoolbar, i));
- }
+ {
+ gtk_widget_hide (get_dock_nth (etoolbar, i));
+ }
}
}
void
-egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
- GtkToolbar *toolbar)
+egg_editable_toolbar_set_fixed (EggEditableToolbar * etoolbar,
+ GtkToolbar * toolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1728,8 +1755,7 @@ egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
#define DEFAULT_ICON_WIDTH 0
static void
-fake_expose_widget (GtkWidget *widget,
- GdkPixmap *pixmap)
+fake_expose_widget (GtkWidget * widget, GdkPixmap * pixmap)
{
GdkWindow *tmp_window;
GdkEventExpose event;
@@ -1743,7 +1769,7 @@ fake_expose_widget (GtkWidget *widget,
tmp_window = widget->window;
widget->window = pixmap;
- gtk_widget_send_expose (widget, (GdkEvent *) &event);
+ gtk_widget_send_expose (widget, (GdkEvent *) & event);
widget->window = tmp_window;
}
@@ -1753,7 +1779,7 @@ fake_expose_widget (GtkWidget *widget,
* with large toolbar icons.
*/
static GdkPixbuf *
-new_pixbuf_from_widget (GtkWidget *widget)
+new_pixbuf_from_widget (GtkWidget * widget)
{
GtkWidget *window;
GdkPixbuf *pixbuf;
@@ -1769,10 +1795,9 @@ new_pixbuf_from_widget (GtkWidget *widget)
screen = gtk_widget_get_screen (widget);
- if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- NULL,
- &icon_height))
+ if (!gtk_icon_size_lookup_for_settings
+ (gtk_settings_get_for_screen (screen), GTK_ICON_SIZE_LARGE_TOOLBAR,
+ NULL, &icon_height))
{
icon_height = DEFAULT_ICON_HEIGHT;
}
@@ -1791,7 +1816,7 @@ new_pixbuf_from_widget (GtkWidget *widget)
* This is needed mostly for pixmap based themes.
*/
gtk_window_set_default_size (GTK_WINDOW (window), icon_width, icon_height);
- gtk_window_get_size (GTK_WINDOW (window),&icon_width, &icon_height);
+ gtk_window_get_size (GTK_WINDOW (window), &icon_width, &icon_height);
gtk_widget_size_request (window, &requisition);
allocation.x = 0;
@@ -1804,7 +1829,8 @@ new_pixbuf_from_widget (GtkWidget *widget)
/* Create a pixmap */
visual = gtk_widget_get_visual (window);
pixmap = gdk_pixmap_new (NULL, icon_width, icon_height, visual->depth);
- gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gtk_widget_get_colormap (window));
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap),
+ gtk_widget_get_colormap (window));
/* Draw the window */
gtk_widget_ensure_style (window);
@@ -1814,8 +1840,10 @@ new_pixbuf_from_widget (GtkWidget *widget)
fake_expose_widget (window, pixmap);
fake_expose_widget (widget, pixmap);
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
- gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width, icon_height);
+ pixbuf =
+ gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
+ gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width,
+ icon_height);
gtk_widget_destroy (window);
@@ -1834,7 +1862,7 @@ new_separator_pixbuf (void)
}
static void
-update_separator_image (GtkImage *image)
+update_separator_image (GtkImage * image)
{
GdkPixbuf *pixbuf = new_separator_pixbuf ();
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
@@ -1842,9 +1870,7 @@ update_separator_image (GtkImage *image)
}
static gboolean
-style_set_cb (GtkWidget *widget,
- GtkStyle *previous_style,
- GtkImage *image)
+style_set_cb (GtkWidget * widget, GtkStyle * previous_style, GtkImage * image)
{
update_separator_image (image);
@@ -1863,7 +1889,7 @@ _egg_editable_toolbar_new_separator_image (void)
}
EggToolbarsModel *
-egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar)
+egg_editable_toolbar_get_model (EggEditableToolbar * etoolbar)
{
return etoolbar->priv->model;
}
diff --git a/src/toolbareditor/egg-editable-toolbar.h b/src/toolbareditor/egg-editable-toolbar.h
index 12ce2aa..29d9d91 100644
--- a/src/toolbareditor/egg-editable-toolbar.h
+++ b/src/toolbareditor/egg-editable-toolbar.h
@@ -27,23 +27,21 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
#define EGG_TYPE_EDITABLE_TOOLBAR (egg_editable_toolbar_get_type ())
#define EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbar))
#define EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarClass))
#define EGG_IS_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_EDITABLE_TOOLBAR))
#define EGG_IS_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_EDITABLE_TOOLBAR))
#define EGG_EDITABLE_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarClass))
-
-typedef struct _EggEditableToolbar EggEditableToolbar;
+typedef struct _EggEditableToolbar EggEditableToolbar;
typedef struct _EggEditableToolbarPrivate EggEditableToolbarPrivate;
-typedef struct _EggEditableToolbarClass EggEditableToolbarClass;
+typedef struct _EggEditableToolbarClass EggEditableToolbarClass;
struct _EggEditableToolbar
{
GtkVBox parent_object;
- /*< private >*/
+ /*< private > */
EggEditableToolbarPrivate *priv;
};
@@ -51,41 +49,42 @@ struct _EggEditableToolbarClass
{
GtkVBoxClass parent_class;
- void (* action_request) (EggEditableToolbar *etoolbar,
- const char *action_name);
+ void (*action_request) (EggEditableToolbar * etoolbar,
+ const char *action_name);
};
-GType egg_editable_toolbar_get_type (void);
-GtkWidget *egg_editable_toolbar_new (GtkUIManager *manager,
- const char *visibility_path);
-GtkWidget *egg_editable_toolbar_new_with_model (GtkUIManager *manager,
- EggToolbarsModel *model,
- const char *visibility_path);
-void egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar,
- EggToolbarsModel *model);
-EggToolbarsModel *egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar);
-GtkUIManager *egg_editable_toolbar_get_manager (EggEditableToolbar *etoolbar);
-void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
- gboolean mode);
-gboolean egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar);
-void egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
- const char *name);
-void egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
- const char *name);
-void egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
- GtkToolbar *fixed_toolbar);
-
-GtkWidget * egg_editable_toolbar_get_selected (EggEditableToolbar *etoolbar);
-void egg_editable_toolbar_set_selected (EggEditableToolbar *etoolbar,
- GtkWidget *widget);
-
-void egg_editable_toolbar_add_visibility (EggEditableToolbar *etoolbar,
- const char *path);
+GType egg_editable_toolbar_get_type (void);
+GtkWidget *egg_editable_toolbar_new (GtkUIManager * manager,
+ const char *visibility_path);
+GtkWidget *egg_editable_toolbar_new_with_model (GtkUIManager * manager,
+ EggToolbarsModel * model,
+ const char *visibility_path);
+void egg_editable_toolbar_set_model (EggEditableToolbar * etoolbar,
+ EggToolbarsModel * model);
+EggToolbarsModel *egg_editable_toolbar_get_model (EggEditableToolbar *
+ etoolbar);
+GtkUIManager *egg_editable_toolbar_get_manager (EggEditableToolbar *
+ etoolbar);
+void egg_editable_toolbar_set_edit_mode (EggEditableToolbar * etoolbar,
+ gboolean mode);
+gboolean egg_editable_toolbar_get_edit_mode (EggEditableToolbar * etoolbar);
+void egg_editable_toolbar_show (EggEditableToolbar * etoolbar,
+ const char *name);
+void egg_editable_toolbar_hide (EggEditableToolbar * etoolbar,
+ const char *name);
+void egg_editable_toolbar_set_fixed (EggEditableToolbar * etoolbar,
+ GtkToolbar * fixed_toolbar);
+
+GtkWidget *egg_editable_toolbar_get_selected (EggEditableToolbar * etoolbar);
+void egg_editable_toolbar_set_selected (EggEditableToolbar * etoolbar,
+ GtkWidget * widget);
+
+void egg_editable_toolbar_add_visibility (EggEditableToolbar * etoolbar,
+ const char *path);
/* Private Functions */
-GtkWidget *_egg_editable_toolbar_new_separator_image (void);
+GtkWidget *_egg_editable_toolbar_new_separator_image (void);
G_END_DECLS
-
#endif
diff --git a/src/toolbareditor/egg-toolbar-editor.c b/src/toolbareditor/egg-toolbar-editor.c
index 1c375e5..4184703 100644
--- a/src/toolbareditor/egg-toolbar-editor.c
+++ b/src/toolbareditor/egg-toolbar-editor.c
@@ -37,8 +37,8 @@ static const GtkTargetEntry source_drag_types[] = {
};
-static void egg_toolbar_editor_finalize (GObject *object);
-static void update_editor_sheet (EggToolbarEditor *editor);
+static void egg_toolbar_editor_finalize (GObject * object);
+static void update_editor_sheet (EggToolbarEditor * editor);
enum
{
@@ -52,7 +52,7 @@ enum
SIGNAL_HANDLER_ITEM_ADDED,
SIGNAL_HANDLER_ITEM_REMOVED,
SIGNAL_HANDLER_TOOLBAR_REMOVED,
- SIGNAL_HANDLER_LIST_SIZE /* Array size */
+ SIGNAL_HANDLER_LIST_SIZE /* Array size */
};
#define EGG_TOOLBAR_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditorPrivate))
@@ -64,33 +64,31 @@ struct EggToolbarEditorPrivate
GtkWidget *table;
GtkWidget *scrolled_window;
- GList *actions_list;
- GList *factory_list;
+ GList *actions_list;
+ GList *factory_list;
/* These handlers need to be sanely disconnected when switching models */
- gulong sig_handlers[SIGNAL_HANDLER_LIST_SIZE];
+ gulong sig_handlers[SIGNAL_HANDLER_LIST_SIZE];
};
G_DEFINE_TYPE (EggToolbarEditor, egg_toolbar_editor, GTK_TYPE_VBOX);
static gint
-compare_items (gconstpointer a,
- gconstpointer b)
+compare_items (gconstpointer a, gconstpointer b)
{
const GtkWidget *item1 = a;
const GtkWidget *item2 = b;
char *key1 = g_object_get_data (G_OBJECT (item1),
- "egg-collate-key");
+ "egg-collate-key");
char *key2 = g_object_get_data (G_OBJECT (item2),
- "egg-collate-key");
+ "egg-collate-key");
return strcmp (key1, key2);
}
static GtkAction *
-find_action (EggToolbarEditor *t,
- const char *name)
+find_action (EggToolbarEditor * t, const char *name)
{
GList *l;
GtkAction *action = NULL;
@@ -113,8 +111,8 @@ find_action (EggToolbarEditor *t,
}
static void
-egg_toolbar_editor_set_ui_manager (EggToolbarEditor *t,
- GtkUIManager *manager)
+egg_toolbar_editor_set_ui_manager (EggToolbarEditor * t,
+ GtkUIManager * manager)
{
g_return_if_fail (GTK_IS_UI_MANAGER (manager));
@@ -122,24 +120,21 @@ egg_toolbar_editor_set_ui_manager (EggToolbarEditor *t,
}
static void
-item_added_or_removed_cb (EggToolbarsModel *model,
- int tpos,
- int ipos,
- EggToolbarEditor *editor)
+item_added_or_removed_cb (EggToolbarsModel * model,
+ int tpos, int ipos, EggToolbarEditor * editor)
{
update_editor_sheet (editor);
}
static void
-toolbar_removed_cb (EggToolbarsModel *model,
- int position,
- EggToolbarEditor *editor)
+toolbar_removed_cb (EggToolbarsModel * model,
+ int position, EggToolbarEditor * editor)
{
update_editor_sheet (editor);
}
static void
-egg_toolbar_editor_disconnect_model (EggToolbarEditor *t)
+egg_toolbar_editor_disconnect_model (EggToolbarEditor * t)
{
EggToolbarEditorPrivate *priv = t->priv;
EggToolbarsModel *model = priv->model;
@@ -151,20 +146,19 @@ egg_toolbar_editor_disconnect_model (EggToolbarEditor *t)
handler = priv->sig_handlers[i];
if (handler != 0)
- {
+ {
if (g_signal_handler_is_connected (model, handler))
{
g_signal_handler_disconnect (model, handler);
}
priv->sig_handlers[i] = 0;
- }
+ }
}
}
void
-egg_toolbar_editor_set_model (EggToolbarEditor *t,
- EggToolbarsModel *model)
+egg_toolbar_editor_set_model (EggToolbarEditor * t, EggToolbarsModel * model)
{
EggToolbarEditorPrivate *priv;
@@ -175,7 +169,8 @@ egg_toolbar_editor_set_model (EggToolbarEditor *t,
if (priv->model)
{
- if (G_UNLIKELY (priv->model == model)) return;
+ if (G_UNLIKELY (priv->model == model))
+ return;
egg_toolbar_editor_disconnect_model (t);
g_object_unref (priv->model);
@@ -197,10 +192,9 @@ egg_toolbar_editor_set_model (EggToolbarEditor *t,
}
static void
-egg_toolbar_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+egg_toolbar_editor_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
@@ -216,10 +210,9 @@ egg_toolbar_editor_set_property (GObject *object,
}
static void
-egg_toolbar_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+egg_toolbar_editor_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
@@ -235,7 +228,7 @@ egg_toolbar_editor_get_property (GObject *object,
}
static void
-egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
+egg_toolbar_editor_class_init (EggToolbarEditorClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -249,22 +242,26 @@ egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
"UI-Manager",
"UI Manager",
GTK_TYPE_UI_MANAGER,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB |
G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_TOOLBARS_MODEL,
- g_param_spec_object ("model",
- "Model",
- "Toolbars Model",
- EGG_TYPE_TOOLBARS_MODEL,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
- G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_TOOLBARS_MODEL,
+ g_param_spec_object ("model", "Model",
+ "Toolbars Model",
+ EGG_TYPE_TOOLBARS_MODEL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB |
+ G_PARAM_CONSTRUCT));
g_type_class_add_private (object_class, sizeof (EggToolbarEditorPrivate));
}
static void
-egg_toolbar_editor_finalize (GObject *object)
+egg_toolbar_editor_finalize (GObject * object)
{
EggToolbarEditor *editor = EGG_TOOLBAR_EDITOR (object);
@@ -286,36 +283,30 @@ egg_toolbar_editor_finalize (GObject *object)
}
GtkWidget *
-egg_toolbar_editor_new (GtkUIManager *manager,
- EggToolbarsModel *model)
+egg_toolbar_editor_new (GtkUIManager * manager, EggToolbarsModel * model)
{
return GTK_WIDGET (g_object_new (EGG_TYPE_TOOLBAR_EDITOR,
"ui-manager", manager,
- "model", model,
- NULL));
+ "model", model, NULL));
}
static void
-drag_begin_cb (GtkWidget *widget,
- GdkDragContext *context)
+drag_begin_cb (GtkWidget * widget, GdkDragContext * context)
{
gtk_widget_hide (widget);
}
static void
-drag_end_cb (GtkWidget *widget,
- GdkDragContext *context)
+drag_end_cb (GtkWidget * widget, GdkDragContext * context)
{
gtk_widget_show (widget);
}
static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EggToolbarEditor *editor)
+drag_data_get_cb (GtkWidget * widget,
+ GdkDragContext * context,
+ GtkSelectionData * selection_data,
+ guint info, guint32 time, EggToolbarEditor * editor)
{
const char *target;
@@ -327,7 +318,7 @@ drag_data_get_cb (GtkWidget *widget,
}
static gchar *
-elide_underscores (const gchar *original)
+elide_underscores (const gchar * original)
{
gchar *q, *result;
const gchar *p;
@@ -353,7 +344,7 @@ elide_underscores (const gchar *original)
}
static void
-set_drag_cursor (GtkWidget *widget)
+set_drag_cursor (GtkWidget * widget)
{
GdkCursor *cursor;
GdkScreen *screen;
@@ -367,7 +358,7 @@ set_drag_cursor (GtkWidget *widget)
}
static void
-event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
+event_box_realize_cb (GtkWidget * widget, GtkImage * icon)
{
GtkImageType type;
@@ -381,7 +372,7 @@ event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
gtk_image_get_stock (icon, &stock_id, NULL);
pixbuf = gtk_widget_render_icon (widget, stock_id,
- GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
+ GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
g_object_unref (pixbuf);
}
@@ -400,16 +391,16 @@ event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
settings = gtk_settings_get_for_screen (screen);
if (!gtk_icon_size_lookup_for_settings (settings,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
&width, &height))
- {
+ {
width = height = 24;
}
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
- MIN (width, height), 0, NULL);
+ MIN (width, height), 0, NULL);
if (G_UNLIKELY (!pixbuf))
- return;
+ return;
gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
g_object_unref (pixbuf);
@@ -423,10 +414,9 @@ event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
}
static GtkWidget *
-editor_create_item (EggToolbarEditor *editor,
- GtkImage *icon,
- const char *label_text,
- GdkDragAction action)
+editor_create_item (EggToolbarEditor * editor,
+ GtkImage * icon,
+ const char *label_text, GdkDragAction action)
{
GtkWidget *event_box;
GtkWidget *vbox;
@@ -438,18 +428,19 @@ editor_create_item (EggToolbarEditor *editor,
gtk_widget_show (event_box);
gtk_drag_source_set (event_box,
GDK_BUTTON1_MASK,
- source_drag_types, G_N_ELEMENTS (source_drag_types), action);
- g_signal_connect (event_box, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), editor);
+ source_drag_types, G_N_ELEMENTS (source_drag_types),
+ action);
+ g_signal_connect (event_box, "drag_data_get", G_CALLBACK (drag_data_get_cb),
+ editor);
g_signal_connect_after (event_box, "realize",
- G_CALLBACK (event_box_realize_cb), icon);
+ G_CALLBACK (event_box_realize_cb), icon);
if (action == GDK_ACTION_MOVE)
{
g_signal_connect (event_box, "drag_begin",
- G_CALLBACK (drag_begin_cb), NULL);
+ G_CALLBACK (drag_begin_cb), NULL);
g_signal_connect (event_box, "drag_end",
- G_CALLBACK (drag_end_cb), NULL);
+ G_CALLBACK (drag_end_cb), NULL);
}
vbox = gtk_vbox_new (0, FALSE);
@@ -468,9 +459,8 @@ editor_create_item (EggToolbarEditor *editor,
}
static GtkWidget *
-editor_create_item_from_name (EggToolbarEditor *editor,
- const char * name,
- GdkDragAction drag_action)
+editor_create_item_from_name (EggToolbarEditor * editor,
+ const char *name, GdkDragAction drag_action)
{
GtkWidget *item;
const char *item_name;
@@ -486,7 +476,7 @@ editor_create_item_from_name (EggToolbarEditor *editor,
item_name = g_strdup (name);
collate_key = g_utf8_collate_key (short_label, -1);
item = editor_create_item (editor, GTK_IMAGE (icon),
- short_label, drag_action);
+ short_label, drag_action);
}
else
{
@@ -498,23 +488,21 @@ editor_create_item_from_name (EggToolbarEditor *editor,
g_return_val_if_fail (action != NULL, NULL);
g_object_get (action,
- "icon-name", &icon_name,
- "stock-id", &stock_id,
- "short-label", &short_label,
- NULL);
+ "icon-name", &icon_name,
+ "stock-id", &stock_id, "short-label", &short_label, NULL);
/* This is a workaround to catch named icons. */
if (icon_name)
- icon = gtk_image_new_from_icon_name (icon_name,
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ icon = gtk_image_new_from_icon_name (icon_name,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
else
- icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
item_name = g_strdup (name);
collate_key = g_utf8_collate_key (short_label, -1);
item = editor_create_item (editor, GTK_IMAGE (icon),
- short_label, drag_action);
+ short_label, drag_action);
g_free (short_label);
g_free (stock_id);
@@ -522,15 +510,15 @@ editor_create_item_from_name (EggToolbarEditor *editor,
}
g_object_set_data_full (G_OBJECT (item), "egg-collate-key",
- (gpointer) collate_key, g_free);
+ (gpointer) collate_key, g_free);
g_object_set_data_full (G_OBJECT (item), "egg-item-name",
- (gpointer) item_name, g_free);
+ (gpointer) item_name, g_free);
return item;
}
static gint
-append_table (GtkTable *table, GList *items, gint y, gint width)
+append_table (GtkTable * table, GList * items, gint y, gint width)
{
if (items != NULL)
{
@@ -542,32 +530,33 @@ append_table (GtkTable *table, GList *items, gint y, gint width)
gtk_table_resize (table, height, width);
if (y > 0)
- {
- item = gtk_hseparator_new ();
- alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), item);
- gtk_widget_show (alignment);
- gtk_widget_show (item);
-
- gtk_table_attach_defaults (table, alignment, 0, width, y-1, y+1);
- }
+ {
+ item = gtk_hseparator_new ();
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), item);
+ gtk_widget_show (alignment);
+ gtk_widget_show (item);
+
+ gtk_table_attach_defaults (table, alignment, 0, width, y - 1,
+ y + 1);
+ }
for (; items != NULL; items = items->next)
- {
- item = items->data;
- alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), item);
- gtk_widget_show (alignment);
- gtk_widget_show (item);
-
- if (x >= width)
- {
- x = 0;
- y++;
- }
- gtk_table_attach_defaults (table, alignment, x, x+1, y, y+1);
- x++;
- }
+ {
+ item = items->data;
+ alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), item);
+ gtk_widget_show (alignment);
+ gtk_widget_show (item);
+
+ if (x >= width)
+ {
+ x = 0;
+ y++;
+ }
+ gtk_table_attach_defaults (table, alignment, x, x + 1, y, y + 1);
+ x++;
+ }
y++;
}
@@ -575,7 +564,7 @@ append_table (GtkTable *table, GList *items, gint y, gint width)
}
static void
-update_editor_sheet (EggToolbarEditor *editor)
+update_editor_sheet (EggToolbarEditor * editor)
{
gint y;
GPtrArray *items;
@@ -593,7 +582,7 @@ update_editor_sheet (EggToolbarEditor *editor)
gtk_widget_show (table);
gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL,
dest_drag_types, G_N_ELEMENTS (dest_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
/* Build two lists of items (one for copying, one for moving). */
items = egg_toolbars_model_get_name_avail (editor->priv->model);
@@ -608,17 +597,17 @@ update_editor_sheet (EggToolbarEditor *editor)
flags = egg_toolbars_model_get_name_flags (editor->priv->model, name);
if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
- {
- item = editor_create_item_from_name (editor, name, GDK_ACTION_MOVE);
- if (item != NULL)
- to_move = g_list_insert_sorted (to_move, item, compare_items);
- }
+ {
+ item = editor_create_item_from_name (editor, name, GDK_ACTION_MOVE);
+ if (item != NULL)
+ to_move = g_list_insert_sorted (to_move, item, compare_items);
+ }
else
- {
- item = editor_create_item_from_name (editor, name, GDK_ACTION_COPY);
- if (item != NULL)
- to_copy = g_list_insert_sorted (to_copy, item, compare_items);
- }
+ {
+ item = editor_create_item_from_name (editor, name, GDK_ACTION_COPY);
+ if (item != NULL)
+ to_copy = g_list_insert_sorted (to_copy, item, compare_items);
+ }
}
/* Add them to the sheet. */
@@ -635,7 +624,7 @@ update_editor_sheet (EggToolbarEditor *editor)
if (viewport)
{
gtk_container_remove (GTK_CONTAINER (viewport),
- GTK_BIN (viewport)->child);
+ GTK_BIN (viewport)->child);
}
/* Add table to window. */
@@ -645,7 +634,7 @@ update_editor_sheet (EggToolbarEditor *editor)
}
static void
-setup_editor (EggToolbarEditor *editor)
+setup_editor (EggToolbarEditor * editor)
{
GtkWidget *scrolled_window;
@@ -659,7 +648,7 @@ setup_editor (EggToolbarEditor *editor)
}
static void
-egg_toolbar_editor_init (EggToolbarEditor *t)
+egg_toolbar_editor_init (EggToolbarEditor * t)
{
t->priv = EGG_TOOLBAR_EDITOR_GET_PRIVATE (t);
@@ -668,4 +657,3 @@ egg_toolbar_editor_init (EggToolbarEditor *t)
setup_editor (t);
}
-
diff --git a/src/toolbareditor/egg-toolbar-editor.h b/src/toolbareditor/egg-toolbar-editor.h
index ba6e1a9..1784f4c 100644
--- a/src/toolbareditor/egg-toolbar-editor.h
+++ b/src/toolbareditor/egg-toolbar-editor.h
@@ -23,9 +23,7 @@
#include "egg-toolbars-model.h"
-G_BEGIN_DECLS
-
-typedef struct EggToolbarEditorClass EggToolbarEditorClass;
+G_BEGIN_DECLS typedef struct EggToolbarEditorClass EggToolbarEditorClass;
#define EGG_TYPE_TOOLBAR_EDITOR (egg_toolbar_editor_get_type ())
#define EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditor))
@@ -42,7 +40,7 @@ struct EggToolbarEditor
{
GtkVBox parent_object;
- /*< private >*/
+ /*< private > */
EggToolbarEditorPrivate *priv;
};
@@ -52,12 +50,11 @@ struct EggToolbarEditorClass
};
-GType egg_toolbar_editor_get_type (void);
-GtkWidget *egg_toolbar_editor_new (GtkUIManager *manager,
- EggToolbarsModel *model);
-void egg_toolbar_editor_set_model (EggToolbarEditor *t,
- EggToolbarsModel *model);
+GType egg_toolbar_editor_get_type (void);
+GtkWidget *egg_toolbar_editor_new (GtkUIManager * manager,
+ EggToolbarsModel * model);
+void egg_toolbar_editor_set_model (EggToolbarEditor * t,
+ EggToolbarsModel * model);
G_END_DECLS
-
#endif
diff --git a/src/toolbareditor/egg-toolbars-model.c b/src/toolbareditor/egg-toolbars-model.c
index c2e8c17..6c10a6a 100644
--- a/src/toolbareditor/egg-toolbars-model.c
+++ b/src/toolbareditor/egg-toolbars-model.c
@@ -30,7 +30,7 @@
#include <libxml/tree.h>
#include <gdk/gdk.h>
-static void egg_toolbars_model_finalize (GObject *object);
+static void egg_toolbars_model_finalize (GObject * object);
enum
{
@@ -65,9 +65,7 @@ struct EggToolbarsModelPrivate
};
G_DEFINE_TYPE (EggToolbarsModel, egg_toolbars_model, G_TYPE_OBJECT)
-
-static xmlDocPtr
-egg_toolbars_model_to_xml (EggToolbarsModel *model)
+ static xmlDocPtr egg_toolbars_model_to_xml (EggToolbarsModel * model)
{
GNode *l1, *l2, *tl;
GList *l3;
@@ -78,56 +76,70 @@ egg_toolbars_model_to_xml (EggToolbarsModel *model)
tl = model->priv->toolbars;
xmlIndentTreeOutput = TRUE;
- doc = xmlNewDoc ((const xmlChar*) "1.0");
- doc->children = xmlNewDocNode (doc, NULL, (const xmlChar*) "toolbars", NULL);
+ doc = xmlNewDoc ((const xmlChar *) "1.0");
+ doc->children =
+ xmlNewDocNode (doc, NULL, (const xmlChar *) "toolbars", NULL);
for (l1 = tl->children; l1 != NULL; l1 = l1->next)
{
xmlNodePtr tnode;
EggToolbarsToolbar *toolbar = l1->data;
- tnode = xmlNewChild (doc->children, NULL, (const xmlChar*) "toolbar", NULL);
- xmlSetProp (tnode, (const xmlChar*) "name", (const xmlChar*) toolbar->name);
- xmlSetProp (tnode, (const xmlChar*) "hidden",
- (toolbar->flags&EGG_TB_MODEL_HIDDEN) ? (const xmlChar*) "true" : (const xmlChar*) "false");
- xmlSetProp (tnode, (const xmlChar*) "editable",
- (toolbar->flags&EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar*) "false" : (const xmlChar*) "true");
+ tnode =
+ xmlNewChild (doc->children, NULL, (const xmlChar *) "toolbar", NULL);
+ xmlSetProp (tnode, (const xmlChar *) "name",
+ (const xmlChar *) toolbar->name);
+ xmlSetProp (tnode, (const xmlChar *) "hidden",
+ (toolbar->
+ flags & EGG_TB_MODEL_HIDDEN) ? (const xmlChar *) "true"
+ : (const xmlChar *) "false");
+ xmlSetProp (tnode, (const xmlChar *) "editable",
+ (toolbar->
+ flags & EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar *)
+ "false" : (const xmlChar *) "true");
for (l2 = l1->children; l2 != NULL; l2 = l2->next)
{
xmlNodePtr node;
EggToolbarsItem *item = l2->data;
- if (strcmp (item->name, "_separator") == 0)
- {
- node = xmlNewChild (tnode, NULL, (const xmlChar*) "separator", NULL);
- continue;
- }
-
- node = xmlNewChild (tnode, NULL, (const xmlChar*) "toolitem", NULL);
- xmlSetProp (node, (const xmlChar*) "name", (const xmlChar*) item->name);
-
- /* Add 'data' nodes for each data type which can be written out for this
- * item. Only write types which can be used to restore the data. */
- for (l3 = model->priv->types; l3 != NULL; l3 = l3->next)
- {
- EggToolbarsItemType *type = l3->data;
- if (type->get_name != NULL && type->get_data != NULL)
- {
- xmlNodePtr dnode;
- char *tmp;
-
- tmp = type->get_data (type, item->name);
- if (tmp != NULL)
- {
- dnode = xmlNewTextChild (node, NULL, (const xmlChar*) "data", (const xmlChar*) tmp);
- g_free (tmp);
-
- tmp = gdk_atom_name (type->type);
- xmlSetProp (dnode, (const xmlChar*) "type", (const xmlChar*) tmp);
- g_free (tmp);
- }
- }
+ if (strcmp (item->name, "_separator") == 0)
+ {
+ node =
+ xmlNewChild (tnode, NULL, (const xmlChar *) "separator",
+ NULL);
+ continue;
+ }
+
+ node =
+ xmlNewChild (tnode, NULL, (const xmlChar *) "toolitem", NULL);
+ xmlSetProp (node, (const xmlChar *) "name",
+ (const xmlChar *) item->name);
+
+ /* Add 'data' nodes for each data type which can be written out for this
+ * item. Only write types which can be used to restore the data. */
+ for (l3 = model->priv->types; l3 != NULL; l3 = l3->next)
+ {
+ EggToolbarsItemType *type = l3->data;
+ if (type->get_name != NULL && type->get_data != NULL)
+ {
+ xmlNodePtr dnode;
+ char *tmp;
+
+ tmp = type->get_data (type, item->name);
+ if (tmp != NULL)
+ {
+ dnode =
+ xmlNewTextChild (node, NULL, (const xmlChar *) "data",
+ (const xmlChar *) tmp);
+ g_free (tmp);
+
+ tmp = gdk_atom_name (type->type);
+ xmlSetProp (dnode, (const xmlChar *) "type",
+ (const xmlChar *) tmp);
+ g_free (tmp);
+ }
+ }
}
}
}
@@ -138,63 +150,62 @@ egg_toolbars_model_to_xml (EggToolbarsModel *model)
static gboolean
safe_save_xml (const char *xml_file, xmlDocPtr doc)
{
- char *tmp_file;
- char *old_file;
- gboolean old_exist;
- gboolean retval = TRUE;
+ char *tmp_file;
+ char *old_file;
+ gboolean old_exist;
+ gboolean retval = TRUE;
- tmp_file = g_strconcat (xml_file, ".tmp", NULL);
- old_file = g_strconcat (xml_file, ".old", NULL);
+ tmp_file = g_strconcat (xml_file, ".tmp", NULL);
+ old_file = g_strconcat (xml_file, ".old", NULL);
- if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
- {
- g_warning ("Failed to write XML data to %s", tmp_file);
- goto failed;
- }
+ if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
+ {
+ g_warning ("Failed to write XML data to %s", tmp_file);
+ goto failed;
+ }
- old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
+ old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
- if (old_exist)
+ if (old_exist)
+ {
+ if (rename (xml_file, old_file) < 0)
{
- if (rename (xml_file, old_file) < 0)
- {
- g_warning ("Failed to rename %s to %s", xml_file, old_file);
- retval = FALSE;
- goto failed;
- }
+ g_warning ("Failed to rename %s to %s", xml_file, old_file);
+ retval = FALSE;
+ goto failed;
}
+ }
- if (rename (tmp_file, xml_file) < 0)
- {
- g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
+ if (rename (tmp_file, xml_file) < 0)
+ {
+ g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
- if (rename (old_file, xml_file) < 0)
- {
- g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
- }
- retval = FALSE;
- goto failed;
+ if (rename (old_file, xml_file) < 0)
+ {
+ g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
}
+ retval = FALSE;
+ goto failed;
+ }
- if (old_exist)
+ if (old_exist)
+ {
+ if (unlink (old_file) < 0)
{
- if (unlink (old_file) < 0)
- {
- g_warning ("Failed to delete old file %s", old_file);
- }
+ g_warning ("Failed to delete old file %s", old_file);
}
+ }
- failed:
- g_free (old_file);
- g_free (tmp_file);
+failed:
+ g_free (old_file);
+ g_free (tmp_file);
- return retval;
+ return retval;
}
void
-egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
- const char *xml_file,
- const char *version)
+egg_toolbars_model_save_toolbars (EggToolbarsModel * model,
+ const char *xml_file, const char *version)
{
xmlDocPtr doc;
xmlNodePtr root;
@@ -203,25 +214,24 @@ egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
doc = egg_toolbars_model_to_xml (model);
root = xmlDocGetRootElement (doc);
- xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) version);
+ xmlSetProp (root, (const xmlChar *) "version", (const xmlChar *) version);
safe_save_xml (xml_file, doc);
xmlFreeDoc (doc);
}
static gboolean
-is_unique (EggToolbarsModel *model,
- EggToolbarsItem *idata)
+is_unique (EggToolbarsModel * model, EggToolbarsItem * idata)
{
EggToolbarsItem *idata2;
GNode *toolbar, *item;
- for(toolbar = g_node_first_child (model->priv->toolbars);
- toolbar != NULL; toolbar = g_node_next_sibling (toolbar))
+ for (toolbar = g_node_first_child (model->priv->toolbars);
+ toolbar != NULL; toolbar = g_node_next_sibling (toolbar))
{
- for(item = g_node_first_child (toolbar);
- item != NULL; item = g_node_next_sibling (item))
- {
+ for (item = g_node_first_child (toolbar);
+ item != NULL; item = g_node_next_sibling (item))
+ {
idata2 = item->data;
if (idata != idata2 && strcmp (idata->name, idata2->name) == 0)
@@ -247,7 +257,7 @@ toolbar_node_new (const char *name)
}
static GNode *
-item_node_new (const char *name, EggToolbarsModel *model)
+item_node_new (const char *name, EggToolbarsModel * model)
{
EggToolbarsItem *item;
int flags;
@@ -257,7 +267,8 @@ item_node_new (const char *name, EggToolbarsModel *model)
item = g_new (EggToolbarsItem, 1);
item->name = g_strdup (name);
- flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
+ flags =
+ GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
g_hash_table_insert (model->priv->flags,
g_strdup (item->name),
@@ -267,12 +278,13 @@ item_node_new (const char *name, EggToolbarsModel *model)
}
static void
-item_node_free (GNode *item_node, EggToolbarsModel *model)
+item_node_free (GNode * item_node, EggToolbarsModel * model)
{
EggToolbarsItem *item = item_node->data;
int flags;
- flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
+ flags =
+ GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0 && is_unique (model, item))
g_hash_table_insert (model->priv->flags,
g_strdup (item->name),
@@ -285,12 +297,12 @@ item_node_free (GNode *item_node, EggToolbarsModel *model)
}
static void
-toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
+toolbar_node_free (GNode * toolbar_node, EggToolbarsModel * model)
{
EggToolbarsToolbar *toolbar = toolbar_node->data;
g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
- (GNodeForeachFunc) item_node_free, model);
+ (GNodeForeachFunc) item_node_free, model);
g_free (toolbar->name);
g_free (toolbar);
@@ -299,8 +311,7 @@ toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
}
EggTbModelFlags
-egg_toolbars_model_get_flags (EggToolbarsModel *model,
- int toolbar_position)
+egg_toolbars_model_get_flags (EggToolbarsModel * model, int toolbar_position)
{
GNode *toolbar_node;
EggToolbarsToolbar *toolbar;
@@ -314,9 +325,8 @@ egg_toolbars_model_get_flags (EggToolbarsModel *model,
}
void
-egg_toolbars_model_set_flags (EggToolbarsModel *model,
- int toolbar_position,
- EggTbModelFlags flags)
+egg_toolbars_model_set_flags (EggToolbarsModel * model,
+ int toolbar_position, EggTbModelFlags flags)
{
GNode *toolbar_node;
EggToolbarsToolbar *toolbar;
@@ -334,18 +344,18 @@ egg_toolbars_model_set_flags (EggToolbarsModel *model,
char *
-egg_toolbars_model_get_data (EggToolbarsModel *model,
- GdkAtom type,
- const char *name)
+egg_toolbars_model_get_data (EggToolbarsModel * model,
+ GdkAtom type, const char *name)
{
EggToolbarsItemType *t;
char *data = NULL;
GList *l;
- if (type == GDK_NONE || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
+ if (type == GDK_NONE
+ || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
{
g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (*name != 0, NULL);
+ g_return_val_if_fail (*name != 0, NULL);
return strdup (name);
}
@@ -353,26 +363,26 @@ egg_toolbars_model_get_data (EggToolbarsModel *model,
{
t = l->data;
if (t->type == type && t->get_data != NULL)
- {
- data = t->get_data (t, name);
- if (data != NULL) break;
- }
+ {
+ data = t->get_data (t, name);
+ if (data != NULL)
+ break;
+ }
}
return data;
}
char *
-egg_toolbars_model_get_name (EggToolbarsModel *model,
- GdkAtom type,
- const char *data,
- gboolean create)
+egg_toolbars_model_get_name (EggToolbarsModel * model,
+ GdkAtom type, const char *data, gboolean create)
{
EggToolbarsItemType *t;
char *name = NULL;
GList *l;
- if (type == GDK_NONE || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
+ if (type == GDK_NONE
+ || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
{
g_return_val_if_fail (data, NULL);
g_return_val_if_fail (*data, NULL);
@@ -382,32 +392,30 @@ egg_toolbars_model_get_name (EggToolbarsModel *model,
if (create)
{
for (l = model->priv->types; name == NULL && l != NULL; l = l->next)
- {
- t = l->data;
- if (t->type == type && t->new_name != NULL)
- name = t->new_name (t, data);
- }
+ {
+ t = l->data;
+ if (t->type == type && t->new_name != NULL)
+ name = t->new_name (t, data);
+ }
return name;
}
else
{
for (l = model->priv->types; name == NULL && l != NULL; l = l->next)
- {
- t = l->data;
- if (t->type == type && t->get_name != NULL)
- name = t->get_name (t, data);
- }
+ {
+ t = l->data;
+ if (t->type == type && t->get_name != NULL)
+ name = t->get_name (t, data);
+ }
return name;
}
}
static gboolean
-impl_add_item (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- const char *name)
+impl_add_item (EggToolbarsModel * model,
+ int toolbar_position, int position, const char *name)
{
GNode *parent_node;
GNode *child_node;
@@ -429,19 +437,17 @@ impl_add_item (EggToolbarsModel *model,
}
gboolean
-egg_toolbars_model_add_item (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- const char *name)
+egg_toolbars_model_add_item (EggToolbarsModel * model,
+ int toolbar_position,
+ int position, const char *name)
{
EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (model);
return klass->add_item (model, toolbar_position, position, name);
}
int
-egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
- int position,
- const char *name)
+egg_toolbars_model_add_toolbar (EggToolbarsModel * model,
+ int position, const char *name)
{
GNode *node;
int real_position;
@@ -453,34 +459,33 @@ egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
real_position = g_node_child_position (model->priv->toolbars, node);
- g_signal_emit (G_OBJECT (model), signals[TOOLBAR_ADDED],
- 0, real_position);
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_ADDED], 0, real_position);
return g_node_child_position (model->priv->toolbars, node);
}
static char *
-parse_data_list (EggToolbarsModel *model,
- xmlNodePtr child,
- gboolean create)
+parse_data_list (EggToolbarsModel * model, xmlNodePtr child, gboolean create)
{
char *name = NULL;
while (child && name == NULL)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "data"))
- {
- xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
- xmlChar *data = xmlNodeGetContent (child);
+ if (xmlStrEqual (child->name, (const xmlChar *) "data"))
+ {
+ xmlChar *type = xmlGetProp (child, (const xmlChar *) "type");
+ xmlChar *data = xmlNodeGetContent (child);
- if (type != NULL)
- {
- GdkAtom atom = gdk_atom_intern ((const char*) type, TRUE);
- name = egg_toolbars_model_get_name (model, atom, (const char*) data, create);
- }
+ if (type != NULL)
+ {
+ GdkAtom atom = gdk_atom_intern ((const char *) type, TRUE);
+ name =
+ egg_toolbars_model_get_name (model, atom, (const char *) data,
+ create);
+ }
- xmlFree (type);
- xmlFree (data);
- }
+ xmlFree (type);
+ xmlFree (data);
+ }
child = child->next;
}
@@ -489,51 +494,54 @@ parse_data_list (EggToolbarsModel *model,
}
static void
-parse_item_list (EggToolbarsModel *model,
- xmlNodePtr child,
- int position)
+parse_item_list (EggToolbarsModel * model, xmlNodePtr child, int position)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
+ if (xmlStrEqual (child->name, (const xmlChar *) "toolitem"))
{
- char *name;
-
- /* Try to get the name using the data elements first,
- as they are more 'portable' or 'persistent'. */
- name = parse_data_list (model, child->children, FALSE);
- if (name == NULL)
- {
- name = parse_data_list (model, child->children, TRUE);
- }
-
- /* If that fails, try to use the name. */
- if (name == NULL)
- {
- xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
- xmlChar *data = xmlGetProp (child, (const xmlChar*) "name");
- GdkAtom atom = type ? gdk_atom_intern ((const char*) type, TRUE) : GDK_NONE;
-
- /* If an old format, try to use it. */
- name = egg_toolbars_model_get_name (model, atom, (const char*) data, FALSE);
- if (name == NULL)
- {
- name = egg_toolbars_model_get_name (model, atom, (const char*) data, TRUE);
- }
-
- xmlFree (type);
- xmlFree (data);
- }
-
- if (name != NULL)
- {
- egg_toolbars_model_add_item (model, position, -1, name);
- g_free (name);
- }
+ char *name;
+
+ /* Try to get the name using the data elements first,
+ as they are more 'portable' or 'persistent'. */
+ name = parse_data_list (model, child->children, FALSE);
+ if (name == NULL)
+ {
+ name = parse_data_list (model, child->children, TRUE);
+ }
+
+ /* If that fails, try to use the name. */
+ if (name == NULL)
+ {
+ xmlChar *type = xmlGetProp (child, (const xmlChar *) "type");
+ xmlChar *data = xmlGetProp (child, (const xmlChar *) "name");
+ GdkAtom atom =
+ type ? gdk_atom_intern ((const char *) type, TRUE) : GDK_NONE;
+
+ /* If an old format, try to use it. */
+ name =
+ egg_toolbars_model_get_name (model, atom, (const char *) data,
+ FALSE);
+ if (name == NULL)
+ {
+ name =
+ egg_toolbars_model_get_name (model, atom,
+ (const char *) data, TRUE);
+ }
+
+ xmlFree (type);
+ xmlFree (data);
+ }
+
+ if (name != NULL)
+ {
+ egg_toolbars_model_add_item (model, position, -1, name);
+ g_free (name);
+ }
}
- else if (xmlStrEqual (child->name, (const xmlChar*) "separator"))
+ else if (xmlStrEqual (child->name, (const xmlChar *) "separator"))
{
- egg_toolbars_model_add_item (model, position, -1, "_separator");
+ egg_toolbars_model_add_item (model, position, -1, "_separator");
}
child = child->next;
@@ -541,38 +549,38 @@ parse_item_list (EggToolbarsModel *model,
}
static void
-parse_toolbars (EggToolbarsModel *model,
- xmlNodePtr child)
+parse_toolbars (EggToolbarsModel * model, xmlNodePtr child)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "toolbar"))
+ if (xmlStrEqual (child->name, (const xmlChar *) "toolbar"))
{
xmlChar *string;
int position;
- EggTbModelFlags flags;
+ EggTbModelFlags flags;
- string = xmlGetProp (child, (const xmlChar*) "name");
- position = egg_toolbars_model_add_toolbar (model, -1, (const char*) string);
- flags = egg_toolbars_model_get_flags (model, position);
+ string = xmlGetProp (child, (const xmlChar *) "name");
+ position =
+ egg_toolbars_model_add_toolbar (model, -1, (const char *) string);
+ flags = egg_toolbars_model_get_flags (model, position);
xmlFree (string);
- string = xmlGetProp (child, (const xmlChar*) "editable");
- if (string && xmlStrEqual (string, (const xmlChar*) "false"))
- flags |= EGG_TB_MODEL_NOT_EDITABLE;
+ string = xmlGetProp (child, (const xmlChar *) "editable");
+ if (string && xmlStrEqual (string, (const xmlChar *) "false"))
+ flags |= EGG_TB_MODEL_NOT_EDITABLE;
xmlFree (string);
- string = xmlGetProp (child, (const xmlChar*) "hidden");
- if (string && xmlStrEqual (string, (const xmlChar*) "true"))
- flags |= EGG_TB_MODEL_HIDDEN;
+ string = xmlGetProp (child, (const xmlChar *) "hidden");
+ if (string && xmlStrEqual (string, (const xmlChar *) "true"))
+ flags |= EGG_TB_MODEL_HIDDEN;
xmlFree (string);
- string = xmlGetProp (child, (const xmlChar*) "style");
- if (string && xmlStrEqual (string, (const xmlChar*) "icons-only"))
- flags |= EGG_TB_MODEL_ICONS;
+ string = xmlGetProp (child, (const xmlChar *) "style");
+ if (string && xmlStrEqual (string, (const xmlChar *) "icons-only"))
+ flags |= EGG_TB_MODEL_ICONS;
xmlFree (string);
- egg_toolbars_model_set_flags (model, position, flags);
+ egg_toolbars_model_set_flags (model, position, flags);
parse_item_list (model, child->children, position);
}
@@ -582,7 +590,7 @@ parse_toolbars (EggToolbarsModel *model,
}
gboolean
-egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
+egg_toolbars_model_load_toolbars (EggToolbarsModel * model,
const char *xml_file)
{
xmlDocPtr doc;
@@ -590,14 +598,15 @@ egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
- if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
+ if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS))
+ return FALSE;
doc = xmlParseFile (xml_file);
if (doc == NULL)
- {
- g_warning ("Failed to load XML data from %s", xml_file);
- return FALSE;
- }
+ {
+ g_warning ("Failed to load XML data from %s", xml_file);
+ return FALSE;
+ }
root = xmlDocGetRootElement (doc);
parse_toolbars (model, root->children);
@@ -608,22 +617,21 @@ egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
}
static void
-parse_available_list (EggToolbarsModel *model,
- xmlNodePtr child)
+parse_available_list (EggToolbarsModel * model, xmlNodePtr child)
{
gint flags;
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
+ if (xmlStrEqual (child->name, (const xmlChar *) "toolitem"))
{
xmlChar *name;
- name = xmlGetProp (child, (const xmlChar*) "name");
+ name = xmlGetProp (child, (const xmlChar *) "name");
flags = egg_toolbars_model_get_name_flags
- (model, (const char*)name);
+ (model, (const char *) name);
egg_toolbars_model_set_name_flags
- (model, (const char*)name, flags | EGG_TB_MODEL_NAME_KNOWN);
+ (model, (const char *) name, flags | EGG_TB_MODEL_NAME_KNOWN);
xmlFree (name);
}
child = child->next;
@@ -631,12 +639,11 @@ parse_available_list (EggToolbarsModel *model,
}
static void
-parse_names (EggToolbarsModel *model,
- xmlNodePtr child)
+parse_names (EggToolbarsModel * model, xmlNodePtr child)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "available"))
+ if (xmlStrEqual (child->name, (const xmlChar *) "available"))
{
parse_available_list (model, child->children);
}
@@ -646,22 +653,22 @@ parse_names (EggToolbarsModel *model,
}
gboolean
-egg_toolbars_model_load_names (EggToolbarsModel *model,
- const char *xml_file)
+egg_toolbars_model_load_names (EggToolbarsModel * model, const char *xml_file)
{
xmlDocPtr doc;
xmlNodePtr root;
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
- if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
+ if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS))
+ return FALSE;
doc = xmlParseFile (xml_file);
if (doc == NULL)
- {
- g_warning ("Failed to load XML data from %s", xml_file);
- return FALSE;
- }
+ {
+ g_warning ("Failed to load XML data from %s", xml_file);
+ return FALSE;
+ }
root = xmlDocGetRootElement (doc);
parse_names (model, root->children);
@@ -672,10 +679,10 @@ egg_toolbars_model_load_names (EggToolbarsModel *model,
}
static void
-egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
+egg_toolbars_model_class_init (EggToolbarsModelClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- volatile GType flags_type; /* work around gcc's optimiser */
+ volatile GType flags_type; /* work around gcc's optimiser */
/* make sure the flags type is known */
flags_type = EGG_TYPE_TB_MODEL_FLAGS;
@@ -724,24 +731,25 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
}
static void
-egg_toolbars_model_init (EggToolbarsModel *model)
+egg_toolbars_model_init (EggToolbarsModel * model)
{
- model->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (model);
+ model->priv = EGG_TOOLBARS_MODEL_GET_PRIVATE (model);
model->priv->toolbars = g_node_new (NULL);
- model->priv->flags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ model->priv->flags =
+ g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
egg_toolbars_model_set_name_flags (model, "_separator",
EGG_TB_MODEL_NAME_KNOWN |
EGG_TB_MODEL_NAME_INFINITE);
}
static void
-egg_toolbars_model_finalize (GObject *object)
+egg_toolbars_model_finalize (GObject * object)
{
EggToolbarsModel *model = EGG_TOOLBARS_MODEL (object);
g_node_children_foreach (model->priv->toolbars, G_TRAVERSE_ALL,
- (GNodeForeachFunc) toolbar_node_free, model);
+ (GNodeForeachFunc) toolbar_node_free, model);
g_node_destroy (model->priv->toolbars);
g_hash_table_destroy (model->priv->flags);
@@ -755,8 +763,7 @@ egg_toolbars_model_new (void)
}
void
-egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
- int position)
+egg_toolbars_model_remove_toolbar (EggToolbarsModel * model, int position)
{
GNode *node;
EggTbModelFlags flags;
@@ -772,15 +779,13 @@ egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
toolbar_node_free (node, model);
- g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED],
- 0, position);
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED], 0, position);
}
}
void
-egg_toolbars_model_remove_item (EggToolbarsModel *model,
- int toolbar_position,
- int position)
+egg_toolbars_model_remove_item (EggToolbarsModel * model,
+ int toolbar_position, int position)
{
GNode *node, *toolbar;
@@ -799,11 +804,10 @@ egg_toolbars_model_remove_item (EggToolbarsModel *model,
}
void
-egg_toolbars_model_move_item (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- int new_toolbar_position,
- int new_position)
+egg_toolbars_model_move_item (EggToolbarsModel * model,
+ int toolbar_position,
+ int position,
+ int new_toolbar_position, int new_position)
{
GNode *node, *toolbar, *new_toolbar;
@@ -812,7 +816,8 @@ egg_toolbars_model_move_item (EggToolbarsModel *model,
toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_if_fail (toolbar != NULL);
- new_toolbar = g_node_nth_child (model->priv->toolbars, new_toolbar_position);
+ new_toolbar =
+ g_node_nth_child (model->priv->toolbars, new_toolbar_position);
g_return_if_fail (new_toolbar != NULL);
node = g_node_nth_child (toolbar, position);
@@ -830,8 +835,7 @@ egg_toolbars_model_move_item (EggToolbarsModel *model,
}
void
-egg_toolbars_model_delete_item (EggToolbarsModel *model,
- const char *name)
+egg_toolbars_model_delete_item (EggToolbarsModel * model, const char *name)
{
EggToolbarsItem *idata;
EggToolbarsToolbar *tdata;
@@ -850,21 +854,20 @@ egg_toolbars_model_delete_item (EggToolbarsModel *model,
/* Don't delete toolbars that were already empty */
if (item == NULL)
- {
+ {
toolbar = g_node_next_sibling (toolbar);
continue;
- }
+ }
while (item != NULL)
- {
+ {
next = g_node_next_sibling (item);
idata = item->data;
if (strcmp (idata->name, name) == 0)
{
item_node_free (item, model);
g_signal_emit (G_OBJECT (model),
- signals[ITEM_REMOVED],
- 0, tpos, ipos);
+ signals[ITEM_REMOVED], 0, tpos, ipos);
}
else
{
@@ -872,31 +875,28 @@ egg_toolbars_model_delete_item (EggToolbarsModel *model,
}
item = next;
- }
+ }
next = g_node_next_sibling (toolbar);
tdata = toolbar->data;
if (!(tdata->flags & EGG_TB_MODEL_NOT_REMOVABLE) &&
g_node_first_child (toolbar) == NULL)
- {
+ {
toolbar_node_free (toolbar, model);
- g_signal_emit (G_OBJECT (model),
- signals[TOOLBAR_REMOVED],
- 0, tpos);
- }
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED], 0, tpos);
+ }
else
- {
+ {
tpos++;
- }
+ }
toolbar = next;
}
}
int
-egg_toolbars_model_n_items (EggToolbarsModel *model,
- int toolbar_position)
+egg_toolbars_model_n_items (EggToolbarsModel * model, int toolbar_position)
{
GNode *toolbar;
@@ -907,9 +907,8 @@ egg_toolbars_model_n_items (EggToolbarsModel *model,
}
const char *
-egg_toolbars_model_item_nth (EggToolbarsModel *model,
- int toolbar_position,
- int position)
+egg_toolbars_model_item_nth (EggToolbarsModel * model,
+ int toolbar_position, int position)
{
GNode *toolbar;
GNode *item;
@@ -926,14 +925,13 @@ egg_toolbars_model_item_nth (EggToolbarsModel *model,
}
int
-egg_toolbars_model_n_toolbars (EggToolbarsModel *model)
+egg_toolbars_model_n_toolbars (EggToolbarsModel * model)
{
return g_node_n_children (model->priv->toolbars);
}
const char *
-egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
- int position)
+egg_toolbars_model_toolbar_nth (EggToolbarsModel * model, int position)
{
GNode *toolbar;
EggToolbarsToolbar *tdata;
@@ -947,27 +945,27 @@ egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
}
GList *
-egg_toolbars_model_get_types (EggToolbarsModel *model)
+egg_toolbars_model_get_types (EggToolbarsModel * model)
{
return model->priv->types;
}
void
-egg_toolbars_model_set_types (EggToolbarsModel *model, GList *types)
+egg_toolbars_model_set_types (EggToolbarsModel * model, GList * types)
{
model->priv->types = types;
}
static void
-fill_avail_array (gpointer key, gpointer value, GPtrArray *array)
+fill_avail_array (gpointer key, gpointer value, GPtrArray * array)
{
int flags = GPOINTER_TO_INT (value);
if ((flags & EGG_TB_MODEL_NAME_KNOWN) && !(flags & EGG_TB_MODEL_NAME_USED))
- g_ptr_array_add (array, key);
+ g_ptr_array_add (array, key);
}
GPtrArray *
-egg_toolbars_model_get_name_avail (EggToolbarsModel *model)
+egg_toolbars_model_get_name_avail (EggToolbarsModel * model)
{
GPtrArray *array = g_ptr_array_new ();
g_hash_table_foreach (model->priv->flags, (GHFunc) fill_avail_array, array);
@@ -975,13 +973,15 @@ egg_toolbars_model_get_name_avail (EggToolbarsModel *model)
}
gint
-egg_toolbars_model_get_name_flags (EggToolbarsModel *model, const char *name)
+egg_toolbars_model_get_name_flags (EggToolbarsModel * model, const char *name)
{
return GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, name));
}
void
-egg_toolbars_model_set_name_flags (EggToolbarsModel *model, const char *name, gint flags)
+egg_toolbars_model_set_name_flags (EggToolbarsModel * model, const char *name,
+ gint flags)
{
- g_hash_table_insert (model->priv->flags, g_strdup (name), GINT_TO_POINTER (flags));
+ g_hash_table_insert (model->priv->flags, g_strdup (name),
+ GINT_TO_POINTER (flags));
}
diff --git a/src/toolbareditor/egg-toolbars-model.h b/src/toolbareditor/egg-toolbars-model.h
index 5c02b0a..8ea7b94 100644
--- a/src/toolbareditor/egg-toolbars-model.h
+++ b/src/toolbareditor/egg-toolbars-model.h
@@ -26,45 +26,43 @@
#include <gdk/gdk.h>
G_BEGIN_DECLS
-
#define EGG_TYPE_TOOLBARS_MODEL (egg_toolbars_model_get_type ())
#define EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModel))
#define EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
#define EGG_IS_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOLBARS_MODEL))
#define EGG_IS_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TOOLBARS_MODEL))
#define EGG_TOOLBARS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
-
-typedef struct EggToolbarsModel EggToolbarsModel;
-typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
-typedef struct EggToolbarsModelClass EggToolbarsModelClass;
+typedef struct EggToolbarsModel EggToolbarsModel;
+typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
+typedef struct EggToolbarsModelClass EggToolbarsModelClass;
#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
typedef enum
{
- EGG_TB_MODEL_NOT_REMOVABLE = 1 << 0,
- EGG_TB_MODEL_NOT_EDITABLE = 1 << 1,
- EGG_TB_MODEL_BOTH = 1 << 2,
- EGG_TB_MODEL_BOTH_HORIZ = 1 << 3,
- EGG_TB_MODEL_ICONS = 1 << 4,
- EGG_TB_MODEL_TEXT = 1 << 5,
- EGG_TB_MODEL_STYLES_MASK = 0x3C,
+ EGG_TB_MODEL_NOT_REMOVABLE = 1 << 0,
+ EGG_TB_MODEL_NOT_EDITABLE = 1 << 1,
+ EGG_TB_MODEL_BOTH = 1 << 2,
+ EGG_TB_MODEL_BOTH_HORIZ = 1 << 3,
+ EGG_TB_MODEL_ICONS = 1 << 4,
+ EGG_TB_MODEL_TEXT = 1 << 5,
+ EGG_TB_MODEL_STYLES_MASK = 0x3C,
EGG_TB_MODEL_ACCEPT_ITEMS_ONLY = 1 << 6,
- EGG_TB_MODEL_HIDDEN = 1 << 7
+ EGG_TB_MODEL_HIDDEN = 1 << 7
} EggTbModelFlags;
typedef enum
{
- EGG_TB_MODEL_NAME_USED = 1 << 0,
- EGG_TB_MODEL_NAME_INFINITE = 1 << 1,
- EGG_TB_MODEL_NAME_KNOWN = 1 << 2
+ EGG_TB_MODEL_NAME_USED = 1 << 0,
+ EGG_TB_MODEL_NAME_INFINITE = 1 << 1,
+ EGG_TB_MODEL_NAME_KNOWN = 1 << 2
} EggTbModelNameFlags;
struct EggToolbarsModel
{
GObject parent_object;
- /*< private >*/
+ /*< private > */
EggToolbarsModelPrivate *priv;
};
@@ -73,24 +71,18 @@ struct EggToolbarsModelClass
GObjectClass parent_class;
/* Signals */
- void (* item_added) (EggToolbarsModel *model,
- int toolbar_position,
- int position);
- void (* item_removed) (EggToolbarsModel *model,
- int toolbar_position,
- int position);
- void (* toolbar_added) (EggToolbarsModel *model,
- int position);
- void (* toolbar_changed) (EggToolbarsModel *model,
- int position);
- void (* toolbar_removed) (EggToolbarsModel *model,
- int position);
+ void (*item_added) (EggToolbarsModel * model,
+ int toolbar_position, int position);
+ void (*item_removed) (EggToolbarsModel * model,
+ int toolbar_position, int position);
+ void (*toolbar_added) (EggToolbarsModel * model, int position);
+ void (*toolbar_changed) (EggToolbarsModel * model, int position);
+ void (*toolbar_removed) (EggToolbarsModel * model, int position);
/* Virtual Table */
- gboolean (* add_item) (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *name);
+ gboolean (*add_item) (EggToolbarsModel * t,
+ int toolbar_position,
+ int position, const char *name);
};
typedef struct EggToolbarsItemType EggToolbarsItemType;
@@ -99,92 +91,79 @@ struct EggToolbarsItemType
{
GdkAtom type;
- gboolean (* has_data) (EggToolbarsItemType *type,
- const char *name);
- char * (* get_data) (EggToolbarsItemType *type,
- const char *name);
+ gboolean (*has_data) (EggToolbarsItemType * type, const char *name);
+ char *(*get_data) (EggToolbarsItemType * type, const char *name);
- char * (* new_name) (EggToolbarsItemType *type,
- const char *data);
- char * (* get_name) (EggToolbarsItemType *type,
- const char *data);
+ char *(*new_name) (EggToolbarsItemType * type, const char *data);
+ char *(*get_name) (EggToolbarsItemType * type, const char *data);
};
-GType egg_tb_model_flags_get_type (void);
-GType egg_toolbars_model_get_type (void);
-EggToolbarsModel *egg_toolbars_model_new (void);
-gboolean egg_toolbars_model_load_names (EggToolbarsModel *model,
- const char *xml_file);
-gboolean egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
- const char *xml_file);
-void egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
- const char *xml_file,
- const char *version);
+GType egg_tb_model_flags_get_type (void);
+GType egg_toolbars_model_get_type (void);
+EggToolbarsModel *egg_toolbars_model_new (void);
+gboolean egg_toolbars_model_load_names (EggToolbarsModel * model,
+ const char *xml_file);
+gboolean egg_toolbars_model_load_toolbars (EggToolbarsModel * model,
+ const char *xml_file);
+void egg_toolbars_model_save_toolbars (EggToolbarsModel * model,
+ const char *xml_file,
+ const char *version);
/* Functions for manipulating the types of portable data this toolbar understands. */
-GList * egg_toolbars_model_get_types (EggToolbarsModel *model);
-void egg_toolbars_model_set_types (EggToolbarsModel *model,
- GList *types);
+GList *egg_toolbars_model_get_types (EggToolbarsModel * model);
+void egg_toolbars_model_set_types (EggToolbarsModel * model, GList * types);
/* Functions for converting between name and portable data. */
-char * egg_toolbars_model_get_name (EggToolbarsModel *model,
- GdkAtom type,
- const char *data,
- gboolean create);
-char * egg_toolbars_model_get_data (EggToolbarsModel *model,
- GdkAtom type,
- const char *name);
+char *egg_toolbars_model_get_name (EggToolbarsModel * model,
+ GdkAtom type,
+ const char *data, gboolean create);
+char *egg_toolbars_model_get_data (EggToolbarsModel * model,
+ GdkAtom type, const char *name);
/* Functions for retrieving what items are available for adding to the toolbars. */
-GPtrArray * egg_toolbars_model_get_name_avail (EggToolbarsModel *model);
-gint egg_toolbars_model_get_name_flags (EggToolbarsModel *model,
- const char *name);
-void egg_toolbars_model_set_name_flags (EggToolbarsModel *model,
- const char *name,
- gint flags);
+GPtrArray *egg_toolbars_model_get_name_avail (EggToolbarsModel * model);
+gint egg_toolbars_model_get_name_flags (EggToolbarsModel * model,
+ const char *name);
+void egg_toolbars_model_set_name_flags (EggToolbarsModel * model,
+ const char *name, gint flags);
/* Functions for manipulating flags on individual toolbars. */
-EggTbModelFlags egg_toolbars_model_get_flags (EggToolbarsModel *model,
- int toolbar_position);
-void egg_toolbars_model_set_flags (EggToolbarsModel *model,
- int toolbar_position,
- EggTbModelFlags flags);
+EggTbModelFlags egg_toolbars_model_get_flags (EggToolbarsModel * model,
+ int toolbar_position);
+void egg_toolbars_model_set_flags (EggToolbarsModel * model,
+ int toolbar_position,
+ EggTbModelFlags flags);
/* Functions for adding and removing toolbars. */
-int egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
- int position,
- const char *name);
-void egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
- int position);
+int egg_toolbars_model_add_toolbar (EggToolbarsModel * model,
+ int position, const char *name);
+void egg_toolbars_model_remove_toolbar (EggToolbarsModel * model,
+ int position);
/* Functions for adding, removing and moving items. */
-gboolean egg_toolbars_model_add_item (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- const char *name);
-void egg_toolbars_model_remove_item (EggToolbarsModel *model,
- int toolbar_position,
- int position);
-void egg_toolbars_model_move_item (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- int new_toolbar_position,
- int new_position);
-void egg_toolbars_model_delete_item (EggToolbarsModel *model,
- const char *name);
+gboolean egg_toolbars_model_add_item (EggToolbarsModel * model,
+ int toolbar_position,
+ int position, const char *name);
+void egg_toolbars_model_remove_item (EggToolbarsModel * model,
+ int toolbar_position, int position);
+void egg_toolbars_model_move_item (EggToolbarsModel * model,
+ int toolbar_position,
+ int position,
+ int new_toolbar_position,
+ int new_position);
+void egg_toolbars_model_delete_item (EggToolbarsModel * model,
+ const char *name);
/* Functions for accessing the names of items. */
-int egg_toolbars_model_n_items (EggToolbarsModel *model,
- int toolbar_position);
-const char * egg_toolbars_model_item_nth (EggToolbarsModel *model,
- int toolbar_position,
- int position);
+int egg_toolbars_model_n_items (EggToolbarsModel * model,
+ int toolbar_position);
+const char *egg_toolbars_model_item_nth (EggToolbarsModel * model,
+ int toolbar_position, int position);
/* Functions for accessing the names of toolbars. */
-int egg_toolbars_model_n_toolbars (EggToolbarsModel *model);
-const char *egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
- int position);
+int egg_toolbars_model_n_toolbars (EggToolbarsModel * model);
+const char *egg_toolbars_model_toolbar_nth (EggToolbarsModel * model,
+ int position);
G_END_DECLS
-
#endif
diff --git a/src/translation-memory/berkeley/berkeley.c b/src/translation-memory/berkeley/berkeley.c
index 58d8e2c..f4d9abe 100644
--- a/src/translation-memory/berkeley/berkeley.c
+++ b/src/translation-memory/berkeley/berkeley.c
@@ -24,7 +24,7 @@
#include "berkeley.h"
#include "translation-memory.h"
-#include DB_HEADER //This can be something like <db.h>
+#include DB_HEADER //This can be something like <db.h>
#include "db-trans.h"
#include "db-orig.h"
#include "db-words.h"
@@ -41,267 +41,260 @@
GTR_TYPE_BERKELEY, \
GtranslatorBerkeleyPrivate))
-static void gtranslator_translation_memory_iface_init (GtranslatorTranslationMemoryIface *iface);
+static void
+gtranslator_translation_memory_iface_init (GtranslatorTranslationMemoryIface *
+ iface);
G_DEFINE_TYPE_WITH_CODE (GtranslatorBerkeley,
gtranslator_berkeley,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTR_TYPE_TRANSLATION_MEMORY,
- gtranslator_translation_memory_iface_init))
-
-struct _GtranslatorBerkeleyPrivate
+ gtranslator_translation_memory_iface_init))
+ struct _GtranslatorBerkeleyPrivate
+ {
+ GtranslatorDbOrig *orig;
+ GtranslatorDbTrans *trans;
+ GtranslatorDbWords *words;
+
+ gsize max_omits;
+ gsize max_delta;
+ gint max_items;
+ };
+
+ static gboolean
+ gtranslator_berkeley_store (GtranslatorTranslationMemory * tm,
+ const gchar * original,
+ const gchar * translation)
{
- GtranslatorDbOrig *orig;
- GtranslatorDbTrans *trans;
- GtranslatorDbWords *words;
-
- gsize max_omits;
- gsize max_delta;
- gint max_items;
-};
+ GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
+ gboolean ok;
+ db_recno_t key;
-static gboolean
-gtranslator_berkeley_store (GtranslatorTranslationMemory *tm,
- const gchar *original,
- const gchar *translation)
-{
- GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
- gboolean ok;
- db_recno_t key;
-
- g_return_val_if_fail (GTR_IS_BERKELEY (ber), FALSE);
-
- key = gtranslator_db_orig_read (ber->priv->orig,
- original);
- if (key == 0)
+ g_return_val_if_fail (GTR_IS_BERKELEY (ber), FALSE);
+
+ key = gtranslator_db_orig_read (ber->priv->orig, original);
+ if (key == 0)
+ {
+ key = gtranslator_db_trans_write_string (ber->priv->trans,
+ translation, 0);
+
+ ok = (key != 0)
+ && gtranslator_db_orig_write (ber->priv->orig, original, key);
+ if (ok)
{
- key = gtranslator_db_trans_write_string (ber->priv->trans,
- translation, 0);
+ gchar **words = NULL;
+ gsize i;
- ok = (key != 0) && gtranslator_db_orig_write (ber->priv->orig, original, key);
- if (ok)
- {
- gchar **words = NULL;
- gsize i;
-
- words = gtranslator_utils_split_string_in_words (original);
- gsize sz = g_strv_length (words);
-
- for (i = 0; i < sz; i++)
- gtranslator_db_words_append (ber->priv->words,
- words[i],
- sz,
- key);
- g_strfreev (words);
- }
- return ok;
+ words = gtranslator_utils_split_string_in_words (original);
+ gsize sz = g_strv_length (words);
+
+ for (i = 0; i < sz; i++)
+ gtranslator_db_words_append (ber->priv->words, words[i], sz, key);
+ g_strfreev (words);
}
- else
+ return ok;
+ }
+ else
+ {
+ gboolean found = FALSE;
+ gint i = 0;
+ gchar *translation_collate;
+ GPtrArray *t = gtranslator_db_trans_read (ber->priv->trans,
+ key);
+ if (!t)
+ return FALSE;
+
+ translation_collate = g_utf8_collate_key (translation, -1);
+ // -1 because we know that last element is NULL
+ while (i < t->len - 1)
{
- gboolean found = FALSE;
- gint i = 0;
- gchar *translation_collate;
- GPtrArray *t = gtranslator_db_trans_read (ber->priv->trans,
- key);
- if (!t)
- return FALSE;
-
- translation_collate = g_utf8_collate_key (translation, -1);
- // -1 because we know that last element is NULL
- while (i < t->len - 1)
- {
- gchar *array_word = g_utf8_collate_key (g_ptr_array_index (t, i), -1);
-
- if (strcmp (array_word, translation_collate) == 0)
- {
- found = TRUE;
- g_free (array_word);
- break;
- }
-
- g_free (array_word);
- i++;
- }
- g_free (translation_collate);
-
- if (!found)
- {
- gchar **translations = NULL;
-
- /*
- * We remove the previous NULL data and then we add the new data
- */
- g_ptr_array_remove_index (t, t->len-1);
- g_ptr_array_add (t, g_strdup (translation));
- g_ptr_array_add (t, NULL);
-
- translations = (gchar **)g_ptr_array_free (t, FALSE);
-
- db_recno_t key2 = gtranslator_db_trans_write (ber->priv->trans,
- translations,
- key);
- g_strfreev (translations);
- ok = (key2 != 0);
- }
- else
- {
- ok = TRUE;
- g_ptr_array_free (t, TRUE);
- }
+ gchar *array_word =
+ g_utf8_collate_key (g_ptr_array_index (t, i), -1);
+
+ if (strcmp (array_word, translation_collate) == 0)
+ {
+ found = TRUE;
+ g_free (array_word);
+ break;
+ }
+
+ g_free (array_word);
+ i++;
+ }
+ g_free (translation_collate);
- return ok;
+ if (!found)
+ {
+ gchar **translations = NULL;
+
+ /*
+ * We remove the previous NULL data and then we add the new data
+ */
+ g_ptr_array_remove_index (t, t->len - 1);
+ g_ptr_array_add (t, g_strdup (translation));
+ g_ptr_array_add (t, NULL);
+
+ translations = (gchar **) g_ptr_array_free (t, FALSE);
+
+ db_recno_t key2 = gtranslator_db_trans_write (ber->priv->trans,
+ translations,
+ key);
+ g_strfreev (translations);
+ ok = (key2 != 0);
}
+ else
+ {
+ ok = TRUE;
+ g_ptr_array_free (t, TRUE);
+ }
+
+ return ok;
+ }
}
static GtranslatorDbKeys *
-union_of_db_keys (GtranslatorBerkeley *ber,
- gsize cnt,
- GtranslatorDbKeys **keys,
- gboolean *mask)
+union_of_db_keys (GtranslatorBerkeley * ber,
+ gsize cnt, GtranslatorDbKeys ** keys, gboolean * mask)
{
- gsize i, minSize;
- db_recno_t **heads = g_new (db_recno_t *, cnt);
- gsize *counters = g_new (gsize, cnt);
- GtranslatorDbKeys *result;
- db_recno_t *res_list;
-
- // initialize heads and counters _and_ find size of smallest keys list
- // (union can't be larger than that)
- for (minSize = 0, i = 0; i < cnt; i++)
+ gsize i, minSize;
+ db_recno_t **heads = g_new (db_recno_t *, cnt);
+ gsize *counters = g_new (gsize, cnt);
+ GtranslatorDbKeys *result;
+ db_recno_t *res_list;
+
+ // initialize heads and counters _and_ find size of smallest keys list
+ // (union can't be larger than that)
+ for (minSize = 0, i = 0; i < cnt; i++)
+ {
+ if (mask[i])
{
- if (mask[i])
- {
- gsize count = gtranslator_db_keys_get_count (keys[i]);
- db_recno_t * list = gtranslator_db_keys_get_list (keys[i]);
-
- counters[i] = count;
- heads[i] = list;
- if (minSize == 0 || minSize > count)
- minSize = count;
- }
- else
- {
- counters[i] = 0;
- heads[i] = NULL;
- }
+ gsize count = gtranslator_db_keys_get_count (keys[i]);
+ db_recno_t *list = gtranslator_db_keys_get_list (keys[i]);
+
+ counters[i] = count;
+ heads[i] = list;
+ if (minSize == 0 || minSize > count)
+ minSize = count;
}
- if (minSize == 0)
+ else
{
- g_free (counters);
- g_free (heads);
-
- return NULL;
+ counters[i] = 0;
+ heads[i] = NULL;
}
-
- result = gtranslator_db_keys_new_with_size (minSize);
- res_list = gtranslator_db_keys_get_list (result);
- gsize res_count = 0;
-
- // Do union of 'cnt' sorted arrays. Algorithm: treat arrays as lists,
- // remember pointer to first unprocessed item. In each iteration, do:
- // if all heads have same value, add that value to output list, otherwise
- // move the head with smallest value one item forward. (This way we won't
- // miss any value that could possibly be in the output list, because
- // if the smallest value of all heads is not at the beginning of other
- // lists, it cannot appear later in these lists due to their sorted nature.
- // We end processing when any head reaches end of (its) list
- db_recno_t smallestValue;
- gsize smallestIndex = 0;
- gboolean allSame;
- for (;;)
+ }
+ if (minSize == 0)
+ {
+ g_free (counters);
+ g_free (heads);
+
+ return NULL;
+ }
+
+ result = gtranslator_db_keys_new_with_size (minSize);
+ res_list = gtranslator_db_keys_get_list (result);
+ gsize res_count = 0;
+
+ // Do union of 'cnt' sorted arrays. Algorithm: treat arrays as lists,
+ // remember pointer to first unprocessed item. In each iteration, do:
+ // if all heads have same value, add that value to output list, otherwise
+ // move the head with smallest value one item forward. (This way we won't
+ // miss any value that could possibly be in the output list, because
+ // if the smallest value of all heads is not at the beginning of other
+ // lists, it cannot appear later in these lists due to their sorted nature.
+ // We end processing when any head reaches end of (its) list
+ db_recno_t smallestValue;
+ gsize smallestIndex = 0;
+ gboolean allSame;
+ for (;;)
+ {
+ allSame = TRUE;
+ smallestValue = 0;
+
+ for (i = 0; i < cnt; i++)
{
- allSame = TRUE;
- smallestValue = 0;
-
- for (i = 0; i < cnt; i++)
+ if (counters[i] == 0)
+ continue;
+ if (smallestValue == 0)
+ {
+ smallestValue = *heads[i];
+ smallestIndex = i;
+ }
+ else if (smallestValue != *heads[i])
+ {
+ allSame = FALSE;
+ if (smallestValue > *heads[i])
{
- if (counters[i] == 0)
- continue;
- if (smallestValue == 0)
- {
- smallestValue = *heads[i];
- smallestIndex = i;
- }
- else if (smallestValue != *heads[i])
- {
- allSame = FALSE;
- if (smallestValue > *heads[i])
- {
- smallestValue = *heads[i];
- smallestIndex = i;
- }
- }
+ smallestValue = *heads[i];
+ smallestIndex = i;
}
-
- if (smallestValue == 0)
- break;
-
- if (allSame)
- {
- gboolean breakMe = FALSE;
- res_list[res_count++] = smallestValue;
- for (i = 0; i < cnt; i++)
- {
- if (counters[i] == 0)
- continue;
- if (--counters[i] == 0)
- {
- breakMe = TRUE;
- break;
- }
- heads[i]++;
- }
- if (breakMe)
- break;
- }
- else
+ }
+ }
+
+ if (smallestValue == 0)
+ break;
+
+ if (allSame)
+ {
+ gboolean breakMe = FALSE;
+ res_list[res_count++] = smallestValue;
+ for (i = 0; i < cnt; i++)
+ {
+ if (counters[i] == 0)
+ continue;
+ if (--counters[i] == 0)
{
- if (--counters[smallestIndex] == 0)
- break;
- heads[smallestIndex]++;
+ breakMe = TRUE;
+ break;
}
+ heads[i]++;
+ }
+ if (breakMe)
+ break;
}
-
- g_free (counters);
- g_free (heads);
- if (res_count == 0)
+ else
{
- g_object_unref (result);
- result = NULL;
+ if (--counters[smallestIndex] == 0)
+ break;
+ heads[smallestIndex]++;
}
- else gtranslator_db_keys_set_count (result, res_count);
-
- return result;
+ }
+
+ g_free (counters);
+ g_free (heads);
+ if (res_count == 0)
+ {
+ g_object_unref (result);
+ result = NULL;
+ }
+ else
+ gtranslator_db_keys_set_count (result, res_count);
+
+ return result;
}
static gboolean
-advance_cycle (gsize omitted[],
- gsize depth,
- gsize cnt)
+advance_cycle (gsize omitted[], gsize depth, gsize cnt)
{
- if (++omitted[depth] == cnt)
- {
- if (depth == 0)
- return FALSE;
- depth--;
- if (!advance_cycle (omitted, depth, cnt))
- return FALSE;
- depth++;
- omitted[depth] = omitted[depth - 1] + 1;
- if (omitted[depth] >= cnt)
- return FALSE;
- return TRUE;
- }
- else
- return TRUE;
+ if (++omitted[depth] == cnt)
+ {
+ if (depth == 0)
+ return FALSE;
+ depth--;
+ if (!advance_cycle (omitted, depth, cnt))
+ return FALSE;
+ depth++;
+ omitted[depth] = omitted[depth - 1] + 1;
+ if (omitted[depth] >= cnt)
+ return FALSE;
+ return TRUE;
+ }
+ else
+ return TRUE;
}
static gboolean
-look_fuzzy (GtranslatorBerkeley *ber,
- gchar **words,
- GHashTable **hash,
- gsize omits,
- gsize delta)
+look_fuzzy (GtranslatorBerkeley * ber,
+ gchar ** words, GHashTable ** hash, gsize omits, gsize delta)
{
#define RETURN_WITH_CLEANUP(val) \
for (i = 0; i < cnt_orig; i++) \
@@ -312,311 +305,311 @@ look_fuzzy (GtranslatorBerkeley *ber,
g_free (omitted); \
return (val);
- gsize i, slot;
- gsize missing;
- GtranslatorDbKeys **keys;
- gboolean *mask;
- gsize *omitted;
- gsize cnt = g_strv_length (words);
- gsize cnt_orig = cnt;
- GtranslatorDbKeys *result;
-
- if (omits >= cnt)
- return FALSE;
- if (cnt + delta <= 0)
- return FALSE;
-
- keys = g_new (GtranslatorDbKeys *, cnt);
- mask = g_new (gboolean, cnt);
- omitted = g_new (gsize, omits);
-
- for (missing = 0, slot = 0, i = 0; i < cnt; i++)
+ gsize i, slot;
+ gsize missing;
+ GtranslatorDbKeys **keys;
+ gboolean *mask;
+ gsize *omitted;
+ gsize cnt = g_strv_length (words);
+ gsize cnt_orig = cnt;
+ GtranslatorDbKeys *result;
+
+ if (omits >= cnt)
+ return FALSE;
+ if (cnt + delta <= 0)
+ return FALSE;
+
+ keys = g_new (GtranslatorDbKeys *, cnt);
+ mask = g_new (gboolean, cnt);
+ omitted = g_new (gsize, omits);
+
+ for (missing = 0, slot = 0, i = 0; i < cnt; i++)
+ {
+ keys[i] = NULL; // so that unused entries are NULL
+ keys[slot] = gtranslator_db_words_read (ber->priv->words,
+ words[i], cnt + delta);
+ if (keys[slot])
+ slot++;
+ else
+ missing++;
+ }
+
+ if (missing >= cnt || missing > omits)
+ {
+ RETURN_WITH_CLEANUP (FALSE)}
+ cnt -= missing;
+ omits -= missing;
+
+ if (omits == 0)
+ {
+ for (i = 0; i < cnt; i++)
+ mask[i] = TRUE;
+
+ result = union_of_db_keys (ber, cnt, keys, mask);
+ if (result != NULL)
{
- keys[i] = NULL; // so that unused entries are NULL
- keys[slot] = gtranslator_db_words_read (ber->priv->words,
- words[i], cnt + delta);
- if (keys[slot])
- slot++;
- else
- missing++;
- }
-
- if (missing >= cnt || missing > omits)
- {
- RETURN_WITH_CLEANUP(FALSE)
- }
- cnt -= missing;
- omits -= missing;
+ GPtrArray *array;
- if (omits == 0)
- {
- for (i = 0; i < cnt; i++)
- mask[i] = TRUE;
-
- result = union_of_db_keys (ber, cnt,
- keys, mask);
- if (result != NULL)
+ db_recno_t *list = gtranslator_db_keys_get_list (result);
+ for (i = 0; i < gtranslator_db_keys_get_count (result); i++)
+ {
+ array = gtranslator_db_trans_read (ber->priv->trans, list[i]);
+ if (array)
{
- GPtrArray *array;
-
- db_recno_t *list = gtranslator_db_keys_get_list (result);
- for (i = 0; i < gtranslator_db_keys_get_count (result); i++)
- {
- array = gtranslator_db_trans_read (ber->priv->trans,
- list[i]);
- if (array)
- {
- gint j = 0;
- gint score = 0;
-
- score = (ber->priv->max_omits - omits) * 100 /
- (ber->priv->max_omits + 1) +
- (ber->priv->max_delta - delta) * 100 /
- ((ber->priv->max_delta + 1) *
- (ber->priv->max_delta + 1));
-
- if (score == 0)
- score = 1;
-
- while (j < array->len -1)
- {
- gchar *string;
-
- string = (gchar *)g_ptr_array_index (array, j);
-
- /* The first adding is always better */
- if (!g_hash_table_lookup (*hash, string))
- g_hash_table_insert (*hash, string,
- GINT_TO_POINTER (score));
-
- j++;
- }
- g_ptr_array_free (array, TRUE);
- }
- }
- g_object_unref (result);
- RETURN_WITH_CLEANUP(TRUE)
+ gint j = 0;
+ gint score = 0;
+
+ score = (ber->priv->max_omits - omits) * 100 /
+ (ber->priv->max_omits + 1) +
+ (ber->priv->max_delta - delta) * 100 /
+ ((ber->priv->max_delta + 1) * (ber->priv->max_delta + 1));
+
+ if (score == 0)
+ score = 1;
+
+ while (j < array->len - 1)
+ {
+ gchar *string;
+
+ string = (gchar *) g_ptr_array_index (array, j);
+
+ /* The first adding is always better */
+ if (!g_hash_table_lookup (*hash, string))
+ g_hash_table_insert (*hash, string,
+ GINT_TO_POINTER (score));
+
+ j++;
+ }
+ g_ptr_array_free (array, TRUE);
}
- }
- else
+ }
+ g_object_unref (result);
+ RETURN_WITH_CLEANUP (TRUE)}
+ }
+ else
+ {
+ gsize depth = omits - 1;
+
+ for (i = 0; i < omits; i++)
+ omitted[i] = i;
+ for (;;)
{
- gsize depth = omits - 1;
-
- for (i = 0; i < omits; i++)
- omitted[i] = i;
- for (;;)
+ for (i = 0; i < cnt; i++)
+ mask[i] = TRUE;
+ for (i = 0; i < omits; i++)
+ mask[omitted[i]] = FALSE;
+
+ result = union_of_db_keys (ber, cnt, keys, mask);
+ if (result != NULL)
+ {
+ GPtrArray *array;
+
+ db_recno_t *list = gtranslator_db_keys_get_list (result);
+ for (i = 0; i < gtranslator_db_keys_get_count (result); i++)
{
- for (i = 0; i < cnt; i++)
- mask[i] = TRUE;
- for (i = 0; i < omits; i++)
- mask[omitted[i]] = FALSE;
-
- result = union_of_db_keys (ber, cnt, keys, mask);
- if (result != NULL)
- {
- GPtrArray *array;
-
- db_recno_t *list = gtranslator_db_keys_get_list (result);
- for (i = 0; i < gtranslator_db_keys_get_count (result); i++)
- {
- array = gtranslator_db_trans_read (ber->priv->trans,
- list[i]);
- if (array)
- {
- gint j = 0;
- gint score = 0;
-
- score = (ber->priv->max_omits - omits) * 100 /
- (ber->priv->max_omits + 1) +
- (ber->priv->max_delta - delta) * 100 /
- ((ber->priv->max_delta + 1) *
- (ber->priv->max_delta + 1));
-
- if (score == 0)
- score = 1;
-
- while (j < array->len -1)
- {
- gchar *string;
-
- string = (gchar *)g_ptr_array_index (array, j);
-
- if (!g_hash_table_lookup (*hash, string))
- g_hash_table_insert (*hash, string,
- GINT_TO_POINTER (score));
-
- j++;
- }
- g_ptr_array_free (array, TRUE);
- }
- }
- g_object_unref (result);
- RETURN_WITH_CLEANUP(TRUE)
+ array = gtranslator_db_trans_read (ber->priv->trans,
+ list[i]);
+ if (array)
+ {
+ gint j = 0;
+ gint score = 0;
+
+ score = (ber->priv->max_omits - omits) * 100 /
+ (ber->priv->max_omits + 1) +
+ (ber->priv->max_delta - delta) * 100 /
+ ((ber->priv->max_delta + 1) *
+ (ber->priv->max_delta + 1));
+
+ if (score == 0)
+ score = 1;
+
+ while (j < array->len - 1)
+ {
+ gchar *string;
+
+ string = (gchar *) g_ptr_array_index (array, j);
+
+ if (!g_hash_table_lookup (*hash, string))
+ g_hash_table_insert (*hash, string,
+ GINT_TO_POINTER (score));
+
+ j++;
}
-
- if (!advance_cycle (omitted, depth, cnt))
- break;
+ g_ptr_array_free (array, TRUE);
+ }
}
+ g_object_unref (result);
+ RETURN_WITH_CLEANUP (TRUE)}
+
+ if (!advance_cycle (omitted, depth, cnt))
+ break;
}
- RETURN_WITH_CLEANUP(FALSE)
-}
+ }
+RETURN_WITH_CLEANUP (FALSE)}
static gint
-insert_match_sorted (gconstpointer a,
- gconstpointer b)
+insert_match_sorted (gconstpointer a, gconstpointer b)
{
- GtranslatorTranslationMemoryMatch *match1 = (GtranslatorTranslationMemoryMatch *)a;
- GtranslatorTranslationMemoryMatch *match2 = (GtranslatorTranslationMemoryMatch *)b;
-
- if (match1->level < match2->level)
- return 1;
- else if (match1->level > match2->level)
- return -1;
- else
- return 0;
+ GtranslatorTranslationMemoryMatch *match1 =
+ (GtranslatorTranslationMemoryMatch *) a;
+ GtranslatorTranslationMemoryMatch *match2 =
+ (GtranslatorTranslationMemoryMatch *) b;
+
+ if (match1->level < match2->level)
+ return 1;
+ else if (match1->level > match2->level)
+ return -1;
+ else
+ return 0;
}
static GList *
-gtranslator_berkeley_lookup (GtranslatorTranslationMemory *tm,
- const gchar *phrase)
+gtranslator_berkeley_lookup (GtranslatorTranslationMemory * tm,
+ const gchar * phrase)
{
- GPtrArray *array = NULL;
- gchar **words;
- gsize omits;
- gsize delta;
- GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
- GHashTable *hash;
- GHashTableIter iter;
- gpointer hkey, value;
- GList *matches = NULL;
-
- g_return_val_if_fail (GTR_IS_BERKELEY (ber), NULL);
-
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-
- // First of all, try exact match:
- db_recno_t key = gtranslator_db_orig_read (ber->priv->orig, phrase);
- if (key != 0)
- {
- gint i = 0;
-
- array = gtranslator_db_trans_read (ber->priv->trans,
- key);
-
- if (array != NULL)
- {
- while (i < array->len -1 && i < ber->priv->max_items)
- {
- g_hash_table_insert (hash, g_strdup (g_ptr_array_index (array, i)),
- GINT_TO_POINTER (100));
- i++;
- }
-
- g_ptr_array_free (array, TRUE);
-
- goto list;
- }
- }
-
- // Then, try to find inexact one within defined limits
- // (MAX_OMITS is max permitted number of unmatched words,
- // MAX_DELTA is max difference in sentences lengths).
- // Start with best matches first, continue to worse ones.
- words = gtranslator_utils_split_string_in_words (phrase);
- for (omits = 0; omits <= ber->priv->max_omits && g_hash_table_size (hash) < ber->priv->max_items; omits++)
+ GPtrArray *array = NULL;
+ gchar **words;
+ gsize omits;
+ gsize delta;
+ GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
+ GHashTable *hash;
+ GHashTableIter iter;
+ gpointer hkey, value;
+ GList *matches = NULL;
+
+ g_return_val_if_fail (GTR_IS_BERKELEY (ber), NULL);
+
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ // First of all, try exact match:
+ db_recno_t key = gtranslator_db_orig_read (ber->priv->orig, phrase);
+ if (key != 0)
+ {
+ gint i = 0;
+
+ array = gtranslator_db_trans_read (ber->priv->trans, key);
+
+ if (array != NULL)
{
- for (delta = 0; delta <= ber->priv->max_delta && g_hash_table_size (hash) < ber->priv->max_items; delta++)
- {
- look_fuzzy (ber, words, &hash, omits, delta);
- }
+ while (i < array->len - 1 && i < ber->priv->max_items)
+ {
+ g_hash_table_insert (hash,
+ g_strdup (g_ptr_array_index (array, i)),
+ GINT_TO_POINTER (100));
+ i++;
+ }
+
+ g_ptr_array_free (array, TRUE);
+
+ goto list;
}
-
-list: g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter, &hkey, &value))
+ }
+
+ // Then, try to find inexact one within defined limits
+ // (MAX_OMITS is max permitted number of unmatched words,
+ // MAX_DELTA is max difference in sentences lengths).
+ // Start with best matches first, continue to worse ones.
+ words = gtranslator_utils_split_string_in_words (phrase);
+ for (omits = 0;
+ omits <= ber->priv->max_omits
+ && g_hash_table_size (hash) < ber->priv->max_items; omits++)
+ {
+ for (delta = 0;
+ delta <= ber->priv->max_delta
+ && g_hash_table_size (hash) < ber->priv->max_items; delta++)
{
- GtranslatorTranslationMemoryMatch *match = g_new (GtranslatorTranslationMemoryMatch, 1);
- match->match = g_strdup (hkey);
- match->level = GPOINTER_TO_INT (value);
-
- matches = g_list_prepend (matches, match);
+ look_fuzzy (ber, words, &hash, omits, delta);
}
- matches = g_list_sort (matches, (GCompareFunc)insert_match_sorted);
+ }
- g_hash_table_unref (hash);
-
- return matches;
+list:g_hash_table_iter_init (&iter, hash);
+ while (g_hash_table_iter_next (&iter, &hkey, &value))
+ {
+ GtranslatorTranslationMemoryMatch *match =
+ g_new (GtranslatorTranslationMemoryMatch, 1);
+ match->match = g_strdup (hkey);
+ match->level = GPOINTER_TO_INT (value);
+
+ matches = g_list_prepend (matches, match);
+ }
+ matches = g_list_sort (matches, (GCompareFunc) insert_match_sorted);
+
+ g_hash_table_unref (hash);
+
+ return matches;
}
static void
-gtranslator_berkeley_set_max_omits (GtranslatorTranslationMemory *tm,
+gtranslator_berkeley_set_max_omits (GtranslatorTranslationMemory * tm,
gsize omits)
{
- GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
-
- ber->priv->max_omits = omits;
+ GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
+
+ ber->priv->max_omits = omits;
}
static void
-gtranslator_berkeley_set_max_delta (GtranslatorTranslationMemory *tm,
+gtranslator_berkeley_set_max_delta (GtranslatorTranslationMemory * tm,
gsize delta)
{
- GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
-
- ber->priv->max_delta = delta;
+ GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
+
+ ber->priv->max_delta = delta;
}
static void
-gtranslator_berkeley_set_max_items (GtranslatorTranslationMemory *tm,
+gtranslator_berkeley_set_max_items (GtranslatorTranslationMemory * tm,
gint items)
{
- GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
-
- ber->priv->max_items = items;
+ GtranslatorBerkeley *ber = GTR_BERKELEY (tm);
+
+ ber->priv->max_items = items;
}
static void
-gtranslator_translation_memory_iface_init (GtranslatorTranslationMemoryIface *iface)
+gtranslator_translation_memory_iface_init (GtranslatorTranslationMemoryIface *
+ iface)
{
- iface->store = gtranslator_berkeley_store;
- iface->lookup = gtranslator_berkeley_lookup;
- iface->set_max_omits = gtranslator_berkeley_set_max_omits;
- iface->set_max_delta = gtranslator_berkeley_set_max_delta;
- iface->set_max_items = gtranslator_berkeley_set_max_items;
+ iface->store = gtranslator_berkeley_store;
+ iface->lookup = gtranslator_berkeley_lookup;
+ iface->set_max_omits = gtranslator_berkeley_set_max_omits;
+ iface->set_max_delta = gtranslator_berkeley_set_max_delta;
+ iface->set_max_items = gtranslator_berkeley_set_max_items;
}
static void
-gtranslator_berkeley_init (GtranslatorBerkeley *pf)
+gtranslator_berkeley_init (GtranslatorBerkeley * pf)
{
- pf->priv = GTR_BERKELEY_GET_PRIVATE (pf);
-
- pf->priv->orig = gtranslator_db_orig_new ();
- pf->priv->trans = gtranslator_db_trans_new ();
- pf->priv->words = gtranslator_db_words_new ();
- pf->priv->max_omits = 0;
- pf->priv->max_delta = 0;
- pf->priv->max_items = 0;
+ pf->priv = GTR_BERKELEY_GET_PRIVATE (pf);
+
+ pf->priv->orig = gtranslator_db_orig_new ();
+ pf->priv->trans = gtranslator_db_trans_new ();
+ pf->priv->words = gtranslator_db_words_new ();
+ pf->priv->max_omits = 0;
+ pf->priv->max_delta = 0;
+ pf->priv->max_items = 0;
}
static void
-gtranslator_berkeley_finalize (GObject *object)
+gtranslator_berkeley_finalize (GObject * object)
{
- GtranslatorBerkeley *ber = GTR_BERKELEY (object);
-
- g_object_unref (ber->priv->orig);
- g_object_unref (ber->priv->trans);
- g_object_unref (ber->priv->words);
-
- G_OBJECT_CLASS (gtranslator_berkeley_parent_class)->finalize (object);
+ GtranslatorBerkeley *ber = GTR_BERKELEY (object);
+
+ g_object_unref (ber->priv->orig);
+ g_object_unref (ber->priv->trans);
+ g_object_unref (ber->priv->words);
+
+ G_OBJECT_CLASS (gtranslator_berkeley_parent_class)->finalize (object);
}
static void
-gtranslator_berkeley_class_init (GtranslatorBerkeleyClass *klass)
+gtranslator_berkeley_class_init (GtranslatorBerkeleyClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorBerkeleyPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorBerkeleyPrivate));
- object_class->finalize = gtranslator_berkeley_finalize;
+ object_class->finalize = gtranslator_berkeley_finalize;
}
/**
@@ -629,10 +622,9 @@ gtranslator_berkeley_class_init (GtranslatorBerkeleyClass *klass)
GtranslatorBerkeley *
gtranslator_berkeley_new ()
{
- GtranslatorBerkeley *berkeley;
+ GtranslatorBerkeley *berkeley;
- berkeley = g_object_new (GTR_TYPE_BERKELEY, NULL);
-
- return berkeley;
-}
+ berkeley = g_object_new (GTR_TYPE_BERKELEY, NULL);
+ return berkeley;
+}
diff --git a/src/translation-memory/berkeley/berkeley.h b/src/translation-memory/berkeley/berkeley.h
index 3b1aaf4..a21ec83 100644
--- a/src/translation-memory/berkeley/berkeley.h
+++ b/src/translation-memory/berkeley/berkeley.h
@@ -23,7 +23,6 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -33,42 +32,42 @@ G_BEGIN_DECLS
#define GTR_IS_BERKELEY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_BERKELEY))
#define GTR_IS_BERKELEY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_BERKELEY))
#define GTR_BERKELEY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_BERKELEY, GtranslatorBerkeleyClass))
-
/* Private structure type */
-typedef struct _GtranslatorBerkeleyPrivate GtranslatorBerkeleyPrivate;
+typedef struct _GtranslatorBerkeleyPrivate GtranslatorBerkeleyPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorBerkeley GtranslatorBerkeley;
+typedef struct _GtranslatorBerkeley GtranslatorBerkeley;
struct _GtranslatorBerkeley
{
- GObject parent_instance;
-
- /*< private > */
- GtranslatorBerkeleyPrivate *priv;
+ GObject parent_instance;
+
+ /*< private > */
+ GtranslatorBerkeleyPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorBerkeleyClass GtranslatorBerkeleyClass;
+typedef struct _GtranslatorBerkeleyClass GtranslatorBerkeleyClass;
struct _GtranslatorBerkeleyClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_berkeley_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_berkeley_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_berkeley_register_type (GTypeModule * module);
+ GType gtranslator_berkeley_register_type (GTypeModule * module);
-GtranslatorBerkeley *gtranslator_berkeley_new (void);
+ GtranslatorBerkeley *gtranslator_berkeley_new (void);
G_END_DECLS
-
#endif /* __BERKELEY_H__ */
diff --git a/src/translation-memory/berkeley/db-base.c b/src/translation-memory/berkeley/db-base.c
index 3474741..69cac21 100644
--- a/src/translation-memory/berkeley/db-base.c
+++ b/src/translation-memory/berkeley/db-base.c
@@ -37,169 +37,158 @@
GTR_TYPE_DB_BASE, \
GtranslatorDbBasePrivate))
-G_DEFINE_TYPE(GtranslatorDbBase, gtranslator_db_base, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GtranslatorDbBase, gtranslator_db_base, G_TYPE_OBJECT)
+ struct _GtranslatorDbBasePrivate
+ {
+ DB *db;
+ gchar *path;
+ };
+
+ static gchar *get_db_base_directory ()
+{
+ gchar *config;
+ gchar *db_dir;
+ config = gtranslator_utils_get_user_config_dir ();
-struct _GtranslatorDbBasePrivate
-{
- DB *db;
- gchar *path;
-};
+ db_dir = g_build_filename (config, "berkeley", NULL);
+ g_free (config);
-static gchar *
-get_db_base_directory ()
-{
- gchar *config;
- gchar *db_dir;
-
- config = gtranslator_utils_get_user_config_dir ();
-
- db_dir = g_build_filename (config, "berkeley", NULL);
- g_free (config);
-
- if (!g_file_test (db_dir, G_FILE_TEST_IS_DIR))
+ if (!g_file_test (db_dir, G_FILE_TEST_IS_DIR))
+ {
+ GFile *file;
+ GError *error = NULL;
+
+ file = g_file_new_for_path (db_dir);
+
+ if (!g_file_make_directory (file, NULL, &error))
{
- GFile *file;
- GError *error = NULL;
-
- file = g_file_new_for_path (db_dir);
-
- if (!g_file_make_directory (file, NULL, &error))
- {
- g_warning ("There was an error making the gtranslator berkeley directory: %s",
- error->message);
-
- g_error_free (error);
- g_object_unref (file);
- g_free (db_dir);
- return NULL;
- }
-
- g_object_unref (file);
+ g_warning
+ ("There was an error making the gtranslator berkeley directory: %s",
+ error->message);
+
+ g_error_free (error);
+ g_object_unref (file);
+ g_free (db_dir);
+ return NULL;
}
-
- return db_dir;
+
+ g_object_unref (file);
+ }
+
+ return db_dir;
}
static void
-gtranslator_db_base_init (GtranslatorDbBase *base)
+gtranslator_db_base_init (GtranslatorDbBase * base)
{
- base->priv = GTR_DB_BASE_GET_PRIVATE (base);
-
- base->priv->path = NULL;
+ base->priv = GTR_DB_BASE_GET_PRIVATE (base);
+
+ base->priv->path = NULL;
}
static void
-gtranslator_db_base_finalize (GObject *object)
+gtranslator_db_base_finalize (GObject * object)
{
- GtranslatorDbBase *base = GTR_DB_BASE (object);
- int err;
-
- if ((err = base->priv->db->close(base->priv->db, 0)) != 0)
- gtranslator_db_base_show_error (base, err);
-
- g_free (base->priv->path);
-
- G_OBJECT_CLASS (gtranslator_db_base_parent_class)->finalize (object);
+ GtranslatorDbBase *base = GTR_DB_BASE (object);
+ int err;
+
+ if ((err = base->priv->db->close (base->priv->db, 0)) != 0)
+ gtranslator_db_base_show_error (base, err);
+
+ g_free (base->priv->path);
+
+ G_OBJECT_CLASS (gtranslator_db_base_parent_class)->finalize (object);
}
static void
-gtranslator_db_base_class_init (GtranslatorDbBaseClass *klass)
+gtranslator_db_base_class_init (GtranslatorDbBaseClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorDbBasePrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorDbBasePrivate));
- object_class->finalize = gtranslator_db_base_finalize;
+ object_class->finalize = gtranslator_db_base_finalize;
}
void
-gtranslator_db_base_create_dabatase (GtranslatorDbBase *base,
- const gchar *filename,
- DBTYPE type)
+gtranslator_db_base_create_dabatase (GtranslatorDbBase * base,
+ const gchar * filename, DBTYPE type)
{
- gint error;
- gchar *db_dir;
-
- g_return_if_fail (GTR_IS_DB_BASE (base));
-
- error = db_create(&base->priv->db, NULL, 0);
- if (error != 0)
- {
- gtranslator_db_base_show_error (base, error);
- return;
- }
-
- db_dir = get_db_base_directory ();
- base->priv->path = g_build_filename (db_dir, filename, NULL);
- g_free (db_dir);
-
- error = base->priv->db->open (base->priv->db,
- NULL,
- base->priv->path,
- NULL,
- type,
- DB_CREATE,
- 0);
-
- if (error != 0)
- {
- gtranslator_db_base_show_error (base, error);
- return;
- }
+ gint error;
+ gchar *db_dir;
+
+ g_return_if_fail (GTR_IS_DB_BASE (base));
+
+ error = db_create (&base->priv->db, NULL, 0);
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (base, error);
+ return;
+ }
+
+ db_dir = get_db_base_directory ();
+ base->priv->path = g_build_filename (db_dir, filename, NULL);
+ g_free (db_dir);
+
+ error = base->priv->db->open (base->priv->db,
+ NULL,
+ base->priv->path, NULL, type, DB_CREATE, 0);
+
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (base, error);
+ return;
+ }
}
void
-gtranslator_db_base_show_error (GtranslatorDbBase *base,
- int error)
+gtranslator_db_base_show_error (GtranslatorDbBase * base, int error)
{
- gchar *err = NULL;
- DB_ENV *env;
- gint e;
-
- switch (error)
+ gchar *err = NULL;
+ DB_ENV *env;
+ gint e;
+
+ switch (error)
+ {
+ case DB_NOTFOUND:
+ break;
+ case DB_RUNRECOVERY:
+ g_warning (_("Running recovery..."));
+
+ env = base->priv->db->get_env (base->priv->db);
+ e = env->open (env, base->priv->path, DB_RECOVER_FATAL, 0);
+
+ if (e != 0)
{
- case DB_NOTFOUND:
- break;
- case DB_RUNRECOVERY:
- g_warning (_("Running recovery..."));
-
- env = base->priv->db->get_env (base->priv->db);
- e = env->open (env, base->priv->path,
- DB_RECOVER_FATAL, 0);
-
- if (e != 0)
- {
- err = g_strdup_printf (_("There was an error recovering the database: %s"),
- db_strerror (e));
-
- g_warning ("%s", err);
- g_free (err);
- }
- break;
- default:
- err = g_strdup_printf (_("There was an error in database: %s"),
- db_strerror (error));
-
- g_warning ("%s", err);
- g_free (err);
- break;
+ err =
+ g_strdup_printf (_
+ ("There was an error recovering the database: %s"),
+ db_strerror (e));
+
+ g_warning ("%s", err);
+ g_free (err);
}
+ break;
+ default:
+ err = g_strdup_printf (_("There was an error in database: %s"),
+ db_strerror (error));
+
+ g_warning ("%s", err);
+ g_free (err);
+ break;
+ }
}
gint
-gtranslator_db_base_put (GtranslatorDbBase *base,
- DBT *key,
- DBT *data,
- u_int32_t flags)
+gtranslator_db_base_put (GtranslatorDbBase * base,
+ DBT * key, DBT * data, u_int32_t flags)
{
- return base->priv->db->put (base->priv->db, NULL, key, data, flags);
+ return base->priv->db->put (base->priv->db, NULL, key, data, flags);
}
gint
-gtranslator_db_base_get (GtranslatorDbBase *base,
- DBT *key,
- DBT *data)
+gtranslator_db_base_get (GtranslatorDbBase * base, DBT * key, DBT * data)
{
- return base->priv->db->get (base->priv->db, NULL, key, data, 0);
+ return base->priv->db->get (base->priv->db, NULL, key, data, 0);
}
diff --git a/src/translation-memory/berkeley/db-base.h b/src/translation-memory/berkeley/db-base.h
index 783d197..d7187d1 100644
--- a/src/translation-memory/berkeley/db-base.h
+++ b/src/translation-memory/berkeley/db-base.h
@@ -24,7 +24,6 @@
#include DB_HEADER
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -34,56 +33,53 @@ G_BEGIN_DECLS
#define GTR_IS_DB_BASE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DB_BASE))
#define GTR_IS_DB_BASE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DB_BASE))
#define GTR_DB_BASE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DB_BASE, GtranslatorDbBaseClass))
-
/* Private structure type */
-typedef struct _GtranslatorDbBasePrivate GtranslatorDbBasePrivate;
+typedef struct _GtranslatorDbBasePrivate GtranslatorDbBasePrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDbBase GtranslatorDbBase;
+typedef struct _GtranslatorDbBase GtranslatorDbBase;
struct _GtranslatorDbBase
{
- GObject parent_instance;
-
- /*< private > */
- GtranslatorDbBasePrivate *priv;
+ GObject parent_instance;
+
+ /*< private > */
+ GtranslatorDbBasePrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDbBaseClass GtranslatorDbBaseClass;
+typedef struct _GtranslatorDbBaseClass GtranslatorDbBaseClass;
struct _GtranslatorDbBaseClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_db_base_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_db_base_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_db_base_register_type (GTypeModule * module);
+ GType gtranslator_db_base_register_type (GTypeModule * module);
-void gtranslator_db_base_create_dabatase (GtranslatorDbBase *base,
- const gchar *filename,
- DBTYPE type);
-
-void gtranslator_db_base_show_error (GtranslatorDbBase *base,
- gint error);
-
-gint gtranslator_db_base_put (GtranslatorDbBase *base,
- DBT *key,
- DBT *data,
- u_int32_t flags);
-
-gint gtranslator_db_base_get (GtranslatorDbBase *base,
- DBT *key,
- DBT *data);
+ void gtranslator_db_base_create_dabatase (GtranslatorDbBase * base,
+ const gchar * filename,
+ DBTYPE type);
-G_END_DECLS
+ void gtranslator_db_base_show_error (GtranslatorDbBase * base,
+ gint error);
+ gint gtranslator_db_base_put (GtranslatorDbBase * base,
+ DBT * key, DBT * data, u_int32_t flags);
+
+ gint gtranslator_db_base_get (GtranslatorDbBase * base,
+ DBT * key, DBT * data);
+
+G_END_DECLS
#endif /* __DB_BASE_H__ */
diff --git a/src/translation-memory/berkeley/db-keys.c b/src/translation-memory/berkeley/db-keys.c
index 405dcda..817d916 100644
--- a/src/translation-memory/berkeley/db-keys.c
+++ b/src/translation-memory/berkeley/db-keys.c
@@ -36,39 +36,36 @@
GTR_TYPE_DB_KEYS, \
GtranslatorDbKeysPrivate))
-G_DEFINE_TYPE(GtranslatorDbKeys, gtranslator_db_keys, G_TYPE_OBJECT)
-
-
-struct _GtranslatorDbKeysPrivate
-{
- db_recno_t *list;
- gsize count;
-};
-
-static void
-gtranslator_db_keys_init (GtranslatorDbKeys *db_keys)
+G_DEFINE_TYPE (GtranslatorDbKeys, gtranslator_db_keys, G_TYPE_OBJECT)
+ struct _GtranslatorDbKeysPrivate
+ {
+ db_recno_t *list;
+ gsize count;
+ };
+
+ static void gtranslator_db_keys_init (GtranslatorDbKeys * db_keys)
{
- db_keys->priv = GTR_DB_KEYS_GET_PRIVATE (db_keys);
+ db_keys->priv = GTR_DB_KEYS_GET_PRIVATE (db_keys);
}
static void
-gtranslator_db_keys_finalize (GObject *object)
+gtranslator_db_keys_finalize (GObject * object)
{
- GtranslatorDbKeys *keys = GTR_DB_KEYS (object);
-
- g_free (keys->priv->list);
-
- G_OBJECT_CLASS (gtranslator_db_keys_parent_class)->finalize (object);
+ GtranslatorDbKeys *keys = GTR_DB_KEYS (object);
+
+ g_free (keys->priv->list);
+
+ G_OBJECT_CLASS (gtranslator_db_keys_parent_class)->finalize (object);
}
static void
-gtranslator_db_keys_class_init (GtranslatorDbKeysClass *klass)
+gtranslator_db_keys_class_init (GtranslatorDbKeysClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorDbKeysPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorDbKeysPrivate));
- object_class->finalize = gtranslator_db_keys_finalize;
+ object_class->finalize = gtranslator_db_keys_finalize;
}
/**
@@ -80,17 +77,17 @@ gtranslator_db_keys_class_init (GtranslatorDbKeysClass *klass)
* Returns: a new #GtranslatorDbKeys object
*/
GtranslatorDbKeys *
-gtranslator_db_keys_new (DBT *data)
+gtranslator_db_keys_new (DBT * data)
{
- GtranslatorDbKeys *db_keys;
-
- db_keys = g_object_new (GTR_TYPE_DB_KEYS, NULL);
-
- db_keys->priv->count = data->size / sizeof(db_recno_t);
- db_keys->priv->list = g_new (db_recno_t, db_keys->priv->count);
- memcpy (db_keys->priv->list, data->data, data->size);
-
- return db_keys;
+ GtranslatorDbKeys *db_keys;
+
+ db_keys = g_object_new (GTR_TYPE_DB_KEYS, NULL);
+
+ db_keys->priv->count = data->size / sizeof (db_recno_t);
+ db_keys->priv->list = g_new (db_recno_t, db_keys->priv->count);
+ memcpy (db_keys->priv->list, data->data, data->size);
+
+ return db_keys;
}
/**
@@ -104,14 +101,14 @@ gtranslator_db_keys_new (DBT *data)
GtranslatorDbKeys *
gtranslator_db_keys_new_with_size (gsize cnt)
{
- GtranslatorDbKeys *db_keys;
-
- db_keys = g_object_new (GTR_TYPE_DB_KEYS, NULL);
-
- db_keys->priv->list = g_new (db_recno_t, cnt);
- db_keys->priv->count = cnt;
-
- return db_keys;
+ GtranslatorDbKeys *db_keys;
+
+ db_keys = g_object_new (GTR_TYPE_DB_KEYS, NULL);
+
+ db_keys->priv->list = g_new (db_recno_t, cnt);
+ db_keys->priv->count = cnt;
+
+ return db_keys;
}
/**
@@ -123,11 +120,11 @@ gtranslator_db_keys_new_with_size (gsize cnt)
* Returns: the list of keys
*/
db_recno_t *
-gtranslator_db_keys_get_list (GtranslatorDbKeys *db_keys)
+gtranslator_db_keys_get_list (GtranslatorDbKeys * db_keys)
{
- g_return_val_if_fail (GTR_IS_DB_KEYS (db_keys), NULL);
-
- return db_keys->priv->list;
+ g_return_val_if_fail (GTR_IS_DB_KEYS (db_keys), NULL);
+
+ return db_keys->priv->list;
}
/**
@@ -139,18 +136,17 @@ gtranslator_db_keys_get_list (GtranslatorDbKeys *db_keys)
* Returns: the number of elements in the list
*/
gsize
-gtranslator_db_keys_get_count (GtranslatorDbKeys *db_keys)
+gtranslator_db_keys_get_count (GtranslatorDbKeys * db_keys)
{
- g_return_val_if_fail (GTR_IS_DB_KEYS (db_keys), 0);
-
- return db_keys->priv->count;
+ g_return_val_if_fail (GTR_IS_DB_KEYS (db_keys), 0);
+
+ return db_keys->priv->count;
}
void
-gtranslator_db_keys_set_count (GtranslatorDbKeys *db_keys,
- gsize count)
+gtranslator_db_keys_set_count (GtranslatorDbKeys * db_keys, gsize count)
{
- g_return_if_fail (GTR_IS_DB_KEYS (db_keys));
-
- db_keys->priv->count = count;
+ g_return_if_fail (GTR_IS_DB_KEYS (db_keys));
+
+ db_keys->priv->count = count;
}
diff --git a/src/translation-memory/berkeley/db-keys.h b/src/translation-memory/berkeley/db-keys.h
index a07b3e4..6dd7d34 100644
--- a/src/translation-memory/berkeley/db-keys.h
+++ b/src/translation-memory/berkeley/db-keys.h
@@ -24,7 +24,6 @@
#include DB_HEADER
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -34,51 +33,51 @@ G_BEGIN_DECLS
#define GTR_IS_DB_KEYS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DB_KEYS))
#define GTR_IS_DB_KEYS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DB_KEYS))
#define GTR_DB_KEYS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DB_KEYS, GtranslatorDbKeysClass))
-
/* Private structure type */
-typedef struct _GtranslatorDbKeysPrivate GtranslatorDbKeysPrivate;
+typedef struct _GtranslatorDbKeysPrivate GtranslatorDbKeysPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDbKeys GtranslatorDbKeys;
+typedef struct _GtranslatorDbKeys GtranslatorDbKeys;
struct _GtranslatorDbKeys
{
- GObject parent_instance;
-
- /*< private > */
- GtranslatorDbKeysPrivate *priv;
+ GObject parent_instance;
+
+ /*< private > */
+ GtranslatorDbKeysPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDbKeysClass GtranslatorDbKeysClass;
+typedef struct _GtranslatorDbKeysClass GtranslatorDbKeysClass;
struct _GtranslatorDbKeysClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_db_keys_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_db_keys_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_db_keys_register_type (GTypeModule * module);
+ GType gtranslator_db_keys_register_type (GTypeModule * module);
-GtranslatorDbKeys *gtranslator_db_keys_new (DBT *data);
+ GtranslatorDbKeys *gtranslator_db_keys_new (DBT * data);
-GtranslatorDbKeys *gtranslator_db_keys_new_with_size (gsize cnt);
+ GtranslatorDbKeys *gtranslator_db_keys_new_with_size (gsize cnt);
-db_recno_t *gtranslator_db_keys_get_list (GtranslatorDbKeys *db_keys);
+ db_recno_t *gtranslator_db_keys_get_list (GtranslatorDbKeys * db_keys);
-gsize gtranslator_db_keys_get_count (GtranslatorDbKeys *db_keys);
+ gsize gtranslator_db_keys_get_count (GtranslatorDbKeys * db_keys);
-void gtranslator_db_keys_set_count (GtranslatorDbKeys *db_keys,
- gsize count);
+ void gtranslator_db_keys_set_count (GtranslatorDbKeys * db_keys,
+ gsize count);
G_END_DECLS
-
#endif /* __DB_KEYS_H__ */
diff --git a/src/translation-memory/berkeley/db-orig.c b/src/translation-memory/berkeley/db-orig.c
index 11ce5e3..86e4097 100644
--- a/src/translation-memory/berkeley/db-orig.c
+++ b/src/translation-memory/berkeley/db-orig.c
@@ -35,38 +35,34 @@
GTR_TYPE_DB_ORIG, \
GtranslatorDbOrigPrivate))
-G_DEFINE_TYPE(GtranslatorDbOrig, gtranslator_db_orig, GTR_TYPE_DB_BASE)
+G_DEFINE_TYPE (GtranslatorDbOrig, gtranslator_db_orig, GTR_TYPE_DB_BASE)
+ struct _GtranslatorDbOrigPrivate
+ {
+ };
-struct _GtranslatorDbOrigPrivate
+ static void gtranslator_db_orig_init (GtranslatorDbOrig * db_orig)
{
+ //db_orig->priv = GTR_DB_ORIG_GET_PRIVATE (db_orig);
-};
-
-static void
-gtranslator_db_orig_init (GtranslatorDbOrig *db_orig)
-{
- //db_orig->priv = GTR_DB_ORIG_GET_PRIVATE (db_orig);
-
- gtranslator_db_base_create_dabatase (GTR_DB_BASE (db_orig),
- "original.db",
- DB_HASH);
+ gtranslator_db_base_create_dabatase (GTR_DB_BASE (db_orig),
+ "original.db", DB_HASH);
}
static void
-gtranslator_db_orig_finalize (GObject *object)
+gtranslator_db_orig_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_db_orig_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_db_orig_parent_class)->finalize (object);
}
static void
-gtranslator_db_orig_class_init (GtranslatorDbOrigClass *klass)
+gtranslator_db_orig_class_init (GtranslatorDbOrigClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- //g_type_class_add_private (klass, sizeof (GtranslatorDbOrigPrivate));
+ //g_type_class_add_private (klass, sizeof (GtranslatorDbOrigPrivate));
- object_class->finalize = gtranslator_db_orig_finalize;
+ object_class->finalize = gtranslator_db_orig_finalize;
}
/**
@@ -79,11 +75,11 @@ gtranslator_db_orig_class_init (GtranslatorDbOrigClass *klass)
GtranslatorDbOrig *
gtranslator_db_orig_new ()
{
- GtranslatorDbOrig *db_orig;
+ GtranslatorDbOrig *db_orig;
+
+ db_orig = g_object_new (GTR_TYPE_DB_ORIG, NULL);
- db_orig = g_object_new (GTR_TYPE_DB_ORIG, NULL);
-
- return db_orig;
+ return db_orig;
}
/**
@@ -98,31 +94,27 @@ gtranslator_db_orig_new ()
* Returns: TRUE if it was successfully stored.
*/
gboolean
-gtranslator_db_orig_write (GtranslatorDbOrig *orig,
- const gchar *string,
- db_recno_t value)
+gtranslator_db_orig_write (GtranslatorDbOrig * orig,
+ const gchar * string, db_recno_t value)
{
- DBT key, data;
- gint error;
-
- memset (&key, 0, sizeof (key));
- memset (&data, 0, sizeof (data));
- key.data = (gpointer) string;
- key.size = strlen (string);
- data.data = &value;
- data.size = sizeof (value);
-
- error = gtranslator_db_base_put (GTR_DB_BASE (orig),
- &key,
- &data,
- 0);
- if (error != 0)
- {
- gtranslator_db_base_show_error (GTR_DB_BASE (orig), error);
- return FALSE;
- }
-
- return TRUE;
+ DBT key, data;
+ gint error;
+
+ memset (&key, 0, sizeof (key));
+ memset (&data, 0, sizeof (data));
+ key.data = (gpointer) string;
+ key.size = strlen (string);
+ data.data = &value;
+ data.size = sizeof (value);
+
+ error = gtranslator_db_base_put (GTR_DB_BASE (orig), &key, &data, 0);
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (GTR_DB_BASE (orig), error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/**
@@ -136,26 +128,23 @@ gtranslator_db_orig_write (GtranslatorDbOrig *orig,
* Returns: the foreign key for #GtranslatorDbTrans
*/
db_recno_t
-gtranslator_db_orig_read (GtranslatorDbOrig *orig,
- const gchar *string)
+gtranslator_db_orig_read (GtranslatorDbOrig * orig, const gchar * string)
{
- DBT key, data;
- gint error;
-
- memset (&key, 0, sizeof (key));
- memset (&data, 0, sizeof (data));
- key.data = (gpointer)string;
- key.size = strlen (string);
-
- error = gtranslator_db_base_get (GTR_DB_BASE (orig),
- &key, &data);
- if (error != 0)
- {
- if (error != DB_NOTFOUND)
- gtranslator_db_base_show_error (GTR_DB_BASE (orig),
- error);
- return 0;
- }
-
- return *((db_recno_t*)data.data);
+ DBT key, data;
+ gint error;
+
+ memset (&key, 0, sizeof (key));
+ memset (&data, 0, sizeof (data));
+ key.data = (gpointer) string;
+ key.size = strlen (string);
+
+ error = gtranslator_db_base_get (GTR_DB_BASE (orig), &key, &data);
+ if (error != 0)
+ {
+ if (error != DB_NOTFOUND)
+ gtranslator_db_base_show_error (GTR_DB_BASE (orig), error);
+ return 0;
+ }
+
+ return *((db_recno_t *) data.data);
}
diff --git a/src/translation-memory/berkeley/db-orig.h b/src/translation-memory/berkeley/db-orig.h
index b6c49fc..4ba7118 100644
--- a/src/translation-memory/berkeley/db-orig.h
+++ b/src/translation-memory/berkeley/db-orig.h
@@ -24,7 +24,6 @@
#include "db-base.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -34,49 +33,49 @@ G_BEGIN_DECLS
#define GTR_IS_DB_ORIG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DB_ORIG))
#define GTR_IS_DB_ORIG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DB_ORIG))
#define GTR_DB_ORIG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DB_ORIG, GtranslatorDbOrigClass))
-
/* Private structure type */
-typedef struct _GtranslatorDbOrigPrivate GtranslatorDbOrigPrivate;
+typedef struct _GtranslatorDbOrigPrivate GtranslatorDbOrigPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDbOrig GtranslatorDbOrig;
+typedef struct _GtranslatorDbOrig GtranslatorDbOrig;
struct _GtranslatorDbOrig
{
- GtranslatorDbBase parent_instance;
-
- /*< private > */
- GtranslatorDbOrigPrivate *priv;
+ GtranslatorDbBase parent_instance;
+
+ /*< private > */
+ GtranslatorDbOrigPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDbOrigClass GtranslatorDbOrigClass;
+typedef struct _GtranslatorDbOrigClass GtranslatorDbOrigClass;
struct _GtranslatorDbOrigClass
{
- GtranslatorDbBaseClass parent_class;
+ GtranslatorDbBaseClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_db_orig_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_db_orig_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_db_orig_register_type (GTypeModule * module);
+ GType gtranslator_db_orig_register_type (GTypeModule * module);
-GtranslatorDbOrig *gtranslator_db_orig_new (void);
+ GtranslatorDbOrig *gtranslator_db_orig_new (void);
-gboolean gtranslator_db_orig_write (GtranslatorDbOrig *orig,
- const gchar *string,
- db_recno_t value);
-
-db_recno_t gtranslator_db_orig_read (GtranslatorDbOrig *orig,
- const gchar *string);
+ gboolean gtranslator_db_orig_write (GtranslatorDbOrig * orig,
+ const gchar * string,
+ db_recno_t value);
-G_END_DECLS
+ db_recno_t gtranslator_db_orig_read (GtranslatorDbOrig * orig,
+ const gchar * string);
+G_END_DECLS
#endif /* __DB_ORIG_H__ */
diff --git a/src/translation-memory/berkeley/db-trans.c b/src/translation-memory/berkeley/db-trans.c
index 152f88e..7bf542e 100644
--- a/src/translation-memory/berkeley/db-trans.c
+++ b/src/translation-memory/berkeley/db-trans.c
@@ -35,38 +35,34 @@
GTR_TYPE_DB_TRANS, \
GtranslatorDbTransPrivate))
-G_DEFINE_TYPE(GtranslatorDbTrans, gtranslator_db_trans, GTR_TYPE_DB_BASE)
+G_DEFINE_TYPE (GtranslatorDbTrans, gtranslator_db_trans, GTR_TYPE_DB_BASE)
+ struct _GtranslatorDbTransPrivate
+ {
+ };
-struct _GtranslatorDbTransPrivate
+ static void gtranslator_db_trans_init (GtranslatorDbTrans * db_trans)
{
+ //db_trans->priv = GTR_DB_TRANS_GET_PRIVATE (db_trans);
-};
-
-static void
-gtranslator_db_trans_init (GtranslatorDbTrans *db_trans)
-{
- //db_trans->priv = GTR_DB_TRANS_GET_PRIVATE (db_trans);
-
- gtranslator_db_base_create_dabatase (GTR_DB_BASE (db_trans),
- "translations.db",
- DB_RECNO);
+ gtranslator_db_base_create_dabatase (GTR_DB_BASE (db_trans),
+ "translations.db", DB_RECNO);
}
static void
-gtranslator_db_trans_finalize (GObject *object)
+gtranslator_db_trans_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_db_trans_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_db_trans_parent_class)->finalize (object);
}
static void
-gtranslator_db_trans_class_init (GtranslatorDbTransClass *klass)
+gtranslator_db_trans_class_init (GtranslatorDbTransClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- //g_type_class_add_private (klass, sizeof (GtranslatorDbTransPrivate));
+ //g_type_class_add_private (klass, sizeof (GtranslatorDbTransPrivate));
- object_class->finalize = gtranslator_db_trans_finalize;
+ object_class->finalize = gtranslator_db_trans_finalize;
}
/**
@@ -79,11 +75,11 @@ gtranslator_db_trans_class_init (GtranslatorDbTransClass *klass)
GtranslatorDbTrans *
gtranslator_db_trans_new ()
{
- GtranslatorDbTrans *db_trans;
+ GtranslatorDbTrans *db_trans;
+
+ db_trans = g_object_new (GTR_TYPE_DB_TRANS, NULL);
- db_trans = g_object_new (GTR_TYPE_DB_TRANS, NULL);
-
- return db_trans;
+ return db_trans;
}
/**
@@ -97,21 +93,20 @@ gtranslator_db_trans_new ()
* Returns: if @index is 0 then returns the new index, else returns @index
*/
db_recno_t
-gtranslator_db_trans_write_string (GtranslatorDbTrans *db_trans,
- const gchar *translation,
- db_recno_t key)
+gtranslator_db_trans_write_string (GtranslatorDbTrans * db_trans,
+ const gchar * translation, db_recno_t key)
{
- gchar *array[2];
- db_recno_t toret;
-
- array[0] = g_strdup (translation);
- array[1] = NULL;
-
- toret = gtranslator_db_trans_write (db_trans, array, key);
-
- g_free (array[0]);
-
- return toret;
+ gchar *array[2];
+ db_recno_t toret;
+
+ array[0] = g_strdup (translation);
+ array[1] = NULL;
+
+ toret = gtranslator_db_trans_write (db_trans, array, key);
+
+ g_free (array[0]);
+
+ return toret;
}
/**
@@ -125,83 +120,82 @@ gtranslator_db_trans_write_string (GtranslatorDbTrans *db_trans,
* Returns: if @index is 0 then returns the new index, else returns @index
*/
db_recno_t
-gtranslator_db_trans_write (GtranslatorDbTrans *db_trans,
- gchar **translations,
- db_recno_t index)
+gtranslator_db_trans_write (GtranslatorDbTrans * db_trans,
+ gchar ** translations, db_recno_t index)
{
- DBT key, data;
- gsize bufLen;
- gsize i;
- gint error = 0;
- gsize len;
- gint trans_len;
-
- trans_len = g_strv_length (translations);
-
- /*
- * Firstly we get buffer length to store:
- * - In the first position the number of strings
- * - then we store for each string: the length of the string
- * and the string.
- * Graphic: (trans_len)(string_len)----->(string_len)----->.....
- * ----> = string data
- */
- for (bufLen = 0, i = 0; i < trans_len; i++)
- {
- len = strlen (translations[i]);
- bufLen += sizeof (len) + len;
- }
- bufLen += sizeof (trans_len);
-
- /*
- * Now we create the buffer with the length I've got in the previous
- * iteration and I store in that buffer what I said before.
- */
- u_int8_t *p, buf[bufLen];
-
- p = &buf[0];
- memcpy (p, &trans_len, sizeof (trans_len));
- p += sizeof (trans_len);
-
- for (i = 0; i < g_strv_length (translations); i++)
- {
- len = strlen (translations[i]);
- memcpy (p, &len, sizeof (len));
- p += sizeof (len);
- memcpy (p, translations[i], len);
- p += len;
- }
-
- /*
- * Storing the buffer with the length in the that and after that
- * we try to store it in the database.
- * If there is a problem we show it.
- */
- memset (&key, 0, sizeof (key));
- memset (&data, 0, sizeof (data));
- data.data = buf;
- data.size = bufLen;
-
- if (index == 0)
- {
- error = gtranslator_db_base_put (GTR_DB_BASE (db_trans),
- &key, &data, DB_APPEND);
- }
- else
- {
- key.data = &index;
- key.size = sizeof (index);
-
- error = gtranslator_db_base_put (GTR_DB_BASE (db_trans),
- &key, &data, 0);
- }
-
- if (error != 0)
- {
- gtranslator_db_base_show_error (GTR_DB_BASE (db_trans), error);
- return 0;
- }
- return (index == 0) ? *((db_recno_t*)key.data) : index;
+ DBT key, data;
+ gsize bufLen;
+ gsize i;
+ gint error = 0;
+ gsize len;
+ gint trans_len;
+
+ trans_len = g_strv_length (translations);
+
+ /*
+ * Firstly we get buffer length to store:
+ * - In the first position the number of strings
+ * - then we store for each string: the length of the string
+ * and the string.
+ * Graphic: (trans_len)(string_len)----->(string_len)----->.....
+ * ----> = string data
+ */
+ for (bufLen = 0, i = 0; i < trans_len; i++)
+ {
+ len = strlen (translations[i]);
+ bufLen += sizeof (len) + len;
+ }
+ bufLen += sizeof (trans_len);
+
+ /*
+ * Now we create the buffer with the length I've got in the previous
+ * iteration and I store in that buffer what I said before.
+ */
+ u_int8_t *p, buf[bufLen];
+
+ p = &buf[0];
+ memcpy (p, &trans_len, sizeof (trans_len));
+ p += sizeof (trans_len);
+
+ for (i = 0; i < g_strv_length (translations); i++)
+ {
+ len = strlen (translations[i]);
+ memcpy (p, &len, sizeof (len));
+ p += sizeof (len);
+ memcpy (p, translations[i], len);
+ p += len;
+ }
+
+ /*
+ * Storing the buffer with the length in the that and after that
+ * we try to store it in the database.
+ * If there is a problem we show it.
+ */
+ memset (&key, 0, sizeof (key));
+ memset (&data, 0, sizeof (data));
+ data.data = buf;
+ data.size = bufLen;
+
+ if (index == 0)
+ {
+ error = gtranslator_db_base_put (GTR_DB_BASE (db_trans),
+ &key, &data, DB_APPEND);
+ }
+ else
+ {
+ key.data = &index;
+ key.size = sizeof (index);
+
+ error = gtranslator_db_base_put (GTR_DB_BASE (db_trans),
+ &key, &data, 0);
+ }
+
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (GTR_DB_BASE (db_trans), error);
+ return 0;
+ }
+ return (index == 0) ? *((db_recno_t *) key.data) : index;
}
/**
@@ -214,64 +208,62 @@ gtranslator_db_trans_write (GtranslatorDbTrans *db_trans,
* The caller must free the #GPtrArray.
*/
GPtrArray *
-gtranslator_db_trans_read (GtranslatorDbTrans *db_trans,
- db_recno_t index)
+gtranslator_db_trans_read (GtranslatorDbTrans * db_trans, db_recno_t index)
{
- DBT key, data;
- gint error;
- GPtrArray *gparray;
- gint bufLen;
- u_int8_t *p;
- u_int8_t *buf;
- gint i =0;
-
- memset (&key, 0, sizeof (key));
- memset (&data, 0, sizeof (data));
- key.data = &index;
- key.size = sizeof (index);
-
- /*
- * We get the data from the key
- */
- error = gtranslator_db_base_get (GTR_DB_BASE (db_trans),
- &key, &data);
- if (error != 0)
- {
- gtranslator_db_base_show_error (GTR_DB_BASE (db_trans), error);
- return NULL;
- }
-
- /*
- * Once we have the data we have to parse the byte array
- * and store it in our GPtrArray
- */
- gparray = g_ptr_array_new ();
-
- buf = data.data;
-
- p = &buf[0];
- memcpy (&bufLen, p, sizeof (bufLen));
- p += sizeof (bufLen);
-
- while (i < bufLen)
- {
- gsize len;
- gchar *data;
-
- memcpy (&len, p, sizeof (len));
- p += sizeof (len);
-
- data = g_malloc (len+1);
- memcpy (data, p, len);
- p += len;
- data[len] = '\0';
-
- g_ptr_array_add (gparray, (gpointer)data);
-
- i++;
- }
-
- g_ptr_array_add (gparray, NULL);
-
- return gparray;
+ DBT key, data;
+ gint error;
+ GPtrArray *gparray;
+ gint bufLen;
+ u_int8_t *p;
+ u_int8_t *buf;
+ gint i = 0;
+
+ memset (&key, 0, sizeof (key));
+ memset (&data, 0, sizeof (data));
+ key.data = &index;
+ key.size = sizeof (index);
+
+ /*
+ * We get the data from the key
+ */
+ error = gtranslator_db_base_get (GTR_DB_BASE (db_trans), &key, &data);
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (GTR_DB_BASE (db_trans), error);
+ return NULL;
+ }
+
+ /*
+ * Once we have the data we have to parse the byte array
+ * and store it in our GPtrArray
+ */
+ gparray = g_ptr_array_new ();
+
+ buf = data.data;
+
+ p = &buf[0];
+ memcpy (&bufLen, p, sizeof (bufLen));
+ p += sizeof (bufLen);
+
+ while (i < bufLen)
+ {
+ gsize len;
+ gchar *data;
+
+ memcpy (&len, p, sizeof (len));
+ p += sizeof (len);
+
+ data = g_malloc (len + 1);
+ memcpy (data, p, len);
+ p += len;
+ data[len] = '\0';
+
+ g_ptr_array_add (gparray, (gpointer) data);
+
+ i++;
+ }
+
+ g_ptr_array_add (gparray, NULL);
+
+ return gparray;
}
diff --git a/src/translation-memory/berkeley/db-trans.h b/src/translation-memory/berkeley/db-trans.h
index fc272a7..c9bbdc7 100644
--- a/src/translation-memory/berkeley/db-trans.h
+++ b/src/translation-memory/berkeley/db-trans.h
@@ -24,7 +24,6 @@
#include "db-base.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -34,55 +33,54 @@ G_BEGIN_DECLS
#define GTR_IS_DB_TRANS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DB_TRANS))
#define GTR_IS_DB_TRANS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DB_TRANS))
#define GTR_DB_TRANS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DB_TRANS, GtranslatorDbTransClass))
-
/* Private structure type */
-typedef struct _GtranslatorDbTransPrivate GtranslatorDbTransPrivate;
+typedef struct _GtranslatorDbTransPrivate GtranslatorDbTransPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDbTrans GtranslatorDbTrans;
+typedef struct _GtranslatorDbTrans GtranslatorDbTrans;
struct _GtranslatorDbTrans
{
- GtranslatorDbBase parent_instance;
-
- /*< private > */
- GtranslatorDbTransPrivate *priv;
+ GtranslatorDbBase parent_instance;
+
+ /*< private > */
+ GtranslatorDbTransPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDbTransClass GtranslatorDbTransClass;
+typedef struct _GtranslatorDbTransClass GtranslatorDbTransClass;
struct _GtranslatorDbTransClass
{
- GtranslatorDbBaseClass parent_class;
+ GtranslatorDbBaseClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_db_trans_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_db_trans_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_db_trans_register_type (GTypeModule * module);
+ GType gtranslator_db_trans_register_type (GTypeModule * module);
-GtranslatorDbTrans *gtranslator_db_trans_new (void);
+ GtranslatorDbTrans *gtranslator_db_trans_new (void);
-db_recno_t gtranslator_db_trans_write_string (GtranslatorDbTrans *db_trans,
- const gchar *translation,
- db_recno_t key);
+ db_recno_t gtranslator_db_trans_write_string (GtranslatorDbTrans *
+ db_trans,
+ const gchar * translation,
+ db_recno_t key);
-db_recno_t gtranslator_db_trans_write (GtranslatorDbTrans *db_trans,
- gchar **translations,
- db_recno_t index);
-
-GPtrArray *gtranslator_db_trans_read (GtranslatorDbTrans *db_trans,
- db_recno_t index);
+ db_recno_t gtranslator_db_trans_write (GtranslatorDbTrans * db_trans,
+ gchar ** translations,
+ db_recno_t index);
-G_END_DECLS
+ GPtrArray *gtranslator_db_trans_read (GtranslatorDbTrans * db_trans,
+ db_recno_t index);
+G_END_DECLS
#endif /* __DB_TRANS_H__ */
-
-
diff --git a/src/translation-memory/berkeley/db-words.c b/src/translation-memory/berkeley/db-words.c
index 810d3fb..c8696dd 100644
--- a/src/translation-memory/berkeley/db-words.c
+++ b/src/translation-memory/berkeley/db-words.c
@@ -36,173 +36,162 @@
GTR_TYPE_DB_WORDS, \
GtranslatorDbWordsPrivate))
-G_DEFINE_TYPE(GtranslatorDbWords, gtranslator_db_words, GTR_TYPE_DB_BASE)
+G_DEFINE_TYPE (GtranslatorDbWords, gtranslator_db_words, GTR_TYPE_DB_BASE)
+ struct _GtranslatorDbWordsPrivate
+ {
+ };
-struct _GtranslatorDbWordsPrivate
+ static void gtranslator_db_words_init (GtranslatorDbWords * db_words)
{
+ //db_words->priv = GTR_DB_WORDS_GET_PRIVATE (db_words);
-};
-
-static void
-gtranslator_db_words_init (GtranslatorDbWords *db_words)
-{
- //db_words->priv = GTR_DB_WORDS_GET_PRIVATE (db_words);
-
- gtranslator_db_base_create_dabatase (GTR_DB_BASE (db_words),
- "words.db",
- DB_HASH);
+ gtranslator_db_base_create_dabatase (GTR_DB_BASE (db_words),
+ "words.db", DB_HASH);
}
static void
-gtranslator_db_words_finalize (GObject *object)
+gtranslator_db_words_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_db_words_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_db_words_parent_class)->finalize (object);
}
static void
-gtranslator_db_words_class_init (GtranslatorDbWordsClass *klass)
+gtranslator_db_words_class_init (GtranslatorDbWordsClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- //g_type_class_add_private (klass, sizeof (GtranslatorDbWordsPrivate));
+ //g_type_class_add_private (klass, sizeof (GtranslatorDbWordsPrivate));
- object_class->finalize = gtranslator_db_words_finalize;
+ object_class->finalize = gtranslator_db_words_finalize;
}
GtranslatorDbWords *
gtranslator_db_words_new ()
{
- GtranslatorDbWords *db_words;
+ GtranslatorDbWords *db_words;
+
+ db_words = g_object_new (GTR_TYPE_DB_WORDS, NULL);
- db_words = g_object_new (GTR_TYPE_DB_WORDS, NULL);
-
- return db_words;
+ return db_words;
}
gboolean
-gtranslator_db_words_append (GtranslatorDbWords *db_words,
- const gchar *word,
- guint sentence_size,
- db_recno_t value)
+gtranslator_db_words_append (GtranslatorDbWords * db_words,
+ const gchar * word,
+ guint sentence_size, db_recno_t value)
{
- // VS: there is a dirty trick: it is always true that 'value' is
- // greater than all values already present in the db, so we may
- // append it to the end of list while still keeping the list sorted.
- // This is important because it allows us to efficiently merge
- // these lists when looking up inexact translations...
-
- DBT key, data;
- gsize len;
- gsize buf_len;
- GtranslatorDbKeys *keys;
- db_recno_t *value_buf = NULL;
- gint error = 0;
-
- /*
- * (sentence_size)(len)(word)
- */
- len = strlen (word);
- buf_len = sizeof (sentence_size) + sizeof (len) + len;
-
- //g_warning ("DEBUG: Append: %d|%d|%d|%s", sizeof (sentence_size), sizeof (len), len, word);
-
- //FIXME: use glib
- u_int8_t *p, buf[buf_len];
-
- p = &buf[0];
- memcpy (p, &sentence_size, sizeof (sentence_size));
- p += sizeof (sentence_size);
- memcpy (p, &len, sizeof (len));
- p += sizeof (len);
- memcpy (p, word, len);
-
- memset(&key, 0, sizeof(key));
- memset(&data, 0, sizeof(data));
- key.data = buf;
- key.size = buf_len;
-
- keys = gtranslator_db_words_read (db_words, word, sentence_size);
- if (keys == NULL)
- {
- data.data = &value;
- data.size = sizeof(value);
- }
- else
- {
- gsize count = gtranslator_db_keys_get_count (keys);
- db_recno_t *list = gtranslator_db_keys_get_list (keys);
-
- value_buf = g_new (db_recno_t, count + 1);
- memcpy(value_buf, list, count * sizeof (db_recno_t));
- value_buf[count] = value;
- data.data = value_buf;
- data.size = (count + 1) * sizeof(db_recno_t);
-
- g_object_unref (keys);
- }
-
- error = gtranslator_db_base_put (GTR_DB_BASE (db_words),
- &key,
- &data,
- 0);
- g_free (value_buf);
-
- if (error != 0)
- {
- gtranslator_db_base_show_error (GTR_DB_BASE (db_words), error);
- return FALSE;
- }
-
- return TRUE;
+ // VS: there is a dirty trick: it is always true that 'value' is
+ // greater than all values already present in the db, so we may
+ // append it to the end of list while still keeping the list sorted.
+ // This is important because it allows us to efficiently merge
+ // these lists when looking up inexact translations...
+
+ DBT key, data;
+ gsize len;
+ gsize buf_len;
+ GtranslatorDbKeys *keys;
+ db_recno_t *value_buf = NULL;
+ gint error = 0;
+
+ /*
+ * (sentence_size)(len)(word)
+ */
+ len = strlen (word);
+ buf_len = sizeof (sentence_size) + sizeof (len) + len;
+
+ //g_warning ("DEBUG: Append: %d|%d|%d|%s", sizeof (sentence_size), sizeof (len), len, word);
+
+ //FIXME: use glib
+ u_int8_t *p, buf[buf_len];
+
+ p = &buf[0];
+ memcpy (p, &sentence_size, sizeof (sentence_size));
+ p += sizeof (sentence_size);
+ memcpy (p, &len, sizeof (len));
+ p += sizeof (len);
+ memcpy (p, word, len);
+
+ memset (&key, 0, sizeof (key));
+ memset (&data, 0, sizeof (data));
+ key.data = buf;
+ key.size = buf_len;
+
+ keys = gtranslator_db_words_read (db_words, word, sentence_size);
+ if (keys == NULL)
+ {
+ data.data = &value;
+ data.size = sizeof (value);
+ }
+ else
+ {
+ gsize count = gtranslator_db_keys_get_count (keys);
+ db_recno_t *list = gtranslator_db_keys_get_list (keys);
+
+ value_buf = g_new (db_recno_t, count + 1);
+ memcpy (value_buf, list, count * sizeof (db_recno_t));
+ value_buf[count] = value;
+ data.data = value_buf;
+ data.size = (count + 1) * sizeof (db_recno_t);
+
+ g_object_unref (keys);
+ }
+
+ error = gtranslator_db_base_put (GTR_DB_BASE (db_words), &key, &data, 0);
+ g_free (value_buf);
+
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (GTR_DB_BASE (db_words), error);
+ return FALSE;
+ }
+
+ return TRUE;
}
GtranslatorDbKeys *
-gtranslator_db_words_read (GtranslatorDbWords *db_words,
- const gchar *word,
- guint sentence_size)
+gtranslator_db_words_read (GtranslatorDbWords * db_words,
+ const gchar * word, guint sentence_size)
{
- DBT key, data;
- gsize len;
- gsize buf_len;
- GtranslatorDbKeys *keys;
- gint error = 0;
-
- /*
- * (sentence_size)(len)(word)
- */
- len = strlen (word);
- buf_len = sizeof (sentence_size) + sizeof (len) + len;
- //g_warning ("DEBUG: Read: %d|%d|%d|%s", sizeof (sentence_size), sizeof (len), len, word);
- /*
- * Here we recreate the key and then with that key we get the list
- * of keys
- */
- //FIXME: use glib
- u_int8_t *p, buf[buf_len];
-
- p = &buf[0];
- memcpy (p, &sentence_size, sizeof (sentence_size));
- p += sizeof (sentence_size);
- memcpy (p, &len, sizeof (len));
- p += sizeof (len);
- memcpy (p, word, len);
-
- memset (&key, 0, sizeof (key));
- memset (&data, 0, sizeof (data));
- key.data = buf;
- key.size = buf_len;
-
- error = gtranslator_db_base_get (GTR_DB_BASE (db_words),
- &key,
- &data);
- if (error != 0)
- {
- gtranslator_db_base_show_error (GTR_DB_BASE (db_words), error);
- return NULL;
- }
-
- keys = gtranslator_db_keys_new (&data);
-
- return keys;
+ DBT key, data;
+ gsize len;
+ gsize buf_len;
+ GtranslatorDbKeys *keys;
+ gint error = 0;
+
+ /*
+ * (sentence_size)(len)(word)
+ */
+ len = strlen (word);
+ buf_len = sizeof (sentence_size) + sizeof (len) + len;
+ //g_warning ("DEBUG: Read: %d|%d|%d|%s", sizeof (sentence_size), sizeof (len), len, word);
+ /*
+ * Here we recreate the key and then with that key we get the list
+ * of keys
+ */
+ //FIXME: use glib
+ u_int8_t *p, buf[buf_len];
+
+ p = &buf[0];
+ memcpy (p, &sentence_size, sizeof (sentence_size));
+ p += sizeof (sentence_size);
+ memcpy (p, &len, sizeof (len));
+ p += sizeof (len);
+ memcpy (p, word, len);
+
+ memset (&key, 0, sizeof (key));
+ memset (&data, 0, sizeof (data));
+ key.data = buf;
+ key.size = buf_len;
+
+ error = gtranslator_db_base_get (GTR_DB_BASE (db_words), &key, &data);
+ if (error != 0)
+ {
+ gtranslator_db_base_show_error (GTR_DB_BASE (db_words), error);
+ return NULL;
+ }
+
+ keys = gtranslator_db_keys_new (&data);
+
+ return keys;
}
diff --git a/src/translation-memory/berkeley/db-words.h b/src/translation-memory/berkeley/db-words.h
index f584a28..259da30 100644
--- a/src/translation-memory/berkeley/db-words.h
+++ b/src/translation-memory/berkeley/db-words.h
@@ -25,7 +25,6 @@
#include "db-keys.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,51 +34,52 @@ G_BEGIN_DECLS
#define GTR_IS_DB_WORDS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DB_WORDS))
#define GTR_IS_DB_WORDS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DB_WORDS))
#define GTR_DB_WORDS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DB_WORDS, GtranslatorDbWordsClass))
-
/* Private structure type */
-typedef struct _GtranslatorDbWordsPrivate GtranslatorDbWordsPrivate;
+typedef struct _GtranslatorDbWordsPrivate GtranslatorDbWordsPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorDbWords GtranslatorDbWords;
+typedef struct _GtranslatorDbWords GtranslatorDbWords;
struct _GtranslatorDbWords
{
- GtranslatorDbBase parent_instance;
-
- /*< private > */
- GtranslatorDbWordsPrivate *priv;
+ GtranslatorDbBase parent_instance;
+
+ /*< private > */
+ GtranslatorDbWordsPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorDbWordsClass GtranslatorDbWordsClass;
+typedef struct _GtranslatorDbWordsClass GtranslatorDbWordsClass;
struct _GtranslatorDbWordsClass
{
- GtranslatorDbBaseClass parent_class;
+ GtranslatorDbBaseClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_db_words_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_db_words_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_db_words_register_type (GTypeModule * module);
+ GType gtranslator_db_words_register_type (GTypeModule * module);
-GtranslatorDbWords *gtranslator_db_words_new (void);
+ GtranslatorDbWords *gtranslator_db_words_new (void);
-gboolean gtranslator_db_words_append (GtranslatorDbWords *db_words,
- const gchar *word,
- guint sentence_size,
- db_recno_t value);
-
-GtranslatorDbKeys *gtranslator_db_words_read (GtranslatorDbWords *db_words,
- const gchar *word,
- guint sentence_size);
+ gboolean gtranslator_db_words_append (GtranslatorDbWords * db_words,
+ const gchar * word,
+ guint sentence_size,
+ db_recno_t value);
-G_END_DECLS
+ GtranslatorDbKeys *gtranslator_db_words_read (GtranslatorDbWords *
+ db_words,
+ const gchar * word,
+ guint sentence_size);
+G_END_DECLS
#endif /* __DB_WORDS_H__ */
diff --git a/src/translation-memory/translation-memory-ui.c b/src/translation-memory/translation-memory-ui.c
index 5b0db98..da32a16 100644
--- a/src/translation-memory/translation-memory-ui.c
+++ b/src/translation-memory/translation-memory-ui.c
@@ -44,31 +44,31 @@
GTR_TYPE_TRANSLATION_MEMORY_UI, \
GtranslatorTranslationMemoryUiPrivate))
-G_DEFINE_TYPE(GtranslatorTranslationMemoryUi, gtranslator_translation_memory_ui, GTK_TYPE_SCROLLED_WINDOW)
-
-struct _GtranslatorTranslationMemoryUiPrivate
-{
- GtkWidget *tree_view;
- GtranslatorTab *tab;
-
- gchar **tm_list;
-};
-
-enum {
- SHORTCUT_COLUMN,
- LEVEL_COLUMN,
- STRING_COLUMN,
- N_COLUMNS
-};
-
-static void
-tree_view_size_cb (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer user_data);
-
-static void
-on_activate_item_cb (GtkMenuItem *menuitem,
- GtranslatorTranslationMemoryUi *tm_ui)
+G_DEFINE_TYPE (GtranslatorTranslationMemoryUi,
+ gtranslator_translation_memory_ui, GTK_TYPE_SCROLLED_WINDOW)
+ struct _GtranslatorTranslationMemoryUiPrivate
+ {
+ GtkWidget *tree_view;
+ GtranslatorTab *tab;
+
+ gchar **tm_list;
+ };
+
+ enum
+ {
+ SHORTCUT_COLUMN,
+ LEVEL_COLUMN,
+ STRING_COLUMN,
+ N_COLUMNS
+ };
+
+ static void
+ tree_view_size_cb (GtkWidget * widget,
+ GtkAllocation * allocation, gpointer user_data);
+
+ static void
+ on_activate_item_cb (GtkMenuItem * menuitem,
+ GtranslatorTranslationMemoryUi * tm_ui)
{
GtranslatorView *view;
GtkTextBuffer *buffer;
@@ -79,7 +79,7 @@ on_activate_item_cb (GtkMenuItem *menuitem,
GtranslatorWindow *window;
window = gtranslator_application_get_active_window (GTR_APP);
-
+
view = gtranslator_window_get_active_view (window);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -91,32 +91,30 @@ on_activate_item_cb (GtkMenuItem *menuitem,
current_msg = gtranslator_po_get_current_message (po);
msg = GTR_MSG (current_msg->data);
-
- gtranslator_msg_set_msgstr (msg, tm_ui->priv->tm_list[index-1]);
+
+ gtranslator_msg_set_msgstr (msg, tm_ui->priv->tm_list[index - 1]);
gtk_text_buffer_begin_user_action (buffer);
- gtk_text_buffer_set_text (buffer,
- tm_ui->priv->tm_list[index-1],
- -1);
- gtk_text_buffer_end_user_action(buffer);
+ gtk_text_buffer_set_text (buffer, tm_ui->priv->tm_list[index - 1], -1);
+ gtk_text_buffer_end_user_action (buffer);
gtranslator_po_set_state (po, GTR_PO_STATE_MODIFIED);
}
static void
-free_list (gpointer data,
- gpointer useless)
+free_list (gpointer data, gpointer useless)
{
- GtranslatorTranslationMemoryMatch *match = (GtranslatorTranslationMemoryMatch *)data;
-
- g_free (match->match);
- g_free (match);
+ GtranslatorTranslationMemoryMatch *match =
+ (GtranslatorTranslationMemoryMatch *) data;
+
+ g_free (match->match);
+ g_free (match);
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorTranslationMemoryUi *tm_ui)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg,
+ GtranslatorTranslationMemoryUi * tm_ui)
{
GtranslatorTranslationMemory *tm;
GtkListStore *model;
@@ -136,236 +134,236 @@ showed_message_cb (GtranslatorTab *tab,
GtkUIManager *manager;
gchar *item_name;
- model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (tm_ui->priv->tree_view)));
-
+ model =
+ GTK_LIST_STORE (gtk_tree_view_get_model
+ (GTK_TREE_VIEW (tm_ui->priv->tree_view)));
+
window = gtranslator_application_get_active_window (GTR_APP);
tm_menu = gtranslator_window_get_tm_menu (window);
g_signal_connect (tm_ui->priv->tree_view,
- "size_allocate",
- G_CALLBACK (tree_view_size_cb),
- tm_ui->priv->tree_view);
-
+ "size_allocate",
+ G_CALLBACK (tree_view_size_cb), tm_ui->priv->tree_view);
+
msgid = gtranslator_msg_get_msgid (msg);
-
- tm = GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory (GTR_APP));
-
+
+ tm =
+ GTR_TRANSLATION_MEMORY (gtranslator_application_get_translation_memory
+ (GTR_APP));
+
tm_list = gtranslator_translation_memory_lookup (tm, msgid);
-
- if (tm_list == NULL) {
- gtk_widget_set_sensitive (tm_menu, FALSE);
- } else {
- gtk_widget_set_sensitive (tm_menu, TRUE);
- }
-
+
+ if (tm_list == NULL)
+ {
+ gtk_widget_set_sensitive (tm_menu, FALSE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (tm_menu, TRUE);
+ }
+
gtk_list_store_clear (model);
g_strfreev (tm_ui->priv->tm_list);
tm_ui->priv->tm_list = g_new (gchar *, MAX_ELEMENTS + 1);
-
- for (l = tm_list; l; l = l->next) {
- GtranslatorTranslationMemoryMatch *match;
- match = (GtranslatorTranslationMemoryMatch *)l->data;
- tm_ui->priv->tm_list[i-1] = g_strdup (match->match);
- level_column = gtk_tree_view_get_column (GTK_TREE_VIEW (tm_ui->priv->tree_view), 0);
- renderers_list = gtk_tree_view_column_get_cell_renderers (level_column);
-
- g_object_set (renderers_list->data,
- "accel-mods", GDK_CONTROL_MASK,
- NULL);
- g_list_free (renderers_list);
-
- gtk_list_store_append (model, &iter);
- gtk_list_store_set (model,
- &iter,
- SHORTCUT_COLUMN,
- GDK_0+k,
- STRING_COLUMN,
- match->match,
- LEVEL_COLUMN,
- match->level,
- -1);
- i++;
- k++;
- if (k == MAX_ELEMENTS)
- break;
- }
+
+ for (l = tm_list; l; l = l->next)
+ {
+ GtranslatorTranslationMemoryMatch *match;
+ match = (GtranslatorTranslationMemoryMatch *) l->data;
+ tm_ui->priv->tm_list[i - 1] = g_strdup (match->match);
+ level_column =
+ gtk_tree_view_get_column (GTK_TREE_VIEW (tm_ui->priv->tree_view), 0);
+ renderers_list = gtk_tree_view_column_get_cell_renderers (level_column);
+
+ g_object_set (renderers_list->data,
+ "accel-mods", GDK_CONTROL_MASK, NULL);
+ g_list_free (renderers_list);
+
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model,
+ &iter,
+ SHORTCUT_COLUMN,
+ GDK_0 + k,
+ STRING_COLUMN,
+ match->match, LEVEL_COLUMN, match->level, -1);
+ i++;
+ k++;
+ if (k == MAX_ELEMENTS)
+ break;
+ }
/* Ensure last element is NULL */
- tm_ui->priv->tm_list[i-1] = NULL;
-
+ tm_ui->priv->tm_list[i - 1] = NULL;
+
/* MenuBar stuff */
-
- items_menu = gtk_menu_new();
-
+
+ items_menu = gtk_menu_new ();
+
manager = gtranslator_window_get_ui_manager (window);
-
+
gtk_menu_set_accel_group (GTK_MENU (items_menu),
- gtk_ui_manager_get_accel_group(manager));
-
- do{
- gchar *accel_path;
-
- item_name = g_strdup_printf (_("Insert Option nº %d"), j);
-
- tm_item = gtk_menu_item_new_with_label (item_name);
- g_object_set_data (G_OBJECT (tm_item), "option", GINT_TO_POINTER (j));
- gtk_widget_show (tm_item);
-
- accel_path = g_strdup_printf ("<Gtranslator-sheet>/Edit/_Translation Memory/%s", item_name);
-
- gtk_menu_item_set_accel_path (GTK_MENU_ITEM (tm_item), accel_path);
- gtk_accel_map_add_entry (accel_path, GDK_0+(j-1), GDK_CONTROL_MASK);
-
+ gtk_ui_manager_get_accel_group (manager));
+
+ do
+ {
+ gchar *accel_path;
+
+ item_name = g_strdup_printf (_("Insert Option nº %d"), j);
+
+ tm_item = gtk_menu_item_new_with_label (item_name);
+ g_object_set_data (G_OBJECT (tm_item), "option", GINT_TO_POINTER (j));
+ gtk_widget_show (tm_item);
+
+ accel_path =
+ g_strdup_printf ("<Gtranslator-sheet>/Edit/_Translation Memory/%s",
+ item_name);
+
+ gtk_menu_item_set_accel_path (GTK_MENU_ITEM (tm_item), accel_path);
+ gtk_accel_map_add_entry (accel_path, GDK_0 + (j - 1), GDK_CONTROL_MASK);
+
g_free (accel_path);
g_free (item_name);
-
+
g_signal_connect (tm_item, "activate",
- G_CALLBACK (on_activate_item_cb),
- tm_ui);
-
+ G_CALLBACK (on_activate_item_cb), tm_ui);
+
gtk_menu_shell_append (GTK_MENU_SHELL (items_menu), tm_item);
-
+
j++;
if (j > MAX_ELEMENTS)
break;
-
- }while ((tm_list = g_list_next (tm_list)));
-
+
+ }
+ while ((tm_list = g_list_next (tm_list)));
+
gtk_menu_item_set_submenu (GTK_MENU_ITEM (tm_menu), items_menu);
-
+
/* Freeing the list */
- g_list_foreach (tm_list, (GFunc)free_list, NULL);
+ g_list_foreach (tm_list, (GFunc) free_list, NULL);
g_list_free (tm_list);
}
static void
-tree_view_size_cb (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer user_data)
+tree_view_size_cb (GtkWidget * widget,
+ GtkAllocation * allocation, gpointer user_data)
{
- GtkTreeView *treeview;
- GtkTreeViewColumn *column;
- GList *renderers_list = NULL;
- gint size;
-
- treeview = GTK_TREE_VIEW (user_data);
-
- column = gtk_tree_view_get_column (treeview, 2);
- renderers_list = gtk_tree_view_column_get_cell_renderers (column);
-
- size = gtk_tree_view_column_get_width (column);
-
- g_object_set (renderers_list->data,
- "wrap-width", size-10,
- NULL);
-
- g_list_free (renderers_list);
+ GtkTreeView *treeview;
+ GtkTreeViewColumn *column;
+ GList *renderers_list = NULL;
+ gint size;
+
+ treeview = GTK_TREE_VIEW (user_data);
+
+ column = gtk_tree_view_get_column (treeview, 2);
+ renderers_list = gtk_tree_view_column_get_cell_renderers (column);
+
+ size = gtk_tree_view_column_get_width (column);
+
+ g_object_set (renderers_list->data, "wrap-width", size - 10, NULL);
+
+ g_list_free (renderers_list);
}
static void
-gtranslator_translation_memory_ui_draw(GtranslatorTranslationMemoryUi *tm_ui)
+gtranslator_translation_memory_ui_draw (GtranslatorTranslationMemoryUi *
+ tm_ui)
{
- GtranslatorTranslationMemoryUiPrivate *priv = tm_ui->priv;
- GtkListStore *model;
- GtkCellRenderer *level_renderer, *string_renderer, *shortcut_renderer;
- GtkTreeViewColumn *shortcut, *string, *level;
-
- priv->tree_view = gtk_tree_view_new();
- gtk_widget_show (priv->tree_view);
-
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tm_ui),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- model = gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), GTK_TREE_MODEL (model));
-
- shortcut_renderer = gtk_cell_renderer_accel_new ();
- shortcut = gtk_tree_view_column_new_with_attributes (_("Shortcut"),
- shortcut_renderer,
- "accel-key", SHORTCUT_COLUMN,
- NULL);
- g_object_set (shortcut_renderer,
- "width", 80,
- NULL);
-
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), shortcut);
-
- level_renderer = gtk_cell_renderer_progress_new ();
- level = gtk_tree_view_column_new_with_attributes (_("Level"),
- level_renderer,
- "value", LEVEL_COLUMN,
- NULL);
- g_object_set (level_renderer,
- "width", 80,
- NULL);
-
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), level);
-
- string_renderer = gtk_cell_renderer_text_new ();
- string = gtk_tree_view_column_new_with_attributes (_("String"),
- string_renderer,
- "text", STRING_COLUMN,
- NULL);
- gtk_tree_view_column_set_sizing (string,
- GTK_TREE_VIEW_COLUMN_FIXED);
-
- g_object_set (string_renderer,
- "ypad", 0,
- "xpad", 5,
- "yalign", 0.0,
- "wrap-mode", PANGO_WRAP_WORD_CHAR,
- NULL);
-
- gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), string);
+ GtranslatorTranslationMemoryUiPrivate *priv = tm_ui->priv;
+ GtkListStore *model;
+ GtkCellRenderer *level_renderer, *string_renderer, *shortcut_renderer;
+ GtkTreeViewColumn *shortcut, *string, *level;
+
+ priv->tree_view = gtk_tree_view_new ();
+ gtk_widget_show (priv->tree_view);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tm_ui),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ model =
+ gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view),
+ GTK_TREE_MODEL (model));
+
+ shortcut_renderer = gtk_cell_renderer_accel_new ();
+ shortcut = gtk_tree_view_column_new_with_attributes (_("Shortcut"),
+ shortcut_renderer,
+ "accel-key",
+ SHORTCUT_COLUMN, NULL);
+ g_object_set (shortcut_renderer, "width", 80, NULL);
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), shortcut);
+
+ level_renderer = gtk_cell_renderer_progress_new ();
+ level = gtk_tree_view_column_new_with_attributes (_("Level"),
+ level_renderer,
+ "value", LEVEL_COLUMN,
+ NULL);
+ g_object_set (level_renderer, "width", 80, NULL);
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), level);
+
+ string_renderer = gtk_cell_renderer_text_new ();
+ string = gtk_tree_view_column_new_with_attributes (_("String"),
+ string_renderer,
+ "text", STRING_COLUMN,
+ NULL);
+ gtk_tree_view_column_set_sizing (string, GTK_TREE_VIEW_COLUMN_FIXED);
+
+ g_object_set (string_renderer,
+ "ypad", 0,
+ "xpad", 5,
+ "yalign", 0.0, "wrap-mode", PANGO_WRAP_WORD_CHAR, NULL);
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), string);
}
static void
-gtranslator_translation_memory_ui_init (GtranslatorTranslationMemoryUi *tm_ui)
+gtranslator_translation_memory_ui_init (GtranslatorTranslationMemoryUi *
+ tm_ui)
{
- tm_ui->priv = GTR_TRANSLATION_MEMORY_UI_GET_PRIVATE (tm_ui);
- tm_ui->priv->tm_list = NULL;
-
- gtranslator_translation_memory_ui_draw (tm_ui);
+ tm_ui->priv = GTR_TRANSLATION_MEMORY_UI_GET_PRIVATE (tm_ui);
+ tm_ui->priv->tm_list = NULL;
+
+ gtranslator_translation_memory_ui_draw (tm_ui);
}
static void
-gtranslator_translation_memory_ui_finalize (GObject *object)
+gtranslator_translation_memory_ui_finalize (GObject * object)
{
- GtranslatorTranslationMemoryUi *tm_ui = GTR_TRANSLATION_MEMORY_UI (object);
-
- g_strfreev (tm_ui->priv->tm_list);
-
- G_OBJECT_CLASS (gtranslator_translation_memory_ui_parent_class)->finalize (object);
+ GtranslatorTranslationMemoryUi *tm_ui = GTR_TRANSLATION_MEMORY_UI (object);
+
+ g_strfreev (tm_ui->priv->tm_list);
+
+ G_OBJECT_CLASS (gtranslator_translation_memory_ui_parent_class)->
+ finalize (object);
}
static void
-gtranslator_translation_memory_ui_class_init (GtranslatorTranslationMemoryUiClass *klass)
+gtranslator_translation_memory_ui_class_init
+ (GtranslatorTranslationMemoryUiClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorTranslationMemoryUiPrivate));
+ g_type_class_add_private (klass,
+ sizeof (GtranslatorTranslationMemoryUiPrivate));
- object_class->finalize = gtranslator_translation_memory_ui_finalize;
+ object_class->finalize = gtranslator_translation_memory_ui_finalize;
}
GtkWidget *
-gtranslator_translation_memory_ui_new (GtkWidget *tab)
+gtranslator_translation_memory_ui_new (GtkWidget * tab)
{
- GtranslatorTranslationMemoryUi *tm_ui;
- tm_ui = g_object_new (GTR_TYPE_TRANSLATION_MEMORY_UI, NULL);
-
- tm_ui->priv->tab = GTR_TAB(tab);
- 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);
-
- return GTK_WIDGET(tm_ui);
+ GtranslatorTranslationMemoryUi *tm_ui;
+ tm_ui = g_object_new (GTR_TYPE_TRANSLATION_MEMORY_UI, NULL);
+
+ tm_ui->priv->tab = GTR_TAB (tab);
+ 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);
+
+ return GTK_WIDGET (tm_ui);
}
diff --git a/src/translation-memory/translation-memory-ui.h b/src/translation-memory/translation-memory-ui.h
index 6ab1a5e..e527424 100644
--- a/src/translation-memory/translation-memory-ui.h
+++ b/src/translation-memory/translation-memory-ui.h
@@ -26,52 +26,54 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
#define GTR_TYPE_TRANSLATION_MEMORY_UI (gtranslator_translation_memory_ui_get_type ())
#define GTR_TRANSLATION_MEMORY_UI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_TRANSLATION_MEMORY_UI, GtranslatorTranslationMemoryUi))
#define GTR_TRANSLATION_MEMORY_UI_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_TRANSLATION_MEMORY_UI, GtranslatorTranslationMemoryUiClass))
-#define GTR_IS_TRANSLATION_MEMORY_UI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_TRANSLATION_MEMORY_UI))
+#define GTR_IS_TRANSLATION_MEMORY_UI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_TRANSLATION_MEMORY_UI))
#define GTR_IS_TRANSLATION_MEMORY_UI_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_TRANSLATION_MEMORY_UI))
#define GTR_TRANSLATION_MEMORY_UI_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_TRANSLATION_MEMORY_UI, GtranslatorTranslationMemoryUiClass))
-
/* Private structure type */
-typedef struct _GtranslatorTranslationMemoryUiPrivate GtranslatorTranslationMemoryUiPrivate;
+typedef struct _GtranslatorTranslationMemoryUiPrivate
+ GtranslatorTranslationMemoryUiPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorTranslationMemoryUi GtranslatorTranslationMemoryUi;
+typedef struct _GtranslatorTranslationMemoryUi GtranslatorTranslationMemoryUi;
struct _GtranslatorTranslationMemoryUi
{
- GtkScrolledWindow parent_instance;
-
- /*< private > */
- GtranslatorTranslationMemoryUiPrivate *priv;
+ GtkScrolledWindow parent_instance;
+
+ /*< private > */
+ GtranslatorTranslationMemoryUiPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorTranslationMemoryUiClass GtranslatorTranslationMemoryUiClass;
+typedef struct _GtranslatorTranslationMemoryUiClass
+ GtranslatorTranslationMemoryUiClass;
struct _GtranslatorTranslationMemoryUiClass
{
- GtkScrolledWindowClass parent_class;
+ GtkScrolledWindowClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_translation_memory_ui_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_translation_memory_ui_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_translation_memory_ui_register_type (GTypeModule * module);
+ GType gtranslator_translation_memory_ui_register_type (GTypeModule *
+ module);
-GtkWidget *gtranslator_translation_memory_ui_new (GtkWidget *tab);
+ GtkWidget *gtranslator_translation_memory_ui_new (GtkWidget * tab);
G_END_DECLS
-
#endif /* __TRANSLATION_MEMORY_UI_H__ */
diff --git a/src/translation-memory/translation-memory.c b/src/translation-memory/translation-memory.c
index 2025138..149790a 100644
--- a/src/translation-memory/translation-memory.c
+++ b/src/translation-memory/translation-memory.c
@@ -26,21 +26,22 @@
* Stores the @original and @translation strings in the database.
*/
gboolean
-gtranslator_translation_memory_store (GtranslatorTranslationMemory *obj,
- const gchar *original,
- const gchar *translation)
+gtranslator_translation_memory_store (GtranslatorTranslationMemory * obj,
+ const gchar * original,
+ const gchar * translation)
{
- g_return_val_if_fail (GTR_IS_TRANSLATION_MEMORY (obj), FALSE);
- return GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->store (obj, original, translation);
+ g_return_val_if_fail (GTR_IS_TRANSLATION_MEMORY (obj), FALSE);
+ return GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->store (obj, original,
+ translation);
}
/* Default implementation */
static gboolean
-gtranslator_translation_memory_store_default (GtranslatorTranslationMemory *obj,
- const gchar *original,
- const gchar *translation)
+gtranslator_translation_memory_store_default (GtranslatorTranslationMemory *
+ obj, const gchar * original,
+ const gchar * translation)
{
- g_return_val_if_reached (FALSE);
+ g_return_val_if_reached (FALSE);
}
/**
@@ -53,19 +54,19 @@ gtranslator_translation_memory_store_default (GtranslatorTranslationMemory *obj,
* Returns: a list of #GtranslatorTranslationMemoryMatch.
*/
GList *
-gtranslator_translation_memory_lookup (GtranslatorTranslationMemory *obj,
- const gchar *phrase)
+gtranslator_translation_memory_lookup (GtranslatorTranslationMemory * obj,
+ const gchar * phrase)
{
- g_return_val_if_fail (GTR_IS_TRANSLATION_MEMORY (obj), 0);
- return GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->lookup (obj, phrase);
+ g_return_val_if_fail (GTR_IS_TRANSLATION_MEMORY (obj), 0);
+ return GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->lookup (obj, phrase);
}
/* Default implementation */
static GList *
-gtranslator_translation_memory_lookup_default (GtranslatorTranslationMemory *obj,
- const gchar *phrase)
+gtranslator_translation_memory_lookup_default (GtranslatorTranslationMemory *
+ obj, const gchar * phrase)
{
- g_return_val_if_reached (0);
+ g_return_val_if_reached (0);
}
/**
@@ -75,19 +76,19 @@ gtranslator_translation_memory_lookup_default (GtranslatorTranslationMemory *obj
* Sets the number of omits used in the search.
*/
void
-gtranslator_translation_memory_set_max_omits (GtranslatorTranslationMemory *obj,
- gsize omits)
+gtranslator_translation_memory_set_max_omits (GtranslatorTranslationMemory *
+ obj, gsize omits)
{
- g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
- GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_omits (obj, omits);
+ g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
+ GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_omits (obj, omits);
}
/* Default implementation */
static void
-gtranslator_translation_memory_set_max_omits_default (GtranslatorTranslationMemory *obj,
- gsize omits)
+gtranslator_translation_memory_set_max_omits_default
+ (GtranslatorTranslationMemory * obj, gsize omits)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
/**
@@ -97,19 +98,19 @@ gtranslator_translation_memory_set_max_omits_default (GtranslatorTranslationMemo
* Sets the difference in the length of string for searching in the database.
*/
void
-gtranslator_translation_memory_set_max_delta (GtranslatorTranslationMemory *obj,
- gsize delta)
+gtranslator_translation_memory_set_max_delta (GtranslatorTranslationMemory *
+ obj, gsize delta)
{
- g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
- GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_delta (obj, delta);
+ g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
+ GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_delta (obj, delta);
}
/* Default implementation */
static void
-gtranslator_translation_memory_set_max_delta_default (GtranslatorTranslationMemory *obj,
- gsize omits)
+gtranslator_translation_memory_set_max_delta_default
+ (GtranslatorTranslationMemory * obj, gsize omits)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
/**
@@ -119,56 +120,61 @@ gtranslator_translation_memory_set_max_delta_default (GtranslatorTranslationMemo
* Sets the number of item to return in gtranslator_translation_memory_lookup().
*/
void
-gtranslator_translation_memory_set_max_items (GtranslatorTranslationMemory *obj,
- gint items)
+gtranslator_translation_memory_set_max_items (GtranslatorTranslationMemory *
+ obj, gint items)
{
- g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
- GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_items (obj, items);
+ g_return_if_fail (GTR_IS_TRANSLATION_MEMORY (obj));
+ GTR_TRANSLATION_MEMORY_GET_IFACE (obj)->set_max_items (obj, items);
}
/* Default implementation */
static void
-gtranslator_translation_memory_set_max_items_default (GtranslatorTranslationMemory *obj,
- gint items)
+gtranslator_translation_memory_set_max_items_default
+ (GtranslatorTranslationMemory * obj, gint items)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
static void
-gtranslator_translation_memory_base_init (GtranslatorTranslationMemoryIface* klass)
+gtranslator_translation_memory_base_init (GtranslatorTranslationMemoryIface *
+ klass)
{
- static gboolean initialized = FALSE;
-
- klass->store = gtranslator_translation_memory_store_default;
- klass->lookup = gtranslator_translation_memory_lookup_default;
- klass->set_max_omits = gtranslator_translation_memory_set_max_omits_default;
- klass->set_max_delta = gtranslator_translation_memory_set_max_delta_default;
- klass->set_max_items = gtranslator_translation_memory_set_max_items_default;
-
- if (!initialized) {
-
- initialized = TRUE;
- }
+ static gboolean initialized = FALSE;
+
+ klass->store = gtranslator_translation_memory_store_default;
+ klass->lookup = gtranslator_translation_memory_lookup_default;
+ klass->set_max_omits = gtranslator_translation_memory_set_max_omits_default;
+ klass->set_max_delta = gtranslator_translation_memory_set_max_delta_default;
+ klass->set_max_items = gtranslator_translation_memory_set_max_items_default;
+
+ if (!initialized)
+ {
+
+ initialized = TRUE;
+ }
}
GType
gtranslator_translation_memory_get_type (void)
{
- static GType type = 0;
- if (!type) {
- static const GTypeInfo info = {
- sizeof (GtranslatorTranslationMemoryIface),
- (GBaseInitFunc) gtranslator_translation_memory_base_init,
- NULL,
- NULL,
- NULL,
- NULL,
- 0,
- 0,
- NULL
- };
- type = g_type_register_static (G_TYPE_INTERFACE, "GtranslatorTranslationMemory", &info, 0);
- g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
- }
- return type;
+ static GType type = 0;
+ if (!type)
+ {
+ static const GTypeInfo info = {
+ sizeof (GtranslatorTranslationMemoryIface),
+ (GBaseInitFunc) gtranslator_translation_memory_base_init,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+ type =
+ g_type_register_static (G_TYPE_INTERFACE,
+ "GtranslatorTranslationMemory", &info, 0);
+ g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+ }
+ return type;
}
diff --git a/src/translation-memory/translation-memory.h b/src/translation-memory/translation-memory.h
index aef719c..a19bdee 100644
--- a/src/translation-memory/translation-memory.h
+++ b/src/translation-memory/translation-memory.h
@@ -21,56 +21,55 @@
#include <glib-object.h>
G_BEGIN_DECLS
-
#define GTR_TYPE_TRANSLATION_MEMORY (gtranslator_translation_memory_get_type ())
#define GTR_TRANSLATION_MEMORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTR_TYPE_TRANSLATION_MEMORY, GtranslatorTranslationMemory))
#define GTR_IS_TRANSLATION_MEMORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTR_TYPE_TRANSLATION_MEMORY))
#define GTR_TRANSLATION_MEMORY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTR_TYPE_TRANSLATION_MEMORY, GtranslatorTranslationMemoryIface))
-
typedef struct _GtranslatorTranslationMemory GtranslatorTranslationMemory;
-typedef struct _GtranslatorTranslationMemoryIface GtranslatorTranslationMemoryIface;
+typedef struct _GtranslatorTranslationMemoryIface
+ GtranslatorTranslationMemoryIface;
+
+struct _GtranslatorTranslationMemoryIface
+{
+ GTypeInterface g_iface;
-struct _GtranslatorTranslationMemoryIface {
- GTypeInterface g_iface;
-
- gboolean (*store) (GtranslatorTranslationMemory *obj,
- const gchar *original,
- const gchar *translation);
- GList * (*lookup) (GtranslatorTranslationMemory *obj,
- const gchar *phrase);
- void (*set_max_omits) (GtranslatorTranslationMemory *obj,
- gsize omits);
- void (*set_max_delta) (GtranslatorTranslationMemory *obj,
- gsize delta);
- void (*set_max_items) (GtranslatorTranslationMemory *obj,
- gint items);
+ gboolean (*store) (GtranslatorTranslationMemory * obj,
+ const gchar * original, const gchar * translation);
+ GList *(*lookup) (GtranslatorTranslationMemory * obj, const gchar * phrase);
+ void (*set_max_omits) (GtranslatorTranslationMemory * obj, gsize omits);
+ void (*set_max_delta) (GtranslatorTranslationMemory * obj, gsize delta);
+ void (*set_max_items) (GtranslatorTranslationMemory * obj, gint items);
};
-typedef struct _GtranslatorTranslationMemoryMatch GtranslatorTranslationMemoryMatch;
-struct _GtranslatorTranslationMemoryMatch {
- gchar *match;
- gint level;
+typedef struct _GtranslatorTranslationMemoryMatch
+ GtranslatorTranslationMemoryMatch;
+struct _GtranslatorTranslationMemoryMatch
+{
+ gchar *match;
+ gint level;
};
-GType gtranslator_translation_memory_get_type (void);
+GType gtranslator_translation_memory_get_type (void);
-gboolean gtranslator_translation_memory_store (GtranslatorTranslationMemory *obj,
- const gchar *original,
- const gchar *translation);
-
-GList * gtranslator_translation_memory_lookup (GtranslatorTranslationMemory *obj,
- const gchar *phrase);
+gboolean gtranslator_translation_memory_store (GtranslatorTranslationMemory *
+ obj, const gchar * original,
+ const gchar * translation);
-void gtranslator_translation_memory_set_max_omits (GtranslatorTranslationMemory *obj,
- gsize omits);
+GList *gtranslator_translation_memory_lookup (GtranslatorTranslationMemory *
+ obj, const gchar * phrase);
-void gtranslator_translation_memory_set_max_delta (GtranslatorTranslationMemory *obj,
- gsize delta);
+void
+gtranslator_translation_memory_set_max_omits (GtranslatorTranslationMemory *
+ obj, gsize omits);
-void gtranslator_translation_memory_set_max_items (GtranslatorTranslationMemory *obj,
- gint items);
+void
+gtranslator_translation_memory_set_max_delta (GtranslatorTranslationMemory *
+ obj, gsize delta);
-G_END_DECLS
+void
+gtranslator_translation_memory_set_max_items (GtranslatorTranslationMemory *
+ obj, gint items);
+G_END_DECLS
#endif
diff --git a/src/utils.c b/src/utils.c
index b556c82..00bf9a8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -36,52 +36,51 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-static const gchar * badwords[]=
-{
- "a",
- //"all",
- "an",
- //"are",
- //"can",
- //"for",
- //"from",
- "have",
- //"it",
- //"may",
- //"not",
- "of",
- //"that",
- "the",
- //"this",
- //"was",
- "will",
- //"with",
- //"you",
- //"your",
- NULL
+static const gchar *badwords[] = {
+ "a",
+ //"all",
+ "an",
+ //"are",
+ //"can",
+ //"for",
+ //"from",
+ "have",
+ //"it",
+ //"may",
+ //"not",
+ "of",
+ //"that",
+ "the",
+ //"this",
+ //"was",
+ "will",
+ //"with",
+ //"you",
+ //"your",
+ NULL
};
static gboolean
-check_good_word (const gchar *word, gchar **badwords)
+check_good_word (const gchar * word, gchar ** badwords)
{
- gboolean check = TRUE;
- gchar *lower = g_utf8_strdown (word, -1);
- gint i = 0;
-
- while (badwords[i] != NULL)
+ gboolean check = TRUE;
+ gchar *lower = g_utf8_strdown (word, -1);
+ gint i = 0;
+
+ while (badwords[i] != NULL)
+ {
+ gchar *lower_collate = g_utf8_collate_key (lower, -1);
+
+ if (strcmp (lower_collate, badwords[i]) == 0)
{
- gchar *lower_collate = g_utf8_collate_key (lower, -1);
-
- if (strcmp (lower_collate, badwords[i]) == 0)
- {
- check = FALSE;
- g_free (lower_collate);
- break;
- }
- i++;
- g_free (lower_collate);
+ check = FALSE;
+ g_free (lower_collate);
+ break;
}
- return check;
+ i++;
+ g_free (lower_collate);
+ }
+ return check;
}
/**
@@ -93,84 +92,80 @@ check_good_word (const gchar *word, gchar **badwords)
* Returns: an array of words of the processed text
*/
gchar **
-gtranslator_utils_split_string_in_words (const gchar *string)
+gtranslator_utils_split_string_in_words (const gchar * string)
{
- PangoLanguage *lang = pango_language_from_string ("en");
- PangoLogAttr *attrs;
- GPtrArray *array;
- gint char_len;
- gint i = 0;
- gchar *s;
- static gchar **badwords_collate = NULL;
-
- if (badwords_collate == NULL)
+ PangoLanguage *lang = pango_language_from_string ("en");
+ PangoLogAttr *attrs;
+ GPtrArray *array;
+ gint char_len;
+ gint i = 0;
+ gchar *s;
+ static gchar **badwords_collate = NULL;
+
+ if (badwords_collate == NULL)
+ {
+ gint words_size = g_strv_length ((gchar **) badwords);
+ gint x = 0;
+
+ badwords_collate = g_new0 (gchar *, words_size + 1);
+
+ while (badwords[x] != NULL)
{
- gint words_size = g_strv_length ((gchar **)badwords);
- gint x = 0;
-
- badwords_collate = g_new0 (gchar *, words_size + 1);
-
- while (badwords[x] != NULL)
- {
- badwords_collate[x] = g_utf8_collate_key (badwords[x], -1);
- x++;
- }
- badwords_collate[x] = NULL;
+ badwords_collate[x] = g_utf8_collate_key (badwords[x], -1);
+ x++;
}
+ badwords_collate[x] = NULL;
+ }
- char_len = g_utf8_strlen (string, -1);
- attrs = g_new (PangoLogAttr, char_len + 1);
-
- pango_get_log_attrs (string,
- strlen (string),
- -1,
- lang,
- attrs,
- char_len + 1);
-
- array = g_ptr_array_new ();
-
- s = (gchar *)string;
- while (i <= char_len)
+ char_len = g_utf8_strlen (string, -1);
+ attrs = g_new (PangoLogAttr, char_len + 1);
+
+ pango_get_log_attrs (string,
+ strlen (string), -1, lang, attrs, char_len + 1);
+
+ array = g_ptr_array_new ();
+
+ s = (gchar *) string;
+ while (i <= char_len)
+ {
+ gchar *start, *end;
+
+ if (attrs[i].is_word_start)
+ start = s;
+ if (attrs[i].is_word_end)
{
- gchar *start, *end;
-
- if (attrs[i].is_word_start)
- start = s;
- if (attrs[i].is_word_end)
- {
- gchar *word;
-
- end = s;
- word = g_strndup (start, end - start);
-
- if (check_good_word (word, badwords_collate))
- g_ptr_array_add (array, word);
- }
+ gchar *word;
+
+ end = s;
+ word = g_strndup (start, end - start);
- i++;
- s = g_utf8_next_char (s);
+ if (check_good_word (word, badwords_collate))
+ g_ptr_array_add (array, word);
}
-
- g_free (attrs);
- g_ptr_array_add (array, NULL);
-
- return (gchar **)g_ptr_array_free (array, FALSE);
+
+ i++;
+ s = g_utf8_next_char (s);
+ }
+
+ g_free (attrs);
+ g_ptr_array_add (array, NULL);
+
+ return (gchar **) g_ptr_array_free (array, FALSE);
}
-xmlDocPtr
-gtranslator_xml_new_doc (const gchar *name)
+xmlDocPtr
+gtranslator_xml_new_doc (const gchar * name)
{
- xmlNodePtr root;
- xmlDocPtr doc;
- doc = xmlNewDoc ("1.0");
- root = xmlNewDocNode (doc, NULL, name, NULL);
- xmlDocSetRootElement (doc, root);
- return doc;
+ xmlNodePtr root;
+ xmlDocPtr doc;
+ doc = xmlNewDoc ("1.0");
+ root = xmlNewDocNode (doc, NULL, name, NULL);
+ xmlDocSetRootElement (doc, root);
+ return doc;
}
-xmlDocPtr
-gtranslator_xml_open_file (const gchar *filename)
+xmlDocPtr
+gtranslator_xml_open_file (const gchar * filename)
{
xmlDocPtr doc;
g_return_val_if_fail (filename != NULL, NULL);
@@ -188,17 +183,17 @@ gtranslator_xml_open_file (const gchar *filename)
* Returns: a new #GtkButton
*/
GtkWidget *
-gtranslator_gtk_button_new_with_stock_icon (const gchar *label,
- const gchar *stock_id)
+gtranslator_gtk_button_new_with_stock_icon (const gchar * label,
+ const gchar * stock_id)
{
- GtkWidget *button;
+ 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));
+ 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));
- return button;
+ return button;
}
/**
@@ -212,30 +207,30 @@ gtranslator_gtk_button_new_with_stock_icon (const gchar *label,
* It returns the position to popup a menu in a specific widget.
*/
void
-gtranslator_utils_menu_position_under_widget (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+gtranslator_utils_menu_position_under_widget (GtkMenu * menu,
+ gint * x,
+ gint * y,
+ gboolean * push_in,
+ gpointer user_data)
{
- GtkWidget *w = GTK_WIDGET (user_data);
- GtkRequisition requisition;
+ GtkWidget *w = GTK_WIDGET (user_data);
+ GtkRequisition requisition;
- gdk_window_get_origin (w->window, x, y);
- gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
+ gdk_window_get_origin (w->window, x, y);
+ gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
- if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
- {
- *x += w->allocation.x + w->allocation.width - requisition.width;
- }
- else
- {
- *x += w->allocation.x;
- }
+ if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
+ {
+ *x += w->allocation.x + w->allocation.width - requisition.width;
+ }
+ else
+ {
+ *x += w->allocation.x;
+ }
- *y += w->allocation.y + w->allocation.height;
+ *y += w->allocation.y + w->allocation.height;
- *push_in = TRUE;
+ *push_in = TRUE;
}
/**
@@ -249,81 +244,78 @@ gtranslator_utils_menu_position_under_widget (GtkMenu *menu,
* It returns the position to popup a menu in a TreeView.
*/
void
-gtranslator_utils_menu_position_under_tree_view (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
+gtranslator_utils_menu_position_under_tree_view (GtkMenu * menu,
+ gint * x,
+ gint * y,
+ gboolean * push_in,
+ gpointer user_data)
{
- GtkTreeView *tree = GTK_TREE_VIEW (user_data);
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- model = gtk_tree_view_get_model (tree);
- g_return_if_fail (model != NULL);
-
- selection = gtk_tree_view_get_selection (tree);
- g_return_if_fail (selection != NULL);
-
- if (gtk_tree_selection_get_selected (selection, NULL, &iter))
- {
- GtkTreePath *path;
- GdkRectangle rect;
-
- gdk_window_get_origin (GTK_WIDGET (tree)->window, x, y);
-
- path = gtk_tree_model_get_path (model, &iter);
- gtk_tree_view_get_cell_area (tree, path,
- gtk_tree_view_get_column (tree, 0), /* FIXME 0 for RTL ? */
- &rect);
- gtk_tree_path_free (path);
-
- *x += rect.x;
- *y += rect.y + rect.height;
-
- if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL)
- {
- GtkRequisition requisition;
- gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
- *x += rect.width - requisition.width;
- }
- }
- else
+ GtkTreeView *tree = GTK_TREE_VIEW (user_data);
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+
+ model = gtk_tree_view_get_model (tree);
+ g_return_if_fail (model != NULL);
+
+ selection = gtk_tree_view_get_selection (tree);
+ g_return_if_fail (selection != NULL);
+
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ GtkTreePath *path;
+ GdkRectangle rect;
+
+ gdk_window_get_origin (GTK_WIDGET (tree)->window, x, y);
+
+ path = gtk_tree_model_get_path (model, &iter);
+ gtk_tree_view_get_cell_area (tree, path, gtk_tree_view_get_column (tree, 0), /* FIXME 0 for RTL ? */
+ &rect);
+ gtk_tree_path_free (path);
+
+ *x += rect.x;
+ *y += rect.y + rect.height;
+
+ if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL)
{
- /* no selection -> regular "under widget" positioning */
- gtranslator_utils_menu_position_under_widget (menu,
- x, y, push_in,
- tree);
+ GtkRequisition requisition;
+ gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
+ *x += rect.width - requisition.width;
}
+ }
+ else
+ {
+ /* no selection -> regular "under widget" positioning */
+ gtranslator_utils_menu_position_under_widget (menu,
+ x, y, push_in, tree);
+ }
}
static GtkWidget *
-handle_builder_error (const gchar *message,
- ...)
+handle_builder_error (const gchar * message, ...)
{
- GtkWidget *label;
- gchar *msg;
- gchar *msg_plain;
- va_list args;
+ GtkWidget *label;
+ gchar *msg;
+ gchar *msg_plain;
+ va_list args;
- va_start (args, message);
- msg_plain = g_strdup_vprintf (message, args);
+ va_start (args, message);
+ msg_plain = g_strdup_vprintf (message, args);
- msg = g_strconcat ("<span size=\"large\" weight=\"bold\">",
- msg_plain, "</span>\n\n",
- _("Please check your installation."), NULL);
- label = gtk_label_new (msg);
+ msg = g_strconcat ("<span size=\"large\" weight=\"bold\">",
+ msg_plain, "</span>\n\n",
+ _("Please check your installation."), NULL);
+ label = gtk_label_new (msg);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- g_free (msg_plain);
- g_free (msg);
+ g_free (msg_plain);
+ g_free (msg);
- gtk_misc_set_padding (GTK_MISC (label), 5, 5);
+ gtk_misc_set_padding (GTK_MISC (label), 5, 5);
- return label;
+ return label;
}
/**
@@ -343,144 +335,143 @@ handle_builder_error (const gchar *message,
* Returns FALSE if an error occurs, TRUE on success.
*/
gboolean
-gtranslator_utils_get_ui_objects (const gchar *filename,
- gchar **root_objects,
- GtkWidget **error_widget,
- const gchar *object_name,
- ...)
+gtranslator_utils_get_ui_objects (const gchar * filename,
+ gchar ** root_objects,
+ GtkWidget ** error_widget,
+ const gchar * object_name, ...)
{
- GtkBuilder *builder;
- va_list args;
- const gchar *name;
- GError *error = NULL;
- gchar *filename_markup;
- gboolean ret = TRUE;
-
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (error_widget != NULL, FALSE);
- g_return_val_if_fail (object_name != NULL, FALSE);
-
- filename_markup = g_markup_printf_escaped ("<i>%s</i>", filename);
- *error_widget = NULL;
-
- builder = gtk_builder_new ();
-
- if (root_objects != NULL)
- gtk_builder_add_objects_from_file (builder,
- filename,
- root_objects,
- &error);
- else
- gtk_builder_add_from_file (builder,
- filename,
- &error);
-
- if (error != NULL)
- {
- *error_widget = handle_builder_error (_("Unable to open ui file %s. Error: %s"),
- filename_markup,
- error->message);
- g_error_free (error);
- g_free (filename_markup);
+ GtkBuilder *builder;
+ va_list args;
+ const gchar *name;
+ GError *error = NULL;
+ gchar *filename_markup;
+ gboolean ret = TRUE;
- return FALSE;
- }
+ g_return_val_if_fail (filename != NULL, FALSE);
+ g_return_val_if_fail (error_widget != NULL, FALSE);
+ g_return_val_if_fail (object_name != NULL, FALSE);
- va_start (args, object_name);
- for (name = object_name; name; name = va_arg (args, const gchar *) )
- {
- GObject **gobj;
+ filename_markup = g_markup_printf_escaped ("<i>%s</i>", filename);
+ *error_widget = NULL;
- gobj = va_arg (args, GObject **);
- *gobj = gtk_builder_get_object (builder, name);
+ builder = gtk_builder_new ();
- if (!*gobj)
- {
- *error_widget = handle_builder_error (_("Unable to find the object '%s' inside file %s."),
- name,
- filename_markup),
- ret = FALSE;
- break;
- }
+ if (root_objects != NULL)
+ gtk_builder_add_objects_from_file (builder,
+ filename, root_objects, &error);
+ else
+ gtk_builder_add_from_file (builder, filename, &error);
+
+ if (error != NULL)
+ {
+ *error_widget =
+ handle_builder_error (_("Unable to open ui file %s. Error: %s"),
+ filename_markup, error->message);
+ g_error_free (error);
+ g_free (filename_markup);
+
+ return FALSE;
+ }
+
+ va_start (args, object_name);
+ for (name = object_name; name; name = va_arg (args, const gchar *))
+ {
+ GObject **gobj;
+
+ gobj = va_arg (args, GObject **);
+ *gobj = gtk_builder_get_object (builder, name);
- /* we return a new ref for the root objects,
- * the others are already reffed by their parent root object */
- if (root_objects != NULL)
+ if (!*gobj)
+ {
+ *error_widget =
+ handle_builder_error (_
+ ("Unable to find the object '%s' inside file %s."),
+ name, filename_markup), ret = FALSE;
+ break;
+ }
+
+ /* we return a new ref for the root objects,
+ * the others are already reffed by their parent root object */
+ if (root_objects != NULL)
+ {
+ gint i;
+
+ for (i = 0; root_objects[i] != NULL; ++i)
+ {
+ if ((strcmp (name, root_objects[i]) == 0))
{
- gint i;
-
- for (i = 0; root_objects[i] != NULL; ++i)
- {
- if ((strcmp (name, root_objects[i]) == 0))
- {
- g_object_ref (*gobj);
- }
- }
+ g_object_ref (*gobj);
}
+ }
}
- va_end (args);
+ }
+ va_end (args);
- g_free (filename_markup);
- g_object_unref (builder);
+ g_free (filename_markup);
+ g_object_unref (builder);
- return ret;
+ return ret;
}
static gboolean
is_valid_scheme_character (gchar c)
{
- return g_ascii_isalnum (c) || c == '+' || c == '-' || c == '.';
+ return g_ascii_isalnum (c) || c == '+' || c == '-' || c == '.';
}
static gboolean
-has_valid_scheme (const gchar *uri)
+has_valid_scheme (const gchar * uri)
{
- const gchar *p;
+ const gchar *p;
- p = uri;
+ p = uri;
- if (!is_valid_scheme_character (*p)) {
- return FALSE;
- }
+ if (!is_valid_scheme_character (*p))
+ {
+ return FALSE;
+ }
- do {
- p++;
- } while (is_valid_scheme_character (*p));
+ do
+ {
+ p++;
+ }
+ while (is_valid_scheme_character (*p));
- return *p == ':';
+ return *p == ':';
}
gboolean
-gtranslator_utils_is_valid_uri (const gchar *uri)
+gtranslator_utils_is_valid_uri (const gchar * uri)
{
- const guchar *p;
+ const guchar *p;
- if (uri == NULL)
- return FALSE;
+ if (uri == NULL)
+ return FALSE;
- if (!has_valid_scheme (uri))
- return FALSE;
+ if (!has_valid_scheme (uri))
+ return FALSE;
- /* We expect to have a fully valid set of characters */
- for (p = (const guchar *)uri; *p; p++) {
- if (*p == '%')
- {
- ++p;
- if (!g_ascii_isxdigit (*p))
- return FALSE;
+ /* We expect to have a fully valid set of characters */
+ for (p = (const guchar *) uri; *p; p++)
+ {
+ if (*p == '%')
+ {
+ ++p;
+ if (!g_ascii_isxdigit (*p))
+ return FALSE;
- ++p;
- if (!g_ascii_isxdigit (*p))
- return FALSE;
- }
- else
- {
- if (*p <= 32 || *p >= 128)
- return FALSE;
- }
+ ++p;
+ if (!g_ascii_isxdigit (*p))
+ return FALSE;
+ }
+ else
+ {
+ if (*p <= 32 || *p >= 128)
+ return FALSE;
}
+ }
- return TRUE;
+ return TRUE;
}
/**
@@ -494,198 +485,196 @@ gtranslator_utils_is_valid_uri (const gchar *uri)
* string array is no longer used
*/
GSList *
-gtranslator_utils_drop_get_locations (GtkSelectionData *selection_data)
+gtranslator_utils_drop_get_locations (GtkSelectionData * selection_data)
{
- gchar **uris;
- gint i;
- GSList *locations = NULL;
+ gchar **uris;
+ gint i;
+ GSList *locations = NULL;
- uris = g_uri_list_extract_uris ((gchar *) selection_data->data);
+ uris = g_uri_list_extract_uris ((gchar *) selection_data->data);
- for (i = 0; uris[i] != NULL; i++)
+ for (i = 0; uris[i] != NULL; i++)
+ {
+ GFile *file;
+ /* Silently ignore malformed URI/filename */
+ if (gtranslator_utils_is_valid_uri (uris[i]))
{
- GFile *file;
- /* Silently ignore malformed URI/filename */
- if (gtranslator_utils_is_valid_uri (uris[i]))
- {
- file = g_file_new_for_uri (uris[i]);
- locations = g_slist_prepend (locations, file);
- }
+ file = g_file_new_for_uri (uris[i]);
+ locations = g_slist_prepend (locations, file);
}
+ }
- return locations;
+ return locations;
}
gchar *
-gtranslator_utils_escape_search_text (const gchar* text)
+gtranslator_utils_escape_search_text (const gchar * text)
{
- GString *str;
- gint length;
- const gchar *p;
- const gchar *end;
-
- if (text == NULL)
- return NULL;
-
- length = strlen (text);
-
- /* no escape when typing.
- * The short circuit works only for ascii, but we only
- * care about not escaping a single '\' */
- if (length == 1)
- return g_strdup (text);
-
- str = g_string_new ("");
-
- p = text;
- end = text + length;
-
- while (p != end)
- {
- const gchar *next;
- next = g_utf8_next_char (p);
-
- switch (*p)
- {
- case '\n':
- g_string_append (str, "\\n");
- break;
- case '\r':
- g_string_append (str, "\\r");
- break;
- case '\t':
- g_string_append (str, "\\t");
- break;
- case '\\':
- g_string_append (str, "\\\\");
- break;
- default:
- g_string_append_len (str, p, next - p);
- break;
- }
-
- p = next;
- }
-
- return g_string_free (str, FALSE);
+ GString *str;
+ gint length;
+ const gchar *p;
+ const gchar *end;
+
+ if (text == NULL)
+ return NULL;
+
+ length = strlen (text);
+
+ /* no escape when typing.
+ * The short circuit works only for ascii, but we only
+ * care about not escaping a single '\' */
+ if (length == 1)
+ return g_strdup (text);
+
+ str = g_string_new ("");
+
+ p = text;
+ end = text + length;
+
+ while (p != end)
+ {
+ const gchar *next;
+ next = g_utf8_next_char (p);
+
+ switch (*p)
+ {
+ case '\n':
+ g_string_append (str, "\\n");
+ break;
+ case '\r':
+ g_string_append (str, "\\r");
+ break;
+ case '\t':
+ g_string_append (str, "\\t");
+ break;
+ case '\\':
+ g_string_append (str, "\\\\");
+ break;
+ default:
+ g_string_append_len (str, p, next - p);
+ break;
+ }
+
+ p = next;
+ }
+
+ return g_string_free (str, FALSE);
}
gchar *
-gtranslator_utils_unescape_search_text (const gchar *text)
+gtranslator_utils_unescape_search_text (const gchar * text)
{
- GString *str;
- gint length;
- gboolean drop_prev = FALSE;
- const gchar *cur;
- const gchar *end;
- const gchar *prev;
-
- if (text == NULL)
- return NULL;
-
- length = strlen (text);
-
- str = g_string_new ("");
-
- cur = text;
- end = text + length;
- prev = NULL;
-
- while (cur != end)
- {
- const gchar *next;
- next = g_utf8_next_char (cur);
+ GString *str;
+ gint length;
+ gboolean drop_prev = FALSE;
+ const gchar *cur;
+ const gchar *end;
+ const gchar *prev;
- if (prev && (*prev == '\\'))
- {
- switch (*cur)
- {
- case 'n':
- str = g_string_append (str, "\n");
- break;
- case 'r':
- str = g_string_append (str, "\r");
- break;
- case 't':
- str = g_string_append (str, "\t");
- break;
- case '\\':
- str = g_string_append (str, "\\");
- drop_prev = TRUE;
- break;
- default:
- str = g_string_append (str, "\\");
- str = g_string_append_len (str, cur, next - cur);
- break;
- }
- }
- else if (*cur != '\\')
- {
- str = g_string_append_len (str, cur, next - cur);
- }
- else if ((next == end) && (*cur == '\\'))
- {
- str = g_string_append (str, "\\");
- }
-
- if (!drop_prev)
- {
- prev = cur;
- }
- else
- {
- prev = NULL;
- drop_prev = FALSE;
- }
+ if (text == NULL)
+ return NULL;
+
+ length = strlen (text);
+
+ str = g_string_new ("");
+
+ cur = text;
+ end = text + length;
+ prev = NULL;
- cur = next;
+ while (cur != end)
+ {
+ const gchar *next;
+ next = g_utf8_next_char (cur);
+
+ if (prev && (*prev == '\\'))
+ {
+ switch (*cur)
+ {
+ case 'n':
+ str = g_string_append (str, "\n");
+ break;
+ case 'r':
+ str = g_string_append (str, "\r");
+ break;
+ case 't':
+ str = g_string_append (str, "\t");
+ break;
+ case '\\':
+ str = g_string_append (str, "\\");
+ drop_prev = TRUE;
+ break;
+ default:
+ str = g_string_append (str, "\\");
+ str = g_string_append_len (str, cur, next - cur);
+ break;
+ }
+ }
+ else if (*cur != '\\')
+ {
+ str = g_string_append_len (str, cur, next - cur);
+ }
+ else if ((next == end) && (*cur == '\\'))
+ {
+ str = g_string_append (str, "\\");
+ }
+
+ if (!drop_prev)
+ {
+ prev = cur;
+ }
+ else
+ {
+ prev = NULL;
+ drop_prev = FALSE;
}
- return g_string_free (str, FALSE);
+ cur = next;
+ }
+
+ return g_string_free (str, FALSE);
}
/*
* n: len of the string in bytes
*/
-gboolean
-g_utf8_caselessnmatch (const gchar *s1,
- const gchar *s2,
- gssize n1,
- gssize n2)
+gboolean
+g_utf8_caselessnmatch (const gchar * s1,
+ const gchar * s2, gssize n1, gssize n2)
{
- gchar *casefold;
- gchar *normalized_s1;
- gchar *normalized_s2;
- gint len_s1;
- gint len_s2;
- gboolean ret = FALSE;
-
- g_return_val_if_fail (s1 != NULL, FALSE);
- g_return_val_if_fail (s2 != NULL, FALSE);
- g_return_val_if_fail (n1 > 0, FALSE);
- g_return_val_if_fail (n2 > 0, FALSE);
-
- casefold = g_utf8_casefold (s1, n1);
- normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
- g_free (casefold);
-
- casefold = g_utf8_casefold (s2, n2);
- normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
- g_free (casefold);
-
- len_s1 = strlen (normalized_s1);
- len_s2 = strlen (normalized_s2);
-
- if (len_s1 < len_s2)
- goto finally_2;
-
- ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0);
-
+ gchar *casefold;
+ gchar *normalized_s1;
+ gchar *normalized_s2;
+ gint len_s1;
+ gint len_s2;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (s1 != NULL, FALSE);
+ g_return_val_if_fail (s2 != NULL, FALSE);
+ g_return_val_if_fail (n1 > 0, FALSE);
+ g_return_val_if_fail (n2 > 0, FALSE);
+
+ casefold = g_utf8_casefold (s1, n1);
+ normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
+ g_free (casefold);
+
+ casefold = g_utf8_casefold (s2, n2);
+ normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_NFD);
+ g_free (casefold);
+
+ len_s1 = strlen (normalized_s1);
+ len_s2 = strlen (normalized_s2);
+
+ if (len_s1 < len_s2)
+ goto finally_2;
+
+ ret = (strncmp (normalized_s1, normalized_s2, len_s2) == 0);
+
finally_2:
- g_free (normalized_s1);
- g_free (normalized_s2);
+ g_free (normalized_s1);
+ g_free (normalized_s2);
- return ret;
+ return ret;
}
/**
@@ -697,29 +686,26 @@ finally_2:
* Shows the corresponding @url in the default browser.
*/
void
-gtranslator_utils_activate_url (GtkAboutDialog *dialog,
- const gchar *url,
- gpointer data)
+gtranslator_utils_activate_url (GtkAboutDialog * dialog,
+ const gchar * url, gpointer data)
{
- //FIXME: gtk_url_show deprecates this func.
- gchar *open[3];
+ //FIXME: gtk_url_show deprecates this func.
+ gchar *open[3];
- if (g_find_program_in_path ("xdg-open"))
- {
- open[0] = "xdg-open";
- }
- else return;
-
- open[1] = (gchar *)url;
- open[2] = NULL;
-
- gdk_spawn_on_screen (gdk_screen_get_default (),
- NULL,
- open,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL, NULL, NULL);
+ if (g_find_program_in_path ("xdg-open"))
+ {
+ open[0] = "xdg-open";
+ }
+ else
+ return;
+
+ open[1] = (gchar *) url;
+ open[2] = NULL;
+
+ gdk_spawn_on_screen (gdk_screen_get_default (),
+ NULL,
+ open,
+ NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
}
/**
@@ -731,29 +717,26 @@ gtranslator_utils_activate_url (GtkAboutDialog *dialog,
* Shows the corresponding @email in the default mailer.
*/
void
-gtranslator_utils_activate_email (GtkAboutDialog *dialog,
- const gchar *email,
- gpointer data)
+gtranslator_utils_activate_email (GtkAboutDialog * dialog,
+ const gchar * email, gpointer data)
{
- //FIXME: gtk_url_show deprecates this func.
- gchar *open[3];
+ //FIXME: gtk_url_show deprecates this func.
+ gchar *open[3];
- if (g_find_program_in_path ("xdg-email"))
- {
- open[0] = "xdg-email";
- }
- else return;
-
- open[1] = (gchar *)email;
- open[2] = NULL;
-
- gdk_spawn_on_screen (gdk_screen_get_default (),
- NULL,
- open,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL, NULL, NULL);
+ if (g_find_program_in_path ("xdg-email"))
+ {
+ open[0] = "xdg-email";
+ }
+ else
+ return;
+
+ open[1] = (gchar *) email;
+ open[2] = NULL;
+
+ gdk_spawn_on_screen (gdk_screen_get_default (),
+ NULL,
+ open,
+ NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
}
/**
@@ -765,92 +748,91 @@ gtranslator_utils_activate_email (GtkAboutDialog *dialog,
* Shows the help for an specific document in the default help browser.
*/
void
-gtranslator_utils_help_display (GtkWindow *parent,
- const gchar *doc_id,
- const gchar *file_name)
+gtranslator_utils_help_display (GtkWindow * parent,
+ const gchar * doc_id, const gchar * file_name)
{
- GError *error = NULL;
- GdkScreen *screen;
- gchar *command;
- const gchar *lang;
- const gchar * const *langs;
- gchar *uri = NULL;
- gchar *path;
- gint i;
+ GError *error = NULL;
+ GdkScreen *screen;
+ gchar *command;
+ const gchar *lang;
+ const gchar *const *langs;
+ gchar *uri = NULL;
+ gchar *path;
+ gint i;
+
+
+ /* FIXME: How to display help on windows. Gedit opens a browser and displays
+ a url with the contents of the help
+ if (uri == NULL)
+ {
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Sorry, Gtranslator for windows is unable to display help yet."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return;
+ } End of FIXME: How to display help on windows. */
+
+
+ g_return_if_fail (file_name != NULL);
+
+ langs = g_get_language_names ();
+ for (i = 0; langs[i]; i++)
+ {
+ lang = langs[i];
+ if (strchr (lang, '.'))
+ continue;
+ path = gtranslator_utils_get_datadir ();
+ uri = g_build_filename (path, "/gnome/help/", doc_id,
+ lang, file_name, NULL);
+ g_free (path);
- /* FIXME: How to display help on windows. Gedit opens a browser and displays
- a url with the contents of the help
- if (uri == NULL)
- {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Sorry, Gtranslator for windows is unable to display help yet."));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return;
- } End of FIXME: How to display help on windows.*/
-
-
- g_return_if_fail (file_name != NULL);
-
- langs = g_get_language_names ();
- for (i = 0; langs[i]; i++)
+ if (g_file_test (uri, G_FILE_TEST_EXISTS))
{
- lang = langs[i];
- if (strchr (lang, '.'))
- continue;
-
- path = gtranslator_utils_get_datadir ();
- uri = g_build_filename (path, "/gnome/help/", doc_id,
- lang, file_name, NULL);
- g_free(path);
-
- if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
- break;
- }
- g_free (uri);
- uri = NULL;
+ break;
}
+ g_free (uri);
+ uri = NULL;
+ }
- if (uri == NULL)
- {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Unable to display help. "
- "Please make sure the Gtranslator "
- "documentation package is installed."));
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- return;
- }
+ if (uri == NULL)
+ {
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Unable to display help. "
+ "Please make sure the Gtranslator "
+ "documentation package is installed."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return;
+ }
- command = g_strconcat ("gnome-help ghelp://", uri, NULL);
- g_free (uri);
+ command = g_strconcat ("gnome-help ghelp://", uri, NULL);
+ g_free (uri);
- screen = gtk_widget_get_screen (GTK_WIDGET (parent));
- gdk_spawn_command_line_on_screen (screen, command, &error);
+ screen = gtk_widget_get_screen (GTK_WIDGET (parent));
+ gdk_spawn_command_line_on_screen (screen, command, &error);
- if (error != NULL)
- {
- g_warning ("Error executing help application: %s",
- error->message);
- g_error_free (error);
-
- return;
- }
- g_free (command);
+ if (error != NULL)
+ {
+ g_warning ("Error executing help application: %s", error->message);
+ g_error_free (error);
+
+ return;
+ }
+ g_free (command);
}
/**
@@ -863,46 +845,47 @@ gtranslator_utils_help_display (GtkWindow *parent,
gchar *
gtranslator_utils_get_user_config_dir (void)
{
- return g_build_filename (g_get_user_config_dir (),
- "gtranslator",
- NULL);
+ return g_build_filename (g_get_user_config_dir (), "gtranslator", NULL);
}
-gchar *gtranslator_utils_get_current_date (void)
+gchar *
+gtranslator_utils_get_current_date (void)
{
time_t now;
struct tm *now_here;
gchar *date = g_malloc (11);
-
- now = time(NULL);
- now_here = localtime(&now);
- strftime(date, 11, "%Y-%m-%d", now_here);
+
+ now = time (NULL);
+ now_here = localtime (&now);
+ strftime (date, 11, "%Y-%m-%d", now_here);
return date;
}
-gchar *gtranslator_utils_get_current_time (void)
+gchar *
+gtranslator_utils_get_current_time (void)
{
time_t now;
struct tm *now_here;
gchar *t = g_malloc (11);
- now = time(NULL);
- now_here = localtime(&now);
- strftime(t, 11, "%H:%M%z", now_here);
-
+ now = time (NULL);
+ now_here = localtime (&now);
+ strftime (t, 11, "%H:%M%z", now_here);
+
return t;
}
-gchar *gtranslator_utils_get_current_year (void)
+gchar *
+gtranslator_utils_get_current_year (void)
{
time_t now;
struct tm *now_here;
- gchar *year=g_malloc (5);
+ gchar *year = g_malloc (5);
- now = time(NULL);
- now_here = localtime(&now);
- strftime(year, 5, "%Y", now_here);
+ now = time (NULL);
+ now_here = localtime (&now);
+ strftime (year, 5, "%Y", now_here);
return year;
}
@@ -918,74 +901,76 @@ gchar *gtranslator_utils_get_current_year (void)
* g_slist_foreach (list, (GFunc)g_object_unref, NULL).
*/
void
-gtranslator_utils_scan_dir (GFile *dir,
- GSList **list,
- const gchar *po_name)
+gtranslator_utils_scan_dir (GFile * dir,
+ GSList ** list, const gchar * po_name)
{
- GFileInfo *info;
- GError *error;
- GFile *file;
- GFileEnumerator *enumerator;
-
- error = NULL;
- enumerator = g_file_enumerate_children (dir,
- G_FILE_ATTRIBUTE_STANDARD_NAME,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- NULL,
- &error);
- if (enumerator)
+ GFileInfo *info;
+ GError *error;
+ GFile *file;
+ GFileEnumerator *enumerator;
+
+ error = NULL;
+ enumerator = g_file_enumerate_children (dir,
+ G_FILE_ATTRIBUTE_STANDARD_NAME,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, &error);
+ if (enumerator)
+ {
+ error = NULL;
+
+ while ((info =
+ g_file_enumerator_next_file (enumerator, NULL, &error)) != NULL)
{
- error = NULL;
-
- while ((info = g_file_enumerator_next_file (enumerator, NULL, &error)) != NULL)
- {
- const gchar *name;
- gchar *filename;
-
- name = g_file_info_get_name (info);
- file = g_file_get_child (dir, name);
-
- if (po_name != NULL)
- {
- if (g_str_has_suffix (po_name, ".po"))
- filename = g_strdup (po_name);
- else
- filename = g_strconcat (po_name, ".po", NULL);
- }
- else
- filename = g_strdup (".po");
-
- if (g_str_has_suffix (name, filename))
- *list = g_slist_prepend (*list, file);
- g_free (filename);
-
- gtranslator_utils_scan_dir (file, list, po_name);
- g_object_unref (info);
- }
- g_file_enumerator_close (enumerator, NULL, NULL);
- g_object_unref (enumerator);
-
- if (error)
- {
- g_warning ("%s", error->message);
- }
+ const gchar *name;
+ gchar *filename;
+
+ name = g_file_info_get_name (info);
+ file = g_file_get_child (dir, name);
+
+ if (po_name != NULL)
+ {
+ if (g_str_has_suffix (po_name, ".po"))
+ filename = g_strdup (po_name);
+ else
+ filename = g_strconcat (po_name, ".po", NULL);
+ }
+ else
+ filename = g_strdup (".po");
+
+ if (g_str_has_suffix (name, filename))
+ *list = g_slist_prepend (*list, file);
+ g_free (filename);
+
+ gtranslator_utils_scan_dir (file, list, po_name);
+ g_object_unref (info);
+ }
+ g_file_enumerator_close (enumerator, NULL, NULL);
+ g_object_unref (enumerator);
+
+ if (error)
+ {
+ g_warning ("%s", error->message);
}
+ }
}
gchar *
-gtranslator_utils_reduce_path (const gchar *path)
+gtranslator_utils_reduce_path (const gchar * path)
{
gchar *new_str;
gchar **array;
-
+
array = g_strsplit (path, "/", -1);
- new_str = g_build_filename (array[1], "/../", array[g_strv_length (array)-1], NULL);
-
+ new_str =
+ g_build_filename (array[1], "/../", array[g_strv_length (array) - 1],
+ NULL);
+
if (strlen (new_str) >= 30)
{
g_free (new_str);
- new_str = g_build_filename ("../", array[g_strv_length (array)-1], NULL);
+ new_str =
+ g_build_filename ("../", array[g_strv_length (array) - 1], NULL);
}
return new_str;
}
@@ -994,43 +979,42 @@ gtranslator_utils_reduce_path (const gchar *path)
* Doubles underscore to avoid spurious menu accels.
* Got from gedit
*/
-gchar *
-gtranslator_utils_escape_underscores (const gchar* text,
- gssize length)
+gchar *
+gtranslator_utils_escape_underscores (const gchar * text, gssize length)
{
- GString *str;
- const gchar *p;
- const gchar *end;
-
- g_return_val_if_fail (text != NULL, NULL);
+ GString *str;
+ const gchar *p;
+ const gchar *end;
- if (length < 0)
- length = strlen (text);
+ g_return_val_if_fail (text != NULL, NULL);
- str = g_string_sized_new (length);
+ if (length < 0)
+ length = strlen (text);
- p = text;
- end = text + length;
+ str = g_string_sized_new (length);
- while (p != end)
- {
- const gchar *next;
- next = g_utf8_next_char (p);
+ p = text;
+ end = text + length;
- switch (*p)
- {
- case '_':
- g_string_append (str, "__");
- break;
- default:
- g_string_append_len (str, p, next - p);
- break;
- }
+ while (p != end)
+ {
+ const gchar *next;
+ next = g_utf8_next_char (p);
- p = next;
+ switch (*p)
+ {
+ case '_':
+ g_string_append (str, "__");
+ break;
+ default:
+ g_string_append_len (str, p, next - p);
+ break;
}
- return g_string_free (str, FALSE);
+ p = next;
+ }
+
+ return g_string_free (str, FALSE);
}
/**
@@ -1041,27 +1025,21 @@ gtranslator_utils_escape_underscores (const gchar* text,
* the pixmaps. If filename is NULL returns the path to the folder PIXMAPSDIR
*/
gchar *
-gtranslator_utils_get_file_from_pixmapsdir (const gchar *filename)
+gtranslator_utils_get_file_from_pixmapsdir (const gchar * filename)
{
- gchar *path;
-
+ gchar *path;
+
#ifndef G_OS_WIN32
- path = g_build_filename (PIXMAPSDIR,
- filename,
- NULL);
+ path = g_build_filename (PIXMAPSDIR, filename, NULL);
#else
- gchar *win32_dir;
-
- win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
- path = g_build_filename (win32_dir,
- "share",
- "pixmaps",
- filename,
- NULL);
- g_free (win32_dir);
+ gchar *win32_dir;
+
+ win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ path = g_build_filename (win32_dir, "share", "pixmaps", filename, NULL);
+ g_free (win32_dir);
#endif
-
- return path;
+
+ return path;
}
@@ -1074,27 +1052,21 @@ gtranslator_utils_get_file_from_pixmapsdir (const gchar *filename)
* that contains the data of the package.
*/
gchar *
-gtranslator_utils_get_file_from_pkgdatadir (const gchar *filename)
+gtranslator_utils_get_file_from_pkgdatadir (const gchar * filename)
{
- gchar *path;
-
+ gchar *path;
+
#ifndef G_OS_WIN32
- path = g_build_filename (PKGDATADIR,
- filename,
- NULL);
+ path = g_build_filename (PKGDATADIR, filename, NULL);
#else
- gchar *win32_dir;
-
- win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
- path = g_build_filename (win32_dir,
- "share",
- "gtranslator",
- filename,
- NULL);
- g_free (win32_dir);
+ gchar *win32_dir;
+
+ win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ path = g_build_filename (win32_dir, "share", "gtranslator", filename, NULL);
+ g_free (win32_dir);
#endif
-
- return path;
+
+ return path;
}
@@ -1107,24 +1079,21 @@ gtranslator_utils_get_file_from_pkgdatadir (const gchar *filename)
gchar *
gtranslator_utils_get_datadir (void)
{
- gchar *path;
+ gchar *path;
#ifndef G_OS_WIN32
- path = g_build_filename (DATADIR,
- NULL);
+ path = g_build_filename (DATADIR, NULL);
#else
- gchar *win32_dir;
-
- win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
-
- path = g_build_filename (win32_dir,
- "share",
- NULL);
-
- g_free (win32_dir);
+ gchar *win32_dir;
+
+ win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+
+ path = g_build_filename (win32_dir, "share", NULL);
+
+ g_free (win32_dir);
#endif
- return path;
+ return path;
}
/**
@@ -1135,23 +1104,19 @@ gtranslator_utils_get_datadir (void)
gchar *
gtranslator_utils_get_win32_plugindir (void)
{
- gchar *path;
+ gchar *path;
#ifndef G_OS_WIN32
- path = NULL;
+ path = NULL;
#else
- gchar *win32_dir;
-
- win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
-
- path = g_build_filename (win32_dir,
- "lib",
- "gtranslator",
- "plugins",
- NULL);
-
- g_free (win32_dir);
+ gchar *win32_dir;
+
+ win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+
+ path = g_build_filename (win32_dir, "lib", "gtranslator", "plugins", NULL);
+
+ g_free (win32_dir);
#endif
- return path;
+ return path;
}
diff --git a/src/utils.h b/src/utils.h
index eac696f..92fc35f 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -28,78 +28,79 @@
#include <libxml/tree.h>
#include <gio/gio.h>
-gchar ** gtranslator_utils_split_string_in_words (const gchar *string);
+gchar **gtranslator_utils_split_string_in_words (const gchar * string);
-xmlDocPtr gtranslator_xml_new_doc (const gchar *name);
+xmlDocPtr gtranslator_xml_new_doc (const gchar * name);
-xmlDocPtr gtranslator_xml_open_file (const gchar *filename);
+xmlDocPtr gtranslator_xml_open_file (const gchar * filename);
-GtkWidget *gtranslator_gtk_button_new_with_stock_icon (const gchar *label,
- const gchar *stock_id);
+GtkWidget *gtranslator_gtk_button_new_with_stock_icon (const gchar * label,
+ const gchar *
+ stock_id);
-void gtranslator_utils_menu_position_under_widget (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
-
-void gtranslator_utils_menu_position_under_tree_view (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
+void gtranslator_utils_menu_position_under_widget (GtkMenu * menu,
+ gint * x,
+ gint * y,
+ gboolean * push_in,
+ gpointer user_data);
-gboolean gtranslator_utils_get_ui_objects (const gchar *filename,
- gchar **root_objects,
- GtkWidget **error_widget,
- const gchar *object_name,
- ...)G_GNUC_NULL_TERMINATED;
+void gtranslator_utils_menu_position_under_tree_view (GtkMenu * menu,
+ gint * x,
+ gint * y,
+ gboolean * push_in,
+ gpointer user_data);
-GSList *gtranslator_utils_drop_get_locations (GtkSelectionData *selection_data);
+gboolean
+gtranslator_utils_get_ui_objects (const gchar * filename,
+ gchar ** root_objects,
+ GtkWidget ** error_widget,
+ const gchar * object_name, ...)
+ G_GNUC_NULL_TERMINATED;
-gchar *gtranslator_utils_escape_search_text (const gchar* text);
+ GSList *gtranslator_utils_drop_get_locations (GtkSelectionData *
+ selection_data);
-gchar *gtranslator_utils_unescape_search_text (const gchar *text);
+ gchar *gtranslator_utils_escape_search_text (const gchar * text);
-gboolean g_utf8_caselessnmatch (const gchar *s1,
- const gchar *s2,
- gssize n1,
- gssize n2);
+ gchar *gtranslator_utils_unescape_search_text (const gchar * text);
-void gtranslator_utils_activate_url (GtkAboutDialog *dialog,
- const gchar *url,
- gpointer data);
+ gboolean g_utf8_caselessnmatch (const gchar * s1,
+ const gchar * s2, gssize n1, gssize n2);
-void gtranslator_utils_activate_email (GtkAboutDialog *dialog,
- const gchar *email,
- gpointer data);
-
-void gtranslator_utils_help_display (GtkWindow *parent,
- const gchar *doc_id,
- const gchar *file_name);
-
-gchar *gtranslator_utils_get_user_config_dir (void);
+ void gtranslator_utils_activate_url (GtkAboutDialog * dialog,
+ const gchar * url, gpointer data);
-gchar *gtranslator_utils_get_current_date (void);
+ void gtranslator_utils_activate_email (GtkAboutDialog * dialog,
+ const gchar * email,
+ gpointer data);
-gchar *gtranslator_utils_get_current_time (void);
+ void gtranslator_utils_help_display (GtkWindow * parent,
+ const gchar * doc_id,
+ const gchar * file_name);
-gchar *gtranslator_utils_get_current_year (void);
+ gchar *gtranslator_utils_get_user_config_dir (void);
-void gtranslator_utils_scan_dir (GFile *dir,
- GSList **list,
- const gchar *po_name);
+ gchar *gtranslator_utils_get_current_date (void);
-gchar * gtranslator_utils_reduce_path (const gchar *path);
+ gchar *gtranslator_utils_get_current_time (void);
-gchar *gtranslator_utils_escape_underscores (const gchar* text,
- gssize length);
+ gchar *gtranslator_utils_get_current_year (void);
-gchar *gtranslator_utils_get_file_from_pixmapsdir (const gchar *filename);
+ void gtranslator_utils_scan_dir (GFile * dir,
+ GSList ** list, const gchar * po_name);
-gchar *gtranslator_utils_get_file_from_pkgdatadir (const gchar *filename);
+ gchar *gtranslator_utils_reduce_path (const gchar * path);
-gchar *gtranslator_utils_get_datadir (void);
+ gchar *gtranslator_utils_escape_underscores (const gchar * text,
+ gssize length);
-gchar *gtranslator_utils_get_win32_plugindir (void);
+ gchar *gtranslator_utils_get_file_from_pixmapsdir (const gchar *
+ filename);
+
+ gchar *gtranslator_utils_get_file_from_pkgdatadir (const gchar *
+ filename);
+
+ gchar *gtranslator_utils_get_datadir (void);
+
+ gchar *gtranslator_utils_get_win32_plugindir (void);
#endif
diff --git a/src/view.c b/src/view.c
index 435e5af..3dde15d 100644
--- a/src/view.c
+++ b/src/view.c
@@ -50,130 +50,131 @@
GTR_TYPE_VIEW, \
GtranslatorViewPrivate))
-G_DEFINE_TYPE(GtranslatorView, gtranslator_view, GTK_TYPE_SOURCE_VIEW)
+G_DEFINE_TYPE (GtranslatorView, gtranslator_view, GTK_TYPE_SOURCE_VIEW)
+ struct _GtranslatorViewPrivate
+ {
+ GtkSourceBuffer *buffer;
+
+ guint search_flags;
+ gchar *search_text;
-struct _GtranslatorViewPrivate
-{
- GtkSourceBuffer *buffer;
-
- guint search_flags;
- gchar *search_text;
-
#ifdef HAVE_GTKSPELL
- GtkSpell *spell;
+ GtkSpell *spell;
#endif
-};
+ };
#ifdef HAVE_GTKSPELL
-static void
-gtranslator_attach_gtkspell(GtranslatorView *view)
+ static void gtranslator_attach_gtkspell (GtranslatorView * view)
{
- gint i;
- GError *error = NULL;
- gchar *errortext = NULL;
- view->priv->spell = NULL;
-
- view->priv->spell =
- gtkspell_new_attach(GTK_TEXT_VIEW(view), NULL, &error);
- if (view->priv->spell == NULL)
- {
- g_warning(_("gtkspell error: %s\n"), error->message);
- errortext = g_strdup_printf(_("GtkSpell was unable to initialize.\n %s"),
- error->message);
- g_warning("%s", errortext);
-
- g_error_free(error);
- g_free(errortext);
- }
+ gint i;
+ GError *error = NULL;
+ gchar *errortext = NULL;
+ view->priv->spell = NULL;
+
+ view->priv->spell =
+ gtkspell_new_attach (GTK_TEXT_VIEW (view), NULL, &error);
+ if (view->priv->spell == NULL)
+ {
+ g_warning (_("gtkspell error: %s\n"), error->message);
+ errortext =
+ g_strdup_printf (_("GtkSpell was unable to initialize.\n %s"),
+ error->message);
+ g_warning ("%s", errortext);
+
+ g_error_free (error);
+ g_free (errortext);
+ }
}
#endif
-
+
static void
-gtranslator_view_init (GtranslatorView *view)
+gtranslator_view_init (GtranslatorView * view)
{
- GtkSourceLanguageManager *lm;
- GtkSourceLanguage *lang;
- GPtrArray *dirs;
- gchar **langs;
- const gchar * const *temp;
- gint i;
- gchar *pkgdatadir;
-
- view->priv = GTR_VIEW_GET_PRIVATE (view);
-
- GtranslatorViewPrivate *priv = view->priv;
-
- lm = gtk_source_language_manager_new();
- dirs = g_ptr_array_new();
-
- for(temp = gtk_source_language_manager_get_search_path(lm);
- temp != NULL && *temp != NULL;
- ++temp)
- g_ptr_array_add(dirs, g_strdup(*temp));
-
- pkgdatadir = gtranslator_utils_get_file_from_pkgdatadir(NULL);
- /* FIXME: Where pkgdatadir must be free */
- g_ptr_array_add(dirs, pkgdatadir);
- g_ptr_array_add(dirs, NULL);
- langs = (gchar **)g_ptr_array_free(dirs, FALSE);
-
-
- gtk_source_language_manager_set_search_path(lm, langs);
- lang = gtk_source_language_manager_get_language(lm, "gtranslator");
- g_strfreev(langs);
-
- priv->buffer = gtk_source_buffer_new_with_language(lang);
-
- gtk_text_view_set_buffer(GTK_TEXT_VIEW(view), GTK_TEXT_BUFFER(priv->buffer));
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
-
- //Set syntax highlight according to preferences
- gtk_source_buffer_set_highlight_syntax(priv->buffer, gtranslator_prefs_manager_get_highlight_syntax());
-
- //Set dot char according to preferences
-
- if(gtranslator_prefs_manager_get_visible_whitespace())
- gtranslator_view_enable_visible_whitespace(view, TRUE);
-
- /*
- * Set fonts according to preferences
- */
- if (gtranslator_prefs_manager_get_use_custom_font ())
- {
- gchar *editor_font;
+ GtkSourceLanguageManager *lm;
+ GtkSourceLanguage *lang;
+ GPtrArray *dirs;
+ gchar **langs;
+ const gchar *const *temp;
+ gint i;
+ gchar *pkgdatadir;
- editor_font = g_strdup(gtranslator_prefs_manager_get_editor_font ());
+ view->priv = GTR_VIEW_GET_PRIVATE (view);
- gtranslator_view_set_font (view, FALSE, editor_font);
+ GtranslatorViewPrivate *priv = view->priv;
- g_free (editor_font);
- }
- else
- {
- gtranslator_view_set_font (view, TRUE, NULL);
- }
-
- /*
- * Set scheme color according to preferences
- */
- gtranslator_view_reload_scheme_color (view);
+ lm = gtk_source_language_manager_new ();
+ dirs = g_ptr_array_new ();
+
+ for (temp = gtk_source_language_manager_get_search_path (lm);
+ temp != NULL && *temp != NULL; ++temp)
+ g_ptr_array_add (dirs, g_strdup (*temp));
+
+ pkgdatadir = gtranslator_utils_get_file_from_pkgdatadir (NULL);
+ /* FIXME: Where pkgdatadir must be free */
+ g_ptr_array_add (dirs, pkgdatadir);
+ g_ptr_array_add (dirs, NULL);
+ langs = (gchar **) g_ptr_array_free (dirs, FALSE);
+
+
+ gtk_source_language_manager_set_search_path (lm, langs);
+ lang = gtk_source_language_manager_get_language (lm, "gtranslator");
+ g_strfreev (langs);
+
+ priv->buffer = gtk_source_buffer_new_with_language (lang);
+
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (view),
+ GTK_TEXT_BUFFER (priv->buffer));
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
+
+ //Set syntax highlight according to preferences
+ gtk_source_buffer_set_highlight_syntax (priv->buffer,
+ gtranslator_prefs_manager_get_highlight_syntax
+ ());
+
+ //Set dot char according to preferences
+
+ if (gtranslator_prefs_manager_get_visible_whitespace ())
+ gtranslator_view_enable_visible_whitespace (view, TRUE);
+
+ /*
+ * Set fonts according to preferences
+ */
+ if (gtranslator_prefs_manager_get_use_custom_font ())
+ {
+ gchar *editor_font;
+
+ editor_font = g_strdup (gtranslator_prefs_manager_get_editor_font ());
+
+ gtranslator_view_set_font (view, FALSE, editor_font);
+
+ g_free (editor_font);
+ }
+ else
+ {
+ gtranslator_view_set_font (view, TRUE, NULL);
+ }
+
+ /*
+ * Set scheme color according to preferences
+ */
+ gtranslator_view_reload_scheme_color (view);
}
static void
-gtranslator_view_finalize (GObject *object)
+gtranslator_view_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_view_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_view_parent_class)->finalize (object);
}
static void
-gtranslator_view_class_init (GtranslatorViewClass *klass)
+gtranslator_view_class_init (GtranslatorViewClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (GtranslatorViewPrivate));
+ g_type_class_add_private (klass, sizeof (GtranslatorViewPrivate));
- object_class->finalize = gtranslator_view_finalize;
+ object_class->finalize = gtranslator_view_finalize;
}
/**
@@ -186,10 +187,10 @@ gtranslator_view_class_init (GtranslatorViewClass *klass)
GtkWidget *
gtranslator_view_new (void)
{
- GtkWidget *view;
-
- view = GTK_WIDGET (g_object_new (GTR_TYPE_VIEW, NULL));
- return view;
+ GtkWidget *view;
+
+ view = GTK_WIDGET (g_object_new (GTR_TYPE_VIEW, NULL));
+ return view;
}
/**
@@ -203,33 +204,32 @@ gtranslator_view_new (void)
* Returns: TRUE if the @selected_text was got correctly.
*/
gboolean
-gtranslator_view_get_selected_text (GtranslatorView *view,
- gchar **selected_text,
- gint *len)
+gtranslator_view_get_selected_text (GtranslatorView * view,
+ gchar ** selected_text, gint * len)
{
- GtkTextIter start, end;
- GtkTextBuffer *doc;
+ GtkTextIter start, end;
+ GtkTextBuffer *doc;
- g_return_val_if_fail (selected_text != NULL, FALSE);
- g_return_val_if_fail (*selected_text == NULL, FALSE);
- g_return_val_if_fail (GTR_IS_VIEW(view), FALSE);
+ g_return_val_if_fail (selected_text != NULL, FALSE);
+ g_return_val_if_fail (*selected_text == NULL, FALSE);
+ g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
- doc = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
-
- if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
- {
- if (len != NULL)
- len = 0;
+ doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- return FALSE;
- }
+ if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
+ {
+ if (len != NULL)
+ len = 0;
- *selected_text = gtk_text_buffer_get_slice (doc, &start, &end, TRUE);
+ return FALSE;
+ }
- if (len != NULL)
- *len = g_utf8_strlen (*selected_text, -1);
+ *selected_text = gtk_text_buffer_get_slice (doc, &start, &end, TRUE);
- return TRUE;
+ if (len != NULL)
+ *len = g_utf8_strlen (*selected_text, -1);
+
+ return TRUE;
}
/**
@@ -240,23 +240,22 @@ gtranslator_view_get_selected_text (GtranslatorView *view,
* Enables the spellcheck
**/
void
-gtranslator_view_enable_spellcheck(GtranslatorView *view,
- gboolean enable)
+gtranslator_view_enable_spellcheck (GtranslatorView * view, gboolean enable)
{
- if(enable)
- {
+ if (enable)
+ {
#ifdef HAVE_GTKSPELL
- gtranslator_attach_gtkspell(view);
+ gtranslator_attach_gtkspell (view);
#endif
- }
- else
- {
+ }
+ else
+ {
#ifdef HAVE_GTKSPELL
- if(!view->priv->spell)
- return;
- gtkspell_detach(view->priv->spell);
+ if (!view->priv->spell)
+ return;
+ gtkspell_detach (view->priv->spell);
#endif
- }
+ }
}
/**
@@ -267,16 +266,16 @@ gtranslator_view_enable_spellcheck(GtranslatorView *view,
* Enables special chars for white spaces including \n and \t
**/
void
-gtranslator_view_enable_visible_whitespace (GtranslatorView *view,
+gtranslator_view_enable_visible_whitespace (GtranslatorView * view,
gboolean enable)
{
- g_return_if_fail (GTR_IS_VIEW (view));
-
- if (enable)
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view),
- GTK_SOURCE_DRAW_SPACES_ALL);
- else
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view), 0);
+ g_return_if_fail (GTR_IS_VIEW (view));
+
+ if (enable)
+ gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view),
+ GTK_SOURCE_DRAW_SPACES_ALL);
+ else
+ gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view), 0);
}
/**
@@ -287,31 +286,28 @@ gtranslator_view_enable_visible_whitespace (GtranslatorView *view,
* then deletes said text if it's editable.
*/
void
-gtranslator_view_cut_clipboard (GtranslatorView *view)
+gtranslator_view_cut_clipboard (GtranslatorView * view)
{
- GtkTextBuffer *buffer;
- GtkClipboard *clipboard;
-
- g_return_if_fail (GTR_IS_VIEW (view));
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
-
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
- GDK_SELECTION_CLIPBOARD);
-
- /* FIXME: what is default editability of a buffer? */
- gtk_text_buffer_cut_clipboard (buffer,
- clipboard,
- gtk_text_view_get_editable(
- GTK_TEXT_VIEW (view)));
-
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
- gtk_text_buffer_get_insert (buffer),
- 0.0,
- FALSE,
- 0.0,
- 0.0);
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
+
+ g_return_if_fail (GTR_IS_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
+
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
+ GDK_SELECTION_CLIPBOARD);
+
+ /* FIXME: what is default editability of a buffer? */
+ gtk_text_buffer_cut_clipboard (buffer,
+ clipboard,
+ gtk_text_view_get_editable (GTK_TEXT_VIEW
+ (view)));
+
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
+ gtk_text_buffer_get_insert (buffer),
+ 0.0, FALSE, 0.0, 0.0);
}
/**
@@ -321,22 +317,22 @@ gtranslator_view_cut_clipboard (GtranslatorView *view)
* Copies the currently-selected text to a clipboard.
*/
void
-gtranslator_view_copy_clipboard (GtranslatorView *view)
+gtranslator_view_copy_clipboard (GtranslatorView * view)
{
- GtkTextBuffer *buffer;
- GtkClipboard *clipboard;
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
- g_return_if_fail (GTR_IS_VIEW (view));
+ g_return_if_fail (GTR_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
- GDK_SELECTION_CLIPBOARD);
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
+ GDK_SELECTION_CLIPBOARD);
- gtk_text_buffer_copy_clipboard (buffer, clipboard);
+ gtk_text_buffer_copy_clipboard (buffer, clipboard);
- /* on copy do not scroll, we are already on screen */
+ /* on copy do not scroll, we are already on screen */
}
/**
@@ -347,32 +343,29 @@ gtranslator_view_copy_clipboard (GtranslatorView *view)
* or at override_location.
*/
void
-gtranslator_view_paste_clipboard (GtranslatorView *view)
+gtranslator_view_paste_clipboard (GtranslatorView * view)
{
- GtkTextBuffer *buffer;
- GtkClipboard *clipboard;
-
- g_return_if_fail (GTR_IS_VIEW (view));
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
-
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
- GDK_SELECTION_CLIPBOARD);
-
- /* FIXME: what is default editability of a buffer? */
- gtk_text_buffer_paste_clipboard (buffer,
- clipboard,
- NULL,
- gtk_text_view_get_editable(
- GTK_TEXT_VIEW (view)));
-
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
- gtk_text_buffer_get_insert (buffer),
- 0.0,
- FALSE,
- 0.0,
- 0.0);
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
+
+ g_return_if_fail (GTR_IS_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
+
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
+ GDK_SELECTION_CLIPBOARD);
+
+ /* FIXME: what is default editability of a buffer? */
+ gtk_text_buffer_paste_clipboard (buffer,
+ clipboard,
+ NULL,
+ gtk_text_view_get_editable (GTK_TEXT_VIEW
+ (view)));
+
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
+ gtk_text_buffer_get_insert (buffer),
+ 0.0, FALSE, 0.0, 0.0);
}
/**
@@ -384,25 +377,24 @@ gtranslator_view_paste_clipboard (GtranslatorView *view)
* Sets the #GtranslatorView font.
**/
void
-gtranslator_view_set_font (GtranslatorView *view,
- gboolean def,
- const gchar *font_name)
+gtranslator_view_set_font (GtranslatorView * view,
+ gboolean def, const gchar * font_name)
{
- PangoFontDescription *font_desc = NULL;
+ PangoFontDescription *font_desc = NULL;
- g_return_if_fail (GTR_IS_VIEW (view));
+ g_return_if_fail (GTR_IS_VIEW (view));
- if (def)
- font_name = g_strdup("Sans 10");
+ if (def)
+ font_name = g_strdup ("Sans 10");
- g_return_if_fail (font_name != NULL);
+ g_return_if_fail (font_name != NULL);
- font_desc = pango_font_description_from_string (font_name);
- g_return_if_fail (font_desc != NULL);
+ 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);
+ gtk_widget_modify_font (GTK_WIDGET (view), font_desc);
- pango_font_description_free (font_desc);
+ pango_font_description_free (font_desc);
}
@@ -415,64 +407,63 @@ gtranslator_view_set_font (GtranslatorView *view,
* Stores the text to search for in the @view with some specific @flags.
*/
void
-gtranslator_view_set_search_text (GtranslatorView *view,
- const gchar *text,
- guint flags)
+gtranslator_view_set_search_text (GtranslatorView * view,
+ const gchar * text, guint flags)
{
- GtkSourceBuffer *doc;
- gchar *converted_text;
- gboolean notify = FALSE;
- //gboolean update_to_search_region = FALSE;
-
- g_return_if_fail (GTR_IS_VIEW (view));
- g_return_if_fail ((text == NULL) || (view->priv->search_text != text));
- g_return_if_fail ((text == NULL) || g_utf8_validate (text, -1, NULL));
-
- //gedit_debug_message (DEBUG_DOCUMENT, "text = %s", text);
- doc = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)));
-
- if (text != NULL)
+ GtkSourceBuffer *doc;
+ gchar *converted_text;
+ gboolean notify = FALSE;
+ //gboolean update_to_search_region = FALSE;
+
+ g_return_if_fail (GTR_IS_VIEW (view));
+ g_return_if_fail ((text == NULL) || (view->priv->search_text != text));
+ g_return_if_fail ((text == NULL) || g_utf8_validate (text, -1, NULL));
+
+ //gedit_debug_message (DEBUG_DOCUMENT, "text = %s", text);
+ doc = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ if (text != NULL)
+ {
+ if (*text != '\0')
{
- if (*text != '\0')
- {
- converted_text = gtranslator_utils_unescape_search_text (text);
- notify = !gtranslator_view_get_can_search_again (view);
- }
- else
- {
- converted_text = g_strdup("");
- notify = gtranslator_view_get_can_search_again (view);
- }
-
- g_free (view->priv->search_text);
-
- view->priv->search_text = converted_text;
- //view->priv->num_of_lines_search_text = compute_num_of_lines (view->priv->search_text);
- //update_to_search_region = TRUE;
+ converted_text = gtranslator_utils_unescape_search_text (text);
+ notify = !gtranslator_view_get_can_search_again (view);
}
-
- if (!GTR_SEARCH_IS_DONT_SET_FLAGS (flags))
+ else
{
- /*if (view->priv->search_flags != flags)
- update_to_search_region = TRUE;*/
-
- view->priv->search_flags = flags;
-
+ converted_text = g_strdup ("");
+ notify = gtranslator_view_get_can_search_again (view);
}
- /*if (update_to_search_region)
- {
- GtkTextIter begin;
- GtkTextIter end;
-
- gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc),
- &begin,
- &end);
-
- to_search_region_range (doc,
- &begin,
- &end);
- }*/
+ g_free (view->priv->search_text);
+
+ view->priv->search_text = converted_text;
+ //view->priv->num_of_lines_search_text = compute_num_of_lines (view->priv->search_text);
+ //update_to_search_region = TRUE;
+ }
+
+ if (!GTR_SEARCH_IS_DONT_SET_FLAGS (flags))
+ {
+ /*if (view->priv->search_flags != flags)
+ update_to_search_region = TRUE; */
+
+ view->priv->search_flags = flags;
+
+ }
+
+ /*if (update_to_search_region)
+ {
+ GtkTextIter begin;
+ GtkTextIter end;
+
+ gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc),
+ &begin,
+ &end);
+
+ to_search_region_range (doc,
+ &begin,
+ &end);
+ } */
}
/**
@@ -486,15 +477,14 @@ gtranslator_view_set_search_text (GtranslatorView *view,
* Returns: the text to search for it.
*/
gchar *
-gtranslator_view_get_search_text (GtranslatorView *view,
- guint *flags)
+gtranslator_view_get_search_text (GtranslatorView * view, guint * flags)
{
- g_return_val_if_fail (GTR_IS_VIEW (view), NULL);
+ g_return_val_if_fail (GTR_IS_VIEW (view), NULL);
- if (flags != NULL)
- *flags = view->priv->search_flags;
+ if (flags != NULL)
+ *flags = view->priv->search_flags;
- return gtranslator_utils_escape_search_text (view->priv->search_text);
+ return gtranslator_utils_escape_search_text (view->priv->search_text);
}
/**
@@ -504,12 +494,12 @@ gtranslator_view_get_search_text (GtranslatorView *view,
* Returns: TRUE if it can search again
*/
gboolean
-gtranslator_view_get_can_search_again (GtranslatorView *view)
+gtranslator_view_get_can_search_again (GtranslatorView * view)
{
- g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
+ g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
- return ((view->priv->search_text != NULL) &&
- (*view->priv->search_text != '\0'));
+ return ((view->priv->search_text != NULL) &&
+ (*view->priv->search_text != '\0'));
}
/**
@@ -529,76 +519,76 @@ gtranslator_view_get_can_search_again (GtranslatorView *view)
* Returns: whether a match was found
*/
gboolean
-gtranslator_view_search_forward (GtranslatorView *view,
- const GtkTextIter *start,
- const GtkTextIter *end,
- GtkTextIter *match_start,
- GtkTextIter *match_end)
+gtranslator_view_search_forward (GtranslatorView * view,
+ const GtkTextIter * start,
+ const GtkTextIter * end,
+ GtkTextIter * match_start,
+ GtkTextIter * match_end)
{
- GtkSourceBuffer *doc;
- GtkTextIter iter;
- GtkSourceSearchFlags search_flags;
- gboolean found = FALSE;
- GtkTextIter m_start;
- GtkTextIter m_end;
-
- g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
-
- doc = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)));
-
- g_return_val_if_fail ((start == NULL) ||
- (gtk_text_iter_get_buffer (start) == GTK_TEXT_BUFFER (doc)), FALSE);
- g_return_val_if_fail ((end == NULL) ||
- (gtk_text_iter_get_buffer (end) == GTK_TEXT_BUFFER (doc)), FALSE);
-
- if (view->priv->search_text == NULL)
- {
- //gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == NULL\n");
- return FALSE;
- }
- /*else
- gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == \"%s\"\n", doc->priv->search_text);*/
-
- if (start == NULL)
- gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (doc), &iter);
- else
- iter = *start;
-
- search_flags = GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_TEXT_ONLY;
-
- if (!GTR_SEARCH_IS_CASE_SENSITIVE (view->priv->search_flags))
+ GtkSourceBuffer *doc;
+ GtkTextIter iter;
+ GtkSourceSearchFlags search_flags;
+ gboolean found = FALSE;
+ GtkTextIter m_start;
+ GtkTextIter m_end;
+
+ g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
+
+ doc = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ g_return_val_if_fail ((start == NULL) ||
+ (gtk_text_iter_get_buffer (start) ==
+ GTK_TEXT_BUFFER (doc)), FALSE);
+ g_return_val_if_fail ((end == NULL)
+ || (gtk_text_iter_get_buffer (end) ==
+ GTK_TEXT_BUFFER (doc)), FALSE);
+
+ if (view->priv->search_text == NULL)
+ {
+ //gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == NULL\n");
+ return FALSE;
+ }
+ /*else
+ gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == \"%s\"\n", doc->priv->search_text); */
+
+ if (start == NULL)
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (doc), &iter);
+ else
+ iter = *start;
+
+ search_flags = GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_TEXT_ONLY;
+
+ if (!GTR_SEARCH_IS_CASE_SENSITIVE (view->priv->search_flags))
+ {
+ search_flags = search_flags | GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
+ }
+
+ while (!found)
+ {
+ found = gtk_source_iter_forward_search (&iter,
+ view->priv->search_text,
+ search_flags,
+ &m_start, &m_end, end);
+
+ if (found && GTR_SEARCH_IS_ENTIRE_WORD (view->priv->search_flags))
{
- search_flags = search_flags | GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
- }
-
- while (!found)
- {
- found = gtk_source_iter_forward_search (&iter,
- view->priv->search_text,
- search_flags,
- &m_start,
- &m_end,
- end);
-
- if (found && GTR_SEARCH_IS_ENTIRE_WORD (view->priv->search_flags))
- {
- found = gtk_text_iter_starts_word (&m_start) &&
- gtk_text_iter_ends_word (&m_end);
-
- if (!found)
- iter = m_end;
- }
- else
- break;
+ found = gtk_text_iter_starts_word (&m_start) &&
+ gtk_text_iter_ends_word (&m_end);
+
+ if (!found)
+ iter = m_end;
}
-
- if (found && (match_start != NULL))
- *match_start = m_start;
-
- if (found && (match_end != NULL))
- *match_end = m_end;
-
- return found;
+ else
+ break;
+ }
+
+ if (found && (match_start != NULL))
+ *match_start = m_start;
+
+ if (found && (match_end != NULL))
+ *match_end = m_end;
+
+ return found;
}
/**
@@ -618,76 +608,76 @@ gtranslator_view_search_forward (GtranslatorView *view,
* Returns: whether a match was found
*/
gboolean
-gtranslator_view_search_backward (GtranslatorView *view,
- const GtkTextIter *start,
- const GtkTextIter *end,
- GtkTextIter *match_start,
- GtkTextIter *match_end)
+gtranslator_view_search_backward (GtranslatorView * view,
+ const GtkTextIter * start,
+ const GtkTextIter * end,
+ GtkTextIter * match_start,
+ GtkTextIter * match_end)
{
- GtkSourceBuffer *doc;
- GtkTextIter iter;
- GtkSourceSearchFlags search_flags;
- gboolean found = FALSE;
- GtkTextIter m_start;
- GtkTextIter m_end;
-
- g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
-
- doc = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)));
-
- g_return_val_if_fail ((start == NULL) ||
- (gtk_text_iter_get_buffer (start) == GTK_TEXT_BUFFER (doc)), FALSE);
- g_return_val_if_fail ((end == NULL) ||
- (gtk_text_iter_get_buffer (end) == GTK_TEXT_BUFFER (doc)), FALSE);
-
- if (view->priv->search_text == NULL)
+ GtkSourceBuffer *doc;
+ GtkTextIter iter;
+ GtkSourceSearchFlags search_flags;
+ gboolean found = FALSE;
+ GtkTextIter m_start;
+ GtkTextIter m_end;
+
+ g_return_val_if_fail (GTR_IS_VIEW (view), FALSE);
+
+ doc = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ g_return_val_if_fail ((start == NULL) ||
+ (gtk_text_iter_get_buffer (start) ==
+ GTK_TEXT_BUFFER (doc)), FALSE);
+ g_return_val_if_fail ((end == NULL)
+ || (gtk_text_iter_get_buffer (end) ==
+ GTK_TEXT_BUFFER (doc)), FALSE);
+
+ if (view->priv->search_text == NULL)
+ {
+ //gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == NULL\n");
+ return FALSE;
+ }
+ /*else
+ gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == \"%s\"\n", doc->priv->search_text); */
+
+ if (end == NULL)
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &iter);
+ else
+ iter = *end;
+
+ search_flags = GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_TEXT_ONLY;
+
+ if (!GTR_SEARCH_IS_CASE_SENSITIVE (view->priv->search_flags))
+ {
+ search_flags = search_flags | GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
+ }
+
+ while (!found)
+ {
+ found = gtk_source_iter_backward_search (&iter,
+ view->priv->search_text,
+ search_flags,
+ &m_start, &m_end, start);
+
+ if (found && GTR_SEARCH_IS_ENTIRE_WORD (view->priv->search_flags))
{
- //gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == NULL\n");
- return FALSE;
- }
- /*else
- gedit_debug_message (DEBUG_DOCUMENT, "doc->priv->search_text == \"%s\"\n", doc->priv->search_text);*/
-
- if (end == NULL)
- gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &iter);
- else
- iter = *end;
-
- search_flags = GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_TEXT_ONLY;
-
- if (!GTR_SEARCH_IS_CASE_SENSITIVE (view->priv->search_flags))
- {
- search_flags = search_flags | GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
- }
+ found = gtk_text_iter_starts_word (&m_start) &&
+ gtk_text_iter_ends_word (&m_end);
- while (!found)
- {
- found = gtk_source_iter_backward_search (&iter,
- view->priv->search_text,
- search_flags,
- &m_start,
- &m_end,
- start);
-
- if (found && GTR_SEARCH_IS_ENTIRE_WORD (view->priv->search_flags))
- {
- found = gtk_text_iter_starts_word (&m_start) &&
- gtk_text_iter_ends_word (&m_end);
-
- if (!found)
- iter = m_start;
- }
- else
- break;
+ if (!found)
+ iter = m_start;
}
-
- if (found && (match_start != NULL))
- *match_start = m_start;
-
- if (found && (match_end != NULL))
- *match_end = m_end;
-
- return found;
+ else
+ break;
+ }
+
+ if (found && (match_start != NULL))
+ *match_start = m_start;
+
+ if (found && (match_end != NULL))
+ *match_end = m_end;
+
+ return found;
}
/**
@@ -702,108 +692,103 @@ gtranslator_view_search_backward (GtranslatorView *view,
*
* Returns: the number of replacements made it.
*/
-gint
-gtranslator_view_replace_all (GtranslatorView *view,
- const gchar *find,
- const gchar *replace,
- guint flags)
+gint
+gtranslator_view_replace_all (GtranslatorView * view,
+ const gchar * find,
+ const gchar * replace, guint flags)
{
- GtkTextIter iter;
- GtkTextIter m_start;
- GtkTextIter m_end;
- GtkSourceSearchFlags search_flags = 0;
- gboolean found = TRUE;
- gint cont = 0;
- gchar *search_text;
- gchar *replace_text;
- gint replace_text_len;
- GtkTextBuffer *buffer;
-
- g_return_val_if_fail (GTR_IS_VIEW (view), 0);
-
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (view));
-
- g_return_val_if_fail (replace != NULL, 0);
- g_return_val_if_fail ((find != NULL) || (view->priv->search_text != NULL), 0);
-
- if (find == NULL)
- search_text = g_strdup (view->priv->search_text);
- else
- search_text = gtranslator_utils_unescape_search_text (find);
-
- replace_text = gtranslator_utils_unescape_search_text (replace);
-
- gtk_text_buffer_get_start_iter (buffer, &iter);
-
- search_flags = GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_TEXT_ONLY;
-
- if (!GTR_SEARCH_IS_CASE_SENSITIVE (flags))
+ GtkTextIter iter;
+ GtkTextIter m_start;
+ GtkTextIter m_end;
+ GtkSourceSearchFlags search_flags = 0;
+ gboolean found = TRUE;
+ gint cont = 0;
+ gchar *search_text;
+ gchar *replace_text;
+ gint replace_text_len;
+ GtkTextBuffer *buffer;
+
+ g_return_val_if_fail (GTR_IS_VIEW (view), 0);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ g_return_val_if_fail (replace != NULL, 0);
+ g_return_val_if_fail ((find != NULL)
+ || (view->priv->search_text != NULL), 0);
+
+ if (find == NULL)
+ search_text = g_strdup (view->priv->search_text);
+ else
+ search_text = gtranslator_utils_unescape_search_text (find);
+
+ replace_text = gtranslator_utils_unescape_search_text (replace);
+
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+
+ search_flags = GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_TEXT_ONLY;
+
+ if (!GTR_SEARCH_IS_CASE_SENSITIVE (flags))
+ {
+ search_flags = search_flags | GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
+ }
+
+ replace_text_len = strlen (replace_text);
+
+ /* disable cursor_moved emission until the end of the
+ * replace_all so that we don't spend all the time
+ * updating the position in the statusbar
+ */
+ //view->priv->stop_cursor_moved_emission = TRUE;
+
+ gtk_text_buffer_begin_user_action (buffer);
+
+ do
+ {
+ found = gtk_source_iter_forward_search (&iter,
+ search_text,
+ search_flags,
+ &m_start, &m_end, NULL);
+
+ if (found && GTR_SEARCH_IS_ENTIRE_WORD (flags))
{
- search_flags = search_flags | GTK_SOURCE_SEARCH_CASE_INSENSITIVE;
+ gboolean word;
+
+ word = gtk_text_iter_starts_word (&m_start) &&
+ gtk_text_iter_ends_word (&m_end);
+
+ if (!word)
+ {
+ iter = m_end;
+ continue;
+ }
}
- replace_text_len = strlen (replace_text);
+ if (found)
+ {
+ ++cont;
+
+ gtk_text_buffer_delete (buffer, &m_start, &m_end);
+ gtk_text_buffer_insert (buffer,
+ &m_start, replace_text, replace_text_len);
- /* disable cursor_moved emission until the end of the
- * replace_all so that we don't spend all the time
- * updating the position in the statusbar
- */
- //view->priv->stop_cursor_moved_emission = TRUE;
+ iter = m_start;
+ }
- gtk_text_buffer_begin_user_action (buffer);
+ }
+ while (found);
- do
- {
- found = gtk_source_iter_forward_search (&iter,
- search_text,
- search_flags,
- &m_start,
- &m_end,
- NULL);
-
- if (found && GTR_SEARCH_IS_ENTIRE_WORD (flags))
- {
- gboolean word;
-
- word = gtk_text_iter_starts_word (&m_start) &&
- gtk_text_iter_ends_word (&m_end);
-
- if (!word)
- {
- iter = m_end;
- continue;
- }
- }
-
- if (found)
- {
- ++cont;
-
- gtk_text_buffer_delete (buffer,
- &m_start,
- &m_end);
- gtk_text_buffer_insert (buffer,
- &m_start,
- replace_text,
- replace_text_len);
-
- iter = m_start;
- }
-
- } while (found);
-
- gtk_text_buffer_end_user_action (buffer);
-
- /* re-enable cursor_moved emission and notify
- * the current position
- */
- //view->priv->stop_cursor_moved_emission = FALSE;
- //emit_cursor_moved (GTK_SOURCE_BUFFER(buffer));
-
- g_free (search_text);
- g_free (replace_text);
-
- return cont;
+ gtk_text_buffer_end_user_action (buffer);
+
+ /* re-enable cursor_moved emission and notify
+ * the current position
+ */
+ //view->priv->stop_cursor_moved_emission = FALSE;
+ //emit_cursor_moved (GTK_SOURCE_BUFFER(buffer));
+
+ g_free (search_text);
+ g_free (replace_text);
+
+ return cont;
}
/**
@@ -814,18 +799,18 @@ gtranslator_view_replace_all (GtranslatorView *view,
* changes.
*/
void
-gtranslator_view_reload_scheme_color (GtranslatorView *view)
+gtranslator_view_reload_scheme_color (GtranslatorView * view)
{
- GtkSourceBuffer *buf;
- GtkSourceStyleScheme *scheme;
- GtkSourceStyleSchemeManager *manager;
- const gchar *scheme_id;
-
- buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
- manager = gtk_source_style_scheme_manager_get_default ();
-
- scheme_id = gtranslator_prefs_manager_get_color_scheme ();
- scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
-
- gtk_source_buffer_set_style_scheme (buf, scheme);
+ GtkSourceBuffer *buf;
+ GtkSourceStyleScheme *scheme;
+ GtkSourceStyleSchemeManager *manager;
+ const gchar *scheme_id;
+
+ buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+ manager = gtk_source_style_scheme_manager_get_default ();
+
+ scheme_id = gtranslator_prefs_manager_get_color_scheme ();
+ scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
+
+ gtk_source_buffer_set_style_scheme (buf, scheme);
}
diff --git a/src/view.h b/src/view.h
index cc67f81..bdbd267 100644
--- a/src/view.h
+++ b/src/view.h
@@ -25,7 +25,6 @@
#include <gtksourceview/gtksourceview.h>
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -35,80 +34,77 @@ G_BEGIN_DECLS
#define GTR_IS_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_VIEW))
#define GTR_IS_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_VIEW))
#define GTR_VIEW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_VIEW, GtranslatorViewClass))
-
-typedef enum
+ typedef enum
{
- GTR_SEARCH_DONT_SET_FLAGS = 1 << 0,
- GTR_SEARCH_ENTIRE_WORD = 1 << 1,
- GTR_SEARCH_CASE_SENSITIVE = 1 << 2
-
+ GTR_SEARCH_DONT_SET_FLAGS = 1 << 0,
+ GTR_SEARCH_ENTIRE_WORD = 1 << 1,
+ GTR_SEARCH_CASE_SENSITIVE = 1 << 2
} GtranslatorSearchFlags;
/* Private structure type */
-typedef struct _GtranslatorViewPrivate GtranslatorViewPrivate;
+typedef struct _GtranslatorViewPrivate GtranslatorViewPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorView GtranslatorView;
+typedef struct _GtranslatorView GtranslatorView;
struct _GtranslatorView
{
- GtkSourceView parent_instance;
-
- /*< private > */
- GtranslatorViewPrivate *priv;
+ GtkSourceView parent_instance;
+
+ /*< private > */
+ GtranslatorViewPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorViewClass GtranslatorViewClass;
+typedef struct _GtranslatorViewClass GtranslatorViewClass;
struct _GtranslatorViewClass
{
- GtkSourceViewClass parent_class;
+ GtkSourceViewClass parent_class;
};
/*
* Public methods
*/
-GType gtranslator_view_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_view_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_view_register_type (GTypeModule * module);
+ GType gtranslator_view_register_type (GTypeModule * module);
-GtkWidget *gtranslator_view_new (void);
+ GtkWidget *gtranslator_view_new (void);
-gboolean gtranslator_view_get_selected_text (GtranslatorView *view,
- gchar **selected_text,
- gint *len);
+ gboolean gtranslator_view_get_selected_text (GtranslatorView * view,
+ gchar ** selected_text,
+ gint * len);
-void gtranslator_view_enable_spellcheck (GtranslatorView *view,
- gboolean enable);
+ void gtranslator_view_enable_spellcheck (GtranslatorView * view,
+ gboolean enable);
-void gtranslator_view_enable_visible_whitespace
- (GtranslatorView *view,
- gboolean enable);
+ void gtranslator_view_enable_visible_whitespace
+ (GtranslatorView * view, gboolean enable);
-void gtranslator_view_cut_clipboard (GtranslatorView *view);
+ void gtranslator_view_cut_clipboard (GtranslatorView * view);
-void gtranslator_view_copy_clipboard (GtranslatorView *view);
+ void gtranslator_view_copy_clipboard (GtranslatorView * view);
-void gtranslator_view_paste_clipboard (GtranslatorView *view);
+ void gtranslator_view_paste_clipboard (GtranslatorView * view);
-void gtranslator_view_set_font (GtranslatorView *view,
- gboolean def,
- const gchar *font_name);
+ void gtranslator_view_set_font (GtranslatorView * view,
+ gboolean def, const gchar * font_name);
-void gtranslator_view_set_search_text (GtranslatorView *view,
- const gchar *text,
- guint flags);
+ void gtranslator_view_set_search_text (GtranslatorView * view,
+ const gchar * text, guint flags);
-gchar *gtranslator_view_get_search_text (GtranslatorView *view,
- guint *flags);
+ gchar *gtranslator_view_get_search_text (GtranslatorView * view,
+ guint * flags);
-void gtranslator_view_reload_scheme_color (GtranslatorView *view);
+ void gtranslator_view_reload_scheme_color (GtranslatorView * view);
/* Search macros */
@@ -125,5 +121,4 @@ void gtranslator_view_reload_scheme_color (GtranslatorView *view)
(sflags |= GTR_SEARCH_CASE_SENSITIVE) : (sflags &= ~GTR_SEARCH_CASE_SENSITIVE))
G_END_DECLS
-
#endif /* __VIEW_H__ */
diff --git a/src/window.c b/src/window.c
index 728ed8b..4c7aa48 100644
--- a/src/window.c
+++ b/src/window.c
@@ -64,667 +64,669 @@
GTR_TYPE_WINDOW, \
GtranslatorWindowPrivate))
-static void gtranslator_window_cmd_edit_toolbar (GtkAction *action, GtranslatorWindow *window);
-
-
-G_DEFINE_TYPE(GtranslatorWindow, gtranslator_window, GTK_TYPE_WINDOW)
-
-struct _GtranslatorWindowPrivate
-{
- GtkWidget *main_box;
-
- GtkWidget *menubar;
- GtkWidget *view_menu;
- GtkWidget *toolbar;
- GtkActionGroup *always_sensitive_action_group;
- GtkActionGroup *action_group;
- GtkActionGroup *documents_list_action_group;
- guint documents_list_menu_ui_id;
-
- GtkWidget *notebook;
- GtranslatorTab *active_tab;
-
- GtkWidget *dock;
- GdlDockLayout *layout_manager;
- GHashTable *widgets;
-
- GtkWidget *statusbar;
-
- GtkUIManager *ui_manager;
- GtkRecentManager *recent_manager;
- GtkWidget *recent_menu;
-
- GtkWidget *tm_menu;
-
- gint width;
- gint height;
- GdkWindowState window_state;
-
- gboolean destroy_has_run : 1;
-};
+static void gtranslator_window_cmd_edit_toolbar (GtkAction * action,
+ GtranslatorWindow * window);
+
+
+G_DEFINE_TYPE (GtranslatorWindow, gtranslator_window, GTK_TYPE_WINDOW)
+ struct _GtranslatorWindowPrivate
+ {
+ GtkWidget *main_box;
+
+ GtkWidget *menubar;
+ GtkWidget *view_menu;
+ GtkWidget *toolbar;
+ GtkActionGroup *always_sensitive_action_group;
+ GtkActionGroup *action_group;
+ GtkActionGroup *documents_list_action_group;
+ guint documents_list_menu_ui_id;
+
+ GtkWidget *notebook;
+ GtranslatorTab *active_tab;
+
+ GtkWidget *dock;
+ GdlDockLayout *layout_manager;
+ GHashTable *widgets;
+
+ GtkWidget *statusbar;
+
+ GtkUIManager *ui_manager;
+ GtkRecentManager *recent_manager;
+ GtkWidget *recent_menu;
+
+ GtkWidget *tm_menu;
+
+ gint width;
+ gint height;
+ GdkWindowState window_state;
+
+ gboolean destroy_has_run:1;
+ };
+
+ enum
+ {
+ TARGET_URI_LIST = 100
+ };
+
+ static const GtkActionEntry always_sensitive_entries[] = {
+
+ {"File", NULL, N_("_File")},
+ {"Edit", NULL, N_("_Edit")},
+ {"View", NULL, N_("_View")},
+ //{ "Bookmarks", NULL, N_("_Bookmarks") },
+ //{ "Actions", NULL, N_("_Actions") },
+ {"Search", NULL, N_("_Search")},
+ {"Go", NULL, N_("_Go")},
+ {"Documents", NULL, N_("_Documents")},
+ {"Help", NULL, N_("_Help")},
+
+ /* File menu */
+ {"FileOpen", GTK_STOCK_OPEN, NULL, "<control>O",
+ N_("Open a PO file"),
+ G_CALLBACK (gtranslator_open_file_dialog)},
+ {"FileRecentFiles", NULL, N_("_Recent Files"), NULL,
+ NULL, NULL},
+ {"FileQuitWindow", GTK_STOCK_QUIT, NULL, "<control>Q",
+ N_("Quit the program"),
+ G_CALLBACK (gtranslator_file_quit)},
+
+ /* Edit menu */
+ {"EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
+ G_CALLBACK (gtranslator_window_cmd_edit_toolbar)},
+ {"EditPreferences", GTK_STOCK_PREFERENCES, NULL, NULL,
+ N_("Edit gtranslator preferences"),
+ G_CALLBACK (gtranslator_actions_edit_preferences)},
+ {"EditHeader", GTK_STOCK_PROPERTIES, N_("_Header..."), NULL, NULL,
+ G_CALLBACK (gtranslator_actions_edit_header)},
+
+ /* Help menu */
+ {"HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL,
+ G_CALLBACK (gtranslator_cmd_help_contents)},
+ {"HelpAbout", GTK_STOCK_ABOUT, NULL, NULL, NULL,
+ G_CALLBACK (gtranslator_about_dialog)},
+ };
-enum
-{
- TARGET_URI_LIST = 100
-};
-
-static const GtkActionEntry always_sensitive_entries[] = {
-
- { "File", NULL, N_("_File") },
- { "Edit", NULL, N_("_Edit") },
- { "View", NULL, N_("_View") },
- //{ "Bookmarks", NULL, N_("_Bookmarks") },
- //{ "Actions", NULL, N_("_Actions") },
- { "Search", NULL, N_("_Search") },
- { "Go", NULL, N_("_Go") },
- { "Documents", NULL, N_("_Documents") },
- { "Help", NULL, N_("_Help") },
-
- /* File menu */
- { "FileOpen", GTK_STOCK_OPEN, NULL, "<control>O",
- N_("Open a PO file"),
- G_CALLBACK (gtranslator_open_file_dialog) },
- { "FileRecentFiles", NULL, N_("_Recent Files"), NULL,
- NULL, NULL },
- { "FileQuitWindow", GTK_STOCK_QUIT, NULL, "<control>Q",
- N_("Quit the program"),
- G_CALLBACK (gtranslator_file_quit) },
-
- /* Edit menu */
- { "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
- G_CALLBACK (gtranslator_window_cmd_edit_toolbar) },
- { "EditPreferences", GTK_STOCK_PREFERENCES, NULL, NULL,
- N_("Edit gtranslator preferences"),
- G_CALLBACK (gtranslator_actions_edit_preferences) },
- { "EditHeader", GTK_STOCK_PROPERTIES, N_("_Header..."), NULL, NULL,
- G_CALLBACK (gtranslator_actions_edit_header) },
-
- /* Help menu */
- { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL,
- G_CALLBACK (gtranslator_cmd_help_contents) },
- { "HelpAbout", GTK_STOCK_ABOUT, NULL, NULL, NULL,
- G_CALLBACK (gtranslator_about_dialog) },
-};
-
/* Normal items */
static const GtkActionEntry entries[] = {
-
- /* File menu */
- { "FileSave", GTK_STOCK_SAVE, NULL, "<control>S",
- N_("Save the current file"),
- G_CALLBACK (gtranslator_save_current_file_dialog) },
- { "FileSaveAs", GTK_STOCK_SAVE_AS, NULL, "<shift><control>S",
- N_("Save the current file with another name"),
- G_CALLBACK (gtranslator_save_file_as_dialog) },
- /*{ "FileRevert", GTK_STOCK_REVERT_TO_SAVED, N_("_Revert"), NULL,
- N_(),
- G_CALLBACK (gtranslator_save_file_as_dialog) },*/
- { "FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
- N_("Close the current file"),
- G_CALLBACK (gtranslator_file_close) },
-
- /* Edit menu */
- { "EditUndo", GTK_STOCK_UNDO, NULL, "<control>Z",
- N_("Undo last operation"),
- G_CALLBACK(gtranslator_actions_edit_undo) },
- { "EditRedo", GTK_STOCK_REDO, NULL, "<shift><control>Z",
- N_("Redo last undone operation"),
- G_CALLBACK(gtranslator_actions_edit_redo) },
- { "EditCut", GTK_STOCK_CUT, NULL, "<control>X",
- N_("Cut the selected text"),
- G_CALLBACK (gtranslator_actions_edit_cut) },
- { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C",
- N_("Copy the selected text"),
- G_CALLBACK (gtranslator_actions_edit_copy) },
- { "EditPaste", GTK_STOCK_PASTE, NULL, "<control>V",
- N_("Paste the contents of the clipboard"),
- G_CALLBACK (gtranslator_actions_edit_paste) },
- { "EditClear", GTK_STOCK_CLEAR, NULL, NULL,
- N_("Clear the selected translation"),
- G_CALLBACK (gtranslator_actions_edit_clear) },
- { "EditHeader", GTK_STOCK_PROPERTIES, N_("_Header..."), NULL, NULL,
- G_CALLBACK (gtranslator_actions_edit_header) },
- { "EditComment", GTK_STOCK_INDEX, N_("C_omment..."), NULL,
- N_("Edit message comment"),
- G_CALLBACK (gtranslator_edit_message_comment) },
- { "EditMessage2Trans", NULL, N_("Copy _Message to Translation"), "<control>space",
- N_("Copy original message contents to the translation field"),
- G_CALLBACK (gtranslator_message_copy_to_translation) },
- { "EditFuzzy", NULL, N_("Toggle _Fuzzy Status"), "<control>U",
- N_("Toggle fuzzy status of a message"),
- G_CALLBACK (gtranslator_message_status_toggle_fuzzy) },
- { "EditTranslationMemory", NULL, N_("_Translation Memory"), NULL, NULL, NULL},
-
-
- /* View menu */
- { "ViewContext", NULL, N_("_Context"), "<control>J",
- N_("Show the Context panel"),
- G_CALLBACK (gtranslator_actions_view_context) },
- { "ViewTranslationMemory", NULL, N_("_Translation Memory"), "<control>K",
- N_("Show the Translation Memory panel"),
- G_CALLBACK (gtranslator_actions_view_translation_memory) },
- /*{ "ViewSidePane", NULL, N_("Side _Pane"), "F9",
- N_("Show or hide the side pane in the current window"),
- NULL },*/
-
- /* Bookmarks menu */
- /*{ "BookmarksAdd", GTK_STOCK_ADD, N_("_Add Bookmark"), "<control>D",
- N_("Add a bookmark to the current message"), NULL},
- { "BookmarksEdit", GTK_STOCK_EDIT, N_("_Edit Bookmarks"), "<control>B",
- N_("Edit stored bookmarks"), NULL},*/
-
- /* Action menu */
- /*{ "ActionsCompile", GTK_STOCK_CONVERT, N_("_Compile"), NULL,
- N_("Compile the current file to a MO file"), NULL },
- { "ActionsRefresh", GTK_STOCK_REFRESH, NULL, NULL,
- N_(" "), NULL },
- //G_CALLBACK(gtranslator_bookmark_adding_dialog) },
- { "ActionsAutotranslate", NULL, N_("Aut_otranslate..."), NULL,
- N_("Autotranslate the current file using a translation memory"), NULL},
- //G_CALLBACK(gtranslator_auto_translation_dialog) },
- { "ActionsRemoveTranslations", GTK_STOCK_REMOVE, N_("Remo_ve All Translations..."), NULL,
- N_("Remove all existing translations"), NULL},
- //G_CALLBACK(gtranslator_remove_all_translations_dialog) },*/
-
- /* Go menu */
- { "GoPrevious", GTK_STOCK_GO_BACK, N_("_Previous Message"),
- "<alt>Left", N_("Move back one message"),
- G_CALLBACK (gtranslator_message_go_to_previous) },
- { "GoForward", GTK_STOCK_GO_FORWARD, N_("_Next Message"),
- "<alt>Right", N_("Move forward one message"),
- G_CALLBACK (gtranslator_message_go_to_next) },
- { "GoJump", GTK_STOCK_JUMP_TO, N_("_Go to Message..."),
- "<control>G", N_("Jumps to a specific message"),
- G_CALLBACK (gtranslator_message_jump) },
- { "GoFirst", GTK_STOCK_GOTO_FIRST, N_("_First Message"),
- "<alt>Home", N_("Go to the first message"),
- G_CALLBACK (gtranslator_message_go_to_first) },
- { "GoLast", GTK_STOCK_GOTO_LAST, N_("_Last Message"),
- "<alt>End", N_("Go to the last message"),
- G_CALLBACK (gtranslator_message_go_to_last) },
- { "GoNextFuzzy", GTR_STOCK_FUZZY_NEXT, N_("Next Fuz_zy"),
- "<alt><control>Page_Down", N_("Go to the next fuzzy message"),
- G_CALLBACK (gtranslator_message_go_to_next_fuzzy) },
- { "GoPreviousFuzzy", GTR_STOCK_FUZZY_PREV, N_("Previous Fuzz_y"),
- "<alt><control>Page_Up", N_("Go to the previous fuzzy message"),
- G_CALLBACK (gtranslator_message_go_to_prev_fuzzy) },
- { "GoNextUntranslated", GTR_STOCK_UNTRANS_NEXT, N_("Next _Untranslated"),
- "<alt>Page_Down", N_("Go to the next untranslated message"),
- G_CALLBACK (gtranslator_message_go_to_next_untranslated) },
- { "GoPreviousUntranslated", GTR_STOCK_UNTRANS_PREV, N_("Previ_ous Untranslated"),
- "<alt>Page_Up", N_("Go to the previous untranslated message"),
- G_CALLBACK (gtranslator_message_go_to_prev_untranslated) },
- { "GoNextFuzzyUntranslated", GTR_STOCK_FUZZY_UNTRANS_NEXT, N_("Next Fu_zzy or Untranslated"),
- "<control><shift>Page_Down", N_("Go to the next fuzzy or untranslated message"),
- G_CALLBACK (gtranslator_message_go_to_next_fuzzy_or_untranslated) },
- { "GoPreviousFuzzyUntranslated", GTR_STOCK_FUZZY_UNTRANS_PREV, N_("Pre_vious Fuzzy or Untranslated"),
- "<control><shift>Page_Up", N_("Go to the previous fuzzy or untranslated message"),
- G_CALLBACK (gtranslator_message_go_to_prev_fuzzy_or_untranslated) },
-
- /* Search menu*/
- { "SearchFind", GTK_STOCK_FIND, NULL, "<control>F",
- N_("Search for text"),
- G_CALLBACK(_gtranslator_actions_search_find) },
- /*{ "SearchFindNext", NULL, N_("Find Ne_xt"), NULL,
- N_("Search forward for the same text"), NULL},
- // G_CALLBACK (gtranslator_find) },
- { "SearchFindPrevious", NULL, N_("Find _Previous"), NULL,
- N_("Search backward for the same text"), NULL},
- // G_CALLBACK (gtranslator_find) },*/
- { "SearchReplace", GTK_STOCK_FIND_AND_REPLACE, NULL, "<control>H",
- N_("Search for and replace text"),
- G_CALLBACK (_gtranslator_actions_search_replace) },
-
- /* Documents menu */
- { "FileSaveAll", GTK_STOCK_SAVE, N_("_Save All"), "<shift><control>L",
- N_("Save all open files"), G_CALLBACK (_gtranslator_actions_file_save_all) },
- { "FileCloseAll", GTK_STOCK_CLOSE, N_("_Close All"), "<shift><control>W",
- N_("Close all open files"), G_CALLBACK (_gtranslator_actions_file_close_all) },
- { "DocumentsPreviousDocument", NULL, N_("_Previous Document"), "<alt><control>Page_Up",
- N_("Activate previous document"), G_CALLBACK (gtranslator_actions_documents_previous_document) },
- { "DocumentsNextDocument", NULL, N_("_Next Document"), "<alt><control>Page_Down",
- N_("Activate next document"), G_CALLBACK (gtranslator_actions_documents_next_document) }
+
+ /* File menu */
+ {"FileSave", GTK_STOCK_SAVE, NULL, "<control>S",
+ N_("Save the current file"),
+ G_CALLBACK (gtranslator_save_current_file_dialog)},
+ {"FileSaveAs", GTK_STOCK_SAVE_AS, NULL, "<shift><control>S",
+ N_("Save the current file with another name"),
+ G_CALLBACK (gtranslator_save_file_as_dialog)},
+ /*{ "FileRevert", GTK_STOCK_REVERT_TO_SAVED, N_("_Revert"), NULL,
+ N_(),
+ G_CALLBACK (gtranslator_save_file_as_dialog) }, */
+ {"FileCloseWindow", GTK_STOCK_CLOSE, NULL, "<control>W",
+ N_("Close the current file"),
+ G_CALLBACK (gtranslator_file_close)},
+
+ /* Edit menu */
+ {"EditUndo", GTK_STOCK_UNDO, NULL, "<control>Z",
+ N_("Undo last operation"),
+ G_CALLBACK (gtranslator_actions_edit_undo)},
+ {"EditRedo", GTK_STOCK_REDO, NULL, "<shift><control>Z",
+ N_("Redo last undone operation"),
+ G_CALLBACK (gtranslator_actions_edit_redo)},
+ {"EditCut", GTK_STOCK_CUT, NULL, "<control>X",
+ N_("Cut the selected text"),
+ G_CALLBACK (gtranslator_actions_edit_cut)},
+ {"EditCopy", GTK_STOCK_COPY, NULL, "<control>C",
+ N_("Copy the selected text"),
+ G_CALLBACK (gtranslator_actions_edit_copy)},
+ {"EditPaste", GTK_STOCK_PASTE, NULL, "<control>V",
+ N_("Paste the contents of the clipboard"),
+ G_CALLBACK (gtranslator_actions_edit_paste)},
+ {"EditClear", GTK_STOCK_CLEAR, NULL, NULL,
+ N_("Clear the selected translation"),
+ G_CALLBACK (gtranslator_actions_edit_clear)},
+ {"EditHeader", GTK_STOCK_PROPERTIES, N_("_Header..."), NULL, NULL,
+ G_CALLBACK (gtranslator_actions_edit_header)},
+ {"EditComment", GTK_STOCK_INDEX, N_("C_omment..."), NULL,
+ N_("Edit message comment"),
+ G_CALLBACK (gtranslator_edit_message_comment)},
+ {"EditMessage2Trans", NULL, N_("Copy _Message to Translation"),
+ "<control>space",
+ N_("Copy original message contents to the translation field"),
+ G_CALLBACK (gtranslator_message_copy_to_translation)},
+ {"EditFuzzy", NULL, N_("Toggle _Fuzzy Status"), "<control>U",
+ N_("Toggle fuzzy status of a message"),
+ G_CALLBACK (gtranslator_message_status_toggle_fuzzy)},
+ {"EditTranslationMemory", NULL, N_("_Translation Memory"), NULL, NULL,
+ NULL},
+
+
+ /* View menu */
+ {"ViewContext", NULL, N_("_Context"), "<control>J",
+ N_("Show the Context panel"),
+ G_CALLBACK (gtranslator_actions_view_context)},
+ {"ViewTranslationMemory", NULL, N_("_Translation Memory"), "<control>K",
+ N_("Show the Translation Memory panel"),
+ G_CALLBACK (gtranslator_actions_view_translation_memory)},
+ /*{ "ViewSidePane", NULL, N_("Side _Pane"), "F9",
+ N_("Show or hide the side pane in the current window"),
+ NULL }, */
+
+ /* Bookmarks menu */
+ /*{ "BookmarksAdd", GTK_STOCK_ADD, N_("_Add Bookmark"), "<control>D",
+ N_("Add a bookmark to the current message"), NULL},
+ { "BookmarksEdit", GTK_STOCK_EDIT, N_("_Edit Bookmarks"), "<control>B",
+ N_("Edit stored bookmarks"), NULL}, */
+
+ /* Action menu */
+ /*{ "ActionsCompile", GTK_STOCK_CONVERT, N_("_Compile"), NULL,
+ N_("Compile the current file to a MO file"), NULL },
+ { "ActionsRefresh", GTK_STOCK_REFRESH, NULL, NULL,
+ N_(" "), NULL },
+ //G_CALLBACK(gtranslator_bookmark_adding_dialog) },
+ { "ActionsAutotranslate", NULL, N_("Aut_otranslate..."), NULL,
+ N_("Autotranslate the current file using a translation memory"), NULL},
+ //G_CALLBACK(gtranslator_auto_translation_dialog) },
+ { "ActionsRemoveTranslations", GTK_STOCK_REMOVE, N_("Remo_ve All Translations..."), NULL,
+ N_("Remove all existing translations"), NULL},
+ //G_CALLBACK(gtranslator_remove_all_translations_dialog) }, */
+
+ /* Go menu */
+ {"GoPrevious", GTK_STOCK_GO_BACK, N_("_Previous Message"),
+ "<alt>Left", N_("Move back one message"),
+ G_CALLBACK (gtranslator_message_go_to_previous)},
+ {"GoForward", GTK_STOCK_GO_FORWARD, N_("_Next Message"),
+ "<alt>Right", N_("Move forward one message"),
+ G_CALLBACK (gtranslator_message_go_to_next)},
+ {"GoJump", GTK_STOCK_JUMP_TO, N_("_Go to Message..."),
+ "<control>G", N_("Jumps to a specific message"),
+ G_CALLBACK (gtranslator_message_jump)},
+ {"GoFirst", GTK_STOCK_GOTO_FIRST, N_("_First Message"),
+ "<alt>Home", N_("Go to the first message"),
+ G_CALLBACK (gtranslator_message_go_to_first)},
+ {"GoLast", GTK_STOCK_GOTO_LAST, N_("_Last Message"),
+ "<alt>End", N_("Go to the last message"),
+ G_CALLBACK (gtranslator_message_go_to_last)},
+ {"GoNextFuzzy", GTR_STOCK_FUZZY_NEXT, N_("Next Fuz_zy"),
+ "<alt><control>Page_Down", N_("Go to the next fuzzy message"),
+ G_CALLBACK (gtranslator_message_go_to_next_fuzzy)},
+ {"GoPreviousFuzzy", GTR_STOCK_FUZZY_PREV, N_("Previous Fuzz_y"),
+ "<alt><control>Page_Up", N_("Go to the previous fuzzy message"),
+ G_CALLBACK (gtranslator_message_go_to_prev_fuzzy)},
+ {"GoNextUntranslated", GTR_STOCK_UNTRANS_NEXT, N_("Next _Untranslated"),
+ "<alt>Page_Down", N_("Go to the next untranslated message"),
+ G_CALLBACK (gtranslator_message_go_to_next_untranslated)},
+ {"GoPreviousUntranslated", GTR_STOCK_UNTRANS_PREV,
+ N_("Previ_ous Untranslated"),
+ "<alt>Page_Up", N_("Go to the previous untranslated message"),
+ G_CALLBACK (gtranslator_message_go_to_prev_untranslated)},
+ {"GoNextFuzzyUntranslated", GTR_STOCK_FUZZY_UNTRANS_NEXT,
+ N_("Next Fu_zzy or Untranslated"),
+ "<control><shift>Page_Down",
+ N_("Go to the next fuzzy or untranslated message"),
+ G_CALLBACK (gtranslator_message_go_to_next_fuzzy_or_untranslated)},
+ {"GoPreviousFuzzyUntranslated", GTR_STOCK_FUZZY_UNTRANS_PREV,
+ N_("Pre_vious Fuzzy or Untranslated"),
+ "<control><shift>Page_Up",
+ N_("Go to the previous fuzzy or untranslated message"),
+ G_CALLBACK (gtranslator_message_go_to_prev_fuzzy_or_untranslated)},
+
+ /* Search menu */
+ {"SearchFind", GTK_STOCK_FIND, NULL, "<control>F",
+ N_("Search for text"),
+ G_CALLBACK (_gtranslator_actions_search_find)},
+ /*{ "SearchFindNext", NULL, N_("Find Ne_xt"), NULL,
+ N_("Search forward for the same text"), NULL},
+ // G_CALLBACK (gtranslator_find) },
+ { "SearchFindPrevious", NULL, N_("Find _Previous"), NULL,
+ N_("Search backward for the same text"), NULL},
+ // G_CALLBACK (gtranslator_find) }, */
+ {"SearchReplace", GTK_STOCK_FIND_AND_REPLACE, NULL, "<control>H",
+ N_("Search for and replace text"),
+ G_CALLBACK (_gtranslator_actions_search_replace)},
+
+ /* Documents menu */
+ {"FileSaveAll", GTK_STOCK_SAVE, N_("_Save All"), "<shift><control>L",
+ N_("Save all open files"),
+ G_CALLBACK (_gtranslator_actions_file_save_all)},
+ {"FileCloseAll", GTK_STOCK_CLOSE, N_("_Close All"), "<shift><control>W",
+ N_("Close all open files"),
+ G_CALLBACK (_gtranslator_actions_file_close_all)},
+ {"DocumentsPreviousDocument", NULL, N_("_Previous Document"),
+ "<alt><control>Page_Up",
+ N_("Activate previous document"),
+ G_CALLBACK (gtranslator_actions_documents_previous_document)},
+ {"DocumentsNextDocument", NULL, N_("_Next Document"),
+ "<alt><control>Page_Down",
+ N_("Activate next document"),
+ G_CALLBACK (gtranslator_actions_documents_next_document)}
};
/*
* Dock funcs
*/
static void
-on_toggle_widget_view (GtkCheckMenuItem *menuitem,
- GtkWidget *dockitem)
+on_toggle_widget_view (GtkCheckMenuItem * menuitem, GtkWidget * dockitem)
+{
+ gboolean state;
+ state = gtk_check_menu_item_get_active (menuitem);
+ if (state)
+ gdl_dock_item_show_item (GDL_DOCK_ITEM (dockitem));
+ else
+ gdl_dock_item_hide_item (GDL_DOCK_ITEM (dockitem));
+}
+
+static void
+on_update_widget_view_menuitem (gpointer key, gpointer wid, gpointer data)
{
- gboolean state;
- state = gtk_check_menu_item_get_active (menuitem);
- if (state)
- gdl_dock_item_show_item (GDL_DOCK_ITEM (dockitem));
- else
- gdl_dock_item_hide_item (GDL_DOCK_ITEM (dockitem));
+ GtkCheckMenuItem *menuitem;
+ GdlDockItem *dockitem;
+
+ dockitem = g_object_get_data (G_OBJECT (wid), "dockitem");
+ menuitem = g_object_get_data (G_OBJECT (wid), "menuitem");
+
+ g_signal_handlers_block_by_func (menuitem,
+ G_CALLBACK (on_toggle_widget_view),
+ dockitem);
+
+ if (GDL_DOCK_OBJECT_ATTACHED (dockitem))
+ gtk_check_menu_item_set_active (menuitem, TRUE);
+ else
+ gtk_check_menu_item_set_active (menuitem, FALSE);
+
+ g_signal_handlers_unblock_by_func (menuitem,
+ G_CALLBACK (on_toggle_widget_view),
+ dockitem);
}
static void
-on_update_widget_view_menuitem (gpointer key,
- gpointer wid,
- gpointer data)
-{
- GtkCheckMenuItem *menuitem;
- GdlDockItem *dockitem;
-
- dockitem = g_object_get_data (G_OBJECT (wid), "dockitem");
- menuitem = g_object_get_data (G_OBJECT (wid), "menuitem");
-
- g_signal_handlers_block_by_func (menuitem,
- G_CALLBACK (on_toggle_widget_view),
- dockitem);
-
- if (GDL_DOCK_OBJECT_ATTACHED (dockitem))
- gtk_check_menu_item_set_active (menuitem, TRUE);
- else
- gtk_check_menu_item_set_active (menuitem, FALSE);
-
- g_signal_handlers_unblock_by_func (menuitem,
- G_CALLBACK (on_toggle_widget_view),
- dockitem);
-}
-
-static void
-on_layout_dirty_notify (GObject *object,
- GParamSpec *pspec,
- GtranslatorWindow *window)
-{
- if (!strcmp (pspec->name, "dirty")) {
- gboolean dirty;
- g_object_get (object, "dirty", &dirty, NULL);
- if (dirty) {
- /* Update UI toggle buttons */
- g_hash_table_foreach (window->priv->widgets,
- on_update_widget_view_menuitem,
- NULL);
- }
+on_layout_dirty_notify (GObject * object,
+ GParamSpec * pspec, GtranslatorWindow * window)
+{
+ if (!strcmp (pspec->name, "dirty"))
+ {
+ gboolean dirty;
+ g_object_get (object, "dirty", &dirty, NULL);
+ if (dirty)
+ {
+ /* Update UI toggle buttons */
+ g_hash_table_foreach (window->priv->widgets,
+ on_update_widget_view_menuitem, NULL);
}
+ }
}
static void
-gtranslator_window_layout_save (GtranslatorWindow *window,
- const gchar *filename,
- const gchar *name)
+gtranslator_window_layout_save (GtranslatorWindow * window,
+ const gchar * filename, const gchar * name)
{
- g_return_if_fail (GTR_IS_WINDOW (window));
- g_return_if_fail (filename != NULL);
+ g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (filename != NULL);
- gdl_dock_layout_save_layout (window->priv->layout_manager, name);
- if (!gdl_dock_layout_save_to_file (window->priv->layout_manager, filename))
- g_warning ("Saving dock layout to '%s' failed!", filename);
+ gdl_dock_layout_save_layout (window->priv->layout_manager, name);
+ if (!gdl_dock_layout_save_to_file (window->priv->layout_manager, filename))
+ g_warning ("Saving dock layout to '%s' failed!", filename);
}
static void
-gtranslator_window_layout_load (GtranslatorWindow *window,
- const gchar *layout_filename,
- const gchar *name)
+gtranslator_window_layout_load (GtranslatorWindow * window,
+ const gchar * layout_filename,
+ const gchar * name)
{
- g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTR_IS_WINDOW (window));
- if (!layout_filename ||
- !gdl_dock_layout_load_from_file (window->priv->layout_manager,
- layout_filename))
- {
- gchar *path;
-
-
- path = gtranslator_utils_get_file_from_pkgdatadir("layout.xml");
- //DEBUG_PRINT ("Layout = %s", path);
- if (!gdl_dock_layout_load_from_file (window->priv->layout_manager,
- path))
- g_warning ("Loading layout from '%s' failed!!", path);
- g_free (path);
- }
-
- if (!gdl_dock_layout_load_layout (window->priv->layout_manager, name))
- g_warning ("Loading layout failed!!");
+ if (!layout_filename ||
+ !gdl_dock_layout_load_from_file (window->priv->layout_manager,
+ layout_filename))
+ {
+ gchar *path;
+
+
+ path = gtranslator_utils_get_file_from_pkgdatadir ("layout.xml");
+ //DEBUG_PRINT ("Layout = %s", path);
+ if (!gdl_dock_layout_load_from_file (window->priv->layout_manager,
+ path))
+ g_warning ("Loading layout from '%s' failed!!", path);
+ g_free (path);
+ }
+
+ if (!gdl_dock_layout_load_layout (window->priv->layout_manager, name))
+ g_warning ("Loading layout failed!!");
}
static gboolean
remove_from_widgets_hash (gpointer name,
- gpointer hash_widget,
- gpointer widget)
+ gpointer hash_widget, gpointer widget)
{
- if (hash_widget == widget)
- return TRUE;
- return FALSE;
+ if (hash_widget == widget)
+ return TRUE;
+ return FALSE;
}
static void
-on_widget_destroy (GtkWidget *widget,
- GtranslatorWindow *window)
+on_widget_destroy (GtkWidget * widget, GtranslatorWindow * window)
{
- //DEBUG_PRINT ("Widget about to be destroyed");
- g_hash_table_foreach_remove (window->priv->widgets,
- remove_from_widgets_hash,
- widget);
+ //DEBUG_PRINT ("Widget about to be destroyed");
+ g_hash_table_foreach_remove (window->priv->widgets,
+ remove_from_widgets_hash, widget);
}
static void
-on_widget_remove (GtkWidget *container,
- GtkWidget *widget,
- GtranslatorWindow *window)
+on_widget_remove (GtkWidget * container,
+ GtkWidget * widget, GtranslatorWindow * window)
{
- GtkWidget *dock_item;
+ GtkWidget *dock_item;
- dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
- if (dock_item)
- {
- gchar* unique_name = g_object_get_data(G_OBJECT(dock_item), "unique_name");
- g_free(unique_name);
- g_signal_handlers_disconnect_by_func (G_OBJECT (dock_item),
- G_CALLBACK (on_widget_remove),
- window);
- gdl_dock_item_unbind (GDL_DOCK_ITEM(dock_item));
- }
- if (g_hash_table_foreach_remove (window->priv->widgets,
- remove_from_widgets_hash,
- widget)){
- //DEBUG_PRINT ("Widget removed from container");
- }
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ if (dock_item)
+ {
+ gchar *unique_name =
+ g_object_get_data (G_OBJECT (dock_item), "unique_name");
+ g_free (unique_name);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (dock_item),
+ G_CALLBACK (on_widget_remove),
+ window);
+ gdl_dock_item_unbind (GDL_DOCK_ITEM (dock_item));
+ }
+ if (g_hash_table_foreach_remove (window->priv->widgets,
+ remove_from_widgets_hash, widget))
+ {
+ //DEBUG_PRINT ("Widget removed from container");
+ }
}
static void
on_widget_removed_from_hash (gpointer widget)
{
- GtranslatorWindow *window;
- GtkWidget *menuitem;
- GdlDockItem *dockitem;
-
- //DEBUG_PRINT ("Removing widget from hash");
-
- window = g_object_get_data (G_OBJECT (widget), "window-object");
- dockitem = g_object_get_data (G_OBJECT (widget), "dockitem");
- menuitem = g_object_get_data (G_OBJECT (widget), "menuitem");
-
- gtk_widget_destroy (menuitem);
-
- g_object_set_data (G_OBJECT (widget), "dockitem", NULL);
- g_object_set_data (G_OBJECT (widget), "menuitem", NULL);
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
- G_CALLBACK (on_widget_destroy), window);
- g_signal_handlers_disconnect_by_func (G_OBJECT (dockitem),
- G_CALLBACK (on_widget_remove), window);
-
- g_object_unref (G_OBJECT (widget));
-}
-
-static void
-add_widget_full (GtranslatorWindow *window,
- GtkWidget *widget,
+ GtranslatorWindow *window;
+ GtkWidget *menuitem;
+ GdlDockItem *dockitem;
+
+ //DEBUG_PRINT ("Removing widget from hash");
+
+ window = g_object_get_data (G_OBJECT (widget), "window-object");
+ dockitem = g_object_get_data (G_OBJECT (widget), "dockitem");
+ menuitem = g_object_get_data (G_OBJECT (widget), "menuitem");
+
+ gtk_widget_destroy (menuitem);
+
+ g_object_set_data (G_OBJECT (widget), "dockitem", NULL);
+ g_object_set_data (G_OBJECT (widget), "menuitem", NULL);
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
+ G_CALLBACK (on_widget_destroy),
+ window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (dockitem),
+ G_CALLBACK (on_widget_remove),
+ window);
+
+ g_object_unref (G_OBJECT (widget));
+}
+
+static void
+add_widget_full (GtranslatorWindow * window,
+ GtkWidget * widget,
const char *name,
const char *title,
const char *stock_id,
GtranslatorWindowPlacement placement,
- gboolean locked,
- GError **error)
+ gboolean locked, GError ** error)
{
- GtkWidget *item;
- GtkCheckMenuItem* menuitem;
+ GtkWidget *item;
+ GtkCheckMenuItem *menuitem;
- g_return_if_fail (GTR_IS_WINDOW (window));
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (name != NULL);
- g_return_if_fail (title != NULL);
+ g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (title != NULL);
- /* Add the widget to hash */
- if (window->priv->widgets == NULL)
- {
- window->priv->widgets = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free,
- on_widget_removed_from_hash);
- }
- g_hash_table_insert (window->priv->widgets, g_strdup (name), widget);
- g_object_ref (widget);
-
- /* Add the widget to dock */
- if (stock_id == NULL)
- item = gdl_dock_item_new (name, title, GDL_DOCK_ITEM_BEH_NORMAL);
- else
- item = gdl_dock_item_new_with_stock (name, title, stock_id,
- GDL_DOCK_ITEM_BEH_NORMAL);
- if (locked)
- {
- guint flags = 0;
- flags |= GDL_DOCK_ITEM_BEH_NEVER_FLOATING;
- flags |= GDL_DOCK_ITEM_BEH_CANT_CLOSE;
- flags |= GDL_DOCK_ITEM_BEH_CANT_ICONIFY;
- flags |= GDL_DOCK_ITEM_BEH_NO_GRIP;
- g_object_set(G_OBJECT(item), "behavior", flags, NULL);
- }
-
- gtk_container_add (GTK_CONTAINER (item), widget);
- gdl_dock_add_item (GDL_DOCK (window->priv->dock),
- GDL_DOCK_ITEM (item), placement);
- gtk_widget_show_all (item);
-
- /* Add toggle button for the widget */
- menuitem = GTK_CHECK_MENU_ITEM (gtk_check_menu_item_new_with_label (title));
- gtk_widget_show (GTK_WIDGET (menuitem));
- gtk_check_menu_item_set_active (menuitem, TRUE);
- gtk_menu_shell_append (GTK_MENU_SHELL (window->priv->view_menu), GTK_WIDGET (menuitem));
-
- if (locked)
- g_object_set( G_OBJECT(menuitem), "visible", FALSE, NULL);
-
-
- g_object_set_data (G_OBJECT (widget), "window-object", window);
- g_object_set_data (G_OBJECT (widget), "menuitem", menuitem);
- g_object_set_data (G_OBJECT (widget), "dockitem", item);
-
- /* For toggling widget view on/off */
- g_signal_connect (G_OBJECT (menuitem), "toggled",
- G_CALLBACK (on_toggle_widget_view), item);
-
- /*
- Watch for widget removal/destruction so that it could be
- removed from widgets hash.
- */
- g_signal_connect (G_OBJECT (item), "remove",
- G_CALLBACK (on_widget_remove), window);
- g_signal_connect_after (G_OBJECT (widget), "destroy",
- G_CALLBACK (on_widget_destroy), window);
-}
-
-static void
-remove_widget (GtranslatorWindow *window,
- GtkWidget *widget,
- GError **error)
-{
- GtkWidget *dock_item;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- g_return_if_fail (window->priv->widgets != NULL);
-
- dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
- g_return_if_fail (dock_item != NULL);
-
- /* Remove the widget from container */
- g_object_ref (widget);
- /* It should call on_widget_remove() and clean up should happen */
- gtk_container_remove (GTK_CONTAINER (dock_item), widget);
- g_object_unref (widget);
-}
-
-static void
-gtranslator_app_present_widget (GtranslatorWindow *window,
- GtkWidget *widget,
- GError **error)
-{
- GdlDockItem *dock_item;
- GtkWidget *parent;
-
- g_return_if_fail (GTR_IS_WINDOW (window));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- g_return_if_fail (window->priv->widgets != NULL);
-
- dock_item = g_object_get_data (G_OBJECT(widget), "dockitem");
- g_return_if_fail (dock_item != NULL);
-
- /* Hack to present the dock item if it's in a notebook dock item */
- parent = gtk_widget_get_parent (GTK_WIDGET(dock_item) );
- if (GTK_IS_NOTEBOOK (parent))
- {
- gint pagenum;
- pagenum = gtk_notebook_page_num (GTK_NOTEBOOK (parent), GTK_WIDGET (dock_item));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (parent), pagenum);
- }
- else if (!GDL_DOCK_OBJECT_ATTACHED (dock_item))
- {
- gdl_dock_item_show_item (GDL_DOCK_ITEM (dock_item));
- }
-
- /* FIXME: If the item is floating, present the window */
- /* FIXME: There is no way to detect if a widget was floating before it was
- detached since it no longer has a parent there is no way to access the
- floating property of the GdlDock structure.*/
+ /* Add the widget to hash */
+ if (window->priv->widgets == NULL)
+ {
+ window->priv->widgets = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free,
+ on_widget_removed_from_hash);
+ }
+ g_hash_table_insert (window->priv->widgets, g_strdup (name), widget);
+ g_object_ref (widget);
+
+ /* Add the widget to dock */
+ if (stock_id == NULL)
+ item = gdl_dock_item_new (name, title, GDL_DOCK_ITEM_BEH_NORMAL);
+ else
+ item = gdl_dock_item_new_with_stock (name, title, stock_id,
+ GDL_DOCK_ITEM_BEH_NORMAL);
+ if (locked)
+ {
+ guint flags = 0;
+ flags |= GDL_DOCK_ITEM_BEH_NEVER_FLOATING;
+ flags |= GDL_DOCK_ITEM_BEH_CANT_CLOSE;
+ flags |= GDL_DOCK_ITEM_BEH_CANT_ICONIFY;
+ flags |= GDL_DOCK_ITEM_BEH_NO_GRIP;
+ g_object_set (G_OBJECT (item), "behavior", flags, NULL);
+ }
+
+ gtk_container_add (GTK_CONTAINER (item), widget);
+ gdl_dock_add_item (GDL_DOCK (window->priv->dock),
+ GDL_DOCK_ITEM (item), placement);
+ gtk_widget_show_all (item);
+
+ /* Add toggle button for the widget */
+ menuitem = GTK_CHECK_MENU_ITEM (gtk_check_menu_item_new_with_label (title));
+ gtk_widget_show (GTK_WIDGET (menuitem));
+ gtk_check_menu_item_set_active (menuitem, TRUE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (window->priv->view_menu),
+ GTK_WIDGET (menuitem));
+
+ if (locked)
+ g_object_set (G_OBJECT (menuitem), "visible", FALSE, NULL);
+
+
+ g_object_set_data (G_OBJECT (widget), "window-object", window);
+ g_object_set_data (G_OBJECT (widget), "menuitem", menuitem);
+ g_object_set_data (G_OBJECT (widget), "dockitem", item);
+
+ /* For toggling widget view on/off */
+ g_signal_connect (G_OBJECT (menuitem), "toggled",
+ G_CALLBACK (on_toggle_widget_view), item);
+
+ /*
+ Watch for widget removal/destruction so that it could be
+ removed from widgets hash.
+ */
+ g_signal_connect (G_OBJECT (item), "remove",
+ G_CALLBACK (on_widget_remove), window);
+ g_signal_connect_after (G_OBJECT (widget), "destroy",
+ G_CALLBACK (on_widget_destroy), window);
+}
+
+static void
+remove_widget (GtranslatorWindow * window,
+ GtkWidget * widget, GError ** error)
+{
+ GtkWidget *dock_item;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ g_return_if_fail (window->priv->widgets != NULL);
+
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ g_return_if_fail (dock_item != NULL);
+
+ /* Remove the widget from container */
+ g_object_ref (widget);
+ /* It should call on_widget_remove() and clean up should happen */
+ gtk_container_remove (GTK_CONTAINER (dock_item), widget);
+ g_object_unref (widget);
+}
+
+static void
+gtranslator_app_present_widget (GtranslatorWindow * window,
+ GtkWidget * widget, GError ** error)
+{
+ GdlDockItem *dock_item;
+ GtkWidget *parent;
+
+ g_return_if_fail (GTR_IS_WINDOW (window));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ g_return_if_fail (window->priv->widgets != NULL);
+
+ dock_item = g_object_get_data (G_OBJECT (widget), "dockitem");
+ g_return_if_fail (dock_item != NULL);
+
+ /* Hack to present the dock item if it's in a notebook dock item */
+ parent = gtk_widget_get_parent (GTK_WIDGET (dock_item));
+ if (GTK_IS_NOTEBOOK (parent))
+ {
+ gint pagenum;
+ pagenum =
+ gtk_notebook_page_num (GTK_NOTEBOOK (parent), GTK_WIDGET (dock_item));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (parent), pagenum);
+ }
+ else if (!GDL_DOCK_OBJECT_ATTACHED (dock_item))
+ {
+ gdl_dock_item_show_item (GDL_DOCK_ITEM (dock_item));
+ }
+
+ /* FIXME: If the item is floating, present the window */
+ /* FIXME: There is no way to detect if a widget was floating before it was
+ detached since it no longer has a parent there is no way to access the
+ floating property of the GdlDock structure. */
}
void
-set_sensitive_according_to_message(GtranslatorWindow *window,
- GtranslatorPo *po)
-{
- GList *current;
- GtkAction *action;
-
- current = gtranslator_po_get_current_message(po);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoForward");
- gtk_action_set_sensitive (action,
- g_list_next(current) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoPrevious");
- gtk_action_set_sensitive (action,
- g_list_previous(current) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoFirst");
- gtk_action_set_sensitive (action,
- g_list_first(current) != current);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoLast");
- gtk_action_set_sensitive (action,
- g_list_last(current) != current);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoNextFuzzy");
- gtk_action_set_sensitive (action,
- gtranslator_po_get_next_fuzzy(po) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoPreviousFuzzy");
- gtk_action_set_sensitive (action,
- gtranslator_po_get_prev_fuzzy(po) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoNextUntranslated");
- gtk_action_set_sensitive (action,
- gtranslator_po_get_next_untrans(po) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoPreviousUntranslated");
- gtk_action_set_sensitive (action,
- gtranslator_po_get_prev_untrans(po) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoNextFuzzyUntranslated");
- gtk_action_set_sensitive (action,
- gtranslator_po_get_next_fuzzy_or_untrans (po) != NULL);
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "GoPreviousFuzzyUntranslated");
- gtk_action_set_sensitive (action,
- gtranslator_po_get_prev_fuzzy_or_untrans (po) != NULL);
+set_sensitive_according_to_message (GtranslatorWindow * window,
+ GtranslatorPo * po)
+{
+ GList *current;
+ GtkAction *action;
+
+ current = gtranslator_po_get_current_message (po);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoForward");
+ gtk_action_set_sensitive (action, g_list_next (current) != NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoPrevious");
+ gtk_action_set_sensitive (action, g_list_previous (current) != NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoFirst");
+ gtk_action_set_sensitive (action, g_list_first (current) != current);
+
+ action = gtk_action_group_get_action (window->priv->action_group, "GoLast");
+ gtk_action_set_sensitive (action, g_list_last (current) != current);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoNextFuzzy");
+ gtk_action_set_sensitive (action,
+ gtranslator_po_get_next_fuzzy (po) != NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoPreviousFuzzy");
+ gtk_action_set_sensitive (action,
+ gtranslator_po_get_prev_fuzzy (po) != NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoNextUntranslated");
+ gtk_action_set_sensitive (action,
+ gtranslator_po_get_next_untrans (po) != NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoPreviousUntranslated");
+ gtk_action_set_sensitive (action,
+ gtranslator_po_get_prev_untrans (po) != NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoNextFuzzyUntranslated");
+ gtk_action_set_sensitive (action,
+ gtranslator_po_get_next_fuzzy_or_untrans (po) !=
+ NULL);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "GoPreviousFuzzyUntranslated");
+ gtk_action_set_sensitive (action,
+ gtranslator_po_get_prev_fuzzy_or_untrans (po) !=
+ NULL);
}
static void
-set_sensitive_according_to_tab(GtranslatorWindow *window,
- GtranslatorTab *tab)
-{
- GtranslatorNotebook *notebook;
- GtranslatorView *view;
- GtranslatorPo *po;
- GtkSourceBuffer *buf;
- GtkAction *action;
- GList *current;
- GtranslatorPoState state;
- gint pages;
- gint current_page;
-
- notebook = gtranslator_window_get_notebook (window);
- pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->priv->notebook));
- view = gtranslator_tab_get_active_view(tab);
- po = gtranslator_tab_get_po(tab);
- current = gtranslator_po_get_current_message(po);
- buf = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)));
-
- if(gtk_action_group_get_sensitive(window->priv->action_group) == FALSE)
- gtk_action_group_set_sensitive(window->priv->action_group, TRUE);
-
- /*File*/
- state = gtranslator_po_get_state(po);
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileSave");
- gtk_action_set_sensitive (action,
- state == GTR_PO_STATE_MODIFIED);
-
- /*Edit*/
- action = gtk_action_group_get_action(window->priv->action_group,
- "EditUndo");
- gtk_action_set_sensitive (action,
- gtk_source_buffer_can_undo (buf));
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "EditRedo");
- gtk_action_set_sensitive (action,
- gtk_source_buffer_can_redo (buf));
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "EditCut");
- gtk_action_set_sensitive (action,
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buf)));
-
- action = gtk_action_group_get_action(window->priv->action_group,
- "EditCopy");
- gtk_action_set_sensitive (action,
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buf)));
-
- /*Go*/
- current_page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET (tab));
- g_return_if_fail (current_page >= 0);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsPreviousDocument");
- gtk_action_set_sensitive (action, current_page != 0);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsNextDocument");
- gtk_action_set_sensitive (action,
- current_page < pages - 1);
-
- set_sensitive_according_to_message(window, po);
+set_sensitive_according_to_tab (GtranslatorWindow * window,
+ GtranslatorTab * tab)
+{
+ GtranslatorNotebook *notebook;
+ GtranslatorView *view;
+ GtranslatorPo *po;
+ GtkSourceBuffer *buf;
+ GtkAction *action;
+ GList *current;
+ GtranslatorPoState state;
+ gint pages;
+ gint current_page;
+
+ notebook = gtranslator_window_get_notebook (window);
+ pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook));
+ view = gtranslator_tab_get_active_view (tab);
+ po = gtranslator_tab_get_po (tab);
+ current = gtranslator_po_get_current_message (po);
+ buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ if (gtk_action_group_get_sensitive (window->priv->action_group) == FALSE)
+ gtk_action_group_set_sensitive (window->priv->action_group, TRUE);
+
+ /*File */
+ state = gtranslator_po_get_state (po);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileSave");
+ gtk_action_set_sensitive (action, state == GTR_PO_STATE_MODIFIED);
+
+ /*Edit */
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditUndo");
+ gtk_action_set_sensitive (action, gtk_source_buffer_can_undo (buf));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditRedo");
+ gtk_action_set_sensitive (action, gtk_source_buffer_can_redo (buf));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditCut");
+ gtk_action_set_sensitive (action,
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER
+ (buf)));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditCopy");
+ gtk_action_set_sensitive (action,
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER
+ (buf)));
+
+ /*Go */
+ current_page =
+ gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET (tab));
+ g_return_if_fail (current_page >= 0);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsPreviousDocument");
+ gtk_action_set_sensitive (action, current_page != 0);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsNextDocument");
+ gtk_action_set_sensitive (action, current_page < pages - 1);
+
+ set_sensitive_according_to_message (window, po);
}
void
-set_sensitive_according_to_window(GtranslatorWindow *window)
+set_sensitive_according_to_window (GtranslatorWindow * window)
{
- gint pages;
-
- pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->priv->notebook));
-
- gtk_action_group_set_sensitive(window->priv->action_group,
- pages > 0);
+ gint pages;
+
+ pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook));
+
+ gtk_action_group_set_sensitive (window->priv->action_group, pages > 0);
}
/*
@@ -734,1113 +736,1073 @@ set_sensitive_according_to_window(GtranslatorWindow *window)
* in the statusbar widget.
*/
static void
-gtranslator_window_update_statusbar_message_count(GtranslatorTab *tab,
- GtranslatorMsg *message,
- GtranslatorWindow *window)
-{
- GtranslatorPo *po;
- gchar *msg;
- gchar *status, *status_msg;
- gchar *current;
- gchar *total;
- gchar *fuzzy_msg;
- gchar *untranslated_msg;
- gint pos, message_count, fuzzy, untranslated;
-
- g_return_if_fail(GTR_IS_MSG(message));
-
- po = gtranslator_tab_get_po(tab);
-
- message_count = gtranslator_po_get_messages_count(po);
- pos = gtranslator_po_get_message_position(po);
- fuzzy = gtranslator_po_get_fuzzy_count(po);
- untranslated = gtranslator_po_get_untranslated_count(po);
-
- switch(gtranslator_msg_get_status(message))
- {
- case GTR_MSG_STATUS_UNTRANSLATED: status = _("Untranslated");
- break;
- case GTR_MSG_STATUS_TRANSLATED: status = _("Translated");
- break;
- case GTR_MSG_STATUS_FUZZY: status = _("Fuzzy");
- break;
- default: break;
- }
+gtranslator_window_update_statusbar_message_count (GtranslatorTab * tab,
+ GtranslatorMsg * message,
+ GtranslatorWindow * window)
+{
+ GtranslatorPo *po;
+ gchar *msg;
+ gchar *status, *status_msg;
+ gchar *current;
+ gchar *total;
+ gchar *fuzzy_msg;
+ gchar *untranslated_msg;
+ gint pos, message_count, fuzzy, untranslated;
+
+ g_return_if_fail (GTR_IS_MSG (message));
+
+ po = gtranslator_tab_get_po (tab);
+
+ message_count = gtranslator_po_get_messages_count (po);
+ pos = gtranslator_po_get_message_position (po);
+ fuzzy = gtranslator_po_get_fuzzy_count (po);
+ untranslated = gtranslator_po_get_untranslated_count (po);
+
+ switch (gtranslator_msg_get_status (message))
+ {
+ case GTR_MSG_STATUS_UNTRANSLATED:
+ status = _("Untranslated");
+ break;
+ case GTR_MSG_STATUS_TRANSLATED:
+ status = _("Translated");
+ break;
+ case GTR_MSG_STATUS_FUZZY:
+ status = _("Fuzzy");
+ break;
+ default:
+ break;
+ }
+
+ status_msg = g_strdup_printf ("(%s)", status);
+ current = g_strdup_printf (_("Current: %d"), pos);
+ total = g_strdup_printf (_("Total: %d translated"), message_count);
+ fuzzy_msg = g_strdup_printf (_("%d fuzzy"), fuzzy);
+ untranslated_msg = g_strdup_printf (_("%d untranslated"), untranslated);
+
+ msg = g_strconcat (" ", current, " ", status_msg, " ", total,
+ ", ", fuzzy_msg, ", ", untranslated_msg, NULL);
+
+ gtranslator_statusbar_pop (GTR_STATUSBAR (window->priv->statusbar), 0);
- status_msg = g_strdup_printf("(%s)", status);
- current = g_strdup_printf(_("Current: %d"), pos);
- total = g_strdup_printf(_("Total: %d translated"), message_count);
- fuzzy_msg = g_strdup_printf(_("%d fuzzy"), fuzzy);
- untranslated_msg = g_strdup_printf(_("%d untranslated"), untranslated);
-
- msg = g_strconcat (" ", current, " ", status_msg, " ", total,
- ", ", fuzzy_msg, ", ", untranslated_msg, NULL);
-
- gtranslator_statusbar_pop (GTR_STATUSBAR (window->priv->statusbar),
- 0);
-
- gtranslator_statusbar_push (GTR_STATUSBAR (window->priv->statusbar),
- 0,
- msg);
-
- g_free(msg);
- g_free(current);
- g_free(status_msg);
- g_free(total);
- g_free(fuzzy_msg);
- g_free(untranslated_msg);
-
- /*
- * We have to update the progress bar too
- */
- gtranslator_statusbar_update_progress_bar (GTR_STATUSBAR (window->priv->statusbar),
- (gdouble)gtranslator_po_get_translated_count (po),
- (gdouble)gtranslator_po_get_messages_count (po));
+ gtranslator_statusbar_push (GTR_STATUSBAR (window->priv->statusbar),
+ 0, msg);
+
+ g_free (msg);
+ g_free (current);
+ g_free (status_msg);
+ g_free (total);
+ g_free (fuzzy_msg);
+ g_free (untranslated_msg);
+
+ /*
+ * We have to update the progress bar too
+ */
+ gtranslator_statusbar_update_progress_bar (GTR_STATUSBAR
+ (window->priv->statusbar),
+ (gdouble)
+ gtranslator_po_get_translated_count
+ (po),
+ (gdouble)
+ gtranslator_po_get_messages_count
+ (po));
}
static void
-documents_list_menu_activate (GtkToggleAction *action,
- GtranslatorWindow *window)
+documents_list_menu_activate (GtkToggleAction * action,
+ GtranslatorWindow * window)
{
- gint n;
+ gint n;
- if (gtk_toggle_action_get_active (action) == FALSE)
- return;
+ if (gtk_toggle_action_get_active (action) == FALSE)
+ return;
- n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), n);
+ n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), n);
}
static gchar *
-get_menu_tip_for_tab (GtranslatorTab *tab)
+get_menu_tip_for_tab (GtranslatorTab * tab)
{
- GtranslatorPo *doc;
- gchar *uri;
- gchar *ruri;
- gchar *tip;
- GFile *file;
+ GtranslatorPo *doc;
+ gchar *uri;
+ gchar *ruri;
+ gchar *tip;
+ GFile *file;
- doc = gtranslator_tab_get_po (tab);
- file = gtranslator_po_get_location (doc);
+ doc = gtranslator_tab_get_po (tab);
+ file = gtranslator_po_get_location (doc);
- uri = g_file_get_path (file);
- g_object_unref (file);
+ uri = g_file_get_path (file);
+ g_object_unref (file);
- /* Translators: %s is a URI */
- tip = g_strdup_printf (_("Activate '%s'"), uri);
- g_free (uri);
-
- return tip;
+ /* Translators: %s is a URI */
+ tip = g_strdup_printf (_("Activate '%s'"), uri);
+ g_free (uri);
+
+ return tip;
}
static void
-update_documents_list_menu (GtranslatorWindow *window)
+update_documents_list_menu (GtranslatorWindow * window)
{
- GtranslatorWindowPrivate *p = window->priv;
- GList *actions, *l;
- gint n, i;
- guint id;
- GSList *group = NULL;
+ GtranslatorWindowPrivate *p = window->priv;
+ GList *actions, *l;
+ gint n, i;
+ guint id;
+ GSList *group = NULL;
- g_return_if_fail (p->documents_list_action_group != NULL);
+ g_return_if_fail (p->documents_list_action_group != NULL);
- if (p->documents_list_menu_ui_id != 0)
- gtk_ui_manager_remove_ui (p->ui_manager,
- p->documents_list_menu_ui_id);
+ if (p->documents_list_menu_ui_id != 0)
+ gtk_ui_manager_remove_ui (p->ui_manager, p->documents_list_menu_ui_id);
- actions = gtk_action_group_list_actions (p->documents_list_action_group);
- for (l = actions; l != NULL; l = l->next)
- {
- g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
- G_CALLBACK (documents_list_menu_activate),
- window);
- gtk_action_group_remove_action (p->documents_list_action_group,
- GTK_ACTION (l->data));
- }
- g_list_free (actions);
+ actions = gtk_action_group_list_actions (p->documents_list_action_group);
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
+ G_CALLBACK
+ (documents_list_menu_activate),
+ window);
+ gtk_action_group_remove_action (p->documents_list_action_group,
+ GTK_ACTION (l->data));
+ }
+ g_list_free (actions);
- n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (p->notebook));
+ n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (p->notebook));
- id = (n > 0) ? gtk_ui_manager_new_merge_id (p->ui_manager) : 0;
+ id = (n > 0) ? gtk_ui_manager_new_merge_id (p->ui_manager) : 0;
- for (i = 0; i < n; i++)
- {
- GtkWidget *tab;
- GtkRadioAction *action;
- gchar *action_name;
- gchar *tab_name;
- gchar *name;
- gchar *tip;
- gchar *accel;
-
- tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
-
- /* NOTE: the action is associated to the position of the tab in
- * the notebook not to the tab itself! This is needed to work
- * around the gtk+ bug #170727: gtk leaves around the accels
- * of the action. Since the accel depends on the tab position
- * the problem is worked around, action with the same name always
- * get the same accel.
- */
- action_name = g_strdup_printf ("Tab_%d", i);
- tab_name = gtranslator_tab_get_name (GTR_TAB (tab));
- name = gtranslator_utils_escape_underscores (tab_name, -1);
- tip = get_menu_tip_for_tab (GTR_TAB (tab));
-
- /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
- accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL;
-
- action = gtk_radio_action_new (action_name,
- name,
- tip,
- NULL,
- i);
-
- if (group != NULL)
- gtk_radio_action_set_group (action, group);
-
- /* note that group changes each time we add an action, so it must be updated */
- group = gtk_radio_action_get_group (action);
-
- gtk_action_group_add_action_with_accel (p->documents_list_action_group,
- GTK_ACTION (action),
- accel);
-
- g_signal_connect (action,
- "activate",
- G_CALLBACK (documents_list_menu_activate),
- window);
-
- gtk_ui_manager_add_ui (p->ui_manager,
- id,
- "/MainMenu/DocumentsMenu/DocumentsListPlaceholder",
- action_name, action_name,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
-
- if (GTR_TAB (tab) == p->active_tab)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
- g_object_unref (action);
-
- g_free (action_name);
- g_free (tab_name);
- g_free (name);
- g_free (tip);
- g_free (accel);
- }
+ for (i = 0; i < n; i++)
+ {
+ GtkWidget *tab;
+ GtkRadioAction *action;
+ gchar *action_name;
+ gchar *tab_name;
+ gchar *name;
+ gchar *tip;
+ gchar *accel;
+
+ tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
+
+ /* NOTE: the action is associated to the position of the tab in
+ * the notebook not to the tab itself! This is needed to work
+ * around the gtk+ bug #170727: gtk leaves around the accels
+ * of the action. Since the accel depends on the tab position
+ * the problem is worked around, action with the same name always
+ * get the same accel.
+ */
+ action_name = g_strdup_printf ("Tab_%d", i);
+ tab_name = gtranslator_tab_get_name (GTR_TAB (tab));
+ name = gtranslator_utils_escape_underscores (tab_name, -1);
+ tip = get_menu_tip_for_tab (GTR_TAB (tab));
+
+ /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
+ accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL;
+
+ action = gtk_radio_action_new (action_name, name, tip, NULL, i);
+
+ if (group != NULL)
+ gtk_radio_action_set_group (action, group);
+
+ /* note that group changes each time we add an action, so it must be updated */
+ group = gtk_radio_action_get_group (action);
+
+ gtk_action_group_add_action_with_accel (p->documents_list_action_group,
+ GTK_ACTION (action), accel);
+
+ g_signal_connect (action,
+ "activate",
+ G_CALLBACK (documents_list_menu_activate), window);
+
+ gtk_ui_manager_add_ui (p->ui_manager,
+ id,
+ "/MainMenu/DocumentsMenu/DocumentsListPlaceholder",
+ action_name, action_name,
+ GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ if (GTR_TAB (tab) == p->active_tab)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- p->documents_list_menu_ui_id = id;
+ g_object_unref (action);
+
+ g_free (action_name);
+ g_free (tab_name);
+ g_free (name);
+ g_free (tip);
+ g_free (accel);
+ }
+
+ p->documents_list_menu_ui_id = id;
}
static GtranslatorWindow *
-get_drop_window (GtkWidget *widget)
+get_drop_window (GtkWidget * widget)
{
- GtkWidget *target_window;
+ GtkWidget *target_window;
- target_window = gtk_widget_get_toplevel (widget);
- g_return_val_if_fail (GTR_IS_WINDOW (target_window), NULL);
-
- return GTR_WINDOW (target_window);
+ target_window = gtk_widget_get_toplevel (widget);
+ g_return_val_if_fail (GTR_IS_WINDOW (target_window), NULL);
+
+ return GTR_WINDOW (target_window);
}
/* Handle drops on the GtranslatorWindow */
static void
-drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- gpointer data)
-{
- GtranslatorWindow *window;
- GSList *locations;
-
- window = get_drop_window (widget);
-
- if (window == NULL)
- return;
-
- if (info == TARGET_URI_LIST)
- {
- locations = gtranslator_utils_drop_get_locations (selection_data);
- gtranslator_actions_load_locations (window, locations);
-
- g_slist_foreach (locations, (GFunc)g_object_unref, NULL);
- g_slist_free (locations);
- }
+drag_data_received_cb (GtkWidget * widget,
+ GdkDragContext * context,
+ gint x,
+ gint y,
+ GtkSelectionData * selection_data,
+ guint info, guint time, gpointer data)
+{
+ GtranslatorWindow *window;
+ GSList *locations;
+
+ window = get_drop_window (widget);
+
+ if (window == NULL)
+ return;
+
+ if (info == TARGET_URI_LIST)
+ {
+ locations = gtranslator_utils_drop_get_locations (selection_data);
+ gtranslator_actions_load_locations (window, locations);
+
+ g_slist_foreach (locations, (GFunc) g_object_unref, NULL);
+ g_slist_free (locations);
+ }
}
static void
-update_overwrite_mode_statusbar (GtkTextView *view,
- GtranslatorWindow *window)
+update_overwrite_mode_statusbar (GtkTextView * view,
+ GtranslatorWindow * window)
{
- if (view != GTK_TEXT_VIEW (gtranslator_window_get_active_view (window)))
- return;
-
- /* Note that we have to use !gtk_text_view_get_overwrite since we
- are in the in the signal handler of "toggle overwrite" that is
- G_SIGNAL_RUN_LAST
- */
- gtranslator_statusbar_set_overwrite (
- GTR_STATUSBAR (window->priv->statusbar),
- !gtk_text_view_get_overwrite (view));
+ if (view != GTK_TEXT_VIEW (gtranslator_window_get_active_view (window)))
+ return;
+
+ /* Note that we have to use !gtk_text_view_get_overwrite since we
+ are in the in the signal handler of "toggle overwrite" that is
+ G_SIGNAL_RUN_LAST
+ */
+ gtranslator_statusbar_set_overwrite (GTR_STATUSBAR
+ (window->priv->statusbar),
+ !gtk_text_view_get_overwrite (view));
}
static void
-set_window_title (GtranslatorWindow *window,
- gboolean with_path)
+set_window_title (GtranslatorWindow * window, gboolean with_path)
{
GtranslatorPo *po;
GtranslatorPoState state;
GtranslatorTab *active_tab;
GFile *file;
gchar *title;
-
+
if (with_path)
{
- po = gtranslator_tab_get_po (GTR_TAB (gtranslator_window_get_active_tab (window)));
+ po =
+ gtranslator_tab_get_po (GTR_TAB
+ (gtranslator_window_get_active_tab (window)));
active_tab = gtranslator_window_get_active_tab (window);
- state = gtranslator_po_get_state (gtranslator_tab_get_po(active_tab));
+ state = gtranslator_po_get_state (gtranslator_tab_get_po (active_tab));
po = gtranslator_tab_get_po (active_tab);
file = gtranslator_po_get_location (po);
-
-
+
+
/* FIXME: We are leaking a lot here */
/*
* Translators: The title of the window when there is only one tab
*/
title = g_strdup_printf (_("gtranslator - %s"), g_file_get_path (file));
if (state == GTR_PO_STATE_MODIFIED)
- title = g_strdup_printf (_("gtranslator - *%s"), g_file_get_path (file));
+ title =
+ g_strdup_printf (_("gtranslator - *%s"), g_file_get_path (file));
else
- title = g_strdup_printf (_("gtranslator - %s"), g_file_get_path (file));
-
+ title =
+ g_strdup_printf (_("gtranslator - %s"), g_file_get_path (file));
+
g_object_unref (file);
}
else
title = g_strdup (_("gtranslator"));
-
+
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
}
static void
-notebook_switch_page(GtkNotebook *nb,
- GtkNotebookPage *page,
- gint page_num,
- GtranslatorWindow *window)
-{
- GtranslatorTab *tab;
- GList *msg;
- GtranslatorView *view;
- GtranslatorPo *po;
- gint n_pages;
- GtkAction *action;
- gchar *action_name;
-
- tab = GTR_TAB (gtk_notebook_get_nth_page (nb, page_num));
- if (tab == window->priv->active_tab)
- return;
-
- /*
- * Set the window title
- */
- n_pages = gtk_notebook_get_n_pages (nb);
- if (n_pages == 1)
- set_window_title (window, TRUE);
- else
- set_window_title (window, FALSE);
-
- window->priv->active_tab = tab;
- view = gtranslator_tab_get_active_view (tab);
-
- set_sensitive_according_to_tab(window, tab);
-
-
- /* sync the statusbar */
- gtranslator_statusbar_set_overwrite (GTR_STATUSBAR (window->priv->statusbar),
- gtk_text_view_get_overwrite (GTK_TEXT_VIEW (view)));
-
- po = gtranslator_tab_get_po(tab);
- msg = gtranslator_po_get_current_message(po);
- gtranslator_window_update_statusbar_message_count(tab,msg->data, window);
-
- /* activate the right item in the documents menu */
- action_name = g_strdup_printf ("Tab_%d", page_num);
- action = gtk_action_group_get_action (window->priv->documents_list_action_group,
- action_name);
-
- /* sometimes the action doesn't exist yet, and the proper action
- * is set active during the documents list menu creation
- * CHECK: would it be nicer if active_tab was a property and we monitored the notify signal?
- */
- if (action != NULL)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
- g_free (action_name);
-
- gtranslator_plugins_engine_update_plugins_ui (gtranslator_plugins_engine_get_default (),
- window, FALSE);
+notebook_switch_page (GtkNotebook * nb,
+ GtkNotebookPage * page,
+ gint page_num, GtranslatorWindow * window)
+{
+ GtranslatorTab *tab;
+ GList *msg;
+ GtranslatorView *view;
+ GtranslatorPo *po;
+ gint n_pages;
+ GtkAction *action;
+ gchar *action_name;
+
+ tab = GTR_TAB (gtk_notebook_get_nth_page (nb, page_num));
+ if (tab == window->priv->active_tab)
+ return;
+
+ /*
+ * Set the window title
+ */
+ n_pages = gtk_notebook_get_n_pages (nb);
+ if (n_pages == 1)
+ set_window_title (window, TRUE);
+ else
+ set_window_title (window, FALSE);
+
+ window->priv->active_tab = tab;
+ view = gtranslator_tab_get_active_view (tab);
+
+ set_sensitive_according_to_tab (window, tab);
+
+
+ /* sync the statusbar */
+ gtranslator_statusbar_set_overwrite (GTR_STATUSBAR
+ (window->priv->statusbar),
+ gtk_text_view_get_overwrite
+ (GTK_TEXT_VIEW (view)));
+
+ po = gtranslator_tab_get_po (tab);
+ msg = gtranslator_po_get_current_message (po);
+ gtranslator_window_update_statusbar_message_count (tab, msg->data, window);
+
+ /* activate the right item in the documents menu */
+ action_name = g_strdup_printf ("Tab_%d", page_num);
+ action =
+ gtk_action_group_get_action (window->priv->documents_list_action_group,
+ action_name);
+
+ /* sometimes the action doesn't exist yet, and the proper action
+ * is set active during the documents list menu creation
+ * CHECK: would it be nicer if active_tab was a property and we monitored the notify signal?
+ */
+ if (action != NULL)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+ g_free (action_name);
+
+ gtranslator_plugins_engine_update_plugins_ui
+ (gtranslator_plugins_engine_get_default (), window, FALSE);
}
static void
-notebook_page_removed (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- GtranslatorWindow *window)
-{
- gint n_pages;
-
- /*
- * Set the window title
- */
- n_pages = gtk_notebook_get_n_pages (notebook);
- if (n_pages == 1)
- set_window_title (window, TRUE);
- else
- set_window_title (window, FALSE);
-
- update_documents_list_menu (window);
+notebook_page_removed (GtkNotebook * notebook,
+ GtkWidget * child,
+ guint page_num, GtranslatorWindow * window)
+{
+ gint n_pages;
+
+ /*
+ * Set the window title
+ */
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ if (n_pages == 1)
+ set_window_title (window, TRUE);
+ else
+ set_window_title (window, FALSE);
+
+ update_documents_list_menu (window);
}
static void
-notebook_tab_close_request (GtranslatorNotebook *notebook,
- GtranslatorTab *tab,
- GtranslatorWindow *window)
+notebook_tab_close_request (GtranslatorNotebook * notebook,
+ GtranslatorTab * tab, GtranslatorWindow * window)
{
- /* Note: we are destroying the tab before the default handler
- * seems to be ok, but we need to keep an eye on this. */
- gtranslator_close_tab (tab, window);
-
- gtranslator_plugins_engine_update_plugins_ui (gtranslator_plugins_engine_get_default (),
- window, FALSE);
+ /* Note: we are destroying the tab before the default handler
+ * seems to be ok, but we need to keep an eye on this. */
+ gtranslator_close_tab (tab, window);
+
+ gtranslator_plugins_engine_update_plugins_ui
+ (gtranslator_plugins_engine_get_default (), window, FALSE);
}
static void
-can_undo(GtkSourceBuffer *doc,
- GParamSpec *pspec,
- GtranslatorWindow *window)
+can_undo (GtkSourceBuffer * doc,
+ GParamSpec * pspec, GtranslatorWindow * window)
{
- GtkAction *action;
- gboolean sensitive;
- GtranslatorView *view;
- GtkSourceBuffer *buf;
+ GtkAction *action;
+ gboolean sensitive;
+ GtranslatorView *view;
+ GtkSourceBuffer *buf;
- view = gtranslator_window_get_active_view (window);
- buf = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)));
-
- sensitive = gtk_source_buffer_can_undo(buf);
-
- if (doc != buf)
- return;
+ view = gtranslator_window_get_active_view (window);
+ buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditUndo");
- gtk_action_set_sensitive (action, sensitive);
+ sensitive = gtk_source_buffer_can_undo (buf);
+
+ if (doc != buf)
+ return;
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditUndo");
+ gtk_action_set_sensitive (action, sensitive);
}
static void
-can_redo(GtkSourceBuffer *doc,
- GParamSpec *spec,
- GtranslatorWindow *window)
+can_redo (GtkSourceBuffer * doc,
+ GParamSpec * spec, GtranslatorWindow * window)
{
- GtkAction *action;
- gboolean sensitive;
- GtranslatorView *view;
- GtkSourceBuffer *buf;
+ GtkAction *action;
+ gboolean sensitive;
+ GtranslatorView *view;
+ GtkSourceBuffer *buf;
+
+ view = gtranslator_window_get_active_view (window);
+ buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
- view = gtranslator_window_get_active_view (window);
- buf = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)));
-
- sensitive = gtk_source_buffer_can_redo(buf);
-
- if (doc != buf)
- return;
+ sensitive = gtk_source_buffer_can_redo (buf);
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditRedo");
- gtk_action_set_sensitive (action, sensitive);
+ if (doc != buf)
+ return;
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditRedo");
+ gtk_action_set_sensitive (action, sensitive);
}
static void
-sync_state (GtranslatorPo *po,
- GParamSpec *pspec,
- GtranslatorWindow *window)
+sync_state (GtranslatorPo * po,
+ GParamSpec * pspec, GtranslatorWindow * window)
{
int n_pages = 0;
set_sensitive_according_to_tab (window,
gtranslator_tab_get_from_document (po));
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK(window->priv->notebook));
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook));
if (n_pages == 1)
set_window_title (window, TRUE);
}
static void
-showed_message_cb (GtranslatorTab *tab,
- GtranslatorMsg *msg,
- GtranslatorWindow *window)
+showed_message_cb (GtranslatorTab * tab,
+ GtranslatorMsg * msg, GtranslatorWindow * window)
{
- g_return_if_fail (GTR_IS_TAB (tab));
-
- gtranslator_window_update_statusbar_message_count (tab, msg, window);
-
- set_sensitive_according_to_message (window, gtranslator_tab_get_po (tab));
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ gtranslator_window_update_statusbar_message_count (tab, msg, window);
+
+ set_sensitive_according_to_message (window, gtranslator_tab_get_po (tab));
}
static void
-notebook_tab_added(GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- GtranslatorWindow *window)
-{
- GList *views;
- GtranslatorTab *tab = GTR_TAB(child);
- GtkTextBuffer *buffer;
- gint n_pages;
-
- g_return_if_fail(GTR_IS_TAB(tab));
-
- /*
- * Set the window title
- */
- n_pages = gtk_notebook_get_n_pages (notebook);
- if (n_pages == 1)
- set_window_title (window, TRUE);
- else
- set_window_title (window, FALSE);
-
- views = gtranslator_tab_get_all_views(tab, FALSE, TRUE);
-
- while(views)
- {
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(views->data));
-
-
- g_signal_connect(GTK_SOURCE_BUFFER(buffer),
- "notify::can-undo",
- G_CALLBACK(can_undo),
- window);
-
- g_signal_connect(GTK_SOURCE_BUFFER(buffer),
- "notify::can-redo",
- G_CALLBACK(can_redo),
- window);
-
- g_signal_connect (views->data,
- "toggle_overwrite",
- G_CALLBACK (update_overwrite_mode_statusbar),
- window);
-
- views = views->next;
- }
-
- g_signal_connect_after (child,
- "message_changed",
- G_CALLBACK(gtranslator_window_update_statusbar_message_count),
- window);
- g_signal_connect_after (child,
- "showed_message",
- G_CALLBACK(showed_message_cb),
- window);
-
- g_signal_connect (gtranslator_tab_get_po (tab),
- "notify::state",
- G_CALLBACK (sync_state),
+notebook_tab_added (GtkNotebook * notebook,
+ GtkWidget * child,
+ guint page_num, GtranslatorWindow * window)
+{
+ GList *views;
+ GtranslatorTab *tab = GTR_TAB (child);
+ GtkTextBuffer *buffer;
+ gint n_pages;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ /*
+ * Set the window title
+ */
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ if (n_pages == 1)
+ set_window_title (window, TRUE);
+ else
+ set_window_title (window, FALSE);
+
+ views = gtranslator_tab_get_all_views (tab, FALSE, TRUE);
+
+ while (views)
+ {
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (views->data));
+
+
+ g_signal_connect (GTK_SOURCE_BUFFER (buffer),
+ "notify::can-undo", G_CALLBACK (can_undo), window);
+
+ g_signal_connect (GTK_SOURCE_BUFFER (buffer),
+ "notify::can-redo", G_CALLBACK (can_redo), window);
+
+ g_signal_connect (views->data,
+ "toggle_overwrite",
+ G_CALLBACK (update_overwrite_mode_statusbar), window);
+
+ views = views->next;
+ }
+
+ g_signal_connect_after (child,
+ "message_changed",
+ G_CALLBACK
+ (gtranslator_window_update_statusbar_message_count),
window);
-
- update_documents_list_menu (window);
-
- gtranslator_plugins_engine_update_plugins_ui (gtranslator_plugins_engine_get_default (),
- window, FALSE);
+ g_signal_connect_after (child, "showed_message",
+ G_CALLBACK (showed_message_cb), window);
+
+ g_signal_connect (gtranslator_tab_get_po (tab),
+ "notify::state", G_CALLBACK (sync_state), window);
+
+ update_documents_list_menu (window);
+
+ gtranslator_plugins_engine_update_plugins_ui
+ (gtranslator_plugins_engine_get_default (), window, FALSE);
}
void
-gtranslator_recent_add (GtranslatorWindow *window,
- GFile *location,
- gchar *project_id)
-{
- GtkRecentData *recent_data;
- gchar *uri;
- GError *error = NULL;
- gchar *path;
- gchar *display_name;
-
- uri = g_file_get_uri (location);
- path = g_file_get_path (location);
- display_name = gtranslator_utils_reduce_path ((const gchar *)path);
-
- recent_data = g_slice_new (GtkRecentData);
-
- recent_data->display_name = display_name;
- recent_data->description = NULL;
- recent_data->mime_type = "text/x-gettext-translation";
- recent_data->app_name = (gchar *) g_get_application_name ();
- recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
- recent_data->groups = NULL;
- recent_data->is_private = FALSE;
-
- if (!gtk_recent_manager_add_full (window->priv->recent_manager,
- uri,
- recent_data))
- {
- g_warning ("Unable to add '%s' to the list of recently used documents", uri);
- }
+gtranslator_recent_add (GtranslatorWindow * window,
+ GFile * location, gchar * project_id)
+{
+ GtkRecentData *recent_data;
+ gchar *uri;
+ GError *error = NULL;
+ gchar *path;
+ gchar *display_name;
+
+ uri = g_file_get_uri (location);
+ path = g_file_get_path (location);
+ display_name = gtranslator_utils_reduce_path ((const gchar *) path);
+
+ recent_data = g_slice_new (GtkRecentData);
+
+ recent_data->display_name = display_name;
+ recent_data->description = NULL;
+ recent_data->mime_type = "text/x-gettext-translation";
+ recent_data->app_name = (gchar *) g_get_application_name ();
+ recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
+ recent_data->groups = NULL;
+ recent_data->is_private = FALSE;
+
+ if (!gtk_recent_manager_add_full (window->priv->recent_manager,
+ uri, recent_data))
+ {
+ g_warning ("Unable to add '%s' to the list of recently used documents",
+ uri);
+ }
- g_free (uri);
- g_free (path);
- g_free (display_name);
- g_free (recent_data->app_exec);
- g_slice_free (GtkRecentData, recent_data);
+ g_free (uri);
+ g_free (path);
+ g_free (display_name);
+ g_free (recent_data->app_exec);
+ g_slice_free (GtkRecentData, recent_data);
}
void
-gtranslator_recent_remove (GtranslatorWindow *window,
- const gchar *path)
-{
- gchar *uri;
- GError *error = NULL;
-
- uri = g_filename_to_uri (path, NULL, &error);
- if (error)
- {
- g_warning ("Could not convert uri \"%s\" to a local path: %s",
- uri, error->message);
- g_error_free (error);
- return;
- }
-
- gtk_recent_manager_remove_item (window->priv->recent_manager, uri, &error);
- if (error)
- {
- g_warning ("Could not remove recent-files uri \"%s\": %s",
- uri, error->message);
- g_error_free (error);
- }
-
- g_free (uri);
+gtranslator_recent_remove (GtranslatorWindow * window, const gchar * path)
+{
+ gchar *uri;
+ GError *error = NULL;
+
+ uri = g_filename_to_uri (path, NULL, &error);
+ if (error)
+ {
+ g_warning ("Could not convert uri \"%s\" to a local path: %s",
+ uri, error->message);
+ g_error_free (error);
+ return;
+ }
+
+ gtk_recent_manager_remove_item (window->priv->recent_manager, uri, &error);
+ if (error)
+ {
+ g_warning ("Could not remove recent-files uri \"%s\": %s",
+ uri, error->message);
+ g_error_free (error);
+ }
+
+ g_free (uri);
}
static void
-gtranslator_recent_chooser_item_activated_cb (GtkRecentChooser *chooser,
- GtranslatorWindow *window)
-{
- gchar *uri;
- GError *error = NULL;
- GtkWidget *dialog;
- GSList *list = NULL;
- GFile *location;
-
- uri = gtk_recent_chooser_get_current_uri (chooser);
- location = g_file_new_for_uri (uri);
- g_free (uri);
-
- list = g_slist_prepend (list, location);
-
- gtranslator_actions_load_locations (window, list);
- g_slist_foreach (list, (GFunc)g_object_unref, NULL);
- g_slist_free (list);
+gtranslator_recent_chooser_item_activated_cb (GtkRecentChooser * chooser,
+ GtranslatorWindow * window)
+{
+ gchar *uri;
+ GError *error = NULL;
+ GtkWidget *dialog;
+ GSList *list = NULL;
+ GFile *location;
+
+ uri = gtk_recent_chooser_get_current_uri (chooser);
+ location = g_file_new_for_uri (uri);
+ g_free (uri);
+
+ list = g_slist_prepend (list, location);
+
+ gtranslator_actions_load_locations (window, list);
+ g_slist_foreach (list, (GFunc) g_object_unref, NULL);
+ g_slist_free (list);
}
static GtkWidget *
-create_recent_chooser_menu (GtranslatorWindow *window,
- GtkRecentManager *manager)
+create_recent_chooser_menu (GtranslatorWindow * window,
+ GtkRecentManager * manager)
{
- GtkWidget *recent_menu;
- GtkRecentFilter *filter;
+ GtkWidget *recent_menu;
+ GtkRecentFilter *filter;
- recent_menu = gtk_recent_chooser_menu_new_for_manager (manager);
+ recent_menu = gtk_recent_chooser_menu_new_for_manager (manager);
- gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (recent_menu), TRUE);
- gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (recent_menu), FALSE);
- gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu), GTK_RECENT_SORT_MRU);
- gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (recent_menu), TRUE);
- gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (recent_menu), TRUE);
+ gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (recent_menu), TRUE);
+ gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (recent_menu), FALSE);
+ gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu),
+ GTK_RECENT_SORT_MRU);
+ gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU
+ (recent_menu), TRUE);
+ gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (recent_menu), TRUE);
- filter = gtk_recent_filter_new ();
- gtk_recent_filter_add_application (filter, g_get_application_name());
- gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (recent_menu), filter);
+ filter = gtk_recent_filter_new ();
+ gtk_recent_filter_add_application (filter, g_get_application_name ());
+ gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (recent_menu), filter);
- return recent_menu;
+ return recent_menu;
}
static void
-gtranslator_window_set_action_sensitive (GtranslatorWindow *window,
- const gchar *name,
+gtranslator_window_set_action_sensitive (GtranslatorWindow * window,
+ const gchar * name,
gboolean sensitive)
{
- GtkAction *action = gtk_action_group_get_action (window->priv->action_group,
- name);
- gtk_action_set_sensitive (action, sensitive);
+ GtkAction *action = gtk_action_group_get_action (window->priv->action_group,
+ name);
+ gtk_action_set_sensitive (action, sensitive);
}
static void
-gtranslator_window_cmd_edit_toolbar_cb (GtkDialog *dialog,
- gint response,
- gpointer data)
+gtranslator_window_cmd_edit_toolbar_cb (GtkDialog * dialog,
+ gint response, gpointer data)
{
- GtranslatorWindow *window = GTR_WINDOW (data);
- egg_editable_toolbar_set_edit_mode
- (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), FALSE);
- _gtranslator_application_save_toolbars_model (GTR_APP);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ GtranslatorWindow *window = GTR_WINDOW (data);
+ egg_editable_toolbar_set_edit_mode
+ (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), FALSE);
+ _gtranslator_application_save_toolbars_model (GTR_APP);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
-gtranslator_window_cmd_edit_toolbar (GtkAction *action,
- GtranslatorWindow *window)
-{
- GtkWidget *dialog;
- GtkWidget *editor;
-
- dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor"),
- GTK_WINDOW (window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
-
- editor = egg_toolbar_editor_new (window->priv->ui_manager,
- EGG_TOOLBARS_MODEL (_gtranslator_application_get_toolbars_model (GTR_APP)));
- gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
- gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
-
- egg_editable_toolbar_set_edit_mode
- (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), TRUE);
-
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtranslator_window_cmd_edit_toolbar_cb),
- window);
- gtk_widget_show_all (dialog);
+gtranslator_window_cmd_edit_toolbar (GtkAction * action,
+ GtranslatorWindow * window)
+{
+ GtkWidget *dialog;
+ GtkWidget *editor;
+
+ dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor"),
+ GTK_WINDOW (window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE, NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
+
+ editor = egg_toolbar_editor_new (window->priv->ui_manager,
+ EGG_TOOLBARS_MODEL
+ (_gtranslator_application_get_toolbars_model
+ (GTR_APP)));
+ gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
+ gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
+
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
+
+ egg_editable_toolbar_set_edit_mode
+ (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), TRUE);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtranslator_window_cmd_edit_toolbar_cb),
+ window);
+ gtk_widget_show_all (dialog);
}
static void
-menu_item_select_cb (GtkMenuItem *proxy,
- GtranslatorWindow *window)
+menu_item_select_cb (GtkMenuItem * proxy, GtranslatorWindow * window)
{
- GtkAction *action;
- char *message;
+ GtkAction *action;
+ char *message;
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
- g_return_if_fail (action != NULL);
+ action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
+ g_return_if_fail (action != NULL);
- g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
- if (message)
- {
- gtranslator_statusbar_push_default (GTR_STATUSBAR (window->priv->statusbar),
- message);
- g_free (message);
- }
+ g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+ if (message)
+ {
+ gtranslator_statusbar_push_default (GTR_STATUSBAR
+ (window->priv->statusbar), message);
+ g_free (message);
+ }
}
static void
-menu_item_deselect_cb (GtkMenuItem *proxy,
- GtranslatorWindow *window)
+menu_item_deselect_cb (GtkMenuItem * proxy, GtranslatorWindow * window)
{
- gtranslator_statusbar_pop_default (GTR_STATUSBAR (window->priv->statusbar));
+ gtranslator_statusbar_pop_default (GTR_STATUSBAR (window->priv->statusbar));
}
static void
-connect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy,
- GtranslatorWindow *window)
+connect_proxy_cb (GtkUIManager * manager,
+ GtkAction * action,
+ GtkWidget * proxy, GtranslatorWindow * window)
{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_connect (proxy, "select",
- G_CALLBACK (menu_item_select_cb), window);
- g_signal_connect (proxy, "deselect",
- G_CALLBACK (menu_item_deselect_cb), window);
- }
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_connect (proxy, "select",
+ G_CALLBACK (menu_item_select_cb), window);
+ g_signal_connect (proxy, "deselect",
+ G_CALLBACK (menu_item_deselect_cb), window);
+ }
}
static void
-disconnect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy,
- GtranslatorWindow *window)
+disconnect_proxy_cb (GtkUIManager * manager,
+ GtkAction * action,
+ GtkWidget * proxy, GtranslatorWindow * window)
{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_select_cb), window);
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_deselect_cb), window);
- }
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_select_cb), window);
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_deselect_cb), window);
+ }
}
static void
-gtranslator_window_draw (GtranslatorWindow *window)
-{
- GtkWidget *hbox; //Statusbar and progressbar
- GtkWidget *widget;
- GError *error = NULL;
- GtkWidget *dockbar;
- GtkWidget *hbox_dock;
- GtkWidget *tm_widget;
- GtkActionGroup *action_group;
- gchar *path;
-
- GtranslatorWindowPrivate *priv = window->priv;
-
- /*
- * Main box
- */
- priv->main_box = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window), priv->main_box);
- gtk_widget_show (priv->main_box);
-
- /*
- * Menus
- */
- priv->ui_manager = gtk_ui_manager_new ();
-
- gtk_window_add_accel_group(GTK_WINDOW(window),
- gtk_ui_manager_get_accel_group(priv->ui_manager));
-
- priv->always_sensitive_action_group = gtk_action_group_new ("AlwaysSensitiveMenuActions");
- gtk_action_group_set_translation_domain(priv->always_sensitive_action_group, NULL);
- gtk_action_group_add_actions (priv->always_sensitive_action_group,
- always_sensitive_entries,
- G_N_ELEMENTS(always_sensitive_entries),
- window);
-
- gtk_ui_manager_insert_action_group (priv->ui_manager,
- priv->always_sensitive_action_group, 0);
-
- priv->action_group = gtk_action_group_new ("MenuActions");
- gtk_action_group_set_translation_domain (priv->action_group, NULL);
- gtk_action_group_add_actions (priv->action_group, entries,
- G_N_ELEMENTS (entries), window);
-
- gtk_ui_manager_insert_action_group (priv->ui_manager,
- priv->action_group, 0);
-
- /* list of open documents menu */
- action_group = gtk_action_group_new ("DocumentsListActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- priv->documents_list_action_group = action_group;
- gtk_ui_manager_insert_action_group (priv->ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- path = gtranslator_utils_get_file_from_pkgdatadir ("gtranslator-ui.xml");
- if (!gtk_ui_manager_add_ui_from_file (priv->ui_manager,
- path,
- &error))
- {
- g_warning ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- g_free (path);
+gtranslator_window_draw (GtranslatorWindow * window)
+{
+ GtkWidget *hbox; //Statusbar and progressbar
+ GtkWidget *widget;
+ GError *error = NULL;
+ GtkWidget *dockbar;
+ GtkWidget *hbox_dock;
+ GtkWidget *tm_widget;
+ GtkActionGroup *action_group;
+ gchar *path;
+
+ GtranslatorWindowPrivate *priv = window->priv;
+
+ /*
+ * Main box
+ */
+ priv->main_box = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), priv->main_box);
+ gtk_widget_show (priv->main_box);
+
+ /*
+ * Menus
+ */
+ priv->ui_manager = gtk_ui_manager_new ();
+
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ gtk_ui_manager_get_accel_group (priv->
+ ui_manager));
+
+ priv->always_sensitive_action_group =
+ gtk_action_group_new ("AlwaysSensitiveMenuActions");
+ gtk_action_group_set_translation_domain (priv->
+ always_sensitive_action_group,
+ NULL);
+ gtk_action_group_add_actions (priv->always_sensitive_action_group,
+ always_sensitive_entries,
+ G_N_ELEMENTS (always_sensitive_entries),
+ window);
- /* show tooltips in the statusbar */
- g_signal_connect (priv->ui_manager,
- "connect_proxy",
- G_CALLBACK (connect_proxy_cb),
- window);
- g_signal_connect (priv->ui_manager,
- "disconnect_proxy",
- G_CALLBACK (disconnect_proxy_cb),
- window);
-
- priv->menubar = gtk_ui_manager_get_widget (priv->ui_manager,
- "/MainMenu");
- gtk_box_pack_start (GTK_BOX (priv->main_box),
- priv->menubar,
- FALSE, FALSE, 0);
-
- /*
- * Recent files
- */
- priv->recent_manager = gtk_recent_manager_get_default();
-
- priv->recent_menu = create_recent_chooser_menu (window, priv->recent_manager);
-
- g_signal_connect (priv->recent_menu,
- "item-activated",
- G_CALLBACK (gtranslator_recent_chooser_item_activated_cb),
- window);
-
- widget = gtk_ui_manager_get_widget (priv->ui_manager,
- "/MainMenu/FileMenu/FileRecentFilesMenu");
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), priv->recent_menu);
-
- /*
- * Translation Memory
- */
- priv->tm_menu= gtk_ui_manager_get_widget (priv->ui_manager,
- "/MainMenu/EditMenu/EditTranslationMemory");
-
- /*
- * Toolbar
- */
- priv->toolbar = GTK_WIDGET
- (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
- "ui-manager", priv->ui_manager,
- "model", _gtranslator_application_get_toolbars_model (GTR_APP),
- NULL));
-
- egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (priv->toolbar),
- "DefaultToolBar");
- gtk_box_pack_start (GTK_BOX (priv->main_box),
- priv->toolbar,
- FALSE, FALSE, 0);
- gtk_widget_show (priv->toolbar);
-
- /*
- * Docker
- */
- hbox = gtk_hbox_new (FALSE, 0);
- priv->dock = gdl_dock_new ();
- gtk_widget_show (priv->dock);
- gtk_box_pack_end(GTK_BOX (hbox),
- priv->dock, TRUE, TRUE, 0);
-
- dockbar = gdl_dock_bar_new (GDL_DOCK(priv->dock));
- gtk_widget_show (dockbar);
- gtk_box_pack_start (GTK_BOX (hbox),
- dockbar, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (priv->main_box),
- hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- priv->layout_manager = gdl_dock_layout_new (GDL_DOCK (priv->dock));
- g_object_set (priv->layout_manager->master,
- "switcher-style",
- gtranslator_prefs_manager_get_pane_switcher_style (),
- NULL);
- g_signal_connect (priv->layout_manager,
- "notify::dirty",
- G_CALLBACK (on_layout_dirty_notify),
- window);
+ gtk_ui_manager_insert_action_group (priv->ui_manager,
+ priv->always_sensitive_action_group, 0);
- /*
- * notebook
- */
- priv->notebook = GTK_WIDGET(gtranslator_notebook_new());
- g_signal_connect(priv->notebook, "switch-page",
- G_CALLBACK(notebook_switch_page), window);
- g_signal_connect(priv->notebook, "page-added",
- G_CALLBACK(notebook_tab_added), window);
- g_signal_connect (priv->notebook, "page-removed",
- G_CALLBACK (notebook_page_removed), window);
- g_signal_connect (priv->notebook,
- "tab_close_request",
- G_CALLBACK (notebook_tab_close_request),
- window);
- /*
- * hbox
- */
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start( GTK_BOX(priv->main_box), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
-
- /*
- * statusbar & progress bar
- */
- window->priv->statusbar = gtranslator_statusbar_new ();
-
- gtk_box_pack_end (GTK_BOX (hbox),
- window->priv->statusbar,
- TRUE,
- TRUE,
- 0);
-
- gtk_widget_show(priv->statusbar);
+ priv->action_group = gtk_action_group_new ("MenuActions");
+ gtk_action_group_set_translation_domain (priv->action_group, NULL);
+ gtk_action_group_add_actions (priv->action_group, entries,
+ G_N_ELEMENTS (entries), window);
+
+ gtk_ui_manager_insert_action_group (priv->ui_manager,
+ priv->action_group, 0);
+
+ /* list of open documents menu */
+ action_group = gtk_action_group_new ("DocumentsListActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ priv->documents_list_action_group = action_group;
+ gtk_ui_manager_insert_action_group (priv->ui_manager, action_group, 0);
+ g_object_unref (action_group);
+
+ path = gtranslator_utils_get_file_from_pkgdatadir ("gtranslator-ui.xml");
+ if (!gtk_ui_manager_add_ui_from_file (priv->ui_manager, path, &error))
+ {
+ g_warning ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+ g_free (path);
+
+ /* show tooltips in the statusbar */
+ g_signal_connect (priv->ui_manager,
+ "connect_proxy", G_CALLBACK (connect_proxy_cb), window);
+ g_signal_connect (priv->ui_manager,
+ "disconnect_proxy",
+ G_CALLBACK (disconnect_proxy_cb), window);
+
+ priv->menubar = gtk_ui_manager_get_widget (priv->ui_manager, "/MainMenu");
+ gtk_box_pack_start (GTK_BOX (priv->main_box),
+ priv->menubar, FALSE, FALSE, 0);
+
+ /*
+ * Recent files
+ */
+ priv->recent_manager = gtk_recent_manager_get_default ();
+
+ priv->recent_menu =
+ create_recent_chooser_menu (window, priv->recent_manager);
+
+ g_signal_connect (priv->recent_menu,
+ "item-activated",
+ G_CALLBACK (gtranslator_recent_chooser_item_activated_cb),
+ window);
+
+ widget = gtk_ui_manager_get_widget (priv->ui_manager,
+ "/MainMenu/FileMenu/FileRecentFilesMenu");
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), priv->recent_menu);
+
+ /*
+ * Translation Memory
+ */
+ priv->tm_menu = gtk_ui_manager_get_widget (priv->ui_manager,
+ "/MainMenu/EditMenu/EditTranslationMemory");
+
+ /*
+ * Toolbar
+ */
+ priv->toolbar = GTK_WIDGET
+ (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
+ "ui-manager", priv->ui_manager,
+ "model",
+ _gtranslator_application_get_toolbars_model (GTR_APP),
+ NULL));
+
+ egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (priv->toolbar),
+ "DefaultToolBar");
+ gtk_box_pack_start (GTK_BOX (priv->main_box),
+ priv->toolbar, FALSE, FALSE, 0);
+ gtk_widget_show (priv->toolbar);
+
+ /*
+ * Docker
+ */
+ hbox = gtk_hbox_new (FALSE, 0);
+ priv->dock = gdl_dock_new ();
+ gtk_widget_show (priv->dock);
+ gtk_box_pack_end (GTK_BOX (hbox), priv->dock, TRUE, TRUE, 0);
+
+ dockbar = gdl_dock_bar_new (GDL_DOCK (priv->dock));
+ gtk_widget_show (dockbar);
+ gtk_box_pack_start (GTK_BOX (hbox), dockbar, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->main_box), hbox, TRUE, TRUE, 0);
+ gtk_widget_show (hbox);
+
+ priv->layout_manager = gdl_dock_layout_new (GDL_DOCK (priv->dock));
+ g_object_set (priv->layout_manager->master,
+ "switcher-style",
+ gtranslator_prefs_manager_get_pane_switcher_style (), NULL);
+ g_signal_connect (priv->layout_manager,
+ "notify::dirty",
+ G_CALLBACK (on_layout_dirty_notify), window);
+
+ /*
+ * notebook
+ */
+ priv->notebook = GTK_WIDGET (gtranslator_notebook_new ());
+ g_signal_connect (priv->notebook, "switch-page",
+ G_CALLBACK (notebook_switch_page), window);
+ g_signal_connect (priv->notebook, "page-added",
+ G_CALLBACK (notebook_tab_added), window);
+ g_signal_connect (priv->notebook, "page-removed",
+ G_CALLBACK (notebook_page_removed), window);
+ g_signal_connect (priv->notebook,
+ "tab_close_request",
+ G_CALLBACK (notebook_tab_close_request), window);
+ /*
+ * hbox
+ */
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->main_box), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ /*
+ * statusbar & progress bar
+ */
+ window->priv->statusbar = gtranslator_statusbar_new ();
+
+ gtk_box_pack_end (GTK_BOX (hbox), window->priv->statusbar, TRUE, TRUE, 0);
+
+ gtk_widget_show (priv->statusbar);
}
static void
-gtranslator_window_init (GtranslatorWindow *window)
-{
- GtkTargetList *tl;
- gint active_page;
- GtkWidget *view_menu;
- gchar *filename;
- gchar *config_folder;
-
- window->priv = GTR_WINDOW_GET_PRIVATE (window);
-
- window->priv->destroy_has_run = FALSE;
-
- gtranslator_window_draw(window);
-
- set_sensitive_according_to_window(window);
-
- /* Drag and drop support, set targets to NULL because we add the
- default uri_targets below */
- gtk_drag_dest_set (GTK_WIDGET (window),
- GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_HIGHLIGHT |
- GTK_DEST_DEFAULT_DROP,
- NULL,
- 0,
- GDK_ACTION_COPY);
-
- /* Add uri targets */
- tl = gtk_drag_dest_get_target_list (GTK_WIDGET (window));
-
- if (tl == NULL)
- {
- tl = gtk_target_list_new (NULL, 0);
- gtk_drag_dest_set_target_list (GTK_WIDGET (window), tl);
- gtk_target_list_unref (tl);
- }
-
- gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
-
- /* Connect signals */
- g_signal_connect (window,
- "drag_data_received",
- G_CALLBACK (drag_data_received_cb),
- NULL);
-
- /*
- * Create widgets menu
- */
- view_menu =
- gtk_ui_manager_get_widget (window->priv->ui_manager,
- "/MainMenu/ViewMenu");
- window->priv->view_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));
-
- /*
- * Plugins
- */
- gtranslator_plugins_engine_update_plugins_ui (gtranslator_plugins_engine_get_default (),
- window, TRUE);
-
- /*
- * Adding notebook to dock
- */
- add_widget_full (window,
- window->priv->notebook,
- "GtranslatorNotebook",
- _("Documents"),
- NULL,
- GTR_WINDOW_PLACEMENT_CENTER,
- TRUE,
- NULL);
-
- /*
- * Loading dock layout
- */
- config_folder = gtranslator_utils_get_user_config_dir ();
- filename = g_build_filename (config_folder,
- "gtranslator-layout.xml",
- NULL);
-
- gtranslator_window_layout_load (window,
- filename,
- NULL);
- g_free (filename);
- g_free (config_folder);
+gtranslator_window_init (GtranslatorWindow * window)
+{
+ GtkTargetList *tl;
+ gint active_page;
+ GtkWidget *view_menu;
+ gchar *filename;
+ gchar *config_folder;
+
+ window->priv = GTR_WINDOW_GET_PRIVATE (window);
+
+ window->priv->destroy_has_run = FALSE;
+
+ gtranslator_window_draw (window);
+
+ set_sensitive_according_to_window (window);
+
+ /* Drag and drop support, set targets to NULL because we add the
+ default uri_targets below */
+ gtk_drag_dest_set (GTK_WIDGET (window),
+ GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_HIGHLIGHT |
+ GTK_DEST_DEFAULT_DROP, NULL, 0, GDK_ACTION_COPY);
+
+ /* Add uri targets */
+ tl = gtk_drag_dest_get_target_list (GTK_WIDGET (window));
+
+ if (tl == NULL)
+ {
+ tl = gtk_target_list_new (NULL, 0);
+ gtk_drag_dest_set_target_list (GTK_WIDGET (window), tl);
+ gtk_target_list_unref (tl);
+ }
+
+ gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
+
+ /* Connect signals */
+ g_signal_connect (window,
+ "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), NULL);
+
+ /*
+ * Create widgets menu
+ */
+ view_menu =
+ gtk_ui_manager_get_widget (window->priv->ui_manager,
+ "/MainMenu/ViewMenu");
+ window->priv->view_menu =
+ gtk_menu_item_get_submenu (GTK_MENU_ITEM (view_menu));
+
+ /*
+ * Plugins
+ */
+ gtranslator_plugins_engine_update_plugins_ui
+ (gtranslator_plugins_engine_get_default (), window, TRUE);
+
+ /*
+ * Adding notebook to dock
+ */
+ add_widget_full (window,
+ window->priv->notebook,
+ "GtranslatorNotebook",
+ _("Documents"),
+ NULL, GTR_WINDOW_PLACEMENT_CENTER, TRUE, NULL);
+
+ /*
+ * Loading dock layout
+ */
+ config_folder = gtranslator_utils_get_user_config_dir ();
+ filename = g_build_filename (config_folder, "gtranslator-layout.xml", NULL);
+
+ gtranslator_window_layout_load (window, filename, NULL);
+ g_free (filename);
+ g_free (config_folder);
}
static void
-gtranslator_window_dispose (GObject *object)
+gtranslator_window_dispose (GObject * object)
{
- GtranslatorWindow *window = GTR_WINDOW(object);
- GtranslatorWindowPrivate *priv = window->priv;
-
- if(priv->ui_manager)
- {
- g_object_unref(priv->ui_manager);
- priv->ui_manager = NULL;
- }
- if(priv->action_group)
- {
- g_object_unref(priv->action_group);
- priv->action_group = NULL;
- }
-
- G_OBJECT_CLASS (gtranslator_window_parent_class)->dispose (object);
+ GtranslatorWindow *window = GTR_WINDOW (object);
+ GtranslatorWindowPrivate *priv = window->priv;
+
+ if (priv->ui_manager)
+ {
+ g_object_unref (priv->ui_manager);
+ priv->ui_manager = NULL;
+ }
+ if (priv->action_group)
+ {
+ g_object_unref (priv->action_group);
+ priv->action_group = NULL;
+ }
+
+ G_OBJECT_CLASS (gtranslator_window_parent_class)->dispose (object);
}
static void
-gtranslator_window_finalize (GObject *object)
+gtranslator_window_finalize (GObject * object)
{
- G_OBJECT_CLASS (gtranslator_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtranslator_window_parent_class)->finalize (object);
}
static void
-save_panes_state(GtranslatorWindow *window)
+save_panes_state (GtranslatorWindow * window)
{
- gchar *filename;
- gchar *config_folder;
+ gchar *filename;
+ gchar *config_folder;
- if (gtranslator_prefs_manager_window_size_can_set ())
- gtranslator_prefs_manager_set_window_size (window->priv->width,
- window->priv->height);
+ if (gtranslator_prefs_manager_window_size_can_set ())
+ gtranslator_prefs_manager_set_window_size (window->priv->width,
+ window->priv->height);
- if (gtranslator_prefs_manager_window_state_can_set ())
- gtranslator_prefs_manager_set_window_state (window->priv->window_state);
+ if (gtranslator_prefs_manager_window_state_can_set ())
+ gtranslator_prefs_manager_set_window_state (window->priv->window_state);
- config_folder = gtranslator_utils_get_user_config_dir ();
- filename = g_build_filename (config_folder,
- "gtranslator-layout.xml",
- NULL);
- gtranslator_window_layout_save (window,
- filename, NULL);
-
- g_free (filename);
- g_free (config_folder);
+ config_folder = gtranslator_utils_get_user_config_dir ();
+ filename = g_build_filename (config_folder, "gtranslator-layout.xml", NULL);
+ gtranslator_window_layout_save (window, filename, NULL);
+
+ g_free (filename);
+ g_free (config_folder);
}
static void
-gtranslator_window_destroy (GtkObject *object)
+gtranslator_window_destroy (GtkObject * object)
{
- GtranslatorWindow *window;
+ GtranslatorWindow *window;
- window = GTR_WINDOW (object);
+ window = GTR_WINDOW (object);
- if (!window->priv->destroy_has_run)
- {
- save_panes_state (window);
- window->priv->destroy_has_run = TRUE;
- }
+ if (!window->priv->destroy_has_run)
+ {
+ save_panes_state (window);
+ window->priv->destroy_has_run = TRUE;
+ }
- GTK_OBJECT_CLASS (gtranslator_window_parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (gtranslator_window_parent_class)->destroy (object);
}
-static gboolean
-gtranslator_window_configure_event (GtkWidget *widget,
- GdkEventConfigure *event)
+static gboolean
+gtranslator_window_configure_event (GtkWidget * widget,
+ GdkEventConfigure * event)
{
- GtranslatorWindow *window = GTR_WINDOW (widget);
+ GtranslatorWindow *window = GTR_WINDOW (widget);
+
+ window->priv->width = event->width;
+ window->priv->height = event->height;
- window->priv->width = event->width;
- window->priv->height = event->height;
-
- return GTK_WIDGET_CLASS (gtranslator_window_parent_class)->configure_event (widget, event);
+ return GTK_WIDGET_CLASS (gtranslator_window_parent_class)->
+ configure_event (widget, event);
}
static void
-gtranslator_window_class_init (GtranslatorWindowClass *klass)
+gtranslator_window_class_init (GtranslatorWindowClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GtranslatorWindowPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorWindowPrivate));
+
+ object_class->finalize = gtranslator_window_finalize;
+ object_class->dispose = gtranslator_window_dispose;
- object_class->finalize = gtranslator_window_finalize;
- object_class->dispose = gtranslator_window_dispose;
-
- gobject_class->destroy = gtranslator_window_destroy;
-
- widget_class->configure_event = gtranslator_window_configure_event;
+ gobject_class->destroy = gtranslator_window_destroy;
+
+ widget_class->configure_event = gtranslator_window_configure_event;
}
/***************************** Public funcs ***********************************/
@@ -1856,18 +1818,16 @@ gtranslator_window_class_init (GtranslatorWindowClass *klass)
* Returns: a new #GtranslatorTab object
*/
GtranslatorTab *
-gtranslator_window_create_tab(GtranslatorWindow *window,
- GtranslatorPo *po)
+gtranslator_window_create_tab (GtranslatorWindow * window, GtranslatorPo * po)
{
- GtranslatorTab *tab;
+ GtranslatorTab *tab;
- tab = gtranslator_tab_new(po);
- gtk_widget_show(GTK_WIDGET(tab));
+ tab = gtranslator_tab_new (po);
+ gtk_widget_show (GTK_WIDGET (tab));
- gtranslator_notebook_add_page(GTR_NOTEBOOK(window->priv->notebook),
- tab);
+ gtranslator_notebook_add_page (GTR_NOTEBOOK (window->priv->notebook), tab);
- return tab;
+ return tab;
}
/**
@@ -1879,9 +1839,10 @@ gtranslator_window_create_tab(GtranslatorWindow *window,
* Returns: the active #GtranslatorTab of the @window.
*/
GtranslatorTab *
-gtranslator_window_get_active_tab(GtranslatorWindow *window)
+gtranslator_window_get_active_tab (GtranslatorWindow * window)
{
- return gtranslator_notebook_get_page(GTR_NOTEBOOK(window->priv->notebook));
+ return
+ gtranslator_notebook_get_page (GTR_NOTEBOOK (window->priv->notebook));
}
/**
@@ -1893,22 +1854,25 @@ gtranslator_window_get_active_tab(GtranslatorWindow *window)
* Returns: a list of all tabs in the @window or NULL if there is no tab opened.
*/
GList *
-gtranslator_window_get_all_tabs(GtranslatorWindow *window)
+gtranslator_window_get_all_tabs (GtranslatorWindow * window)
{
- gint num_pages;
- gint i = 0;
- GList *toret = NULL;
+ gint num_pages;
+ gint i = 0;
+ GList *toret = NULL;
- num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->priv->notebook));
+ num_pages =
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook));
- while(i < num_pages)
- {
- toret = g_list_append(toret,
- gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->priv->notebook),i));
- i++;
- }
+ while (i < num_pages)
+ {
+ toret = g_list_append (toret,
+ gtk_notebook_get_nth_page (GTK_NOTEBOOK
+ (window->priv->
+ notebook), i));
+ i++;
+ }
- return toret;
+ return toret;
}
/**
@@ -1922,22 +1886,22 @@ gtranslator_window_get_all_tabs(GtranslatorWindow *window)
* #GtranslatorTab
*/
GtranslatorHeader *
-gtranslator_window_get_header_from_active_tab(GtranslatorWindow *window)
+gtranslator_window_get_header_from_active_tab (GtranslatorWindow * window)
{
- GtranslatorTab *current_page;
- GtranslatorPo *po;
- GtranslatorHeader *header;
+ GtranslatorTab *current_page;
+ GtranslatorPo *po;
+ GtranslatorHeader *header;
- g_return_val_if_fail(GTR_IS_WINDOW(window), NULL);
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
- current_page = gtranslator_window_get_active_tab(window);
- if(!current_page)
- return NULL;
+ current_page = gtranslator_window_get_active_tab (window);
+ if (!current_page)
+ return NULL;
- po = gtranslator_tab_get_po(current_page);
- header = gtranslator_po_get_header(po);
+ po = gtranslator_tab_get_po (current_page);
+ header = gtranslator_po_get_header (po);
- return header;
+ return header;
}
/**
@@ -1949,9 +1913,9 @@ gtranslator_window_get_header_from_active_tab(GtranslatorWindow *window)
* Returns: the #GtranslatorNotebook of the @window
*/
GtranslatorNotebook *
-gtranslator_window_get_notebook(GtranslatorWindow *window)
+gtranslator_window_get_notebook (GtranslatorWindow * window)
{
- return GTR_NOTEBOOK(window->priv->notebook);
+ return GTR_NOTEBOOK (window->priv->notebook);
}
/**
@@ -1963,9 +1927,9 @@ gtranslator_window_get_notebook(GtranslatorWindow *window)
* Returns: the statusbar widget of the window
*/
GtkWidget *
-gtranslator_window_get_statusbar(GtranslatorWindow *window)
+gtranslator_window_get_statusbar (GtranslatorWindow * window)
{
- return window->priv->statusbar;
+ return window->priv->statusbar;
}
/**
@@ -1977,9 +1941,9 @@ gtranslator_window_get_statusbar(GtranslatorWindow *window)
* Returns: the #GtkUIManager of the @window
*/
GtkUIManager *
-gtranslator_window_get_ui_manager(GtranslatorWindow *window)
+gtranslator_window_get_ui_manager (GtranslatorWindow * window)
{
- return window->priv->ui_manager;
+ return window->priv->ui_manager;
}
/**
@@ -1993,15 +1957,15 @@ gtranslator_window_get_ui_manager(GtranslatorWindow *window)
* NULL if there is not tab opened.
**/
GtranslatorView *
-gtranslator_window_get_active_view(GtranslatorWindow *window)
+gtranslator_window_get_active_view (GtranslatorWindow * window)
{
- GtranslatorTab *current_tab;
- current_tab = gtranslator_window_get_active_tab(window);
-
- if (!current_tab)
- return NULL;
-
- return gtranslator_tab_get_active_view(current_tab);
+ GtranslatorTab *current_tab;
+ current_tab = gtranslator_window_get_active_tab (window);
+
+ if (!current_tab)
+ return NULL;
+
+ return gtranslator_tab_get_active_view (current_tab);
}
/**
@@ -2015,31 +1979,31 @@ gtranslator_window_get_active_view(GtranslatorWindow *window)
* Return value: a newly allocated list of #GtranslationWindow objects
**/
GList *
-gtranslator_window_get_all_views(GtranslatorWindow *window,
- gboolean original,
- gboolean translated)
-{
- gint numtabs;
- gint i;
- GList *views = NULL;
- GtkWidget *tab;
-
- g_return_val_if_fail(GTR_IS_WINDOW(window), NULL);
-
- numtabs = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->priv->notebook));
- i = numtabs - 1;
-
- while(i >= 0 && numtabs != 0)
- {
- tab = gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->priv->notebook),
- i);
- views = g_list_concat(views, gtranslator_tab_get_all_views(GTR_TAB(tab),
- original,
- translated));
- i--;
- }
-
- return views;
+gtranslator_window_get_all_views (GtranslatorWindow * window,
+ gboolean original, gboolean translated)
+{
+ gint numtabs;
+ gint i;
+ GList *views = NULL;
+ GtkWidget *tab;
+
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
+
+ numtabs = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook));
+ i = numtabs - 1;
+
+ while (i >= 0 && numtabs != 0)
+ {
+ tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->priv->notebook),
+ i);
+ views =
+ g_list_concat (views,
+ gtranslator_tab_get_all_views (GTR_TAB (tab), original,
+ translated));
+ i--;
+ }
+
+ return views;
}
/**
@@ -2055,17 +2019,16 @@ gtranslator_window_get_all_views(GtranslatorWindow *window,
* specific name, title and icon you want.
*/
void
-gtranslator_window_add_widget (GtranslatorWindow *window,
- GtkWidget *widget,
- const gchar *name,
- const gchar *title,
- const gchar *stock_id,
+gtranslator_window_add_widget (GtranslatorWindow * window,
+ GtkWidget * widget,
+ const gchar * name,
+ const gchar * title,
+ const gchar * stock_id,
GtranslatorWindowPlacement placement)
{
- /*FIXME: We have to manage the error*/
- add_widget_full (window, widget,
- name, title, stock_id,
- placement, FALSE, NULL);
+ /*FIXME: We have to manage the error */
+ add_widget_full (window, widget,
+ name, title, stock_id, placement, FALSE, NULL);
}
/**
@@ -2076,11 +2039,11 @@ gtranslator_window_add_widget (GtranslatorWindow *window,
* Removes from the @window the @widget if it exists.
*/
void
-gtranslator_window_remove_widget (GtranslatorWindow *window,
- GtkWidget *widget)
+gtranslator_window_remove_widget (GtranslatorWindow * window,
+ GtkWidget * widget)
{
- /*FIXME: We have to manage the error*/
- remove_widget (window, widget, NULL);
+ /*FIXME: We have to manage the error */
+ remove_widget (window, widget, NULL);
}
/**
@@ -2092,11 +2055,11 @@ gtranslator_window_remove_widget (GtranslatorWindow *window,
* Returns: the GDL layout manager of the window.
*/
GObject *
-_gtranslator_window_get_layout_manager (GtranslatorWindow *window)
+_gtranslator_window_get_layout_manager (GtranslatorWindow * window)
{
- g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
-
- return G_OBJECT (window->priv->layout_manager);
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
+
+ return G_OBJECT (window->priv->layout_manager);
}
/**
@@ -2110,33 +2073,33 @@ _gtranslator_window_get_layout_manager (GtranslatorWindow *window)
* Returns: the #GtranslatorTab which @location matches with its po file.
*/
GtkWidget *
-gtranslator_window_get_tab_from_location (GtranslatorWindow *window,
- GFile *location)
-{
- GList *tabs, *l;
- GtranslatorPo *po;
- GFile *po_location;
-
- g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
-
- tabs = gtranslator_window_get_all_tabs (window);
-
- for (l = tabs; l != NULL; l = g_list_next (l))
+gtranslator_window_get_tab_from_location (GtranslatorWindow * window,
+ GFile * location)
+{
+ GList *tabs, *l;
+ GtranslatorPo *po;
+ GFile *po_location;
+
+ g_return_val_if_fail (GTR_IS_WINDOW (window), NULL);
+
+ tabs = gtranslator_window_get_all_tabs (window);
+
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ po = gtranslator_tab_get_po (GTR_TAB (l->data));
+
+ po_location = gtranslator_po_get_location (po);
+
+ if (g_file_equal (location, po_location) == TRUE)
{
- po = gtranslator_tab_get_po (GTR_TAB (l->data));
-
- po_location = gtranslator_po_get_location (po);
-
- if (g_file_equal (location, po_location) == TRUE)
- {
- g_object_unref (po_location);
-
- return l->data;
- }
- g_object_unref (po_location);
+ g_object_unref (po_location);
+
+ return l->data;
}
-
- return NULL;
+ g_object_unref (po_location);
+ }
+
+ return NULL;
}
/**
@@ -2147,16 +2110,14 @@ gtranslator_window_get_tab_from_location (GtranslatorWindow *window,
* Sets the active tab for the @window.
*/
void
-gtranslator_window_set_active_tab (GtranslatorWindow *window,
- GtkWidget *tab)
+gtranslator_window_set_active_tab (GtranslatorWindow * window,
+ GtkWidget * tab)
{
- gint page;
-
- page = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
- tab);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
- page);
+ gint page;
+
+ page = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), tab);
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), page);
}
/**
@@ -2168,33 +2129,33 @@ gtranslator_window_set_active_tab (GtranslatorWindow *window,
* widgets.
*/
void
-_gtranslator_window_close_tab (GtranslatorWindow *window,
- GtranslatorTab *tab)
-{
- gint i;
-
- g_return_if_fail (GTR_IS_TAB (tab));
-
- i = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
- GTK_WIDGET (tab));
- if (i != -1)
- gtranslator_notebook_remove_page (GTR_NOTEBOOK (window->priv->notebook), i);
-
- /*
- * If there is only one file opened, we have to clear the statusbar
- */
- if (i == 0)
- {
- gtranslator_statusbar_push (GTR_STATUSBAR (window->priv->statusbar),
- 0,
- " ");
- gtranslator_statusbar_clear_progress_bar (GTR_STATUSBAR (window->priv->statusbar));
- }
- set_sensitive_according_to_window (window);
-}
-
-GtkWidget
-*gtranslator_window_get_tm_menu (GtranslatorWindow *window)
-{
- return window->priv->tm_menu;
+_gtranslator_window_close_tab (GtranslatorWindow * window,
+ GtranslatorTab * tab)
+{
+ gint i;
+
+ g_return_if_fail (GTR_IS_TAB (tab));
+
+ i = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
+ GTK_WIDGET (tab));
+ if (i != -1)
+ gtranslator_notebook_remove_page (GTR_NOTEBOOK (window->priv->notebook),
+ i);
+
+ /*
+ * If there is only one file opened, we have to clear the statusbar
+ */
+ if (i == 0)
+ {
+ gtranslator_statusbar_push (GTR_STATUSBAR (window->priv->statusbar),
+ 0, " ");
+ gtranslator_statusbar_clear_progress_bar (GTR_STATUSBAR
+ (window->priv->statusbar));
+ }
+ set_sensitive_according_to_window (window);
+}
+
+GtkWidget * gtranslator_window_get_tm_menu (GtranslatorWindow * window)
+{
+ return window->priv->tm_menu;
}
diff --git a/src/window.h b/src/window.h
index 4e39603..d449d52 100644
--- a/src/window.h
+++ b/src/window.h
@@ -33,7 +33,6 @@
#include "view.h"
G_BEGIN_DECLS
-
/*
* Type checking and casting macros
*/
@@ -43,101 +42,108 @@ G_BEGIN_DECLS
#define GTR_IS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_WINDOW))
#define GTR_IS_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_WINDOW))
#define GTR_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_WINDOW, GtranslatorWindowClass))
-
/* Private structure type */
-typedef struct _GtranslatorWindowPrivate GtranslatorWindowPrivate;
+typedef struct _GtranslatorWindowPrivate GtranslatorWindowPrivate;
/*
* Main object structure
*/
-typedef struct _GtranslatorWindow GtranslatorWindow;
+typedef struct _GtranslatorWindow GtranslatorWindow;
struct _GtranslatorWindow
{
- GtkWindow parent_instance;
-
- /*< private > */
- GtranslatorWindowPrivate *priv;
+ GtkWindow parent_instance;
+
+ /*< private > */
+ GtranslatorWindowPrivate *priv;
};
/*
* Class definition
*/
-typedef struct _GtranslatorWindowClass GtranslatorWindowClass;
+typedef struct _GtranslatorWindowClass GtranslatorWindowClass;
struct _GtranslatorWindowClass
{
- GtkWindowClass parent_class;
+ GtkWindowClass parent_class;
};
typedef enum
{
- GTR_WINDOW_PLACEMENT_NONE = 0,
- GTR_WINDOW_PLACEMENT_TOP,
- GTR_WINDOW_PLACEMENT_BOTTOM,
- GTR_WINDOW_PLACEMENT_RIGHT,
- GTR_WINDOW_PLACEMENT_LEFT,
- GTR_WINDOW_PLACEMENT_CENTER,
- GTR_WINDOW_PLACEMENT_FLOATING
+ GTR_WINDOW_PLACEMENT_NONE = 0,
+ GTR_WINDOW_PLACEMENT_TOP,
+ GTR_WINDOW_PLACEMENT_BOTTOM,
+ GTR_WINDOW_PLACEMENT_RIGHT,
+ GTR_WINDOW_PLACEMENT_LEFT,
+ GTR_WINDOW_PLACEMENT_CENTER,
+ GTR_WINDOW_PLACEMENT_FLOATING
} GtranslatorWindowPlacement;
/*
* Public methods
*/
-GType gtranslator_window_get_type (void) G_GNUC_CONST;
+GType
+gtranslator_window_get_type (void)
+ G_GNUC_CONST;
-GType gtranslator_window_register_type (GTypeModule * module);
+ GType gtranslator_window_register_type (GTypeModule * module);
-GtranslatorTab *gtranslator_window_create_tab (GtranslatorWindow *window,
- GtranslatorPo *po);
+ GtranslatorTab *gtranslator_window_create_tab (GtranslatorWindow *
+ window,
+ GtranslatorPo * po);
-GtranslatorTab *gtranslator_window_get_active_tab (GtranslatorWindow *window);
+ GtranslatorTab *gtranslator_window_get_active_tab (GtranslatorWindow *
+ window);
-GList *gtranslator_window_get_all_tabs (GtranslatorWindow *window);
+ GList *gtranslator_window_get_all_tabs (GtranslatorWindow * window);
-GtranslatorNotebook *gtranslator_window_get_notebook (GtranslatorWindow *window);
-GtranslatorHeader *gtranslator_window_get_header_from_active_tab (GtranslatorWindow *window);
+ GtranslatorNotebook *gtranslator_window_get_notebook (GtranslatorWindow *
+ window);
+ GtranslatorHeader
+ *gtranslator_window_get_header_from_active_tab (GtranslatorWindow *
+ window);
-GtkWidget *gtranslator_window_get_statusbar (GtranslatorWindow *window);
+ GtkWidget *gtranslator_window_get_statusbar (GtranslatorWindow * window);
-GtkUIManager *gtranslator_window_get_ui_manager (GtranslatorWindow *window);
+ GtkUIManager *gtranslator_window_get_ui_manager (GtranslatorWindow *
+ window);
-GtranslatorView *gtranslator_window_get_active_view (GtranslatorWindow *window);
+ GtranslatorView *gtranslator_window_get_active_view (GtranslatorWindow *
+ window);
-GList *gtranslator_window_get_all_views (GtranslatorWindow *window,
- gboolean original,
- gboolean translated);
+ GList *gtranslator_window_get_all_views (GtranslatorWindow * window,
+ gboolean original,
+ gboolean translated);
-void set_sensitive_according_to_message (GtranslatorWindow *window,
- GtranslatorPo *po);
+ void set_sensitive_according_to_message (GtranslatorWindow * window,
+ GtranslatorPo * po);
-void set_sensitive_according_to_window (GtranslatorWindow *window);
+ void set_sensitive_according_to_window (GtranslatorWindow * window);
-void gtranslator_window_add_widget (GtranslatorWindow *window,
- GtkWidget *widget,
- const gchar *name,
- const gchar *title,
- const gchar *stock_id,
- GtranslatorWindowPlacement placement);
+ void gtranslator_window_add_widget (GtranslatorWindow * window,
+ GtkWidget * widget,
+ const gchar * name,
+ const gchar * title,
+ const gchar * stock_id,
+ GtranslatorWindowPlacement
+ placement);
-void gtranslator_window_remove_widget (GtranslatorWindow *window,
- GtkWidget *widget);
+ void gtranslator_window_remove_widget (GtranslatorWindow * window,
+ GtkWidget * widget);
-GObject * _gtranslator_window_get_layout_manager
- (GtranslatorWindow *window);
+ GObject *_gtranslator_window_get_layout_manager
+ (GtranslatorWindow * window);
-GtkWidget *gtranslator_window_get_tab_from_location
- (GtranslatorWindow *window,
- GFile *location);
+ GtkWidget *gtranslator_window_get_tab_from_location
+ (GtranslatorWindow * window, GFile * location);
-void gtranslator_window_set_active_tab (GtranslatorWindow *window,
- GtkWidget *tab);
-
-void _gtranslator_window_close_tab (GtranslatorWindow *window,
- GtranslatorTab *tab);
+ void gtranslator_window_set_active_tab (GtranslatorWindow * window,
+ GtkWidget * tab);
-GtkWidget *gtranslator_window_get_tm_menu (GtranslatorWindow *window);
+ void _gtranslator_window_close_tab (GtranslatorWindow * window,
+ GtranslatorTab * tab);
-G_END_DECLS
+ GtkWidget *gtranslator_window_get_tm_menu (GtranslatorWindow * window);
+G_END_DECLS
#endif /* __WINDOW_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]