BINARIES = bin
MAIN_BINARIES = ../../bin
-${EXECUTABLE}: ${BINARIES}/ws_gui.o ${BINARIES}/ws_gui_callbacks.o ${BINARIES}/ws_gui_layout.o ${MAIN_BINARIES}/ws_dbus.o
- ${CC} ${DEBUG} -o ${BINARIES}/${EXECUTABLE} ${BINARIES}/ws_gui.o ${BINARIES}/ws_gui_callbacks.o ${BINARIES}/ws_gui_layout.o ${MAIN_BINARIES}/ws_dbus.o ${LIBS} ${CFLAGS} ${DEFINES}
+${EXECUTABLE}: ${BINARIES}/ws_gui.o ${BINARIES}/ws_gui_callbacks.o ${BINARIES}/ws_gui_layout.o ${BINARIES}/ws_gui_utils.o ${MAIN_BINARIES}/ws_dbus.o
+ ${CC} ${DEBUG} -o ${BINARIES}/${EXECUTABLE} ${BINARIES}/ws_gui.o ${BINARIES}/ws_gui_callbacks.o ${BINARIES}/ws_gui_layout.o ${BINARIES}/ws_gui_utils.o ${MAIN_BINARIES}/ws_dbus.o ${LIBS} ${CFLAGS} ${DEFINES}
@cp ${BINARIES}/${EXECUTABLE} ${MAIN_BINARIES}
${BINARIES}/ws_gui.o: ${SOURCES}/ws_gui.c ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
${CC} ${DEBUG} -c ${SOURCES}/ws_gui.c -o ${BINARIES}/ws_gui.o ${CFLAGS} ${DEFINES}
-${BINARIES}/ws_gui_callbacks.o: ${SOURCES}/ws_gui_callbacks.c ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
+${BINARIES}/ws_gui_callbacks.o: ${SOURCES}/ws_gui_callbacks.c ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_GUI}/ws_gui_utils.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
${CC} ${DEBUG} -c ${SOURCES}/ws_gui_callbacks.c -o ${BINARIES}/ws_gui_callbacks.o ${CFLAGS} ${DEFINES}
${BINARIES}/ws_gui_layout.o: ${SOURCES}/ws_gui_layout.c ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
${CC} ${DEBUG} -DWS_VERSION=\"${APP_VER}\" -c ${SOURCES}/ws_gui_layout.c -o ${BINARIES}/ws_gui_layout.o ${CFLAGS} ${DEFINES}
+${BINARIES}/ws_gui_utils.o: ${SOURCES}/ws_gui_utils.c ${INCLUDE_GUI}/ws_gui_utils.h
+ ${CC} ${DEBUG} -DWS_VERSION=\"${APP_VER}\" -c ${SOURCES}/ws_gui_utils.c -o ${BINARIES}/ws_gui_utils.o ${CFLAGS} ${DEFINES}
+
${MAIN_BINARIES}/ws_dbus.o:
cd ../dbus_wrapper && make
dyn:
- ${BINARIES}/wsl_gui.o ${BINARIES}/wsl_gui_callbacks.o ${BINARIES}/wsl_gui_layout.o
- @{CC} ${DEBUG} -shared -fPIC -o ${EXECUTABLE}.so ${BINARIES}/wsl_gui.o ${BINARIES}/wsl_gui_callbacks.o ${BINARIES}/wsl_gui_layout.o dbus/ws_dbus.o ${LIBS} ${CFLAGS} ${DEFINES}
+ ${BINARIES}/wsl_gui.o ${BINARIES}/wsl_gui_callbacks.o ${BINARIES}/wsl_gui_layout.o ${BINARIES}/wsl_gui_utils.o
+ @{CC} ${DEBUG} -shared -fPIC -o ${EXECUTABLE}.so ${BINARIES}/wsl_gui.o ${BINARIES}/wsl_gui_callbacks.o ${BINARIES}/wsl_gui_layout.o ${BINARIES}/wsl_gui_utils.o dbus/ws_dbus.o ${LIBS} ${CFLAGS} ${DEFINES}
${BINARIES}/wsl_gui.o: ${SOURCES}/ws_gui.c ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_GUI}/ws_gui_callbacks.h ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
@{CC} ${DEBUG} -fPIC -c ${SOURCES}/ws_gui.c -o ${BINARIES}/wsl_gui.o ${CFLAGS} ${DEFINES}
${BINARIES}/wsl_gui_layout.o: ${SOURCES}/ws_gui_layout.c ${INCLUDE_GUI}/ws_gui_layout.h ${INCLUDE_GUI}/ws_gui.h ${INCLUDE_DBUS_WRAPPER}/ws_dbus.h
@{CC} ${DEBUG} -fPIC -c ${SOURCES}/ws_gui_layout.c -o ${BINARIES}/wsl_gui_layout.o ${CFLAGS} ${DEFINES}
+${BINARIES}/wsl_gui_utils.o: ${SOURCES}/ws_gui_utils.c ${INCLUDE_GUI}/ws_gui_utils.h
+ @{CC} ${DEBUG} -fPIC -c ${SOURCES}/ws_gui_utils.c -o ${BINARIES}/wsl_gui_utils.o ${CFLAGS} ${DEFINES}
clean:
rm -f ${BINARIES}/*
#include <ws_gui_callbacks.h>
#include <ws_gui.h>
#include <ws_gui_layout.h>
+#include <ws_gui_utils.h>
#include <ws_dbus.h>
/** \brief show how much time did take a callback of another function
WSGuiApp *data = (WSGuiApp*) user_data;
osso_rpc_t* osso_data = NULL;
- //get the word passed by dbus
+ /*get the word passed by dbus*/
osso_data = &g_array_index (word, osso_rpc_t, 0);
- //free memory used by last searched word
+ /*free memory used by last searched word*/
gchar* tmp = NULL;
tmp = g_strdup(osso_data->value.s + 11);
+
+ /* check for special characters in text starting with % */
+ ws_gui_word_conversion( osso_data );
g_object_set(G_OBJECT(data->ws_gui_hildon_find_toolbar),
"prefix",
*/
void ws_gui_clear_list (GtkListStore* list, gpointer user_data)
{
- //WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
GtkTreeIter iter;
gboolean tmp;
- //g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n\nws_gui_clear_list\n\n");
tmp = gtk_tree_model_get_iter_first(
GTK_TREE_MODEL(list),
&iter);
while (tmp == TRUE)
{
- // g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "\n\nws_gui_clear_list2\n\n");
tmp = gtk_list_store_remove(list, &iter);
}
g_array_append_val(tmp, tmp_word);
}
- //g_assert(ws_gui_app->ws_gui_banner_list_searching);
- //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_banner_list_searching));
-
ws_gui_app->loading = FALSE;
ws_gui_set_toolbar_avail(ws_gui_app);
- //ws_gui_app->ws_gui_banner_flag = FALSE;
-
- //ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store);
-
-
ws_gui_app->ws_gui_w_list->ws_gui_model =
create_and_fill_model(tmp, ws_gui_app);
ws_gui_app->html_flag = TRUE;
g_value_unset (&value);
}
-
-
-/* g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Dlugosc tempa to: %d", tmp->len);
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "w tempie mamy: %s", tmp_word);*/
- //if (&& ws_gui_app->stop_clicked != TRUE )
-
+
if ((tmp->len == 0 || tmp_word == NULL) && ws_gui_app->stop_clicked != TRUE )
{
hildon_banner_show_information(GTK_WIDGET(
NULL,
_("ws_ni_no_words_found"));
- //ws_gui_fill_html(" ", ws_gui_app);
- //ws_gui_app->html_flag = FALSE;
if (ws_gui_app->dictionary_selection_changed == TRUE)
{
ws_gui_clear_list(ws_gui_app->ws_gui_w_list->ws_gui_store, ws_gui_app);
g_free(html_content);
ws_gui_app->html_flag = TRUE;
- //gtk_widget_hide(ws_gui_app->ws_gui_banner_translation_loading);
ws_gui_app->loading = FALSE;
ws_gui_set_toolbar_avail(ws_gui_app);
gchar *tmp = g_array_index(ws_gui_app->ws_gui_history,
gchar*,
i);
- //tmp_iter = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL(ws_gui_app->ws_gui_w_list->ws_gui_model), &ws_gui_app->ws_gui_w_list->ws_gui_iter);
if (previous_word != NULL &&
strcmp(previous_word, new_word) != 0)
ws_gui_app->ws_gui_history_cur_pos =
ws_gui_app->ws_gui_history_cur_pos - 1;
- //set object's property
+ /*set object's property*/
g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
"prefix",
(g_array_index(ws_gui_app->ws_gui_history_list,
gchar*,
ws_gui_app->ws_gui_history_cur_pos))
);
- //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
- //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
ws_gui_app->loading = TRUE;
ws_gui_set_toolbar_avail(ws_gui_app);
}
ws_gui_app->ws_gui_history_cur_pos + 1;
- //set object's property
+ /*set object's property*/
g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
"prefix",
(g_array_index(ws_gui_app->ws_gui_history_list,
ws_gui_app->ws_gui_history_cur_pos))
);
- //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
- //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
ws_gui_app->loading = TRUE;
ws_gui_set_toolbar_avail(ws_gui_app);
}
else
{
- //make forward button inactive
+ /*make forward button inactive*/
gtk_widget_set_sensitive(
GTK_WIDGET(ws_gui_app->ws_gui_toobar_button_forward),
FALSE);
- //make find next button inactive
+ /*make find next button inactive*/
gtk_widget_set_sensitive(
GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_find_next),
FALSE);
if (ws_gui_app->history_flag == FALSE && tmp != NULL)
{
- //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
ws_dbus_client_find_translation(ws_gui_app->dbus_data, tmp);
ws_gui_history_add(tmp, ws_gui_app);
g_strstrip(temp);
if (temp != NULL || strcmp(temp, " "))
{
- //set object's property
+ /*set object's property*/
g_object_set(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
"prefix",
temp,
NULL);
ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
- //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
}
else
{
ws_gui_app->stop_clicked = FALSE;
-// if (ws_gui_app->ws_gui_banner_flag == FALSE)
- //{
gchar* ws_gui_text = NULL;
g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
"prefix",
g_strstrip(ws_gui_text);
if (strlen(ws_gui_text) != 0)
{
- //gtk_widget_show(ws_gui_app->ws_gui_banner_list_searching);
-
ws_gui_app->loading = TRUE;
ws_gui_set_toolbar_avail(ws_gui_app);
-
- //ws_gui_app->ws_gui_banner_flag = TRUE;
- //ws_gui_fill_html(" ", ws_gui_app);
- //ws_gui_app->html_flag = FALSE;
ws_dbus_client_find_word (ws_gui_app->dbus_data, ws_gui_text);
- //gtk_widget_hide(GTK_WIDGET(ws_gui_app->ws_gui_list_hbox));
g_free(ws_gui_text);
}
}
g_free(ws_gui_app->last_word);
ws_gui_app->last_word=NULL;
- //}
}
/** stop search process
gtk_html_set_editable (GTK_HTML(ws_gui_app->ws_gui_html), FALSE);
- //Load welcome screen or translation string
+ /*Load welcome screen or translation string*/
if (ws_gui_app->first_run == TRUE && ws_gui_app->bookmark_mode==FALSE)
{
gtk_html_load_from_string(GTK_HTML(ws_gui_app->ws_gui_html),
&temp,
NULL);
ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
- //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
}
else
}
}
- //setting sensitivity of components
+ /*setting sensitivity of components*/
gtk_widget_set_sensitive(
GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark),
FALSE);
}
}
- //setting sensitivity of components
+ /*setting sensitivity of components*/
gtk_widget_set_sensitive(
GTK_WIDGET(ws_gui_app->ws_gui_menu->ws_gui_menu_open_bookmark),
TRUE);
-1);
if (string != NULL)
{
- //gtk_widget_show(ws_gui_app->ws_gui_banner_translation_loading);
ws_gui_app->loading = TRUE;
ws_gui_set_toolbar_avail(ws_gui_app);
WSGuiApp* ws_gui_app=(WSGuiApp*)user_data;
- //refreshing the words list and translation pane
+ /*efreshing the words list and translation pane*/
gchar *temp;
g_object_get(G_OBJECT(ws_gui_app->ws_gui_hildon_find_toolbar),
"prefix",
{
ws_dbus_client_find_word (ws_gui_app->dbus_data, temp);
}
- //gtk_widget_hide(ws_gui_app->ws_gui_list_hbox);
- //-----------------------------------------------
}
/*@}*/
--- /dev/null
+/*******************************************************************************
+This file is part of mdictionary.
+
+mdictionary is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+mdictionary is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with mdictionary; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Copyright 2006 ComArch S.A.
+*******************************************************************************/
+/** \addtogroup GUI
+ */
+/*@{*/
+/** \file ws_gui_utils.c
+ * \brief File with functions used in GUI.
+ *
+ * Functions used in GUI like hex conversion etc.
+ * \author Marcin Biedron \<marcin.biedron\@comarch.com\>
+ * \date 18-01-2008
+ * \version 1.0.0
+ */
+
+#include <ws_gui_callbacks.h>
+#include <ws_gui.h>
+#include <ws_gui_layout.h>
+#include <ws_gui_utils.h>
+#include <ws_dbus.h>
+
+/**
+ * Function that checks if given char is hex.
+ * \param tchar char that is being checked
+ */
+gboolean ws_gui_is_hex ( char tchar )
+{
+ if ( (( 'a' <= tchar ) && ( tchar <= 'f')) ||
+ (( 'A' <= tchar ) && ( tchar <= 'F')) ||
+ (( '0' <= tchar ) && ( tchar <= '9')))
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+/**
+ * Function that changes all hex characters into asci code.
+ * \param word word to search
+ * \param user_data user data passed to function
+ */
+void ws_gui_word_conversion( osso_rpc_t* osso_data )
+{
+
+ /* Looking for '%' char */
+ char* pch = strchr(osso_data->value.s, '%');
+ while ( pch != NULL )
+ {
+ g_debug( "[L-word] -> %s: Found percentage character in string...", __FUNCTION__ );
+ /* Check if it is a hexdecimal number */
+ if (( ( pch+1 != NULL ) && ( pch+2 != NULL ) ) &&
+ ( ws_gui_is_hex ( pch[1] ) && ws_gui_is_hex ( pch[2] )))
+ {
+ char convertedWord[strlen(osso_data->value.s)];
+ char tempLetterHex[2];
+ char tempLetterASCI;
+ int tempLetterInteger;
+ tempLetterHex[0] = pch[1];
+ tempLetterHex[1] = pch[2];
+ int sscanfReturn = 0;
+ sscanfReturn = sscanf(tempLetterHex, "%x", &tempLetterInteger);
+ if (sscanfReturn == 1)
+ {
+ tempLetterASCI = (char)(tempLetterInteger);
+ int actualChar = pch - osso_data->value.s;
+ int stringLength = strlen(osso_data->value.s);
+ int i = 0;
+ for ( i = 0; i < stringLength; i++)
+ {
+ if (i < actualChar) { convertedWord[i] = osso_data->value.s[i]; }
+ if (i == actualChar) { convertedWord[ i ] = tempLetterASCI; }
+ if (i > actualChar) { convertedWord[i] = osso_data->value.s[ i + 2 ]; }
+ }
+ }
+ strcpy(osso_data->value.s, convertedWord);
+ }
+ pch = strchr( pch + 1, '%' );
+ }
+
+ /* Looking for '+' char */
+ pch = strchr(osso_data->value.s, '+');
+ while ( pch != NULL )
+ {
+ g_debug( "[L-word] -> %s: Found plus character in string...", __FUNCTION__ );
+ pch[0] = ' ';
+ pch = strchr( pch + 1, '+' );
+ }
+}
+
+//end of file