summaryrefslogtreecommitdiff
path: root/mate-dictionary/src/gdict-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-dictionary/src/gdict-window.c')
-rw-r--r--mate-dictionary/src/gdict-window.c186
1 files changed, 93 insertions, 93 deletions
diff --git a/mate-dictionary/src/gdict-window.c b/mate-dictionary/src/gdict-window.c
index 7921537c..2f4b9d9c 100644
--- a/mate-dictionary/src/gdict-window.c
+++ b/mate-dictionary/src/gdict-window.c
@@ -83,7 +83,7 @@ enum
enum
{
CREATED,
-
+
LAST_SIGNAL
};
@@ -115,7 +115,7 @@ gdict_window_finalize (GObject *gobject)
g_free (window->word);
g_free (window->database);
g_free (window->strategy);
-
+
G_OBJECT_CLASS (gdict_window_parent_class)->finalize (gobject);
}
@@ -136,7 +136,7 @@ gdict_window_dispose (GObject *gobject)
window->settings = NULL;
}
-
+
if (window->context)
{
if (window->lookup_start_id)
@@ -155,19 +155,19 @@ gdict_window_dispose (GObject *gobject)
g_object_unref (window->context);
window->context = NULL;
}
-
+
if (window->loader)
{
g_object_unref (window->loader);
window->loader = NULL;
}
-
+
if (window->ui_manager)
{
g_object_unref (window->ui_manager);
window->ui_manager = NULL;
}
-
+
if (window->action_group)
{
g_object_unref (window->action_group);
@@ -315,7 +315,7 @@ gdict_window_lookup_start_cb (GdictContext *context,
window->busy_cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
message = g_strdup_printf (_("Searching for '%s'..."), window->word);
-
+
if (window->status && window->statusbar_visible)
gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, message);
@@ -340,14 +340,14 @@ gdict_window_lookup_end_cb (GdictContext *context,
GtkTreeIter iter;
GdictSource *source;
GdictContext *speller_context;
-
+
count = window->current_definition;
window->max_definition = count - 1;
if (count == 0)
message = g_strdup (_("No definitions found"));
- else
+ else
message = g_strdup_printf (ngettext("A definition found",
"%d definitions found",
count),
@@ -400,7 +400,7 @@ gdict_window_error_cb (GdictContext *context,
GdictWindow *window)
{
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL);
-
+
if (window->status && window->statusbar_visible)
gtk_statusbar_push (GTK_STATUSBAR (window->status), 0,
_("No definitions found"));
@@ -429,10 +429,10 @@ gdict_window_error_cb (GdictContext *context,
context);
g_object_unref (context);
g_object_unref (source);
-
+
gdict_speller_set_strategy (GDICT_SPELLER (window->speller),
window->strategy);
-
+
gdict_speller_match (GDICT_SPELLER (window->speller),
window->word);
}
@@ -514,46 +514,46 @@ get_context_from_loader (GdictWindow *window)
source = gdict_source_loader_get_source (window->loader,
window->source_name);
}
-
+
if (!source)
{
gchar *detail;
-
+
detail = g_strdup_printf (_("No dictionary source available with name '%s'"),
window->source_name);
gdict_show_error_dialog (GTK_WINDOW (window),
_("Unable to find dictionary source"),
detail);
-
+
g_free (detail);
return NULL;
}
-
+
gdict_window_set_database (window, gdict_source_get_database (source));
gdict_window_set_strategy (window, 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));
-
+
gdict_show_error_dialog (GTK_WINDOW (window),
_("Unable to create a context"),
detail);
-
+
g_free (detail);
g_object_unref (source);
-
+
return NULL;
}
-
+
g_object_unref (source);
-
+
return retval;
}
@@ -589,7 +589,7 @@ gdict_window_set_word (GdictWindow *window,
const gchar *database)
{
gchar *title;
-
+
g_free (window->word);
window->word = NULL;
@@ -605,7 +605,7 @@ gdict_window_set_word (GdictWindow *window,
title = g_strdup_printf (_("%s - Dictionary"), window->word);
else
title = g_strdup (_("Dictionary"));
-
+
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
@@ -626,12 +626,12 @@ gdict_window_set_context (GdictWindow *window,
g_signal_handler_disconnect (window->context, window->lookup_start_id);
g_signal_handler_disconnect (window->context, window->lookup_end_id);
g_signal_handler_disconnect (window->context, window->error_id);
-
+
window->definition_id = 0;
window->lookup_start_id = 0;
window->lookup_end_id = 0;
window->error_id = 0;
-
+
g_object_unref (window->context);
window->context = NULL;
}
@@ -647,7 +647,7 @@ gdict_window_set_context (GdictWindow *window,
if (!context)
return;
-
+
/* attach our callbacks */
window->definition_id = g_signal_connect (context, "definition-found",
G_CALLBACK (gdict_window_definition_cb),
@@ -661,7 +661,7 @@ gdict_window_set_context (GdictWindow *window,
window->error_id = g_signal_connect (context, "error",
G_CALLBACK (gdict_window_error_cb),
window);
-
+
window->context = context;
}
@@ -699,7 +699,7 @@ gdict_window_set_property (GObject *object,
GParamSpec *pspec)
{
GdictWindow *window = GDICT_WINDOW (object);
-
+
switch (prop_id)
{
case PROP_ACTION:
@@ -742,7 +742,7 @@ gdict_window_get_property (GObject *object,
GParamSpec *pspec)
{
GdictWindow *window = GDICT_WINDOW (object);
-
+
switch (prop_id)
{
case PROP_ACTION:
@@ -947,7 +947,7 @@ gdict_window_cmd_file_new (GtkAction *action,
NULL, NULL);
gtk_widget_show (new_window);
-
+
g_signal_emit (window, gdict_window_signals[CREATED], 0, new_window);
}
@@ -956,9 +956,9 @@ gdict_window_cmd_save_as (GtkAction *action,
GdictWindow *window)
{
GtkWidget *dialog;
-
+
g_assert (GDICT_IS_WINDOW (window));
-
+
dialog = gtk_file_chooser_dialog_new (_("Save a Copy"),
GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -966,22 +966,22 @@ gdict_window_cmd_save_as (GtkAction *action,
"gtk-save", GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
-
+
/* default to user's home */
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), _("Untitled document"));
-
+
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
gchar *filename;
gchar *text;
gsize len;
GError *write_error = NULL;
-
+
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
+
text = gdict_defbox_get_text (GDICT_DEFBOX (window->defbox), &len);
-
+
g_file_set_contents (filename,
text,
len,
@@ -989,16 +989,16 @@ gdict_window_cmd_save_as (GtkAction *action,
if (write_error)
{
gchar *message;
-
+
message = g_strdup_printf (_("Error while writing to '%s'"), filename);
-
+
gdict_show_gerror_dialog (GTK_WINDOW (window),
message,
write_error);
g_free (message);
}
-
+
g_free (text);
g_free (filename);
}
@@ -1021,7 +1021,7 @@ gdict_window_cmd_file_print (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
gdict_show_print_dialog (GTK_WINDOW (window),
GDICT_DEFBOX (window->defbox));
}
@@ -1072,7 +1072,7 @@ gdict_window_cmd_edit_find (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
gdict_defbox_set_show_find (GDICT_DEFBOX (window->defbox), TRUE);
}
@@ -1099,7 +1099,7 @@ gdict_window_cmd_edit_preferences (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
gdict_show_pref_dialog (GTK_WIDGET (window),
_("Dictionary Preferences"),
window->loader);
@@ -1183,7 +1183,7 @@ gdict_window_cmd_go_first_def (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
window->last_definition = 0;
gdict_defbox_jump_to_definition (GDICT_DEFBOX (window->defbox),
window->last_definition);
@@ -1194,10 +1194,10 @@ gdict_window_cmd_go_previous_def (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
if (window->last_definition == 0)
return;
-
+
window->last_definition -= 1;
gdict_defbox_jump_to_definition (GDICT_DEFBOX (window->defbox),
window->last_definition);
@@ -1208,13 +1208,13 @@ gdict_window_cmd_go_next_def (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
if (window->max_definition == -1)
window->max_definition = gdict_defbox_count_definitions (GDICT_DEFBOX (window->defbox)) - 1;
-
+
if (window->last_definition == window->max_definition)
return;
-
+
window->last_definition += 1;
gdict_defbox_jump_to_definition (GDICT_DEFBOX (window->defbox),
window->last_definition);
@@ -1225,10 +1225,10 @@ gdict_window_cmd_go_last_def (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
if (window->max_definition == -1)
window->last_definition = gdict_defbox_count_definitions (GDICT_DEFBOX (window->defbox)) - 1;
-
+
window->last_definition = window->max_definition;
gdict_defbox_jump_to_definition (GDICT_DEFBOX (window->defbox),
window->last_definition);
@@ -1239,12 +1239,12 @@ gdict_window_cmd_help_contents (GtkAction *action,
GdictWindow *window)
{
GError *err = NULL;
-
+
g_return_if_fail (GDICT_IS_WINDOW (window));
gtk_show_uri_on_window (GTK_WINDOW (window),
"help:mate-dictionary",
- gtk_get_current_event_time (), &err);
+ gtk_get_current_event_time (), &err);
if (err)
{
gdict_show_gerror_dialog (GTK_WINDOW (window),
@@ -1258,7 +1258,7 @@ gdict_window_cmd_help_about (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
gdict_show_about_dialog (GTK_WIDGET (window));
}
@@ -1276,7 +1276,7 @@ gdict_window_cmd_escape (GtkAction *action,
GdictWindow *window)
{
g_assert (GDICT_IS_WINDOW (window));
-
+
gdict_defbox_set_show_find (GDICT_DEFBOX (window->defbox), FALSE);
}
@@ -1340,7 +1340,7 @@ static const GtkActionEntry entries[] =
G_CALLBACK (gdict_window_cmd_help_contents) },
{ "HelpAbout", "help-about", N_("_About"), NULL, NULL,
G_CALLBACK (gdict_window_cmd_help_about) },
-
+
/* Accelerators */
{ "Lookup", NULL, "", "<control>L", NULL, G_CALLBACK (gdict_window_cmd_lookup) },
{ "Escape", NULL, "", "Escape", "", G_CALLBACK (gdict_window_cmd_escape) },
@@ -1371,12 +1371,12 @@ gdict_window_state_event_cb (GtkWidget *widget,
gpointer user_data)
{
GdictWindow *window = GDICT_WINDOW (widget);
-
+
if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
window->is_maximized = TRUE;
else
window->is_maximized = FALSE;
-
+
return FALSE;
}
@@ -1386,12 +1386,12 @@ lookup_word (GdictWindow *window,
{
const gchar *entry_text;
gchar *word;
-
+
g_assert (GDICT_IS_WINDOW (window));
-
+
if (!window->context)
return;
-
+
entry_text = gtk_entry_get_text (GTK_ENTRY (window->entry));
if (!entry_text || *entry_text == '\0')
return;
@@ -1470,7 +1470,7 @@ speller_word_activated_cb (GdictSpeller *speller,
GdictWindow *window)
{
gtk_entry_set_text (GTK_ENTRY (window->entry), word);
-
+
gdict_window_set_word (window, word, db_name);
if (window->status && window->statusbar_visible)
@@ -1509,7 +1509,7 @@ sidebar_page_changed_cb (GdictSidebar *sidebar,
break;
case 't': /* strat-chooser */
message = _("Double-click on the matching strategy to use");
-
+
gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (window->strat_chooser));
break;
case 'o': /* source-chooser */
@@ -1523,7 +1523,7 @@ sidebar_page_changed_cb (GdictSidebar *sidebar,
break;
case 'd': /* db-chooser */
message = _("Double-click on the database to use");
-
+
gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (window->db_chooser));
break;
default:
@@ -1539,7 +1539,7 @@ static void
sidebar_closed_cb (GdictSidebar *sidebar,
GdictWindow *window)
{
- gdict_window_set_sidebar_visible (window, FALSE);
+ gdict_window_set_sidebar_visible (window, FALSE);
}
static void
@@ -1555,7 +1555,7 @@ gdict_window_link_clicked (GdictDefbox *defbox,
window->loader,
NULL, link_text);
gtk_widget_show (new_window);
-
+
g_signal_emit (window, gdict_window_signals[CREATED], 0, new_window);
}
@@ -1571,7 +1571,7 @@ gdict_window_drag_data_received_cb (GtkWidget *widget,
{
GdictWindow *window = GDICT_WINDOW (user_data);
gchar *text;
-
+
text = (gchar *) gtk_selection_data_get_text (data);
if (text)
{
@@ -1579,7 +1579,7 @@ gdict_window_drag_data_received_cb (GtkWidget *widget,
gdict_window_set_word (window, text, NULL);
g_free (text);
-
+
gtk_drag_finish (context, TRUE, FALSE, time_);
}
else
@@ -1649,7 +1649,7 @@ gdict_window_constructor (GType type,
window->main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), window->main_box);
gtk_widget_show (window->main_box);
-
+
/* build menus */
action_group = gtk_action_group_new ("MenuActions");
window->action_group = action_group;
@@ -1660,13 +1660,13 @@ gdict_window_constructor (GType type,
gtk_action_group_add_toggle_actions (action_group, toggle_entries,
G_N_ELEMENTS (toggle_entries),
window);
-
+
window->ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (window->ui_manager, action_group, 0);
-
+
accel_group = gtk_ui_manager_get_accel_group (window->ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
-
+
error = NULL;
if (!gtk_ui_manager_add_ui_from_file (window->ui_manager,
PKGDATADIR "/mate-dictionary-ui.xml",
@@ -1678,22 +1678,22 @@ gdict_window_constructor (GType type,
else
{
window->menubar = gtk_ui_manager_get_widget (window->ui_manager, "/MainMenu");
-
+
gtk_box_pack_start (GTK_BOX (window->main_box), window->menubar, FALSE, FALSE, 0);
gtk_widget_show (window->menubar);
gdict_window_ensure_menu_state (window);
}
-
+
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_container_add (GTK_CONTAINER (window->main_box), vbox);
gtk_widget_show (vbox);
-
+
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
-
+
button = gtk_button_new_with_mnemonic (_("Look _up:"));
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (lookup_word),
@@ -1704,18 +1704,18 @@ gdict_window_constructor (GType type,
window->completion_model = gtk_list_store_new (COMPLETION_N_COLUMNS,
G_TYPE_STRING);
-
+
window->completion = gtk_entry_completion_new ();
gtk_entry_completion_set_popup_completion (window->completion, TRUE);
gtk_entry_completion_set_model (window->completion,
GTK_TREE_MODEL (window->completion_model));
gtk_entry_completion_set_text_column (window->completion,
COMPLETION_TEXT_COLUMN);
-
+
window->entry = gtk_entry_new ();
if (window->word)
gtk_entry_set_text (GTK_ENTRY (window->entry), window->word);
-
+
gtk_entry_set_completion (GTK_ENTRY (window->entry),
window->completion);
g_signal_connect_swapped (window->entry, "activate",
@@ -1730,7 +1730,7 @@ gdict_window_constructor (GType type,
frame1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
frame2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-
+
window->defbox = gdict_defbox_new ();
if (window->context)
gdict_defbox_set_context (GDICT_DEFBOX (window->defbox), window->context);
@@ -1758,7 +1758,7 @@ gdict_window_constructor (GType type,
G_CALLBACK (sidebar_closed_cb),
window);
gtk_widget_show (window->sidebar);
-
+
/* Speller */
window->speller = gdict_speller_new ();
if (window->context)
@@ -1875,7 +1875,7 @@ gdict_window_constructor (GType type,
{
gint font_size;
gint width, height;
-
+
font_size = pango_font_description_get_size (font_desc);
font_size = PANGO_PIXELS (font_size);
@@ -1887,7 +1887,7 @@ gdict_window_constructor (GType type,
}
pango_font_description_free (font_desc);
-
+
gtk_window_set_title (GTK_WINDOW (window), _("Dictionary"));
gtk_window_set_default_size (GTK_WINDOW (window),
window->default_width,
@@ -2021,7 +2021,7 @@ static void
gdict_window_init (GdictWindow *window)
{
window->action = GDICT_WINDOW_ACTION_CLEAR;
-
+
window->loader = NULL;
window->context = NULL;
@@ -2042,7 +2042,7 @@ gdict_window_init (GdictWindow *window)
window->sidebar_visible = FALSE;
window->statusbar_visible = FALSE;
window->sidebar_page = NULL;
-
+
window->window_id = (gulong) time (NULL);
/* we need to create the chooser widgets for the sidebar before
@@ -2060,9 +2060,9 @@ gdict_window_new (GdictWindowAction action,
{
GtkWidget *retval;
GdictWindow *window;
-
+
g_return_val_if_fail (GDICT_IS_SOURCE_LOADER (loader), NULL);
-
+
retval = g_object_new (GDICT_TYPE_WINDOW,
"action", action,
"source-loader", loader,
@@ -2086,7 +2086,7 @@ gdict_window_new (GdictWindowAction action,
GdictContext *context;
gtk_entry_set_text (GTK_ENTRY (window->entry), word);
-
+
gdict_window_set_sidebar_visible (window, TRUE);
gdict_sidebar_view_page (GDICT_SIDEBAR (window->sidebar),
GDICT_SIDEBAR_SPELLER_PAGE);
@@ -2100,13 +2100,13 @@ gdict_window_new (GdictWindowAction action,
context = gdict_source_get_context (source);
gdict_speller_set_context (GDICT_SPELLER (window->speller), context);
-
+
g_object_unref (context);
g_object_unref (source);
-
+
gdict_speller_set_strategy (GDICT_SPELLER (window->speller),
window->strategy);
-
+
gdict_speller_match (GDICT_SPELLER (window->speller), word);
}
break;