grim/testing

Bootstrap the account assistant
draft default tip
2021-06-08, Gary Kramlich
de822751b911
Parents 1c25eac61c19
Children
Bootstrap the account assistant
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/assistant/pidginaccountassistant.c Tue Jun 08 15:37:38 2021 -0500
@@ -0,0 +1,107 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * 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, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <purple.h>
+
+#include "pidginaccountassistant.h"
+
+struct _PidginAccountAssistant {
+ GtkAssistant parent;
+};
+
+G_DEFINE_TYPE(PidginAccountAssistant, pidgin_account_assistant,
+ GTK_TYPE_ASSISTANT)
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static GtkWidget *account_assistant = NULL;
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static void
+pidgin_account_assistant_close(PidginAccountAssistant *assistant) {
+ gtk_widget_destroy(GTK_WIDGET(assistant));
+
+ /* This should never be false, but just in case some manually creates an
+ * instance with g_object_new we shouldn't nuke our global instance.
+ */
+ if(account_assistant == GTK_WIDGET(assistant)) {
+ account_assistant = NULL;
+ }
+}
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static void
+pidgin_account_assistant_cancel_cb(GtkAssistant *assistant, gpointer data) {
+ pidgin_account_assistant_close(PIDGIN_ACCOUNT_ASSISTANT(assistant));
+}
+
+static gboolean
+pidgin_account_assistant_delete_cb(GtkWidget *widget, GdkEvent *event,
+ gpointer data)
+{
+ pidgin_account_assistant_close(PIDGIN_ACCOUNT_ASSISTANT(widget));
+
+ return FALSE;
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+pidgin_account_assistant_init(PidginAccountAssistant *assistant)
+{
+ gtk_widget_init_template(GTK_WIDGET(assistant));
+}
+
+static void
+pidgin_account_assistant_class_init(PidginAccountAssistantClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ gtk_widget_class_set_template_from_resource(
+ widget_class,
+ "/im/pidgin/Pidgin/Assistant/accountassistant.ui"
+ );
+
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_account_assistant_delete_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_account_assistant_cancel_cb);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+void
+pidgin_account_assistant_show(void) {
+ if(!PIDGIN_IS_ACCOUNT_ASSISTANT(account_assistant)) {
+ account_assistant = GTK_WIDGET(g_object_new(PIDGIN_TYPE_ACCOUNT_ASSISTANT,
+ NULL));
+ }
+
+ gtk_widget_show(account_assistant);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/assistant/pidginaccountassistant.h Tue Jun 08 15:37:38 2021 -0500
@@ -0,0 +1,75 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * 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, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
+# error "only <pidgin.h> may be included directly"
+#endif
+
+#ifndef PIDGIN_ACCOUNT_ASSISTANT_H
+#define PIDGIN_ACCOUNT_ASSISTANT_H
+
+/**
+ * SECTION:pidginaccountassistant
+ * @section_id: pidgin-pidginaccountassistant
+ * @short_description: The account assistant
+ * @title: Account Assistant widget
+ *
+ * #PidginAccountAssistant is a widget that helps users create accounts.
+ */
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/**
+ * PIDGIN_TYPE_ACCOUNT_ASSISTANT:
+ *
+ * The standard _get_type macro for #PidginAccountAssistant.
+ *
+ * Since: 3.0.0
+ */
+#define PIDGIN_TYPE_ACCOUNT_ASSISTANT (pidgin_account_assistant_get_type())
+G_DECLARE_FINAL_TYPE(PidginAccountAssistant, pidgin_account_assistant,
+ PIDGIN, ACCOUNT_ASSISTANT, GtkAssistant)
+
+/**
+ * PidginAccountAssistant:
+ *
+ * A widget that displays a credential provider.
+ *
+ * Since: 3.0.0
+ */
+
+/**
+ * pidgin_account_assistant_show:
+ *
+ * Displays the account assistant.
+ *
+ * Since: 3.0.0
+ */
+void pidgin_account_assistant_show(void);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ACCOUNT_ASSISTANT_H */
--- a/pidgin/meson.build Tue Jun 08 01:45:21 2021 -0500
+++ b/pidgin/meson.build Tue Jun 08 15:37:38 2021 -0500
@@ -1,4 +1,5 @@
libpidgin_SOURCES = [
+ 'assistant/pidginaccountassistant.c',
'pidginstock.c',
'gtkaccount.c',
'gtkblist.c',
@@ -69,6 +70,7 @@
]
libpidgin_headers = [
+ 'assistant/pidginaccountassistant.h',
'gtkaccount.h',
'gtkblist.h',
'gtkconn.h',
--- a/pidgin/pidginapplication.c Tue Jun 08 01:45:21 2021 -0500
+++ b/pidgin/pidginapplication.c Tue Jun 08 15:37:38 2021 -0500
@@ -35,6 +35,7 @@
#include "pidginapplication.h"
+#include "assistant/pidginaccountassistant.h"
#include "gtkaccount.h"
#include "gtkblist.h"
#include "gtkdialogs.h"
@@ -176,6 +177,13 @@
}
static void
+pidgin_application_account_assistant(GSimpleAction *simple, GVariant *parameter,
+ gpointer data)
+{
+ pidgin_account_assistant_show();
+}
+
+static void
pidgin_application_add_chat(GSimpleAction *simple, GVariant *parameter,
gpointer data)
{
@@ -310,6 +318,9 @@
.name = "add-buddy",
.activate = pidgin_application_add_buddy,
}, {
+ .name = "account-assistant",
+ .activate = pidgin_application_account_assistant,
+ }, {
.name = "add-chat",
.activate = pidgin_application_add_chat,
}, {
--- a/pidgin/resources/Accounts/menu.ui Tue Jun 08 01:45:21 2021 -0500
+++ b/pidgin/resources/Accounts/menu.ui Tue Jun 08 15:37:38 2021 -0500
@@ -40,18 +40,21 @@
</object>
</child>
<child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="action-name">app.account-assistant</property>
+ <property name="label" translatable="yes">Account Assistant</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="enable_account">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Enable Account</property>
<property name="use-underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="disabled_menu">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- </object>
- </child>
</object>
</child>
<child>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Assistant/accountassistant.ui Tue Jun 08 15:37:38 2021 -0500
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <template class="PidginAccountAssistant" parent="GtkAssistant">
+ <property name="can-focus">False</property>
+ <signal name="cancel" handler="pidgin_account_assistant_cancel_cb" swapped="no"/>
+ <signal name="delete-event" handler="pidgin_account_assistant_delete_cb" swapped="no"/>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Introduction page</property>
+ </object>
+ <packing>
+ <property name="page-type">intro</property>
+ <property name="has-padding">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Content page</property>
+ </object>
+ <packing>
+ <property name="has-padding">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Confirmation page</property>
+ </object>
+ <packing>
+ <property name="page-type">confirm</property>
+ <property name="has-padding">False</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="margin-left">6</property>
+ <property name="margin-right">6</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">6</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+ <property name="spacing">6</property>
+ </object>
+ <packing>
+ <property name="has-padding">False</property>
+ </packing>
+ </child>
+ </template>
+</interface>
--- a/pidgin/resources/pidgin.gresource.xml Tue Jun 08 01:45:21 2021 -0500
+++ b/pidgin/resources/pidgin.gresource.xml Tue Jun 08 15:37:38 2021 -0500
@@ -9,6 +9,7 @@
<file compressed="true">Accounts/chooser.ui</file>
<file compressed="true">Accounts/entry.css</file>
<file compressed="true">Accounts/menu.ui</file>
+ <file compressed="true">Assistant/accountassistant.ui</file>
<file compressed="true">Avatar/avatar.ui</file>
<file compressed="true">Avatar/menu.ui</file>
<file compressed="true">BuddyList/window.ui</file>