Commit 74b85c04 authored by Amin Bandali's avatar Amin Bandali Committed by Sébastien Blin
Browse files

pixmaps: add and use Jami logo with white text with dark theme

accountcreationwizard, dialogs, mainwindow, welcomeview: use the Jami
logo with the white text when using a dark theme.

utils/drawing: bring over the logic for detection of dark theme from
'mainwindow' to here, so that it could also be used by 'dialogs' for
the about dialog.

dialogs: change from .c to .cpp so we can include utils/drawing;
remove some unused code; and add my name to the authors list.

GitLab: #1221
Change-Id: If466427d7fc63bbd1b0fbd739e5b82592001f547
parent 26d20a16
......@@ -278,7 +278,7 @@ SET( SRC_FILES
src/video/xrectsel.h
src/video/xrectsel.c
src/dialogs.h
src/dialogs.c
src/dialogs.cpp
src/mediasettingsview.h
src/mediasettingsview.cpp
src/pluginsettingsview.h
......
This diff is collapsed.
......@@ -3,6 +3,7 @@
<gresource prefix="/net/jami/JamiGnome">
<file alias="jami-symbol-blue">jami.svg</file>
<file alias="jami-logo-blue">LOGO_JAMI_201106.svg</file>
<file alias="jami-logo-white">LOGO_JAMI_201106_white.svg</file>
<file alias="addressbook_small">addressbook.svg</file>
<file alias="history_small">history.svg</file>
<file alias="clear_history">ic_delete_forever_black_24px.svg</file>
......
......@@ -150,6 +150,8 @@ struct _AccountCreationWizardPrivate
lrc::api::AVModel* avModel_;
lrc::api::NewAccountModel* accountModel_;
bool useDarkTheme {false};
Mode mode;
GSettings *settings;
......@@ -935,8 +937,11 @@ build_creation_wizard_view(AccountCreationWizard *view)
/* set ring logo */
GError *error = NULL;
GdkPixbuf* logo_ring = gdk_pixbuf_new_from_resource_at_scale("/net/jami/JamiGnome/jami-logo-blue",
-1, 50, TRUE, &error);
GdkPixbuf* logo_ring = gdk_pixbuf_new_from_resource_at_scale(
priv->useDarkTheme
? "/net/jami/JamiGnome/jami-logo-white"
: "/net/jami/JamiGnome/jami-logo-blue",
-1, 50, TRUE, &error);
if (logo_ring == NULL) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
......@@ -1031,13 +1036,14 @@ build_creation_wizard_view(AccountCreationWizard *view)
}
GtkWidget *
account_creation_wizard_new(lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel)
account_creation_wizard_new(lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel, bool useDarkTheme)
{
gpointer view = g_object_new(ACCOUNT_CREATION_WIZARD_TYPE, NULL);
auto* priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
priv->avModel_ = &avModel;
priv->accountModel_ = &accountModel;
priv->useDarkTheme = useDarkTheme;
build_creation_wizard_view(ACCOUNT_CREATION_WIZARD(view));
return (GtkWidget *)view;
......
......@@ -48,7 +48,7 @@ typedef struct _AccountCreationWizard AccountCreationWizard;
typedef struct _AccountCreationWizardClass AccountCreationWizardClass;
GType account_creation_wizard_get_type (void) G_GNUC_CONST;
GtkWidget *account_creation_wizard_new (lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel);
GtkWidget *account_creation_wizard_new (lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel, bool useDarkTheme);
void account_creation_wizard_show_preview (AccountCreationWizard *win, gboolean show_preview = TRUE);
void show_rendezvous_creation_wizard (AccountCreationWizard *win);
......
......@@ -22,47 +22,30 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include "config.h"
#include "revision.h"
#include "utils/drawing.h"
GtkWidget *
dialog_working(GtkWidget *parent, const gchar *msg)
void
about_dialog_set_theme(GtkAboutDialog *dialog, gboolean use_dark_theme)
{
GtkWidget *dialog = gtk_dialog_new();
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
if (parent && GTK_IS_WIDGET(parent)) {
/* get parent window so we can center on it */
parent = gtk_widget_get_toplevel(GTK_WIDGET(parent));
if (gtk_widget_is_toplevel(parent)) {
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
}
}
GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_box_set_spacing(GTK_BOX(content_area), 10);
gtk_widget_set_size_request(content_area, 250, -1);
gtk_widget_set_margin_top(content_area, 25);
GtkWidget *message = NULL;
if (msg) {
message = gtk_label_new(msg);
} else {
message = gtk_label_new(_("Working…"));
GError *error = NULL;
GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale(
use_dark_theme
? "/net/jami/JamiGnome/jami-logo-white"
: "/net/jami/JamiGnome/jami-logo-blue",
350, -1, TRUE, &error);
if (!logo) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
}
gtk_about_dialog_set_logo(dialog, logo);
}
gtk_box_pack_start(GTK_BOX(content_area), message, FALSE, TRUE, 0);
GtkWidget *spinner = gtk_spinner_new();
gtk_spinner_start(GTK_SPINNER(spinner));
gtk_box_pack_start(GTK_BOX(content_area), spinner, FALSE, TRUE, 0);
gtk_widget_show_all(content_area);
return dialog;
void
about_dialog_on_redraw(GtkWidget *dialog)
{
about_dialog_set_theme(GTK_ABOUT_DIALOG(dialog),
use_dark_theme(get_ambient_color(dialog)));
}
void
......@@ -72,15 +55,6 @@ about_dialog(GtkWidget *parent)
if (parent && GTK_IS_WIDGET(parent))
parent = gtk_widget_get_toplevel(GTK_WIDGET(parent));
/* get logo */
GError *error = NULL;
GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale(
"/net/jami/JamiGnome/jami-logo-blue", 350, -1, TRUE, &error);
if (logo == NULL) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
}
gchar *version = g_strdup_printf(C_("Do not translate the release name nor the status (beta, final, ...)",
"\"%s\"\nbuilt on %.25s"),
"Together",
......@@ -94,6 +68,7 @@ about_dialog(GtkWidget *parent)
"Alexandre Viau",
"Aline Bonnet",
"Aline Gondim Santos",
"Amin Bandali",
"AmirHossein Naghshzan",
"Andreas Traczyk",
"Anthony Léonard",
......@@ -142,20 +117,38 @@ about_dialog(GtkWidget *parent)
NULL,
};
gtk_show_about_dialog(
GTK_WINDOW(parent),
"program-name", "",
"copyright", "© 2020 Savoir-faire Linux",
"license-type", GTK_LICENSE_GPL_3_0,
"logo", logo,
"version", version,
"comments", _("The GNOME client for Jami.\nJami is free software for universal communication which respects the freedoms and privacy of its users."),
"authors", authors,
"website", "https://jami.net/",
"website-label", "jami.net",
"translator-credits", "https://www.transifex.com/savoirfairelinux/jami",
NULL
);
GtkWidget *about = (GtkWidget*) g_object_get_data(G_OBJECT(GTK_WINDOW(parent)),
"gtk-about-dialog");
if (!about) {
about = gtk_about_dialog_new();
g_object_ref_sink(about);
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(about), "");
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), "© 2020 Savoir-faire Linux");
gtk_about_dialog_set_license_type(GTK_ABOUT_DIALOG(about), GTK_LICENSE_GPL_3_0);
about_dialog_set_theme(GTK_ABOUT_DIALOG(about), use_dark_theme(get_ambient_color(parent)));
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), version);
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), _("The GNOME client for Jami.\nJami is free software for universal communication which respects the freedoms and privacy of its users."));
gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about), authors);
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about), "https://jami.net/");
gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(about), "jami.net");
gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(about), "https://www.transifex.com/savoirfairelinux/jami");
g_free(version);
g_signal_connect(about, "delete-event",
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
g_signal_connect(about, "response",
G_CALLBACK(gtk_widget_hide), NULL);
g_signal_connect(about, "draw",
G_CALLBACK(about_dialog_on_redraw), NULL);
gtk_window_set_modal(GTK_WINDOW(about), TRUE);
gtk_window_set_transient_for(GTK_WINDOW(about), GTK_WINDOW(parent));
gtk_window_set_destroy_with_parent(GTK_WINDOW(about), TRUE);
g_object_set_data_full(G_OBJECT(parent),
g_intern_static_string("gtk-about-dialog"),
about, g_object_unref);
}
g_free(version);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_window_present(GTK_WINDOW(about));
G_GNUC_END_IGNORE_DEPRECATIONS
}
......@@ -24,7 +24,6 @@
G_BEGIN_DECLS
GtkWidget *dialog_working(GtkWidget *parent, const gchar *msg);
void about_dialog(GtkWidget *parent);
G_END_DECLS
......
......@@ -142,6 +142,7 @@ struct MainWindowPrivate
GCancellable *cancellable;
GtkWidget* migratingDialog_;
GtkWidget* migratingDialogLogo_;
#if USE_LIBNM
/* NetworkManager */
NMClient *nm_client;
......@@ -535,7 +536,7 @@ on_redraw(GtkWidget*, cairo_t*, MainWindow* self)
auto* priv = MAIN_WINDOW_GET_PRIVATE(MAIN_WINDOW(self));
auto color = get_ambient_color(GTK_WIDGET(self));
bool current_theme = (color.red + color.green + color.blue) / 3 < .5;
bool current_theme = use_dark_theme(color);
conversations_view_set_theme(CONVERSATIONS_VIEW(priv->treeview_conversations), current_theme);
if (priv->useDarkTheme != current_theme) {
welcome_set_theme(WELCOME_VIEW(priv->welcome_view), current_theme);
......@@ -570,6 +571,28 @@ on_redraw(GtkWidget*, cairo_t*, MainWindow* self)
return false;
}
gboolean
on_migrating_dialog_redraw(GtkWidget* migrating_dialog, cairo_t*, MainWindow* win)
{
g_return_val_if_fail(IS_MAIN_WINDOW(win), G_SOURCE_REMOVE);
auto* priv = MAIN_WINDOW_GET_PRIVATE(MAIN_WINDOW(win));
GError *error = nullptr;
GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale(
use_dark_theme(get_ambient_color(migrating_dialog))
? "/net/jami/JamiGnome/jami-logo-white"
: "/net/jami/JamiGnome/jami-logo-blue",
350, -1, TRUE, &error);
if (!logo) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
} else {
gtk_image_set_from_pixbuf(
GTK_IMAGE(priv->migratingDialogLogo_), logo);
}
return false;
}
static void
on_send_text_clicked(G_GNUC_UNUSED GtkWidget*, gchar* uid, gchar* body, MainWindow* self)
{
......@@ -1131,19 +1154,26 @@ CppImpl::CppImpl(MainWindow& widget)
auto* content_area = gtk_dialog_get_content_area(GTK_DIALOG(widgets->migratingDialog_));
GError *error = nullptr;
GdkPixbuf* logo_jami = gdk_pixbuf_new_from_resource_at_scale("/net/jami/JamiGnome/jami-logo-blue",
-1, 128, TRUE, &error);
GdkPixbuf* logo_jami = gdk_pixbuf_new_from_resource_at_scale(
use_dark_theme(get_ambient_color(widgets->migratingDialog_))
? "/net/jami/JamiGnome/jami-logo-white"
: "/net/jami/JamiGnome/jami-logo-blue",
-1, 128, TRUE, &error);
if (!logo_jami) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
return;
}
auto* image = gtk_image_new_from_pixbuf(logo_jami);
widgets->migratingDialogLogo_ = gtk_image_new_from_pixbuf(logo_jami);
auto* label = gtk_label_new(_("Migration in progress... please do not close this window."));
gtk_container_add(GTK_CONTAINER(content_area), image);
gtk_container_add(GTK_CONTAINER(content_area), widgets->migratingDialogLogo_);
gtk_container_add(GTK_CONTAINER(content_area), label);
gtk_widget_set_margin_left(content_area, 32);
gtk_widget_set_margin_right(content_area, 32);
g_signal_connect(widgets->migratingDialog_,
"draw",
G_CALLBACK(on_migrating_dialog_redraw),
MAIN_WINDOW(self));
gtk_widget_show_all(widgets->migratingDialog_);
......@@ -1796,7 +1826,10 @@ void
CppImpl::enterAccountCreationWizard(bool showControls)
{
if (!widgets->account_creation_wizard) {
widgets->account_creation_wizard = account_creation_wizard_new(lrc_->getAVModel(), lrc_->getAccountModel());
widgets->account_creation_wizard =
account_creation_wizard_new(lrc_->getAVModel(),
lrc_->getAccountModel(),
widgets->useDarkTheme);
g_object_add_weak_pointer(G_OBJECT(widgets->account_creation_wizard),
reinterpret_cast<gpointer*>(&widgets->account_creation_wizard));
g_signal_connect_swapped(widgets->account_creation_wizard, "account-creation-lock",
......
......@@ -400,4 +400,10 @@ get_ambient_color(GtkWidget* widget)
cairo_destroy(cr);
cairo_surface_destroy(surface);
return GdkRGBA{1.0f, 1.0f, 1.0f, 1.0f};
}
\ No newline at end of file
}
gboolean
use_dark_theme(GdkRGBA color)
{
return (color.red + color.green + color.blue) / 3 < .5;
}
......@@ -46,4 +46,6 @@ GdkPixbuf *draw_status(const GdkPixbuf *avatar, IconStatus status);
GdkRGBA get_ambient_color(GtkWidget* widget);
gboolean use_dark_theme(GdkRGBA color);
#endif /* _DRAWING */
......@@ -49,6 +49,7 @@ struct _WelcomeViewPrivate
GtkWidget *label_explanation;
GtkWidget *hbox_idlayout;
GtkWidget *label_ringid;
GtkWidget *image_logo;
GtkWidget *button_qrcode;
GtkWidget *revealer_qrcode;
......@@ -118,6 +119,19 @@ welcome_update_view(WelcomeView* self) {
GError *error = NULL;
GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale(
priv->useDarkTheme
? "/net/jami/JamiGnome/jami-logo-white"
: "/net/jami/JamiGnome/jami-logo-blue",
350, -1, TRUE, &error);
if (!logo) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
} else {
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_logo), logo);
}
GdkPixbuf *image_qr = gdk_pixbuf_new_from_resource_at_scale(priv->useDarkTheme? "/net/jami/JamiGnome/qrcode-white" : "/net/jami/JamiGnome/qrcode",
-1, 16, TRUE, &error);
if (!image_qr) {
......@@ -179,16 +193,20 @@ welcome_view_init(WelcomeView *self)
gtk_container_add(GTK_CONTAINER(overlay_qrcode), priv->box_overlay);
/* get logo */
priv->image_logo = gtk_image_new();
GError *error = NULL;
GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale("/net/jami/JamiGnome/jami-logo-blue",
350, -1, TRUE, &error);
if (logo == NULL) {
GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale(
priv->useDarkTheme
? "/net/jami/JamiGnome/jami-logo-white"
: "/net/jami/JamiGnome/jami-logo-blue",
350, -1, TRUE, &error);
if (!logo) {
g_debug("Could not load logo: %s", error->message);
g_clear_error(&error);
} else {
auto image_ring_logo = gtk_image_new_from_pixbuf(logo);
gtk_box_pack_start(GTK_BOX(priv->box_overlay), image_ring_logo, FALSE, TRUE, 0);
gtk_widget_set_visible(GTK_WIDGET(image_ring_logo), TRUE);
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_logo), logo);
gtk_box_pack_start(GTK_BOX(priv->box_overlay), GTK_WIDGET(priv->image_logo), FALSE, TRUE, 0);
gtk_widget_set_visible(GTK_WIDGET(priv->image_logo), TRUE);
}
/* welcome text */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment