diff options
author | Gary Kramlich <grim@reaperworld.com> | 2019-04-23 16:04:12 -0500 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2019-04-23 16:04:12 -0500 |
commit | edd8a6ccb5ce208602563b244f4b39dbff500114 (patch) | |
tree | ce0012248033935894497f6718ab9e8164d738ce | |
parent | fc156d80732d401fa641ebbe42ee03633b26d7e4 (diff) | |
download | pidgin-edd8a6ccb5ce208602563b244f4b39dbff500114.tar.gz |
Start of the new invite widget
-rw-r--r-- | pidgin/pidgininvitedialog.c | 201 | ||||
-rw-r--r-- | pidgin/pidgininvitedialog.h | 29 | ||||
-rw-r--r-- | pidgin/resources/Conversations/invite_dialog.ui | 134 |
3 files changed, 364 insertions, 0 deletions
diff --git a/pidgin/pidgininvitedialog.c b/pidgin/pidgininvitedialog.c new file mode 100644 index 0000000000..0942d68732 --- /dev/null +++ b/pidgin/pidgininvitedialog.c @@ -0,0 +1,201 @@ +/* Purple 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 "pidgininvitedialog.h" + +struct _PidginInviteDialog { + GtkDialog parent; +}; + +typedef struct { + gchar *contact; + gchar *message; +} PidginInviteDialogPrivate; + +enum { + PROP_ZERO, + PROP_CONTACT, + PROP_MESSAGE, + N_PROPERTIES, +}; + +static GParamSpec *properties[N_PROPERTIES] = {}; + +G_DEFINE_TYPE_WITH_PRIVATE(PidginInviteDialog, pidgin_invite_dialog, GTK_TYPE_DIALOG); + +/****************************************************************************** + * GObject Stuff + *****************************************************************************/ +static void +pidgin_invite_dialog_get_property(GObject *obj, + guint param_id, + GValue *value, + GParamSpec *pspec) +{ + PidginInviteDialog *dialog = PIDGIN_INVITE_DIALOG(obj); + + switch(param_id) { + case PROP_CONTACT: + g_value_set_string(value, + pidgin_invite_dialog_get_contact(dialog)); + break; + case PROP_MESSAGE: + g_value_set_string(value, + pidgin_invite_dialog_get_message(dialog)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); + break; + } +} + +static void +pidgin_invite_dialog_set_property(GObject *obj, + guint param_id, + const GValue *value, + GParamSpec *pspec) +{ + PidginInviteDialog *dialog = PIDGIN_INVITE_DIALOG(obj); + + switch(param_id) { + case PROP_CONTACT: + pidgin_invite_dialog_set_contact(dialog, + g_value_get_string(value)); + break; + case PROP_MESSAGE: + pidgin_invite_dialog_set_message(dialog, + g_value_get_string(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); + break; + } +} + +static void +pidgin_invite_dialog_finalize(GObject *obj) { + PidginInviteDialogPrivate *priv = NULL; + + priv = pidgin_invite_dialog_get_instance_private(PIDGIN_INVITE_DIALOG(obj)); + + g_clear_pointer(&priv->contact, g_free); + g_clear_pointer(&priv->message, g_free); + + G_OBJECT_CLASS(pidgin_invite_dialog_parent_class)->finalize(obj); +} + +static void +pidgin_invite_dialog_init(PidginInviteDialog *dialog) { + gtk_widget_init_template(GTK_WIDGET(dialog)); +} + +static void +pidgin_invite_dialog_class_init(PidginInviteDialogClass *klass) { + GObjectClass *obj_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + + 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; + + gtk_widget_class_set_template_from_resource( + widget_class, + "/im/pidgin/Pidgin/Conversations/invite_dialog.ui" + ); + + properties[PROP_CONTACT] = g_param_spec_string( + "contact", + "contact", + "The person that is being invited", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + + properties[PROP_MESSAGE] = g_param_spec_string( + "message", + "message", + "The invite message to send", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + + g_object_class_install_properties(obj_class, N_PROPERTIES, properties); +} + +/****************************************************************************** + * Public API + *****************************************************************************/ +const gchar * +pidgin_invite_dialog_get_contact(PidginInviteDialog *dialog) { + PidginInviteDialogPrivate *priv = NULL; + + g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); + + priv = pidgin_invite_dialog_get_instance_private(dialog); + + return priv->contact; +} + +void +pidgin_invite_dialog_set_contact(PidginInviteDialog *dialog, + const gchar *contact) +{ + PidginInviteDialogPrivate *priv = NULL; + + g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); + + priv = pidgin_invite_dialog_get_instance_private(dialog); + + g_clear_pointer(&priv->contact, g_free); + + if(contact != NULL) { + priv->contact = g_strdup(contact); + } + + g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_CONTACT]); +} + +const gchar * +pidgin_invite_dialog_get_message(PidginInviteDialog *dialog) { + PidginInviteDialogPrivate *priv = NULL; + + g_return_val_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog), NULL); + + priv = pidgin_invite_dialog_get_instance_private(dialog); + + return priv->message; +} + +void +pidgin_invite_dialog_set_message(PidginInviteDialog *dialog, + const gchar *message) +{ + PidginInviteDialogPrivate *priv = NULL; + + g_return_if_fail(PIDGIN_IS_INVITE_DIALOG(dialog)); + + priv = pidgin_invite_dialog_get_instance_private(dialog); + + g_clear_pointer(&priv->message, g_free); + + if(message != NULL) { + priv->message = g_strdup(message); + } + + g_object_notify_by_pspec(G_OBJECT(dialog), properties[PROP_MESSAGE]); +} + diff --git a/pidgin/pidgininvitedialog.h b/pidgin/pidgininvitedialog.h new file mode 100644 index 0000000000..0907ae9924 --- /dev/null +++ b/pidgin/pidgininvitedialog.h @@ -0,0 +1,29 @@ +#ifndef PIDGIN_ABOUT_H +#define PIDGIN_ABOUT_H + +/** + * SECTION:pidgininvitedialog + * @section_id: pidgin-invite-dialog + * @short_description: <filename>pidgininvitedialog.h</filename> + * @title: Invite Dialog + */ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define PIDGIN_TYPE_INVITE_DIALOG pidgin_invite_dialog_get_type() +G_DECLARE_FINAL_TYPE(PidginInviteDialog, pidgin_invite_dialog, PIDGIN, + INVITE_DIALOG, GtkDialog) + +GtkWidget *pidgin_invite_dialog_new(); + +void pidgin_invite_dialog_set_contact(PidginInviteDialog *dialog, const gchar *contact); +const gchar *pidgin_invite_dialog_get_contact(PidginInviteDialog *dialog); + +void pidgin_invite_dialog_set_message(PidginInviteDialog *dialog, const gchar *message); +const gchar * pidgin_invite_dialog_get_message(PidginInviteDialog *dialog); + +G_END_DECLS + +#endif /* PIDGIN_INVITE_H */ diff --git a/pidgin/resources/Conversations/invite_dialog.ui b/pidgin/resources/Conversations/invite_dialog.ui new file mode 100644 index 0000000000..4a465ae469 --- /dev/null +++ b/pidgin/resources/Conversations/invite_dialog.ui @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface> + <requires lib="gtk+" version="3.20"/> + <template class="PidginInviteDialog" parent="GtkDialog"> + <property name="can_focus">False</property> + <property name="border_width">12</property> + <property name="title" translatable="yes">Invite to conversation...</property> + <property name="resizable">False</property> + <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button1"> + <property name="label" translatable="yes">Cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button2"> + <property name="label" translatable="yes">Invite</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_bottom">6</property> + <property name="row_spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Please enter the name of the user you wish to invite, along with an optional invite message.</property> + <property name="wrap">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Contact:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Message:</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="contact"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="message"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-6">button1</action-widget> + <action-widget response="-3">button2</action-widget> + </action-widgets> + </template> +</interface> |