messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit 8e553e0324a970fb847b827b8f47f2d7c7b4f76a
parent ee55ecb8712955fc1d982b3a271c909896eb0631
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Sun, 31 Oct 2021 00:49:51 +0200

Added area optimization for mobile usage

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Mresources/ui/messenger.ui | 57+++++++++++++++++++++------------------------------------
Msrc/application.c | 14++++++++++----
Msrc/application.h | 2++
Msrc/event.c | 8+++-----
Msrc/ui/messenger.c | 12++++++++++++
5 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/resources/ui/messenger.ui b/resources/ui/messenger.ui @@ -884,6 +884,26 @@ Author: Tobias Frisch <property name="margin-bottom">8</property> <property name="spacing">8</property> <child> + <object class="GtkButton" id="back_button"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="relief">none</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">go-previous-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -927,7 +947,7 @@ Author: Tobias Frisch <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> @@ -951,27 +971,6 @@ Author: Tobias Frisch <property name="position">1</property> </packing> </child> - <child> - <object class="GtkButton"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="relief">none</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="icon-name">system-search-symbolic</property> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack-type">end</property> - <property name="position">2</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> @@ -1688,20 +1687,6 @@ Author: Tobias Frisch <property name="title" translatable="yes">Messenger</property> <property name="subtitle" translatable="yes">GNUnet</property> <property name="interpolate-size">True</property> - <child> - <object class="GtkButton" id="back_button"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="icon-name">go-previous-symbolic</property> - </object> - </child> - </object> - </child> </object> </child> </object> diff --git a/src/application.c b/src/application.c @@ -58,6 +58,16 @@ application_init(MESSENGER_Application *app, app->chat.tid = 0; app->chat.signal = MESSENGER_NONE; + app->ui.mobile = FALSE; + + for (int i = 0; i < app->argc; i++) { + if (0 == strcmp("--mobile", app->argv[i])) + { + app->ui.mobile = TRUE; + break; + } + } + ui_messenger_init(app, &(app->ui.messenger)); } @@ -102,8 +112,6 @@ typedef struct MESSENGER_ApplicationEventCall static gboolean _application_event_call(gpointer user_data) { - //printf("_application_event_call\n"); - MESSENGER_ApplicationEventCall *call; call = (MESSENGER_ApplicationEventCall*) user_data; @@ -117,8 +125,6 @@ void application_call_event(MESSENGER_Application *app, MESSENGER_ApplicationEvent event) { - //printf("application_call_event\n"); - MESSENGER_ApplicationEventCall *call; call = (MESSENGER_ApplicationEventCall*) GNUNET_malloc( diff --git a/src/application.h b/src/application.h @@ -55,6 +55,8 @@ typedef struct MESSENGER_Application } chat; struct { + gboolean mobile; + UI_MESSENGER_Handle messenger; } ui; } MESSENGER_Application; diff --git a/src/event.c b/src/event.c @@ -27,15 +27,13 @@ void event_update_profile(MESSENGER_Application *app) { - //printf("event_update_profile\n"); + UI_MESSENGER_Handle* ui = &(app->ui.messenger); const char *name = GNUNET_CHAT_get_name(app->chat.messenger.handle); - //printf("A: %s\n", name); - if (name) { - hdy_avatar_set_text(app->ui.messenger.profile_avatar, name); - gtk_label_set_text(app->ui.messenger.profile_label, name); + hdy_avatar_set_text(ui->profile_avatar, name); + gtk_label_set_text(ui->profile_label, name); } } diff --git a/src/ui/messenger.c b/src/ui/messenger.c @@ -118,6 +118,18 @@ ui_messenger_init(MESSENGER_Application *app, gtk_builder_get_object(builder, "leaflet_chat") ); + if (app->ui.mobile) + { + g_object_bind_property( + handle->leaflet_chat, + "folded", + handle->title_bar, + "visible", + G_BINDING_SYNC_CREATE | + G_BINDING_INVERT_BOOLEAN + ); + } + hdy_leaflet_set_homogeneous(handle->leaflet_chat, FALSE, GTK_ORIENTATION_HORIZONTAL, FALSE); handle->chats_listbox = GTK_LIST_BOX(