//!
//! @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);
}
//!
//! @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);
}
Beispiel #3
0
static void 
gw_window_constructed (GObject *object)
{
    GwWindow *window;
    GwWindowPrivate *priv;
    gboolean os_shows_app_menu;
    GtkSettings *settings;

    //Chain the parent class
    {
      G_OBJECT_CLASS (gw_window_parent_class)->constructed (object);
    }

    window = GW_WINDOW (object);
    priv = window->priv;
    settings = gtk_settings_get_default ();
    g_object_get (settings, "gtk-shell-shows-app-menu", &os_shows_app_menu, NULL);
    gtk_widget_add_events (GTK_WIDGET (window), GDK_FOCUS_CHANGE_MASK);

    gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);

    priv->accelgroup = gtk_accel_group_new ();
    gtk_window_add_accel_group (GTK_WINDOW (window), priv->accelgroup);
    gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (priv->application));
    priv->builder = gtk_builder_new ();
    gw_window_load_ui_xml (window, priv->ui_xml);
    priv->toplevel = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "toplevel"));

    g_signal_connect (G_OBJECT (window), "configure-event", G_CALLBACK (gw_window_configure_event_cb), NULL);
    g_signal_connect (window, "focus-in-event", G_CALLBACK (gw_window_focus_in_event_cb), NULL);
}
//!
//! @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);
    }
}
Beispiel #5
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));
    }
}
Beispiel #6
0
static void 
gw_window_get_property (GObject      *object,
                        guint         property_id,
                        GValue       *value,
                        GParamSpec   *pspec)
{
    GwWindow *window;
    GwWindowPrivate *priv;

    window = GW_WINDOW (object);
    priv = window->priv;

    switch (property_id)
    {
      case PROP_APPLICATION:
        g_value_set_object (value, priv->application);
        break;
      case PROP_UI_XML:
        g_value_set_string (value, priv->ui_xml);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}
Beispiel #7
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;
}
//!
//! @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);
}
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);
    }
}
//!
//! @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]);
    }
}
Beispiel #11
0
static void
gw_addvocabularywindow_init_accelerators (GwAddVocabularyWindow *window)
{
    GtkWidget *widget;
    GtkAccelGroup *accelgroup;

    accelgroup = gw_window_get_accel_group (GW_WINDOW (window));

    //Set menu accelerators
    widget = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "cancel_button"));
    gtk_widget_add_accelerator (GTK_WIDGET (widget), "activate", 
      accelgroup, (GDK_KEY_Escape), 0, GTK_ACCEL_VISIBLE);

    widget = GTK_WIDGET (gw_window_get_object (GW_WINDOW (window), "add_button"));
    gtk_widget_add_accelerator (GTK_WIDGET (widget), "activate", 
      accelgroup, (GDK_KEY_ISO_Enter), 0, GTK_ACCEL_VISIBLE);
}
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);
}
Beispiel #13
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);
}
Beispiel #14
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;
}
Beispiel #15
0
static void 
gw_kanjipadwindow_constructed (GObject *object)
{
    GwKanjipadWindow *window;
    GwKanjipadWindowPrivate *priv;
    GtkAccelGroup *accelgroup;

    //Chain the parent class
    {
      G_OBJECT_CLASS (gw_kanjipadwindow_parent_class)->constructed (object);
    }

    window = GW_KANJIPADWINDOW (object);
    priv = window->priv;
    accelgroup = gw_window_get_accel_group (GW_WINDOW (window));

    gw_kanjipadwindow_map_actions (G_ACTION_MAP (window), window);

    gtk_window_set_title (GTK_WINDOW (window), gettext("gWaei Kanjipad"));
    gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
    gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_UTILITY);
    gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE);
    gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE);
    gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE);
    gtk_window_set_icon_name (GTK_WINDOW (window), "gwaei");

    priv->drawingarea = GTK_DRAWING_AREA (gw_window_get_object (GW_WINDOW (window), "kdrawing_area"));
    priv->candidates = GTK_DRAWING_AREA (gw_window_get_object (GW_WINDOW (window), "kguesses"));
    priv->close_button = GTK_BUTTON (gw_window_get_object (GW_WINDOW (window), "close_button"));

    gw_kanjipadwindow_initialize_drawingarea (window);
    gw_kanjipadwindow_initialize_candidates (window);
    _kanjipadwindow_initialize_engine (window);

    gtk_widget_add_accelerator (GTK_WIDGET (priv->close_button), "activate", 
      accelgroup, (GDK_KEY_Escape), 0, GTK_ACCEL_VISIBLE);
    gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (priv->close_button), "win.close");

    gw_window_unload_xml (GW_WINDOW (window));
}
Beispiel #16
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;
}
Beispiel #17
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);
}
Beispiel #18
0
GMenuModel*
gw_window_get_transient_for_menumodel (GwWindow *window)
{
    //Sanity checks
    g_return_val_if_fail (window != NULL, NULL);

    //Declarations
    GMenuModel *menumodel;
    GwWindow *transientfor;
    gboolean check_transient_for;

    //Initializations
    transientfor = GW_WINDOW (gtk_window_get_transient_for (GTK_WINDOW (window)));
    menumodel = gw_window_get_menumodel (window);
    check_transient_for = (transientfor != NULL && menumodel == NULL);

    //Recursive
    if (check_transient_for)
      return gw_window_get_transient_for_menumodel (GW_WINDOW (transientfor));
    else
      return gw_window_get_menumodel (window);
}
Beispiel #19
0
//!
//! @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);
}
Beispiel #21
0
gboolean
gw_application_should_quit (GwApplication *application)
{
    GList *windowlist;
    GList *link;
    gboolean should_quit;

    windowlist = gtk_application_get_windows (GTK_APPLICATION (application));
    should_quit = TRUE;

    for (link = windowlist; should_quit && link != NULL; link = link->next)
      if (gw_window_is_important (GW_WINDOW (link->data))) should_quit = FALSE;

    return should_quit;
}
Beispiel #22
0
//!
//! @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);
}
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);
}
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));
}
Beispiel #25
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;
}
Beispiel #26
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;
}
Beispiel #27
0
static void 
gw_window_finalize (GObject *object)
{
    GwWindow *window;
    GwWindowPrivate *priv;

    window = GW_WINDOW (object);
    priv = window->priv;

    priv->application = NULL;
    if (priv->builder != NULL) g_object_unref (priv->builder);
    if (priv->ui_xml != NULL) g_free (priv->ui_xml);
    priv->toplevel = NULL;
    if (priv->accelgroup) g_object_unref (priv->accelgroup); priv->accelgroup = NULL;

    G_OBJECT_CLASS (gw_window_parent_class)->finalize (object);
}
Beispiel #28
0
G_MODULE_EXPORT gboolean 
gw_window_configure_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
{
    GwWindow *window;
    GwWindowPrivate *priv;
    GdkEventConfigure *event_configure;

    window = GW_WINDOW (widget);
    priv = window->priv;
    event_configure = (GdkEventConfigure*) event;

    priv->x = event_configure->x;
    priv->y = event_configure->y;
    priv->width = event_configure->width;
    priv->height = event_configure->height;

    return FALSE;
}
//!
//! @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);
}