commit 39f27418afa22e63019aa569473b0ee12ff7eb7d
parent fc7f147d38bd144d3868861e97923c87d9d1a283
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Sun, 21 Nov 2021 03:13:32 +0100
Added settings dialog
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
7 files changed, 929 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -14,7 +14,8 @@ SOURCES = messenger_gtk.c\
ui/message.c\
ui/messenger.c\
ui/new_contact.c\
- ui/new_platform.c
+ ui/new_platform.c\
+ ui/settings.c
HEADERS =
diff --git a/resources/css/style.css b/resources/css/style.css
@@ -45,3 +45,7 @@
padding: 2px 12px;
}
+.settings-entry {
+ margin: 8px;
+}
+
diff --git a/resources/ui/settings.ui b/resources/ui/settings.ui
@@ -0,0 +1,793 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Copyright (C) 2021 GNUnet e.V.
+
+GNUnet is free software: you can redistribute it and/or modify it
+under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+GNUnet 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
+Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+SPDX-License-Identifier: AGPL3.0-or-later
+Author: Tobias Frisch
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <requires lib="libhandy" version="1.2"/>
+ <object class="GtkListStore" id="delay_store">
+ <columns>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name value -->
+ <column type="gulong"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Off</col>
+ <col id="1">0</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">4 weeks</col>
+ <col id="1">2419200</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1 week</col>
+ <col id="1">604800</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1 day</col>
+ <col id="1">86400</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">8 hours</col>
+ <col id="1">28800</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1 hour</col>
+ <col id="1">3600</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">5 minutes</col>
+ <col id="1">300</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">30 seconds</col>
+ <col id="1">30</col>
+ </row>
+ </data>
+ </object>
+ <object class="HdyPreferencesWindow" id="settings_dialog">
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Settings</property>
+ <property name="modal">True</property>
+ <property name="window-position">center-on-parent</property>
+ <property name="type-hint">dialog</property>
+ <child>
+ <object class="HdyPreferencesPage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">preferences-system-symbolic</property>
+ <property name="title" translatable="yes">General</property>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">System</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Start on login</property>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Start on login</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Run in background</property>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Run in background</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesPage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">preferences-system-notifications-symbolic</property>
+ <property name="title" translatable="yes">Notifications</property>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Notifications</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Enable notifications</property>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Enable notifications</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Play notification sounds</property>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Play notification sounds</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesPage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">preferences-system-privacy-symbolic</property>
+ <property name="title" translatable="yes">Privacy</property>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Blocked</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">0 blocked contacts</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Messaging</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Send read receipts</property>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Send read receipts</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Show whispering</property>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Show whispering</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="draw-indicator">True</property>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Disappearing messages</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Default timer for new chats</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Default timer for new chats</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="model">delay_store</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">History</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Clear history automatically</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Clear history automatically</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="model">delay_store</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Clear all history</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <style>
+ <class name="delete-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesPage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="icon-name">preferences-system-network-symbolic</property>
+ <property name="title" translatable="yes">Network</property>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Invitations</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Automatically accept invitations</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Automatically accept invitations</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Clear invitations automatically</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Clear invitations automatically</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="model">delay_store</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Clear all invitations</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Clear all invitations</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <style>
+ <class name="delete-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Files</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Automatically accept files</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Automatically accept files</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Download folder</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Download folder</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Select download folder</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Delete files automatically</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Delete files automatically</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="model">delay_store</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Delete all files</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Delete all files</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <style>
+ <class name="delete-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Rooms</property>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Leave rooms automatically</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Leave rooms automatically</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="model">delay_store</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="HdyPreferencesRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="title" translatable="yes">Leave all rooms</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Leave all rooms</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <style>
+ <class name="delete-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="settings-entry"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/application.h b/src/application.h
@@ -33,6 +33,7 @@
#include "ui/messenger.h"
#include "ui/new_contact.h"
#include "ui/new_platform.h"
+#include "ui/settings.h"
#include "util.h"
@@ -70,6 +71,7 @@ typedef struct MESSENGER_Application
UI_NEW_CONTACT_Handle new_contact;
UI_NEW_PLATFORM_Handle new_platform;
UI_CONTACTS_Handle contacts;
+ UI_SETTINGS_Handle settings;
} ui;
} MESSENGER_Application;
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
@@ -31,6 +31,8 @@
#include "message.h"
#include "new_contact.h"
#include "new_platform.h"
+#include "settings.h"
+
#include "../application.h"
static void
@@ -108,6 +110,19 @@ handle_contacts_button_click(UNUSED GtkButton* button,
}
static void
+handle_settings_button_click(UNUSED GtkButton* button,
+ gpointer user_data)
+{
+ MESSENGER_Application *app = (MESSENGER_Application*) user_data;
+
+ hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE);
+
+ ui_settings_dialog_init(app, &(app->ui.settings));
+
+ gtk_widget_show(GTK_WIDGET(app->ui.settings.dialog));
+}
+
+static void
handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox,
GtkListBoxRow* row,
gpointer user_data)
@@ -282,6 +297,13 @@ ui_messenger_init(MESSENGER_Application *app,
app
);
+ g_signal_connect(
+ handle->settings_button,
+ "clicked",
+ G_CALLBACK(handle_settings_button_click),
+ app
+ );
+
handle->user_details_button = GTK_BUTTON(
gtk_builder_get_object(handle->builder, "user_details_button")
);
diff --git a/src/ui/settings.c b/src/ui/settings.c
@@ -0,0 +1,63 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet 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
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/*
+ * @author Tobias Frisch
+ * @file ui/settings.c
+ */
+
+#include "settings.h"
+
+#include "../application.h"
+
+static void
+handle_dialog_destroy(UNUSED GtkWidget *window,
+ gpointer user_data)
+{
+ ui_settings_dialog_cleanup((UI_SETTINGS_Handle*) user_data);
+}
+
+void
+ui_settings_dialog_init(MESSENGER_Application *app,
+ UI_SETTINGS_Handle *handle)
+{
+ handle->builder = gtk_builder_new_from_file("resources/ui/settings.ui");
+
+ handle->dialog = HDY_PREFERENCES_WINDOW(
+ gtk_builder_get_object(handle->builder, "settings_dialog")
+ );
+
+ gtk_window_set_transient_for(
+ GTK_WINDOW(handle->dialog),
+ GTK_WINDOW(app->ui.messenger.main_window)
+ );
+
+ g_signal_connect(
+ handle->dialog,
+ "destroy",
+ G_CALLBACK(handle_dialog_destroy),
+ handle
+ );
+}
+
+void
+ui_settings_dialog_cleanup(UI_SETTINGS_Handle *handle)
+{
+ g_object_unref(handle->builder);
+}
diff --git a/src/ui/settings.h b/src/ui/settings.h
@@ -0,0 +1,43 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet 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
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/*
+ * @author Tobias Frisch
+ * @file ui/settings.h
+ */
+
+#ifndef UI_SETTINGS_H_
+#define UI_SETTINGS_H_
+
+#include "messenger.h"
+
+typedef struct UI_SETTINGS_Handle
+{
+ GtkBuilder *builder;
+ HdyPreferencesWindow *dialog;
+} UI_SETTINGS_Handle;
+
+void
+ui_settings_dialog_init(MESSENGER_Application *app,
+ UI_SETTINGS_Handle *handle);
+
+void
+ui_settings_dialog_cleanup(UI_SETTINGS_Handle *handle);
+
+#endif /* UI_SETTINGS_H_ */