static void status_icon_set_visibility (EmpathyStatusIcon *icon, gboolean visible, gboolean store) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (store) { empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); } if (!visible) { empathy_window_iconify (priv->window, priv->icon); } else { GList *accounts; empathy_window_present (GTK_WINDOW (priv->window), TRUE); /* Show the accounts dialog if there is no enabled accounts */ accounts = mc_accounts_list_by_enabled (TRUE); if (accounts) { mc_accounts_list_free (accounts); } else { DEBUG ("No enabled account, Showing account dialog"); empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL); } } }
static void status_icon_set_visibility (EmpathyStatusIcon *icon, gboolean visible, gboolean store) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (store) { empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); } if (!visible) { empathy_window_iconify (priv->window, priv->icon); } else { GList *accounts; GList *l; gboolean one_enabled = FALSE; empathy_window_present (GTK_WINDOW (priv->window), TRUE); /* Show the accounts dialog if there is no enabled accounts */ accounts = empathy_account_manager_dup_accounts (priv->account_manager); for (l = accounts ; l != NULL ; l = g_list_next (l)) { one_enabled = empathy_account_is_enabled (EMPATHY_ACCOUNT (l->data)) || one_enabled; g_object_unref (l->data); } g_list_free (accounts); if (!one_enabled) { DEBUG ("No enabled account, Showing account dialog"); empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL); } } }
int main (int argc, char *argv[]) { GtkWidget *dialog; gtk_init (&argc, &argv); if (g_getenv ("EMPATHY_TIMING") != NULL) { g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL); } empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG")); tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE")); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), PKGDATADIR G_DIR_SEPARATOR_S "icons"); dialog = empathy_accounts_dialog_show (NULL); g_signal_connect (dialog, "destroy", G_CALLBACK (destroy_cb), NULL); gtk_main (); return EXIT_SUCCESS; }
static void do_show_accounts_ui (GtkWindow *window, TpAccountManager *manager) { GtkWidget *ui; if (has_non_salut_accounts (manager)) ui = empathy_accounts_dialog_show (window, NULL); else ui = empathy_account_assistant_show (window); if (account_dialog_only) g_signal_connect (ui, "destroy", G_CALLBACK (gtk_main_quit), NULL); }
/* The code that handles single-instance and startup notification is * copied from gedit. * * Copyright (C) 2005 - Paolo Maggi */ static void on_bacon_message_received (const char *message, gpointer data) { GtkWidget *window = data; guint32 startup_timestamp; g_return_if_fail (message != NULL); DEBUG ("Other instance launched, presenting the main window. message='%s'", message); if (strcmp (message, "accounts") == 0) { /* accounts dialog requested */ empathy_accounts_dialog_show (GTK_WINDOW (window), NULL); } else { startup_timestamp = atoi (message); /* Set the proper interaction time on the window. * Fall back to roundtripping to the X server when we * don't have the timestamp, e.g. when launched from * terminal. We also need to make sure that the window * has been realized otherwise it will not work. lame. */ if (startup_timestamp == 0) { /* Work if launched from the terminal */ DEBUG ("Using X server timestamp as a fallback"); if (!GTK_WIDGET_REALIZED (window)) { gtk_widget_realize (GTK_WIDGET (window)); } startup_timestamp = gdk_x11_get_server_time (window->window); } gtk_window_present_with_time (GTK_WINDOW (window), startup_timestamp); } }
int main (int argc, char *argv[]) { guint32 startup_timestamp; EmpathyStatusIcon *icon; EmpathyDispatcher *dispatcher; EmpathyChatroomManager *chatroom_manager; EmpathyCallFactory *call_factory; GtkWidget *window; MissionControl *mc; EmpathyIdle *idle; gboolean autoconnect = TRUE; gboolean no_connect = FALSE; gboolean hide_contact_list = FALSE; gboolean accounts_dialog = FALSE; GError *error = NULL; GOptionEntry options[] = { { "no-connect", 'n', 0, G_OPTION_ARG_NONE, &no_connect, N_("Don't connect on startup"), NULL }, { "hide-contact-list", 'h', 0, G_OPTION_ARG_NONE, &hide_contact_list, N_("Don't show the contact list on startup"), NULL }, { "accounts", 'a', 0, G_OPTION_ARG_NONE, &accounts_dialog, N_("Show the accounts dialog"), NULL }, { "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb, NULL, NULL }, { NULL } }; /* Init */ g_thread_init (NULL); empathy_init (); if (!gtk_init_with_args (&argc, &argv, N_("- Empathy Instant Messenger"), options, GETTEXT_PACKAGE, &error)) { g_warning ("Error in empathy init: %s", error->message); return EXIT_FAILURE; } empathy_gtk_init (); g_set_application_name (_(PACKAGE_NAME)); gst_init (&argc, &argv); gtk_window_set_default_icon_name ("empathy"); textdomain (GETTEXT_PACKAGE); /* Setting up the bacon connection */ startup_timestamp = get_startup_timestamp (); connection = bacon_message_connection_new ("empathy"); if (connection != NULL) { if (!bacon_message_connection_get_is_server (connection)) { gchar *message; if (accounts_dialog) { DEBUG ("Showing accounts dialog from existing Empathy instance"); message = g_strdup ("accounts"); } else { DEBUG ("Activating existing instance"); message = g_strdup_printf ("%" G_GUINT32_FORMAT, startup_timestamp); } bacon_message_connection_send (connection, message); /* We never popup a window, so tell startup-notification * that we are done. */ gdk_notify_startup_complete (); g_free (message); bacon_message_connection_free (connection); return EXIT_SUCCESS; } } else { g_warning ("Cannot create the 'empathy' bacon connection."); } /* Setting up MC */ mc = empathy_mission_control_dup_singleton (); g_signal_connect (mc, "ServiceEnded", G_CALLBACK (service_ended_cb), NULL); g_signal_connect (mc, "Error", G_CALLBACK (operation_error_cb), NULL); if (accounts_dialog) { GtkWidget *dialog; dialog = empathy_accounts_dialog_show (NULL, NULL); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_main (); return 0; } /* Setting up Idle */ idle = empathy_idle_dup_singleton (); empathy_idle_set_auto_away (idle, TRUE); use_nm_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_NM, idle); empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_NM, use_nm_notify_cb, idle); /* Autoconnect */ empathy_conf_get_bool (empathy_conf_get(), EMPATHY_PREFS_AUTOCONNECT, &autoconnect); if (autoconnect && ! no_connect && empathy_idle_get_state (idle) <= MC_PRESENCE_OFFLINE) { empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE); } create_salut_account (); /* Setting up UI */ window = empathy_main_window_show (); icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list); if (connection) { /* We se the callback here because we need window */ bacon_message_connection_set_callback (connection, on_bacon_message_received, window); } /* Handle channels */ dispatcher = empathy_dispatcher_dup_singleton (); g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL); chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL); empathy_chatroom_manager_observe (chatroom_manager, dispatcher); notify_init (_(PACKAGE_NAME)); /* Create the call factory */ call_factory = empathy_call_factory_initialise (); g_signal_connect (G_OBJECT (call_factory), "new-call-handler", G_CALLBACK (new_call_handler_cb), NULL); gtk_main (); empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE); g_object_unref (mc); g_object_unref (idle); g_object_unref (icon); g_object_unref (dispatcher); g_object_unref (chatroom_manager); notify_uninit (); return EXIT_SUCCESS; }