static int gw_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { //Declarations LwDictionary *dictionary; GwSearchWindow *window; GwDictionaryList *dictionarylist; GwApplicationPrivate *priv; gint argc; gchar **argv; gint position; //Initializations priv = GW_APPLICATION (application)->priv; dictionarylist = gw_application_get_installed_dictionarylist (GW_APPLICATION (application)); argv = NULL; if (command_line != NULL) { argv = g_application_command_line_get_arguments (command_line, &argc); gw_application_parse_args (GW_APPLICATION (application), &argc, &argv); } g_application_activate (G_APPLICATION (application)); window = gw_application_get_last_focused_searchwindow (GW_APPLICATION (application)); if (window == NULL) return 0; dictionary = lw_dictionarylist_get_dictionary_fuzzy (LW_DICTIONARYLIST (dictionarylist), priv->arg_dictionary); //Set the initial dictionary if (dictionary != NULL) { position = lw_dictionarylist_get_position (LW_DICTIONARYLIST (dictionarylist), dictionary); gw_searchwindow_set_dictionary (window, position); } //Set the initial query text if it was passed as an argument to the program if (priv->arg_query != NULL) { gw_searchwindow_entry_set_text (window, priv->arg_query); gw_searchwindow_search_cb (GTK_WIDGET (window), window); } //Cleanup if (argv != NULL) g_strfreev (argv); argv = NULL; return 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); }