Example #1
0
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);
		}
	}
}
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);
        }
    }
}
Example #3
0
static void
preferences_languages_save (EmpathyPreferences *preferences)
{
	GtkTreeView       *view;
	GtkTreeModel      *model;

	gchar             *languages = NULL;

	view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
	model = gtk_tree_view_get_model (view);

	gtk_tree_model_foreach (model,
				(GtkTreeModelForeachFunc) preferences_languages_save_foreach,
				&languages);

	/* if user selects no languages, we don't want spell check */
	empathy_conf_set_bool (empathy_conf_get (),
			       EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
			       languages != NULL);

	empathy_conf_set_string (empathy_conf_get (),
				 EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
				 languages ? languages : "");

	g_free (languages);
}
static void
preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
				   char *path_string,
				   EmpathyPreferences *preferences)
{
	GtkTreePath *path;
	gboolean toggled, instore;
	GtkTreeIter iter;
	GtkTreeView *view;
	GtkTreeModel *model;
	char *key;

	view = GTK_TREE_VIEW (preferences->treeview_sounds);
	model = gtk_tree_view_get_model (view);

	path = gtk_tree_path_new_from_string (path_string);
	toggled = gtk_cell_renderer_toggle_get_active (toggle);

	gtk_tree_model_get_iter (model, &iter, path);
	gtk_tree_model_get (model, &iter, COL_SOUND_KEY, &key,
			    COL_SOUND_ENABLED, &instore, -1);

	instore ^= 1;

	gtk_list_store_set (GTK_LIST_STORE (model), &iter,
			    COL_SOUND_ENABLED, instore, -1);

	empathy_conf_set_bool (empathy_conf_get (), key, instore);

	gtk_tree_path_free (path);
}
Example #5
0
static void
preferences_toggle_button_toggled_cb (GtkWidget *button,
				      gpointer   user_data)
{
	const gchar *key;

	key = g_object_get_data (G_OBJECT (button), "key");

	empathy_conf_set_bool (empathy_conf_get (),
			       key,
			       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
}
Example #6
0
static void
main_window_view_contacts_list_size_cb (GtkRadioAction    *action,
					GtkRadioAction    *current,
					EmpathyMainWindow *window)
{
	gint     value;

	value = gtk_radio_action_get_current_value (action);

	empathy_conf_set_bool (empathy_conf_get (),
			       EMPATHY_PREFS_UI_SHOW_AVATARS,
			       value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
	empathy_conf_set_bool (empathy_conf_get (),
			       EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
			       value == CONTACT_LIST_COMPACT_SIZE);

	empathy_contact_list_store_set_show_avatars (window->list_store,
						     value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
	empathy_contact_list_store_set_is_compact (window->list_store,
						   value == CONTACT_LIST_COMPACT_SIZE);
}
Example #7
0
static void
main_window_view_show_protocols_cb (GtkToggleAction *action,
					EmpathyMainWindow *window)
{
	gboolean value;

	value = gtk_toggle_action_get_active (action);

	empathy_conf_set_bool (empathy_conf_get (),
					 EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
					 value == TRUE);
	empathy_contact_list_store_set_show_protocols (window->list_store,
					 value == TRUE);
}
Example #8
0
static void
main_window_view_show_offline_cb (GtkToggleAction   *action,
				  EmpathyMainWindow *window)
{
	gboolean current;

	current = gtk_toggle_action_get_active (action);
	empathy_conf_set_bool (empathy_conf_get (),
			      EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
			      current);

	/* Turn off sound just while we alter the contact list. */
	// FIXME: empathy_sound_set_enabled (FALSE);
	empathy_contact_list_store_set_show_offline (window->list_store, current);
	//empathy_sound_set_enabled (TRUE);
}
Example #9
0
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 {
		empathy_window_present (GTK_WINDOW (priv->window));
	}
}
Example #10
0
/* Salut account creation. The TpAccountManager first argument
 * must already be prepared when calling this function. */
static gboolean
should_create_salut_account (TpAccountManager *manager)
{
  gboolean salut_created = FALSE;
  GList *accounts, *l;

  /* Check if we already created a salut account */
  empathy_conf_get_bool (empathy_conf_get (),
      EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
      &salut_created);

  if (salut_created)
    {
      DEBUG ("Gconf says we already created a salut account once");
      return FALSE;
    }

  accounts = tp_account_manager_get_valid_accounts (manager);

  for (l = accounts; l != NULL;  l = g_list_next (l))
    {
      TpAccount *account = TP_ACCOUNT (l->data);

      if (!tp_strdiff (tp_account_get_protocol (account), "local-xmpp"))
        {
          salut_created = TRUE;
          break;
        }
    }

  g_list_free (accounts);

  if (salut_created)
    {
      DEBUG ("Existing salut account already exists, flagging so in gconf");
      empathy_conf_set_bool (empathy_conf_get (),
          EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
          TRUE);
    }

  return !salut_created;
}
Example #11
0
static void
preferences_languages_add (EmpathyPreferences *preferences)
{
	GtkTreeView  *view;
	GtkListStore *store;
	GList        *codes, *l;

	view = GTK_TREE_VIEW (preferences->treeview_spell_checker);
	store = GTK_LIST_STORE (gtk_tree_view_get_model (view));

	codes = empathy_spell_get_language_codes ();

	empathy_conf_set_bool (empathy_conf_get(),
			       EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
			       codes != NULL);
	if (!codes) {
		gtk_widget_set_sensitive (preferences->treeview_spell_checker, FALSE);
	}		

	for (l = codes; l; l = l->next) {
		GtkTreeIter  iter;
		const gchar *code;
		const gchar *name;

		code = l->data;
		name = empathy_spell_get_language_name (code);
		if (!name) {
			continue;
		}

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    COL_LANG_CODE, code,
				    COL_LANG_NAME, name,
				    -1);
	}

	empathy_spell_free_language_codes (codes);
}
Example #12
0
static void
salut_account_created (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
  TpAccount *account;
  GError *error = NULL;

  if (!empathy_account_settings_apply_finish (settings, result, &error))
    {
      DEBUG ("Failed to create salut account: %s", error->message);
      g_error_free (error);
      return;
    }

  account = empathy_account_settings_get_account (settings);

  tp_account_set_enabled_async (account, TRUE, NULL, NULL);
  empathy_conf_set_bool (empathy_conf_get (),
      EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
      TRUE);
}
Example #13
0
static void
create_salut_account (void)
{
	McProfile  *profile;
	McProtocol *protocol;
	gboolean    salut_created = FALSE;
	McAccount  *account;
	GList      *accounts;
	EBook      *book;
	EContact   *contact;
	gchar      *nickname = NULL;
	gchar      *first_name = NULL;
	gchar      *last_name = NULL;
	gchar      *email = NULL;
	gchar      *jid = NULL;
	GError     *error = NULL;

	/* Check if we already created a salut account */
	empathy_conf_get_bool (empathy_conf_get(),
			       EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
			       &salut_created);
	if (salut_created) {
		return;
	}

	DEBUG ("Try to add a salut account...");

	/* Check if the salut CM is installed */
	profile = mc_profile_lookup ("salut");
	if (!profile) {
		DEBUG ("No salut profile");
		return;
	}
	protocol = mc_profile_get_protocol (profile);
	if (!protocol) {
		DEBUG ("Salut not installed");
		g_object_unref (profile);
		return;
	}
	g_object_unref (protocol);

	/* Get self EContact from EDS */
	if (!e_book_get_self (&contact, &book, &error)) {
		DEBUG ("Failed to get self econtact: %s",
			error ? error->message : "No error given");
		g_clear_error (&error);
		g_object_unref (profile);
		return;
	}

	empathy_conf_set_bool (empathy_conf_get (),
			       EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
			       TRUE);

	/* Check if there is already a salut account */
	accounts = mc_accounts_list_by_profile (profile);
	if (accounts) {
		DEBUG ("There is already a salut account");
		mc_accounts_list_free (accounts);
		g_object_unref (profile);
		return;
	}

	account = mc_account_create (profile);
	mc_account_set_display_name (account, _("People nearby"));
	
	nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
	first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
	last_name = e_contact_get (contact, E_CONTACT_FAMILY_NAME);
	email = e_contact_get (contact, E_CONTACT_EMAIL_1);
	jid = e_contact_get (contact, E_CONTACT_IM_JABBER_HOME_1);
	
	if (!tp_strdiff (nickname, "nickname")) {
		g_free (nickname);
		nickname = NULL;
	}

	DEBUG ("Salut account created:\nnickname=%s\nfirst-name=%s\n"
		"last-name=%s\nemail=%s\njid=%s\n",
		nickname, first_name, last_name, email, jid);

	mc_account_set_param_string (account, "nickname", nickname ? nickname : "");
	mc_account_set_param_string (account, "first-name", first_name ? first_name : "");
	mc_account_set_param_string (account, "last-name", last_name ? last_name : "");
	mc_account_set_param_string (account, "email", email ? email : "");
	mc_account_set_param_string (account, "jid", jid ? jid : "");

	g_free (nickname);
	g_free (first_name);
	g_free (last_name);
	g_free (email);
	g_free (jid);
	g_object_unref (account);
	g_object_unref (profile);
	g_object_unref (contact);
	g_object_unref (book);
}