mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2025-01-30 23:00:11 -05:00
GUI work
This commit is contained in:
parent
2e95867469
commit
9c43932abe
@ -91,6 +91,9 @@ Author: Raphaël Assénat
|
||||
<patterns>
|
||||
<pattern>*.mpk</pattern>
|
||||
<pattern>*.n64</pattern>
|
||||
<pattern>*.N64</pattern>
|
||||
<pattern>*.MPK</pattern>
|
||||
<pattern>*.Mpk</pattern>
|
||||
</patterns>
|
||||
</object>
|
||||
<object class="GtkFileFilter" id="n64_note_filter">
|
||||
@ -106,6 +109,8 @@ Author: Raphaël Assénat
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Pages -->
|
||||
<column type="gint"/>
|
||||
<!-- column-name Comments -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="pollrate_adjustment">
|
||||
@ -979,52 +984,77 @@ Author: Raphaël Assénat
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="n64_notes_treeview">
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">n64_notes</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="enable_grid_lines">both</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection1"/>
|
||||
</child>
|
||||
<property name="shadow_type">in</property>
|
||||
<property name="min_content_width">600</property>
|
||||
<property name="min_content_height">300</property>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Note ID</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
<object class="GtkTreeView" id="n64_notes_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="vscroll_policy">natural</property>
|
||||
<property name="model">n64_notes</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="enable_grid_lines">both</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection1"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Game Data</property>
|
||||
<property name="expand">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext4"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Note ID</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Pages</property>
|
||||
<property name="sort_order">descending</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext5"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Game Data</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext4"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Pages</property>
|
||||
<property name="sort_order">descending</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext5"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Comments</property>
|
||||
<property name="expand">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext6">
|
||||
<property name="ellipsize">end</property>
|
||||
<property name="wrap_mode">word</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">3</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -210,7 +210,7 @@ void deselect_adapter(struct application *app)
|
||||
gtk_combo_box_set_active_iter(cb_adapter_list, NULL);
|
||||
}
|
||||
|
||||
void infoPopop(struct application *app, const char *message)
|
||||
void infoPopup(struct application *app, const char *message)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
@ -225,7 +225,7 @@ void infoPopop(struct application *app, const char *message)
|
||||
}
|
||||
|
||||
|
||||
void errorPopop(struct application *app, const char *message)
|
||||
void errorPopup(struct application *app, const char *message)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
@ -282,7 +282,7 @@ G_MODULE_EXPORT void update_usbadapter_firmware(GtkWidget *w, gpointer data)
|
||||
return;
|
||||
}
|
||||
if (pclose(dfu_fp)) {
|
||||
errorPopop(app, "dfu-programmmer not found. Cannot perform update.");
|
||||
errorPopup(app, "dfu-programmmer not found. Cannot perform update.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ G_MODULE_EXPORT void update_usbadapter_firmware(GtkWidget *w, gpointer data)
|
||||
app->updateHexFile = filename;
|
||||
|
||||
if (!check_ihex_for_signature(filename, "9c3ea8b8-753f-11e5-a0dc-001bfca3c593")) {
|
||||
errorPopop(app, "Signature not found - This file is invalid or not meant for this adapter");
|
||||
errorPopup(app, "Signature not found - This file is invalid or not meant for this adapter");
|
||||
}
|
||||
|
||||
/* Prepare the update dialog widgets... */
|
||||
@ -322,9 +322,9 @@ G_MODULE_EXPORT void update_usbadapter_firmware(GtkWidget *w, gpointer data)
|
||||
gtk_widget_hide( GTK_WIDGET(firmware_update_dialog));
|
||||
|
||||
if (res == GTK_RESPONSE_OK) {
|
||||
infoPopop(app, "Update succeeded.");
|
||||
infoPopup(app, "Update succeeded.");
|
||||
} else if (res == GTK_RESPONSE_REJECT) {
|
||||
errorPopop(app, "Update failed. Suggestion: Do not disconnect the adapter and retry right away!");
|
||||
errorPopup(app, "Update failed. Suggestion: Do not disconnect the adapter and retry right away!");
|
||||
}
|
||||
printf("Update dialog done\n");
|
||||
|
||||
@ -414,7 +414,7 @@ G_MODULE_EXPORT void pollIntervalChanged(GtkWidget *win, gpointer data)
|
||||
|
||||
n = gcn64lib_setConfig(app->current_adapter_handle, CFG_PARAM_POLL_INTERVAL0, &buf, 1);
|
||||
if (n != 0) {
|
||||
errorPopop(app, "Error setting configuration");
|
||||
errorPopup(app, "Error setting configuration");
|
||||
deselect_adapter(app);
|
||||
rebuild_device_list_store(data);
|
||||
}
|
||||
@ -442,7 +442,7 @@ G_MODULE_EXPORT void config_checkbox_changed(GtkWidget *win, gpointer data)
|
||||
buf = gtk_toggle_button_get_active(configurable_bits[i].chkbtn);
|
||||
n = gcn64lib_setConfig(app->current_adapter_handle, configurable_bits[i].cfg_param, &buf, 1);
|
||||
if (n != 0) {
|
||||
errorPopop(app, "Error setting configuration");
|
||||
errorPopup(app, "Error setting configuration");
|
||||
deselect_adapter(app);
|
||||
rebuild_device_list_store(app);
|
||||
break;
|
||||
@ -532,7 +532,7 @@ G_MODULE_EXPORT void adapterSelected(GtkComboBox *cb, gpointer data)
|
||||
|
||||
app->current_adapter_handle = gcn64_openDevice(info);
|
||||
if (!app->current_adapter_handle) {
|
||||
errorPopop(app, "Failed to open adapter");
|
||||
errorPopup(app, "Failed to open adapter");
|
||||
deselect_adapter(app);
|
||||
return;
|
||||
}
|
||||
@ -568,19 +568,23 @@ G_MODULE_EXPORT void onFileRescan(GtkWidget *wid, gpointer data)
|
||||
rebuild_device_list_store(data);
|
||||
}
|
||||
|
||||
static void mempak_io_progress_cb(int progress, void *ctx)
|
||||
static int mempak_io_progress_cb(int progress, void *ctx)
|
||||
{
|
||||
struct application *app = ctx;
|
||||
GET_UI_ELEMENT(GtkProgressBar, mempak_io_progress);
|
||||
gdouble fract;
|
||||
|
||||
fract = progress/MEMPAK_BLOCK_SIZE;
|
||||
|
||||
gtk_progress_bar_set_fraction(mempak_io_progress, progress/((gdouble)MEMPAK_MEM_SIZE));
|
||||
while (gtk_events_pending()) {
|
||||
gtk_main_iteration_do(FALSE);
|
||||
}
|
||||
|
||||
return app->stop_reading_mempak;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void mempak_io_stop(GtkWidget *wid, gpointer data)
|
||||
{
|
||||
struct application *app = data;
|
||||
app->stop_reading_mempak = 1;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void read_n64_pak(GtkWidget *wid, gpointer data)
|
||||
@ -599,16 +603,18 @@ G_MODULE_EXPORT void read_n64_pak(GtkWidget *wid, gpointer data)
|
||||
gtk_widget_show(GTK_WIDGET(mempak_io_dialog));
|
||||
gtk_label_set_text(mempak_op_label, "Reading memory pack...");
|
||||
|
||||
app->stop_reading_mempak = 0;
|
||||
res = gcn64lib_mempak_download(app->current_adapter_handle, 0, &mpk, mempak_io_progress_cb, app);
|
||||
|
||||
gtk_widget_hide(GTK_WIDGET(mempak_io_dialog));
|
||||
if (res != 0) {
|
||||
switch(res)
|
||||
{
|
||||
case -1: errorPopop(app, "No mempak detected"); break;
|
||||
case -2: errorPopop(app, "I/O error reading mempak"); break;
|
||||
case -1: errorPopup(app, "No mempak detected"); break;
|
||||
case -2: errorPopup(app, "I/O error reading mempak"); break;
|
||||
case -4: errorPopup(app, "Read aborted"); break;
|
||||
default:
|
||||
case -3: errorPopop(app, "Error reading mempak"); break;
|
||||
case -3: errorPopup(app, "Error reading mempak"); break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define GET_ELEMENT(TYPE, ELEMENT) (TYPE *)gtk_builder_get_object(app->builder, #ELEMENT)
|
||||
#define GET_UI_ELEMENT(TYPE, ELEMENT) TYPE *ELEMENT = GET_ELEMENT(TYPE, ELEMENT)
|
||||
|
||||
void errorPopop(struct application *app, const char *message);
|
||||
void errorPopup(struct application *app, const char *message);
|
||||
|
||||
struct application {
|
||||
GtkBuilder *builder;
|
||||
@ -24,6 +24,7 @@ struct application {
|
||||
int update_dialog_response;
|
||||
|
||||
struct mpkedit_data *mpke;
|
||||
int stop_reading_mempak;
|
||||
};
|
||||
|
||||
|
||||
|
@ -175,7 +175,7 @@ G_MODULE_EXPORT void mpke_export_note(GtkWidget *win, gpointer data)
|
||||
if (0==get_mempak_entry(app->mpke->mpk, selection, &entry)) {
|
||||
char namebuf[64];
|
||||
if (!entry.valid) {
|
||||
errorPopop(app, "Please select a non-empty note");
|
||||
errorPopup(app, "Please select a non-empty note");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ G_MODULE_EXPORT void mpke_export_note(GtkWidget *win, gpointer data)
|
||||
|
||||
filename = gtk_file_chooser_get_filename(chooser);
|
||||
if (mempak_exportNote(app->mpke->mpk, selection, filename)) {
|
||||
errorPopop(app, "Could not export note");
|
||||
errorPopup(app, "Could not export note");
|
||||
} else {
|
||||
printf("Note saved to %s\n", filename);
|
||||
}
|
||||
@ -255,8 +255,8 @@ G_MODULE_EXPORT void mpke_insert_note(GtkWidget *win, gpointer data)
|
||||
switch(res)
|
||||
{
|
||||
default:
|
||||
case -1: errorPopop(app, "Error loading file or inserting note\n"); break;
|
||||
case -2: errorPopop(app, "Not enough free blocks to insert note\n"); break;
|
||||
case -1: errorPopup(app, "Error loading file or inserting note\n"); break;
|
||||
case -2: errorPopup(app, "Not enough free blocks to insert note\n"); break;
|
||||
}
|
||||
} else {
|
||||
// Success
|
||||
@ -309,7 +309,7 @@ G_MODULE_EXPORT void mpke_open(GtkWidget *win, gpointer data)
|
||||
app->mpke->modified = 0;
|
||||
mpke_replaceMpk(app, mpk, filename);
|
||||
} else {
|
||||
errorPopop(app, "Failed to load mempak");
|
||||
errorPopup(app, "Failed to load mempak");
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,7 +361,7 @@ G_MODULE_EXPORT void mpke_saveas(GtkWidget *win, gpointer data)
|
||||
app->mpke->modified = 0;
|
||||
mpke_updateFilename(app,filename);
|
||||
} else {
|
||||
errorPopop(app, "Unknown file format specified");
|
||||
errorPopup(app, "Unknown file format specified");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user