/soc/2013/ankitkv/gobjectification: 4fc616843cb2: Removed conver...

Ankit Vani a at nevitus.org
Thu Jun 27 13:31:04 EDT 2013


Changeset: 4fc616843cb2b01d795e97739a2700ec95b61838
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-27 23:00 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4fc616843cb2

Description:

Removed conversation type argument from pidgin conversation functions.
* Split pidgin_conversations_find_unseen_list() into:
  - pidgin_conversations_get_unseen_all()
  - pidgin_conversations_get_unseen_ims()
  - pidgin_conversations_get_unseen_chats()
* Split pidgin_conv_window_[first,last]_with_type with pidgin_conv_window_[first,last]_[im,chat]

diffstat:

 pidgin/gtkblist.c                        |   22 ++---
 pidgin/gtkconv.c                         |  113 ++++++++++++++++++++++++------
 pidgin/gtkconv.h                         |   46 +++++++++++-
 pidgin/gtkconvwin.h                      |    6 +-
 pidgin/gtkdocklet.c                      |    6 +-
 pidgin/plugins/extplacement.c            |    3 +-
 pidgin/plugins/perl/common/GtkConv.xs    |   15 +++-
 pidgin/plugins/perl/common/GtkConvWin.xs |   12 ++-
 8 files changed, 167 insertions(+), 56 deletions(-)

diffs (truncated from 387 to 300 lines):

diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -4697,11 +4697,9 @@ unseen_conv_menu(void)
 		menu = NULL;
 	}
 
-	ims = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM,
-				PIDGIN_UNSEEN_TEXT, FALSE, 0);
-
-	chats = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT,
-				PIDGIN_UNSEEN_NICK, FALSE, 0);
+	ims = pidgin_conversations_get_unseen_ims(PIDGIN_UNSEEN_TEXT, FALSE, 0);
+
+	chats = pidgin_conversations_get_unseen_chats(PIDGIN_UNSEEN_NICK, FALSE, 0);
 
 	if(ims && chats)
 		convs = g_list_concat(ims, chats);
@@ -4730,12 +4728,10 @@ menutray_press_cb(GtkWidget *widget, Gdk
 
 	switch (event->button) {
 		case 1:
-			convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM,
-							PIDGIN_UNSEEN_TEXT, FALSE, 1);
+			convs = pidgin_conversations_get_unseen_ims(PIDGIN_UNSEEN_TEXT, FALSE, 1);
 
 			if(!convs)
-				convs = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT,
-								PIDGIN_UNSEEN_NICK, FALSE, 1);
+				convs = pidgin_conversations_get_unseen_chats(PIDGIN_UNSEEN_NICK, FALSE, 1);
 			if (convs) {
 				pidgin_conv_present_conversation((PurpleConversation*)convs->data);
 				g_list_free(convs);
@@ -4771,11 +4767,9 @@ conversation_updated_cb(PurpleConversati
 		gtkblist->menutrayicon = NULL;
 	}
 
-	ims = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM,
-				PIDGIN_UNSEEN_TEXT, FALSE, 0);
-
-	chats = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT,
-				PIDGIN_UNSEEN_NICK, FALSE, 0);
+	ims = pidgin_conversations_get_unseen_ims(PIDGIN_UNSEEN_TEXT, FALSE, 0);
+
+	chats = pidgin_conversations_get_unseen_chats(PIDGIN_UNSEEN_NICK, FALSE, 0);
 
 	if(ims && chats)
 		convs = g_list_concat(ims, chats);
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -3049,24 +3049,15 @@ pidgin_conv_present_conversation(PurpleC
 	gtk_window_present(GTK_WINDOW(gtkconv->win->window));
 }
 
