static void database_found_cb (GdictContext *context, GdictDatabase *database, gpointer user_data) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (user_data); GdictDatabaseChooserPrivate *priv = chooser->priv; GtkTreeIter iter; const gchar *name, *full_name; gint weight = PANGO_WEIGHT_NORMAL; name = gdict_database_get_name (database); full_name = gdict_database_get_full_name (database); if (priv->current_db && !strcmp (priv->current_db, name)) weight = PANGO_WEIGHT_BOLD; GDICT_NOTE (CHOOSER, "DATABASE: `%s' (`%s')", name, full_name); gtk_list_store_append (priv->store, &iter); gtk_list_store_set (priv->store, &iter, DB_COLUMN_TYPE, DATABASE_NAME, DB_COLUMN_NAME, name, DB_COLUMN_DESCRIPTION, full_name, DB_COLUMN_CURRENT, weight, -1); priv->results += 1; }
static void gtr_dict_panel_set_context (GtrDictPanel * panel, GdictContext * context) { GtrDictPanelPrivate *priv = panel->priv; if (priv->context) { g_object_unref (priv->context); priv->context = NULL; } if (priv->defbox) gdict_defbox_set_context (GDICT_DEFBOX (priv->defbox), context); if (priv->db_chooser) gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (priv->db_chooser), context); if (priv->strat_chooser) gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (priv->strat_chooser), context); if (!context) return; priv->context = context; }
static void clear_button_clicked_cb (GtkWidget *widget, gpointer user_data) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (user_data); gdict_database_chooser_clear (chooser); }
static void gdict_database_chooser_finalize (GObject *gobject) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (gobject); GdictDatabaseChooserPrivate *priv = chooser->priv; g_free (priv->current_db); G_OBJECT_CLASS (gdict_database_chooser_parent_class)->finalize (gobject); }
static void lookup_end_cb (GdictContext *context, gpointer user_data) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (user_data); GdictDatabaseChooserPrivate *priv = chooser->priv; if (gtk_widget_get_window (GTK_WIDGET (chooser))) gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (chooser)), NULL); priv->is_searching = FALSE; }
static void error_cb (GdictContext *context, const GError *error, gpointer user_data) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (user_data); if (gtk_widget_get_window (GTK_WIDGET (chooser))) gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (chooser)), NULL); chooser->priv->is_searching = FALSE; chooser->priv->results = 0; }
static void sidebar_page_changed_cb (GdictSidebar * sidebar, GtrDictPanel * panel) { GtrDictPanelPrivate *priv = panel->priv; const gchar *page_id; const gchar *message; page_id = gdict_sidebar_current_page (sidebar); switch (page_id[0]) { case 's': { switch (page_id[1]) { case 'p': /* speller */ message = _("Double-click on the word to look up"); if (priv->word) gdict_speller_match (GDICT_SPELLER (priv->speller), priv->word); break; case 't': /* strat-chooser */ message = _("Double-click on the matching strategy to use"); gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (priv->strat_chooser)); break; case 'o': /* source-chooser */ message = _("Double-click on the source to use"); gdict_source_chooser_refresh (GDICT_SOURCE_CHOOSER (priv->source_chooser)); break; default: message = NULL; } } break; case 'd': /* db-chooser */ message = _("Double-click on the database to use"); gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (priv->db_chooser)); break; default: message = NULL; break; } if (message && priv->status) gtr_statusbar_flash_message (panel->priv->status, 0, "%s", message); }
static void lookup_start_cb (GdictContext *context, gpointer user_data) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (user_data); GdictDatabaseChooserPrivate *priv = chooser->priv; if (!priv->busy_cursor) priv->busy_cursor = gdk_cursor_new (GDK_WATCH); if (gtk_widget_get_window (GTK_WIDGET (chooser))) gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (chooser)), priv->busy_cursor); priv->is_searching = TRUE; }
static void sidebar_page_changed_cb (GdictSidebar *sidebar, GeditDictPanel *panel) { GeditDictPanelPrivate *priv = panel->priv; const gchar *page_id; const gchar *message; page_id = gdict_sidebar_current_page (sidebar); switch (page_id[0]) { case 's': { switch (page_id[1]) { case 'p': /* speller */ message = _("Double-click on the word to look up"); if (priv->word) gdict_speller_match (GDICT_SPELLER (priv->speller), priv->word); break; case 't': /* strat-chooser */ message = _("Double-click on the matching strategy to use"); gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (priv->strat_chooser)); break; default: message = NULL; } } break; case 'd': /* db-chooser */ message = _("Double-click on the database to use"); gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (priv->db_chooser)); break; default: message = NULL; break; } /*if (message && window->status) gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, message);*/ }
static void gdict_database_chooser_set_property (GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (gobject); switch (prop_id) { case PROP_CONTEXT: set_gdict_context (chooser, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
static void gdict_database_chooser_dispose (GObject *gobject) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (gobject); GdictDatabaseChooserPrivate *priv = chooser->priv; set_gdict_context (chooser, NULL); g_clear_object (&priv->busy_cursor); if (priv->store) { g_object_unref (priv->store); priv->store = NULL; } G_OBJECT_CLASS (gdict_database_chooser_parent_class)->dispose (gobject); }
static void row_activated_cb (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (user_data); GdictDatabaseChooserPrivate *priv = chooser->priv; GtkTreeIter iter; gchar *db_name, *db_desc; gboolean valid; valid = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path); if (!valid) { g_warning ("Invalid iterator found"); return; } gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, DB_COLUMN_NAME, &db_name, DB_COLUMN_DESCRIPTION, &db_desc, -1); if (db_name && db_desc) { g_free (priv->current_db); priv->current_db = g_strdup (db_name); g_signal_emit (chooser, db_chooser_signals[DATABASE_ACTIVATED], 0, db_name, db_desc); } else { gchar *row = gtk_tree_path_to_string (path); g_warning ("Row %s activated, but no database attached", row); g_free (row); } g_free (db_name); g_free (db_desc); }
static void gdict_database_chooser_get_property (GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec) { GdictDatabaseChooser *chooser = GDICT_DATABASE_CHOOSER (gobject); switch (prop_id) { case PROP_CONTEXT: g_value_set_object (value, chooser->priv->context); break; case PROP_COUNT: g_value_set_int (value, chooser->priv->results); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
static void save_source (GdictSourceDialog *dialog) { GdictSource *source; GdictDatabaseChooser *db_chooser; GdictStrategyChooser *strat_chooser; gchar *name, *text; GdictSourceTransport transport; gchar *host, *port; gchar *data; gsize length; GError *error; gchar *filename; source = gdict_source_loader_get_source (dialog->loader, dialog->source_name); if (!source) { g_warning ("Attempting to save source `%s', but no " "source for that name was found.", dialog->source_name); return; } text = get_text_from_entry (dialog, "description_entry"); gdict_source_set_description (source, text); g_free (text); db_chooser = GDICT_DATABASE_CHOOSER (dialog->db_chooser); text = gdict_database_chooser_get_current_database (db_chooser); gdict_source_set_database (source, text); g_free (text); strat_chooser = GDICT_STRATEGY_CHOOSER (dialog->strat_chooser); text = gdict_strategy_chooser_get_current_strategy (strat_chooser); gdict_source_set_strategy (source, text); g_free (text); /* get the selected transport id */ transport = dialog->transport; switch (transport) { case GDICT_SOURCE_TRANSPORT_DICTD: host = get_text_from_entry (dialog, "hostname_entry"); port = get_text_from_entry (dialog, "port_entry"); gdict_source_set_transport (source, GDICT_SOURCE_TRANSPORT_DICTD, "hostname", host, "port", atoi (port), NULL); g_free (host); g_free (port); break; case GDICT_SOURCE_TRANSPORT_INVALID: default: g_warning ("Invalid transport"); return; } error = NULL; data = gdict_source_to_data (source, &length, &error); if (error) { gdict_show_gerror_dialog (GTK_WINDOW (dialog), _("Unable to create a source file"), error); g_object_unref (source); return; } name = g_strdup_printf ("%s.desktop", gdict_source_get_name (source)); filename = g_build_filename (g_get_home_dir (), ".gnome2", "gnome-dictionary", name, NULL); g_free (name); g_file_set_contents (filename, data, length, &error); if (error) gdict_show_gerror_dialog (GTK_WINDOW (dialog), _("Unable to save source file"), error); g_free (filename); g_free (data); g_object_unref (source); }
static void update_dialog_ui (GdictSourceDialog *dialog) { GdictSource *source; /* TODO - add code to update the contents of the dialog depending * on the action; if we are in _CREATE, no action is needed */ switch (dialog->action) { case GDICT_SOURCE_DIALOG_VIEW: case GDICT_SOURCE_DIALOG_EDIT: if (!dialog->source_name) { g_warning ("Attempting to retrieve source, but no " "source name has been defined. Aborting..."); return; } source = gdict_source_loader_get_source (dialog->loader, dialog->source_name); if (!source) { g_warning ("Attempting to retrieve source, but no " "source named `%s' was found. Aborting...", dialog->source_name); return; } g_object_ref (source); dialog->source = source; set_text_to_entry (dialog, "description_entry", gdict_source_get_description (source)); dialog->transport = gdict_source_get_transport (source); gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->transport_combo), (gint) dialog->transport); /* set the context for the database and strategy choosers */ dialog->context = gdict_source_get_context (source); if (!dialog->context) { g_warning ("Attempting to retrieve the context, but " "none was found for source `%s'.", dialog->source_name); return; } set_transport_settings (dialog); gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (dialog->db_chooser), dialog->context); gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (dialog->db_chooser)); gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (dialog->strat_chooser), dialog->context); gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (dialog->strat_chooser)); break; case GDICT_SOURCE_DIALOG_CREATE: /* DICTD transport is default */ gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->transport_combo), 0); g_signal_emit_by_name (dialog->transport_combo, "changed"); break; default: g_assert_not_reached (); break; } }
static void gtr_dict_panel_init (GtrDictPanel * panel) { GtrDictPanelPrivate *priv; GtkWidget *vbox; GtkWidget *hbox; panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel); priv = panel->priv; priv->status = NULL; if (!priv->loader) panel->priv->loader = gdict_source_loader_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (panel), GTK_ORIENTATION_VERTICAL); /* add our data dir inside $HOME to the loader's search paths */ gdict_source_loader_add_search_path (priv->loader, gtr_dirs_get_user_config_dir ()); /* settings */ priv->settings = g_settings_new ("org.gnome.gtranslator.plugins.dictionary"); g_signal_connect (priv->settings, "changed", G_CALLBACK (on_settings_changed), panel); /* force retrieval of the configuration from gsettings */ gtr_dict_panel_set_source_name (panel, NULL); /* Draw widgets */ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* Look up Button */ panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:")); g_signal_connect (panel->priv->button, "clicked", G_CALLBACK (gtr_dict_panel_entry_activate_cb), panel); gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE); gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0); gtk_widget_show (panel->priv->button); /* Entry */ panel->priv->entry = gtk_entry_new (); if (panel->priv->word) gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word); g_signal_connect (panel->priv->entry, "activate", G_CALLBACK (gtr_dict_panel_entry_activate_cb), panel); gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0); gtk_widget_show (panel->priv->entry); /* Defbox */ panel->priv->defbox = gdict_defbox_new (); if (panel->priv->context) gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox), panel->priv->context); g_signal_connect (panel->priv->defbox, "link-clicked", G_CALLBACK (gtr_dict_panel_link_clicked), panel); gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox); gtk_widget_show (panel->priv->defbox); /* Sidebar */ panel->priv->sidebar = gdict_sidebar_new (); g_signal_connect (panel->priv->sidebar, "page-changed", G_CALLBACK (sidebar_page_changed_cb), panel); /* Paned */ panel->priv->paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL)); gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET (panel->priv->paned), TRUE, TRUE, 0); gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE); gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE); gtk_widget_show (GTK_WIDGET (panel->priv->paned)); g_settings_bind (panel->priv->settings, DICTIONARY_SETTINGS_POSITION_KEY, panel->priv->paned, "position", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET); /* Speller */ panel->priv->speller = gdict_speller_new (); if (panel->priv->context) gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller), panel->priv->context); g_signal_connect (panel->priv->speller, "word-activated", G_CALLBACK (speller_word_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_SPELLER_PAGE, _("Similar words"), panel->priv->speller); gtk_widget_show (panel->priv->speller); /* db chooser */ panel->priv->db_chooser = gdict_database_chooser_new (); if (panel->priv->context) gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (panel->priv->db_chooser), panel->priv->context); g_signal_connect (panel->priv->db_chooser, "database-activated", G_CALLBACK (database_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_DATABASES_PAGE, _("Available dictionaries"), panel->priv->db_chooser); gtk_widget_show (panel->priv->db_chooser); /* Strategy chooser */ panel->priv->strat_chooser = gdict_strategy_chooser_new (); if (panel->priv->context) gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (panel->priv->strat_chooser), panel->priv->context); g_signal_connect (panel->priv->strat_chooser, "strategy-activated", G_CALLBACK (strategy_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_STRATEGIES_PAGE, _("Available strategies"), panel->priv->strat_chooser); gtk_widget_show (panel->priv->strat_chooser); /* Source chooser */ panel->priv->source_chooser = gdict_source_chooser_new_with_loader (panel->priv->loader); g_signal_connect (panel->priv->source_chooser, "source-activated", G_CALLBACK (source_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_SOURCES_PAGE, _("Dictionary sources"), panel->priv->source_chooser); gtk_widget_show (panel->priv->source_chooser); gtk_widget_show (panel->priv->sidebar); }
static void gedit_dict_panel_draw (GeditDictPanel *panel) { GtkWidget *vbox; GtkWidget *hbox; vbox = gtk_vbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_widget_show (vbox); hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* * Look up Button */ panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:")); g_signal_connect(panel->priv->button, "clicked", G_CALLBACK (gedit_dict_panel_entry_activate_cb), panel); gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE); gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0); gtk_widget_show(panel->priv->button); /* * Entry */ panel->priv->entry = gtk_entry_new (); if (panel->priv->word) gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word); g_signal_connect (panel->priv->entry, "activate", G_CALLBACK (gedit_dict_panel_entry_activate_cb), panel); gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0); gtk_widget_show (panel->priv->entry); /* * Defbox */ panel->priv->defbox = gdict_defbox_new (); if (panel->priv->context) gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox), panel->priv->context); g_signal_connect(panel->priv->defbox, "link-clicked", G_CALLBACK(gedit_dict_panel_link_clicked), panel); gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox); gtk_widget_show (panel->priv->defbox); panel->priv->sidebar = gdict_sidebar_new (); g_signal_connect (panel->priv->sidebar, "page-changed", G_CALLBACK (sidebar_page_changed_cb), panel); /* * Paned */ panel->priv->paned = GTK_PANED(gtk_vpaned_new()); gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET(panel->priv->paned), TRUE, TRUE, 0); gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE); gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE); gtk_widget_show (GTK_WIDGET(panel->priv->paned)); g_signal_connect(panel->priv->paned, "notify::position", G_CALLBACK(store_position), NULL); /* * Speller */ panel->priv->speller = gdict_speller_new (); if (panel->priv->context) gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller), panel->priv->context); g_signal_connect (panel->priv->speller, "word-activated", G_CALLBACK (speller_word_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_SPELLER_PAGE, _("Similar words"), panel->priv->speller); gtk_widget_show (panel->priv->speller); /* * db chooser */ panel->priv->db_chooser = gdict_database_chooser_new (); if (panel->priv->context) gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (panel->priv->db_chooser), panel->priv->context); g_signal_connect (panel->priv->db_chooser, "database-activated", G_CALLBACK (database_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_DATABASES_PAGE, _("Available dictionaries"), panel->priv->db_chooser); gtk_widget_show (panel->priv->db_chooser); /* * Strategy chooser */ panel->priv->strat_chooser = gdict_strategy_chooser_new (); if (panel->priv->context) gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (panel->priv->strat_chooser), panel->priv->context); g_signal_connect (panel->priv->strat_chooser, "strategy-activated", G_CALLBACK (strategy_activated_cb), panel); gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar), GDICT_SIDEBAR_STRATEGIES_PAGE, _("Available strategies"), panel->priv->strat_chooser); gtk_widget_show (panel->priv->strat_chooser); gtk_widget_show (panel->priv->sidebar); }
static void build_new_source (GdictSourceDialog *dialog) { GdictSource *source; gchar *name, *text; GdictSourceTransport transport; gchar *host, *port; gchar *data; gsize length; GError *error; gchar *filename; GdictDatabaseChooser *db_chooser; GdictStrategyChooser *strat_chooser; source = gdict_source_new (); /* use the timestamp and the pid to get a unique name */ name = g_strdup_printf ("source-%lu-%u", (gulong) time (NULL), (guint) getpid ()); gdict_source_set_name (source, name); g_free (name); text = get_text_from_entry (dialog, "description_entry"); gdict_source_set_description (source, text); g_free (text); db_chooser = GDICT_DATABASE_CHOOSER (dialog->db_chooser); text = gdict_database_chooser_get_current_database (db_chooser); gdict_source_set_database (source, text); g_free (text); strat_chooser = GDICT_STRATEGY_CHOOSER (dialog->strat_chooser); text = gdict_strategy_chooser_get_current_strategy (strat_chooser); gdict_source_set_strategy (source, text); g_free (text); /* get the selected transport id */ transport = dialog->transport; switch (transport) { case GDICT_SOURCE_TRANSPORT_DICTD: host = get_text_from_entry (dialog, "hostname_entry"); port = get_text_from_entry (dialog, "port_entry"); gdict_source_set_transport (source, GDICT_SOURCE_TRANSPORT_DICTD, "hostname", host, "port", atoi (port), NULL); g_free (host); g_free (port); break; case GDICT_SOURCE_TRANSPORT_INVALID: default: g_warning ("Invalid transport"); return; } error = NULL; data = gdict_source_to_data (source, &length, &error); if (error) { gdict_show_gerror_dialog (GTK_WINDOW (dialog), _("Unable to create a source file"), error); g_object_unref (source); return; } name = g_strdup_printf ("%s.desktop", gdict_source_get_name (source)); filename = g_build_filename (g_get_user_config_dir (), "mate", "mate-dictionary", name, NULL); g_free (name); g_file_set_contents (filename, data, length, &error); if (error) gdict_show_gerror_dialog (GTK_WINDOW (dialog), _("Unable to save source file"), error); g_free (filename); g_free (data); g_object_unref (source); }
static GObject * gdict_database_chooser_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObjectClass *parent_class; GObject *object; GdictDatabaseChooser *chooser; GdictDatabaseChooserPrivate *priv; GtkWidget *sw; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkWidget *hbox; parent_class = G_OBJECT_CLASS (gdict_database_chooser_parent_class); object = parent_class->constructor (type, n_params, params); chooser = GDICT_DATABASE_CHOOSER (object); priv = chooser->priv; gtk_widget_push_composite_child (); sw = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_hexpand (sw, TRUE); gtk_widget_set_composite_name (sw, "gdict-database-chooser-scrolled-window"); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (chooser), sw, TRUE, TRUE, 0); gtk_widget_show (sw); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("databases", renderer, "text", DB_COLUMN_DESCRIPTION, "weight", DB_COLUMN_CURRENT, NULL); priv->treeview = gtk_tree_view_new (); gtk_widget_set_composite_name (priv->treeview, "gdict-database-chooser-treeview"); gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), GTK_TREE_MODEL (priv->store)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE); gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column); g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), "changed", G_CALLBACK (selection_changed_cb), chooser); g_signal_connect (priv->treeview, "row-activated", G_CALLBACK (row_activated_cb), chooser); gtk_container_add (GTK_CONTAINER (sw), priv->treeview); gtk_widget_show (priv->treeview); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); priv->buttons_box = hbox; priv->refresh_button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (priv->refresh_button), gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_SMALL_TOOLBAR)); g_signal_connect (priv->refresh_button, "clicked", G_CALLBACK (refresh_button_clicked_cb), chooser); gtk_box_pack_start (GTK_BOX (hbox), priv->refresh_button, FALSE, FALSE, 0); gtk_widget_show (priv->refresh_button); gtk_widget_set_tooltip_text (priv->refresh_button, _("Reload the list of available databases")); priv->clear_button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (priv->clear_button), gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_SMALL_TOOLBAR)); g_signal_connect (priv->clear_button, "clicked", G_CALLBACK (clear_button_clicked_cb), chooser); gtk_box_pack_start (GTK_BOX (hbox), priv->clear_button, FALSE, FALSE, 0); gtk_widget_show (priv->clear_button); gtk_widget_set_tooltip_text (priv->clear_button, _("Clear the list of available databases")); gtk_box_pack_end (GTK_BOX (chooser), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); gtk_widget_pop_composite_child (); return object; }