changeset 12857:e5f780a6137b

[gaim-migrate @ 15208] This is the ability to set a startup status to be used instead of the status when you last exited. The savedstatus stuff was missing from Changelog.API, so I added it. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 13 Jan 2006 02:47:12 +0000
parents be1cd5952a48
children b1c85bf2dab3
files plugins/ChangeLog.API src/account.c src/account.h src/gtkmain.c src/gtkprefs.c src/savedstatuses.c src/savedstatuses.h
diffstat 7 files changed, 102 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Fri Jan 13 01:02:56 2006 +0000
+++ b/plugins/ChangeLog.API	Fri Jan 13 02:47:12 2006 +0000
@@ -231,6 +231,35 @@
 	* gaim_gtk_log_init()
 	* gaim_gtk_log_get_handle()
 	* gaim_gtk_log_uninit()
+	* gaim_accounts_restore_current_statuses()
+	* gaim_savedstatus_new()
+	* gaim_savedstatus_set_title()
+	* gaim_savedstatus_set_type()
+	* gaim_savedstatus_set_message()
+	* gaim_savedstatus_set_substatus()
+	* gaim_savedstatus_unset_substatus()
+	* gaim_savedstatus_delete()
+	* gaim_savedstatus_get_all()
+	* gaim_savedstatus_get_popular()
+	* gaim_savedstatus_get_current()
+	* gaim_savedstatus_get_startup()
+	* gaim_savedstatus_get_idleaway()
+	* gaim_savedstatus_find()
+	* gaim_savedstatus_find_by_creation_time()
+	* gaim_savedstatus_is_transient()
+	* gaim_savedstatus_get_title()
+	* gaim_savedstatus_get_type()
+	* gaim_savedstatus_get_message()
+	* gaim_savedstatus_get_creation_time()
+	* gaim_savedstatus_has_substatuses()
+	* gaim_savedstatus_get_substatus()
+	* gaim_savedstatus_substatus_get_type()
+	* gaim_savedstatus_substatus_get_message()
+	* gaim_savedstatus_activate()
+	* gaim_savedstatus_activate_for_account()
+	* gaim_savedstatuses_get_handle()
+	* gaim_savedstatuses_init()
+	* gaim_savedstatuses_uninit()
 
 	Signals - Changed:  (See the Doxygen docs for details on all signals.)
 	* Signal propagation now stops after a handler returns a non-NULL value.
--- a/src/account.c	Fri Jan 13 01:02:56 2006 +0000
+++ b/src/account.c	Fri Jan 13 02:47:12 2006 +0000
@@ -2249,7 +2249,7 @@
 }
 
 void
-gaim_accounts_restore_previous_statuses()
+gaim_accounts_restore_current_statuses()
 {
 	GList *l;
 	GaimAccount *account;
--- a/src/account.h	Fri Jan 13 01:02:56 2006 +0000
+++ b/src/account.h	Fri Jan 13 02:47:12 2006 +0000
@@ -854,13 +854,13 @@
 /**
  * This is called by the core after all subsystems and what
  * not have been initialized.  It sets all enabled accounts
- * to their previous status by signing them on, setting them
+ * to their startup status by signing them on, setting them
  * away, etc.
  *
  * You probably shouldn't call this unless you really know
  * what you're doing.
  */
-void gaim_accounts_restore_previous_statuses(void);
+void gaim_accounts_restore_current_statuses(void);
 
 /*@}*/
 
--- a/src/gtkmain.c	Fri Jan 13 01:02:56 2006 +0000
+++ b/src/gtkmain.c	Fri Jan 13 02:47:12 2006 +0000
@@ -727,7 +727,9 @@
 	else
 	{
 		/* Everything is good to go--sign on already */
-		gaim_accounts_restore_previous_statuses();
+		if (!gaim_prefs_get_bool("/core/savedstatus/startup_current_status"))
+			gaim_savedstatus_activate(gaim_savedstatus_get_startup());
+		gaim_accounts_restore_current_statuses();
 	}
 
 	if (gaim_accounts_get_all_active() == NULL)
--- a/src/gtkprefs.c	Fri Jan 13 01:02:56 2006 +0000
+++ b/src/gtkprefs.c	Fri Jan 13 02:47:12 2006 +0000
@@ -1701,6 +1701,12 @@
 	gaim_prefs_set_int("/core/savedstatus/idleaway", gaim_savedstatus_get_creation_time(status));
 }
 
