Skip to content

Commit

Permalink
Implement dialog to add tags to messages
Browse files Browse the repository at this point in the history
Signed-off-by: Jacki <[email protected]>
  • Loading branch information
TheJackiMonster committed Mar 22, 2024
1 parent a37289b commit 673f848
Show file tree
Hide file tree
Showing 14 changed files with 816 additions and 25 deletions.
4 changes: 3 additions & 1 deletion resources/ui.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
<file compressed="true">ui/message-sent.ui</file>
<file compressed="true">ui/message-status.ui</file>
<file compressed="true">ui/messenger.ui</file>
<file compressed="true">ui/new_account.ui</file>
<file compressed="true">ui/new_contact.ui</file>
<file compressed="true">ui/new_group.ui</file>
<file compressed="true">ui/new_lobby.ui</file>
<file compressed="true">ui/new_platform.ui</file>
<file compressed="true">ui/new_account.ui</file>
<file compressed="true">ui/new_tag.ui</file>
<file compressed="true">ui/picker.ui</file>
<file compressed="true">ui/play_media.ui</file>
<file compressed="true">ui/account_entry.ui</file>
<file compressed="true">ui/send_file.ui</file>
<file compressed="true">ui/settings.ui</file>
<file compressed="true">ui/tag.ui</file>
</gresource>
</gresources>
133 changes: 133 additions & 0 deletions resources/ui/new_tag.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0
Copyright (C) 2024 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="GtkDialog" id="new_tag_dialog">
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="window-position">center-on-parent</property>
<property name="type-hint">dialog</property>
<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="cancel_button">
<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="confirm_button">
<property name="label" translatable="yes">Confirm</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="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="border-width">8</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="HdyAvatar" id="tag_avatar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
<property name="icon-name">user-bookmarks-symbolic</property>
<property name="size">128</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Tag:</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="tag_entry">
<property name="width-request">250</property>
<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="position">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>
</object>
</interface>
34 changes: 34 additions & 0 deletions resources/ui/tag.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0
Copyright (C) 2024 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"/>
<object class="GtkLabel" id="tag_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="ellipsize">end</property>
<property name="single-line-mode">True</property>
<style>
<class name="tag-label"/>
</style>
</object>
</interface>
4 changes: 3 additions & 1 deletion src/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "ui/new_group.h"
#include "ui/new_lobby.h"
#include "ui/new_platform.h"
#include "ui/new_tag.h"
#include "ui/play_media.h"
#include "ui/send_file.h"
#include "ui/settings.h"
Expand Down Expand Up @@ -124,11 +125,12 @@ typedef struct MESSENGER_Application
UI_SEND_FILE_Handle send_file;
UI_PLAY_MEDIA_Handle play_media;

UI_NEW_ACCOUNT_Handle new_account;
UI_NEW_CONTACT_Handle new_contact;
UI_NEW_GROUP_Handle new_group;
UI_NEW_LOBBY_Handle new_lobby;
UI_NEW_PLATFORM_Handle new_platform;
UI_NEW_ACCOUNT_Handle new_account;
UI_NEW_TAG_Handle new_tag;

UI_ACCOUNTS_Handle accounts;
UI_CONTACTS_Handle contacts;
Expand Down
19 changes: 19 additions & 0 deletions src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "ui.h"

#include <gnunet/gnunet_common.h>

void
ui_label_set_text(GtkLabel *label, const char *text)
{
Expand Down Expand Up @@ -56,6 +58,23 @@ ui_entry_set_text(GtkEntry *entry, const char *text)
g_free(_text);
}

char*
ui_entry_get_text(GtkEntry *entry)
{
g_assert(entry);

const gchar *text = gtk_entry_get_text(entry);

if (!text)
return NULL;

gchar *_text = g_locale_from_utf8(text, -1, NULL, NULL, NULL);
char *result = GNUNET_strdup(_text);
g_free(_text);

return result;
}

void
ui_avatar_set_text(HdyAvatar *avatar, const char *text)
{
Expand Down
9 changes: 9 additions & 0 deletions src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ void
ui_entry_set_text(GtkEntry *entry,
const char *text);

/**
* Returns the text from a GtkEntry applying automatic
* inverse utf8 conversion.
*
* @param entry Entry
*/
char*
ui_entry_get_text(GtkEntry *entry);

/**
* Sets the text of a HdyAvatar applying automatic utf8
* conversion.
Expand Down
Loading

0 comments on commit 673f848

Please sign in to comment.