コード例 #1
0
ファイル: application.c プロジェクト: kyoushuu/gwaei
static void 
gw_application_activate (GApplication *application)
{
    GwApplicationPrivate *priv;
    GwSearchWindow *searchwindow;
    GwVocabularyWindow *vocabularywindow;
    GwSettingsWindow *settingswindow;
    GwDictionaryList *dictionarylist;

    priv = GW_APPLICATION (application)->priv;
    dictionarylist = gw_application_get_installed_dictionarylist (GW_APPLICATION (application));

    if (priv->arg_new_vocabulary_window_switch)
    {
      vocabularywindow = GW_VOCABULARYWINDOW (gw_vocabularywindow_new (GTK_APPLICATION (application)));
      gtk_widget_show (GTK_WIDGET (vocabularywindow));
      return;
    }

    else
    {
      searchwindow = GW_SEARCHWINDOW (gw_searchwindow_new (GTK_APPLICATION (application)));
      gtk_widget_show (GTK_WIDGET (searchwindow));

      if (lw_dictionarylist_get_total (LW_DICTIONARYLIST (dictionarylist)) == 0)
      {
        settingswindow = GW_SETTINGSWINDOW (gw_settingswindow_new (GTK_APPLICATION (application)));
        gtk_window_set_transient_for (GTK_WINDOW (settingswindow), GTK_WINDOW (searchwindow));
        gtk_widget_show (GTK_WIDGET (settingswindow));
      }
      return;
    }
}
コード例 #2
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);
}
コード例 #3
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);
}
コード例 #4
0
ファイル: settingswindow.c プロジェクト: kyoushuu/gwaei
G_MODULE_EXPORT gboolean
gw_settingswindow_dictionary_drag_drop_cb (
  GtkWidget *widget,
  GdkDragContext *context,
  gint x,
  gint y,
  guint time,
  gpointer user_data)
{
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GtkTreeView *source;
    gboolean success;

    window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (widget), GW_TYPE_SETTINGSWINDOW));
    g_return_val_if_fail (window != NULL, FALSE);
    priv = window->priv;
    source = GTK_TREE_VIEW (gtk_drag_get_source_widget (context));
    success = FALSE;

    if (source == priv->manage_dictionaries_treeview)
      gw_settingswindow_dictionary_drag_reorder (widget, context, x, y, time, user_data);

    gtk_drag_finish (context, success, FALSE, time);

    return success;
}
コード例 #5
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);
}
コード例 #6
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);
    }
}
コード例 #7
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]);
    }
}
コード例 #8
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);
}
コード例 #9
0
ファイル: settingswindow.c プロジェクト: kyoushuu/gwaei
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;
}
コード例 #10
0
ファイル: settingswindow.c プロジェクト: kyoushuu/gwaei
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);
}
コード例 #11
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));
}
コード例 #12
0
G_MODULE_EXPORT void 
gw_settingswindow_sync_romaji_kana_conv_cb (GSettings *settings, gchar *KEY, gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GtkComboBox *combobox;
    int request;

    window = GW_SETTINGSWINDOW (data);
    priv = window->priv;
    combobox = priv->romaji_to_kana_combobox;
    request = lw_preferences_get_int (settings, KEY);

    gtk_combo_box_set_active (combobox, request);
}
コード例 #13
0
ファイル: settingswindow.c プロジェクト: kyoushuu/gwaei
//!
//! @brief Sets up the variables in main-interface.c and main-callbacks.c for use
//!
GtkWindow* 
gw_settingswindow_new (GtkApplication *application)
{
    g_assert (application != NULL);

    //Declarations
    GwSettingsWindow *window;

    //Initializations
    window = GW_SETTINGSWINDOW (g_object_new (GW_TYPE_SETTINGSWINDOW,
                                            "type",        GTK_WINDOW_TOPLEVEL,
                                            "application", GW_APPLICATION (application),
                                            "ui-xml",      "settingswindow.ui",
                                            NULL));

    return GTK_WINDOW (window);
}
コード例 #14
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);
}
コード例 #15
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);
}
コード例 #16
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);
}
コード例 #17
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);
}
コード例 #18
0
ファイル: settingswindow.c プロジェクト: kyoushuu/gwaei
G_MODULE_EXPORT void
gw_settingswindow_dictionary_drag_motion_cb (
  GtkWidget *widget,
  GdkDragContext *context,
  gint x,
  gint y,
  guint time,
  gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GtkTreeView *view;
    GtkTreeViewDropPosition drop_position;
    GtkTreePath *path;
    GtkTreeView *source;

    //Initializations
    window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (widget), GW_TYPE_SETTINGSWINDOW));
    g_return_if_fail (window != NULL);
    priv = window->priv;
    view = GTK_TREE_VIEW (widget);
    source = GTK_TREE_VIEW (gtk_drag_get_source_widget (context));

    if (source == priv->manage_dictionaries_treeview)
    {
      gtk_tree_view_get_dest_row_at_pos (view, x, y, &path, &drop_position);

      if (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_view_set_drag_dest_row (view, path, drop_position);
      }
    }

    if (path != NULL) gtk_tree_path_free (path); path = NULL;
}
コード例 #19
0
G_MODULE_EXPORT void 
gw_settingswindow_sync_spellcheck_cb (GSettings *settings, gchar *KEY, gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GtkWidget *toplevel;
    GtkToggleButton *togglebutton;
    gboolean request;

    //Initializations
    window = GW_SETTINGSWINDOW (data);
    g_return_if_fail (window != NULL);
    priv = window->priv;
    toplevel = gw_window_get_toplevel (GW_WINDOW (window));
    togglebutton = GTK_TOGGLE_BUTTON (priv->spellcheck_checkbutton);
    request = lw_preferences_get_boolean (settings, KEY);

    G_GNUC_EXTENSION g_signal_handlers_block_by_func (togglebutton, gw_settingswindow_spellcheck_toggled_cb, toplevel);
    gtk_toggle_button_set_active (togglebutton, request);
    G_GNUC_EXTENSION g_signal_handlers_unblock_by_func (togglebutton, gw_settingswindow_spellcheck_toggled_cb, toplevel);
}
コード例 #20
0
//!
//! @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);
}
コード例 #21
0
G_MODULE_EXPORT void 
gw_settingswindow_sync_swatch_color_cb (GSettings *settings, gchar *KEY, gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GtkColorChooser *swatch;
    GdkRGBA color;
    char hex_color_string[20];

    //Initializations
    window = GW_SETTINGSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_SETTINGSWINDOW));
    g_return_if_fail (window != NULL);
    swatch = GTK_COLOR_CHOOSER (data);
    lw_preferences_get_string (hex_color_string, settings, KEY, 20);
    g_assert (swatch != NULL);

    if (gdk_rgba_parse (&color, hex_color_string) == TRUE)
    {
      G_GNUC_EXTENSION g_signal_handlers_block_by_func (swatch, gw_settingswindow_swatch_color_changed_cb, window);
      gtk_color_chooser_set_rgba (swatch, &color);
      G_GNUC_EXTENSION g_signal_handlers_unblock_by_func (swatch, gw_settingswindow_swatch_color_changed_cb, window);
    }
}
コード例 #22
0
//!
//! @brief Callback to update the install dialog progress.  The data passed to it should be
//!        in the form of a LwDictInst.  If it is NULL, the progress window will be closed.
//!
G_MODULE_EXPORT gboolean 
gw_installprogresswindow_update_ui_timeout (gpointer data)
{
    //Sanity check
    g_assert (data != NULL);

    //Declarations
    GwInstallProgressWindow *window;
    GwInstallProgressWindowPrivate *priv;
    GtkWindow *settingswindow;
    GwApplication *application;
    LwDictInstList *dictinstlist;
    GwDictInfoList *dictinfolist;
    LwDictInst *di;
    GList *iter;
    int current_to_install;
    int total_to_install;
    char *text_installing;
    char *text_installing_markup;
    char *text_left;
    char *text_left_markup;
    char *text_progressbar;

    //Initializations
    window = GW_INSTALLPROGRESSWINDOW (gtk_widget_get_ancestor (GTK_WIDGET (data), GW_TYPE_INSTALLPROGRESSWINDOW));
    if (window == NULL) return FALSE;
    application = gw_window_get_application (GW_WINDOW (window));
    dictinstlist = gw_application_get_dictinstlist (application);
    priv = window->priv;
    current_to_install = 0;
    total_to_install = 0;

    //The install is complete close the window
    if (priv->di == NULL)
    {
      settingswindow = gtk_window_get_transient_for (GTK_WINDOW (window));
      dictinfolist = gw_application_get_dictinfolist (application);

      gw_dictinfolist_reload (dictinfolist);

      gtk_widget_destroy (GTK_WIDGET (window));

      gw_application_handle_error (application, GTK_WINDOW (settingswindow), TRUE, NULL);

      lw_dictinstlist_set_cancel_operations (dictinstlist, FALSE);
      gw_settingswindow_check_for_dictionaries (GW_SETTINGSWINDOW (settingswindow));

      return FALSE;
    }

    g_mutex_lock (priv->mutex);

    //Calculate the number of dictionaries left to install
    for (iter = dictinstlist->list; iter != NULL; iter = iter->next)
    {
      di = LW_DICTINST (iter->data);
      if (di != NULL && di->selected)
      {
        current_to_install++;
      }
      if (iter->data == priv->di) break;
    }

    //Calculate the number of dictionaries left to install
    for (iter = dictinstlist->list; iter != NULL; iter = iter->next)
    {
      di = LW_DICTINST (iter->data);
      if (di->selected)
      {
        total_to_install++;
      }
    }
    
    di = priv->di;

    text_progressbar =  g_markup_printf_escaped (gettext("Installing %s..."), di->filename);
    text_left = g_strdup_printf (gettext("Installing dictionary %d of %d..."), current_to_install, total_to_install);
    text_left_markup = g_markup_printf_escaped ("<big><b>%s</b></big>", text_left);
    text_installing = lw_dictinst_get_status_string (di, TRUE);
    text_installing_markup = g_markup_printf_escaped ("<small>%s</small>", text_installing);

    gtk_label_set_markup (priv->label, text_left_markup);
    gtk_label_set_markup (priv->sublabel, text_installing_markup);
    gtk_progress_bar_set_fraction (priv->progressbar, priv->install_fraction);
    gtk_progress_bar_set_text (priv->progressbar, text_progressbar);

    g_mutex_unlock (priv->mutex);

    //Cleanup
    g_free (text_progressbar);
    g_free (text_left);
    g_free (text_left_markup);
    g_free (text_installing);
    g_free (text_installing_markup);

    return TRUE;
}
コード例 #23
0
ファイル: settingswindow.c プロジェクト: kyoushuu/gwaei
static void 
gw_settingswindow_constructed (GObject *object)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GwApplication *application;
    LwDictionaryList *dictionarylist;
    GtkAccelGroup *accelgroup;

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

    //Initializations
    window = GW_SETTINGSWINDOW (object);
    priv = window->priv;
    accelgroup = gw_window_get_accel_group (GW_WINDOW (window));
    application = gw_window_get_application (GW_WINDOW (window));
    dictionarylist = LW_DICTIONARYLIST (gw_application_get_installed_dictionarylist (application));

    gw_settingswindow_map_actions (G_ACTION_MAP (window), window);

    priv->manage_dictionaries_treeview = GTK_TREE_VIEW (gw_window_get_object (GW_WINDOW (window), "dictionary_treeview"));
    priv->notebook = GTK_NOTEBOOK (gw_window_get_object (GW_WINDOW (window), "settings_notebook"));
    priv->close_button = GTK_BUTTON (gw_window_get_object (GW_WINDOW (window), "close_button"));
    priv->spellcheck_checkbutton = GTK_TOGGLE_BUTTON (gw_window_get_object (GW_WINDOW (window), "spellcheck_checkbutton"));
    priv->please_install_dictionary_hbox = GTK_BOX (gw_window_get_object (GW_WINDOW (window), "please_install_dictionary_hbox"));
    priv->custom_font_fontbutton = GTK_FONT_BUTTON (gw_window_get_object (GW_WINDOW (window), "custom_font_fontbutton"));

    priv->match_foreground = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "match_foreground_colorbutton"));
    priv->match_background = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "match_background_colorbutton"));
    priv->comment_foreground = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "comment_foreground_colorbutton"));
    priv->header_foreground = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "header_foreground_colorbutton"));
    priv->header_background = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "header_background_colorbutton"));
    priv->system_document_font_hbox = GTK_BOX (gw_window_get_object (GW_WINDOW (window), "system_document_font_hbox"));
    priv->system_font_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "system_font_checkbutton"));
    priv->search_as_you_type_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "search_as_you_type_checkbutton"));
    priv->romaji_to_kana_combobox = GTK_COMBO_BOX (gw_window_get_object (GW_WINDOW (window), "romaji_to_kana_combobox"));
    priv->hiragana_to_katakana_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "hiragana_to_katakana_checkbutton"));
    priv->katakana_to_hiragana_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "katakana_to_hiragana_checkbutton"));
    priv->remove_dictionary_toolbutton = GTK_TOOL_BUTTON (gw_window_get_object (GW_WINDOW (window), "remove_dictionary_toolbutton"));

    gtk_window_set_title (GTK_WINDOW (window), gettext("gWaei Settings"));
    gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
    gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
    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");
    gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);

    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (gw_settingswindow_remove_signals), NULL);

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


    gw_settingswindow_init_styles (window);
    gw_settingswindow_init_dictionary_treeview (window);

    if (lw_dictionarylist_get_total (LW_DICTIONARYLIST (dictionarylist)) == 0)
      gtk_notebook_set_current_page (priv->notebook, 1);
    gw_settingswindow_check_for_dictionaries (window);

    #ifdef WITH_HUNSPELL
    gtk_widget_show (GTK_WIDGET (priv->spellcheck_checkbutton));
    #else
    gtk_widget_hide (GTK_WIDGET (priv->spellcheck_checkbutton));
    #endif

    gw_settingswindow_attach_signals (window);

    gtk_widget_add_accelerator (GTK_WIDGET (priv->close_button), "activate", 
      accelgroup, (GDK_KEY_W), GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator (GTK_WIDGET (priv->close_button), "activate", 
      accelgroup, (GDK_KEY_Escape), 0, GTK_ACCEL_VISIBLE);

    gw_window_unload_xml (GW_WINDOW (window));
}