--- a/po/POTFILES.in Mon Sep 15 10:19:57 2008 +0200
+++ b/po/POTFILES.in Tue Sep 16 10:46:31 2008 +0200
@@ -3,9 +3,12 @@ src/busybox.c
src/busybox.c
src/desktop.c
src/effects.c
+src/network.c
+src/gtk_helpers.c
src/users.c
src/utils.c
src/window_bio_mess_init.c
src/window_bio_mess_misc.c
src/window_login.c
+src/window_network.c
src/window_password.c
--- a/src/9dm.c Mon Sep 15 10:19:57 2008 +0200
+++ b/src/9dm.c Tue Sep 16 10:46:31 2008 +0200
@@ -36,10 +36,11 @@
#include "minidesk_network.h"
#include "desktop.h"
#include "users.h"
-#include "window_login.h"
-#include "window_password.h"
#include "window_bio_mess_init.h"
#include "window_bio_mess_misc.h"
+#include "window_login.h"
+#include "window_network.h"
+#include "window_password.h"
#include "bio_functions.h"
#include "gtk_helpers.h"
#include "network.h"
@@ -85,7 +86,7 @@ int main(int argc, char **argv)
{
GdkScreen *screen;
GList *users_list;
- GtkWidget *main_window;
+ GtkWidget *main_window, *network_window;
int main_window_height;
#ifdef HAVE_GETOPT_LONG
int option_index = 0;
@@ -170,6 +171,9 @@ int main(int argc, char **argv)
#if HAVE_THINKFINGER
g_timeout_add(TIMEOUT_1*1000, bio_sensor_message_timeout_cb,(gpointer)main_window_height);
#endif
+
+ network_window = window_network_init();
+ gtk_widget_show(network_window);
g_timeout_add(200, network_check_available_cb, NULL);
gtk_widget_show(main_window);
@@ -351,6 +355,7 @@ network_check_available_cb(const gpointe
old_status = network_status;
+ window_network_set_network_status(network_status);
switch (network_status)
{
case NETWORK_STATUS_OK:
--- a/src/Makefile.am Mon Sep 15 10:19:57 2008 +0200
+++ b/src/Makefile.am Tue Sep 16 10:46:31 2008 +0200
@@ -29,6 +29,8 @@ 9dm_SOURCES= \
window_bio_mess_misc.h \
window_login.c \
window_login.h \
+ window_network.c \
+ window_network.h \
window_password.c \
window_password.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/window_network.c Tue Sep 16 10:46:31 2008 +0200
@@ -0,0 +1,195 @@
+/*
+ * Stonage: a puzzle game
+ * Copyright (C) 2001 Luc Saillard <luc@saillard.org>
+ *
+ * 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.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "9dm.h"
+#include "desktop.h"
+#include "window_network.h"
+#include "utils.h"
+
+/*
+ *
+ *
+ */
+
+/*
+ *
+ *
+ */
+static void on_realize_event(GtkWidget *widget, gpointer data);
+
+
+
+static GtkWidget *network_status_image;
+static GtkWidget *network_status_label;
+
+/*
+ *
+ *
+ */
+GtkWidget *
+window_network_init(void)
+{
+ GtkWidget *window, *image, *hbox, *vbox;
+ GtkWidget *configure_network_button;
+ GdkPixmap *dialog_pixmap_background;
+ GdkPixbuf *dialog_pixbuf, *dialog_pixbuf_under, *pixbuf;
+ int dialog_height, dialog_width;
+ int window_x, window_y;
+ GtkIconTheme *theme = gtk_icon_theme_get_default();
+
+ /* Load first, the box, to known the size of the biomess box */
+ dialog_pixbuf = gdk_pixbuf_new_from_path("biomess_box.svg", 0);
+ if (!dialog_pixbuf)
+ {
+ trace("Can't load biomess_box.svg\n");
+ return NULL;
+ }
+
+ dialog_width = gdk_pixbuf_get_width(dialog_pixbuf);
+ dialog_height = gdk_pixbuf_get_height(dialog_pixbuf);
+ window_x = 64;
+ window_y = screen_height - dialog_height - 64;
+
+ /* Get the pixel under the dialog we want to display */
+ dialog_pixbuf_under = gdk_pixbuf_get_from_drawable(NULL,
+ gdk_get_default_root_window(),
+ NULL,
+ window_x, window_y,
+ 0, 0,
+ dialog_width, dialog_height);
+
+ /* ... put the logo box, over the background pixmap */
+ dialog_pixmap_background = gdk_pixmap_new(NULL, dialog_width, dialog_height, 24);
+
+ gdk_draw_pixbuf(dialog_pixmap_background, NULL, dialog_pixbuf_under,
+ 0, 0,
+ 0, 0,
+ -1, -1,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+
+ gdk_draw_pixbuf(dialog_pixmap_background, NULL, dialog_pixbuf,
+ 0, 0,
+ 0, 0,
+ -1, -1,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+
+ g_object_unref(dialog_pixbuf_under);
+ g_object_unref(dialog_pixbuf);
+
+ /* Create the top widget level */
+ window = gtk_window_new(GTK_WINDOW_POPUP);
+ gtk_widget_set_uposition(window, window_x, window_y);
+ gtk_widget_set_size_request(window, dialog_width, dialog_height);
+
+ g_signal_connect(G_OBJECT(window), "realize", G_CALLBACK(on_realize_event), dialog_pixmap_background);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window), hbox);
+
+ pixbuf = gtk_icon_theme_load_icon(theme, "network-offline", 64, 0, NULL);
+ if (pixbuf)
+ {
+ network_status_image = image = gtk_image_new_from_pixbuf(pixbuf);
+ gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 16);
+ g_object_unref(pixbuf);
+ }
+
+
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 8);
+
+ network_status_label = gtk_label_new(_("Checking connectivity"));
+ gtk_box_pack_start(GTK_BOX(vbox), network_status_label, TRUE, FALSE, 8);
+
+ configure_network_button = gtk_button_new();
+ image = gtk_image_new_from_icon_name("gtk-refresh", GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image(GTK_BUTTON(configure_network_button), image);
+ gtk_button_set_label(GTK_BUTTON(configure_network_button), _("Configure network"));
+ gtk_box_pack_start(GTK_BOX(vbox), configure_network_button, TRUE, FALSE, 8);
+
+ gtk_widget_show_all(hbox);
+
+ return window;
+}
+
+
+/*
+ *
+ *
+ */
+static void
+on_realize_event(GtkWidget *widget, gpointer user_data)
+{
+ GdkPixmap *bg_pixmap = (GdkPixmap *)user_data;
+
+ GtkStyle *style = gtk_style_new();
+ style->bg_pixmap[GTK_STATE_NORMAL] = bg_pixmap;
+ gtk_widget_set_style(widget, style);
+}
+
+
+void
+window_network_set_network_status(enum network_status network_status)
+{
+ const char *icon_name;
+ GdkPixbuf *pixbuf;
+
+ if (network_status_image == NULL)
+ return;
+
+ switch (network_status)
+ {
+ case NETWORK_STATUS_OK:
+ icon_name = "network-idle";
+ gtk_label_set_markup(GTK_LABEL(network_status_label), _("<span foreground=\"#107f10\">Network OK</span>"));
+ break;
+
+ case NETWORK_STATUS_BAD:
+ icon_name = "network-offline";
+ gtk_label_set_markup(GTK_LABEL(network_status_label), _("<span foreground=\"red\">No Network</span>"));
+ break;
+
+ case NETWORK_STATUS_UNKNOWN:
+ icon_name = "network-error";
+ gtk_label_set_markup(GTK_LABEL(network_status_label), _("<span foreground=\"red\">Network Error</span>"));
+ break;
+
+ default:
+ return;
+ }
+
+ pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), icon_name, 64, 0, NULL);
+ if (pixbuf)
+ {
+ gtk_image_set_from_pixbuf(GTK_IMAGE(network_status_image), pixbuf);
+ g_object_unref(pixbuf);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/window_network.h Tue Sep 16 10:46:31 2008 +0200
@@ -0,0 +1,32 @@
+/*
+ * Stonage: a puzzle game
+ * Copyright (C) 2001 Luc Saillard <luc@saillard.org>
+ *
+ * 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.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __WINDOW_NETWORK__H
+#define __WINDOW_NETWORK__H
+
+#include <gtk/gtk.h>
+
+#include "network.h"
+
+GtkWidget *window_network_init(void);
+void window_network_set_network_status(enum network_status network_status);
+
+#endif
+