+static void
+set_startupstatus(GaimSavedStatus *status)
+{
+	gaim_prefs_set_int("/core/savedstatus/startup", gaim_savedstatus_get_creation_time(status));
+}
+
 static GtkWidget *
 away_page()
 {
@@ -1746,7 +1752,6 @@
 	gtk_misc_set_alignment(GTK_MISC(dd), 0, 0.5);
 
 	/* Auto-away stuff */
-	sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 	vbox = gaim_gtk_make_frame(ret, _("Auto-away"));
 
 	button = gaim_gtk_prefs_checkbox(_("Change status when _idle"),
@@ -1781,6 +1786,34 @@
 		gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
 	}
 
+	/* Signon status stuff */
+	vbox = gaim_gtk_make_frame(ret, _("Status at startup"));
+
+	button = gaim_gtk_prefs_checkbox(_("Use status from last _exit at startup"),
+		"/core/savedstatus/startup_current_status", vbox);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_container_add(GTK_CONTAINER(vbox), hbox);
+
+	label = gtk_label_new_with_mnemonic(_("Status to a_pply at startup:"));
+	gtk_size_group_add_widget(sg, label);
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+	g_signal_connect(G_OBJECT(button), "clicked",
+					 G_CALLBACK(gaim_gtk_toggle_sensitive), label);
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+	/* TODO: Show something useful if we don't have any saved statuses. */
+	menu = gaim_gtk_status_menu(gaim_savedstatus_get_startup(), G_CALLBACK(set_startupstatus));
+	gtk_box_pack_start(GTK_BOX(hbox), menu, FALSE, FALSE, 0);
+	g_signal_connect(G_OBJECT(button), "clicked",
+			 G_CALLBACK(gaim_gtk_toggle_sensitive), menu);
+	gtk_label_set_mnemonic_widget(GTK_LABEL(label), menu);
+
+	if (gaim_prefs_get_bool("/core/savedstatus/startup_current_status")) {
+		gtk_widget_set_sensitive(GTK_WIDGET(menu), FALSE);
+		gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
+	}
+
 	gtk_widget_show_all(ret);
 
 	return ret;
--- a/src/savedstatuses.c	Fri Jan 13 01:02:56 2006 +0000
+++ b/src/savedstatuses.c	Fri Jan 13 02:47:12 2006 +0000
@@ -691,6 +691,29 @@
 }
 
 GaimSavedStatus *
+gaim_savedstatus_get_startup()
+{
+	int creation_time;
+	GaimSavedStatus *saved_status = NULL;
+
+	creation_time = gaim_prefs_get_int("/core/savedstatus/startup");
+
+	if (creation_time != 0)
+		saved_status = g_hash_table_lookup(creation_times, &creation_time);
+
+	if (saved_status == NULL)
+	{
+		/* We don't have a status to apply.
+		 * This may be the first login, or the user wants to
+		 * restore the "current" status */
+		saved_status = gaim_savedstatus_get_current();
+	}
+
+	return saved_status;
+}
+
+
+GaimSavedStatus *
 gaim_savedstatus_get_current()
 {
 	int creation_time;
@@ -909,6 +932,7 @@
 		GaimAccount *account;
 
 		account = node->data;
+
 		gaim_savedstatus_activate_for_account(saved_status, account);
 	}
 
@@ -978,6 +1002,8 @@
 	 */
 	gaim_prefs_add_none("/core/savedstatus");
 	gaim_prefs_add_int("/core/savedstatus/current", 0);
+	gaim_prefs_add_int("/core/savedstatus/startup", 0);
+	gaim_prefs_add_bool("/core/savedstatus/startup_current_status", TRUE);
 	gaim_prefs_add_int("/core/savedstatus/idleaway", 0);
 
 	load_statuses();
--- a/src/savedstatuses.h	Fri Jan 13 01:02:56 2006 +0000
+++ b/src/savedstatuses.h	Fri Jan 13 02:47:12 2006 +0000
@@ -174,6 +174,13 @@
 GaimSavedStatus *gaim_savedstatus_get_current(void);
 
 /**
+ * Returns the status to be used when gaim is starting up
+ *
+ * @return A pointer to the startup GaimSavedStatus.
+ */
+GaimSavedStatus *gaim_savedstatus_get_startup(void);
+
+/**
  * Returns the saved status that gets used when your
  * accounts become idle-away.
  *