# HG changeset patch # User Elliott Sales de Andrade # Date 1652429796 18000 # Node ID 54d7cfc990eb6e0fa3ff4981e5e24be5bdb2267b # Parent 789f96848a43906858ee0ddffd647bb34798f872 Split away/idle prefs into a separate widget I didn't do any re-designing, but did change `GtkFrame` to `HdyPreferencesGroup`, as that allowed using a `HdyPreferencesPage` like with the credentials page. Testing Done: Opened Preferences and didn't see any errors. Also, changed all settings and saw that debug log showed they were changed and prefs were re-saving. Reviewed at https://reviews.imfreedom.org/r/1435/ diff -r 789f96848a43 -r 54d7cfc990eb pidgin/meson.build --- a/pidgin/meson.build Fri May 13 00:39:03 2022 -0500 +++ b/pidgin/meson.build Fri May 13 03:16:36 2022 -0500 @@ -60,6 +60,7 @@ 'pidginstylecontext.c', 'pidgintalkatu.c', 'prefs/pidginprefs.c', + 'prefs/pidginawaypage.c', 'prefs/pidgincredentialproviderrow.c', 'prefs/pidgincredentialspage.c', ] @@ -128,6 +129,7 @@ libpidgin_prefs_headers = [ 'prefs/pidginprefs.h', + 'prefs/pidginawaypage.h', 'prefs/pidgincredentialproviderrow.h', 'prefs/pidgincredentialspage.h', ] diff -r 789f96848a43 -r 54d7cfc990eb pidgin/prefs/pidginawaypage.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/prefs/pidginawaypage.c Fri May 13 03:16:36 2022 -0500 @@ -0,0 +1,149 @@ +/* + * Pidgin - Internet Messenger + * Copyright (C) Pidgin Developers + * + * 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 . + */ + +#include + +#include + +#include "pidginawaypage.h" +#include "gtksavedstatuses.h" +#include "gtkutils.h" +#include "pidginprefsinternal.h" + +struct _PidginAwayPage { + HdyPreferencesPage parent; + + PidginPrefCombo idle_reporting; + GtkWidget *mins_before_away; + GtkWidget *idle_hbox; + GtkWidget *away_when_idle; + PidginPrefCombo auto_reply; + GtkWidget *startup_current_status; + GtkWidget *startup_hbox; + GtkWidget *startup_label; +}; + +G_DEFINE_TYPE(PidginAwayPage, pidgin_away_page, HDY_TYPE_PREFERENCES_PAGE) + +/****************************************************************************** + * Helpers + *****************************************************************************/ +static void +set_idle_away(PurpleSavedStatus *status) +{ + purple_prefs_set_int("/purple/savedstatus/idleaway", + purple_savedstatus_get_creation_time(status)); +} + +static void +set_startupstatus(PurpleSavedStatus *status) +{ + purple_prefs_set_int("/purple/savedstatus/startup", + purple_savedstatus_get_creation_time(status)); +} + +/****************************************************************************** + * GObject Implementation + *****************************************************************************/ +static void +pidgin_away_page_class_init(PidginAwayPageClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + + gtk_widget_class_set_template_from_resource( + widget_class, + "/im/pidgin/Pidgin3/Prefs/away.ui" + ); + + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, idle_reporting.combo); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, mins_before_away); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, away_when_idle); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, idle_hbox); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, auto_reply.combo); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, startup_current_status); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, startup_hbox); + gtk_widget_class_bind_template_child( + widget_class, PidginAwayPage, startup_label); +} + +static void +pidgin_away_page_init(PidginAwayPage *page) +{ + GtkWidget *menu; + + gtk_widget_init_template(GTK_WIDGET(page)); + + page->idle_reporting.type = PURPLE_PREF_STRING; + page->idle_reporting.key = "/purple/away/idle_reporting"; + pidgin_prefs_bind_dropdown(&page->idle_reporting); + + pidgin_prefs_bind_spin_button("/purple/away/mins_before_away", + page->mins_before_away); + + pidgin_prefs_bind_checkbox("/purple/away/away_when_idle", + page->away_when_idle); + + /* TODO: Show something useful if we don't have any saved statuses. */ + menu = pidgin_status_menu(purple_savedstatus_get_idleaway(), + G_CALLBACK(set_idle_away)); + gtk_widget_show_all(menu); + gtk_box_pack_start(GTK_BOX(page->idle_hbox), menu, FALSE, FALSE, 0); + + g_object_bind_property(page->away_when_idle, "active", + menu, "sensitive", + G_BINDING_SYNC_CREATE); + + /* Away stuff */ + page->auto_reply.type = PURPLE_PREF_STRING; + page->auto_reply.key = "/purple/away/auto_reply"; + pidgin_prefs_bind_dropdown(&page->auto_reply); + + /* Signon status stuff */ + pidgin_prefs_bind_checkbox("/purple/savedstatus/startup_current_status", + page->startup_current_status); + + /* TODO: Show something useful if we don't have any saved statuses. */ + menu = pidgin_status_menu(purple_savedstatus_get_startup(), + G_CALLBACK(set_startupstatus)); + gtk_widget_show_all(menu); + gtk_box_pack_start(GTK_BOX(page->startup_hbox), menu, FALSE, FALSE, 0); + gtk_label_set_mnemonic_widget(GTK_LABEL(page->startup_label), menu); + pidgin_set_accessible_label(menu, GTK_LABEL(page->startup_label)); + g_object_bind_property(page->startup_current_status, "active", + page->startup_hbox, "sensitive", + G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); +} + +/****************************************************************************** + * API + *****************************************************************************/ +GtkWidget * +pidgin_away_page_new(void) { + return GTK_WIDGET(g_object_new(PIDGIN_TYPE_AWAY_PAGE, NULL)); +} diff -r 789f96848a43 -r 54d7cfc990eb pidgin/prefs/pidginawaypage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/prefs/pidginawaypage.h Fri May 13 03:16:36 2022 -0500 @@ -0,0 +1,62 @@ +/* + * Pidgin - Internet Messenger + * Copyright (C) Pidgin Developers + * + * 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 . + */ + +#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) +# error "only may be included directly" +#endif + +#ifndef PIDGIN_AWAY_PAGE_H +#define PIDGIN_AWAY_PAGE_H + +#include + +#include +#include + +G_BEGIN_DECLS + +/** + * PidginAwayPage: + * + * #PidginAwayPage is a widget for the preferences window to let users + * choose and configure their away and idle settings. + * + * Since: 3.0.0 + */ +#define PIDGIN_TYPE_AWAY_PAGE (pidgin_away_page_get_type()) +G_DECLARE_FINAL_TYPE(PidginAwayPage, pidgin_away_page, + PIDGIN, AWAY_PAGE, HdyPreferencesPage) + +/** + * pidgin_away_page_new: + * + * Creates a new #PidginAwayPage instance. + * + * Returns: (transfer full): The new #PidginAwayPage instance. + * + * Since: 3.0.0 + */ +GtkWidget *pidgin_away_page_new(void); + +G_END_DECLS + +#endif /* PIDGIN_AWAY_PAGE_H */ diff -r 789f96848a43 -r 54d7cfc990eb pidgin/prefs/pidginprefs.c --- a/pidgin/prefs/pidginprefs.c Fri May 13 00:39:03 2022 -0500 +++ b/pidgin/prefs/pidginprefs.c Fri May 13 03:16:36 2022 -0500 @@ -37,7 +37,6 @@ #include "gtkblist.h" #include "gtkconv.h" #include "gtkdialogs.h" -#include "gtksavedstatuses.h" #include "gtkutils.h" #include "pidgincore.h" #include "pidgindebug.h" @@ -106,18 +105,6 @@ GtkWidget *password; } proxy; - /* Away page */ - struct { - PidginPrefCombo idle_reporting; - GtkWidget *mins_before_away; - GtkWidget *idle_hbox; - GtkWidget *away_when_idle; - PidginPrefCombo auto_reply; - GtkWidget *startup_current_status; - GtkWidget *startup_hbox; - GtkWidget *startup_label; - } away; - #ifdef USE_VV /* Voice/Video page */ struct { @@ -1048,63 +1035,6 @@ } } -static void -set_idle_away(PurpleSavedStatus *status) -{ - purple_prefs_set_int("/purple/savedstatus/idleaway", purple_savedstatus_get_creation_time(status)); -} - -static void -set_startupstatus(PurpleSavedStatus *status) -{ - purple_prefs_set_int("/purple/savedstatus/startup", purple_savedstatus_get_creation_time(status)); -} - -static void -bind_away_page(PidginPrefsWindow *win) -{ - GtkWidget *menu; - - /* Idle stuff */ - win->away.idle_reporting.type = PURPLE_PREF_STRING; - win->away.idle_reporting.key = "/purple/away/idle_reporting"; - pidgin_prefs_bind_dropdown(&win->away.idle_reporting); - - pidgin_prefs_bind_spin_button("/purple/away/mins_before_away", - win->away.mins_before_away); - - pidgin_prefs_bind_checkbox("/purple/away/away_when_idle", - win->away.away_when_idle); - - /* TODO: Show something useful if we don't have any saved statuses. */ - menu = pidgin_status_menu(purple_savedstatus_get_idleaway(), G_CALLBACK(set_idle_away)); - gtk_widget_show_all(menu); - gtk_box_pack_start(GTK_BOX(win->away.idle_hbox), menu, FALSE, FALSE, 0); - - g_object_bind_property(win->away.away_when_idle, "active", - menu, "sensitive", - G_BINDING_SYNC_CREATE); - - /* Away stuff */ - win->away.auto_reply.type = PURPLE_PREF_STRING; - win->away.auto_reply.key = "/purple/away/auto_reply"; - pidgin_prefs_bind_dropdown(&win->away.auto_reply); - - /* Signon status stuff */ - pidgin_prefs_bind_checkbox("/purple/savedstatus/startup_current_status", - win->away.startup_current_status); - - /* TODO: Show something useful if we don't have any saved statuses. */ - menu = pidgin_status_menu(purple_savedstatus_get_startup(), G_CALLBACK(set_startupstatus)); - gtk_widget_show_all(menu); - gtk_box_pack_start(GTK_BOX(win->away.startup_hbox), menu, FALSE, FALSE, 0); - gtk_label_set_mnemonic_widget(GTK_LABEL(win->away.startup_label), menu); - pidgin_set_accessible_label(menu, GTK_LABEL(win->away.startup_label)); - g_object_bind_property(win->away.startup_current_status, "active", - win->away.startup_hbox, "sensitive", - G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); -} - #ifdef USE_VV static GList * get_vv_device_menuitems(PurpleMediaElementType type) @@ -1623,7 +1553,6 @@ bind_conv_page(win); bind_network_page(win); bind_proxy_page(win); - bind_away_page(win); #ifdef USE_VV vv = vv_page(win); gtk_container_add_with_properties(GTK_CONTAINER(stack), vv, "name", @@ -1744,28 +1673,6 @@ proxy_button_clicked_cb); gtk_widget_class_bind_template_callback(widget_class, proxy_print_option); - - /* Away page */ - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, - away.idle_reporting.combo); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, - away.mins_before_away); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, away.away_when_idle); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, away.idle_hbox); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, - away.auto_reply.combo); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, - away.startup_current_status); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, away.startup_hbox); - gtk_widget_class_bind_template_child( - widget_class, PidginPrefsWindow, away.startup_label); } static void diff -r 789f96848a43 -r 54d7cfc990eb pidgin/resources/Prefs/away.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/resources/Prefs/away.ui Fri May 13 03:16:36 2022 -0500 @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + Never + never + + + When away + away + + + When both away and idle + awayidle + + + + + + + + + + + + + Never + none + + + From last sent message + purple + + + Based on keyboard or mouse use + system + + + + + 1 + 1440 + 1 + 1 + 10 + + + + + + + + + + + + + diff -r 789f96848a43 -r 54d7cfc990eb pidgin/resources/Prefs/prefs.ui --- a/pidgin/resources/Prefs/prefs.ui Fri May 13 00:39:03 2022 -0500 +++ b/pidgin/resources/Prefs/prefs.ui Fri May 13 03:16:36 2022 -0500 @@ -27,57 +27,6 @@ - - - - - - - - - - Never - never - - - When away - away - - - When both away and idle - awayidle - - - - - - - - - - - - - Never - none - - - From last sent message - purple - - - Based on keyboard or mouse use - system - - - - - 1 - 1440 - 1 - 1 - 10 - conversations.format_tag_table @@ -1264,329 +1213,9 @@ - + True False - 12 - vertical - 18 - - - True - False - 0 - none - - - True - False - 12 - - - True - False - vertical - 6 - - - True - False - 6 - - - True - False - _Report idle time: - True - away.idle_reporting.combo - 0 - - - False - True - 0 - - - - - True - False - away.idle_reporting.store - - - - 0 - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 6 - - - True - False - _Minutes before becoming idle: - True - away.mins_before_away - 0 - - - False - True - 0 - - - - - True - True - away.mins_before_away.adjustment - True - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 6 - - - Change to this status when _idle: - True - True - False - True - True - - - False - True - 0 - - - - - - - - False - True - 2 - - - - - - - - - True - False - Idle - - - - - - - - False - True - 0 - - - - - True - False - 0 - none - - - True - False - 12 - - - True - False - vertical - - - True - False - 6 - - - True - False - _Auto-reply: - True - away.auto_reply.combo - 0 - - - False - True - 0 - - - - - True - False - away.auto_reply.store - - - - 0 - - - - - False - True - 1 - - - - - False - True - 0 - - - - - - - - - True - False - Away - - - - - - - - False - True - 1 - - - - - True - False - 0 - none - - - True - False - 12 - - - True - False - vertical - 6 - - - Use status from last _exit at startup - True - True - False - True - True - - - False - True - 0 - - - - - True - False - 6 - - - True - False - Status to a_pply at startup: - True - 0 - - - False - True - 0 - - - - - - - - False - True - 1 - - - - - - - - - True - False - Status at Startup - - - - - - - - False - True - 2 - - away @@ -1625,16 +1254,6 @@ - - - - - - - - - - diff -r 789f96848a43 -r 54d7cfc990eb pidgin/resources/pidgin.gresource.xml --- a/pidgin/resources/pidgin.gresource.xml Fri May 13 00:39:03 2022 -0500 +++ b/pidgin/resources/pidgin.gresource.xml Fri May 13 03:16:36 2022 -0500 @@ -23,6 +23,7 @@ Log/log-viewer.ui Plugins/dialog.ui Plugins/menu.ui + Prefs/away.ui Prefs/credentials.ui Prefs/credentialprovider.ui Prefs/ip.css diff -r 789f96848a43 -r 54d7cfc990eb po/POTFILES.in --- a/po/POTFILES.in Fri May 13 00:39:03 2022 -0500 +++ b/po/POTFILES.in Fri May 13 03:16:36 2022 -0500 @@ -388,6 +388,7 @@ pidgin/plugins/unity.c pidgin/plugins/xmppconsole/console.ui pidgin/plugins/xmppconsole/xmppconsole.c +pidgin/prefs/pidginawaypage.c pidgin/prefs/pidgincredentialproviderrow.c pidgin/prefs/pidgincredentialspage.c pidgin/prefs/pidginprefs.c @@ -408,6 +409,7 @@ pidgin/resources/Log/log-viewer.ui pidgin/resources/Plugins/dialog.ui pidgin/resources/Plugins/menu.ui +pidgin/resources/Prefs/away.ui pidgin/resources/Prefs/credentialprovider.ui pidgin/resources/Prefs/credentials.ui pidgin/resources/Prefs/prefs.ui