System info in about dialog
parent
ff46f7f30d
commit
00be4c2391
|
@ -13,6 +13,9 @@ AC_DEFUN([MOO_AC_FUNCS],[
|
|||
#for moofileutils.c
|
||||
AC_CHECK_FUNCS(unlink)
|
||||
|
||||
#for mooappabout.h
|
||||
AC_CHECK_HEADERS(sys/utsname.h)
|
||||
|
||||
################################################################################
|
||||
# Terminal stuff
|
||||
AC_CHECK_HEADERS([poll.h errno.h io.h fcntl.h sys/types.h sys/wait.h signal.h])
|
||||
|
|
|
@ -13,7 +13,8 @@ mooapp_include_headers = \
|
|||
|
||||
mooapp_sources = \
|
||||
$(mooapp_include_headers) \
|
||||
$(mooapp)/mooappdialogs.c \
|
||||
$(mooapp)/mooappabout.c \
|
||||
$(mooapp)/mooappabout.h \
|
||||
$(mooapp)/mooapp-prefs.c \
|
||||
$(mooapp)/mooapp-private.h \
|
||||
$(mooapp)/mooapp.c \
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<glade-interface>
|
||||
|
||||
<widget class="GtkDialog" id="credits">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Credits</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
|
@ -37,7 +36,9 @@
|
|||
<widget class="GtkButton" id="close">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="has_focus">True</property>
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
|
@ -133,7 +134,6 @@
|
|||
</widget>
|
||||
|
||||
<widget class="GtkDialog" id="license">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">License</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
|
@ -149,7 +149,7 @@
|
|||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">True</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox2">
|
||||
|
@ -166,7 +166,9 @@
|
|||
<widget class="GtkButton" id="close">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="has_focus">True</property>
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
|
@ -223,11 +225,12 @@
|
|||
</widget>
|
||||
|
||||
<widget class="GtkDialog" id="system">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">System Info</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">360</property>
|
||||
<property name="default_height">260</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="decorated">True</property>
|
||||
|
@ -237,7 +240,7 @@
|
|||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">True</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox3">
|
||||
|
@ -254,7 +257,9 @@
|
|||
<widget class="GtkButton" id="close">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="has_focus">True</property>
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
|
@ -272,13 +277,33 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table">
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">0</property>
|
||||
<property name="column_spacing">0</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTextView" id="textview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_CHAR</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
<property name="pixels_above_lines">0</property>
|
||||
<property name="pixels_below_lines">0</property>
|
||||
<property name="pixels_inside_wrap">0</property>
|
||||
<property name="left_margin">0</property>
|
||||
<property name="right_margin">0</property>
|
||||
<property name="indent">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
@ -291,7 +316,6 @@
|
|||
</widget>
|
||||
|
||||
<widget class="GtkDialog" id="dialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">About</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
|
@ -454,12 +478,13 @@
|
|||
<child>
|
||||
<widget class="GtkLabel" id="name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes"><span size="xx-large"><b>The App</b></span></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
|
@ -479,12 +504,13 @@
|
|||
<child>
|
||||
<widget class="GtkLabel" id="description">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">The App is an app</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
|
@ -504,12 +530,13 @@
|
|||
<child>
|
||||
<widget class="GtkLabel" id="copyright">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes"><small>© 2004-2006 The Author</small></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="selectable">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* mooapp/mooappdialogs.c
|
||||
* mooapp/mooappabout.c
|
||||
*
|
||||
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
|
@ -11,18 +11,16 @@
|
|||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mooapp/mooapp-private.h"
|
||||
#include "mooapp/mooappabout-glade.h"
|
||||
#include "mooapp/mooappabout.h"
|
||||
#include "mooapp/moohtml.h"
|
||||
#include "mooutils/moostock.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include "mooutils/moolinklabel.h"
|
||||
#include "mooutils/mooglade.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static GtkWidget *about_dialog;
|
||||
|
@ -103,6 +101,76 @@ show_license (void)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
show_system_info (void)
|
||||
{
|
||||
MooGladeXML *xml;
|
||||
GtkTextView *textview;
|
||||
GtkTextBuffer *buffer;
|
||||
GString *text;
|
||||
char *string;
|
||||
|
||||
if (system_info_dialog)
|
||||
{
|
||||
if (about_dialog)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (system_info_dialog),
|
||||
GTK_WINDOW (about_dialog));
|
||||
gtk_window_present (GTK_WINDOW (system_info_dialog));
|
||||
return;
|
||||
}
|
||||
|
||||
xml = moo_glade_xml_new_from_buf (MOO_APP_ABOUT_GLADE_UI, -1, "system");
|
||||
|
||||
system_info_dialog = moo_glade_xml_get_widget (xml, "system");
|
||||
g_return_if_fail (system_info_dialog != NULL);
|
||||
g_object_add_weak_pointer (G_OBJECT (system_info_dialog), (gpointer*) &system_info_dialog);
|
||||
g_signal_connect (system_info_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
textview = moo_glade_xml_get_widget (xml, "textview");
|
||||
buffer = gtk_text_view_get_buffer (textview);
|
||||
text = g_string_new (NULL);
|
||||
|
||||
#ifdef __WIN32__
|
||||
string = get_windows_name ();
|
||||
g_string_append_printf (text, "OS: %s\n", string ? string : "Win32");
|
||||
g_free (string);
|
||||
#else
|
||||
g_string_append (text, "OS: " MOO_OS_NAME "\n");
|
||||
|
||||
if ((string = get_uname ()))
|
||||
{
|
||||
g_string_append_printf (text, "OS details: %s", string);
|
||||
|
||||
if (!*string || string[strlen(string) - 1] != '\n')
|
||||
g_string_append (text, "\n");
|
||||
|
||||
g_free (string);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_string_append_printf (text, "GTK version: %d.%d.%d\n",
|
||||
gtk_major_version,
|
||||
gtk_minor_version,
|
||||
gtk_micro_version);
|
||||
g_string_append_printf (text, "Built with GTK %d.%d.%d\n",
|
||||
GTK_MAJOR_VERSION,
|
||||
GTK_MINOR_VERSION,
|
||||
GTK_MICRO_VERSION);
|
||||
|
||||
string = get_python_info ();
|
||||
g_string_append_printf (text, "Python: %s\n", string ? string : "None");
|
||||
g_free (string);
|
||||
|
||||
gtk_text_buffer_set_text (buffer, text->str, -1);
|
||||
g_string_free (text, TRUE);
|
||||
|
||||
if (about_dialog)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (system_info_dialog),
|
||||
GTK_WINDOW (about_dialog));
|
||||
gtk_window_present (GTK_WINDOW (system_info_dialog));
|
||||
}
|
||||
|
||||
|
||||
#define COPYRIGHT_SYMBOL "\302\251"
|
||||
static const char *copyright = COPYRIGHT_SYMBOL " 2004-2006 Yevgen Muntyan";
|
||||
|
||||
|
@ -157,8 +225,8 @@ create_about_dialog (void)
|
|||
g_signal_connect (button, "clicked", G_CALLBACK (show_credits), NULL);
|
||||
button = moo_glade_xml_get_widget (xml, "license_button");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (show_license), NULL);
|
||||
// button = moo_glade_xml_get_widget (xml, "system_button");
|
||||
// g_signal_connect (button, "clicked", G_CALLBACK (show_system_info), NULL);
|
||||
button = moo_glade_xml_get_widget (xml, "system_button");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (show_system_info), NULL);
|
||||
|
||||
g_free (title);
|
||||
g_object_unref (xml);
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* mooapp/mooappabout.h
|
||||
*
|
||||
* Copyright (C) 2004-2006 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.
|
||||
*/
|
||||
|
||||
#ifndef __MOO_APP_ABOUT_H__
|
||||
#define __MOO_APP_ABOUT_H__
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_UTSNAME_H
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#if defined(MOO_OS_MINGW)
|
||||
#define MOO_OS_NAME "Win32"
|
||||
#elif defined(MOO_OS_DARWIN)
|
||||
#define MOO_OS_NAME "Darwin"
|
||||
#elif defined(MOO_OS_BSD)
|
||||
#define MOO_OS_NAME "BSD"
|
||||
#elif defined(MOO_OS_UNIX)
|
||||
#define MOO_OS_NAME "UNIX"
|
||||
#else
|
||||
#define MOO_OS_NAME "Unknown???"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_UTSNAME_H
|
||||
static char *
|
||||
get_uname (void)
|
||||
{
|
||||
struct utsname name;
|
||||
|
||||
if (uname (&name))
|
||||
{
|
||||
int err = errno;
|
||||
g_critical ("%s: %s", G_STRLOC, g_strerror (err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_strdup_printf ("%s %s (%s), %s", name.sysname,
|
||||
name.release, name.version, name.machine);
|
||||
}
|
||||
#elif defined __WIN32__
|
||||
static char *
|
||||
get_windows_name (void)
|
||||
{
|
||||
OSVERSIONINFOEX ver;
|
||||
|
||||
memset (&ver, 0, sizeof (ver));
|
||||
ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
|
||||
if (!GetVersionEx (&ver))
|
||||
return g_strdup ("Win32");
|
||||
|
||||
switch (ver.dwMajorVersion)
|
||||
{
|
||||
case 4: /* Windows NT 4.0, Windows Me, Windows 98, or Windows 95 */
|
||||
switch (ver.dwMinorVersion)
|
||||
{
|
||||
case 0: /* Windows NT 4.0 or Windows95 */
|
||||
if (ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
||||
return g_strdup ("Windows 95");
|
||||
else
|
||||
return g_strdup ("Windows NT 4.0");
|
||||
|
||||
case 10:
|
||||
return g_strdup ("Windows 98");
|
||||
|
||||
case 90:
|
||||
return g_strdup ("Windows 98");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 5: /* Windows Server 2003 R2, Windows Server 2003, Windows XP, or Windows 2000 */
|
||||
switch (ver.dwMinorVersion)
|
||||
{
|
||||
case 0:
|
||||
return g_strdup ("Windows 2000");
|
||||
case 1:
|
||||
return g_strdup ("Windows XP");
|
||||
case 2:
|
||||
return g_strdup ("Windows Server 2003");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 6:
|
||||
memset (&ver, 0, sizeof (ver));
|
||||
ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
||||
|
||||
if (!GetVersionEx (&ver))
|
||||
return g_strdup ("Windows Vista");
|
||||
|
||||
if (ver.wProductType == VER_NT_WORKSTATION)
|
||||
return g_strdup ("Windows Vista");
|
||||
else
|
||||
return g_strdup ("Windows Server \"Longhorn\"");
|
||||
}
|
||||
|
||||
return g_strdup ("Win32");
|
||||
}
|
||||
#else
|
||||
static char *
|
||||
get_uname (void)
|
||||
{
|
||||
char *string;
|
||||
|
||||
if (g_spawn_command_line_sync ("uname -a", &string, NULL, NULL, NULL))
|
||||
return string;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static char *
|
||||
get_python_info (void)
|
||||
{
|
||||
if (!moo_python_running ())
|
||||
return NULL;
|
||||
|
||||
return moo_python_get_info ();
|
||||
}
|
||||
|
||||
|
||||
#endif /* __MOO_APP_ABOUT_H__ */
|
|
@ -184,11 +184,19 @@ err_print (void)
|
|||
}
|
||||
|
||||
|
||||
static char *
|
||||
get_info (void)
|
||||
{
|
||||
return g_strdup_printf ("%s %s", Py_GetVersion (), Py_GetPlatform ());
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
moo_python_api_init (void)
|
||||
{
|
||||
static MooPyAPI api = {
|
||||
incref, decref, err_print,
|
||||
get_info,
|
||||
run_simple_string, run_string, run_file,
|
||||
py_object_from_gobject,
|
||||
get_script_dict,
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MOO_PY_API_VERSION 89
|
||||
#define MOO_PY_API_VERSION 90
|
||||
|
||||
typedef struct _MooPyAPI MooPyAPI;
|
||||
typedef struct _MooPyObject MooPyObject;
|
||||
|
@ -29,6 +29,8 @@ struct _MooPyAPI {
|
|||
void (*decref) (MooPyObject *obj);
|
||||
void (*err_print) (void);
|
||||
|
||||
char* (*get_info) (void);
|
||||
|
||||
MooPyObject* (*run_simple_string) (const char *str);
|
||||
MooPyObject* (*run_string) (const char *str,
|
||||
MooPyObject *locals,
|
||||
|
@ -61,6 +63,8 @@ gboolean moo_python_init (guint version,
|
|||
#define moo_Py_DECREF moo_py_api->decref
|
||||
#define moo_PyErr_Print moo_py_api->err_print
|
||||
|
||||
#define moo_python_get_info moo_py_api->get_info
|
||||
|
||||
#define moo_python_run_simple_string moo_py_api->run_simple_string
|
||||
#define moo_python_run_string moo_py_api->run_string
|
||||
#define moo_python_run_file moo_py_api->run_file
|
||||
|
|
Loading…
Reference in New Issue