Added replace, fixed tab dragging, sorted worlds in menu
This commit is contained in:
parent
e45ee6f583
commit
8939311dea
|
@ -53,7 +53,12 @@ gboolean on_gm_app_view_entry_find_key_press(GtkWidget *widget,
|
|||
GdkEventKey *event, GmAppView *view);
|
||||
void on_gm_app_view_button_find_close_clicked(GtkButton *button,
|
||||
GmAppView *view);
|
||||
|
||||
void on_gm_app_view_button_replace_clicked(GtkButton *button,
|
||||
GmAppView *view);
|
||||
void on_gm_app_view_button_replace_all_clicked(GtkButton *button,
|
||||
GmAppView *view);
|
||||
void on_gm_app_view_expander_replace(GObject *object, GParamSpec *param_spec,
|
||||
GmAppView *view);
|
||||
void on_gm_app_view_notebook_switch_page(GtkNotebook * notebook,
|
||||
GtkNotebookPage * page, guint page_num, GmAppView *view);
|
||||
void on_gm_app_view_world_view_notebook_switch_page(GtkNotebook * notebook,
|
||||
|
@ -119,9 +124,13 @@ struct _GmAppViewPrivate {
|
|||
GmWorld *active_world;
|
||||
GtkMenuBar *menu;
|
||||
|
||||
GtkLabel *label_replace;
|
||||
GtkExpander *expander_replace;
|
||||
GtkEntry *entry_find;
|
||||
GtkEntry *entry_replace;
|
||||
GtkVBox *vbox_find;
|
||||
GtkHBox *hbox_control_find;
|
||||
GtkHBox *hbox_replace;
|
||||
GtkCheckButton *check_button_search_direction;
|
||||
gboolean ignore_toggling;
|
||||
|
||||
|
@ -129,6 +138,7 @@ struct _GmAppViewPrivate {
|
|||
gint motion_notify_handler_id;
|
||||
gint x_start;
|
||||
gint y_start;
|
||||
gint tab;
|
||||
GdkCursor *cursor;
|
||||
};
|
||||
|
||||
|
@ -148,6 +158,9 @@ gm_app_view_finalize(GObject *object) {
|
|||
|
||||
gm_scripts_dialog_fini();
|
||||
|
||||
if (view->priv->cursor)
|
||||
gdk_cursor_unref(view->priv->cursor);
|
||||
|
||||
g_hash_table_destroy(view->priv->world_menu_items);
|
||||
G_OBJECT_CLASS(gm_app_view_parent_class)->finalize(object);
|
||||
}
|
||||
|
@ -211,65 +224,126 @@ gm_app_view_create_menu(GmAppView *view) {
|
|||
|
||||
#ifndef HAVE_RUBY
|
||||
gtk_widget_set_sensitive(gtk_ui_manager_get_widget(view->priv->manager,
|
||||
"/MenuBar/ViewMenu/ViewScriptsMenu"), FALSE);
|
||||
"/MenuBar/ViewMenu/EditScriptsMenu"), FALSE);
|
||||
#endif
|
||||
|
||||
return gtk_ui_manager_get_widget(view->priv->manager, "/MenuBar");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_button(gchar *label, gchar *stock) {
|
||||
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
|
||||
GtkWidget *button = gtk_button_new();
|
||||
GtkWidget *hbox = gtk_hbox_new(FALSE, 2);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(button), align);
|
||||
gtk_container_add(GTK_CONTAINER(align), hbox);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_stock(
|
||||
stock, GTK_ICON_SIZE_BUTTON), FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox),
|
||||
gtk_label_new(label), FALSE, FALSE, 0);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gm_app_view_create_search_box(GmAppView *view) {
|
||||
GtkWidget *vbox = gtk_vbox_new(FALSE, 3);
|
||||
GtkWidget *hbox = gtk_hbox_new(FALSE, 6);
|
||||
GtkWidget *table = gtk_table_new(2, 2, FALSE);
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox_control = gtk_hbox_new(FALSE, 6);
|
||||
GtkWidget *lbl = gtk_label_new(_("Find:"));
|
||||
GtkWidget *entry = gtk_entry_new();
|
||||
GtkWidget *button = gtk_button_new();
|
||||
GtkWidget *hbox_button = gtk_hbox_new(FALSE, 2);
|
||||
GtkWidget *align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
|
||||
GtkWidget *lbl;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *button;
|
||||
GtkWidget *align;
|
||||
GtkWidget *check_button =
|
||||
gtk_check_button_new_with_label(_("Search backwards"));
|
||||
GtkWidget *button_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
||||
GtkWidget *separator = gtk_hseparator_new();
|
||||
GtkWidget *expander = gtk_expander_new(NULL);
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(table), 3);
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 6);
|
||||
lbl = gtk_label_new(_("Find:"));
|
||||
gtk_misc_set_alignment(GTK_MISC(lbl), 1.0, 0.5);
|
||||
|
||||
gtk_widget_set_sensitive(expander, FALSE);
|
||||
align = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
|
||||
gtk_container_add(GTK_CONTAINER(align), expander);
|
||||
g_signal_connect(expander, "notify::expanded",
|
||||
G_CALLBACK(on_gm_app_view_expander_replace), view);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), align, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), lbl, FALSE, FALSE, 0);
|
||||
gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 0, 1, GTK_SHRINK | GTK_FILL,
|
||||
GTK_SHRINK | GTK_FILL, 0.0, 0.0);
|
||||
lbl = gtk_label_new(_("Replace:"));
|
||||
view->priv->label_replace = GTK_LABEL(lbl);
|
||||
gtk_misc_set_alignment(GTK_MISC(lbl), 1.0, 0.5);
|
||||
gtk_table_attach(GTK_TABLE(table), lbl, 0, 1, 1, 2, GTK_SHRINK | GTK_FILL,
|
||||
GTK_SHRINK | GTK_FILL, 0.0, 0.0);
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 6);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
||||
gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL,
|
||||
GTK_SHRINK | GTK_FILL, 0.0, 0.0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, TRUE, 0);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(button), align);
|
||||
gtk_container_add(GTK_CONTAINER(align), hbox_button);
|
||||
gtk_box_pack_start(GTK_BOX(hbox_button), gtk_image_new_from_stock(
|
||||
GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON), FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox_button),
|
||||
gtk_label_new(_("Find next")), FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox_control), lbl, FALSE, FALSE, 0);
|
||||
entry = gtk_entry_new();
|
||||
view->priv->entry_find = GTK_ENTRY(entry);
|
||||
button = create_button(_("Find next"), GTK_STOCK_FIND);
|
||||
g_signal_connect(button, "clicked",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_activate), view);
|
||||
g_signal_connect(entry, "key_press_event",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_key_press), view);
|
||||
g_signal_connect(entry, "activate",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_activate), view);
|
||||
g_signal_connect(entry, "changed",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_changed), view);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox_control), entry, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox_control), button, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox_control), check_button, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), hbox_control, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end(GTK_BOX(hbox), button_close, FALSE, FALSE, 0);
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 6);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
|
||||
entry = gtk_entry_new();
|
||||
g_signal_connect(entry, "key_press_event",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_key_press), view);
|
||||
view->priv->entry_replace = GTK_ENTRY(entry);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
|
||||
|
||||
button = create_button(_("Replace"), GTK_STOCK_FIND_AND_REPLACE);
|
||||
g_signal_connect(button, "clicked",
|
||||
G_CALLBACK(on_gm_app_view_button_replace_clicked), view);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
button = gtk_button_new_with_label(_("Replace all"));
|
||||
g_signal_connect(button, "clicked",
|
||||
G_CALLBACK(on_gm_app_view_button_replace_all_clicked), view);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
|
||||
gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL,
|
||||
GTK_SHRINK | GTK_FILL, 0.0, 0.0);
|
||||
|
||||
view->priv->expander_replace = GTK_EXPANDER(expander);
|
||||
view->priv->hbox_replace = GTK_HBOX(hbox);
|
||||
view->priv->vbox_find = GTK_VBOX(vbox);
|
||||
view->priv->hbox_control_find = GTK_HBOX(hbox_control);
|
||||
view->priv->entry_find = GTK_ENTRY(entry);
|
||||
view->priv->check_button_search_direction = GTK_CHECK_BUTTON(check_button);
|
||||
view->priv->ignore_toggling = FALSE;
|
||||
|
||||
gtk_widget_show_all(vbox);
|
||||
gtk_widget_hide(GTK_WIDGET(view->priv->label_replace));
|
||||
gtk_widget_hide(GTK_WIDGET(view->priv->hbox_replace));
|
||||
gtk_widget_hide(vbox);
|
||||
|
||||
g_signal_connect(entry, "activate",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_activate), view);
|
||||
g_signal_connect(entry, "changed",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_changed), view);
|
||||
g_signal_connect(entry, "key_press_event",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_key_press), view);
|
||||
|
||||
g_signal_connect(button_close, "clicked",
|
||||
G_CALLBACK(on_gm_app_view_button_find_close_clicked), view);
|
||||
g_signal_connect(button, "clicked",
|
||||
G_CALLBACK(on_gm_app_view_entry_find_activate), view);
|
||||
g_signal_connect(check_button, "toggled",
|
||||
G_CALLBACK(on_gm_app_view_check_button_search_direction_toggled),
|
||||
view);
|
||||
|
@ -535,14 +609,16 @@ gm_app_view_update_connect_button(GmAppView *view, gboolean connected) {
|
|||
|
||||
void
|
||||
gm_app_view_worlds_unloaded(GmAppView *view) {
|
||||
gm_app_view_set_sensitivity(view, FALSE);
|
||||
gm_app_view_update_connect_button(view, FALSE);
|
||||
gm_app_view_update_title(view);
|
||||
gm_app_view_set_sensitivity(view, FALSE);
|
||||
gm_app_view_update_connect_button(view, FALSE);
|
||||
gm_app_view_update_title(view);
|
||||
}
|
||||
|
||||
void
|
||||
gm_app_view_worlds_loaded(GmAppView *view) {
|
||||
gm_app_view_set_sensitivity(view, TRUE);
|
||||
gm_app_view_set_sensitivity(view, TRUE);
|
||||
gtk_action_set_sensitive(gm_app_view_action(view,
|
||||
"/MenuBar/EditMenu/EditReplaceMenu"), FALSE);
|
||||
}
|
||||
|
||||
/* TODO: move to custom widget thingie, and put control in gm-app instead
|
||||
|
@ -675,19 +751,6 @@ if_main_show_hide(gboolean show) {
|
|||
}
|
||||
}*/
|
||||
|
||||
void
|
||||
gm_app_view_update_world_info(gboolean hasInfo) {
|
||||
/* TODO: do this some other way */
|
||||
/*GtkWidget *image;
|
||||
world *wld = world_get_active();
|
||||
gtk_widget_set_sensitive(if_main_get_widget("mnuWorldInfo"), hasInfo);
|
||||
|
||||
if (options_get_str(wld->settings, "logo")) {
|
||||
image = gtk_image_new_from_pixbuf(gnoe_pixbuf_get_at_size(options_get_str(wld->settings, "logo"), 16, 16));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(wld->widgets.menuItem), image);
|
||||
}*/
|
||||
}
|
||||
|
||||
GmWorldView *
|
||||
gm_app_view_world_view_from_world(GmAppView *view, GmWorld *world) {
|
||||
GtkNotebook *book = view->priv->notebook;
|
||||
|
@ -739,12 +802,25 @@ on_gm_app_view_world_name_changed(GmWorld *world, const gchar *name,
|
|||
|
||||
void
|
||||
on_gm_app_view_world_added(GmApp *app, GmWorld *world, GmAppView *view) {
|
||||
static guint id = 0;
|
||||
GmAppViewWorldMenuItem *item = g_new0(GmAppViewWorldMenuItem, 1);
|
||||
gchar *name = g_strdup_printf("WorldItem%d", id);
|
||||
gchar *name = g_strconcat("WorldItem", gm_world_name(world), NULL);
|
||||
gchar *tooltip = g_strconcat(_("Open world "), gm_world_name(world), NULL);
|
||||
gchar *path;
|
||||
GList *worlds, *position;
|
||||
gboolean top;
|
||||
|
||||
++id;
|
||||
// Find the world previous to this one
|
||||
worlds = gm_app_worlds(app);
|
||||
position = g_list_find(worlds, world);
|
||||
|
||||
if (!position || !position->prev) {
|
||||
path = g_strdup("/MenuBar/WorldMenu/WorldMenuAdditions");
|
||||
top = TRUE;
|
||||
} else {
|
||||
path = g_strconcat("/MenuBar/WorldMenu/WorldMenuAdditions/WorldItem",
|
||||
gm_world_name((GmWorld *)(position->prev->data)), NULL);
|
||||
top = FALSE;
|
||||
}
|
||||
|
||||
/* TODO: add custom icon from logo */
|
||||
item->merge_id = gtk_ui_manager_new_merge_id(view->priv->manager);
|
||||
|
@ -752,8 +828,11 @@ on_gm_app_view_world_added(GmApp *app, GmWorld *world, GmAppView *view) {
|
|||
|
||||
gtk_action_group_add_action(view->priv->worlds_action_group, item->action);
|
||||
gtk_ui_manager_add_ui(view->priv->manager, item->merge_id,
|
||||
"/MenuBar/WorldMenu/WorldMenuAdditions", name, name,
|
||||
GTK_UI_MANAGER_MENUITEM, FALSE);
|
||||
path, name, name,
|
||||
GTK_UI_MANAGER_MENUITEM, top);
|
||||
|
||||
g_free(path);
|
||||
gtk_ui_manager_ensure_update(view->priv->manager);
|
||||
|
||||
g_signal_connect(item->action, "activate",
|
||||
G_CALLBACK(on_gm_app_view_world_activate), world);
|
||||
|
@ -904,24 +983,24 @@ gm_app_view_search_flags(GmAppView *view) {
|
|||
|
||||
gboolean
|
||||
gm_app_view_find_first(GmAppView *view) {
|
||||
GmWorldView *world_view = gm_app_view_active_world_view(view);
|
||||
GdkColor red;
|
||||
GtkEntry *entry = view->priv->entry_find;
|
||||
GmWorldView *world_view = gm_app_view_active_world_view(view);
|
||||
GdkColor red;
|
||||
GtkEntry *entry = view->priv->entry_find;
|
||||
gchar const *text;
|
||||
|
||||
if (world_view) {
|
||||
gdk_color_parse ("#ff6666", &red);
|
||||
//gdk_color_parse ("white", &white);
|
||||
|
||||
if (g_utf8_strlen(gtk_entry_get_text(entry), -1) == 0 ||
|
||||
gm_world_view_find_first(world_view, gtk_entry_get_text(entry),
|
||||
gm_app_view_search_flags(view))) {
|
||||
gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, NULL);
|
||||
} else {
|
||||
gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, &red);
|
||||
}
|
||||
}
|
||||
if (world_view) {
|
||||
gdk_color_parse ("#ff6666", &red);
|
||||
text = gtk_entry_get_text(entry);
|
||||
|
||||
if (gm_world_view_find_first(world_view, text,
|
||||
gm_app_view_search_flags(view)) || *text == '\0') {
|
||||
gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, NULL);
|
||||
} else {
|
||||
gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, &red);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -934,6 +1013,34 @@ on_gm_app_view_entry_find_activate(GtkEntry *entry, GmAppView *view) {
|
|||
on_gm_app_view_edit_find_next(NULL, view);
|
||||
}
|
||||
|
||||
void
|
||||
gm_app_view_show_replace_box(GmAppView *view) {
|
||||
GmWorldView *world_view;
|
||||
gint i, n;
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE(view->priv->hbox_replace)) {
|
||||
n = gtk_notebook_get_n_pages(view->priv->notebook);
|
||||
|
||||
for (i = 0; i < gtk_notebook_get_n_pages(view->priv->notebook); i++) {
|
||||
world_view = GM_WORLD_VIEW(gtk_notebook_get_nth_page(
|
||||
view->priv->notebook, i));
|
||||
|
||||
gm_world_view_scroll_end_prepare(world_view);
|
||||
}
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(view->priv->label_replace));
|
||||
gtk_widget_show(GTK_WIDGET(view->priv->hbox_replace));
|
||||
gm_do_events();
|
||||
|
||||
for (i = 0; i < gtk_notebook_get_n_pages(view->priv->notebook); i++) {
|
||||
world_view = GM_WORLD_VIEW(gtk_notebook_get_nth_page(
|
||||
view->priv->notebook, i));
|
||||
|
||||
gm_world_view_scroll_end(world_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gm_app_view_show_find_box(GmAppView *view) {
|
||||
GmWorldView *world_view;
|
||||
|
@ -979,11 +1086,51 @@ on_gm_app_view_edit_find_next(GtkMenuItem * menuitem, GmAppView *view) {
|
|||
gm_app_view_search_flags(view));
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_edit_replace(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
GtkWidget *entry = GTK_WIDGET(view->priv->entry_replace);
|
||||
|
||||
gm_app_view_show_find_box(view);
|
||||
gm_app_view_show_replace_box(view);
|
||||
gtk_widget_grab_focus(entry);
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_button_find_clicked(GtkButton *button, gpointer user_data) {
|
||||
on_gm_app_view_edit_find_next(NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_button_replace_clicked(GtkButton *button, GmAppView *view) {
|
||||
if (gm_world_view_replace(gm_app_view_active_world_view(view),
|
||||
gtk_entry_get_text(view->priv->entry_replace))) {
|
||||
gm_world_view_find_next(gm_app_view_active_world_view(view),
|
||||
gtk_entry_get_text(view->priv->entry_find),
|
||||
gm_app_view_search_flags(view));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_button_replace_all_clicked(GtkButton *button, GmAppView *view) {
|
||||
gm_world_view_replace_all(gm_app_view_active_world_view(view),
|
||||
gtk_entry_get_text(view->priv->entry_find),
|
||||
gtk_entry_get_text(view->priv->entry_replace),
|
||||
gm_app_view_search_flags(view));
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_expander_replace(GObject *object, GParamSpec *param_spec,
|
||||
GmAppView *view) {
|
||||
gboolean exp = gtk_expander_get_expanded(view->priv->expander_replace);
|
||||
|
||||
if (exp) {
|
||||
gm_app_view_show_replace_box(view);
|
||||
} else {
|
||||
gtk_widget_hide(GTK_WIDGET(view->priv->label_replace));
|
||||
gtk_widget_hide(GTK_WIDGET(view->priv->hbox_replace));
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
on_gm_app_view_entry_find_key_press(GtkWidget *widget, GdkEventKey *event,
|
||||
GmAppView *view) {
|
||||
|
@ -1081,8 +1228,8 @@ gm_app_view_find_tab_num_at_pos(GmAppView *view, gint abs_x,
|
|||
if (((tab_pos == GTK_POS_TOP) || (tab_pos == GTK_POS_BOTTOM)) &&
|
||||
(abs_x <= max_x)) {
|
||||
return page_num;
|
||||
} else if (((tab_pos == GTK_POS_LEFT) || (tab_pos == GTK_POS_RIGHT)) &&
|
||||
(abs_y <= max_y)) {
|
||||
} else if (((tab_pos == GTK_POS_LEFT) ||
|
||||
(tab_pos == GTK_POS_RIGHT)) && (abs_y <= max_y)) {
|
||||
return page_num;
|
||||
}
|
||||
|
||||
|
@ -1097,8 +1244,8 @@ gm_app_view_drag_stop(GmAppView *view) {
|
|||
view->priv->drag_in_progress = FALSE;
|
||||
|
||||
if (view->priv->motion_notify_handler_id != 0) {
|
||||
g_signal_handler_disconnect(G_OBJECT(view->priv->notebook),
|
||||
view->priv->motion_notify_handler_id);
|
||||
g_signal_handler_disconnect(G_OBJECT(view->priv->notebook),
|
||||
view->priv->motion_notify_handler_id);
|
||||
|
||||
view->priv->motion_notify_handler_id = 0;
|
||||
}
|
||||
|
@ -1119,8 +1266,8 @@ gm_app_view_drag_start(GmAppView *view, guint32 time) {
|
|||
/* FIXME multi-head */
|
||||
if (!gdk_pointer_is_grabbed()) {
|
||||
gdk_pointer_grab(GTK_WIDGET(view->priv->notebook)->window,
|
||||
FALSE, GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL,
|
||||
view->priv->cursor, time);
|
||||
FALSE, GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL,
|
||||
view->priv->cursor, time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1133,17 +1280,18 @@ gm_app_view_move_current_tab(GmAppView *view, gint dest_position) {
|
|||
GtkWidget *cur_tab;
|
||||
|
||||
cur_tab = gtk_notebook_get_nth_page(view->priv->notebook, cur_page_num);
|
||||
gtk_notebook_reorder_child(view->priv->notebook, cur_tab, dest_position);
|
||||
gtk_notebook_reorder_child(view->priv->notebook, cur_tab,
|
||||
dest_position);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
on_gm_app_view_motion_notify(GmAppView *view, GdkEventMotion *event,
|
||||
gpointer data) {
|
||||
on_gm_app_view_motion_notify(GtkWidget *widget, GdkEventMotion *event,
|
||||
GmAppView *view) {
|
||||
gint page_num;
|
||||
|
||||
if (view->priv->drag_in_progress == FALSE) {
|
||||
if (gtk_drag_check_threshold(GTK_WIDGET(view->priv->notebook),
|
||||
if (gtk_drag_check_threshold(widget,
|
||||
view->priv->x_start,
|
||||
view->priv->y_start,
|
||||
event->x_root,
|
||||
|
@ -1180,12 +1328,18 @@ on_gm_app_view_notebook_button_press(GtkNotebook *notebook,
|
|||
(tab_clicked >= 0)) {
|
||||
view->priv->x_start = event->x_root;
|
||||
view->priv->y_start = event->y_root;
|
||||
|
||||
view->priv->motion_notify_handler_id = g_signal_connect(G_OBJECT(notebook),
|
||||
"motion-notify-event", G_CALLBACK(on_gm_app_view_motion_notify), NULL);
|
||||
} else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
|
||||
/* Switch to the page the mouse is over, but don't consume the event */
|
||||
//gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
|
||||
view->priv->tab = tab_clicked;
|
||||
view->priv->motion_notify_handler_id =
|
||||
g_signal_connect(G_OBJECT(notebook), "motion-notify-event",
|
||||
G_CALLBACK(on_gm_app_view_motion_notify), view);
|
||||
} else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
|
||||
if (tab_clicked == -1) {
|
||||
/* Don't show context menu for non tabs */
|
||||
return TRUE;
|
||||
} else {
|
||||
/* Switch to the page the mouse is over, but don't consume the event */
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK (notebook), tab_clicked);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -1220,13 +1374,34 @@ on_gm_app_view_world_view_notebook_switch_page(GtkNotebook *notebook,
|
|||
GtkNotebookPage * page, guint page_num, GmAppView *view) {
|
||||
GmWorldView *world_view = GM_WORLD_VIEW(notebook);
|
||||
gboolean direction;
|
||||
gboolean can_replace;
|
||||
gboolean can_find;
|
||||
|
||||
if (!GTK_IS_WIDGET(view) || !GTK_IS_WIDGET(page) ||
|
||||
!GTK_IS_WIDGET(view->priv->hbox_control_find))
|
||||
if (!GTK_IS_WIDGET(view) || !GTK_IS_WIDGET(view->priv->hbox_control_find))
|
||||
return;
|
||||
|
||||
can_find = gm_world_view_page_can_find(world_view, page_num);
|
||||
gtk_action_set_sensitive(gm_app_view_action(view,
|
||||
"/MenuBar/EditMenu/EditFindMenu"), can_find);
|
||||
gtk_action_set_sensitive(gm_app_view_action(view,
|
||||
"/MenuBar/EditMenu/EditFindNextMenu"), can_find);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(view->priv->hbox_control_find),
|
||||
gm_world_view_page_can_find(world_view, page_num));
|
||||
can_find);
|
||||
|
||||
can_replace = gm_world_view_page_can_replace(world_view, page_num);
|
||||
gtk_action_set_sensitive(gm_app_view_action(view,
|
||||
"/MenuBar/EditMenu/EditReplaceMenu"), can_replace);
|
||||
|
||||
if (!can_replace) {
|
||||
gtk_widget_hide(GTK_WIDGET(view->priv->hbox_replace));
|
||||
gtk_widget_hide(GTK_WIDGET(view->priv->label_replace));
|
||||
gtk_expander_set_expanded(view->priv->expander_replace, FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(view->priv->expander_replace),
|
||||
FALSE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(view->priv->expander_replace),
|
||||
TRUE);
|
||||
}
|
||||
|
||||
if (page_num == 0) {
|
||||
direction = gm_options_get_int(gm_app_options(gm_app_instance()),
|
||||
|
@ -1363,13 +1538,7 @@ on_gm_app_view_world_connect(GtkMenuItem * menuitem, GmAppView *view) {
|
|||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_view_mcp(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
/* TODO: implementation */
|
||||
//if_mcpconsole_create();
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_app_view_view_scripts(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
on_gm_app_view_edit_scripts(GtkMenuItem * menuitem, GmAppView *view) {
|
||||
#ifdef HAVE_RUBY
|
||||
gm_scripts_dialog_run(view);
|
||||
#endif
|
||||
|
|
|
@ -67,11 +67,12 @@ void on_gm_app_view_edit_worlds(GtkMenuItem * menuitem, GmAppView *view);
|
|||
void on_gm_app_view_edit_world(GtkMenuItem * menuitem, GmAppView *view);
|
||||
void on_gm_app_view_edit_find(GtkMenuItem * menuitem, GmAppView *view);
|
||||
void on_gm_app_view_edit_find_next(GtkMenuItem * menuitem, GmAppView *view);
|
||||
void on_gm_app_view_edit_replace(GtkMenuItem * menuitem, GmAppView *view);
|
||||
|
||||
void on_gm_app_view_edit_preferences(
|
||||
GtkMenuItem * menuitem, GmAppView *view);
|
||||
|
||||
void on_gm_app_view_view_mcp(GtkMenuItem * menuitem, GmAppView *view);
|
||||
void on_gm_app_view_view_scripts(GtkMenuItem * menuitem, GmAppView *view);
|
||||
void on_gm_app_view_edit_scripts(GtkMenuItem * menuitem, GmAppView *view);
|
||||
|
||||
void on_gm_app_view_help_about(GtkMenuItem * menuitem, GmAppView *view);
|
||||
|
||||
|
|
Reference in New Issue