This repository has been archived on 2020-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
gnoemoe/gnoemoe/widgets/gm-commands.c

246 lines
5.9 KiB
C
Raw Normal View History

* VERSION CHANGED TO 2.0.9 * po/POTFILES.in: added gnoemoe/dialogs/gm-world-paste-dialog.c and ui/gm-world-paste.glade * po/nl.po: added translations * ui/Makefile.am: * ui/gm-ui.xml: * ui/gm-world-paste.glade: new paste dialog * gnoemoe/mcp/Makefile.include: added gm-cell-renderer-text.[ch] * gnoemoe/mcp/gm-cell-renderer-text.[ch]: new cell renderer for rendering userlist * gnoemoe/mcp/gm-mcp-vmoo-client.c: update metrics in timeout so to reduce the number of updates when resizing * gnoemoe/mcp/gm-mcp-icecrew-serverinfo.c: max version set to 1.0 (1.0 does not actively request the info because it will be send on initialization). Set menu item invisible instead of insensitive when there is no info available * gnoemoe/mcp/gm-mcp-icecrew-userlist.c: fixed menu item substitution * gnoemoe/mcp/gm-mcp-vmoo-userlist.c: removed support for status because it doesn't really support it * gm-mcp-userlist-view.[ch]: moved column constants to header. Render items with new gm-cell-renderer-text. * gnoemoe/mcp/gm-mcp-icecrew-playerdb.[ch]: made gm_mcp_icecrew_playerdb_players public * gnoemoe/dialogs/Makefile.include: added gm-world-paste-dialog * gnoemoe/dialogs/gm-world-paste-dialog.[ch]: new paste dialog * gnoemoe/dialogs/gm-world-properties-dialog.c: * gnoemoe/dialogs/gm-world-logs-dialog.c: fixed leaking tree stores * gnoemoe/widgets/Makefile.include: added gm-commands.[ch] * gnoemoe/widgets/gm-commands.[ch]: new file for handling action activation (removed from gm-app-view) * gnoemoe/widgets/gm-world-view.c: fixed userlist size restore * gnoemoe/widgets/gm-app-view.c: removed action handlers * gnoemoe/gm-support.[ch]: added gm_find_child * gnoemoe/gm-world.c: removed debug message * gnoemoe/gm-ui.h: changed actions to gm-commands
2006-04-23 16:51:04 +02:00
#include "gm-app-view.h"
#include "gm-commands.h"
#include "gm-pixbuf.h"
#include "dialogs/gm-world-properties-dialog.h"
#include "dialogs/gm-open-world-dialog.h"
#include "dialogs/gm-world-paste-dialog.h"
#include "dialogs/gm-world-logs-dialog.h"
#include "dialogs/gm-worlds-list-dialog.h"
#include "dialogs/gm-preferences-dialog.h"
#include "dialogs/gm-scripts-dialog.h"
/* World callbacks */
void
on_action_world_new(GtkAction *action, GmAppView *view) {
gm_world_properties_dialog_run_new(NULL);
}
void
on_action_world_open(GtkAction *action, GmAppView *view) {
gm_open_world_dialog_run();
}
void
on_action_world_connect(GtkAction *action, GmAppView *view) {
GmWorld *world = gm_app_view_active_world(view);
if (world != NULL) {
if (gm_world_disconnected(world)) {
gm_world_connect(world);
} else {
gm_world_disconnect(world);
}
}
}
void
on_action_world_paste(GtkAction *action, GmAppView *view) {
gm_world_paste_dialog_run(view);
}
void
on_action_world_logs(GtkAction *action, 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);
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),
G_DIR_SEPARATOR_S, "logs", G_DIR_SEPARATOR_S,
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);
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));
}
}
void
on_action_world_close(GtkAction *action, GmAppView *view) {
GmWorld *world = gm_app_view_active_world(view);
if (world) {
gm_world_unload(world);
}
}
void
on_action_world_quit(GtkAction *action, GmAppView *view) {
gtk_widget_destroy(GTK_WIDGET(view));
}
/* Edit callbacks */
void
on_action_edit_cut(GtkAction *action, GmAppView *view) {
GtkWidget *active = gtk_window_get_focus(GTK_WINDOW(view));
GtkClipboard *clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
GtkTextBuffer *buf;
if (active && GTK_IS_TEXT_VIEW(active)) {
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(active));
gtk_text_buffer_cut_clipboard(buf, clip, TRUE);
}
}
void
on_action_edit_copy(GtkAction *action, GmAppView *view) {
GtkWidget *active = gtk_window_get_focus(GTK_WINDOW(view));
GtkClipboard *clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
GtkTextBuffer *buf;
GtkTextIter start, end;
GmWorldView *world_view;
world_view = gm_app_view_active_world_view(view);
if (world_view && active == GTK_WIDGET(gm_world_view_input(world_view))) {
buf = gm_world_view_buffer(world_view);
if (gtk_text_buffer_get_selection_bounds(buf, &start, &end)) {
gtk_text_buffer_copy_clipboard(buf, clip);
return;
}
}
if (active && GTK_IS_TEXT_VIEW(active)) {
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(active));
gtk_text_buffer_copy_clipboard(buf, clip);
}
}
void
on_action_edit_paste(GtkAction *action, GmAppView *view) {
GtkWidget *active = gtk_window_get_focus(GTK_WINDOW(view));
GtkClipboard *clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
GtkTextBuffer *buf;
if (active && GTK_IS_TEXT_VIEW(active)) {
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(active));
gtk_text_buffer_paste_clipboard(buf, clip, NULL, TRUE);
}
}
void
on_action_edit_world(GtkAction *action, GmAppView *view) {
GmWorld *active = gm_app_view_active_world(view);
gm_world_properties_dialog_run(active);
}
void
on_action_edit_worlds(GtkAction *action, GmAppView *view) {
gm_worlds_list_dialog_run();
}
void
on_action_edit_preferences(GtkAction *action, GmAppView *view) {
gm_preferences_dialog_run();
}
void
on_action_edit_scripts(GtkAction *action, GmAppView *view) {
#ifdef HAVE_RUBY
gm_scripts_dialog_run(view);
#endif
}
/* Editor callbacks */
void
on_action_editor_save(GtkAction *action, GmAppView *view) {
gm_editor_view_save(gm_app_view_active_editor_view(view));
}
void
on_action_editor_save_close(GtkAction *action, GmAppView *view) {
GmEditorView *editor_view = gm_app_view_active_editor_view(view);
gm_editor_view_save(editor_view);
gm_editor_close(gm_editor_view_editor(editor_view));
}
#ifdef HAVE_PARSER
* VERSION CHANGED TO 2.0.9 * po/POTFILES.in: added gnoemoe/dialogs/gm-world-paste-dialog.c and ui/gm-world-paste.glade * po/nl.po: added translations * ui/Makefile.am: * ui/gm-ui.xml: * ui/gm-world-paste.glade: new paste dialog * gnoemoe/mcp/Makefile.include: added gm-cell-renderer-text.[ch] * gnoemoe/mcp/gm-cell-renderer-text.[ch]: new cell renderer for rendering userlist * gnoemoe/mcp/gm-mcp-vmoo-client.c: update metrics in timeout so to reduce the number of updates when resizing * gnoemoe/mcp/gm-mcp-icecrew-serverinfo.c: max version set to 1.0 (1.0 does not actively request the info because it will be send on initialization). Set menu item invisible instead of insensitive when there is no info available * gnoemoe/mcp/gm-mcp-icecrew-userlist.c: fixed menu item substitution * gnoemoe/mcp/gm-mcp-vmoo-userlist.c: removed support for status because it doesn't really support it * gm-mcp-userlist-view.[ch]: moved column constants to header. Render items with new gm-cell-renderer-text. * gnoemoe/mcp/gm-mcp-icecrew-playerdb.[ch]: made gm_mcp_icecrew_playerdb_players public * gnoemoe/dialogs/Makefile.include: added gm-world-paste-dialog * gnoemoe/dialogs/gm-world-paste-dialog.[ch]: new paste dialog * gnoemoe/dialogs/gm-world-properties-dialog.c: * gnoemoe/dialogs/gm-world-logs-dialog.c: fixed leaking tree stores * gnoemoe/widgets/Makefile.include: added gm-commands.[ch] * gnoemoe/widgets/gm-commands.[ch]: new file for handling action activation (removed from gm-app-view) * gnoemoe/widgets/gm-world-view.c: fixed userlist size restore * gnoemoe/widgets/gm-app-view.c: removed action handlers * gnoemoe/gm-support.[ch]: added gm_find_child * gnoemoe/gm-world.c: removed debug message * gnoemoe/gm-ui.h: changed actions to gm-commands
2006-04-23 16:51:04 +02:00
void
on_action_editor_parse(GtkAction *action, GmAppView *view) {
gm_editor_view_check_syntax(gm_app_view_active_editor_view(view));
}
#endif
* VERSION CHANGED TO 2.0.9 * po/POTFILES.in: added gnoemoe/dialogs/gm-world-paste-dialog.c and ui/gm-world-paste.glade * po/nl.po: added translations * ui/Makefile.am: * ui/gm-ui.xml: * ui/gm-world-paste.glade: new paste dialog * gnoemoe/mcp/Makefile.include: added gm-cell-renderer-text.[ch] * gnoemoe/mcp/gm-cell-renderer-text.[ch]: new cell renderer for rendering userlist * gnoemoe/mcp/gm-mcp-vmoo-client.c: update metrics in timeout so to reduce the number of updates when resizing * gnoemoe/mcp/gm-mcp-icecrew-serverinfo.c: max version set to 1.0 (1.0 does not actively request the info because it will be send on initialization). Set menu item invisible instead of insensitive when there is no info available * gnoemoe/mcp/gm-mcp-icecrew-userlist.c: fixed menu item substitution * gnoemoe/mcp/gm-mcp-vmoo-userlist.c: removed support for status because it doesn't really support it * gm-mcp-userlist-view.[ch]: moved column constants to header. Render items with new gm-cell-renderer-text. * gnoemoe/mcp/gm-mcp-icecrew-playerdb.[ch]: made gm_mcp_icecrew_playerdb_players public * gnoemoe/dialogs/Makefile.include: added gm-world-paste-dialog * gnoemoe/dialogs/gm-world-paste-dialog.[ch]: new paste dialog * gnoemoe/dialogs/gm-world-properties-dialog.c: * gnoemoe/dialogs/gm-world-logs-dialog.c: fixed leaking tree stores * gnoemoe/widgets/Makefile.include: added gm-commands.[ch] * gnoemoe/widgets/gm-commands.[ch]: new file for handling action activation (removed from gm-app-view) * gnoemoe/widgets/gm-world-view.c: fixed userlist size restore * gnoemoe/widgets/gm-app-view.c: removed action handlers * gnoemoe/gm-support.[ch]: added gm_find_child * gnoemoe/gm-world.c: removed debug message * gnoemoe/gm-ui.h: changed actions to gm-commands
2006-04-23 16:51:04 +02:00
void
on_action_editor_close(GtkAction *action, GmAppView *view) {
gm_editor_close(gm_editor_view_editor(
gm_app_view_active_editor_view(view)));
}
/* Toolbar callbacks */
void
on_action_edit_triggers(GtkAction *action, GmAppView *view) {
GmWorld *active = gm_app_view_active_world(view);
gm_world_properties_dialog_run_triggers(active);
}
/* Help callbacks */
static const gchar *authors[] = {
N_("Jesse van den Kieboom"),
N_("Sjoerd Simons (debian package)"),
NULL
};
static const gchar *artists[] = {
N_("Simon Gijsen"),
NULL
};
void
on_action_help_about(GtkAction *action, GmAppView *view) {
gtk_show_about_dialog(GTK_WINDOW(view),
"name", _("GnoeMoe"),
"version", PACKAGE_VERSION,
"copyright", _("(C) 2004-2005 Icecrew.nl"),
"comments", _("GnoeMoe Gnome MOO Client"),
"authors", authors,
"artists", artists,
"logo", gm_pixbuf_get("gnoemoe_logo.svg"),
NULL);
}