//! //! @brief Sets the text in the custom document font button //! @param font_description_string The font description in the form "Sans 10" //! G_MODULE_EXPORT void gw_settingswindow_sync_custom_font_cb (GSettings *settings, gchar *KEY, gpointer data) { //Declarations GwSettingsWindow *window; GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; GtkWidget *toplevel; GtkButton *button; char font[50]; //Initializations window = GW_SETTINGSWINDOW (data); g_return_if_fail (window != NULL); priv = window->priv; toplevel = gw_window_get_toplevel (GW_WINDOW (window)); application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); lw_preferences_get_string_by_schema (preferences, font, LW_SCHEMA_FONT, LW_KEY_FONT_CUSTOM_FONT, 50); button = GTK_BUTTON (priv->custom_font_fontbutton); //Body G_GNUC_EXTENSION g_signal_handlers_block_by_func (button, gw_settingswindow_custom_document_font_changed_cb, toplevel); gtk_font_button_set_font_name (GTK_FONT_BUTTON (button), font); G_GNUC_EXTENSION g_signal_handlers_unblock_by_func (button, gw_settingswindow_custom_document_font_changed_cb, toplevel); }
//! //! @brief Sets the checkbox to show or hide the toolbar //! @param request How to set the toolbar //! G_MODULE_EXPORT void gw_settingswindow_sync_search_as_you_type_cb (GSettings *settings, gchar *KEY, gpointer data) { //Declarations GwSettingsWindow *window; GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; GtkWidget *toplevel; gboolean request; GtkToggleButton *togglebutton; //Initializations window = GW_SETTINGSWINDOW (data); g_return_if_fail (window != NULL); priv = window->priv; application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); toplevel = gw_window_get_toplevel (GW_WINDOW (window)); request = lw_preferences_get_boolean_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_SEARCH_AS_YOU_TYPE); togglebutton = GTK_TOGGLE_BUTTON (priv->search_as_you_type_checkbutton); G_GNUC_EXTENSION g_signal_handlers_block_by_func (togglebutton, gw_settingswindow_search_as_you_type_toggled_cb, toplevel); gtk_toggle_button_set_active (togglebutton, request); G_GNUC_EXTENSION g_signal_handlers_unblock_by_func (togglebutton, gw_settingswindow_search_as_you_type_toggled_cb, toplevel); }
G_MODULE_EXPORT void gw_settingswindow_sync_global_document_font_cb (GSettings *settings, gchar *KEY, gpointer data) { //Declarations GwSettingsWindow *window; GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; gchar font[50]; gchar *font2; gchar *text; PangoFontDescription *desc; //Initializations window = GW_SETTINGSWINDOW (data); g_return_if_fail (window != NULL); priv = window->priv; application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); lw_preferences_get_string_by_schema (preferences, font, LW_SCHEMA_GNOME_INTERFACE, LW_KEY_DOCUMENT_FONT_NAME, 50); desc = pango_font_description_from_string (font); pango_font_description_set_family (desc, "Serif"); font2 = pango_font_description_to_string (desc); if (font2) text = g_strdup_printf (gettext("_Use the System Document Font (%s)"), font2); g_free (font2); font2 = NULL; pango_font_description_free (desc); desc = NULL; if (text != NULL) { gtk_button_set_label (GTK_BUTTON (priv->system_font_checkbutton), text); g_free (text); } }
GwDictionaryList* gw_application_get_installable_dictionarylist (GwApplication *application) { //Sanity checks g_return_val_if_fail (application != NULL, NULL); //Declarations GwApplicationPrivate *priv; LwPreferences *preferences; GwDictionaryList *dictionarylist; gpointer *pointer; //Initializations priv = application->priv; if (priv->installable_dictionarylist == NULL) { dictionarylist = gw_dictionarylist_new (); preferences = gw_application_get_preferences (application); lw_dictionarylist_load_installable (LW_DICTIONARYLIST (dictionarylist), preferences); priv->installable_dictionarylist = dictionarylist; pointer = (gpointer*) &(priv->installable_dictionarylist); g_object_add_weak_pointer (G_OBJECT (priv->installable_dictionarylist), pointer); } return priv->installable_dictionarylist; }
//! //! @brief Callback to reset all the colors for all the swatches to the default in the preferences //! @param widget Unused pointer to a GtkWidget //! @param data Unused gpointer //! G_MODULE_EXPORT void gw_settingswindow_reset_all_swatches_activated_cb (GtkWidget *widget, gpointer data) { //Declarations GwSettingsWindow *window; GwApplication *application; LwPreferences *preferences; int i; char *pref_key[] = { LW_KEY_MATCH_FG, LW_KEY_MATCH_BG, LW_KEY_HEADER_FG, LW_KEY_HEADER_BG, LW_KEY_COMMENT_FG, NULL }; //Initializations window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW)); g_return_if_fail (window != NULL); application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); //Start setting the default values for (i = 0; pref_key[i] != NULL; i++) { lw_preferences_reset_value_by_schema (preferences, LW_SCHEMA_HIGHLIGHT, pref_key[i]); } }
static void gw_spellcheck_remove_signals (GwSpellcheck *spellcheck) { //Declarations GwSpellcheckPrivate *priv; LwPreferences *preferences; GtkEntry *entry; GSource *source; int i; priv = spellcheck->priv; preferences = gw_application_get_preferences (priv->application); entry = priv->entry; if (priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] != 0) { lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] ); priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] = 0; } if (priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] != 0) { lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] ); priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] = 0; } for (i = 0; i < TOTAL_GW_SPELLCHECK_SIGNALIDS && entry != NULL; i++) { if (priv->signalid[i] > 0) { g_signal_handler_disconnect (G_OBJECT (entry), priv->signalid[i]); priv->signalid[i] = 0; } } for (i = 0; i < TOTAL_GW_SPELLCHECK_TIMEOUTIDS; i++) { if (g_main_current_source () != NULL && !g_source_is_destroyed (g_main_current_source ()) && priv->timeoutid[i] > 0 ) { source = g_main_context_find_source_by_id (NULL, priv->timeoutid[i]); if (source != NULL) { g_source_destroy (source); } } priv->timeoutid[i] = 0; } }
void gw_window_save_size (GwWindow *window) { GwWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; gchar buffer[500]; gchar *new_buffer; gchar **atoms; gchar *atom; gchar **ptr; const gchar *NAME; priv = window->priv; application = gw_window_get_application (window); preferences = gw_application_get_preferences (application); new_buffer = NULL; NAME = G_OBJECT_TYPE_NAME (window); atom = g_strdup_printf ("%s:%d,%d", NAME, priv->width, priv->height); if (atom != NULL) //Atom is sometimes freed as part of g_strfreev! { lw_preferences_get_string_by_schema (preferences, buffer, LW_SCHEMA_BASE, LW_KEY_WINDOW_SIZE, 500); atoms = g_strsplit (buffer, ";", -1); if (atoms != NULL) { ptr = atoms; while (*ptr != NULL && strncmp(*ptr, NAME, strlen(NAME)) != 0) ptr++; if (*ptr != NULL) { g_free (*ptr); *ptr = atom; new_buffer = g_strjoinv (";", atoms); } else { if (*buffer != '\0') new_buffer = g_strjoin (";", buffer, atom, NULL); else new_buffer = g_strdup (atom); g_free (atom); atom = NULL; } g_strfreev (atoms); atoms = NULL; } } //set our new buffer to the prefs if (new_buffer != NULL) { lw_preferences_set_string_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_WINDOW_SIZE, new_buffer); g_free (new_buffer); new_buffer = NULL; } }
static gboolean gw_settingswindow_dictionary_drag_reorder ( GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) { //Declarations GwSettingsWindow *window; GwApplication *application; GwDictionaryList *dictionarylist; LwPreferences *preferences; GtkTreeViewDropPosition drop_position; GtkTreePath *path; GtkTreeView *view; GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter, position; //Initializations window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (widget), GW_TYPE_SETTINGSWINDOW)); application = gw_window_get_application (GW_WINDOW (window)); dictionarylist = gw_application_get_installed_dictionarylist (application); preferences = gw_application_get_preferences (application); g_return_val_if_fail (window != NULL, FALSE); view = GTK_TREE_VIEW (widget); selection = gtk_tree_view_get_selection (view); model = gtk_tree_view_get_model (view); gtk_tree_view_get_dest_row_at_pos (view, x, y, &path, &drop_position); if (path == NULL) return FALSE; gtk_tree_model_get_iter (model, &position, path); gtk_tree_path_free (path); path = NULL; if (drop_position == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE) drop_position = GTK_TREE_VIEW_DROP_BEFORE; else if (drop_position == GTK_TREE_VIEW_DROP_INTO_OR_AFTER) drop_position = GTK_TREE_VIEW_DROP_AFTER; gtk_tree_selection_get_selected (selection, &model, &iter); if (drop_position == GTK_TREE_VIEW_DROP_BEFORE) gtk_list_store_move_before (GTK_LIST_STORE (model), &iter, &position); else if (drop_position == GTK_TREE_VIEW_DROP_AFTER) gtk_list_store_move_after (GTK_LIST_STORE (model), &iter, &position); gw_dictionarylist_save_order (dictionarylist, preferences); return TRUE; }
//! //! @brief Sets up the dictionary manager. This is the backbone of every portion of the GUI that allows editing dictionaries //! GwDictInfoList* gw_dictinfolist_new (const int MAX, GwApplication *application) { GwDictInfoList *temp; LwPreferences *preferences; temp = (GwDictInfoList*) malloc(sizeof(GwDictInfoList)); if (temp != NULL) { preferences = gw_application_get_preferences (application); lw_dictinfolist_init (LW_DICTINFOLIST (temp), MAX, preferences); gw_dictinfolist_init (temp, application); } return temp; }
//! //! @brief Callback to toggle spellcheck in the search entry //! @param widget Unused pointer to a GtkWidget //! @param data Unused gpointer //! void gw_application_spellcheck_toggled_cb (GSimpleAction *action, GVariant *parameter, gpointer data) { //Declarations GwApplication *application; LwPreferences *preferences; gboolean state; //Initializations application = GW_APPLICATION (data); preferences = gw_application_get_preferences (application); state = lw_preferences_get_boolean_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK); lw_preferences_set_boolean_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK, !state); }
//! //! Sets updates the list of dictionaries against the list in the global dictlist //! void gw_dictinfolist_reload (GwDictInfoList *dil) { LwPreferences *preferences; preferences = gw_application_get_preferences (dil->application); lw_dictinfolist_reload (LW_DICTINFOLIST (dil)); lw_dictinfolist_load_dictionary_order_from_pref (LW_DICTINFOLIST (dil), preferences); if (dil->signalids[GW_DICTINFOLIST_SIGNALID_ROW_CHANGED] > 0) g_signal_handler_block (dil->model, dil->signalids[GW_DICTINFOLIST_SIGNALID_ROW_CHANGED]); gw_dictinfolist_rebuild_liststore (dil); if (dil->signalids[GW_DICTINFOLIST_SIGNALID_ROW_CHANGED] > 0) g_signal_handler_unblock (dil->model, dil->signalids[GW_DICTINFOLIST_SIGNALID_ROW_CHANGED]); }
void gw_window_load_size (GwWindow *window) { GwApplication *application; LwPreferences *preferences; gchar buffer[500]; gchar **atoms; gchar **atom; gchar **ptr; gchar *endptr; const gchar* NAME; gint width, height; application = gw_window_get_application (window); preferences = gw_application_get_preferences (application); lw_preferences_get_string_by_schema (preferences, buffer, LW_SCHEMA_BASE, LW_KEY_WINDOW_SIZE, 500); NAME = G_OBJECT_TYPE_NAME (window); atoms = g_strsplit (buffer, ";", -1); if (atoms != NULL) { //look for the correct window name ptr = atoms; while (*ptr != NULL && strncmp(*ptr, NAME, strlen(NAME)) != 0) ptr++; //if it exists, get the info for it if (*ptr != NULL) { atom = g_strsplit_set (*ptr, ":,", 3); if (g_strv_length (atom) == 3) { width = (gint) g_ascii_strtoll (atom[1], &endptr, 10); height = (gint) g_ascii_strtoll (atom[2], &endptr, 10); gint default_width, default_height; gtk_window_get_default_size (GTK_WINDOW (window), &default_width, &default_height); if (width > 0 && width != default_width && height > 0 && height != default_height) { gtk_window_set_default_size (GTK_WINDOW (window), width, height); } } if (atom != NULL) g_strfreev (atom); atom = NULL; } g_strfreev (atoms); atoms = NULL; } }
//! //! @brief Sets the preference key for the new custom document font //! @param widget Unused GtkWidget pointer. //! @param data Unused gpointer //! G_MODULE_EXPORT void gw_settingswindow_custom_document_font_changed_cb (GtkWidget *widget, gpointer data) { GwSettingsWindow *window; GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; const char *font; window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW)); g_return_if_fail (window != NULL); priv = window->priv; application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); font = gtk_font_button_get_font_name (priv->custom_font_fontbutton); lw_preferences_set_string_by_schema (preferences, LW_SCHEMA_FONT, LW_KEY_FONT_CUSTOM_FONT, font); }
//! //! @brief Callback to toggle spellcheck in the search entry //! @param widget Unused pointer to a GtkWidget //! @param data Unused gpointer //! G_MODULE_EXPORT void gw_settingswindow_spellcheck_toggled_cb (GtkWidget *widget, gpointer data) { //Declarations GwSettingsWindow *window; GwApplication *application; LwPreferences *preferences; gboolean request; //Initializations window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW)); g_return_if_fail (window != NULL); application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); request = lw_preferences_get_boolean_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK); lw_preferences_set_boolean_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK, !request); }
//! //! @brief Callback to toggle romaji-kana conversion //! @param widget Unused pointer to a GtkWidget //! @param data Unused gpointer //! G_MODULE_EXPORT void gw_settingswindow_romaji_kana_conv_changed_cb (GtkWidget *widget, gpointer data) { //Declarations GwSettingsWindow *window; GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; int active; //Initializations window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW)); g_return_if_fail (window != NULL); priv = window->priv; application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); active = gtk_combo_box_get_active (priv->romaji_to_kana_combobox); lw_preferences_set_int_by_schema (preferences, LW_SCHEMA_BASE, LW_KEY_ROMAN_KANA, active); }
GtkListStore* gw_application_get_vocabularyliststore (GwApplication *application) { GwApplicationPrivate *priv; LwPreferences *preferences; gpointer* pointer; priv = application->priv; if (priv->vocabularyliststore == NULL) { preferences = gw_application_get_preferences (application); priv->vocabularyliststore = gw_vocabularyliststore_new (); pointer = (gpointer*) &(priv->vocabularyliststore); g_object_add_weak_pointer (G_OBJECT (priv->vocabularyliststore), pointer); gw_vocabularyliststore_load_list_order (GW_VOCABULARYLISTSTORE (priv->vocabularyliststore), preferences); } return priv->vocabularyliststore; }
static void gw_application_attach_signals (GwApplication *application) { #ifdef WITH_HUNSPELL //Sanity checks g_return_if_fail (application != NULL); //Declarations LwPreferences *preferences; //Initializations preferences = gw_application_get_preferences (application); lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK, gw_application_sync_spellcheck_cb, application ); #endif }
//! //! @brief Sets up an initites a new search in a new tab //! //! @param widget Currently unused widget pointer //! @param data A gpointer to a LwSearchItem that hold the search information //! static void _searchwindow_new_tab_with_search_cb (GtkMenuItem *widget, gpointer data) { //Sanity check g_assert (data != NULL); //Declarations GwApplication *application; GwSearchWindow *window; GwSearchWindowPrivate *priv; LwPreferences *preferences; LwSearchItem *item; LwSearchItem *item_new; GtkTextView *view; GwSearchData *sdata; int index; //Initializations item = LW_SEARCHITEM (data); sdata = GW_SEARCHDATA (lw_searchitem_get_data (item)); window = GW_SEARCHWINDOW (sdata->window); application = gw_window_get_application (GW_WINDOW (window)); priv = window->priv; preferences = gw_application_get_preferences (application); item_new = lw_searchitem_new (item->queryline->string, item->dictionary, preferences, NULL); if (!gw_application_can_start_search (application)) return; if (item_new != NULL) { view = gw_searchwindow_get_current_textview (window); sdata = gw_searchdata_new (view, window); lw_searchitem_set_data (item_new, sdata, LW_SEARCHITEM_DATA_FREE_FUNC (gw_searchdata_free)); index = gw_searchwindow_new_tab (window); gtk_notebook_set_current_page (priv->notebook, index); gw_searchwindow_start_search (window, item_new); } }
//! //! @brief Callback to set the user selected color to the color swatch for text highlighting //! @param widget Unused pointer to a GtkWidget //! @param data Unused gpointer //! G_MODULE_EXPORT void gw_settingswindow_swatch_color_changed_cb (GtkWidget *widget, gpointer data) { //Declarations GwSettingsWindow *window; GwApplication *application; LwPreferences *preferences; GdkRGBA color; char *hex_color_string; char *pref_key; char *letter; //Initializations window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW)); g_return_if_fail (window != NULL); application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); hex_color_string = gdk_rgba_to_string (&color); pref_key = g_strdup_printf ("%s", gtk_buildable_get_name (GTK_BUILDABLE (widget))); letter = strchr(pref_key, '_'); if (letter == NULL) return; *letter = '-'; letter = strchr(letter, '_'); if (letter == NULL) return; *letter = '\0'; //Set the color in the prefs if (pref_key != NULL && hex_color_string != NULL) { lw_preferences_set_string_by_schema (preferences, LW_SCHEMA_HIGHLIGHT, pref_key, hex_color_string); } //Cleanup if (pref_key != NULL) g_free (pref_key); if (hex_color_string != NULL) g_free (hex_color_string); }
static void gw_settingswindow_remove_signals (GwSettingsWindow *window) { //Declarations GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; int i; priv = window->priv; application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_ROMAJI_KANA] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_HIRA_KATA] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_KATA_HIRA] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_SPELLCHECK] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_FONT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_USE_GLOBAL_DOCUMENT_FONT] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_GNOME_INTERFACE, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_GLOBAL_DOCUMENT_FONT] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_FONT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_CUSTOM_FONT] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_SEARCH_AS_YOU_TYPE] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_MATCH_FG] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_MATCH_BG] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_COMMENT_FG] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_HEADER_FG] ); lw_preferences_remove_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, priv->signalids[GW_SETTINGSWINDOW_SIGNALID_HEADER_BG] ); for (i = 0; i < TOTAL_GW_SETTINGSWINDOW_SIGNALIDS; i++) priv->signalids[i] = 0; }
static void gw_settingswindow_attach_signals (GwSettingsWindow *window) { //Declarations GwSettingsWindowPrivate *priv; GwApplication *application; LwPreferences *preferences; int i; priv = window->priv; application = gw_window_get_application (GW_WINDOW (window)); preferences = gw_application_get_preferences (application); for (i = 0; i < TOTAL_GW_SETTINGSWINDOW_SIGNALIDS; i++) priv->signalids[i] = 0; priv->signalids[GW_SETTINGSWINDOW_SIGNALID_ROMAJI_KANA] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_ROMAN_KANA, gw_settingswindow_sync_romaji_kana_conv_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_HIRA_KATA] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_HIRA_KATA, gw_settingswindow_sync_hira_kata_conv_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_KATA_HIRA] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_KATA_HIRA, gw_settingswindow_sync_kata_hira_conv_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_SPELLCHECK] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK, gw_settingswindow_sync_spellcheck_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_USE_GLOBAL_DOCUMENT_FONT] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_FONT, LW_KEY_FONT_USE_GLOBAL_FONT, gw_settingswindow_sync_use_global_document_font_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_GLOBAL_DOCUMENT_FONT] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_GNOME_INTERFACE, LW_KEY_DOCUMENT_FONT_NAME, gw_settingswindow_sync_global_document_font_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_CUSTOM_FONT] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_FONT, LW_KEY_FONT_CUSTOM_FONT, gw_settingswindow_sync_custom_font_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_SEARCH_AS_YOU_TYPE] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_SEARCH_AS_YOU_TYPE, gw_settingswindow_sync_search_as_you_type_cb, window ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_MATCH_FG] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, LW_KEY_MATCH_FG, gw_settingswindow_sync_swatch_color_cb, priv->match_foreground ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_MATCH_BG] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, LW_KEY_MATCH_BG, gw_settingswindow_sync_swatch_color_cb, priv->match_background ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_COMMENT_FG] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, LW_KEY_COMMENT_FG, gw_settingswindow_sync_swatch_color_cb, priv->comment_foreground ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_HEADER_FG] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, LW_KEY_HEADER_FG, gw_settingswindow_sync_swatch_color_cb, priv->header_foreground ); priv->signalids[GW_SETTINGSWINDOW_SIGNALID_HEADER_BG] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_HIGHLIGHT, LW_KEY_HEADER_BG, gw_settingswindow_sync_swatch_color_cb, priv->header_background ); }
void gw_spellcheck_set_entry (GwSpellcheck *spellcheck, GtkEntry *entry) { GwSpellcheckPrivate *priv; LwPreferences *preferences; priv = spellcheck->priv; preferences = gw_application_get_preferences (priv->application); //Remove the old signals if (priv->entry != NULL) { if (priv->signalid[GW_SPELLCHECK_SIGNALID_DRAW] != 0) g_signal_handler_disconnect (G_OBJECT (priv->entry), priv->signalid[GW_SPELLCHECK_SIGNALID_DRAW]); if (priv->signalid[GW_SPELLCHECK_SIGNALID_CHANGED] != 0) g_signal_handler_disconnect (G_OBJECT (priv->entry), priv->signalid[GW_SPELLCHECK_SIGNALID_CHANGED]); if (priv->signalid[GW_SPELLCHECK_SIGNALID_POPULATE_POPUP] != 0) g_signal_handler_disconnect (G_OBJECT (priv->entry), priv->signalid[GW_SPELLCHECK_SIGNALID_POPULATE_POPUP]); if (priv->signalid[GW_SPELLCHECK_SIGNALID_DESTROY] != 0) g_signal_handler_disconnect (G_OBJECT (priv->entry), priv->signalid[GW_SPELLCHECK_SIGNALID_DESTROY]); g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer*) (&(priv->entry))); } //Set the entry pointer priv->entry = entry; if (entry == NULL) return; g_object_add_weak_pointer (G_OBJECT (priv->entry), (gpointer*) (&(priv->entry))); //set the new signals priv->signalid[GW_SPELLCHECK_SIGNALID_DICTIONARY] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_SPELLCHECK_DICTIONARY, gw_spellcheck_sync_dictionary_cb, spellcheck ); priv->signalid[GW_SPELLCHECK_SIGNALID_RK_CONV] = lw_preferences_add_change_listener_by_schema ( preferences, LW_SCHEMA_BASE, LW_KEY_ROMAJI_TO_FURIGANA, gw_spellcheck_sync_rk_conv_cb, spellcheck ); priv->signalid[GW_SPELLCHECK_SIGNALID_DRAW] = g_signal_connect_after ( G_OBJECT (entry), "draw", G_CALLBACK (gw_spellcheck_draw_underline_cb), spellcheck ); priv->signalid[GW_SPELLCHECK_SIGNALID_CHANGED] = g_signal_connect ( G_OBJECT (entry), "changed", G_CALLBACK (gw_spellcheck_queue_cb), spellcheck ); priv->signalid[GW_SPELLCHECK_SIGNALID_BUTTON_PRESS_EVENT] = g_signal_connect ( G_OBJECT (entry), "button-press-event", G_CALLBACK (gw_spellcheck_button_press_event_cb), spellcheck ); priv->signalid[GW_SPELLCHECK_SIGNALID_POPULATE_POPUP] = g_signal_connect ( G_OBJECT (entry), "populate-popup", G_CALLBACK (gw_spellcheck_populate_popup_cb), spellcheck ); priv->signalid[GW_SPELLCHECK_SIGNALID_DESTROY] = g_signal_connect_swapped ( G_OBJECT (entry), "destroy", G_CALLBACK (gw_spellcheck_remove_signals), spellcheck ); gw_spellcheck_queue (spellcheck); }
//! //! @brief Populates the main contextual menu with search options //! //! @param view The GtkTexView that was right clicked //! @param menu The Popup menu to populate //! @param data Currently unused gpointer containing user data //! static GtkWidget* _resultpopup_new (GwResultPopupData *rpdata) { if (rpdata == NULL) return NULL; //Declarations GwSearchWindow *window; GwApplication *application; LwDictInfoList *dictinfolist; LwPreferences *preferences; LwSearchItem *item; GwSearchData *sdata; LwDictInfo *di; GtkWidget *popup; char *menu_text; GtkWidget *menuitem; int i; //Initializations window = rpdata->window; application = gw_window_get_application (GW_WINDOW (window)); dictinfolist = LW_DICTINFOLIST (gw_application_get_dictinfolist (application)); preferences = gw_application_get_preferences (application); popup = gtk_menu_new (); g_signal_connect_after (G_OBJECT (popup), "hide", G_CALLBACK (_resultpopup_hide_cb), rpdata->button); char *website_url_menuitems[] = { "Wikipedia", "http://www.wikipedia.org/wiki/%s", "wikipedia.png", "Goo.ne.jp", "http://dictionary.goo.ne.jp/srch/all/%s/m0u/", "goo.png", "Google.com", "http://www.google.com/search?q=%s", "google.png", NULL, NULL, NULL }; //Add internal dictionary links i = 0; while ((di = lw_dictinfolist_get_dictinfo_by_load_position (dictinfolist, i)) != NULL) { if (di != NULL && (item = lw_searchitem_new (rpdata->text, di, preferences, NULL)) != NULL) { sdata = gw_searchdata_new (gw_searchwindow_get_current_textview (window), window); lw_searchitem_set_data (item, sdata, LW_SEARCHITEM_DATA_FREE_FUNC (gw_searchdata_free)); menu_text = g_strdup_printf ("%s", di->longname); if (menu_text != NULL) { menuitem = GTK_WIDGET (gtk_image_menu_item_new_with_label (menu_text)); g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (_searchwindow_new_tab_with_search_cb), item); g_signal_connect_swapped (G_OBJECT (menuitem), "destroy", G_CALLBACK (lw_searchitem_free), item); gtk_menu_shell_append (GTK_MENU_SHELL (popup), GTK_WIDGET (menuitem)); gtk_widget_show (GTK_WIDGET (menuitem)); // gtk_widget_show (GTK_WIDGET (menuimage)); g_free (menu_text); menu_text = NULL; } } i++; } //Separator menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (popup), GTK_WIDGET (menuitem)); gtk_widget_show (GTK_WIDGET (menuitem)); //Add weblinks i = 0; di = lw_dictinfolist_get_dictinfo_by_load_position (dictinfolist, 0); while (website_url_menuitems[i] != NULL) { if (di != NULL && (item = lw_searchitem_new (rpdata->text, di, preferences, NULL)) != NULL) { //Create handy variables sdata = gw_searchdata_new (gw_searchwindow_get_current_textview (window), window); lw_searchitem_set_data (item, sdata, LW_SEARCHITEM_DATA_FREE_FUNC (gw_searchdata_free)); char *name = website_url_menuitems[i]; char *url = g_strdup_printf(website_url_menuitems[i + 1], rpdata->text); if (url != NULL) { g_free (item->queryline->string); item->queryline->string = g_strdup (url); g_free (url); url = NULL; } char *icon_path = website_url_menuitems[i + 2]; //Start creating menu_text = g_strdup_printf ("%s", name); if (menu_text != NULL) { menuitem = GTK_WIDGET (gtk_image_menu_item_new_with_label (menu_text)); char *path = g_build_filename (DATADIR2, PACKAGE, icon_path, NULL); if (path != NULL) { // menuimage = gtk_image_new_from_file (path); // gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), GTK_WIDGET (menuimage)); g_free (path); path = NULL; } g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (_resultpopup_search_online_cb), item); g_signal_connect_swapped (G_OBJECT (menuitem), "destroy", G_CALLBACK (lw_searchitem_free), item); gtk_menu_shell_append (GTK_MENU_SHELL (popup), GTK_WIDGET (menuitem)); gtk_widget_show (GTK_WIDGET (menuitem)); // gtk_widget_show (GTK_WIDGET (menuimage)); g_free (menu_text); menu_text = NULL; } } i += 3; } return popup; }