| 1 |
/* |
|---|
| 2 |
* Sweep, a sound wave editor. |
|---|
| 3 |
* |
|---|
| 4 |
* Copyright (C) 2000 Conrad Parker |
|---|
| 5 |
* |
|---|
| 6 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 7 |
* it under the terms of the GNU General Public License as published by |
|---|
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 |
* (at your option) any later version. |
|---|
| 10 |
* |
|---|
| 11 |
* This program is distributed in the hope that it will be useful, |
|---|
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 |
* GNU General Public License for more details. |
|---|
| 15 |
* |
|---|
| 16 |
* You should have received a copy of the GNU General Public License |
|---|
| 17 |
* along with this program; if not, write to the Free Software |
|---|
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 |
*/ |
|---|
| 20 |
|
|---|
| 21 |
#ifdef HAVE_CONFIG_H |
|---|
| 22 |
# include <config.h> |
|---|
| 23 |
#endif |
|---|
| 24 |
|
|---|
| 25 |
#include <stdio.h> |
|---|
| 26 |
#include <stdlib.h> |
|---|
| 27 |
#include <string.h> |
|---|
| 28 |
#include <time.h> |
|---|
| 29 |
|
|---|
| 30 |
#include <gtk/gtk.h> |
|---|
| 31 |
|
|---|
| 32 |
#include <sweep/sweep_types.h> |
|---|
| 33 |
#include <sweep/sweep_i18n.h> |
|---|
| 34 |
|
|---|
| 35 |
#include "about_dialog.h" |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
static void about_dialog_destroy(void); |
|---|
| 39 |
static int about_dialog_button(GtkWidget * widget, |
|---|
| 40 |
GdkEventButton * event); |
|---|
| 41 |
|
|---|
| 42 |
static GtkWidget *about_dialog = NULL; |
|---|
| 43 |
|
|---|
| 44 |
static void |
|---|
| 45 |
sweep_homepage (GtkWidget * widget, gpointer data) |
|---|
| 46 |
{ |
|---|
| 47 |
if (system ("gnome-moz-remote http://sweep.sourceforge.net/") < 0) |
|---|
| 48 |
perror ("system") ; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
void |
|---|
| 52 |
about_dialog_create() |
|---|
| 53 |
{ |
|---|
| 54 |
/* FIXME: for unused about box font style, reimplement?) |
|---|
| 55 |
* GtkStyle *style; |
|---|
| 56 |
*/ |
|---|
| 57 |
GtkWidget *vbox; |
|---|
| 58 |
GtkWidget *label; |
|---|
| 59 |
gchar buf[64]; |
|---|
| 60 |
GtkWidget * button; |
|---|
| 61 |
GtkWidget * about_image; |
|---|
| 62 |
GtkWidget * about_ebox; |
|---|
| 63 |
gchar buf2[1024]; |
|---|
| 64 |
|
|---|
| 65 |
if (!about_dialog) { |
|---|
| 66 |
about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|---|
| 67 |
gtk_window_set_type_hint (GTK_WINDOW(about_dialog), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); |
|---|
| 68 |
gtk_window_set_decorated ( GTK_WINDOW (about_dialog), FALSE); |
|---|
| 69 |
gtk_window_set_wmclass(GTK_WINDOW(about_dialog), "about_dialog", "Sweep"); |
|---|
| 70 |
gtk_window_set_resizable (GTK_WINDOW(about_dialog), FALSE); |
|---|
| 71 |
gtk_window_set_position (GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); |
|---|
| 72 |
g_signal_connect(GTK_OBJECT(about_dialog), "destroy", |
|---|
| 73 |
G_CALLBACK(about_dialog_destroy), NULL); |
|---|
| 74 |
g_signal_connect(GTK_OBJECT(about_dialog), "button_press_event", |
|---|
| 75 |
G_CALLBACK(about_dialog_button), NULL); |
|---|
| 76 |
gtk_widget_set_events(about_dialog, GDK_BUTTON_PRESS_MASK); |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
vbox = gtk_vbox_new(FALSE, 1); |
|---|
| 81 |
gtk_container_add(GTK_CONTAINER(about_dialog), vbox); |
|---|
| 82 |
gtk_widget_show(vbox); |
|---|
| 83 |
|
|---|
| 84 |
about_ebox = gtk_event_box_new(); |
|---|
| 85 |
gtk_box_pack_start(GTK_BOX(vbox), about_ebox, TRUE, TRUE, 0); |
|---|
| 86 |
gtk_widget_show(about_ebox); |
|---|
| 87 |
snprintf(buf2, sizeof (buf2), "%s/sweep_splash.png", PACKAGE_DATA_DIR); |
|---|
| 88 |
about_image = gtk_image_new_from_file (buf2); |
|---|
| 89 |
gtk_container_add(GTK_CONTAINER(about_ebox), about_image); |
|---|
| 90 |
gtk_widget_show(about_ebox); |
|---|
| 91 |
gtk_widget_show(about_image); |
|---|
| 92 |
|
|---|
| 93 |
/* FIXME: old gtk font code. reimplement? |
|---|
| 94 |
* style = gtk_style_new(); |
|---|
| 95 |
* gdk_font_unref(style->font); |
|---|
| 96 |
* style->font = gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*"); |
|---|
| 97 |
* gtk_widget_push_style(style); |
|---|
| 98 |
*/ |
|---|
| 99 |
snprintf (buf, sizeof (buf), "%s %s", _("This is Sweep version"), VERSION); |
|---|
| 100 |
label = gtk_label_new(buf); |
|---|
| 101 |
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); |
|---|
| 102 |
gtk_widget_show(label); |
|---|
| 103 |
|
|---|
| 104 |
/* FIXME: old style code |
|---|
| 105 |
* gtk_widget_pop_style(); |
|---|
| 106 |
*/ |
|---|
| 107 |
|
|---|
| 108 |
button = gtk_button_new_with_label ("http://sweep.sourceforge.net/"); |
|---|
| 109 |
gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, TRUE, 0); |
|---|
| 110 |
gtk_widget_show (button); |
|---|
| 111 |
g_signal_connect (GTK_OBJECT(button), "clicked", |
|---|
| 112 |
G_CALLBACK(sweep_homepage), NULL); |
|---|
| 113 |
} |
|---|
| 114 |
if (!GTK_WIDGET_VISIBLE(about_dialog)) { |
|---|
| 115 |
gtk_widget_show(about_dialog); |
|---|
| 116 |
} else { |
|---|
| 117 |
gdk_window_raise(about_dialog->window); |
|---|
| 118 |
} |
|---|
| 119 |
} |
|---|
| 120 |
|
|---|
| 121 |
static void |
|---|
| 122 |
about_dialog_destroy() |
|---|
| 123 |
{ |
|---|
| 124 |
about_dialog = NULL; |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
static int |
|---|
| 128 |
about_dialog_button(GtkWidget * widget, |
|---|
| 129 |
GdkEventButton * event) |
|---|
| 130 |
{ |
|---|
| 131 |
gtk_widget_hide(about_dialog); |
|---|
| 132 |
|
|---|
| 133 |
return FALSE; |
|---|
| 134 |
} |
|---|