]> sjero.net Git - linphone/blobdiff - gtk/main.c
fix warning in gtk app
[linphone] / gtk / main.c
index b31396b0857c233b6b5b43a9e86133db41b42e18..1aa2e287c5c2fc6931804ae1608cb48345cb797e 100644 (file)
@@ -63,12 +63,16 @@ static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl)
 static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg);
 static void linphone_gtk_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t enabled, const char *token);
 static void linphone_gtk_transfer_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate);
+void linphone_gtk_save_main_window_position(GtkWindow* mw, GdkEvent *event, gpointer data);
 static gboolean linphone_gtk_auto_answer(LinphoneCall *call);
 void linphone_gtk_status_icon_set_blinking(gboolean val);
 void _linphone_gtk_enable_video(gboolean val);
 
 
-
+#ifndef HAVE_GTK_OSX
+static gint main_window_x=0;
+static gint main_window_y=0;
+#endif
 static gboolean verbose=0;
 static gboolean auto_answer = 0;
 static gchar * addr_to_call = NULL;
@@ -216,7 +220,7 @@ static const char *linphone_gtk_get_factory_config_file(){
 }
 
 static void linphone_gtk_init_liblinphone(const char *config_file,
-               const char *factory_config_file) {
+               const char *factory_config_file, const char *db_file) {
        LinphoneCoreVTable vtable={0};
        gchar *secrets_file=linphone_gtk_get_config_file(SECRETS_FILE);
 
@@ -248,6 +252,7 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
                _linphone_gtk_enable_video(FALSE);
                linphone_gtk_set_ui_config_int("videoselfview",0);
        }
+       if (db_file) linphone_core_set_chat_database_path(the_core,db_file);
 }
 
 LinphoneCore *linphone_gtk_get_core(void){
@@ -563,7 +568,7 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){
                if (id!=0){
                        ms_message("Updating window decorations");
 #ifndef WIN32
-                       w=gdk_window_foreign_new(id);
+                       w=gdk_window_foreign_new((GdkNativeWindow)id);
 #else
                        w=gdk_window_foreign_new((HANDLE)id);
 #endif
@@ -582,7 +587,7 @@ static gboolean linphone_gtk_iterate(LinphoneCore *lc){
                if (id!=0){
                        ms_message("Updating window decorations for preview");
 #ifndef WIN32
-                       w=gdk_window_foreign_new(id);
+                       w=gdk_window_foreign_new((GdkNativeWindow)id);
 #else
                        w=gdk_window_foreign_new((HANDLE)id);
 #endif
@@ -1227,10 +1232,10 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call
                break;
                case LinphoneCallPausing:
                        linphone_gtk_enable_hold_button(call,TRUE,FALSE);
-                       update_tab_header(call,FALSE);
+                       linphone_gtk_call_update_tab_header(call,FALSE);
                case LinphoneCallPausedByRemote:
                        linphone_gtk_in_call_view_set_paused(call);
-                       update_tab_header(call,TRUE);
+                       linphone_gtk_call_update_tab_header(call,TRUE);
                break;
                case LinphoneCallConnected:
                        linphone_gtk_enable_hold_button (call,TRUE,TRUE);
@@ -1370,11 +1375,20 @@ static GtkWidget *create_icon_menu(){
        return menu;
 }
 
+void linphone_gtk_save_main_window_position(GtkWindow* mw, GdkEvent *event, gpointer data){
+       gtk_window_get_position(GTK_WINDOW(mw), &main_window_x, &main_window_y); 
+}
+
 static void handle_icon_click() {
        GtkWidget *mw=linphone_gtk_get_main_window();
        if (!gtk_window_is_active((GtkWindow*)mw)) {
+               if(!gtk_widget_is_drawable(mw)){ 
+                       //we only move if window was hidden. If it was simply behind the window stack, ie, drawable, we keep it as it was
+                       gtk_window_move (GTK_WINDOW(mw), main_window_x, main_window_y);
+               }
                linphone_gtk_show_main_window();
        } else {
+               linphone_gtk_save_main_window_position((GtkWindow*)mw, NULL, NULL);
                gtk_widget_hide(mw);
        }
 }
@@ -1556,10 +1570,6 @@ static void linphone_gtk_configure_main_window(){
        static gboolean buttons_have_borders;
        static gboolean show_abcd;
        GtkWidget *w=linphone_gtk_get_main_window();
-       GHashTable *contacts_history;
-
-       contacts_history=g_hash_table_new_full(g_str_hash, g_str_equal,g_free, NULL);
-       g_object_set_data(G_OBJECT(w),"history",(gpointer)contacts_history);
 
        if (!config_loaded){
                title=linphone_gtk_get_ui_config("title","Linphone");
@@ -1716,6 +1726,7 @@ static void linphone_gtk_init_main_window(){
        linphone_gtk_load_identities();
        linphone_gtk_set_my_presence(linphone_core_get_presence_info(linphone_gtk_get_core()));
        linphone_gtk_show_friends();
+       linphone_core_reset_missed_calls_count(linphone_gtk_get_core());
        main_window=linphone_gtk_get_main_window();
        linphone_gtk_call_log_update(main_window);
 
@@ -1738,7 +1749,6 @@ static void linphone_gtk_init_main_window(){
        linphone_gtk_check_menu_items();
 }
 
-
 void linphone_gtk_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
        if (verbose){
                const char *lname="undef";
@@ -1844,6 +1854,7 @@ int main(int argc, char *argv[]){
        GdkPixbuf *pbuf;
        const char *app_name="Linphone";
        LpConfig *factory;
+       const char *db_file;
 
 #if !GLIB_CHECK_VERSION(2, 31, 0)
        g_thread_init(NULL);
@@ -1950,7 +1961,8 @@ int main(int argc, char *argv[]){
        linphone_gtk_create_log_window();
        linphone_core_enable_logs_with_cb(linphone_gtk_log_handler);
 
-       linphone_gtk_init_liblinphone(config_file, factory_config_file);
+       db_file=linphone_gtk_message_storage_get_db_file(NULL);
+       linphone_gtk_init_liblinphone(config_file, factory_config_file, db_file);
 
        g_set_application_name(app_name);
        pbuf=create_pixbuf(linphone_gtk_get_ui_config("icon",LINPHONE_ICON));