/***************************************************************************** Initilialize a lua console. *****************************************************************************/ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) { GtkWidget *entry, *box, *vbox, *sw, *text, *notebook; fc_assert_ret(NULL != pdialog); if (gui_gtk2_message_chat_location == GUI_GTK_MSGCHAT_SPLIT) { notebook = right_notebook; } else { notebook = bottom_notebook; } gui_dialog_new(&pdialog->shell, GTK_NOTEBOOK(notebook), pdialog, TRUE); gui_dialog_set_title(pdialog->shell, _("Client Lua Console")); box = GTK_WIDGET(pdialog->shell->vbox); vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(box), vbox, TRUE, TRUE, 0); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); text = gtk_text_view_new_with_buffer(pdialog->message_buffer); set_message_buffer_view_link_handlers(text); gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); gtk_container_add(GTK_CONTAINER(sw), text); g_signal_connect(text, "size-allocate", G_CALLBACK(luaconsole_dialog_area_size_allocate), NULL); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); gtk_widget_realize(text); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5); pdialog->message_area = GTK_TEXT_VIEW(text); /* The lua console input line. */ entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, TRUE, 2); g_signal_connect(entry, "activate", G_CALLBACK(luaconsole_input_return), NULL); g_signal_connect(entry, "key_press_event", G_CALLBACK(luaconsole_input_handler), NULL); pdialog->entry = entry; /* Load lua script command button. */ gui_dialog_add_stockbutton(pdialog->shell, GTK_STOCK_OPEN, _("Load Lua Script"), LUACONSOLE_RES_OPEN); gui_dialog_add_button(pdialog->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gui_dialog_response_set_callback(pdialog->shell, luaconsole_response_callback); luaconsole_dialog_refresh(pdialog); gui_dialog_show_all(pdialog->shell); }
/**************************************************************** ... *****************************************************************/ static void create_meswin_dialog(void) { GtkCellRenderer *renderer; GtkTreeViewColumn *col; GtkWidget *view, *sw, *cmd, *notebook; if (gui_gtk2_split_bottom_notebook) { notebook = right_notebook; } else { notebook = bottom_notebook; } gui_dialog_new(&meswin_shell, GTK_NOTEBOOK(notebook), NULL); gui_dialog_set_title(meswin_shell, _("Messages")); meswin_store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_box_pack_start(GTK_BOX(meswin_shell->vbox), sw, TRUE, TRUE, 0); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(meswin_store)); meswin_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); g_object_unref(meswin_store); gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view)); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); renderer = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new_with_attributes(NULL, renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); gtk_tree_view_column_set_cell_data_func(col, renderer, meswin_cell_data_func, NULL, NULL); gtk_container_add(GTK_CONTAINER(sw), view); g_signal_connect(meswin_selection, "changed", G_CALLBACK(meswin_selection_callback), NULL); g_signal_connect(view, "row_activated", G_CALLBACK(meswin_row_activated_callback), NULL); g_signal_connect(view, "button-press-event", G_CALLBACK(meswin_button_press_callback), NULL); if (gui_gtk2_show_message_window_buttons) { cmd = gui_dialog_add_stockbutton(meswin_shell, GTK_STOCK_JUMP_TO, _("Goto _Location"), CMD_GOTO); gtk_widget_set_sensitive(cmd, FALSE); cmd = gui_dialog_add_stockbutton(meswin_shell, GTK_STOCK_ZOOM_IN, _("Inspect _City"), CMD_POPCITY); gtk_widget_set_sensitive(cmd, FALSE); } gui_dialog_add_button(meswin_shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gui_dialog_response_set_callback(meswin_shell, meswin_response_callback); gui_dialog_set_default_size(meswin_shell, 520, 300); gui_dialog_show_all(meswin_shell); }