2005-06-22 11:20:32 -07:00
|
|
|
/*
|
|
|
|
* mooapp/mooappdialogs.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
|
|
|
*
|
|
|
|
* 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 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mooapp/mooapp-private.h"
|
2005-07-23 21:58:57 -07:00
|
|
|
#include "mooterm/mooterm-prefs.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
#include "mooedit/mooeditprefs.h"
|
2005-10-13 07:08:18 -07:00
|
|
|
#include "mooedit/mooplugin.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
#include "mooutils/mooprefsdialog.h"
|
|
|
|
#include "mooutils/moostock.h"
|
2005-10-31 14:58:01 -08:00
|
|
|
#include "mooutils/mooutils-misc.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
|
|
|
|
void moo_app_prefs_dialog (GtkWidget *parent)
|
|
|
|
{
|
|
|
|
MooApp *app;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
app = moo_app_get_instance ();
|
|
|
|
dialog = MOO_APP_GET_CLASS(app)->prefs_dialog (app);
|
|
|
|
g_return_if_fail (MOO_IS_PREFS_DIALOG (dialog));
|
|
|
|
|
|
|
|
moo_prefs_dialog_run (MOO_PREFS_DIALOG (dialog), parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *_moo_app_create_prefs_dialog (MooApp *app)
|
|
|
|
{
|
|
|
|
char *title;
|
|
|
|
const MooAppInfo *info;
|
|
|
|
MooPrefsDialog *dialog;
|
|
|
|
|
|
|
|
info = moo_app_get_info (app);
|
|
|
|
title = g_strdup_printf ("%s Preferences", info->full_name);
|
|
|
|
dialog = MOO_PREFS_DIALOG (moo_prefs_dialog_new (title));
|
|
|
|
g_free (title);
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
#ifdef MOO_BUILD_TERM
|
2005-07-24 19:55:19 -07:00
|
|
|
moo_prefs_dialog_append_page (dialog, moo_term_prefs_page_new ());
|
2005-10-13 07:08:18 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOO_BUILD_EDIT
|
2005-10-16 22:23:40 -07:00
|
|
|
// moo_prefs_dialog_append_page (dialog, moo_edit_prefs_page_new (moo_app_get_editor (app)));
|
|
|
|
moo_prefs_dialog_append_page (dialog, moo_edit_colors_prefs_page_new (moo_app_get_editor (app)));
|
2005-10-13 07:08:18 -07:00
|
|
|
_moo_plugin_attach_prefs (GTK_WIDGET (dialog));
|
|
|
|
#endif
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
return GTK_WIDGET (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
#define COPYRIGHT_SYMBOL "\302\251"
|
|
|
|
static const char *copyright = COPYRIGHT_SYMBOL " 2004-2005 Yevgen Muntyan";
|
2005-07-25 08:50:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
static void show_about_dialog (GtkWidget *dialog,
|
|
|
|
GtkWindow *parent)
|
|
|
|
{
|
|
|
|
g_return_if_fail (dialog != NULL);
|
|
|
|
|
2005-09-11 06:52:58 -07:00
|
|
|
if (parent)
|
2005-07-25 08:50:20 -07:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dialog_destroyed (void)
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (moo_app_get_instance()),
|
|
|
|
"moo-app-about-dialog", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-25 08:57:10 -07:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2005-07-25 07:04:11 -07:00
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
static void open_link (G_GNUC_UNUSED GtkAboutDialog *about,
|
|
|
|
const gchar *link,
|
|
|
|
G_GNUC_UNUSED gpointer data)
|
|
|
|
{
|
|
|
|
moo_open_url (link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void send_mail (G_GNUC_UNUSED GtkAboutDialog *about,
|
|
|
|
const gchar *address,
|
|
|
|
G_GNUC_UNUSED gpointer data)
|
|
|
|
{
|
|
|
|
moo_open_email (address, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void moo_app_about_dialog (GtkWidget *parent)
|
|
|
|
{
|
|
|
|
GtkWindow *parent_window = NULL;
|
2005-07-25 08:50:20 -07:00
|
|
|
GtkWidget *dialog;
|
2005-06-22 11:20:32 -07:00
|
|
|
static gboolean url_hook_set = FALSE;
|
|
|
|
const MooAppInfo *info;
|
|
|
|
const char *authors[] = {"Yevgen Muntyan <muntyan@math.tamu.edu>", NULL};
|
|
|
|
const char *gpl =
|
|
|
|
#include "mooapp/gpl"
|
|
|
|
;
|
|
|
|
|
|
|
|
if (!url_hook_set)
|
|
|
|
{
|
|
|
|
url_hook_set = TRUE;
|
|
|
|
|
|
|
|
gtk_about_dialog_set_email_hook (send_mail, NULL, NULL);
|
|
|
|
gtk_about_dialog_set_url_hook (open_link, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
parent_window = GTK_WINDOW (gtk_widget_get_toplevel (parent));
|
|
|
|
|
|
|
|
info = moo_app_get_info (moo_app_get_instance());
|
|
|
|
|
2005-07-25 08:50:20 -07:00
|
|
|
dialog = g_object_get_data (G_OBJECT (moo_app_get_instance()),
|
|
|
|
"moo-app-about-dialog");
|
|
|
|
|
|
|
|
if (!dialog)
|
|
|
|
{
|
|
|
|
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
2005-09-11 06:52:58 -07:00
|
|
|
"authors", authors,
|
|
|
|
"comments", info->description,
|
|
|
|
"copyright", copyright,
|
|
|
|
"license", gpl,
|
|
|
|
"logo-icon-name", MOO_STOCK_APP,
|
|
|
|
"name", info->full_name,
|
|
|
|
"version", info->version,
|
|
|
|
"website", info->website,
|
|
|
|
"website-label", info->website_label,
|
|
|
|
NULL);
|
|
|
|
g_object_set_data_full (G_OBJECT (moo_app_get_instance()),
|
|
|
|
"moo-app-about-dialog", dialog,
|
|
|
|
g_object_unref);
|
2005-07-25 08:50:20 -07:00
|
|
|
g_signal_connect (dialog, "delete-event",
|
|
|
|
G_CALLBACK (gtk_widget_hide_on_delete),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (dialog_destroyed),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
show_about_dialog (dialog, parent_window);
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !GTK_CHECK_VERSION(2,6,0) */
|
2005-07-25 08:50:20 -07:00
|
|
|
|
2005-09-11 06:44:14 -07:00
|
|
|
#include "mooapp/mooappabout-glade.h"
|
|
|
|
#include "mooutils/mooglade.h"
|
2005-07-25 08:50:20 -07:00
|
|
|
|
|
|
|
void moo_app_about_dialog (GtkWidget *parent)
|
|
|
|
{
|
|
|
|
GtkWindow *parent_window = NULL;
|
|
|
|
GtkWidget *dialog;
|
2005-09-11 06:44:14 -07:00
|
|
|
MooGladeXML *xml;
|
2005-07-25 08:50:20 -07:00
|
|
|
|
|
|
|
if (parent)
|
|
|
|
parent_window = GTK_WINDOW (gtk_widget_get_toplevel (parent));
|
|
|
|
|
|
|
|
dialog = g_object_get_data (G_OBJECT (moo_app_get_instance()),
|
|
|
|
"moo-app-about-dialog");
|
|
|
|
|
|
|
|
if (!dialog)
|
|
|
|
{
|
|
|
|
const MooAppInfo *info;
|
2005-07-25 09:05:30 -07:00
|
|
|
char *name_markup, *copyright_markup, *title;
|
2005-09-11 06:44:14 -07:00
|
|
|
GtkLabel *name_label, *copyright_label;
|
|
|
|
GtkWidget *dialog, *logo;
|
2005-07-25 08:50:20 -07:00
|
|
|
|
|
|
|
info = moo_app_get_info (moo_app_get_instance());
|
|
|
|
|
2005-09-11 06:44:14 -07:00
|
|
|
xml = moo_glade_xml_new_from_buf (MOO_APP_ABOUT_GLADE_UI,
|
|
|
|
-1, "dialog", NULL);
|
|
|
|
g_return_if_fail (xml != NULL);
|
2005-07-25 08:50:20 -07:00
|
|
|
|
2005-09-11 06:44:14 -07:00
|
|
|
dialog = moo_glade_xml_get_widget (xml, "dialog");
|
|
|
|
|
|
|
|
title = g_strdup_printf ("About %s", info->full_name);
|
2005-07-25 09:05:30 -07:00
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
2005-09-11 06:44:14 -07:00
|
|
|
|
2005-07-25 08:50:20 -07:00
|
|
|
g_object_set_data (G_OBJECT (moo_app_get_instance()),
|
|
|
|
"moo-app-about-dialog",
|
|
|
|
dialog);
|
|
|
|
g_signal_connect (dialog, "delete-event",
|
|
|
|
G_CALLBACK (gtk_widget_hide_on_delete),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (dialog, "destroy",
|
|
|
|
G_CALLBACK (dialog_destroyed),
|
|
|
|
NULL);
|
|
|
|
|
2005-09-11 06:44:14 -07:00
|
|
|
name_label = moo_glade_xml_get_widget (xml, "name_label");
|
|
|
|
name_markup = g_strdup_printf ("<span size=\"xx-large\"><b>%s</b></span>",
|
|
|
|
info->full_name);
|
|
|
|
gtk_label_set_markup (name_label, name_markup);
|
|
|
|
|
|
|
|
copyright_label = moo_glade_xml_get_widget (xml, "copyright_label");
|
|
|
|
copyright_markup = g_strdup_printf ("<small>%s</small>", copyright);
|
|
|
|
gtk_label_set_markup (copyright_label, copyright_markup);
|
|
|
|
|
|
|
|
logo = moo_glade_xml_get_widget (xml, "logo");
|
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (logo), MOO_STOCK_APP, GTK_ICON_SIZE_DIALOG);
|
|
|
|
|
2005-07-25 08:50:20 -07:00
|
|
|
g_free (name_markup);
|
|
|
|
g_free (copyright_markup);
|
2005-07-25 09:05:30 -07:00
|
|
|
g_free (title);
|
2005-09-11 06:44:14 -07:00
|
|
|
moo_glade_xml_unref (xml);
|
2005-07-25 08:50:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
show_about_dialog (dialog, parent_window);
|
|
|
|
}
|
|
|
|
|
2005-06-22 11:20:32 -07:00
|
|
|
#endif /* !GTK_CHECK_VERSION(2,6,0) */
|