src/gui/src/ws_gui.c

Go to the documentation of this file.
00001 /*******************************************************************************
00002 This file is part of mdictionary.
00003 
00004 mdictionary is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 mdictionary is distributed in the hope that it will be useful, 
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License 
00015 along with mdictionary; if not, write to the Free Software
00016 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00017 
00018 Copyright 2006 ComArch S.A.
00019 *******************************************************************************/
00032 #include <ws_gui.h>
00033 #include <ws_gui_callbacks.h>
00034 #include <ws_gui_layout.h>
00035 
00036 //int ws_gui_init(int argc, char *argv[])
00037 int main(int argc, char *argv[])
00038 {
00039         
00040         
00041         gtk_init(&argc, &argv);
00042 
00043         //localization
00044         setlocale(LC_ALL, "");
00045         bindtextdomain(PACKAGE, LOCALEDIR);
00046         bind_textdomain_codeset(PACKAGE, "UTF-8");
00047         textdomain(PACKAGE);
00048 
00049         if (strcmp(_("ws_check"), "ws_check") == 0)
00050         {
00051                 setlocale(LC_ALL, "en_GB");
00052                 bindtextdomain(PACKAGE, LOCALEDIR);
00053                 bind_textdomain_codeset(PACKAGE, "UTF-8");
00054                 textdomain(PACKAGE);
00055         }
00056 
00057 
00058         WSGuiApp *ws_gui_app;
00059         ws_gui_app = (WSGuiApp*)g_malloc(sizeof(WSGuiApp)); 
00060 
00061         /*memory allocation*/
00062         ws_gui_app->ws_gui_w_list = 
00063                 (struct WSGuiList*)g_malloc(sizeof(struct WSGuiList));
00064         ws_gui_app->ws_gui_menu = 
00065                 (struct WSGuiMenu*)g_malloc(sizeof(struct WSGuiMenu));
00066 
00067         /*gconf*/
00068         ws_gui_app->client = gconf_client_get_default();
00069 
00070         ws_gui_create_window(ws_gui_app);
00071         ws_gui_read_adjustment(ws_gui_app);
00072 
00073 
00074         /*dbus wrapper*/
00075         ws_gui_app->dbus_data = ws_dbus_create ("mdictionaryGui", "v1.0");
00076 
00077         /*dbus wrapper configuration*/
00078         ws_dbus_config (ws_gui_app->dbus_data, 
00079                         WS_DBUS_CONFIG_SERVICE,
00080                         GUI_SERVICE);
00081         ws_dbus_config (ws_gui_app->dbus_data,
00082                         WS_DBUS_CONFIG_OBJECT,
00083                         GUI_OBJECT);
00084         ws_dbus_config (ws_gui_app->dbus_data,
00085                         WS_DBUS_CONFIG_IFACE,
00086                         GUI_IFACE);
00087         ws_dbus_config (ws_gui_app->dbus_data,
00088                         WS_DBUS_CONFIG_REMOTE_SERVICE,
00089                         MANAGER_SERVICE);
00090         ws_dbus_config (ws_gui_app->dbus_data,
00091                         WS_DBUS_CONFIG_REMOTE_OBJECT,
00092                         MANAGER_OBJECT);
00093         ws_dbus_config (ws_gui_app->dbus_data,
00094                         WS_DBUS_CONFIG_REMOTE_IFACE,
00095                         MANAGER_IFACE);
00096 
00097         //Add a list of remote methods available
00098         ws_dbus_add_method (ws_gui_app->dbus_data,
00099                         "return_words",
00100                         WS_DBUS_TYPE_GARRAY,
00101                         WS_DBUS_TYPE_INVALID);
00102                         
00103         ws_dbus_add_method (ws_gui_app->dbus_data,
00104                         "return_translations",
00105                         WS_DBUS_TYPE_STRING,
00106                         WS_DBUS_TYPE_INVALID);
00107 
00108         ws_dbus_add_method (ws_gui_app->dbus_data,
00109                         "return_extracted_dict",
00110                         WS_DBUS_TYPE_STRING,
00111                         WS_DBUS_TYPE_INVALID);
00112 
00113         ws_dbus_add_method (ws_gui_app->dbus_data,
00114                         "update_progressbar",
00115                         WS_DBUS_TYPE_DOUBLE,
00116                         WS_DBUS_TYPE_INVALID);
00117 
00118         ws_dbus_add_method (ws_gui_app->dbus_data,
00119                         "signal",
00120                         WS_DBUS_TYPE_SIGNAL,
00121                         WS_DBUS_TYPE_INVALID);
00122 
00123         ws_dbus_add_method (ws_gui_app->dbus_data,
00124                         "search_home_applet",
00125                         WS_DBUS_TYPE_STRING,
00126                         WS_DBUS_TYPE_INVALID);
00127 
00128         //setting callbacks for local methods
00129         ws_dbus_set_cb (ws_gui_app->dbus_data,
00130                         "return_words",
00131                         ws_gui_dbus_return_words,
00132                         ws_gui_app);
00133 
00134         ws_dbus_set_cb (ws_gui_app->dbus_data,
00135                         "return_translations",
00136                         ws_gui_dbus_return_translation,
00137                         ws_gui_app);
00138         ws_dbus_set_cb (ws_gui_app->dbus_data,
00139                         "return_extracted_dict",
00140                         ws_dbus_server_return_extracted_bzip,
00141                         ws_gui_app);
00142         ws_dbus_set_cb (ws_gui_app->dbus_data,
00143                         "update_progressbar",
00144                         ws_dbus_progress_bar,
00145                         ws_gui_app);
00146         ws_dbus_set_cb (ws_gui_app->dbus_data,
00147                         "signal",
00148                         ws_gui_signal_hander,
00149                         ws_gui_app);
00150         /*hisa*/
00151         ws_dbus_set_cb (ws_gui_app->dbus_data,
00152                         "search_home_applet",
00153                         ws_gui_search_home_handler,
00154                         ws_gui_app);
00155 
00156         ws_dbus_connect (ws_gui_app->dbus_data);
00157 
00158         /*setting the clipboard*/
00159         ws_gui_app->ws_gui_clipboard = 
00160                 gtk_widget_get_clipboard (GTK_WIDGET(ws_gui_app->ws_gui_html),
00161                                         GDK_SELECTION_CLIPBOARD);
00162 
00163         /*connecting the signals*/
00164         g_signal_connect(G_OBJECT (ws_gui_app->ws_gui_w_list->ws_gui_view),
00165                         "cursor-changed",
00166                         G_CALLBACK (ws_gui_view_cursor_changed), 
00167                         ws_gui_app);
00168 
00169 
00170         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_window),
00171                         "key-press-event",
00172                         G_CALLBACK(hildon_key_press_listener),
00173                         ws_gui_app);
00174         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_html),
00175                         "button-press-event",
00176                         G_CALLBACK(ws_gui_button_press),
00177                         ws_gui_app);
00178         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_html),
00179                         "button-release-event",
00180                         G_CALLBACK(ws_gui_button_release),
00181                         ws_gui_app);
00182         
00183         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_list_eventbox),
00184                         "button-press-event",
00185                         G_CALLBACK(ws_gui_list_full_dialog),
00186                         ws_gui_app);
00187         g_signal_connect(G_OBJECT(ws_gui_app->ws_gui_hildon_window),
00188                         "delete-event",
00189                         G_CALLBACK(ws_gui_on_exit),
00190                         ws_gui_app);
00191 
00192         ws_dbus_notify(ws_gui_app->dbus_data,
00193                 WS_DBUS_ERROR_UNKNOWN);
00194 
00195         gtk_main();
00196         
00197         return 0;
00198 }
00199 

Generated on Fri Jan 11 14:30:17 2008 for mDictionary Project by  doxygen 1.5.1