summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-11-25 20:54:22 +0100
committerPali Rohár <pali.rohar@gmail.com>2012-11-25 20:54:22 +0100
commitedb4793863b19528b3551f977c081472bea8968b (patch)
tree9037a37e5b967cb9a0c6407b0f4ccd4440577cfa
parent880a3e084651509177b8cbcc1104f7cee3c97ac6 (diff)
download0xFFFF-edb4793863b19528b3551f977c081472bea8968b.tar.bz2
Remove old gui from tree
-rw-r--r--0xFFFF.desktop9
-rw-r--r--Makefile10
-rw-r--r--src/gui/Makefile21
-rw-r--r--src/gui/extras.vapi10
-rw-r--r--src/gui/gui.c1163
-rw-r--r--src/gui/gui.gtkaml.orig356
-rw-r--r--src/gui/gui.gtkon321
7 files changed, 1 insertions, 1889 deletions
diff --git a/0xFFFF.desktop b/0xFFFF.desktop
deleted file mode 100644
index 03a3d0e..0000000
--- a/0xFFFF.desktop
+++ /dev/null
@@ -1,9 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Name=0xFFFF
-Comment=Free flasher for the Nokia internet tablets
-Exec=gnome-terminal -e goxf
-Icon=gnome-terminal.png
-Terminal=false
-Type=Application
-Categories=GTK;Application;Utility;
diff --git a/Makefile b/Makefile
index 58156ff..97fdc3a 100644
--- a/Makefile
+++ b/Makefile
@@ -2,12 +2,9 @@ include config.mk
PREFIX?=/usr/local
DESTDIR?=
-all: frontend
+all:
cd src && ${MAKE} all
-frontend:
- -cd src/gui && ${MAKE} all
-
static:
cd src && ${MAKE} static
@@ -19,12 +16,7 @@ clean:
install:
mkdir -p ${DESTDIR}${PREFIX}/bin
- mkdir -p ${DESTDIR}${PREFIX}/share/applications/
cp src/0xFFFF ${DESTDIR}${PREFIX}/bin
- -cp src/gui/goxf ${DESTDIR}${PREFIX}/bin
- cp 0xFFFF.desktop ${DESTDIR}${PREFIX}/share/applications/
deinstall:
rm -f ${DESTDIR}${PREFIX}/bin/0xFFFF
- rm -f ${DESTDIR}${PREFIX}/bin/goxf
- rm ${DESTDIR}${PREFIX}/share/applications/0xFFFF.desktop
diff --git a/src/gui/Makefile b/src/gui/Makefile
deleted file mode 100644
index 3fb5c85..0000000
--- a/src/gui/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-include ../../config.mk
-
-ifeq (${HAVE_GUI},1)
-all: goxf
-
-goxf:
- ${CC} -I../squeue ../squeue/squeue.c ../fpid.c gui.c `pkg-config --cflags --libs gtk+-2.0` -o goxf
-
-c:
- gtkamlc --save-temps --Xcc=-I../squeue ../squeue/squeue.c ../fpid.c ../squeue/squeue.vapi gui.gtkon extras.vapi --pkg gtk+-2.0 -o goxf
-
-test:
- valac --save-temps --Xcc=-I.. squeue.vapi test.vala ../squeue.c -o v
- valac --save-temps --Xcc=-I.. squeue.vapi client.vala ../squeue.c -o c
-else
-all:
- @true
-endif
-
-clean:
- rm -f goxf *.o *.c
diff --git a/src/gui/extras.vapi b/src/gui/extras.vapi
deleted file mode 100644
index d8f2ddc..0000000
--- a/src/gui/extras.vapi
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Extras {
- public class External {
- [CCode (cname = "system")]
- public static int system(string cmd);
- [CCode (cname = "fpid_file")]
- public static string fpid_file(string file);
- [CCode (cname = "fpid_size")]
- public static long fpid_size(string file);
- }
-}
diff --git a/src/gui/gui.c b/src/gui/gui.c
deleted file mode 100644
index f8a1ffc..0000000
--- a/src/gui/gui.c
+++ /dev/null
@@ -1,1163 +0,0 @@
-/* gui.c generated by valac 0.11.2.14-5f971, the Vala compiler
- * generated from gui.vala, do not modify */
-
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gtk/gtk.h>
-#include <squeue.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib/gstdio.h>
-#include <stdio.h>
-#include <float.h>
-#include <math.h>
-#include <gdk/gdk.h>
-
-
-#define TYPE_MAIN_WINDOW (main_window_get_type ())
-#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
-#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
-#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
-#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
-#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))
-
-typedef struct _MainWindow MainWindow;
-typedef struct _MainWindowClass MainWindowClass;
-typedef struct _MainWindowPrivate MainWindowPrivate;
-#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-#define _g_free0(var) (var = (g_free (var), NULL))
-#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
-
-struct _MainWindow {
- GtkWindow parent_instance;
- MainWindowPrivate * priv;
-};
-
-struct _MainWindowClass {
- GtkWindowClass parent_class;
-};
-
-struct _MainWindowPrivate {
- GtkTreeView* tv;
- GtkProgressBar* pb;
- GtkAboutDialog* aboutdialog1;
-};
-
-
-static gpointer main_window_parent_class = NULL;
-static struct squeue_t* main_window_q;
-static struct squeue_t* main_window_q = NULL;
-static struct squeue_t* main_window_p;
-static struct squeue_t* main_window_p = NULL;
-static MainWindow* main_window_viewer;
-static MainWindow* main_window_viewer = NULL;
-
-GType main_window_get_type (void) G_GNUC_CONST;
-#define MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN_WINDOW, MainWindowPrivate))
-enum {
- MAIN_WINDOW_DUMMY_PROPERTY
-};
-static void main_window_doCloseApplication (MainWindow* self);
-static void main_window_OnReset (MainWindow* self);
-static void main_window_OnFileFlashEvent (MainWindow* self);
-gboolean main_window_showYesNo (MainWindow* self, const gchar* s);
-void main_window_showMessage (MainWindow* self, const gchar* s, GtkMessageType mt);
-static void main_window_OnFileOpenEvent (MainWindow* self);
-void main_window_add_file (MainWindow* self, const gchar* type, const gchar* size, const gchar* file);
-gboolean main_window_loadFile (MainWindow* self, const gchar* filename);
-void main_window_showError (MainWindow* self, const gchar* s);
-static void main_window_OnMenuHelpAboutActivatedEvent (MainWindow* self);
-static void _lambda0_ (gint x, MainWindow* self);
-static void __lambda0__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
-static void main_window_OnFileNewEvent (MainWindow* self);
-void main_window_list_clear (MainWindow* self);
-static void main_window_OnQuitEvent (MainWindow* self);
-void main_window_list_del (MainWindow* self);
-void main_window_setup_treeview (GtkTreeView* view);
-gboolean main_window_readFunc (void);
-static void main_window_OnGetInformation (MainWindow* self);
-void main_window_msg (MainWindow* self, const gchar* str);
-static void main_window_OnConnect (MainWindow* self);
-static void main_window_OnStop (MainWindow* self);
-static gboolean main_window_chk_queues (MainWindow* self);
-static gint main_window_main (gchar** args, int args_length1);
-MainWindow* main_window_new (void);
-MainWindow* main_window_construct (GType object_type);
-static gboolean _lambda1_ (GtkWidget* x, GdkEvent* y);
-static gboolean __lambda1__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self);
-static GObject * main_window_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-static void _main_window_OnFileNewEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnFileOpenEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnQuitEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnConnect_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnStop_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnGetInformation_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnReset_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnMenuHelpAboutActivatedEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _main_window_OnConnect_gtk_button_clicked (GtkButton* _sender, gpointer self);
-static void _main_window_OnStop_gtk_button_clicked (GtkButton* _sender, gpointer self);
-static void _main_window_OnGetInformation_gtk_button_clicked (GtkButton* _sender, gpointer self);
-static void _main_window_OnFileOpenEvent_gtk_button_clicked (GtkButton* _sender, gpointer self);
-static void _main_window_list_del_gtk_button_clicked (GtkButton* _sender, gpointer self);
-static void _main_window_OnFileFlashEvent_gtk_button_clicked (GtkButton* _sender, gpointer self);
-static gboolean _gtk_widget_hide_on_delete_gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self);
-static void main_window_finalize (GObject* obj);
-static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
-static gint _vala_array_length (gpointer array);
-
-
-static void main_window_doCloseApplication (MainWindow* self) {
- g_return_if_fail (self != NULL);
- gtk_main_quit ();
-}
-
-
-static void main_window_OnReset (MainWindow* self) {
- g_return_if_fail (self != NULL);
- squeue_push (main_window_q, "reset:device", 1);
-}
-
-
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
-}
-
-
-static void main_window_OnFileFlashEvent (MainWindow* self) {
- GtkTreeModel* _tmp0_ = NULL;
- GtkListStore* _tmp1_;
- GtkListStore* ls;
- const gchar* str;
- GtkTreeIter iter = {0};
- gint _tmp2_;
- gint n;
- g_return_if_fail (self != NULL);
- _tmp0_ = gtk_tree_view_get_model (self->priv->tv);
- _tmp1_ = _g_object_ref0 (GTK_LIST_STORE (_tmp0_));
- ls = _tmp1_;
- str = NULL;
- _tmp2_ = gtk_tree_model_iter_n_children ((GtkTreeModel*) ls, NULL);
- n = _tmp2_;
- if (n > 0) {
- gboolean _tmp3_;
- _tmp3_ = main_window_showYesNo (self, "Do you want to flash these files?");
- if (_tmp3_) {
- GtkTreeIter _tmp4_ = {0};
- gtk_tree_model_get_iter_first ((GtkTreeModel*) ls, &_tmp4_);
- iter = _tmp4_;
- {
- gboolean _tmp5_;
- _tmp5_ = TRUE;
- while (TRUE) {
- if (!_tmp5_) {
- gboolean _tmp6_;
- _tmp6_ = gtk_tree_model_iter_next ((GtkTreeModel*) ls, &iter);
- if (!_tmp6_) {
- break;
- }
- }
- _tmp5_ = FALSE;
- gtk_tree_model_get ((GtkTreeModel*) ls, &iter, 2, &str, -1, -1);
- squeue_push2 (main_window_q, "flash", str, 1);
- }
- }
- }
- } else {
- main_window_showMessage (self, "No files selected", GTK_MESSAGE_ERROR);
- }
- _g_object_unref0 (ls);
-}
-
-
-static void main_window_OnFileOpenEvent (MainWindow* self) {
- GtkFileChooserDialog* _tmp0_ = NULL;
- GtkFileChooserDialog* fc;
- gint _tmp1_;
- gint resp;
- g_return_if_fail (self != NULL);
- _tmp0_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Select file to open", (GtkWindow*) self, GTK_FILE_CHOOSER_ACTION_OPEN, "gtk-cancel", GTK_RESPONSE_CANCEL, "gtk-open", GTK_RESPONSE_ACCEPT, NULL);
- fc = g_object_ref_sink (_tmp0_);
- _tmp1_ = gtk_dialog_run ((GtkDialog*) fc);
- resp = _tmp1_;
- gtk_widget_hide ((GtkWidget*) fc);
- if (resp == GTK_RESPONSE_ACCEPT) {
- gchar* _tmp2_ = NULL;
- gchar* file;
- gchar* _tmp3_ = NULL;
- const gchar* type;
- glong _tmp4_;
- gchar* _tmp5_ = NULL;
- gchar* size;
- _tmp2_ = gtk_file_chooser_get_filename ((GtkFileChooser*) fc);
- file = _tmp2_;
- _tmp3_ = fpid_file (file);
- type = _tmp3_;
- _tmp4_ = fpid_size (file);
- _tmp5_ = g_strdup_printf ("%ld", _tmp4_);
- size = _tmp5_;
- if (type == NULL) {
- main_window_showMessage (self, "Invalid file type", GTK_MESSAGE_ERROR);
- } else {
- main_window_add_file (self, type, size, file);
- }
- _g_free0 (size);
- _g_free0 (file);
- }
- gtk_object_destroy ((GtkObject*) fc);
- _g_object_unref0 (fc);
-}
-
-
-gboolean main_window_loadFile (MainWindow* self, const gchar* filename) {
- gboolean result = FALSE;
- gint err;
- gchar* contents;
- gsize length = 0UL;
- gchar* _tmp0_ = NULL;
- gsize _tmp1_;
- GError * _inner_error_ = NULL;
- g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- err = 0;
- contents = NULL;
- g_file_get_contents (filename, &_tmp0_, &_tmp1_, &_inner_error_);
- _g_free0 (contents);
- contents = _tmp0_;
- length = _tmp1_;
- if (_inner_error_ != NULL) {
- _g_free0 (contents);
- goto __catch0_g_error;
- }
- _g_free0 (contents);
- goto __finally0;
- __catch0_g_error:
- {
- GError * e;
- gchar* _tmp2_;
- e = _inner_error_;
- _inner_error_ = NULL;
- _tmp2_ = g_strconcat ("Unexpected error while loading the file, please contact the author wit" \
-"h the following information:\n" \
-"\n", e->message, NULL);
- main_window_showError (self, _tmp2_);
- _g_free0 (_tmp2_);
- err++;
- _g_error_free0 (e);
- }
- __finally0:
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return FALSE;
- }
- result = err == 0;
- return result;
-}
-
-
-gboolean main_window_showYesNo (MainWindow* self, const gchar* s) {
- gboolean result = FALSE;
- GtkMessageDialog* _tmp0_ = NULL;
- GtkMessageDialog* md;
- gint _tmp1_;
- gint ret;
- g_return_val_if_fail (self != NULL, FALSE);
- g_return_val_if_fail (s != NULL, FALSE);
- _tmp0_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, s);
- md = g_object_ref_sink (_tmp0_);
- _tmp1_ = gtk_dialog_run ((GtkDialog*) md);
- ret = _tmp1_;
- gtk_object_destroy ((GtkObject*) md);
- result = ret == GTK_RESPONSE_YES;
- _g_object_unref0 (md);
- return result;
-}
-
-
-void main_window_showMessage (MainWindow* self, const gchar* s, GtkMessageType mt) {
- GtkMessageDialog* _tmp0_ = NULL;
- GtkMessageDialog* md;
- g_return_if_fail (self != NULL);
- g_return_if_fail (s != NULL);
- _tmp0_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) self, GTK_DIALOG_DESTROY_WITH_PARENT, mt, GTK_BUTTONS_CLOSE, s);
- md = g_object_ref_sink (_tmp0_);
- gtk_dialog_run ((GtkDialog*) md);
- gtk_object_destroy ((GtkObject*) md);
- _g_object_unref0 (md);
-}
-
-
-static void _lambda0_ (gint x, MainWindow* self) {
- gtk_widget_hide ((GtkWidget*) self->priv->aboutdialog1);
-}
-
-
-static void __lambda0__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
- _lambda0_ (response_id, self);
-}
-
-
-static void main_window_OnMenuHelpAboutActivatedEvent (MainWindow* self) {
- g_return_if_fail (self != NULL);
- gtk_window_set_transient_for ((GtkWindow*) self->priv->aboutdialog1, (GtkWindow*) self);
- g_signal_connect_object ((GtkDialog*) self->priv->aboutdialog1, "response", (GCallback) __lambda0__gtk_dialog_response, self, 0);
- gtk_dialog_run ((GtkDialog*) self->priv->aboutdialog1);
-}
-
-
-void main_window_showError (MainWindow* self, const gchar* s) {
- GtkMessageDialog* _tmp0_ = NULL;
- GtkMessageDialog* md;
- g_return_if_fail (self != NULL);
- g_return_if_fail (s != NULL);
- _tmp0_ = (GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, s);
- md = g_object_ref_sink (_tmp0_);
- gtk_dialog_run ((GtkDialog*) md);
- gtk_object_destroy ((GtkObject*) md);
- _g_object_unref0 (md);
-}
-
-
-static void main_window_OnFileNewEvent (MainWindow* self) {
- g_return_if_fail (self != NULL);
- main_window_list_clear (self);
-}
-
-
-static void main_window_OnQuitEvent (MainWindow* self) {
- g_return_if_fail (self != NULL);
- main_window_doCloseApplication (self);
-}
-
-
-void main_window_list_clear (MainWindow* self) {
- GtkTreeModel* _tmp0_ = NULL;
- g_return_if_fail (self != NULL);
- _tmp0_ = gtk_tree_view_get_model (self->priv->tv);
- gtk_list_store_clear (GTK_LIST_STORE (_tmp0_));
-}
-
-
-void main_window_list_del (MainWindow* self) {
- GtkTreeIter iter = {0};
- GtkTreeModel* model;
- GtkTreeSelection* _tmp0_ = NULL;
- GtkTreeSelection* _tmp1_;
- GtkTreeSelection* sel;
- gint _tmp2_;
- g_return_if_fail (self != NULL);
- model = NULL;
- _tmp0_ = gtk_tree_view_get_selection (self->priv->tv);
- _tmp1_ = _g_object_ref0 (_tmp0_);
- sel = _tmp1_;
- _tmp2_ = gtk_tree_selection_count_selected_rows (sel);
- if (_tmp2_ == 1) {
- GtkTreeModel* _tmp3_ = NULL;
- GtkTreeIter _tmp4_ = {0};
- GtkTreeModel* _tmp5_;
- GtkTreeModel* _tmp6_ = NULL;
- gtk_tree_selection_get_selected (sel, &_tmp3_, &_tmp4_);
- _g_object_unref0 (model);
- _tmp5_ = _g_object_ref0 (_tmp3_);
- model = _tmp5_;
- iter = _tmp4_;
- _tmp6_ = gtk_tree_view_get_model (self->priv->tv);
- gtk_list_store_remove (GTK_LIST_STORE (_tmp6_), &iter);
- }
- _g_object_unref0 (sel);
- _g_object_unref0 (model);
-}
-
-
-void main_window_add_file (MainWindow* self, const gchar* type, const gchar* size, const gchar* file) {
- GtkTreeModel* _tmp0_ = NULL;
- GtkListStore* _tmp1_;
- GtkListStore* listmodel;
- GtkTreeIter iter = {0};
- GtkTreeIter _tmp2_ = {0};
- g_return_if_fail (self != NULL);
- g_return_if_fail (type != NULL);
- g_return_if_fail (size != NULL);
- g_return_if_fail (file != NULL);
- _tmp0_ = gtk_tree_view_get_model (self->priv->tv);
- _tmp1_ = _g_object_ref0 (GTK_LIST_STORE (_tmp0_));
- listmodel = _tmp1_;
- gtk_list_store_append (listmodel, &_tmp2_);
- iter = _tmp2_;
- gtk_list_store_set (listmodel, &iter, 0, type, 1, size, 2, file, -1, -1);
- _g_object_unref0 (listmodel);
-}
-
-
-void main_window_setup_treeview (GtkTreeView* view) {
- GtkListStore* _tmp0_ = NULL;
- GtkListStore* listmodel;
- GtkCellRendererText* _tmp1_ = NULL;
- GtkCellRendererText* _tmp2_;
- GtkCellRendererText* _tmp3_ = NULL;
- GtkCellRendererText* _tmp4_;
- GtkCellRendererText* _tmp5_ = NULL;
- GtkCellRendererText* cell;
- g_return_if_fail (view != NULL);
- _tmp0_ = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- listmodel = _tmp0_;
- gtk_tree_view_set_model (view, (GtkTreeModel*) listmodel);
- _tmp1_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
- _tmp2_ = g_object_ref_sink (_tmp1_);
- gtk_tree_view_insert_column_with_attributes (view, -1, "Type", (GtkCellRenderer*) _tmp2_, "text", 0, NULL, NULL);
- _g_object_unref0 (_tmp2_);
- _tmp3_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
- _tmp4_ = g_object_ref_sink (_tmp3_);
- gtk_tree_view_insert_column_with_attributes (view, -1, "Size", (GtkCellRenderer*) _tmp4_, "text", 1, NULL, NULL);
- _g_object_unref0 (_tmp4_);
- _tmp5_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
- cell = g_object_ref_sink (_tmp5_);
- g_object_set ((GObject*) cell, "foreground_set", TRUE, NULL, NULL);
- gtk_tree_view_insert_column_with_attributes (view, -1, "Name", (GtkCellRenderer*) cell, "text", 2, "foreground", 3, NULL, NULL);
- _g_object_unref0 (cell);
- _g_object_unref0 (listmodel);
-}
-
-
-static gchar string_get (const gchar* self, glong index) {
- gchar result = '\0';
- g_return_val_if_fail (self != NULL, '\0');
- result = ((gchar*) self)[index];
- return result;
-}
-
-
-gboolean main_window_readFunc (void) {
- gboolean result = FALSE;
- const gchar* _tmp0_ = NULL;
- const gchar* msg;
- gboolean _tmp1_ = FALSE;
- _tmp0_ = squeue_get (main_window_p, 0);
- msg = _tmp0_;
- if (msg != NULL) {
- gchar _tmp2_;
- _tmp2_ = string_get (msg, (glong) 0);
- _tmp1_ = _tmp2_ != '\0';
- } else {
- _tmp1_ = FALSE;
- }
- if (_tmp1_) {
- gchar** _tmp3_;
- gchar** _tmp4_ = NULL;
- gint foo_length1;
- gint _foo_size_;
- gchar** _tmp5_;
- gchar** foo;
- fprintf (stdout, "[<] msg received: %s\n", msg);
- _tmp4_ = _tmp3_ = g_strsplit (msg, ":", 2);
- _tmp5_ = _tmp4_;
- foo_length1 = _vala_array_length (_tmp3_);
- _foo_size_ = foo_length1;
- foo = _tmp5_;
- if (foo[1] != NULL) {
- const gchar* _tmp6_;
- GQuark _tmp7_;
- static GQuark _tmp7__label0 = 0;
- static GQuark _tmp7__label1 = 0;
- static GQuark _tmp7__label2 = 0;
- _tmp6_ = foo[0];
- _tmp7_ = (NULL == _tmp6_) ? 0 : g_quark_from_string (_tmp6_);
- if (_tmp7_ == ((0 != _tmp7__label0) ? _tmp7__label0 : (_tmp7__label0 = g_quark_from_static_string ("bar")))) {
- switch (0) {
- default:
- {
- gint _tmp8_;
- gchar* _tmp9_;
- _tmp8_ = atoi (foo[1]);
- gtk_progress_bar_set_fraction (main_window_viewer->priv->pb, (gdouble) (_tmp8_ / 100));
- _tmp9_ = g_strconcat (foo[1], "%", NULL);
- gtk_progress_bar_set_text (main_window_viewer->priv->pb, _tmp9_);
- _g_free0 (_tmp9_);
- break;
- }
- }
- } else if (_tmp7_ == ((0 != _tmp7__label1) ? _tmp7__label1 : (_tmp7__label1 = g_quark_from_static_string ("error")))) {
- switch (0) {
- default:
- {
- main_window_showMessage (main_window_viewer, foo[1], GTK_MESSAGE_ERROR);
- break;
- }
- }
- } else if (_tmp7_ == ((0 != _tmp7__label2) ? _tmp7__label2 : (_tmp7__label2 = g_quark_from_static_string ("info")))) {
- switch (0) {
- default:
- {
- main_window_showMessage (main_window_viewer, foo[1], GTK_MESSAGE_INFO);
- break;
- }
- }
- } else {
- switch (0) {
- default:
- {
- fprintf (stderr, "[E] Unknown message type\n");
- break;
- }
- }
- }
- }
- squeue_pop (main_window_p);
- foo = (_vala_array_free (foo, foo_length1, (GDestroyNotify) g_free), NULL);
- }
- result = TRUE;
- return result;
-}
-
-
-static void main_window_OnGetInformation (MainWindow* self) {
- g_return_if_fail (self != NULL);
- main_window_msg (self, "info:device");
-}
-
-
-static void main_window_OnConnect (MainWindow* self) {
- g_return_if_fail (self != NULL);
- main_window_OnStop (self);
- system ("sudo 0xFFFF -Q &");
- squeue_close (main_window_p);
- squeue_close (main_window_q);
- main_window_q = NULL;
- main_window_p = main_window_q;
-}
-
-
-static void main_window_OnStop (MainWindow* self) {
- g_return_if_fail (self != NULL);
- system ("sudo pkill 0xFFFF");
-}
-
-
-static gboolean main_window_chk_queues (MainWindow* self) {
- gboolean result = FALSE;
- gboolean _tmp2_ = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- if (main_window_p == NULL) {
- struct squeue_t* _tmp0_ = NULL;
- _tmp0_ = squeue_open ("/tmp/0xFFFF.1", (gint) Q_OPEN);
- main_window_p = _tmp0_;
- }
- if (main_window_q == NULL) {
- struct squeue_t* _tmp1_ = NULL;
- _tmp1_ = squeue_open ("/tmp/0xFFFF.2", (gint) Q_OPEN);
- main_window_q = _tmp1_;
- }
- if (main_window_p == NULL) {
- _tmp2_ = TRUE;
- } else {
- _tmp2_ = main_window_q == NULL;
- }
- if (_tmp2_) {
- main_window_showMessage (self, "Cannot connect to queues", GTK_MESSAGE_ERROR);
- result = FALSE;
- return result;
- }
- result = TRUE;
- return result;
-}
-
-
-void main_window_msg (MainWindow* self, const gchar* str) {
- gboolean _tmp0_;
- gint _tmp1_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (str != NULL);
- _tmp0_ = main_window_chk_queues (self);
- if (!_tmp0_) {
- return;
- }
- _tmp1_ = squeue_push (main_window_q, str, 0);
- if (_tmp1_ < 1) {
- fprintf (stderr, "Oops on push\n");
- squeue_free (main_window_q);
- main_window_q = NULL;
- squeue_free (main_window_p);
- main_window_p = NULL;
- }
-}
-
-
-static gboolean _lambda1_ (GtkWidget* x, GdkEvent* y) {
- gboolean result = FALSE;
- g_return_val_if_fail (x != NULL, FALSE);
- g_return_val_if_fail (y != NULL, FALSE);
- gtk_main_quit ();
- result = FALSE;
- return result;
-}
-
-
-static gboolean __lambda1__gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) {
- gboolean result;
- result = _lambda1_ (_sender, event);
- return result;
-}
-
-
-static gint main_window_main (gchar** args, int args_length1) {
- gint result = 0;
- MainWindow* _tmp0_ = NULL;
- MainWindow* _tmp1_;
- GSourceFunc _tmp2_;
- gtk_init (&args_length1, &args);
- _tmp0_ = main_window_new ();
- _tmp1_ = g_object_ref_sink (_tmp0_);
- _g_object_unref0 (main_window_viewer);
- main_window_viewer = _tmp1_;
- if (args_length1 > 1) {
- main_window_loadFile (main_window_viewer, args[1]);
- }
- gtk_window_resize ((GtkWindow*) main_window_viewer, 600, 400);
- gtk_window_set_position ((GtkWindow*) main_window_viewer, GTK_WIN_POS_CENTER);
- g_signal_connect ((GtkWidget*) main_window_viewer, "delete-event", (GCallback) __lambda1__gtk_widget_delete_event, NULL);
- main_window_setup_treeview (main_window_viewer->priv->tv);
- gtk_widget_show_all ((GtkWidget*) main_window_viewer);
- _tmp2_ = (GSourceFunc) main_window_readFunc;
- g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, _tmp2_, NULL, NULL);
- gtk_main ();
- result = 0;
- return result;
-}
-
-
-int main (int argc, char ** argv) {
- g_type_init ();
- return main_window_main (argv, argc);
-}
-
-
-MainWindow* main_window_construct (GType object_type) {
- MainWindow * self = NULL;
- self = (MainWindow*) g_object_new (object_type, NULL);
- return self;
-}
-
-
-MainWindow* main_window_new (void) {
- return main_window_construct (TYPE_MAIN_WINDOW);
-}
-
-
-static void _main_window_OnFileNewEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnFileNewEvent (self);
-}
-
-
-static void _main_window_OnFileOpenEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnFileOpenEvent (self);
-}
-
-
-static void _main_window_OnQuitEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnQuitEvent (self);
-}
-
-
-static void _main_window_OnConnect_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnConnect (self);
-}
-
-
-static void _main_window_OnStop_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnStop (self);
-}
-
-
-static void _main_window_OnGetInformation_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnGetInformation (self);
-}
-
-
-static void _main_window_OnReset_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnReset (self);
-}
-
-
-static void _main_window_OnMenuHelpAboutActivatedEvent_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- main_window_OnMenuHelpAboutActivatedEvent (self);
-}
-
-
-static void _main_window_OnConnect_gtk_button_clicked (GtkButton* _sender, gpointer self) {
- main_window_OnConnect (self);
-}
-
-
-static void _main_window_OnStop_gtk_button_clicked (GtkButton* _sender, gpointer self) {
- main_window_OnStop (self);
-}
-
-
-static void _main_window_OnGetInformation_gtk_button_clicked (GtkButton* _sender, gpointer self) {
- main_window_OnGetInformation (self);
-}
-
-
-static void _main_window_OnFileOpenEvent_gtk_button_clicked (GtkButton* _sender, gpointer self) {
- main_window_OnFileOpenEvent (self);
-}
-
-
-static void _main_window_list_del_gtk_button_clicked (GtkButton* _sender, gpointer self) {
- main_window_list_del (self);
-}
-
-
-static void _main_window_OnFileFlashEvent_gtk_button_clicked (GtkButton* _sender, gpointer self) {
- main_window_OnFileFlashEvent (self);
-}
-
-
-static gboolean _gtk_widget_hide_on_delete_gtk_widget_delete_event (GtkWidget* _sender, GdkEvent* event, gpointer self) {
- gboolean result;
- result = gtk_widget_hide_on_delete (self);
- return result;
-}
-
-
-static GObject * main_window_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
- GObject * obj;
- GObjectClass * parent_class;
- MainWindow * self;
- GtkVBox* _vbox0;
- GtkMenuBar* _menubar0;
- GtkMenuItem* _menuitem0;
- GtkMenu* _menu0;
- GtkImageMenuItem* _imagemenuitem0;
- GtkImageMenuItem* _imagemenuitem1;
- GtkSeparatorMenuItem* _separatormenuitem0;
- GtkImageMenuItem* _imagemenuitem2;
- GtkMenuItem* _menuitem1;
- GtkMenu* _menu1;
- GtkImageMenuItem* _imagemenuitem3;
- GtkImageMenuItem* _imagemenuitem4;
- GtkImageMenuItem* _imagemenuitem5;
- GtkImageMenuItem* _imagemenuitem6;
- GtkMenuItem* _menuitem2;
- GtkMenu* _menu2;
- GtkImageMenuItem* _imagemenuitem7;
- GtkHBox* _hbox0;
- GtkVBox* _vbox1;
- GtkScrolledWindow* _scrolledwindow0;
- GtkVBox* _vbox2;
- GtkButton* _button0;
- GtkButton* _button1;
- GtkButton* _button2;
- GtkLabel* _label0;
- GtkButton* _button3;
- GtkButton* _button4;
- GtkLabel* _label1;
- GtkButton* _button5;
- GtkVBox* _tmp0_ = NULL;
- GtkVBox* _tmp1_;
- GtkMenuBar* _tmp2_ = NULL;
- GtkMenuBar* _tmp3_;
- GtkMenu* _tmp4_ = NULL;
- GtkMenu* _tmp5_;
- GtkImageMenuItem* _tmp6_ = NULL;
- GtkImageMenuItem* _tmp7_;
- GtkImageMenuItem* _tmp8_ = NULL;
- GtkImageMenuItem* _tmp9_;
- GtkSeparatorMenuItem* _tmp10_ = NULL;
- GtkSeparatorMenuItem* _tmp11_;
- GtkImageMenuItem* _tmp12_ = NULL;
- GtkImageMenuItem* _tmp13_;
- GtkMenuItem* _tmp14_ = NULL;
- GtkMenuItem* _tmp15_;
- GtkMenu* _tmp16_ = NULL;
- GtkMenu* _tmp17_;
- GtkImageMenuItem* _tmp18_ = NULL;
- GtkImageMenuItem* _tmp19_;
- GtkImageMenuItem* _tmp20_ = NULL;
- GtkImageMenuItem* _tmp21_;
- GtkImageMenuItem* _tmp22_ = NULL;
- GtkImageMenuItem* _tmp23_;
- GtkImageMenuItem* _tmp24_ = NULL;
- GtkImageMenuItem* _tmp25_;
- GtkMenuItem* _tmp26_ = NULL;
- GtkMenuItem* _tmp27_;
- GtkMenu* _tmp28_ = NULL;
- GtkMenu* _tmp29_;
- GtkImageMenuItem* _tmp30_ = NULL;
- GtkImageMenuItem* _tmp31_;
- GtkMenuItem* _tmp32_ = NULL;
- GtkMenuItem* _tmp33_;
- GtkHBox* _tmp34_ = NULL;
- GtkHBox* _tmp35_;
- GtkVBox* _tmp36_ = NULL;
- GtkVBox* _tmp37_;
- GtkScrolledWindow* _tmp38_ = NULL;
- GtkScrolledWindow* _tmp39_;
- GtkTreeView* _tmp40_ = NULL;
- GtkTreeView* _tmp41_;
- GtkVBox* _tmp42_ = NULL;
- GtkVBox* _tmp43_;
- GtkButton* _tmp44_ = NULL;
- GtkButton* _tmp45_;
- GtkButton* _tmp46_ = NULL;
- GtkButton* _tmp47_;
- GtkButton* _tmp48_ = NULL;
- GtkButton* _tmp49_;
- GtkLabel* _tmp50_ = NULL;
- GtkLabel* _tmp51_;
- GtkButton* _tmp52_ = NULL;
- GtkButton* _tmp53_;
- GtkButton* _tmp54_ = NULL;
- GtkButton* _tmp55_;
- GtkLabel* _tmp56_ = NULL;
- GtkLabel* _tmp57_;
- GtkButton* _tmp58_ = NULL;
- GtkButton* _tmp59_;
- GtkProgressBar* _tmp60_ = NULL;
- GtkProgressBar* _tmp61_;
- GtkAboutDialog* _tmp62_ = NULL;
- GtkAboutDialog* _tmp63_;
- gchar* _tmp64_;
- gchar** _tmp65_ = NULL;
- gchar** _tmp66_;
- gint _tmp66__length1;
- parent_class = G_OBJECT_CLASS (main_window_parent_class);
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = MAIN_WINDOW (obj);
- _vbox0 = NULL;
- _menubar0 = NULL;
- _menuitem0 = NULL;
- _menu0 = NULL;
- _imagemenuitem0 = NULL;
- _imagemenuitem1 = NULL;
- _separatormenuitem0 = NULL;
- _imagemenuitem2 = NULL;
- _menuitem1 = NULL;
- _menu1 = NULL;
- _imagemenuitem3 = NULL;
- _imagemenuitem4 = NULL;
- _imagemenuitem5 = NULL;
- _imagemenuitem6 = NULL;
- _menuitem2 = NULL;
- _menu2 = NULL;
- _imagemenuitem7 = NULL;
- _hbox0 = NULL;
- _vbox1 = NULL;
- _scrolledwindow0 = NULL;
- _vbox2 = NULL;
- _button0 = NULL;
- _button1 = NULL;
- _button2 = NULL;
- _label0 = NULL;
- _button3 = NULL;
- _button4 = NULL;
- _label1 = NULL;
- _button5 = NULL;
- _tmp0_ = (GtkVBox*) gtk_vbox_new (FALSE, 0);
- _tmp1_ = g_object_ref_sink (_tmp0_);
- _g_object_unref0 (_vbox0);
- _vbox0 = _tmp1_;
- _tmp2_ = (GtkMenuBar*) gtk_menu_bar_new ();
- _tmp3_ = g_object_ref_sink (_tmp2_);
- _g_object_unref0 (_menubar0);
- _menubar0 = _tmp3_;
- _tmp4_ = (GtkMenu*) gtk_menu_new ();
- _tmp5_ = g_object_ref_sink (_tmp4_);
- _g_object_unref0 (_menu0);
- _menu0 = _tmp5_;
- _tmp6_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-new", NULL);
- _tmp7_ = g_object_ref_sink (_tmp6_);
- _g_object_unref0 (_imagemenuitem0);
- _imagemenuitem0 = _tmp7_;
- _tmp8_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-open", NULL);
- _tmp9_ = g_object_ref_sink (_tmp8_);
- _g_object_unref0 (_imagemenuitem1);
- _imagemenuitem1 = _tmp9_;
- _tmp10_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new ();
- _tmp11_ = g_object_ref_sink (_tmp10_);
- _g_object_unref0 (_separatormenuitem0);
- _separatormenuitem0 = _tmp11_;
- _tmp12_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-quit", NULL);
- _tmp13_ = g_object_ref_sink (_tmp12_);
- _g_object_unref0 (_imagemenuitem2);
- _imagemenuitem2 = _tmp13_;
- _tmp14_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic ("_File");
- _tmp15_ = g_object_ref_sink (_tmp14_);
- _g_object_unref0 (_menuitem0);
- _menuitem0 = _tmp15_;
- _tmp16_ = (GtkMenu*) gtk_menu_new ();
- _tmp17_ = g_object_ref_sink (_tmp16_);
- _g_object_unref0 (_menu1);
- _menu1 = _tmp17_;
- _tmp18_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-connect", NULL);
- _tmp19_ = g_object_ref_sink (_tmp18_);
- _g_object_unref0 (_imagemenuitem3);
- _imagemenuitem3 = _tmp19_;
- _tmp20_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-stop", NULL);
- _tmp21_ = g_object_ref_sink (_tmp20_);
- _g_object_unref0 (_imagemenuitem4);
- _imagemenuitem4 = _tmp21_;
- _tmp22_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-info", NULL);
- _tmp23_ = g_object_ref_sink (_tmp22_);
- _g_object_unref0 (_imagemenuitem5);
- _imagemenuitem5 = _tmp23_;
- _tmp24_ = (GtkImageMenuItem*) gtk_image_menu_item_new_with_label ("Reset");
- _tmp25_ = g_object_ref_sink (_tmp24_);
- _g_object_unref0 (_imagemenuitem6);
- _imagemenuitem6 = _tmp25_;
- _tmp26_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic ("_Target");
- _tmp27_ = g_object_ref_sink (_tmp26_);
- _g_object_unref0 (_menuitem1);
- _menuitem1 = _tmp27_;
- _tmp28_ = (GtkMenu*) gtk_menu_new ();
- _tmp29_ = g_object_ref_sink (_tmp28_);
- _g_object_unref0 (_menu2);
- _menu2 = _tmp29_;
- _tmp30_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock ("gtk-about", NULL);
- _tmp31_ = g_object_ref_sink (_tmp30_);
- _g_object_unref0 (_imagemenuitem7);
- _imagemenuitem7 = _tmp31_;
- _tmp32_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic ("_Help");
- _tmp33_ = g_object_ref_sink (_tmp32_);
- _g_object_unref0 (_menuitem2);
- _menuitem2 = _tmp33_;
- _tmp34_ = (GtkHBox*) gtk_hbox_new (FALSE, 0);
- _tmp35_ = g_object_ref_sink (_tmp34_);
- _g_object_unref0 (_hbox0);
- _hbox0 = _tmp35_;
- _tmp36_ = (GtkVBox*) gtk_vbox_new (FALSE, 3);
- _tmp37_ = g_object_ref_sink (_tmp36_);
- _g_object_unref0 (_vbox1);
- _vbox1 = _tmp37_;
- _tmp38_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
- _tmp39_ = g_object_ref_sink (_tmp38_);
- _g_object_unref0 (_scrolledwindow0);
- _scrolledwindow0 = _tmp39_;
- _tmp40_ = (GtkTreeView*) gtk_tree_view_new ();
- _tmp41_ = g_object_ref_sink (_tmp40_);
- _g_object_unref0 (self->priv->tv);
- self->priv->tv = _tmp41_;
- _tmp42_ = (GtkVBox*) gtk_vbox_new (FALSE, 3);
- _tmp43_ = g_object_ref_sink (_tmp42_);
- _g_object_unref0 (_vbox2);
- _vbox2 = _tmp43_;
- _tmp44_ = (GtkButton*) gtk_button_new_with_label ("gtk-connect");
- _tmp45_ = g_object_ref_sink (_tmp44_);
- _g_object_unref0 (_button0);
- _button0 = _tmp45_;
- _tmp46_ = (GtkButton*) gtk_button_new_with_label ("gtk-stop");
- _tmp47_ = g_object_ref_sink (_tmp46_);
- _g_object_unref0 (_button1);
- _button1 = _tmp47_;
- _tmp48_ = (GtkButton*) gtk_button_new_with_label ("gtk-info");
- _tmp49_ = g_object_ref_sink (_tmp48_);
- _g_object_unref0 (_button2);
- _button2 = _tmp49_;
- _tmp50_ = (GtkLabel*) gtk_label_new ("");
- _tmp51_ = g_object_ref_sink (_tmp50_);
- _g_object_unref0 (_label0);
- _label0 = _tmp51_;
- _tmp52_ = (GtkButton*) gtk_button_new_with_label ("gtk-add");
- _tmp53_ = g_object_ref_sink (_tmp52_);
- _g_object_unref0 (_button3);
- _button3 = _tmp53_;
- _tmp54_ = (GtkButton*) gtk_button_new_with_label ("gtk-remove");
- _tmp55_ = g_object_ref_sink (_tmp54_);
- _g_object_unref0 (_button4);
- _button4 = _tmp55_;
- _tmp56_ = (GtkLabel*) gtk_label_new ("");
- _tmp57_ = g_object_ref_sink (_tmp56_);
- _g_object_unref0 (_label1);
- _label1 = _tmp57_;
- _tmp58_ = (GtkButton*) gtk_button_new_with_label ("gtk-media-record");
- _tmp59_ = g_object_ref_sink (_tmp58_);
- _g_object_unref0 (_button5);
- _button5 = _tmp59_;
- _tmp60_ = (GtkProgressBar*) gtk_progress_bar_new ();
- _tmp61_ = g_object_ref_sink (_tmp60_);
- _g_object_unref0 (self->priv->pb);
- self->priv->pb = _tmp61_;
- _tmp62_ = (GtkAboutDialog*) gtk_about_dialog_new ();
- _tmp63_ = g_object_ref_sink (_tmp62_);
- _g_object_unref0 (self->priv->aboutdialog1);
- self->priv->aboutdialog1 = _tmp63_;
- g_object_set ((GtkWindow*) self, "type", GTK_WINDOW_TOPLEVEL, NULL);
- gtk_window_set_title ((GtkWindow*) self, "0xFFFF GUI");
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem0, "activate", (GCallback) _main_window_OnFileNewEvent_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu0, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem0));
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem1, "activate", (GCallback) _main_window_OnFileOpenEvent_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu0, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem1));
- gtk_menu_shell_append ((GtkMenuShell*) _menu0, (GtkWidget*) ((GtkMenuItem*) _separatormenuitem0));
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem2, "activate", (GCallback) _main_window_OnQuitEvent_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu0, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem2));
- gtk_menu_item_set_submenu (_menuitem0, _menu0);
- gtk_menu_shell_append ((GtkMenuShell*) _menubar0, (GtkWidget*) _menuitem0);
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem3, "activate", (GCallback) _main_window_OnConnect_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu1, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem3));
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem4, "activate", (GCallback) _main_window_OnStop_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu1, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem4));
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem5, "activate", (GCallback) _main_window_OnGetInformation_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu1, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem5));
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem6, "activate", (GCallback) _main_window_OnReset_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu1, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem6));
- gtk_menu_item_set_submenu (_menuitem1, _menu1);
- gtk_menu_shell_append ((GtkMenuShell*) _menubar0, (GtkWidget*) _menuitem1);
- g_signal_connect_object ((GtkMenuItem*) _imagemenuitem7, "activate", (GCallback) _main_window_OnMenuHelpAboutActivatedEvent_gtk_menu_item_activate, self, 0);
- gtk_menu_shell_append ((GtkMenuShell*) _menu2, (GtkWidget*) ((GtkMenuItem*) _imagemenuitem7));
- gtk_menu_item_set_submenu (_menuitem2, _menu2);
- gtk_menu_shell_append ((GtkMenuShell*) _menubar0, (GtkWidget*) _menuitem2);
- gtk_box_pack_start ((GtkBox*) _vbox0, (GtkWidget*) _menubar0, FALSE, TRUE, (guint) 0);
- gtk_container_set_border_width ((GtkContainer*) _hbox0, (guint) 5);
- gtk_container_set_border_width ((GtkContainer*) _vbox1, (guint) 3);
- g_object_set ((GtkWidget*) _scrolledwindow0, "can-focus", TRUE, NULL);
- g_object_set (_scrolledwindow0, "hscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
- g_object_set (_scrolledwindow0, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
- gtk_container_add ((GtkContainer*) _scrolledwindow0, (GtkWidget*) self->priv->tv);
- gtk_container_add ((GtkContainer*) _vbox1, (GtkWidget*) _scrolledwindow0);
- gtk_container_add ((GtkContainer*) _hbox0, (GtkWidget*) _vbox1);
- gtk_container_set_border_width ((GtkContainer*) _vbox2, (guint) 3);
- gtk_button_set_use_stock (_button0, TRUE);
- g_signal_connect_object (_button0, "clicked", (GCallback) _main_window_OnConnect_gtk_button_clicked, self, 0);
- gtk_box_pack_start ((GtkBox*) _vbox2, (GtkWidget*) _button0, FALSE, TRUE, (guint) 0);
- gtk_button_set_use_stock (_button1, TRUE);
- g_signal_connect_object (_button1, "clicked", (GCallback) _main_window_OnStop_gtk_button_clicked, self, 0);
- gtk_box_pack_start ((GtkBox*) _vbox2, (GtkWidget*) _button1, FALSE, TRUE, (guint) 0);
- gtk_button_set_use_stock (_button2, TRUE);
- g_signal_connect_object (_button2, "clicked", (GCallback) _main_window_OnGetInformation_gtk_button_clicked, self, 0);
- gtk_box_pack_start ((GtkBox*) _vbox2, (GtkWidget*) _button2, FALSE, TRUE, (guint) 0);
- gtk_container_add ((GtkContainer*) _vbox2, (GtkWidget*) _label0);
- gtk_button_set_use_stock (_button3, TRUE);
- g_signal_connect_object (_button3, "clicked", (GCallback) _main_window_OnFileOpenEvent_gtk_button_clicked, self, 0);
- gtk_box_pack_start ((GtkBox*) _vbox2, (GtkWidget*) _button3, FALSE, TRUE, (guint) 0);
- gtk_button_set_use_stock (_button4, TRUE);
- g_signal_connect_object (_button4, "clicked", (GCallback) _main_window_list_del_gtk_button_clicked, self, 0);
- gtk_box_pack_start ((GtkBox*) _vbox2, (GtkWidget*) _button4, FALSE, TRUE, (guint) 0);
- gtk_container_add ((GtkContainer*) _vbox2, (GtkWidget*) _label1);
- gtk_button_set_use_stock (_button5, TRUE);
- g_signal_connect_object (_button5, "clicked", (GCallback) _main_window_OnFileFlashEvent_gtk_button_clicked, self, 0);
- gtk_box_pack_start ((GtkBox*) _vbox2, (GtkWidget*) _button5, FALSE, TRUE, (guint) 0);
- gtk_box_pack_start ((GtkBox*) _hbox0, (GtkWidget*) _vbox2, FALSE, TRUE, (guint) 0);
- gtk_container_add ((GtkContainer*) _vbox0, (GtkWidget*) _hbox0);
- gtk_box_pack_start ((GtkBox*) _vbox0, (GtkWidget*) self->priv->pb, FALSE, TRUE, (guint) 0);
- gtk_container_add ((GtkContainer*) self, (GtkWidget*) _vbox0);
- g_signal_connect_object ((GtkWidget*) self->priv->aboutdialog1, "delete-event", (GCallback) _gtk_widget_hide_on_delete_gtk_widget_delete_event, (GtkWidget*) self->priv->aboutdialog1, 0);
- gtk_container_set_border_width ((GtkContainer*) self->priv->aboutdialog1, (guint) 5);
- gtk_window_set_title ((GtkWindow*) self->priv->aboutdialog1, "About 0xFFFF gui");
- gtk_window_set_resizable ((GtkWindow*) self->priv->aboutdialog1, FALSE);
- gtk_window_set_modal ((GtkWindow*) self->priv->aboutdialog1, TRUE);
- g_object_set ((GtkWindow*) self->priv->aboutdialog1, "window-position", GTK_WIN_POS_CENTER_ON_PARENT, NULL);
- gtk_dialog_set_has_separator ((GtkDialog*) self->priv->aboutdialog1, FALSE);
- gtk_about_dialog_set_program_name (self->priv->aboutdialog1, "0xFFFF");
- gtk_about_dialog_set_version (self->priv->aboutdialog1, "0.5");
- gtk_about_dialog_set_copyright (self->priv->aboutdialog1, "Copyright (c) 2007-2009 pancake");
- gtk_about_dialog_set_comments (self->priv->aboutdialog1, "The Free Nokia Internet Tablet flasher");
- gtk_about_dialog_set_website (self->priv->aboutdialog1, "http://www.nopcode.org/0xFFFF/");
- _tmp64_ = g_strdup ("pancake (pancake@youterm.com)");
- _tmp65_ = g_new0 (gchar*, 2 + 1);
- _tmp65_[0] = _tmp64_;
- _tmp65_[1] = NULL;
- _tmp66_ = _tmp65_;
- _tmp66__length1 = 2;
- gtk_about_dialog_set_authors (self->priv->aboutdialog1, _tmp66_);
- _tmp66_ = (_vala_array_free (_tmp66_, _tmp66__length1, (GDestroyNotify) g_free), NULL);
- _g_object_unref0 (_button5);
- _g_object_unref0 (_label1);
- _g_object_unref0 (_button4);
- _g_object_unref0 (_button3);
- _g_object_unref0 (_label0);
- _g_object_unref0 (_button2);
- _g_object_unref0 (_button1);
- _g_object_unref0 (_button0);
- _g_object_unref0 (_vbox2);
- _g_object_unref0 (_scrolledwindow0);
- _g_object_unref0 (_vbox1);
- _g_object_unref0 (_hbox0);
- _g_object_unref0 (_imagemenuitem7);
- _g_object_unref0 (_menu2);
- _g_object_unref0 (_menuitem2);
- _g_object_unref0 (_imagemenuitem6);
- _g_object_unref0 (_imagemenuitem5);
- _g_object_unref0 (_imagemenuitem4);
- _g_object_unref0 (_imagemenuitem3);
- _g_object_unref0 (_menu1);
- _g_object_unref0 (_menuitem1);
- _g_object_unref0 (_imagemenuitem2);
- _g_object_unref0 (_separatormenuitem0);
- _g_object_unref0 (_imagemenuitem1);
- _g_object_unref0 (_imagemenuitem0);
- _g_object_unref0 (_menu0);
- _g_object_unref0 (_menuitem0);
- _g_object_unref0 (_menubar0);
- _g_object_unref0 (_vbox0);
- return obj;
-}
-
-
-static void main_window_class_init (MainWindowClass * klass) {
- main_window_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (MainWindowPrivate));
- G_OBJECT_CLASS (klass)->constructor = main_window_constructor;
- G_OBJECT_CLASS (klass)->finalize = main_window_finalize;
-}
-
-
-static void main_window_instance_init (MainWindow * self) {
- self->priv = MAIN_WINDOW_GET_PRIVATE (self);
-}
-
-
-static void main_window_finalize (GObject* obj) {
- MainWindow * self;
- self = MAIN_WINDOW (obj);
- _g_object_unref0 (self->priv->tv);
- _g_object_unref0 (self->priv->pb);
- _g_object_unref0 (self->priv->aboutdialog1);
- G_OBJECT_CLASS (main_window_parent_class)->finalize (obj);
-}
-
-
-GType main_window_get_type (void) {
- static volatile gsize main_window_type_id__volatile = 0;
- if (g_once_init_enter (&main_window_type_id__volatile)) {
- static const GTypeInfo g_define_type_info = { sizeof (MainWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MainWindow), 0, (GInstanceInitFunc) main_window_instance_init, NULL };
- GType main_window_type_id;
- main_window_type_id = g_type_register_static (GTK_TYPE_WINDOW, "MainWindow", &g_define_type_info, 0);
- g_once_init_leave (&main_window_type_id__volatile, main_window_type_id);
- }
- return main_window_type_id__volatile;
-}
-
-
-static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
- if ((array != NULL) && (destroy_func != NULL)) {
- int i;
- for (i = 0; i < array_length; i = i + 1) {
- if (((gpointer*) array)[i] != NULL) {
- destroy_func (((gpointer*) array)[i]);
- }
- }
- }
-}
-
-
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
- _vala_array_destroy (array, array_length, destroy_func);
- g_free (array);
-}
-
-
-static gint _vala_array_length (gpointer array) {
- int length;
- length = 0;
- if (array) {
- while (((gpointer*) array)[length]) {
- length++;
- }
- }
- return length;
-}
-
-
-
diff --git a/src/gui/gui.gtkaml.orig b/src/gui/gui.gtkaml.orig
deleted file mode 100644
index 7e73a1a..0000000
--- a/src/gui/gui.gtkaml.orig
+++ /dev/null
@@ -1,356 +0,0 @@
-<!--
-
- Frontend for the 0xFFFF flasher in gtkaml
-
- author: pancake <youterm.com>
-
--->
-
-<Window xmlns="Gtk"
- xmlns:GLib="GLib"
- xmlns:Extras="Extras"
- xmlns:SQueues="SQueues"
- xmlns:class="http://gtkaml.org/0.2"
- class:name="MainWindow"
- title="0xFFFF GUI">
- <!-- delete-event="{OnWindow1DeleteEvent}" -->
-<VBox>
- <MenuBar expand="false">
- <MenuItem label="_File" with-mnemonic="true">
- <submenu>
- <Menu>
- <ImageMenuItem stock-id="gtk-new" activate="{OnFileNewEvent}"/>
- <ImageMenuItem stock-id="gtk-open" activate="{OnFileOpenEvent}"/>
- <SeparatorMenuItem />
- <ImageMenuItem stock-id="gtk-quit" activate="{OnQuitEvent}"/>
- </Menu>
- </submenu>
- </MenuItem>
-
- <!-- Help menu -->
- <MenuItem label="_Target" with-mnemonic="true">
- <submenu>
- <Menu>
- <ImageMenuItem stock-id="gtk-connect" activate="{OnConnect}"/>
- <ImageMenuItem stock-id="gtk-stop" activate="{OnStop}"/>
- <ImageMenuItem stock-id="gtk-info" activate="{OnGetInformation}"/>
- <ImageMenuItem label="Reset" activate="{OnReset}"/>
- </Menu>
- </submenu>
- </MenuItem>
-
- <!-- Help menu -->
- <MenuItem label="_Help" with-mnemonic="true">
- <submenu>
- <Menu>
- <ImageMenuItem stock-id="gtk-about" activate="{OnMenuHelpAboutActivatedEvent}"/>
- </Menu>
- </submenu>
- </MenuItem>
- </MenuBar>
-
- <HBox border-width="5">
- <VBox border-width="3" spacing="3">
- <ScrolledWindow can-focus="true" hscrollbar-policy="{PolicyType.AUTOMATIC}" vscrollbar-policy="{PolicyType.AUTOMATIC}">
- <TreeView class:private="tv">
- </TreeView>
- </ScrolledWindow>
-
- </VBox>
- <VBox expand="false" border-width="3" spacing="3">
- <Button label="gtk-connect" use-stock="true" expand="false" clicked="{OnConnect}"/>
- <Button label="gtk-stop" use-stock="true" expand="false" clicked="{OnStop}"/>
- <Button label="gtk-info" use-stock="true" expand="false" clicked="{OnGetInformation}"/>
- <Label label="" />
-<!-- <Button label="Options" use-stock="false" expand="false"/>
- <Button label="Fiasco!" use-stock="false" expand="false"/>
- <Button label="Unpack!" use-stock="false" expand="false"/> -->
- <Button label="gtk-add" use-stock="true" expand="false" clicked="{OnFileOpenEvent}" />
- <Button label="gtk-remove" use-stock="true" expand="false" clicked="{list_del}"/>
- <Label label="" />
- <Button label="gtk-media-record" use-stock="true" expand="false" clicked="{OnFileFlashEvent}"/>
- </VBox>
- </HBox>
- <ProgressBar class:private="pb" expand="false" />
-
- <!-- <Statusbar expand="false"/> -->
-</VBox>
- <AboutDialog class:standalone="true" class:private="aboutdialog1" delete-event="{aboutdialog1.hide_on_delete}"
- border-width="5" title="About 0xFFFF gui" resizable="false" modal="true"
- window-position="{WindowPosition.CENTER_ON_PARENT}" has-separator="false"
- program-name="0xFFFF" version="0.5" copyright="Copyright (c) 2007-2009 pancake"
- comments="The Free Nokia Internet Tablet flasher"
- website="http://www.nopcode.org/0xFFFF/"
- authors='{new string[] {"pancake (pancake@youterm.com)", null}}'>
- </AboutDialog>
-
-<![CDATA[
-
-
-private void doCloseApplication ()
-{
- Gtk.main_quit ();
-}
-
-private void OnReset()
-{
- q->push("reset:device", 1);
-}
-
-private void OnFileFlashEvent()
-{
- ListStore ls = (ListStore)tv.get_model();
- weak string str;
- TreeIter iter;
-
- int n = ls.iter_n_children(null);
- if (n >0) {
- if (showYesNo("Do you want to flash these files?")) {
- ls.get_iter_first(out iter);
- do {
- ls.get(iter, 2, out str, -1);
- //stdout.printf("polla:%s\n", str);
- q->push2("flash", str, 1);
- } while(ls.iter_next(ref iter));
- }
- } else {
- showMessage("No files selected", MessageType.ERROR);
- }
-}
-
-private void OnFileOpenEvent ()
-{
- FileChooserDialog fc = new FileChooserDialog("Select file to open",
- this, FileChooserAction.OPEN,
- "gtk-cancel", ResponseType.CANCEL,
- "gtk-open", ResponseType.ACCEPT);
- int resp = fc.run ();
- fc.hide ();
- if (resp == ResponseType.ACCEPT) {
- string file = fc.get_filename();
- string *type = External.fpid_file(file);
- string size = "%ld".printf(External.fpid_size(file));
- if (type == null) {
- showMessage("Invalid file type", MessageType.ERROR);
- } else {
- add_file(type, size, file);
- }
- }
- fc.destroy ();
-}
-
-public bool loadFile( string filename )
-{
- int err = 0;
- try {
- string contents; size_t length;
- FileUtils.get_contents (filename, out contents, out length);
- //textview1.buffer.set_text (contents, length);
- } catch(Error e) {
- showError ("Unexpected error while loading the file, please contact the author with the following information:\n\n" + e.message);
- err++;
- }
- return err == 0;
-}
-
-public bool showYesNo(string s)
-{
- MessageDialog md = new MessageDialog (this,
- DialogFlags.DESTROY_WITH_PARENT,
- MessageType.QUESTION, ButtonsType.YES_NO, s);
- int ret = md.run ();
- md.destroy ();
-
- return ret==ResponseType.YES;
-}
-
-public void showMessage(string s, MessageType mt)
-{
- MessageDialog md = new MessageDialog (this,
- DialogFlags.DESTROY_WITH_PARENT,
- mt, ButtonsType.CLOSE, s);
- md.run ();
- md.destroy ();
-}
-
-private void OnMenuHelpAboutActivatedEvent ()
-{
- aboutdialog1.transient_for = this;
- aboutdialog1.run ();
-}
-
-public void showError (string s)
-{
- MessageDialog md = new MessageDialog (this,
- DialogFlags.DESTROY_WITH_PARENT,
- MessageType.ERROR,
- ButtonsType.CLOSE,
- s);
- md.run ();
- md.destroy ();
-}
-
-private void OnFileNewEvent ()
-{
- list_clear();
- // TODO: clear file list
-}
-
-private void OnQuitEvent ()
-{
- doCloseApplication();
- // TODO: send message to gracefully kill 0xFFFF
- // TODO: handle ^C when flashing
-}
-
-public void list_clear()
-{
- ((ListStore)tv.model).clear();
-}
-
-public void list_del()
-{
- TreeIter iter;
- TreeModel model;
-
- TreeSelection sel = tv.get_selection();
-
- if (sel.count_selected_rows() == 1) {
- sel.get_selected(out model, out iter);
- ((ListStore)tv.model).remove(iter);
- }
-}
-
-public void add_file(string type, string size, string file)
-{
- ListStore listmodel = (ListStore)tv.get_model();
- Gtk.TreeIter iter;
- listmodel.append (out iter);
- listmodel.set (iter, 0, type, 1, size, 2, file, -1);
-}
-
-public static void setup_treeview (Gtk.TreeView view)
-{
- /* use liststore to hold accountname, accounttype, balance and color attribute */
- /* for more info how gtkTreeview works take a look in the GTK API */
-
- var listmodel = new Gtk.ListStore(4, typeof(string), typeof(string), typeof(string), typeof(string));
- view.set_model(listmodel);
-
- view.insert_column_with_attributes (-1, "Type", new Gtk.CellRendererText(), "text", 0, null);
- view.insert_column_with_attributes (-1, "Size", new Gtk.CellRendererText(), "text", 1, null);
-
- var cell = new Gtk.CellRendererText ();
- cell.set ("foreground_set", true, null);
- view.insert_column_with_attributes (-1, "Name", cell, "text", 2, "foreground", 3, null);
-
-// Gtk.TreeIter iter;
- // listmodel.append (out iter);
- // listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", -1);
- //listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", 3, "green", -1);
-
- // listmodel.append (out iter);
- // listmodel.set (iter, 0, "rootfs", 1, "52M", 2, "rootfs.jffs", -1);
-}
-
-public static bool readFunc()
-{
- weak string msg = p->get(0);
-
- if (msg != null && msg[0]!='\0') {
- stdout.printf("[<] msg received: %s\n", msg);
- string[] foo = msg.split(":",2);
- if (foo[1] != null) {
- switch(foo[0]) {
- case "bar":
- viewer.pb.fraction = foo[1].to_int() / 100;
- viewer.pb.text = foo[1]+"%";
- break;
- case "error":
- viewer.showMessage(foo[1], MessageType.ERROR);
- break;
- case "info":
- viewer.showMessage(foo[1], MessageType.INFO);
- break;
- default:
- stderr.printf("[E] Unknown message type\n");
- break;
- }
- //viewer.showMessage(msg, MessageType.INFO);
- }
- p->pop();
- }
- return true;
-}
-
-static SQueue *q = null;
-static SQueue *p = null;
-
-private void OnGetInformation()
-{
- msg("info:device");
-}
-
-private void OnConnect()
-{
- //msg("connect:device");
- OnStop();
- External.system("sudo 0xFFFF -Q &");
- p->close();
- q->close();
- p = q = null;
-}
-
-private void OnStop()
-{
- External.system("sudo pkill 0xFFFF");
-}
-
-
-private bool chk_queues()
-{
- if (p == null)
- p = SQueue.open("/tmp/0xFFFF.1", SQueueMode.OPEN);
- if (q == null)
- q = SQueue.open("/tmp/0xFFFF.2", SQueueMode.OPEN);
- if (p == null || q == null) {
- showMessage("Cannot connect to queues", MessageType.ERROR);
- return false;
- }
- return true;
-}
-
-public void msg(string str)
-{
- if (!chk_queues())
- return;
- if (q->push(str, 0)<1) {
- stderr.printf("Oops on push\n");
- q->free();
- q = null;
- p->free();
- p = null;
- }
-}
-
-static MainWindow viewer;
-
-static int main (string[] args)
-{
- Gtk.init (ref args);
- viewer = new MainWindow();
- if (args.length > 1)
- viewer.loadFile (args[1]);
- viewer.resize(600,400);
- viewer.set_position(WindowPosition.CENTER);
- viewer.delete_event += (x,y) => { Gtk.main_quit(); };
- setup_treeview(viewer.tv);
- viewer.show_all ();
-// viewer.showMessage("This software is beta and does not guaranties correct functionality", MessageType.WARNING);
- Timeout.add(200, (SourceFunc)(readFunc));
- Gtk.main ();
- return 0;
-}
-
-]]>
-</Window>
diff --git a/src/gui/gui.gtkon b/src/gui/gui.gtkon
deleted file mode 100644
index b684e13..0000000
--- a/src/gui/gui.gtkon
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- | Frontend for the 0xFFFF flasher in gtkaml
- | author: pancake <youterm.com>
- */
-
-Window using="Gtk" gtkon:version=0.4
- using:Extras="Extras"
- using:SQueues="SQueues"
- name="MainWindow"
- title="0xFFFF GUI"
-{
- /* delete-event="{OnWindow1DeleteEvent}" */
- VBox {
- MenuBar !expand {
- MenuItem label="_File" with-mnemonic {
- submenu {
- Menu {
- ImageMenuItem stock-id="gtk-new" activate=OnFileNewEvent;
- ImageMenuItem stock-id="gtk-open" activate=OnFileOpenEvent;
- SeparatorMenuItem;
- ImageMenuItem stock-id="gtk-quit" activate=OnQuitEvent;
- }
- }
- }
- MenuItem label="_Target" with-mnemonic {
- submenu {
- Menu {
- ImageMenuItem stock-id="gtk-connect" activate=OnConnect;
- ImageMenuItem stock-id="gtk-stop" activate=OnStop;
- ImageMenuItem stock-id="gtk-info" activate=OnGetInformation;
- ImageMenuItem label="Reset" activate=OnReset;
- }
- }
- }
- MenuItem label="_Help" with-mnemonic {
- submenu {
- Menu {
- ImageMenuItem stock-id="gtk-about" activate=OnMenuHelpAboutActivatedEvent;
- }
- }
- }
- }
-
- HBox border-width="5" {
- VBox border-width="3" spacing="3" {
- ScrolledWindow can-focus="true" hscrollbar-policy="{PolicyType.AUTOMATIC}" vscrollbar-policy="{PolicyType.AUTOMATIC}" {
- TreeView $.tv;
- }
-
- }
- VBox !expand border-width="3" spacing="3" {
- Button label="gtk-connect" use-stock !expand clicked=OnConnect;
- Button label="gtk-stop" use-stock !expand clicked=OnStop;
- Button label="gtk-info" use-stock !expand clicked=OnGetInformation;
- Label label="";
- /*
- <!-- <Button label="Options" use-stock="false" expand="false"/>
- <Button label="Fiasco!" use-stock="false" expand="false"/>
- <Button label="Unpack!" use-stock="false" expand/> -->
- */
- Button label="gtk-add" use-stock="true" !expand clicked=OnFileOpenEvent;
- Button label="gtk-remove" use-stock="true" expand="false" clicked=list_del;
- Label label="";
- Button label="gtk-media-record" use-stock="true" expand="false" clicked=OnFileFlashEvent;
- }
- }
- ProgressBar $.pb !expand;
-
- //<!-- <Statusbar expand="false"/> -->
- }
- AboutDialog gtkaml:standalone $.aboutdialog1 delete-event=aboutdialog1.hide_on_delete
- border-width="5" title="About 0xFFFF gui" resizable="false" modal="true"
- window-position="{WindowPosition.CENTER_ON_PARENT}" has-separator="false"
- program-name="0xFFFF" version="0.5" copyright="Copyright (c) 2007-2009 pancake"
- comments="The Free Nokia Internet Tablet flasher"
- website="http://www.nopcode.org/0xFFFF/"
- authors='{new string[] {"pancake (pancake@youterm.com)", null}}';
-
- -{
-
-
- private void doCloseApplication () {
- Gtk.main_quit ();
- }
-
- private void OnReset() {
- q->push("reset:device", 1);
- }
-
- private void OnFileFlashEvent() {
- ListStore ls = (ListStore)tv.get_model();
- weak string str;
- TreeIter iter;
-
- int n = ls.iter_n_children(null);
- if (n >0) {
- if (showYesNo("Do you want to flash these files?")) {
- ls.get_iter_first(out iter);
- do {
- ls.get(iter, 2, out str, -1);
- //stdout.printf("polla:%s\n", str);
- q->push2("flash", str, 1);
- } while(ls.iter_next(ref iter));
- }
- } else showMessage("No files selected", MessageType.ERROR);
- }
-
- private void OnFileOpenEvent () {
- FileChooserDialog fc = new FileChooserDialog("Select file to open",
- this, FileChooserAction.OPEN,
- "gtk-cancel", ResponseType.CANCEL,
- "gtk-open", ResponseType.ACCEPT);
- int resp = fc.run ();
- fc.hide ();
- if (resp == ResponseType.ACCEPT) {
- string file = fc.get_filename();
- string *type = External.fpid_file(file);
- string size = "%ld".printf(External.fpid_size(file));
- if (type == null)
- showMessage("Invalid file type", MessageType.ERROR);
- else add_file(type, size, file);
- }
- fc.destroy ();
- }
-
- public bool loadFile( string filename ) {
- int err = 0;
- try {
- string contents; size_t length;
- FileUtils.get_contents (filename, out contents, out length);
- //textview1.buffer.set_text (contents, length);
- } catch(Error e) {
- showError ("Unexpected error while loading the file, please contact the author with the following information:\n\n" + e.message);
- err++;
- }
- return err == 0;
- }
-
- public bool showYesNo(string s) {
- MessageDialog md = new MessageDialog (this,
- DialogFlags.DESTROY_WITH_PARENT,
- MessageType.QUESTION, ButtonsType.YES_NO, s);
- int ret = md.run ();
- md.destroy ();
- return ret==ResponseType.YES;
- }
-
- public void showMessage(string s, MessageType mt) {
- MessageDialog md = new MessageDialog (this,
- DialogFlags.DESTROY_WITH_PARENT,
- mt, ButtonsType.CLOSE, s);
- md.run ();
- md.destroy ();
- }
-
- private void OnMenuHelpAboutActivatedEvent () {
- aboutdialog1.transient_for = this;
- aboutdialog1.response.connect ((x)=> { aboutdialog1.hide (); });
- aboutdialog1.run ();
- }
-
- public void showError (string s) {
- MessageDialog md = new MessageDialog (this,
- DialogFlags.DESTROY_WITH_PARENT,
- MessageType.ERROR,
- ButtonsType.CLOSE,
- s);
- md.run ();
- md.destroy ();
- }
-
- private void OnFileNewEvent () {
- list_clear();
- // TODO: clear file list
- }
-
- private void OnQuitEvent () {
- doCloseApplication();
- // TODO: send message to gracefully kill 0xFFFF
- // TODO: handle ^C when flashing
- }
-
- public void list_clear() {
- ((ListStore)tv.model).clear();
- }
-
- public void list_del() {
- TreeIter iter;
- TreeModel model;
-
- TreeSelection sel = tv.get_selection();
-
- if (sel.count_selected_rows() == 1) {
- sel.get_selected(out model, out iter);
- ((ListStore)tv.model).remove(iter);
- }
- }
-
- public void add_file(string type, string size, string file) {
- ListStore listmodel = (ListStore)tv.get_model();
- Gtk.TreeIter iter;
- listmodel.append (out iter);
- listmodel.set (iter, 0, type, 1, size, 2, file, -1);
- }
-
- public static void setup_treeview (Gtk.TreeView view) {
- /* use liststore to hold accountname, accounttype, balance and color attribute */
- /* for more info how gtkTreeview works take a look in the GTK API */
-
- var listmodel = new Gtk.ListStore(4, typeof(string), typeof(string), typeof(string), typeof(string));
- view.set_model(listmodel);
-
- view.insert_column_with_attributes (-1, "Type", new Gtk.CellRendererText(), "text", 0, null);
- view.insert_column_with_attributes (-1, "Size", new Gtk.CellRendererText(), "text", 1, null);
-
- var cell = new Gtk.CellRendererText ();
- cell.set ("foreground_set", true, null);
- view.insert_column_with_attributes (-1, "Name", cell, "text", 2, "foreground", 3, null);
-
- // Gtk.TreeIter iter;
- // listmodel.append (out iter);
- // listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", -1);
- //listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", 3, "green", -1);
-
- // listmodel.append (out iter);
- // listmodel.set (iter, 0, "rootfs", 1, "52M", 2, "rootfs.jffs", -1);
- }
-
- public static bool readFunc() {
- weak string msg = p->get(0);
-
- if (msg != null && msg[0]!='\0') {
- stdout.printf("[<] msg received: %s\n", msg);
- string[] foo = msg.split(":",2);
- if (foo[1] != null) {
- switch(foo[0]) {
- case "bar":
- viewer.pb.fraction = foo[1].to_int() / 100;
- viewer.pb.text = foo[1]+"%";
- break;
- case "error":
- viewer.showMessage(foo[1], MessageType.ERROR);
- break;
- case "info":
- viewer.showMessage(foo[1], MessageType.INFO);
- break;
- default:
- stderr.printf("[E] Unknown message type\n");
- break;
- }
- //viewer.showMessage(msg, MessageType.INFO);
- }
- p->pop();
- }
- return true;
- }
-
- static SQueue *q = null;
- static SQueue *p = null;
-
- private void OnGetInformation() {
- msg("info:device");
- }
-
- private void OnConnect() {
- //msg("connect:device");
- OnStop();
- External.system("sudo 0xFFFF -Q &");
- p->close();
- q->close();
- p = q = null;
- }
-
- private void OnStop() {
- External.system("sudo pkill 0xFFFF");
- }
-
- private bool chk_queues() {
- if (p == null)
- p = SQueue.open("/tmp/0xFFFF.1", SQueueMode.OPEN);
- if (q == null)
- q = SQueue.open("/tmp/0xFFFF.2", SQueueMode.OPEN);
- if (p == null || q == null) {
- showMessage("Cannot connect to queues", MessageType.ERROR);
- return false;
- }
- return true;
- }
-
- public void msg(string str) {
- if (!chk_queues())
- return;
- if (q->push(str, 0)<1) {
- stderr.printf("Oops on push\n");
- q->free();
- q = null;
- p->free();
- p = null;
- }
- }
-
- static MainWindow viewer;
-
- static int main (string[] args) {
- Gtk.init (ref args);
- viewer = new MainWindow();
- if (args.length > 1)
- viewer.loadFile (args[1]);
- viewer.resize(600,400);
- viewer.set_position(WindowPosition.CENTER);
- viewer.delete_event.connect ((x,y) => { Gtk.main_quit(); return false; });
- setup_treeview(viewer.tv);
- viewer.show_all ();
- // viewer.showMessage("This software is beta and does not guaranties correct functionality", MessageType.WARNING);
- Timeout.add(200, (SourceFunc)(readFunc));
- Gtk.main ();
- return 0;
- }
-
- }-
-}