Remove PidginContactCompletion for now as it's barely used and not GTK4 compatible.

Mon, 04 Apr 2022 23:56:44 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 04 Apr 2022 23:56:44 -0500
changeset 41321
97b0dbc1873f
parent 41320
1695e758b590
child 41323
21185b889103

Remove PidginContactCompletion for now as it's barely used and not GTK4 compatible.

I created PIDGIN-17606 to reimplement this in a better way and to use it in the
new instant message dialog as well as the invite to chat dialog.

Testing Done:
Compiled and ran.

Reviewed at https://reviews.imfreedom.org/r/1378/

pidgin/meson.build file | annotate | diff | comparison | revisions
pidgin/pidgincontactcompletion.c file | annotate | diff | comparison | revisions
pidgin/pidgincontactcompletion.h file | annotate | diff | comparison | revisions
pidgin/pidgininvitedialog.c file | annotate | diff | comparison | revisions
po/POTFILES.in file | annotate | diff | comparison | revisions
--- a/pidgin/meson.build	Mon Apr 04 23:15:13 2022 -0500
+++ b/pidgin/meson.build	Mon Apr 04 23:56:44 2022 -0500
@@ -34,7 +34,6 @@
 	'pidginclosebutton.c',
 	'pidgincolor.c',
 	'pidgincommands.c',
-	'pidgincontactcompletion.c',
 	'pidginconversationwindow.c',
 	'pidgincontactlist.c',
 	'pidgindebug.c',
@@ -97,7 +96,6 @@
 	'pidgincellrendererexpander.h',
 	'pidginclosebutton.h',
 	'pidgincolor.h',
-	'pidgincontactcompletion.h',
 	'pidginconversationwindow.h',
 	'pidgincontactlist.h',
 	'pidgincore.h',
