示例#1
0
//!
//! @brief Opens the dictionary folder using the user's default file browser
//! @param widget Unused GtkWidget pointer
//! @param data Unused gpointer
//!
G_MODULE_EXPORT void 
gw_settingswindow_open_dictionary_folder_cb (GtkWidget *widget, gpointer data) 
{
    //Declarations
    GwSettingsWindow *window;
    GwApplication *application;
    char *directory;
    char *uri;
    GError *error;

    //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));
    directory = lw_util_build_filename (LW_PATH_DICTIONARY, NULL);
    uri = g_build_filename ("file://", directory, NULL);
    error = NULL;

    gtk_show_uri (NULL, uri, gtk_get_current_event_time (), &error);

    gw_application_handle_error (application, GTK_WINDOW (window), TRUE, &error);

    g_free (uri);
    g_free (directory);
}
示例#2
0
//!
//! @brief Searches for the word in a webbrower in an external dictionary
//! @param widget Unused GtkWidget pointer
//! @param data Unused gpointer
//!
static void _resultpopup_search_online_cb (GtkMenuItem *widget, gpointer data)
{
    //Sanity check
    g_assert (data != NULL);

    //Declarations
    GwApplication *application;
    LwSearchItem *item;
    GError *error;
    GwSearchWindow *window;
    GtkTextView *view;
    GwSearchData *sdata;

    //Initializations
    item = LW_SEARCHITEM (data);
    if (item != NULL)
    {
      sdata = GW_SEARCHDATA (lw_searchitem_get_data (item));
      window = GW_SEARCHWINDOW (sdata->window);
      application = GW_APPLICATION (gw_window_get_application (GW_WINDOW (window)));
      view = gw_searchwindow_get_current_textview (window);
      sdata = gw_searchdata_new (view, window);
      lw_searchitem_set_data (item, sdata, LW_SEARCHITEM_DATA_FREE_FUNC (gw_searchdata_free));
      error = NULL;
      printf("%s\n", item->queryline->string);

      gtk_show_uri (NULL, item->queryline->string, gtk_get_current_event_time (), &error);
      gw_application_handle_error (application, GTK_WINDOW (window), TRUE, &error);
    }
}
示例#3
0
//!
//! @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);
}
示例#4
0
void 
gw_application_open_settingswindow_cb (GSimpleAction *action,
                                       GVariant      *parameter,
                                       gpointer       data)
{
    //Declarations
    GwApplication *application;
    GwSearchWindow *searchwindow;
    GtkWindow *settingswindow;
    GList *link;

    //Initializations
    searchwindow = GW_SEARCHWINDOW (gw_application_get_last_focused_searchwindow (GW_APPLICATION (data)));
    application = gw_window_get_application (GW_WINDOW (searchwindow));
    link = gtk_application_get_windows (GTK_APPLICATION (application));

    while (link != NULL && !GW_IS_SETTINGSWINDOW (link->data)) link = link->next;

    if (link != NULL)
    {
      settingswindow = GTK_WINDOW (link->data);
      gtk_window_set_transient_for (GTK_WINDOW (settingswindow), GTK_WINDOW (searchwindow));
      gtk_window_present (GTK_WINDOW (settingswindow));
    }
    else
    {
      settingswindow = gw_settingswindow_new (GTK_APPLICATION (application));
      gtk_window_set_transient_for (GTK_WINDOW (settingswindow), GTK_WINDOW (searchwindow));
      gtk_widget_show (GTK_WIDGET (settingswindow));
    }
}
示例#5
0
//!
//! @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]);
    }
}
示例#6
0
//!
//! @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);
}
示例#7
0
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);
    }
}
示例#8
0
G_MODULE_EXPORT gboolean
gw_window_focus_in_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{
    //Declarations
    GwWindow *window;
    GwApplication *application;
    GMenuModel *menumodel;
    gboolean os_shows_win_menu;
    GtkSettings *settings;
    
    //Initializations
    window = GW_WINDOW (widget);
    application = gw_window_get_application (window);
    settings = gtk_settings_get_default ();
    g_object_get (settings, "gtk-shell-shows-menubar", &os_shows_win_menu, NULL);

    menumodel = gw_window_get_transient_for_menumodel (window);
    if (menumodel == NULL)
      menumodel = G_MENU_MODEL (g_menu_new ());
    if (menumodel == NULL) 
      return FALSE;

    if (os_shows_win_menu)
      gw_application_set_win_menubar (GW_APPLICATION (application), menumodel);

    return FALSE;
}
示例#9
0
void 
gw_settingswindow_remove_dictionary_cb (GSimpleAction *action, 
                                        GVariant      *parameter,
                                        gpointer       data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GwApplication *application;
    GwDictionaryList *dictionarylist;

    GtkTreePath *path;
    GtkTreeIter iter;
    LwDictionary *dictionary;
    GError *error;
    GtkTreeSelection *selection;
    GtkTreeModel *model;
    gboolean has_selection;
    gint* indices;
    GtkTreeView *view;

    //Initializations
    window = GW_SETTINGSWINDOW (data);
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));
    dictionarylist = gw_application_get_installed_dictionarylist (application);
    view = priv->manage_dictionaries_treeview;
    selection = gtk_tree_view_get_selection (view);
    model = GTK_TREE_MODEL (gw_dictionarylist_get_liststore (dictionarylist));
    has_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
    error = NULL;

    //Sanity check
    if (!has_selection) return;

    path = gtk_tree_model_get_path (model, &iter);
    indices = gtk_tree_path_get_indices (path);
    dictionary = lw_dictionarylist_remove_by_position (LW_DICTIONARYLIST (dictionarylist), *indices);

    if (dictionary != NULL)
    {
      lw_dictionary_uninstall (dictionary, NULL, &error);
    }

    //Cleanup
    gtk_tree_path_free (path); path = NULL;

    if (error != NULL)
    {
      gw_application_handle_error (application, GTK_WINDOW (window), TRUE, &error);
      exit(EXIT_SUCCESS);
    }

    gw_settingswindow_check_for_dictionaries (window);
}
示例#10
0
文件: window.c 项目: kyoushuu/gwaei
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;
    }
}
示例#11
0
//!
//! @brief Open the connection to the engine
//!
static void _kanjipadwindow_initialize_engine (GwKanjipadWindow *window)
{
    //Declarations
    GwApplication *application;
    GwKanjipadWindowPrivate *priv;
    char *dir;
    char *path;
    char *argv[2];
    GError *error;
    int stdin_fd;
    int stdout_fd;

    //Initializations
    application = gw_window_get_application (GW_WINDOW (window));
    priv = window->priv;
    error = NULL;
    dir = g_get_current_dir ();
#ifdef G_OS_WIN32
    path = g_build_filename (dir, "..", "lib", PACKAGE, "kpengine.exe", NULL);
#else
    path = g_build_filename (LIBDIR, PACKAGE, "kpengine", NULL);
#endif
    argv[0] = path;
    argv[1] = NULL;

    if (!g_file_test(argv[0], G_FILE_TEST_EXISTS)) 
    {
      fprintf(stderr, "Error: Can't find kpengine at %s\n", argv[0]);
      exit (EXIT_FAILURE);
    }

    if (!g_spawn_async_with_pipes (NULL, /* working directory */
           argv, NULL,  /* argv, envp */
           0,
           NULL, NULL,  /* child_setup */
           (gpointer)&priv->engine_pid,   /* child pid */
           &stdin_fd, &stdout_fd, NULL,
           &error))
    {
      gw_application_handle_error (application, NULL, FALSE, &error);
      exit (EXIT_FAILURE);
    }

    if (!(priv->to_engine = g_io_channel_unix_new (stdin_fd)))
      g_error ("Couldn't create pipe to child process: %s", g_strerror(errno));
    if (!(priv->from_engine = g_io_channel_unix_new (stdout_fd)))
      g_error ("Couldn't create pipe from child process: %s", g_strerror(errno));

    priv->iowatchid = g_io_add_watch (priv->from_engine, G_IO_IN, _kanjipadwindow_engine_input_handler, window);

    //Cleanup
    g_free(path);
    g_free(dir);
}
示例#12
0
static gpointer 
gw_installprogresswindow_install_thread (gpointer data)
{
    //Declarations
    GwInstallProgressWindow *window;
    GwInstallProgressWindowPrivate *priv;
    GwApplication *application;
    GwDictionaryList *dictionarylist;
    GList *link;
    LwDictionary *dictionary;
    GError *error;
    gulong signalid;
    GCancellable *cancellable;

    //Initializations
    window = GW_INSTALLPROGRESSWINDOW (data);
    if (window == NULL) return NULL;
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));
    dictionarylist = gw_application_get_installable_dictionarylist (application);
    cancellable = priv->cancellable;
    error = NULL;
    link = lw_dictionarylist_get_list (LW_DICTIONARYLIST (dictionarylist));

    //Do the installation
    g_timeout_add (100, gw_installprogresswindow_update_ui_timeout, window);
    while (link != NULL && error == NULL)
    {
      dictionary = LW_DICTIONARY (link->data);
      if (dictionary != NULL && lw_dictionary_is_selected (dictionary))
      {
        g_mutex_lock (&priv->mutex);
        priv->dictionary = dictionary;
        g_mutex_unlock (&priv->mutex);
        signalid = g_signal_connect (dictionary, "progress-changed", G_CALLBACK (gw_installprogresswindow_update_dictionary_cb), window);
        lw_dictionary_install (dictionary, cancellable, &error);
        if (g_signal_handler_is_connected (dictionary, signalid))
          g_signal_handler_disconnect (dictionary, signalid);
      }

      link = link->next;
    }

    gw_application_set_error (application, error);
    error = NULL;

    g_mutex_lock (&priv->mutex);
    //This will clue the progress window to close itself
    priv->dictionary = NULL;
    g_mutex_unlock (&priv->mutex);

    return NULL;
}
示例#13
0
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;
}
示例#14
0
static void 
gw_settingswindow_finalize (GObject *object)
{
    GwSettingsWindow *window;
    GwApplication *application;

    window = GW_SETTINGSWINDOW (object);
    application = gw_window_get_application (GW_WINDOW (window));

    if (g_main_current_source () != NULL) gw_application_unblock_searches (application);

    G_OBJECT_CLASS (gw_settingswindow_parent_class)->finalize (object);
}
示例#15
0
文件: printing.c 项目: pv/gwaei-stuff
//!
//! @brief Sets up a print preview for the results
//!
G_MODULE_EXPORT void gw_print_preview_cb (GtkWidget *widget, gpointer data)
{
    GwSearchWindow *window;
    GwApplication *application;

    window = GW_SEARCHWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SEARCHWINDOW));
    if (window == NULL) return;
    application = gw_window_get_application (GW_WINDOW (window));

    gw_application_block_searches (application);
    gw_print (GTK_PRINT_OPERATION_ACTION_PREVIEW, window);
    gw_application_unblock_searches (application);
}
G_MODULE_EXPORT void 
gw_installprogresswindow_cancel_cb (GtkWidget *widget, gpointer data)
{
    GwInstallProgressWindow *window;
    GwApplication *application;
    LwDictInstList *dictinstlist;

    window = GW_INSTALLPROGRESSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_INSTALLPROGRESSWINDOW));
    if (window == NULL) return;
    application = gw_window_get_application (GW_WINDOW (window));
    dictinstlist = gw_application_get_dictinstlist (application);

    lw_dictinstlist_set_cancel_operations (dictinstlist, TRUE);
}
示例#17
0
文件: printing.c 项目: kyoushuu/gwaei
//!
//! @brief Sets up a print operation for the current results
//!
//! The function checks the results of the results text buffer, and then attempts
//! to set up a print operation.  If a section of the search results are highlighted
//! only those results are printed.
//!
G_MODULE_EXPORT void gw_print_cb (GSimpleAction *action,
                                  GVariant      *parameter,
                                  gpointer       data)
{
    GwSearchWindow *window;
    GwApplication *application;

    window = GW_SEARCHWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SEARCHWINDOW));
    if (window == NULL) return;
    application = gw_window_get_application (GW_WINDOW (window));

    gw_application_block_searches (application);
    gw_print (GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, window);
    gw_application_unblock_searches (application);
}
示例#18
0
G_MODULE_EXPORT void
gw_flashcardwindow_close_cb (GtkWidget *widget, gpointer data)
{
    GwFlashCardWindow *window;
    GwApplication *application;

    window = GW_FLASHCARDWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_FLASHCARDWINDOW));
    g_return_if_fail (window != NULL);
    application = gw_window_get_application (GW_WINDOW (window));

    gtk_widget_destroy (GTK_WIDGET (window));

    if (gw_application_should_quit (application))
      gw_application_quit (application);
}
示例#19
0
void 
gw_settingswindow_add_dictionary_cb (GSimpleAction *action, 
                                     GVariant      *parameter,
                                     gpointer       data)
{
    GwSettingsWindow *window;
    GtkWindow *dictionaryinstallwindow;
    GwApplication *application;

    window = GW_SETTINGSWINDOW (data);
    application = gw_window_get_application (GW_WINDOW (window));

    dictionaryinstallwindow = gw_dictionaryinstallwindow_new (GTK_APPLICATION (application));
    gtk_window_set_transient_for (GTK_WINDOW (dictionaryinstallwindow), GTK_WINDOW (window));
    gtk_widget_show (GTK_WIDGET (dictionaryinstallwindow));
}
示例#20
0
GtkListStore*
gw_addvocabularywindow_get_wordstore (GwAddVocabularyWindow *window)
{
    //Declarations
    GwApplication *application;
    GtkListStore *wordstore;
    GtkListStore *liststore;
    const gchar *name;

    //Initializations
    application = gw_window_get_application (GW_WINDOW (window));
    liststore = gw_application_get_vocabularyliststore (application);
    name = gw_addvocabularywindow_get_list (window);
    wordstore = gw_vocabularyliststore_get_wordstore_by_name (GW_VOCABULARYLISTSTORE (liststore), name);

    return wordstore;
}
示例#21
0
G_MODULE_EXPORT gboolean
gw_window_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{
    GwApplication *application;
    GwWindow *window;

    window = GW_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_WINDOW));
    g_return_val_if_fail (window != NULL, FALSE);
    application = gw_window_get_application (window);

    gtk_widget_destroy (GTK_WIDGET (window));

    if (gw_application_should_quit (application))
      gw_application_quit (application);

    return TRUE;
}
示例#22
0
文件: window.c 项目: kyoushuu/gwaei
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;
    }
}
示例#23
0
//!
//! @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);
}
示例#24
0
//!
//! @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);
}
示例#25
0
//!
//! @brief Closes the window passed throught the widget pointer
//! @param widget GtkWidget pointer to the window to close
//! @param data Currently unused gpointer
//!
G_MODULE_EXPORT void 
gw_settingswindow_close_cb (GtkWidget *widget, gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GwApplication *application;
    GwDictionaryList *dictionarylist;
    
    //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));
    dictionarylist = gw_application_get_installed_dictionarylist (application);

    gtk_widget_destroy (GTK_WIDGET (window));

    if (lw_dictionarylist_get_total (LW_DICTIONARYLIST (dictionarylist)) == 0)
      gw_application_quit (application);
}
示例#26
0
//!
//! @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);
}
示例#27
0
static void
gw_addvocabularywindow_init_combobox (GwAddVocabularyWindow *window)
{
    GwAddVocabularyWindowPrivate *priv;
    GwAddVocabularyWindowClass *klass;
    GwApplication *application;
    GtkListStore *store;
    GtkTreeModel *model;

    priv = window->priv;
    klass = GW_ADDVOCABULARYWINDOW_CLASS (G_OBJECT_GET_CLASS (window));
    application = gw_window_get_application (GW_WINDOW (window));
    store = gw_application_get_vocabularyliststore (application);
    model = GTK_TREE_MODEL (store);

    //Initialize the combobox
    gtk_combo_box_set_model (priv->vocabulary_list_combobox, model); 

    //Remove the default entry since it doesn't seem to be editable for some reason
    priv->list_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->vocabulary_list_combobox)));
    gtk_widget_destroy (GTK_WIDGET (priv->list_entry));

    //Add our entry
    priv->list_entry = GTK_ENTRY (gtk_entry_new ());
    gtk_entry_set_activates_default (priv->list_entry, TRUE);
    g_signal_connect (G_OBJECT (priv->list_entry), "changed", G_CALLBACK (gw_addvocabularywindow_list_changed_cb), window);
    gtk_widget_show (GTK_WIDGET (priv->list_entry));
    gtk_combo_box_set_entry_text_column (priv->vocabulary_list_combobox, GW_VOCABULARYLISTSTORE_COLUMN_NAME);
    gtk_container_add (GTK_CONTAINER (priv->vocabulary_list_combobox), GTK_WIDGET (priv->list_entry));

    //Set the correct initial selection
    if (klass->last_selected_list_name != NULL)
    {
      gtk_entry_set_text (priv->list_entry, klass->last_selected_list_name);
    }
    else
    {
      gtk_combo_box_set_active (priv->vocabulary_list_combobox, 0);
    }
    gtk_editable_select_region (GTK_EDITABLE (priv->list_entry), 0, 0);
}
示例#28
0
//!
//! @brief The function that does the grunt work of setting up a search using the window
//!
//! The function will get the data from the buttons to set up the query and the dictionary
//! with that to set up the searchitem. 
//!
//! @param widget Currently unused GtkWidget pointer
//! @param data Currently unused gpointer
//!
G_MODULE_EXPORT void 
gw_radicalswindow_search_cb (GtkWidget *widget, gpointer data)
{
    //Declarations
    GwApplication *application;
    GwRadicalsWindow *window;
    GwSearchWindow *searchwindow;
    LwDictInfoList *dictinfolist;
    LwDictInfo *di;
    char *text_query;
    char *text_radicals;
    char *text_strokes;

    //Initializations
    window = GW_RADICALSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_RADICALSWINDOW));
    if (window == NULL) return;
    searchwindow = GW_SEARCHWINDOW (gtk_window_get_transient_for (GTK_WINDOW (window)));
    g_assert (searchwindow != NULL);
    application = gw_window_get_application (GW_WINDOW (window));
    dictinfolist = LW_DICTINFOLIST (gw_application_get_dictinfolist (application));
    di = lw_dictinfolist_get_dictinfo (dictinfolist, LW_DICTTYPE_KANJI, "Kanji");
    if (di == NULL) return;

    text_radicals = gw_radicalswindow_strdup_all_selected (window);
    text_strokes = gw_radicalswindow_strdup_prefered_stroke_count (window);
    text_query = g_strdup_printf ("%s%s", text_radicals, text_strokes);

    //Sanity checks
    if (text_query != NULL && strlen(text_query) > 0)
    {
      gw_searchwindow_entry_set_text (searchwindow, text_query);
      gw_searchwindow_set_dictionary (searchwindow, di->load_position);

      gw_searchwindow_search_cb (GTK_WIDGET (searchwindow), searchwindow);
    }

    //Cleanup
    if (text_query != NULL) g_free (text_query);
    if (text_strokes != NULL) g_free (text_strokes);
    if (text_radicals != NULL) g_free (text_radicals);
}
示例#29
0
//!
//! @brief Disables portions of the interface depending on the currently queued jobs.
//!
void 
gw_settingswindow_check_for_dictionaries (GwSettingsWindow *window)
{
    //Declarations
    GwSettingsWindowPrivate *priv;
    GwApplication *application;
    LwDictionaryList *dictionarylist;
    GtkWidget *message;

    //Initializations
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));
    dictionarylist = LW_DICTIONARYLIST (gw_application_get_installed_dictionarylist (application));
    message = GTK_WIDGET (priv->please_install_dictionary_hbox);

    //Set the show state of the dictionaries required message
    if (lw_dictionarylist_get_total (dictionarylist) > 0)
      gtk_widget_hide (message);
    else
      gtk_widget_show (message);
}
示例#30
0
//!
//! @brief Resets the states of all the buttons as if the dialog was just freshly opened
//!
//! @param widget Currently unused GtkWidget pointer
//! @param data Currently unused gpointer
//!
G_MODULE_EXPORT void 
gw_radicalswindow_clear_cb (GtkWidget *widget, gpointer data)
{
    //Declaratins
    GwApplication *application;
    GwRadicalsWindow *window;
    GwRadicalsWindowPrivate *priv;

    //Initializations
    window = GW_RADICALSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_RADICALSWINDOW));
    if (window == NULL) return;
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));

    gw_application_block_searches (application);

    gw_radicalswindow_deselect_all_radicals (window);
    gtk_toggle_button_set_active (priv->strokes_checkbutton, FALSE);

    gw_application_unblock_searches (application);
}