Commit 1d586175 authored by Mohammed Sadiq's avatar Mohammed Sadiq
Browse files

Port to libhandy-1

Fixes #401
parent 45ad2840
......@@ -9,7 +9,7 @@ Build-Depends:
desktop-file-utils,
libgtk-3-dev,
libfeedback-dev,
libhandy-0.0-dev (>= 0.0.10),
libhandy-1-dev (>= 1.0.0),
libebook-contacts1.2-dev,
libphonenumber-dev,
libpurple-dev,
......
......@@ -24,6 +24,7 @@
#define G_LOG_DOMAIN "chatty-application"
#include <glib/gi18n.h>
#include <handy.h>
#include "chatty-config.h"
#include "chatty-window.h"
......@@ -301,6 +302,8 @@ chatty_application_startup (GApplication *application)
G_APPLICATION_CLASS (chatty_application_parent_class)->startup (application);
hdy_init ();
g_set_application_name (_("Chats"));
lfb_init (CHATTY_APP_ID, NULL);
......
......@@ -88,7 +88,6 @@ struct _ChattyWindow
G_DEFINE_TYPE (ChattyWindow, chatty_window, GTK_TYPE_APPLICATION_WINDOW)
static void chatty_update_header (ChattyWindow *self);
static void chatty_window_show_new_muc_dialog (ChattyWindow *self);
......@@ -308,7 +307,7 @@ window_chat_name_matches (ChattyItem *item,
return FALSE;
}
if (hdy_leaflet_get_fold (HDY_LEAFLET (self->header_box)) == HDY_FOLD_FOLDED) {
if (hdy_leaflet_get_folded (HDY_LEAFLET (self->header_box))) {
GListModel *message_list;
guint n_items;
......@@ -408,18 +407,6 @@ window_chat_row_activated_cb (GtkListBox *box,
chatty_window_open_item (self, self->selected_item);
}
static void
header_visible_child_cb (GObject *sender,
GParamSpec *pspec,
ChattyWindow *self)
{
g_assert (CHATTY_IS_WINDOW (self));
chatty_update_header (self);
}
static void
window_search_changed_cb (ChattyWindow *self,
GtkEntry *entry)
......@@ -437,14 +424,14 @@ notify_fold_cb (GObject *sender,
GParamSpec *pspec,
ChattyWindow *self)
{
HdyFold fold = hdy_leaflet_get_fold (HDY_LEAFLET (self->header_box));
gboolean folded = hdy_leaflet_get_folded (HDY_LEAFLET (self->header_box));
if (fold == HDY_FOLD_FOLDED)
if (folded)
gtk_list_box_set_selection_mode (GTK_LIST_BOX (self->chats_listbox), GTK_SELECTION_NONE);
else
gtk_list_box_set_selection_mode (GTK_LIST_BOX (self->chats_listbox), GTK_SELECTION_SINGLE);
if (fold == HDY_FOLD_FOLDED) {
if (folded) {
window_set_item (self, NULL);
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->content_box), "sidebar");
} else if (self->selected_item) {
......@@ -454,7 +441,6 @@ notify_fold_cb (GObject *sender,
}
gtk_filter_changed (self->chat_filter, GTK_FILTER_CHANGE_DIFFERENT);
chatty_update_header (self);
}
......@@ -546,22 +532,6 @@ chatty_window_chat_list_select_first (ChattyWindow *self)
}
}
static void
chatty_update_header (ChattyWindow *self)
{
GtkWidget *header_child = hdy_leaflet_get_visible_child (HDY_LEAFLET (self->header_box));
HdyFold fold = hdy_leaflet_get_fold (HDY_LEAFLET (self->header_box));
g_assert (CHATTY_IS_WINDOW (self));
g_assert (header_child == NULL || GTK_IS_HEADER_BAR (header_child));
hdy_header_group_set_focus (HDY_HEADER_GROUP (self->header_group),
fold == HDY_FOLD_FOLDED ?
GTK_HEADER_BAR (header_child) : NULL);
}
static void
window_delete_buddy_clicked_cb (ChattyWindow *self)
{
......@@ -1033,7 +1003,6 @@ chatty_window_class_init (ChattyWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, window_add_in_contacts_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, window_leave_chat_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, window_delete_buddy_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, header_visible_child_cb);
gtk_widget_class_bind_template_callback (widget_class, window_search_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, window_chat_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, chatty_window_show_new_muc_dialog);
......
......@@ -16,13 +16,14 @@
#include "chatty-icons.h"
#include "chatty-list-row.h"
#include "chatty-manager.h"
#include "chatty-utils.h"
#include "purple.h"
#include "chatty-muc-info-dialog.h"
struct _ChattyMucInfoDialog
{
HdyDialog parent_instance;
GtkDialog parent_instance;
GtkWidget *button_back;
GtkWidget *button_invite_contact;
......@@ -53,7 +54,7 @@ struct _ChattyMucInfoDialog
};
G_DEFINE_TYPE (ChattyMucInfoDialog, chatty_muc_info_dialog, HDY_TYPE_DIALOG)
G_DEFINE_TYPE (ChattyMucInfoDialog, chatty_muc_info_dialog, GTK_TYPE_DIALOG)
static void chatty_muc_set_topic (ChattyMucInfoDialog *self);
......@@ -369,10 +370,6 @@ static void
chatty_muc_info_dialog_init (ChattyMucInfoDialog *self)
{
gtk_widget_init_template (GTK_WIDGET(self));
gtk_list_box_set_header_func (GTK_LIST_BOX(self->list_muc_settings),
hdy_list_box_separator_header,
NULL, NULL);
}
......
......@@ -7,13 +7,12 @@
#pragma once
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
G_BEGIN_DECLS
#define CHATTY_TYPE_MUC_INFO_DIALOG (chatty_muc_info_dialog_get_type())
G_DECLARE_FINAL_TYPE (ChattyMucInfoDialog, chatty_muc_info_dialog, CHATTY, MUC_INFO_DIALOG, HdyDialog)
G_DECLARE_FINAL_TYPE (ChattyMucInfoDialog, chatty_muc_info_dialog, CHATTY, MUC_INFO_DIALOG, GtkDialog)
GtkWidget *chatty_muc_info_dialog_new (GtkWindow *parent_window);
......
......@@ -38,7 +38,7 @@ static void chatty_new_chat_name_check (ChattyNewChatDialog *self,
struct _ChattyNewChatDialog
{
HdyDialog parent_instance;
GtkDialog parent_instance;
GtkWidget *chats_listbox;
GtkWidget *new_contact_row;
......@@ -74,7 +74,7 @@ struct _ChattyNewChatDialog
};
G_DEFINE_TYPE (ChattyNewChatDialog, chatty_new_chat_dialog, HDY_TYPE_DIALOG)
G_DEFINE_TYPE (ChattyNewChatDialog, chatty_new_chat_dialog, GTK_TYPE_DIALOG)
static gboolean
......@@ -420,7 +420,7 @@ chatty_new_chat_add_account_to_list (ChattyNewChatDialog *self,
g_return_if_fail (CHATTY_IS_NEW_CHAT_DIALOG (self));
row = hdy_action_row_new ();
row = HDY_ACTION_ROW (hdy_action_row_new ());
g_object_set_data (G_OBJECT (row),
"row-account",
(gpointer)account);
......@@ -450,7 +450,7 @@ chatty_new_chat_add_account_to_list (ChattyNewChatDialog *self,
(gpointer)prefix_radio_button);
hdy_action_row_add_prefix (row, GTK_WIDGET (prefix_radio_button ));
hdy_action_row_set_title (row, chatty_account_get_username (CHATTY_ACCOUNT (account)));
hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (row), chatty_account_get_username (CHATTY_ACCOUNT (account)));
gtk_container_add (GTK_CONTAINER (self->accounts_list), GTK_WIDGET (row));
......@@ -605,10 +605,6 @@ chatty_new_chat_dialog_init (ChattyNewChatDialog *self)
gtk_widget_init_template (GTK_WIDGET (self));
self->cancellable = g_cancellable_new ();
gtk_list_box_set_header_func (GTK_LIST_BOX (self->accounts_list),
hdy_list_box_separator_header,
NULL, NULL);
self->dummy_prefix_radio = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (NULL));
self->manager = g_object_ref (chatty_manager_get_default ());
......
......@@ -7,7 +7,6 @@
#pragma once
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
#include "users/chatty-item.h"
......@@ -15,7 +14,7 @@
G_BEGIN_DECLS
#define CHATTY_TYPE_NEW_CHAT_DIALOG (chatty_new_chat_dialog_get_type())
G_DECLARE_FINAL_TYPE (ChattyNewChatDialog, chatty_new_chat_dialog, CHATTY, NEW_CHAT_DIALOG, HdyDialog)
G_DECLARE_FINAL_TYPE (ChattyNewChatDialog, chatty_new_chat_dialog, CHATTY, NEW_CHAT_DIALOG, GtkDialog)
GtkWidget *chatty_new_chat_dialog_new (GtkWindow *parent_window);
......
......@@ -26,7 +26,7 @@ static void chatty_new_muc_name_check (ChattyNewMucDialog *self,
struct _ChattyNewMucDialog
{
HdyDialog parent_instance;
GtkDialog parent_instance;
GtkWidget *accounts_list;
GtkWidget *button_join_chat;
......@@ -40,7 +40,7 @@ struct _ChattyNewMucDialog
};
G_DEFINE_TYPE (ChattyNewMucDialog, chatty_new_muc_dialog, HDY_TYPE_DIALOG)
G_DEFINE_TYPE (ChattyNewMucDialog, chatty_new_muc_dialog, GTK_TYPE_DIALOG)
static void
......@@ -172,7 +172,7 @@ chatty_new_muc_add_account_to_list (ChattyNewMucDialog *self,
g_return_if_fail (CHATTY_IS_NEW_MUC_DIALOG(self));
row = hdy_action_row_new ();
row = HDY_ACTION_ROW (hdy_action_row_new ());
g_object_set_data (G_OBJECT(row),
"row-account",
(gpointer) account);
......@@ -200,7 +200,7 @@ chatty_new_muc_add_account_to_list (ChattyNewMucDialog *self,
(gpointer)prefix_radio_button);
hdy_action_row_add_prefix (row, GTK_WIDGET(prefix_radio_button ));
hdy_action_row_set_title (row, chatty_account_get_username (CHATTY_ACCOUNT (account)));
hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (row), chatty_account_get_username (CHATTY_ACCOUNT (account)));
gtk_container_add (GTK_CONTAINER(self->accounts_list), GTK_WIDGET(row));
......@@ -267,10 +267,6 @@ chatty_new_muc_dialog_init (ChattyNewMucDialog *self)
{
gtk_widget_init_template (GTK_WIDGET(self));
gtk_list_box_set_header_func (GTK_LIST_BOX(self->accounts_list),
hdy_list_box_separator_header,
NULL, NULL);
self->dummy_prefix_radio = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON(NULL));
chatty_new_muc_populate_account_list (self);
......
......@@ -7,13 +7,12 @@
#pragma once
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
G_BEGIN_DECLS
#define CHATTY_TYPE_NEW_MUC_DIALOG (chatty_new_muc_dialog_get_type())
G_DECLARE_FINAL_TYPE (ChattyNewMucDialog, chatty_new_muc_dialog, CHATTY, NEW_MUC_DIALOG, HdyDialog)
G_DECLARE_FINAL_TYPE (ChattyNewMucDialog, chatty_new_muc_dialog, CHATTY, NEW_MUC_DIALOG, GtkDialog)
GtkWidget *chatty_new_muc_dialog_new (GtkWindow *parent_window);
......
......@@ -44,7 +44,7 @@
* which was written by Andrea Schäfer. */
struct _ChattySettingsDialog
{
HdyDialog parent_instance;
GtkDialog parent_instance;
GtkWidget *add_button;
GtkWidget *save_button;
......@@ -95,7 +95,7 @@ struct _ChattySettingsDialog
gboolean visible;
};
G_DEFINE_TYPE (ChattySettingsDialog, chatty_settings_dialog, HDY_TYPE_DIALOG)
G_DEFINE_TYPE (ChattySettingsDialog, chatty_settings_dialog, GTK_TYPE_DIALOG)
static void
......@@ -572,7 +572,8 @@ chatty_account_row_new (ChattyAccount *account)
GtkWidget *spinner;
ChattyProtocol protocol;
row = hdy_action_row_new ();
row = HDY_ACTION_ROW (hdy_action_row_new ());
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), TRUE);
gtk_widget_show (GTK_WIDGET (row));
g_object_set_data (G_OBJECT(row),
"row-account",
......@@ -607,9 +608,9 @@ chatty_account_row_new (ChattyAccount *account)
account_enabled_switch, "active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
hdy_action_row_set_title (row, chatty_account_get_username (CHATTY_ACCOUNT (account)));
hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (row), chatty_account_get_username (CHATTY_ACCOUNT (account)));
hdy_action_row_set_subtitle (row, chatty_account_get_protocol_name (CHATTY_ACCOUNT (account)));
hdy_action_row_add_action (row, account_enabled_switch);
gtk_container_add (GTK_CONTAINER (row), account_enabled_switch);
hdy_action_row_set_activatable_widget (row, NULL);
return GTK_WIDGET (row);
......@@ -792,18 +793,6 @@ chatty_settings_dialog_init (ChattySettingsDialog *self)
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_set_header_func (GTK_LIST_BOX (self->accounts_list_box),
hdy_list_box_separator_header, NULL, NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX (self->fingerprint_list),
hdy_list_box_separator_header, NULL, NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX (self->fingerprint_device_list),
hdy_list_box_separator_header, NULL, NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX (self->protocol_list),
hdy_list_box_separator_header, NULL, NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX (self->new_account_settings_list),
hdy_list_box_separator_header, NULL, NULL);
gtk_widget_set_visible (self->message_carbons_row,
chatty_manager_has_carbons_plugin (manager));
}
......
......@@ -24,13 +24,12 @@
#pragma once
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
G_BEGIN_DECLS
#define CHATTY_TYPE_SETTINGS_DIALOG (chatty_settings_dialog_get_type())
G_DECLARE_FINAL_TYPE (ChattySettingsDialog, chatty_settings_dialog, CHATTY, SETTINGS_DIALOG, HdyDialog)
G_DECLARE_FINAL_TYPE (ChattySettingsDialog, chatty_settings_dialog, CHATTY, SETTINGS_DIALOG, GtkDialog)
GtkWidget *chatty_settings_dialog_new (GtkWindow *parent_window);
......
......@@ -25,7 +25,7 @@
struct _ChattyUserInfoDialog
{
HdyDialog parent_instance;
GtkDialog parent_instance;
GtkWidget *label_alias;
GtkWidget *label_jid;
......@@ -48,7 +48,7 @@ struct _ChattyUserInfoDialog
};
G_DEFINE_TYPE (ChattyUserInfoDialog, chatty_user_info_dialog, HDY_TYPE_DIALOG)
G_DEFINE_TYPE (ChattyUserInfoDialog, chatty_user_info_dialog, GTK_TYPE_DIALOG)
/* Copied from chatty-dialogs.c written by Andrea Schäfer <mosibasu@me.com> */
......@@ -300,14 +300,6 @@ static void
chatty_user_info_dialog_init (ChattyUserInfoDialog *self)
{
gtk_widget_init_template (GTK_WIDGET(self));
gtk_list_box_set_header_func (GTK_LIST_BOX(self->listbox_fps),
hdy_list_box_separator_header,
NULL, NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX(self->listbox_prefs),
hdy_list_box_separator_header,
NULL, NULL);
}
......
......@@ -7,13 +7,12 @@
#pragma once
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
G_BEGIN_DECLS
#define CHATTY_TYPE_USER_INFO_DIALOG (chatty_user_info_dialog_get_type())
G_DECLARE_FINAL_TYPE (ChattyUserInfoDialog, chatty_user_info_dialog, CHATTY, USER_INFO_DIALOG, HdyDialog)
G_DECLARE_FINAL_TYPE (ChattyUserInfoDialog, chatty_user_info_dialog, CHATTY, USER_INFO_DIALOG, GtkDialog)
GtkWidget *chatty_user_info_dialog_new (GtkWindow *parent_window);
......
......@@ -63,7 +63,7 @@ chatty_deps = [
dependency('gio-2.0', version: '>= 2.50'),
dependency('gtk+-3.0', version: '>= 3.22'),
purple, jabber,
dependency('libhandy-0.0'),
dependency('libhandy-1'),
dependency('sqlite3', version: '>=3.0.0'),
dependency('libebook-contacts-1.2'),
dependency('libebook-1.2'),
......
......@@ -15,12 +15,10 @@
<class name="view"/>
</style>
<child>
<object class="HdyColumn">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="maximum-width">640</property>
<property name="linear-growth-width">640</property>
<child>
<object class="GtkBox" id="property">
<property name="visible">True</property>
......@@ -69,11 +67,9 @@
</child>
<child>
<object class="HdyColumn">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="maximum-width">600</property>
<property name="linear-growth-width">600</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......@@ -169,7 +165,7 @@
</object>
</child>
</object> <!-- ./HdyColumn -->
</object> <!-- ./HdyClamp -->
</child>
</template>
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.16"/>
<template class="ChattyNewMucDialog" parent="HdyDialog">
<template class="ChattyNewMucDialog" parent="GtkDialog">
<property name="modal">True</property>
<property name="can_focus">False</property>
<property name="default_width">360</property>
......@@ -55,7 +55,7 @@
<property name="orientation">vertical</property>
<property name="visible">True</property>
<child>
<object class="HdyColumn">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">fill</property>
......@@ -65,7 +65,6 @@
<property name="margin-end">12</property>
<property name="margin-top">32</property>
<property name="expand">True</property>
<property name="maximum-width">600</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......@@ -88,21 +87,18 @@
</object>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<child>
<object class="GtkListBox" id="accounts_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="selection-mode">none</property>
<signal name="row-activated" handler="account_list_row_activated_cb" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBox" id="accounts_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="selection-mode">none</property>
<signal name="row-activated" handler="account_list_row_activated_cb" swapped="yes"/>
<style>
<class name="content"/>
</style>
</object>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.16"/>
<template class="ChattyMucInfoDialog" parent="HdyDialog">
<template class="ChattyMucInfoDialog" parent="GtkDialog">
<property name="modal">True</property>
<property name="can_focus">False</property>
<property name="default_width">360</property>
......@@ -105,7 +105,7 @@
<property name="vhomogeneous">False</property>
<property name="transition_type">slide-left-right</property>
<child>
<object class="HdyColumn">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">fill</property>
......@@ -115,7 +115,6 @@
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="expand">True</property>
<property name="maximum-width">600</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......@@ -232,49 +231,45 @@
</object>
</child>
<child>
<object class="GtkFrame">
<object class="GtkListBox" id="list_muc_settings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="selection-mode">none</property>
<property name="margin-bottom">32</property>
<style>
<class name="content"/>
</style>
<child>
<object class="GtkListBox" id="list_muc_settings">
<object class="HdyActionRow">
<property name="title" translatable="yes">Notifications</property>
<property name="subtitle" translatable="yes">Show notification badge</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="selection-mode">none</property>
<property name="selectable">False</property>
<property name="activatable-widget">switch_prefs_notifications</property>
<child>
<object class="HdyActionRow">
<property name="title" translatable="yes">Notifications</property>
<property name="subtitle" translatable="yes">Show notification badge</property>
<object class="GtkSwitch" id="switch_prefs_notifications">
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="visible">True</property>
<property name="selectable">False</property>
<property name="activatable">False</property>
<child type="action">
<object class="GtkSwitch" id="switch_prefs_notifications">
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="visible">True</property>
<signal name="notify::active" handler="switch_prefs_notify_changed_cb" swapped="yes"/>
</object>
</child>
<signal name="notify::active" handler="switch_prefs_notify_changed_cb" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
<object class="HdyActionRow">
<property name="title" translatable="yes">Status Messages</property>
<property name="subtitle" translatable="yes">Show status messages in chat</property>
<property name="visible">True</property>
<property name="selectable">False</property>
<property name="activatable-widget">switch_prefs_status</property>
<child>
<object class="HdyActionRow">
<property name="title" translatable="yes">Status Messages</property>
<property name="subtitle" translatable="yes">Show status messages in chat</property>
<object class="GtkSwitch" id="switch_prefs_status">
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="visible">True</property>
<property name="selectable">False</property>
<property name="activatable">False</property>
<child type="action">
<object class="GtkSwitch" id="switch_prefs_status">
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="visible">True</property>
<signal name="notify::active" handler="switch_prefs_state_changed_cb" swapped="yes"/>
</object>