dialogs.c 4.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 *  Copyright (C) 2015 Savoir-Faire Linux Inc.
 *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *  Additional permission under GNU GPL version 3 section 7:
 *
 *  If you modify this program, or any covered work, by linking or
 *  combining it with the OpenSSL project's OpenSSL library (or a
 *  modified version of that library), containing parts covered by the
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 *  grants you additional permission to convey the resulting work.
 *  Corresponding Source for a non-source form of such a combination
 *  shall include the source code for the parts of OpenSSL used as well
 *  as that of the covered work.
 */

#include "dialogs.h"

#include <gtk/gtk.h>
Stepan Salenikovich's avatar
Stepan Salenikovich committed
34 35
#include <glib/gprintf.h>
#include "config.h"
36 37 38 39 40 41

GtkWidget *
ring_dialog_working(GtkWidget *parent, const gchar *msg)
{
    GtkWidget *dialog = gtk_dialog_new();
    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
42
    gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
43 44 45 46 47 48 49 50 51 52 53 54

    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);
55 56
    gtk_widget_set_size_request(content_area, 250, -1);
    gtk_widget_set_margin_top(content_area, 25);
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

    GtkWidget *message = NULL;
    if (msg) {
        message = gtk_label_new(msg);
    } else {
        message = gtk_label_new("Working...");
    }

    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;
Stepan Salenikovich's avatar
Stepan Salenikovich committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
}

void
ring_about_dialog(GtkWidget *parent)
{
    /* get parent window */
    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("/cx/ring/RingGnome/ring-logo-blue", &error);
    if (logo == NULL) {
        g_debug("Could not load logo: %s", error->message);
        g_error_free(error);
    }

92
    gchar *name = g_strdup_printf("Gnome Ring v%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
Stepan Salenikovich's avatar
Stepan Salenikovich committed
93 94

    const gchar *authors[] = {
95 96 97 98 99 100 101 102 103
        [0] = "Adrien Béraud",
        [1] = "Alexandre Lision",
        [2] = "Edric Milaret",
        [3] = "Éloi Bail",
        [4] = "Emmanuel Lepage-Vallée",
        [5] = "Guillaume Roguez",
        [6] = "Stepan Salenikovich",
        [7] = "Based on the SFLPhone project",
        [8] = NULL,
Stepan Salenikovich's avatar
Stepan Salenikovich committed
104 105 106 107 108 109 110 111 112
    };

    const gchar *artists[] = {
        [0] = "Marianne Forget",
        [1] = NULL,
    };

    gtk_show_about_dialog(
        GTK_WINDOW(parent),
113
        "program-name", name,
Stepan Salenikovich's avatar
Stepan Salenikovich committed
114 115 116
        "copyright", "© 2015 Savoir-faire Linux",
        "license-type", GTK_LICENSE_GPL_3_0,
        "logo", logo,
117 118
        "version", "release: Samuel de Champlain",
        "comments", "The GNOME client for Ring.\nRing is a secured and distributed communication software.",
Stepan Salenikovich's avatar
Stepan Salenikovich committed
119 120 121 122 123 124 125
        "authors", authors,
        "website", "http://www.ring.cx/",
        "website-label", "www.ring.cx",
        "artists", artists,
        NULL
    );

126
    g_free(name);
Stepan Salenikovich's avatar
Stepan Salenikovich committed
127
}