cpw.nader.asynclogging-3: 68d46238: Cleaned up gtklog.c to split up long lin...

morshed.nader at gmail.com morshed.nader at gmail.com
Wed Mar 30 01:41:58 EDT 2011


----------------------------------------------------------------------
Revision: 68d462386b8d04f68739e7846cce7e44568ef070
Parent:   720e73faab68d9ae355ae5cf39e0188ad78af896
Author:   morshed.nader at gmail.com
Date:     03/21/11 02:09:47
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/68d462386b8d04f68739e7846cce7e44568ef070

Changelog: 

Cleaned up gtklog.c to split up long lines

Changes against parent 720e73faab68d9ae355ae5cf39e0188ad78af896

  patched  pidgin/gtklog.c

-------------- next part --------------
============================================================
--- pidgin/gtklog.c	cd591708b1fc189b3c93641de72f2e032aa02729
+++ pidgin/gtklog.c	cfab497e80fa8327e7a57f5b3b6c5ee9bfd408a5
@@ -149,7 +149,8 @@ static void destroy_cb(PidginLogViewer *
 static void pidgin_log_search_cb(GObject *, GAsyncResult *, gpointer);
 static void search_cb(GtkWidget *, PidginLogViewer *);
 static void destroy_cb(PidginLogViewer *, gint, log_viewer_hash_t *);
-static void log_row_activated_cb(GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *);
+static void log_row_activated_cb(GtkTreeView *, GtkTreePath *,
+	GtkTreeViewColumn *);
 static void delete_log_cleanup_cb(log_delete_callback_data *);
 static void pidgin_log_delete_log_cb(GObject *, GAsyncResult *, gpointer);
 static void delete_log_cb(log_delete_callback_data *);
@@ -157,7 +158,8 @@ static void log_show_popup_menu(GdkEvent
 static void log_delete_log_cb(GtkWidget *, log_menu_callback_data *);
 static void log_menu_callback_data_free(log_menu_callback_data *);
 static void log_show_popup_menu(GdkEventButton *, log_menu_callback_data *);
-static gboolean log_button_press_cb(GtkTreeView *, GdkEventButton *, PidginLogViewer *);
+static gboolean log_button_press_cb(GtkTreeView *, GdkEventButton *,
+	PidginLogViewer *);
 static gboolean log_popup_menu_cb(GtkTreeView *, PidginLogViewer *);
 static gboolean search_find_cb(gpointer);
 static void pidgin_log_read_cb(GObject *, GAsyncResult *, gpointer);
@@ -253,7 +255,8 @@ select_first_log(PidginLogViewer *lv)
 		path = gtk_tree_model_get_path(model, &it);
 	}
 
-	gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview)), path);
+	gtk_tree_selection_select_path(
+		gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview)), path);
 	gtk_tree_path_free(path);
 }
 
@@ -303,8 +306,8 @@ pidgin_log_search_cb(GObject *object, GA
 
 	if (text == NULL) {
 		if (error->code != G_IO_ERROR_CANCELLED)
-			purple_debug_error("gtklog", "Error reading file during search: %s\n",
-				error->message);
+			purple_debug_error("gtklog",
+				"Error reading file during search: %s\n", error->message);
 	} else if (pidgin_log_data->is_window_open) {
 		PidginLogViewer *lv = pidgin_log_data->log_viewer;
 		GtkTreeStore *treestore = pidgin_log_viewer_get_tree_store(lv);
@@ -312,7 +315,8 @@ pidgin_log_search_cb(GObject *object, GA
 
 		if (*text && purple_strcasestr(text, pidgin_log_data->string)) {
 			gtk_tree_store_append(treestore, &iter, NULL);
-			gtk_tree_store_set(treestore, &iter, 0, log_get_date(log), 1, log, -1);
+			gtk_tree_store_set(treestore, &iter, 0, log_get_date(log),
+				1, log, -1);
 		}
 	}
 
@@ -406,11 +410,12 @@ destroy_cb(PidginLogViewer *lv, gint res
 	if (resp == GTK_RESPONSE_HELP) {
 		GtkTreeSelection *sel;
 		GtkTreeIter iter;
-		GtkTreeModel *model = GTK_TREE_MODEL(pidgin_log_viewer_get_tree_store(lv));
+		GtkTreeModel *model;
 		GtkWidget *view = pidgin_log_viewer_get_tree_view(lv);
 		PurpleLog *log = NULL;
 		gchar *logdir;
 
+		model = GTK_TREE_MODEL(pidgin_log_viewer_get_tree_store(lv));
 		sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
 
 		if (gtk_tree_selection_get_selected(sel, &model, &iter))
@@ -484,7 +489,8 @@ pidgin_log_delete_log_cb(GObject *object
 		PidginLogViewer *lv = temp->log_data->log_viewer;
 		GtkTreeStore *treestore = pidgin_log_viewer_get_tree_store(lv);
 		GtkTreeIter *iter = temp->iter;
-		GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), iter);
+		GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore),
+			iter);
 		gboolean first = !gtk_tree_path_prev(path);
 
 		if (!gtk_tree_store_remove(treestore, iter) && first) {
@@ -542,8 +548,9 @@ log_delete_log_cb(GtkWidget *menuitem, l
 		else
 			name = log_name;
 
-		str = g_strdup_printf(_("Are you sure you want to permanently delete the log of the "
-			"conversation with %s which started at %s?"), name, time);
+		str = g_strdup_printf(_("Are you sure you want to permanently delete "
+			"the log of the conversation with %s which started at %s?"),
+			name, time);
 	} else if (chat_type == PURPLE_LOG_CHAT) {
 		PurpleAccount *account = purple_log_get_account(log);
 		const gchar *log_name = purple_log_get_name(log);
@@ -555,11 +562,12 @@ log_delete_log_cb(GtkWidget *menuitem, l
 		else
 			name = log_name;
 
-		str = g_strdup_printf(_("Are you sure you want to permanently delete the log of the "
-			"conversation in %s which started at %s?"), name, time);
+		str = g_strdup_printf(_("Are you sure you want to permanently delete "
+			"the log of the conversation in %s which started at %s?"),
+			name, time);
 	} else if (chat_type == PURPLE_LOG_SYSTEM) {
-		str = g_strdup_printf(_("Are you sure you want to permanently delete the system log "
-			"which started at %s?"), time);
+		str = g_strdup_printf(_("Are you sure you want to permanently delete "
+			"the system log which started at %s?"), time);
 	} else
 		/* Stuff will get freed elsewhere */
 		g_return_if_reached();
@@ -631,11 +639,12 @@ static gboolean
 }
 
 static gboolean
-log_button_press_cb(GtkTreeView *treeview, GdkEventButton *event, PidginLogViewer *lv)
+log_button_press_cb(GtkTreeView *treeview, GdkEventButton *event,
+	PidginLogViewer *lv)
 {
 	if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
 		log_menu_callback_data *data;
-		GtkTreeModel *model = GTK_TREE_MODEL(pidgin_log_viewer_get_tree_store(lv));
+		GtkTreeModel *model;
 		GtkTreeSelection *selection;
 		GtkTreePath *path;
 		GtkTreeIter *iter;
@@ -646,6 +655,7 @@ log_button_press_cb(GtkTreeView *treevie
 			return FALSE;
 
 		iter = g_new(GtkTreeIter, 1);
+		model = GTK_TREE_MODEL(pidgin_log_viewer_get_tree_store(lv));
 		gtk_tree_model_get_iter(model, iter, path);
 		selection = gtk_tree_view_get_selection(treeview);
 		gtk_tree_selection_select_iter(selection, iter);
@@ -688,7 +698,8 @@ log_popup_menu_cb(GtkTreeView *treeview,
 		return FALSE;
 	}
 
-	gtk_tree_model_get(GTK_TREE_MODEL(pidgin_log_viewer_get_tree_store(lv)), iter, NODE_COLUMN, &log, -1);
+	gtk_tree_model_get(GTK_TREE_MODEL(pidgin_log_viewer_get_tree_store(lv)),
+		iter, NODE_COLUMN, &log, -1);
 
 	if (log == NULL) {
 		g_free(iter);
@@ -771,7 +782,10 @@ pidgin_log_read_cb(GObject *object, GAsy
 			GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL |
 			(flags & PURPLE_LOG_READ_NO_NEWLINE ? GTK_IMHTML_NO_NEWLINE : 0));
 
-		/* If we have something in the search bar, scroll to it in the current log */
+		/**
+		 * If we have something in the search bar, scroll to it in the
+		 * current log.
+		 */
 		if (search != NULL) {
 			gtk_imhtml_search_clear(imhtml);
 			g_idle_add(search_find_cb, pidgin_log_data);
@@ -816,7 +830,8 @@ log_select_cb(GtkTreeSelection *sel, Pid
 			title = g_strdup_printf(_("Conversation with %s on %s"),
 				log_name, log_get_date(log));
 
-		bold_text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title);
+		bold_text = g_strdup_printf("<span size='larger' "
+			"weight='bold'>%s</span>", title);
 		gtk_label_set_markup(GTK_LABEL(priv->label), bold_text);
 
 		g_free(title);
@@ -848,17 +863,23 @@ log_select_cb(GtkTreeSelection *sel, Pid
 	g_object_unref(cancel);
 }
 
-/* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet.
- * I want the tree to be divided into groups like "Today," "Yesterday," "Last week,"
- * "August," "2002," etc. based on how many conversation took place in each subdivision.
+/**
+ * I want to make this smarter, but haven't come up with a cool algorithm to
+ * do so, yet.
  *
+ * I want the tree to be divided into groups like "Today,"
+ * "Yesterday," "Last week," "August," "2002," etc. based on how many
+ * conversation took place in each subdivision.
+ *
  * For now, I'll just make it a flat list.
  */
 static void
 populate_log_tree(PidginLogViewer *lv)
-     /* Logs are made from trees in real life.
-        This is a tree made from logs */
 {
+	/**
+	 * Logs are made from trees in real life.
+	 * This is a tree made from logs
+	 */
 	GtkTreeIter toplevel, child;
 	GtkTreeStore *treestore = pidgin_log_viewer_get_tree_store(lv);
 	GList *logs = pidgin_log_viewer_get_logs(lv);
@@ -878,7 +899,8 @@ populate_log_tree(PidginLogViewer *lv)
 		if (strcmp(month, prev_top_month) != 0) {
 			/* top level */
 			gtk_tree_store_append(treestore, &toplevel, NULL);
-			gtk_tree_store_set(treestore, &toplevel, 0, month, 1, NULL, 2, log_tm, -1);
+			gtk_tree_store_set(treestore, &toplevel, 0, month, 1, NULL,
+				2, log_tm, -1);
 
 			strncpy(prev_top_month, month, sizeof(prev_top_month));
 		}
@@ -903,7 +925,9 @@ pidgin_log_viewer_new(log_viewer_hash_t 
 		"need-log-size", need_log_size,
 		NULL);
 
-	/* Store the information to later prevent duplicate windows from popping up */
+	/**
+	 * Store the information to later prevent duplicate windows from popping up.
+	 */
 	if (ht != NULL) {
 		G_LOCK(log_viewers);
 		g_hash_table_insert(log_viewers, ht, g_object_ref(lv));
@@ -1286,7 +1310,8 @@ pidgin_log_show_contact(PurpleContact *c
 	}
 
 	if ((name = purple_contact_get_alias(contact)) == NULL)
-		name = purple_buddy_get_contact_alias(purple_contact_get_priority_buddy(contact));
+		name = purple_buddy_get_contact_alias(
+			purple_contact_get_priority_buddy(contact));
 
 	/* This will happen if the contact doesn't have an alias,
 	 * and none of the contact's buddies are online.
@@ -1306,7 +1331,9 @@ pidgin_log_show_contact(PurpleContact *c
 	pidgin_log_data->count = pidgin_log_data->total = 0;
 
 	title = g_strdup_printf(_("Conversations with %s"), name);
-	lv = pidgin_log_data->log_viewer = pidgin_log_viewer_new(ht, title, image, TRUE);
+	lv = pidgin_log_data->log_viewer =
+		pidgin_log_viewer_new(ht, title, image, TRUE);
+
 	g_free(title);
 	gtk_widget_show(GTK_WIDGET(lv));
 
@@ -1684,7 +1711,8 @@ static void
 }
 
 static void
-pidgin_log_viewer_set_viewer_type(PidginLogViewer *lv, PurpleLogChatType viewer_type)
+pidgin_log_viewer_set_viewer_type(PidginLogViewer *lv,
+	PurpleLogChatType viewer_type)
 {
 	g_return_if_fail(PIDGIN_IS_LOG_VIEWER(lv));
 
@@ -1709,7 +1737,8 @@ pidgin_log_viewer_set_need_log_size(Pidg
 {
 	g_return_if_fail(PIDGIN_IS_LOG_VIEWER(lv));
 
-	PIDGIN_LOG_VIEWER_GET_PRIVATE(lv)->need_log_size = need_log_size ? TRUE : FALSE;
+	PIDGIN_LOG_VIEWER_GET_PRIVATE(lv)->need_log_size =
+		need_log_size ? TRUE : FALSE;
 
 	g_object_notify(G_OBJECT(lv), "need-log-size");
 }
@@ -1756,7 +1785,8 @@ pidgin_log_viewer_constructed(GObject *o
 
 		priv->size_label = gtk_label_new(NULL);
 		gtk_misc_set_alignment(GTK_MISC(priv->size_label), 0, 0);
-		gtk_box_pack_start(GTK_BOX(content_area), priv->size_label, FALSE, FALSE, 0);
+		gtk_box_pack_start(GTK_BOX(content_area), priv->size_label,
+			FALSE, FALSE, 0);
 		gtk_widget_show(priv->size_label);
 
 		text = g_strdup_printf("<span weight='bold'>%s</span> %s",
@@ -1771,11 +1801,15 @@ pidgin_log_viewer_constructed(GObject *o
 	/* Hook up all the signals */
 	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview));
 
-	g_signal_connect(lv, "notify::title", G_CALLBACK(pidgin_log_viewer_update_label), NULL);
+	g_signal_connect(lv, "notify::title",
+		G_CALLBACK(pidgin_log_viewer_update_label), NULL);
 	g_signal_connect(sel, "changed", G_CALLBACK(log_select_cb), lv);
-	g_signal_connect(priv->treeview, "row-activated", G_CALLBACK(log_row_activated_cb), NULL);
-	g_signal_connect(priv->treeview, "button-press-event", G_CALLBACK(log_button_press_cb), lv);
-	g_signal_connect(priv->treeview, "popup-menu", G_CALLBACK(log_popup_menu_cb), lv);
+	g_signal_connect(priv->treeview, "row-activated",
+		G_CALLBACK(log_row_activated_cb), NULL);
+	g_signal_connect(priv->treeview, "button-press-event",
+		G_CALLBACK(log_button_press_cb), lv);
+	g_signal_connect(priv->treeview, "popup-menu",
+		G_CALLBACK(log_popup_menu_cb), lv);
 }
 
 static void
@@ -1811,7 +1845,8 @@ static void
 }
 
 static void
-pidgin_log_viewer_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+pidgin_log_viewer_set_property(GObject *object, guint prop_id,
+	const GValue *value, GParamSpec *pspec)
 {
 	PidginLogViewer *lv = PIDGIN_LOG_VIEWER(object);
 
@@ -1853,7 +1888,8 @@ static void
 }
 
 static void
-pidgin_log_viewer_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+pidgin_log_viewer_get_property(GObject *object, guint prop_id,
+	GValue *value, GParamSpec *pspec)
 {
 	PidginLogViewer *lv = PIDGIN_LOG_VIEWER(object);
 
@@ -1942,7 +1978,7 @@ pidgin_log_viewer_class_init(PidginLogVi
 	properties[PROP_TEXT_AREA] =
 		g_param_spec_object("text-area",
 			"Text Area",
-			"The text area that displays the currently selected log to the user",
+			"The text area that displays the selected log to the user",
 			GTK_TYPE_WIDGET,
 			G_PARAM_READABLE);
 
@@ -1979,21 +2015,21 @@ pidgin_log_viewer_class_init(PidginLogVi
 	properties[PROP_SEARCH_CANCEL] =
 		g_param_spec_object("search-cancel",
 			"Search Cancellable",
-			"A GCancellable object used to stop searches that are in progress",
+			"An object used to stop searches that are in progress",
 			G_TYPE_CANCELLABLE,
 			G_PARAM_READWRITE);
 
 	properties[PROP_LIST_CANCEL] =
 		g_param_spec_object("list-cancel",
 			"List Cancellable",
-			"A GCancellable object used to stop log-listings that are in progress",
+			"An object used to stop log-listings that are in progress",
 			G_TYPE_CANCELLABLE,
 			G_PARAM_READWRITE);
 
 	properties[PROP_READ_CANCEL] =
 		g_param_spec_object("read-cancel",
 			"Read Cancellable",
-			"A GCancellable object used to stop log-listings that are in progress",
+			"An object used to stop log-listings that are in progress",
 			G_TYPE_CANCELLABLE,
 			G_PARAM_READWRITE);
 
@@ -2104,7 +2140,10 @@ pidgin_log_viewer_init(PidginLogViewer *
 	/* Window */
 	gtk_dialog_add_buttons(dialog, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
 #ifdef G_OS_WIN32
-	/* Steal the "HELP" response and use it to trigger browsing to the logs folder */
+	/**
+	 * Steal the "HELP" response and use it to trigger browsing to the
+	 * logs folder
+	 */
 	gtk_dialog_add_button(dialog, _("_Browse logs folder"), GTK_RESPONSE_HELP);
 #endif
 
@@ -2116,7 +2155,8 @@ pidgin_log_viewer_init(PidginLogViewer *
 
 	/* Box for icon and label */
 	priv->title_box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
-	gtk_container_set_border_width(GTK_CONTAINER(priv->title_box), PIDGIN_HIG_BOX_SPACE);
+	gtk_container_set_border_width(GTK_CONTAINER(priv->title_box),
+		PIDGIN_HIG_BOX_SPACE);
 	gtk_box_pack_start(GTK_BOX(content_area), priv->title_box, FALSE, FALSE, 0);
 
 
@@ -2138,16 +2178,20 @@ pidgin_log_viewer_init(PidginLogViewer *
 	/* List */
 	sw = gtk_scrolled_window_new(NULL, NULL);
 	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
+		GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
 	gtk_paned_add1(GTK_PANED(pane), sw);
 
-	priv->treestore = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_OBJECT, PURPLE_TYPE_STRUCT_TM);
-	priv->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->treestore));
+	priv->treestore = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_OBJECT,
+		PURPLE_TYPE_STRUCT_TM);
+	priv->treeview =
+		gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->treestore));
 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->treeview), FALSE);
 	pidgin_set_accessible_label(priv->treeview, priv->label);
 
 	rend = gtk_cell_renderer_text_new();
-	col = gtk_tree_view_column_new_with_attributes("time", rend, "markup", 0, NULL);
+	col = gtk_tree_view_column_new_with_attributes("time", rend, "markup",
+		0, NULL);
 	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->treeview), col);
 	gtk_container_add(GTK_CONTAINER(sw), priv->treeview);
 
@@ -2189,8 +2233,10 @@ pidgin_log_viewer_init(PidginLogViewer *
 	priv->list_bar = gtk_progress_bar_new();
 	priv->search_bar = gtk_progress_bar_new();
 
-	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(priv->list_bar), _("Waiting for logs ..."));
-	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(priv->search_bar), _("Searching logs ..."));
+	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(priv->list_bar),
+		_("Waiting for logs ..."));
+	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(priv->search_bar),
+		_("Searching logs ..."));
 
 	gtk_box_pack_start(GTK_BOX(vbox), priv->list_bar, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), priv->search_bar, FALSE, FALSE, 0);
@@ -2232,7 +2278,8 @@ pidgin_log_init(void)
 
 	G_LOCK(log_viewers);
 	// Is the ht stuff leaking?
-	log_viewers = g_hash_table_new_full(log_viewer_hash, log_viewer_equal, NULL, g_object_unref);
+	log_viewers = g_hash_table_new_full(log_viewer_hash, log_viewer_equal,
+		NULL, g_object_unref);
 	G_UNLOCK(log_viewers);
 
 	G_LOCK(syslog_viewer);


More information about the Commits mailing list