--- a/pidgin/pidgincontactcompletion.c	Mon Apr 04 23:15:13 2022 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,271 +0,0 @@
-/* pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
- */
-
-#include "pidgincontactcompletion.h"
-
-#include <purple.h>
-
-struct _PidginContactCompletion {
-	GtkEntryCompletion parent;
-	PurpleAccount *account;
-};
-
-enum {
-	PIDGIN_CONTACT_COMPLETION_COLUMN_CONTACT,
-	PIDGIN_CONTACT_COMPLETION_COLUMN_ACCOUNT,
-	PIDGIN_CONTACT_COMPLETION_N_COLUMNS,
-};
-
-enum {
-	PROP_0,
-	PROP_ACCOUNT,
-	N_PROPERTIES
-};
-
-static GParamSpec *properties[N_PROPERTIES] = {0, };
-
-G_DEFINE_TYPE(PidginContactCompletion, pidgin_contact_completion, GTK_TYPE_ENTRY_COMPLETION);
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static void
-pidgin_contact_completion_walk_contact_func(PurpleBlistNode *node, gpointer data) {
-	PurpleBuddy *buddy = PURPLE_BUDDY(node);
-	PurpleAccount *account = purple_buddy_get_account(buddy);
-	GtkListStore *store = GTK_LIST_STORE(data);
-	GtkTreeIter iter;
-	const gchar *name;
-
-	name = purple_buddy_get_name(buddy);
-	if(name == NULL) {
-		name = "";
-	}
-
-	gtk_list_store_append(store, &iter);
-	gtk_list_store_set(
-		store,
-		&iter,
-		PIDGIN_CONTACT_COMPLETION_COLUMN_CONTACT, name,
-		PIDGIN_CONTACT_COMPLETION_COLUMN_ACCOUNT, account,
-		-1
-	);
-}
-
-static GtkTreeModel *
-pidgin_contact_completion_create_model(void) {
-	GtkListStore *store = NULL;
-
-	store = gtk_list_store_new(
-		PIDGIN_CONTACT_COMPLETION_N_COLUMNS,
-		G_TYPE_STRING,
-		PURPLE_TYPE_ACCOUNT
-	);
-
-	purple_blist_walk(NULL,
-	                  NULL,
-	                  NULL,
-	                  pidgin_contact_completion_walk_contact_func,
-	                  store
-	);
-
-	return GTK_TREE_MODEL(store);
-}
-
-static gboolean
-pidgin_contact_completion_match_func(GtkEntryCompletion *completion,
-                                     const gchar *key,
-                                     GtkTreeIter *iter,
-                                     gpointer data)
-{
-	GtkTreeModel *model = NULL;
-	PidginContactCompletion *comp = PIDGIN_CONTACT_COMPLETION(completion);
-	gchar *name = NULL;
-
-	model = gtk_entry_completion_get_model(completion);
-
-	gtk_tree_model_get(
-		model,
-		iter,
-		PIDGIN_CONTACT_COMPLETION_COLUMN_CONTACT, &name,
-		-1
-	);
-
-	if(name == NULL) {
-		return FALSE;
-	}
-
-	if (!g_str_has_prefix(name, key)) {
-		g_free(name);
-		return FALSE;
-	}
-
-	if(PURPLE_IS_ACCOUNT(comp->account)) {
-		PurpleAccount *account = NULL;
-
-		gtk_tree_model_get(
-			model,
-			iter,
-			PIDGIN_CONTACT_COMPLETION_COLUMN_ACCOUNT, &account,
-			-1
-		);
-
-		if(account != comp->account) {
-			g_object_unref(account);
-			return FALSE;
-		}
-
-		g_object_unref(account);
-	}
-
-	return TRUE;
-}
-
-/******************************************************************************
- * GObject Implementation
- *****************************************************************************/
-static void
-pidgin_contact_completion_init(PidginContactCompletion *comp) {
-}
-
-static void
-pidgin_contact_completion_constructed(GObject *obj) {
-	GtkTreeModel *model = NULL;
-
-	G_OBJECT_CLASS(pidgin_contact_completion_parent_class)->constructed(obj);
-
-	model = pidgin_contact_completion_create_model();
-
-	gtk_entry_completion_set_model(
-		GTK_ENTRY_COMPLETION(obj),
-		model
-	);
-
-	gtk_entry_completion_set_match_func(
-		GTK_ENTRY_COMPLETION(obj),
-		pidgin_contact_completion_match_func,
-		NULL,
-		NULL
-	);
-
-	gtk_entry_completion_set_text_column(
-		GTK_ENTRY_COMPLETION(obj),
-		PIDGIN_CONTACT_COMPLETION_COLUMN_CONTACT
-	);
-}
-
-static void
-pidgin_contact_completion_get_property(GObject *obj,
-                                       guint param_id,
-                                       GValue *value,
-                                       GParamSpec *pspec)
-{
-	PidginContactCompletion *comp = PIDGIN_CONTACT_COMPLETION(obj);
-
-	switch(param_id) {
-		case PROP_ACCOUNT:
-			g_value_set_object(value, pidgin_contact_completion_get_account(comp));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-static void
-pidgin_contact_completion_set_property(GObject *obj,
-                                       guint param_id,
-                                       const GValue *value,
-                                       GParamSpec *pspec)
-{
-	PidginContactCompletion *comp = PIDGIN_CONTACT_COMPLETION(obj);
-
-	switch(param_id) {
-		case PROP_ACCOUNT:
-			pidgin_contact_completion_set_account(comp,
-			                                      g_value_get_object(value));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-static void
-pidgin_contact_completion_finalize(GObject *obj) {
-	PidginContactCompletion *comp = PIDGIN_CONTACT_COMPLETION(obj);
-
-	g_object_unref(comp->account);
-
-	G_OBJECT_CLASS(pidgin_contact_completion_parent_class)->finalize(obj);
-}
-
-static void
-pidgin_contact_completion_class_init(PidginContactCompletionClass *klass) {
-	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
-	/* The only solution I could find to make this work was to implement the
-	 * constructed handler and chain up to the parent.  If you find another,
-	 * better way, please implement it :)
-	 */
-	obj_class->constructed = pidgin_contact_completion_constructed;
-
-	obj_class->get_property = pidgin_contact_completion_get_property;
-	obj_class->set_property = pidgin_contact_completion_set_property;
-	obj_class->finalize = pidgin_contact_completion_finalize;
-
-	properties[PROP_ACCOUNT] = g_param_spec_object(
-		"account",
-		"account",
-		"The account to filter by or NULL for no filtering",
-		PURPLE_TYPE_ACCOUNT,
-		G_PARAM_READWRITE | G_PARAM_CONSTRUCT
-	);
-
-	g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-}
-
-/******************************************************************************
- * Public API
- *****************************************************************************/
-GtkEntryCompletion *
-pidgin_contact_completion_new(void) {
-	return GTK_ENTRY_COMPLETION(g_object_new(PIDGIN_TYPE_CONTACT_COMPLETION, NULL));
-}
-
-PurpleAccount *
-pidgin_contact_completion_get_account(PidginContactCompletion *completion) {
-	g_return_val_if_fail(PIDGIN_IS_CONTACT_COMPLETION(completion), NULL);
-
-	return g_object_ref(completion->account);
-}
-
-void
-pidgin_contact_completion_set_account(PidginContactCompletion *completion,
-                                      PurpleAccount *account)
-{
-	g_return_if_fail(PIDGIN_IS_CONTACT_COMPLETION(completion));
-
-	if(g_set_object(&completion->account, account)) {
-		g_object_notify_by_pspec(G_OBJECT(completion),
-		                         properties[PROP_ACCOUNT]);
-	}
-}
--- a/pidgin/pidgincontactcompletion.h	Mon Apr 04 23:15:13 2022 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/* pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
- */
-
-#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
-# error "only <pidgin.h> may be included directly"
-#endif
-
-#ifndef PIDGIN_CONTACT_COMPLETION_H
-#define PIDGIN_CONTACT_COMPLETION_H
-
-#include <gtk/gtk.h>
-
-#include <purple.h>
-
-G_BEGIN_DECLS
-
-/**
- * PidginContactCompletion:
- *
- * #PidginContactCompletion should be treated like a normal
- * #GtkEntryCompletion, except it already does all of the setup for the
- * completion.  You can also filter by a #PurpleAccount to limit what's shown.
- *
- * |[<!-- language="C" -->
- * GtkWidget *entry = gtk_entry_new();
- * GtkEntryCompletion *completion = pidgin_contact_completion_new();
- *
- * gtk_entry_set_completion(GTK_ENTRY(entry), completion);
- * pidgin_contact_completion_set_account(PIDGIN_CONTACT_COMPLETION(completion), account);
- * g_object_unref(completion);
- * ]|
- */
-
-#define PIDGIN_TYPE_CONTACT_COMPLETION  pidgin_contact_completion_get_type()
-
-G_DECLARE_FINAL_TYPE(PidginContactCompletion, pidgin_contact_completion, PIDGIN,
-		CONTACT_COMPLETION, GtkEntryCompletion)
-
-/**
- * pidgin_contact_completion_new:
- *
- * Creates a new #GtkEntryCompletion for looking up contacts.
- *
- * Returns: (transfer full): The new #GtkEntryCompletion instance.
- *
- * Since: 3.0.0
- */
-GtkEntryCompletion *pidgin_contact_completion_new(void);
-
-/**
- * pidgin_contact_completion_get_account:
- * @completion: The #PidginContactCompletion instance.
- *
- * Gets the account that @completion is filtering for.  If no filtering is set
- * %NULL will be returned.
- *
- * Returns: (transfer full) (nullable): The #PurpleAccount that's being
- *          filtered for.
- *
- * Since: 3.0.0
- */
-PurpleAccount *pidgin_contact_completion_get_account(PidginContactCompletion *completion);
-
-/**
- * pidgin_contact_completion_set_account:
- * @completion: The #PidginContactCompletion instance.
- * @account: (nullable): The #PurpleAccount to filter for or %NULL.
- *
- * Set the #PurpleAccount that @completion should filter for.  If @account is
- * %NULL, all filtering will be disabled.
- *
- * Since: 3.0.0
- */
-void pidgin_contact_completion_set_account(PidginContactCompletion *completion, PurpleAccount *account);
-
-G_END_DECLS
-
-#endif /* PIDGIN_CONTACT_COMPLETION_H */
--- a/pidgin/pidgininvitedialog.c	Mon Apr 04 23:15:13 2022 -0500
+++ b/pidgin/pidgininvitedialog.c	Mon Apr 04 23:56:44 2022 -0500
@@ -18,7 +18,6 @@
  */
 
 #include "pidgininvitedialog.h"
-#include "pidgincontactcompletion.h"
 
 struct _PidginInviteDialog {
 	GtkDialog parent;
@@ -137,34 +136,6 @@
 }
 
 static void
-pidgin_invite_dialog_constructed(GObject *obj) {
-	PidginInviteDialog *dialog = PIDGIN_INVITE_DIALOG(obj);
-	PidginInviteDialogPrivate *priv = NULL;
-	GtkEntryCompletion *completion = NULL;
-
-	priv = pidgin_invite_dialog_get_instance_private(dialog);
-
-	completion = pidgin_contact_completion_new();
-
-	/* constructed is called after all properties are set, so we set the
-	 * account for the completion from the conversation we were created with.
-	 */
-	if(priv->conversation) {
-		PurpleAccount *account = purple_conversation_get_account(PURPLE_CONVERSATION(priv->conversation));
-
-		if(account != NULL) {
-			pidgin_contact_completion_set_account(
-				PIDGIN_CONTACT_COMPLETION(completion),
-				account
-			);
-		}
-	}
-
-	gtk_entry_set_completion(GTK_ENTRY(priv->contact), completion);
-	g_object_unref(completion);
-}
-
-static void
 pidgin_invite_dialog_class_init(PidginInviteDialogClass *klass) {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
@@ -172,7 +143,6 @@
 	obj_class->get_property = pidgin_invite_dialog_get_property;
 	obj_class->set_property = pidgin_invite_dialog_set_property;
 	obj_class->finalize = pidgin_invite_dialog_finalize;
-	obj_class->constructed = pidgin_invite_dialog_constructed;
 
 	gtk_widget_class_set_template_from_resource(
 		widget_class,
--- a/po/POTFILES.in	Mon Apr 04 23:15:13 2022 -0500
+++ b/po/POTFILES.in	Mon Apr 04 23:56:44 2022 -0500
@@ -348,7 +348,6 @@
 pidgin/pidginclosebutton.c
 pidgin/pidgincolor.c
 pidgin/pidgincommands.c
-pidgin/pidgincontactcompletion.c
 pidgin/pidgincontactlist.c
 pidgin/pidginconversationwindow.c
 pidgin/pidgindebug.c

mercurial