-GList *
-pidgin_conversations_find_unseen_list(PurpleConversationType type,
-										PidginUnseenState min_state,
-										gboolean hidden_only,
-										guint max_count)
-{
-	GList *l;
+static GList *
+pidgin_conversations_get_unseen(GList *l,
+									PidginUnseenState min_state,
+									gboolean hidden_only,
+									guint max_count)
+{
 	GList *r = NULL;
 	guint c = 0;
 
-	if (type == PURPLE_CONV_TYPE_IM) {
-		l = purple_conversations_get_ims();
-	} else if (type == PURPLE_CONV_TYPE_CHAT) {
-		l = purple_conversations_get_chats();
-	} else {
-		l = purple_conversations_get_all();
-	}
-
 	for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) {
 		PurpleConversation *conv = (PurpleConversation*)l->data;
 		PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
@@ -3086,6 +3077,33 @@ pidgin_conversations_find_unseen_list(Pu
 	return r;
 }
 
+GList *
+pidgin_conversations_get_unseen_all(PidginUnseenState min_state,
+										gboolean hidden_only,
+										guint max_count)
+{
+	return pidgin_conversations_get_unseen(purple_conversations_get_all(),
+			min_state, hidden_only, max_count);
+}
+
+GList *
+pidgin_conversations_get_unseen_ims(PidginUnseenState min_state,
+										gboolean hidden_only,
+										guint max_count)
+{
+	return pidgin_conversations_get_unseen(purple_conversations_get_ims(),
+			min_state, hidden_only, max_count);
+}
+
+GList *
+pidgin_conversations_get_unseen_chats(PidginUnseenState min_state,
+										gboolean hidden_only,
+										guint max_count)
+{
+	return pidgin_conversations_get_unseen(purple_conversations_get_chats(),
+			min_state, hidden_only, max_count);
+}
+
 static void
 unseen_conv_menu_cb(GtkMenuItem *item, PurpleConversation *conv)
 {
@@ -10585,15 +10603,12 @@ pidgin_conv_window_get_gtkconv_count(Pid
 }
 
 PidginWindow *
-pidgin_conv_window_first_with_type(PurpleConversationType type)
+pidgin_conv_window_first_im(void)
 {
 	GList *wins, *convs;
 	PidginWindow *win;
 	PidginConversation *conv;
 
-	if (type == PURPLE_CONV_TYPE_UNKNOWN)
-		return NULL;
-
 	for (wins = pidgin_conv_windows_get_list(); wins != NULL; wins = wins->next) {
 		win = wins->data;
 
@@ -10603,7 +10618,7 @@ pidgin_conv_window_first_with_type(Purpl
 
 			conv = convs->data;
 
-			if (purple_conversation_get_type(conv->active_conv) == type)
+			if (PURPLE_IS_IM_CONVERSATION(conv->active_conv))
 				return win;
 		}
 	}
@@ -10612,15 +10627,12 @@ pidgin_conv_window_first_with_type(Purpl
 }
 
 PidginWindow *
-pidgin_conv_window_last_with_type(PurpleConversationType type)
+pidgin_conv_window_last_im(void)
 {
 	GList *wins, *convs;
 	PidginWindow *win;
 	PidginConversation *conv;
 
-	if (type == PURPLE_CONV_TYPE_UNKNOWN)
-		return NULL;
-
 	for (wins = g_list_last(pidgin_conv_windows_get_list());
 	     wins != NULL;
 	     wins = wins->prev) {
@@ -10633,7 +10645,58 @@ pidgin_conv_window_last_with_type(Purple
 
 			conv = convs->data;
 
-			if (purple_conversation_get_type(conv->active_conv) == type)
+			if (PURPLE_IS_IM_CONVERSATION(conv->active_conv) == type)
+				return win;
+		}
+	}
+
+	return NULL;
+}
+
+PidginWindow *
+pidgin_conv_window_first_chat(void)
+{
+	GList *wins, *convs;
+	PidginWindow *win;
+	PidginConversation *conv;
+
+	for (wins = pidgin_conv_windows_get_list(); wins != NULL; wins = wins->next) {
+		win = wins->data;
+
+		for (convs = win->gtkconvs;
+		     convs != NULL;
+		     convs = convs->next) {
+
+			conv = convs->data;
+
+			if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv))
+				return win;
+		}
+	}
+
+	return NULL;
+}
+
+PidginWindow *
+pidgin_conv_window_last_chat(void)
+{
+	GList *wins, *convs;
+	PidginWindow *win;
+	PidginConversation *conv;
+
+	for (wins = g_list_last(pidgin_conv_windows_get_list());
+	     wins != NULL;
+	     wins = wins->prev) {
+
+		win = wins->data;
+
+		for (convs = win->gtkconvs;
+		     convs != NULL;
+		     convs = convs->next) {
+
+			conv = convs->data;
+
+			if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv) == type)
 				return win;
 		}
 	}
diff --git a/pidgin/gtkconv.h b/pidgin/gtkconv.h
--- a/pidgin/gtkconv.h
+++ b/pidgin/gtkconv.h
@@ -197,14 +197,13 @@ void pidgin_conv_switch_active_conversat
 void pidgin_conv_update_buttons_by_protocol(PurpleConversation *conv);
 
 /**
- * Returns a list of conversations of the given type which have an unseen
+ * Returns a list of conversations of any type which have an unseen
  * state greater than or equal to the specified minimum state. Using the
  * hidden_only parameter, this search can be limited to hidden
  * conversations. The max_count parameter will limit the total number of
  * converations returned if greater than zero. The returned list should
  * be freed by the caller.
  *
- * @param type         The type of conversation.
  * @param min_state    The minimum unseen state.
  * @param hidden_only  If TRUE, only consider hidden conversations.
  * @param max_count    Maximum number of conversations to return, or 0 for
@@ -212,8 +211,47 @@ void pidgin_conv_update_buttons_by_proto
  * @return             List of PurpleConversation matching criteria, or NULL.
  */
 GList *
-pidgin_conversations_find_unseen_list(PurpleConversationType type,
-										PidginUnseenState min_state,
+pidgin_conversations_get_unseen_all(PidginUnseenState min_state,
+										gboolean hidden_only,
+										guint max_count);
+
+/**
+ * Returns a list of IM conversations which have an unseen state greater
+ * than or equal to the specified minimum state. Using the hidden_only
+ * parameter, this search can be limited to hidden IM conversations. The
+ * max_count parameter will limit the total number of IM converations
+ * returned if greater than zero. The returned list should be freed by the
+ * caller.
+ *
+ * @param min_state    The minimum unseen state.
+ * @param hidden_only  If TRUE, only consider hidden conversations.
+ * @param max_count    Maximum number of conversations to return, or 0 for
+ *                     no maximum.
+ * @return             List of PurpleIMConversation matching criteria,
+ *                     or NULL.
+ */
+GList *
+pidgin_conversations_get_unseen_ims(PidginUnseenState min_state,
+										gboolean hidden_only,
+										guint max_count);
+
+/**
+ * Returns a list of chat conversations which have an unseen state greater
+ * than or equal to the specified minimum state. Using the hidden_only
+ * parameter, this search can be limited to hidden chat conversations. The
+ * max_count parameter will limit the total number of chat converations
+ * returned if greater than zero. The returned list should be freed by the
+ * caller.
+ *
+ * @param min_state    The minimum unseen state.
+ * @param hidden_only  If TRUE, only consider hidden conversations.
+ * @param max_count    Maximum number of conversations to return, or 0 for
+ *                     no maximum.
+ * @return             List of PurpleChatConversation matching criteria,
+ *                     or NULL.
+ */
+GList *
+pidgin_conversations_get_unseen_chats(PidginUnseenState min_state,
 										gboolean hidden_only,
 										guint max_count);
 
diff --git a/pidgin/gtkconvwin.h b/pidgin/gtkconvwin.h
--- a/pidgin/gtkconvwin.h
+++ b/pidgin/gtkconvwin.h
@@ -123,8 +123,10 @@ PidginWindow *pidgin_conv_window_get_at_
 GList *pidgin_conv_window_get_gtkconvs(PidginWindow *win);
 guint pidgin_conv_window_get_gtkconv_count(PidginWindow *win);
 
-PidginWindow *pidgin_conv_window_first_with_type(PurpleConversationType type);
-PidginWindow *pidgin_conv_window_last_with_type(PurpleConversationType type);
+PidginWindow *pidgin_conv_window_first_im(void);
+PidginWindow *pidgin_conv_window_last_im(void);
+PidginWindow *pidgin_conv_window_first_chat(void);



More information about the Commits mailing list