changeset 19391:7b1e34d10986

merge of '5e1b8aa2904f61701e271733882021002c85f8f3' and '7065ea3a32aff99504eab114d10635aa0c1dcf6f'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 23 Aug 2007 22:31:40 +0000
parents ecf46f3674a9 (diff) 7e326d88bb42 (current diff)
children 74f7d5e4a605
files
diffstat 3 files changed, 33 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/idle.c	Thu Aug 23 22:08:00 2007 +0000
+++ b/libpurple/idle.c	Thu Aug 23 22:31:40 2007 +0000
@@ -163,8 +163,8 @@
 		{
 			if (!no_away)
 			{
+				no_away = TRUE;
 				purple_savedstatus_set_idleaway(FALSE);
-				no_away = TRUE;
 			}
 			time_until_next_idle_event = 0;
 			return;
--- a/libpurple/xmlnode.c	Thu Aug 23 22:08:00 2007 +0000
+++ b/libpurple/xmlnode.c	Thu Aug 23 22:31:40 2007 +0000
@@ -272,6 +272,8 @@
 	if(NULL != node->parent) {
 		if(node->parent->child == node) {
 			node->parent->child = node->next;
+			if (node->parent->lastchild == node)
+				node->parent->lastchild = node->next;
 		} else {
 			xmlnode *prev = node->parent->child;
 			while(prev && prev->next != node) {
@@ -279,6 +281,8 @@
 			}
 			if(prev) {
 				prev->next = node->next;
+				if (node->parent->lastchild == node)
+					node->parent->lastchild = prev;
 			}
 		}
 	}
--- a/pidgin/gtksavedstatuses.c	Thu Aug 23 22:08:00 2007 +0000
+++ b/pidgin/gtksavedstatuses.c	Thu Aug 23 22:31:40 2007 +0000
@@ -1450,7 +1450,9 @@
 	GtkWidget *win;
 	GtkTreeIter iter;
 	GtkCellRenderer *rend;
-	const char *status_id = NULL;
+	char *status_id = NULL;
+	char *message = NULL;
+	gboolean parent_dialog_has_substatus = FALSE;
 	GList *list;
 	gboolean select = FALSE;
 
@@ -1553,25 +1555,29 @@
 					 G_CALLBACK(substatus_editor_ok_cb), dialog);
 
 	/* Seed the input widgets with the current values */
-	/* TODO: Get the current values from our parent's list store, not the saved_status! */
-	if (status_editor->original_title != NULL)
-	{
+
+	/* Only look at the saved status if we can't find it in the parent status dialog's substatuses model */
+	gtk_tree_model_get(GTK_TREE_MODEL(status_editor->model), &iter, 
+		STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, &parent_dialog_has_substatus, -1);
+	if (parent_dialog_has_substatus) {
+		gtk_tree_model_get(GTK_TREE_MODEL(status_editor->model), &iter,
+			STATUS_EDITOR_COLUMN_STATUS_ID, &status_id,
+			STATUS_EDITOR_COLUMN_STATUS_MESSAGE, &message, -1);
+	} else if (status_editor->original_title != NULL) {
 		PurpleSavedStatus *saved_status = NULL;
 		PurpleSavedStatusSub *substatus = NULL;
 
-		saved_status = purple_savedstatus_find(status_editor->original_title);
-		if (saved_status != NULL)
-			substatus = purple_savedstatus_get_substatus(saved_status, account);
+		if ((saved_status = purple_savedstatus_find(status_editor->original_title)) != NULL) {
+			if ((substatus = purple_savedstatus_get_substatus(saved_status, account)) != NULL) {
+				message = (char *)purple_savedstatus_substatus_get_message(substatus);
+				status_id = (char *)purple_status_type_get_id(purple_savedstatus_substatus_get_type(substatus));
+			}
+		}
+	}
+	/* TODO: Else get the generic status type from our parent */
 
-		if (substatus != NULL)
-		{
-			gtk_imhtml_append_text(dialog->message,
-								   purple_savedstatus_substatus_get_message(substatus),
-								   0);
-			status_id = purple_status_type_get_id(purple_savedstatus_substatus_get_type(substatus));
-		}
-		/* TODO: Else get the generic status type from our parent */
-	}
+	if (message)
+		gtk_imhtml_append_text(dialog->message, message, 0);
 
 	for (list = purple_account_get_status_types(account); list; list = list->next)
 	{
@@ -1607,6 +1613,12 @@
 	if (!select)
 		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
 
+	if (parent_dialog_has_substatus) {
+		/* These two were gotten from the parent tree model, so they need to be freed */
+		g_free(status_id);
+		g_free(message);
+	}
+
 	gtk_widget_show_all(win);
 }