Added package_created handler, fixed log file opening, fixed things
This commit is contained in:
parent
b03b58176b
commit
2ff0303821
|
@ -20,13 +20,14 @@
|
|||
#include "../gm-ui.h"
|
||||
#include "gm-world-view.h"
|
||||
#include "../gm-world.h"
|
||||
#include "../dialogs/gm-world-info-dialog.h"
|
||||
#include "../dialogs/gm-worlds-list-dialog.h"
|
||||
#include "../dialogs/gm-world-logs-dialog.h"
|
||||
#include "../dialogs/gm-world-properties-dialog.h"
|
||||
#include "../dialogs/gm-scripts-dialog.h"
|
||||
#include "../dialogs/gm-preferences-dialog.h"
|
||||
#include "gm-world-tab.h"
|
||||
#include "mcp/gm-mcp-session.h"
|
||||
#include "mcp/gm-mcp-package.h"
|
||||
|
||||
//#include "if_world.h"
|
||||
//#include "if_worlds_listing.h"
|
||||
|
@ -61,6 +62,9 @@ gboolean on_gm_app_view_notebook_button_release(GtkNotebook *notebook,
|
|||
void on_gm_app_view_check_button_search_direction_toggled(
|
||||
GtkToggleButton *button, GmAppView *view);
|
||||
|
||||
void on_gm_app_view_world_mcp_package_created(GmMcpSession *session,
|
||||
GmMcpPackage *package, GmAppView *view);
|
||||
|
||||
typedef struct _AccelInfo AccelInfo;
|
||||
struct _AccelInfo {
|
||||
int num;
|
||||
|
@ -401,11 +405,16 @@ gm_app_view_new(GmApp *application) {
|
|||
return view;
|
||||
}
|
||||
|
||||
const GmApp *
|
||||
GmApp const *
|
||||
gm_app_view_application(GmAppView *view) {
|
||||
return view->priv->application;
|
||||
}
|
||||
|
||||
GtkNotebook *
|
||||
gm_app_view_notebook(GmAppView *view) {
|
||||
return view->priv->notebook;
|
||||
}
|
||||
|
||||
void
|
||||
gm_app_view_destroy_world_menu_item(GmAppViewWorldMenuItem *item) {
|
||||
g_object_unref(item->action);
|
||||
|
@ -428,6 +437,11 @@ void
|
|||
gm_app_view_set_sensitivity(GmAppView *view, gboolean sens) {
|
||||
gtk_action_group_set_sensitive(view->priv->action_group, sens);
|
||||
|
||||
if (sens == TRUE) {
|
||||
gtk_action_set_sensitive(gtk_action_group_get_action(
|
||||
view->priv->action_group, "WorldInfo"), FALSE);
|
||||
}
|
||||
|
||||
if (sens) {
|
||||
/* TODO: set world info menu item not sensitive if no world info avail
|
||||
First fix MCP
|
||||
|
@ -475,34 +489,26 @@ gm_app_view_update_title(GmAppView *view) {
|
|||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gm_app_view_container_item(GtkContainer *cnt, GType type) {
|
||||
GList *childFirst = gtk_container_get_children(cnt);
|
||||
GList *child;
|
||||
GtkWidget *result = NULL;
|
||||
|
||||
for (child = childFirst; child; child = child->next) {
|
||||
if (G_TYPE_CHECK_INSTANCE_TYPE(child->data, type)) {
|
||||
result = GTK_WIDGET(child->data);
|
||||
break;
|
||||
} else if (GTK_IS_CONTAINER(child->data)) {
|
||||
if ((result = gm_app_view_container_item(
|
||||
GTK_CONTAINER(child->data), type))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free(childFirst);
|
||||
return result;
|
||||
GtkMenuItem *
|
||||
gm_app_view_menu_item(GmAppView *view, gchar const *path) {
|
||||
GtkMenuItem *img = GTK_MENU_ITEM(
|
||||
gtk_ui_manager_get_widget(view->priv->manager, path));
|
||||
return img;
|
||||
}
|
||||
|
||||
GtkAction *
|
||||
gm_app_view_action(GmAppView *view, gchar const *path) {
|
||||
GtkAction *action = gtk_ui_manager_get_action(view->priv->manager, path);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gm_app_view_update_connect_button(GmAppView *view, gboolean connected) {
|
||||
GtkImageMenuItem *img = GTK_IMAGE_MENU_ITEM(
|
||||
gtk_ui_manager_get_widget(view->priv->manager,
|
||||
"/MenuBar/WorldMenu/WorldConnectMenu"));
|
||||
GtkLabel *label = GTK_LABEL(gm_app_view_container_item(GTK_CONTAINER(img),
|
||||
GtkLabel *label = GTK_LABEL(gm_container_item(GTK_CONTAINER(img),
|
||||
GTK_TYPE_LABEL));
|
||||
GtkWidget *im;
|
||||
|
||||
|
@ -729,7 +735,7 @@ on_gm_app_view_world_added(GmApp *app, GmWorld *world, GmAppView *view) {
|
|||
gchar *name = g_strdup_printf("WorldItem%d", id);
|
||||
gchar *tooltip = g_strconcat(_("Open world "), gm_world_name(world), NULL);
|
||||
|
||||
id++;
|
||||
++id;
|
||||
|
||||
/* TODO: add custom icon from logo */
|
||||
item->merge_id = gtk_ui_manager_new_merge_id(view->priv->manager);
|
||||
|
@ -785,6 +791,9 @@ on_gm_app_view_world_load(GmWorld *world, GmAppView *view) {
|
|||
g_signal_connect(tab, "close",
|
||||
G_CALLBACK(on_gm_app_view_world_close_from_tab), world);
|
||||
|
||||
g_signal_connect(gm_world_get_mcp_session(world), "package_created",
|
||||
G_CALLBACK(on_gm_app_view_world_mcp_package_created), view);
|
||||
|
||||
gtk_notebook_append_page(view->priv->notebook, world_view,
|
||||
GTK_WIDGET(tab));
|
||||
gtk_widget_show_all(world_view);
|
||||
|
@ -815,8 +824,8 @@ on_gm_app_view_world_activate_request(GmWorld *world, GmAppView *view) {
|
|||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_world_quit(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
gtk_widget_destroy(GTK_WIDGET(view));
|
||||
on_gm_app_view_world_quit(GtkMenuItem *menuitem, GmAppView *view) {
|
||||
gtk_widget_destroy(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1285,18 +1294,6 @@ on_gm_app_view_world_connect(GtkMenuItem * menuitem, GmAppView *view) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_world_info(GtkMenuItem *menuitem, GmAppView *view) {
|
||||
GmWorld *world = gm_app_view_active_world(view);
|
||||
|
||||
if (world) {
|
||||
gm_world_info_dialog_new(gm_world_info(world));
|
||||
} else {
|
||||
gm_app_view_update_world_info(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_gm_app_view_view_mcp(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
/* TODO: implementation */
|
||||
|
@ -1311,62 +1308,53 @@ on_gm_app_view_view_scripts(GtkMenuItem * menuitem, GmAppView *view) {
|
|||
}
|
||||
|
||||
void
|
||||
gm_app_view_open_log_progress(long bytes_read, long bytes_total, gchar *buf,
|
||||
GtkProgressBar *progress) {
|
||||
gtk_progress_bar_set_fraction(progress, (double)bytes_read / (double)bytes_total);
|
||||
gm_do_events();
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_world_logs(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
GtkDialog *dlg;
|
||||
GtkTreeView *tview;
|
||||
GtkTreeModel *smodel;
|
||||
gchar *tmp, *tmp2;
|
||||
GtkTreeIter iter;
|
||||
gboolean done = FALSE;
|
||||
static GdkCursor *wait_cursor = NULL;
|
||||
GmWorld *world = gm_app_view_active_world(view);
|
||||
GtkProgressBar *pgs;
|
||||
on_gm_app_view_world_logs(GtkMenuItem *menuitem, GmAppView *view) {
|
||||
GtkDialog *dlg;
|
||||
GtkTreeView *tview;
|
||||
GtkTreeModel *smodel;
|
||||
gchar *tmp, *tmp2;
|
||||
GtkTreeIter iter;
|
||||
gboolean done = FALSE;
|
||||
GdkCursor *wait_cursor;
|
||||
GmWorld *world = gm_app_view_active_world(view);
|
||||
|
||||
dlg = gm_world_logs_dialog_new(gm_app_view_active_world(view), &tview, &pgs);
|
||||
dlg = gm_world_logs_dialog_new(gm_app_view_active_world(view), &tview);
|
||||
|
||||
if (dlg != NULL) {
|
||||
smodel = gtk_tree_view_get_model(tview);
|
||||
if (dlg != NULL) {
|
||||
smodel = gtk_tree_view_get_model(tview);
|
||||
|
||||
while (!done) {
|
||||
done = TRUE;
|
||||
switch (gtk_dialog_run(dlg)) {
|
||||
case GTK_RESPONSE_OK:
|
||||
if (gtk_tree_selection_get_selected(
|
||||
gtk_tree_view_get_selection(tview), &smodel, &iter)) {
|
||||
gtk_tree_model_get(smodel, &iter, 0, &tmp, -1);
|
||||
tmp2 = g_strconcat(gm_world_path(world), tmp, NULL);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(dlg), FALSE);
|
||||
|
||||
if (wait_cursor == NULL) {
|
||||
wait_cursor = gdk_cursor_new(GDK_WATCH);
|
||||
}
|
||||
|
||||
gdk_window_set_cursor(GTK_WIDGET(dlg)->window, wait_cursor);
|
||||
gtk_widget_show(GTK_WIDGET(pgs));
|
||||
gm_world_view_open_log(gm_app_view_active_world_view(view), tmp2,
|
||||
(OpenLogProgress)gm_app_view_open_log_progress,
|
||||
pgs);
|
||||
done = TRUE;
|
||||
|
||||
switch (gtk_dialog_run(dlg)) {
|
||||
case GTK_RESPONSE_OK:
|
||||
if (gtk_tree_selection_get_selected(
|
||||
gtk_tree_view_get_selection(tview), &smodel,
|
||||
&iter)) {
|
||||
gtk_tree_model_get(smodel, &iter, 0, &tmp, -1);
|
||||
tmp2 = g_strconcat(gm_world_path(world), tmp, NULL);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(dlg), FALSE);
|
||||
|
||||
wait_cursor = gdk_cursor_new(GDK_WATCH);
|
||||
gdk_window_set_cursor(GTK_WIDGET(dlg)->window,
|
||||
wait_cursor);
|
||||
gdk_cursor_unref(wait_cursor);
|
||||
|
||||
gtk_widget_hide(GTK_WIDGET(pgs));
|
||||
|
||||
gdk_window_set_cursor(GTK_WIDGET(dlg)->window, NULL);
|
||||
g_free(tmp2);
|
||||
g_free(tmp);
|
||||
} else {
|
||||
gm_error_dialog(_("You didn't select a log file"), NULL);
|
||||
done = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
gm_world_view_open_log(
|
||||
gm_app_view_active_world_view(view), tmp2);
|
||||
|
||||
gdk_window_set_cursor(GTK_WIDGET(dlg)->window, NULL);
|
||||
g_free(tmp2);
|
||||
g_free(tmp);
|
||||
} else {
|
||||
gm_error_dialog(_("You didn't select a log file"),
|
||||
NULL);
|
||||
done = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(dlg));
|
||||
|
@ -1403,3 +1391,9 @@ on_gm_app_view_focus_in(GtkWidget *widget, GdkEventFocus *event,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_world_mcp_package_created(GmMcpSession *session,
|
||||
GmMcpPackage *package, GmAppView *view) {
|
||||
gm_mcp_package_create_view(package, G_OBJECT(view));
|
||||
}
|
||||
|
|
Reference in New Issue