gedit r6741 - in trunk: . plugins/spell
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6741 - in trunk: . plugins/spell
- Date: Sun, 28 Dec 2008 19:23:36 +0000 (UTC)
Author: icq
Date: Sun Dec 28 19:23:36 2008
New Revision: 6741
URL: http://svn.gnome.org/viewvc/gedit?rev=6741&view=rev
Log:
2008-12-28 Ignacio Casal Quinteiro <nacho resa gmail com>
* plugins/spell/gedit-spell-plugin.c:
* plugins/spell/gedit-spell-checker-dialog.c:
* plugins/spell/gedit-spell-checker-dialog.h:
* plugins/spell/gedit-spell-language-dialog.c:
* plugins/spell/Makefile.am:
* plugins/spell/gedit-spell-language-dialog.h:
Use data-dir property.
Modified:
trunk/ChangeLog
trunk/plugins/spell/Makefile.am
trunk/plugins/spell/gedit-spell-checker-dialog.c
trunk/plugins/spell/gedit-spell-checker-dialog.h
trunk/plugins/spell/gedit-spell-language-dialog.c
trunk/plugins/spell/gedit-spell-language-dialog.h
trunk/plugins/spell/gedit-spell-plugin.c
Modified: trunk/plugins/spell/Makefile.am
==============================================================================
--- trunk/plugins/spell/Makefile.am (original)
+++ trunk/plugins/spell/Makefile.am Sun Dec 28 19:23:36 2008
@@ -12,9 +12,7 @@
$(ENCHANT_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
- -DGEDIT_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
- -DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" \
- -DGEDIT_UIDIR=\""$(datadir)/gedit-2/plugins/spell/"\"
+ -DGEDIT_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
plugin_LTLIBRARIES = libspell.la
Modified: trunk/plugins/spell/gedit-spell-checker-dialog.c
==============================================================================
--- trunk/plugins/spell/gedit-spell-checker-dialog.c (original)
+++ trunk/plugins/spell/gedit-spell-checker-dialog.c Sun Dec 28 19:23:36 2008
@@ -215,7 +215,8 @@
}
static void
-gedit_spell_checker_dialog_init (GeditSpellCheckerDialog *dlg)
+create_dialog (GeditSpellCheckerDialog *dlg,
+ const gchar *data_dir)
{
GtkWidget *error_widget;
GtkWidget *content;
@@ -223,6 +224,7 @@
GtkCellRenderer *cell;
GtkTreeSelection *selection;
gboolean ret;
+ gchar *ui_file;
gchar *root_objects[] = {
"content",
NULL
@@ -233,7 +235,8 @@
dlg->spell_checker = NULL;
dlg->misspelled_word = NULL;
- ret = gedit_utils_get_ui_objects (GEDIT_UIDIR "spell-checker.ui",
+ ui_file = g_build_filename (data_dir, "spell-checker.ui", NULL);
+ ret = gedit_utils_get_ui_objects (ui_file,
root_objects,
&error_widget,
@@ -250,7 +253,8 @@
"suggestions_list", &dlg->suggestions_list,
"language_label", &dlg->language_label,
NULL);
-
+ g_free (ui_file);
+
if (!ret)
{
gtk_widget_show (error_widget);
@@ -330,6 +334,11 @@
}
static void
+gedit_spell_checker_dialog_init (GeditSpellCheckerDialog *dlg)
+{
+}
+
+static void
gedit_spell_checker_dialog_destroy (GtkObject *object)
{
GeditSpellCheckerDialog *dlg = GEDIT_SPELL_CHECKER_DIALOG (object);
@@ -357,7 +366,7 @@
*/
GtkWidget *
-gedit_spell_checker_dialog_new (void)
+gedit_spell_checker_dialog_new (const gchar *data_dir)
{
GeditSpellCheckerDialog *dlg;
@@ -365,12 +374,15 @@
g_object_new (GEDIT_TYPE_SPELL_CHECKER_DIALOG, NULL));
g_return_val_if_fail (dlg != NULL, NULL);
+
+ create_dialog (dlg, data_dir);
return GTK_WIDGET (dlg);
}
GtkWidget *
-gedit_spell_checker_dialog_new_from_spell_checker (GeditSpellChecker *spell)
+gedit_spell_checker_dialog_new_from_spell_checker (GeditSpellChecker *spell,
+ const gchar *data_dir)
{
GeditSpellCheckerDialog *dlg;
@@ -380,6 +392,8 @@
g_object_new (GEDIT_TYPE_SPELL_CHECKER_DIALOG, NULL));
g_return_val_if_fail (dlg != NULL, NULL);
+
+ create_dialog (dlg, data_dir);
gedit_spell_checker_dialog_set_spell_checker (dlg, spell);
Modified: trunk/plugins/spell/gedit-spell-checker-dialog.h
==============================================================================
--- trunk/plugins/spell/gedit-spell-checker-dialog.h (original)
+++ trunk/plugins/spell/gedit-spell-checker-dialog.h Sun Dec 28 19:23:36 2008
@@ -70,9 +70,10 @@
GType gedit_spell_checker_dialog_get_type (void) G_GNUC_CONST;
/* Constructors */
-GtkWidget *gedit_spell_checker_dialog_new (void);
+GtkWidget *gedit_spell_checker_dialog_new (const gchar *data_dir);
GtkWidget *gedit_spell_checker_dialog_new_from_spell_checker
- (GeditSpellChecker *spell);
+ (GeditSpellChecker *spell,
+ const gchar *data_dir);
void gedit_spell_checker_dialog_set_spell_checker
(GeditSpellCheckerDialog *dlg,
Modified: trunk/plugins/spell/gedit-spell-language-dialog.c
==============================================================================
--- trunk/plugins/spell/gedit-spell-language-dialog.c (original)
+++ trunk/plugins/spell/gedit-spell-language-dialog.c Sun Dec 28 19:23:36 2008
@@ -115,13 +115,15 @@
}
static void
-gedit_spell_language_dialog_init (GeditSpellLanguageDialog *dlg)
+create_dialog (GeditSpellLanguageDialog *dlg,
+ const gchar *data_dir)
{
GtkWidget *error_widget;
GtkWidget *content;
gboolean ret;
GtkCellRenderer *cell;
GtkTreeViewColumn *column;
+ gchar *ui_file;
gchar *root_objects[] = {
"content",
NULL
@@ -152,13 +154,15 @@
G_CALLBACK (dialog_response_handler),
NULL);
- ret = gedit_utils_get_ui_objects (GEDIT_UIDIR "languages-dialog.ui",
+ ui_file = g_build_filename (data_dir, "languages-dialog.ui", NULL);
+ ret = gedit_utils_get_ui_objects (ui_file,
root_objects,
&error_widget,
"content", &content,
"languages_treeview", &dlg->languages_treeview,
NULL);
-
+ g_free (ui_file);
+
if (!ret)
{
gtk_widget_show (error_widget);
@@ -208,6 +212,12 @@
}
static void
+gedit_spell_language_dialog_init (GeditSpellLanguageDialog *dlg)
+{
+
+}
+
+static void
populate_language_list (GeditSpellLanguageDialog *dlg,
const GeditSpellCheckerLanguage *cur_lang)
{
@@ -249,7 +259,8 @@
GtkWidget *
gedit_spell_language_dialog_new (GtkWindow *parent,
- const GeditSpellCheckerLanguage *cur_lang)
+ const GeditSpellCheckerLanguage *cur_lang,
+ const gchar *data_dir)
{
GeditSpellLanguageDialog *dlg;
@@ -257,6 +268,8 @@
dlg = g_object_new (GEDIT_TYPE_SPELL_LANGUAGE_DIALOG, NULL);
+ create_dialog (dlg, data_dir);
+
populate_language_list (dlg, cur_lang);
gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
Modified: trunk/plugins/spell/gedit-spell-language-dialog.h
==============================================================================
--- trunk/plugins/spell/gedit-spell-language-dialog.h (original)
+++ trunk/plugins/spell/gedit-spell-language-dialog.h Sun Dec 28 19:23:36 2008
@@ -55,7 +55,8 @@
GType gedit_spell_language_dialog_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_spell_language_dialog_new (GtkWindow *parent,
- const GeditSpellCheckerLanguage *cur_lang);
+ const GeditSpellCheckerLanguage *cur_lang,
+ const gchar *data_dir);
const GeditSpellCheckerLanguage *
gedit_spell_language_get_selected_language (GeditSpellLanguageDialog *dlg);
Modified: trunk/plugins/spell/gedit-spell-plugin.c
==============================================================================
--- trunk/plugins/spell/gedit-spell-plugin.c (original)
+++ trunk/plugins/spell/gedit-spell-plugin.c Sun Dec 28 19:23:36 2008
@@ -57,8 +57,14 @@
guint message_cid;
} WindowData;
-static void spell_cb (GtkAction *action, GeditWindow *window);
-static void set_language_cb (GtkAction *action, GeditWindow *window);
+typedef struct
+{
+ GeditPlugin *plugin;
+ GeditWindow *window;
+} ActionData;
+
+static void spell_cb (GtkAction *action, ActionData *action_data);
+static void set_language_cb (GtkAction *action, ActionData *action_data);
static void auto_spell_cb (GtkAction *action, GeditWindow *window);
/* UI actions. */
@@ -676,17 +682,18 @@
static void
set_language_cb (GtkAction *action,
- GeditWindow *window)
+ ActionData *action_data)
{
GeditDocument *doc;
GeditSpellChecker *spell;
const GeditSpellCheckerLanguage *lang;
GtkWidget *dlg;
GtkWindowGroup *wg;
+ gchar *data_dir;
gedit_debug (DEBUG_PLUGINS);
- doc = gedit_window_get_active_document (window);
+ doc = gedit_window_get_active_document (action_data->window);
g_return_if_fail (doc != NULL);
spell = get_spell_checker_from_document (doc);
@@ -694,9 +701,13 @@
lang = gedit_spell_checker_get_language (spell);
- dlg = gedit_spell_language_dialog_new (GTK_WINDOW (window), lang);
+ data_dir = gedit_plugin_get_data_dir (action_data->plugin);
+ dlg = gedit_spell_language_dialog_new (GTK_WINDOW (action_data->window),
+ lang,
+ data_dir);
+ g_free (data_dir);
- wg = gedit_window_get_group (window);
+ wg = gedit_window_get_group (action_data->window);
gtk_window_group_add_window (wg, GTK_WINDOW (dlg));
@@ -712,7 +723,7 @@
static void
spell_cb (GtkAction *action,
- GeditWindow *window)
+ ActionData *action_data)
{
GeditView *view;
GeditDocument *doc;
@@ -722,10 +733,11 @@
GtkTextIter sel_start, sel_end;
gchar *word;
gboolean sel = FALSE;
+ gchar *data_dir;
gedit_debug (DEBUG_PLUGINS);
- view = gedit_window_get_active_view (window);
+ view = gedit_window_get_active_view (action_data->window);
g_return_if_fail (view != NULL);
doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
@@ -739,10 +751,11 @@
WindowData *data;
GtkWidget *statusbar;
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ data = (WindowData *) g_object_get_data (G_OBJECT (action_data->window),
+ WINDOW_DATA_KEY);
g_return_if_fail (data != NULL);
- statusbar = gedit_window_get_statusbar (window);
+ statusbar = gedit_window_get_statusbar (action_data->window);
gedit_statusbar_flash_message (GEDIT_STATUSBAR (statusbar),
data->message_cid,
_("The document is empty."));
@@ -771,10 +784,11 @@
WindowData *data;
GtkWidget *statusbar;
- data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
+ data = (WindowData *) g_object_get_data (G_OBJECT (action_data->window),
+ WINDOW_DATA_KEY);
g_return_if_fail (data != NULL);
- statusbar = gedit_window_get_statusbar (window);
+ statusbar = gedit_window_get_statusbar (action_data->window);
gedit_statusbar_flash_message (GEDIT_STATUSBAR (statusbar),
data->message_cid,
_("No misspelled words"));
@@ -782,9 +796,12 @@
return;
}
- dlg = gedit_spell_checker_dialog_new_from_spell_checker (spell);
+ data_dir = gedit_plugin_get_data_dir (action_data->plugin);
+ dlg = gedit_spell_checker_dialog_new_from_spell_checker (spell, data_dir);
+ g_free (data_dir);
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
- gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (window));
+ gtk_window_set_transient_for (GTK_WINDOW (dlg),
+ GTK_WINDOW (action_data->window));
g_signal_connect (dlg, "ignore", G_CALLBACK (ignore_cb), view);
g_signal_connect (dlg, "ignore_all", G_CALLBACK (ignore_cb), view);
@@ -854,7 +871,15 @@
g_return_if_fail (data != NULL);
g_object_unref (data->action_group);
- g_free (data);
+ g_slice_free (WindowData, data);
+}
+
+static void
+free_action_data (gpointer data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_slice_free (ActionData, data);
}
static void
@@ -887,20 +912,25 @@
{
GtkUIManager *manager;
WindowData *data;
+ ActionData *action_data;
gedit_debug (DEBUG_PLUGINS);
- data = g_new (WindowData, 1);
+ data = g_slice_new (WindowData);
+ action_data = g_slice_new (ActionData);
+ action_data->plugin = plugin;
+ action_data->window = window;
manager = gedit_window_get_ui_manager (window);
data->action_group = gtk_action_group_new ("GeditSpellPluginActions");
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_action_group_add_actions_full (data->action_group,
+ action_entries,
+ G_N_ELEMENTS (action_entries),
+ action_data,
+ (GDestroyNotify) free_action_data);
gtk_action_group_add_toggle_actions (data->action_group,
toggle_action_entries,
G_N_ELEMENTS (toggle_action_entries),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]