I don't understand your question at all but a run of your code I'll assume you're talking about the values sent to g_print not being what you want as that seems to be the only error. I'm actually very surprised this compiles. I guess gcc is a lot cleverer than I thought. There are a lot of errors. Here is some that I've corrected:
* in refresh_txtview you have win as a local scope variable but have declared it differently as a global variable above.
* You use sprintf but don't include string.h. actually you are better not including this and use the glib functions (g_sprintf etc.)
* in clicked_cb there is no need to redo gtk_widget_show on the notebook or queue a draw, this will happen automatically when control is passed back to gtk_main. Similarly with all the other refreshing you are doing.
* Also here you have listed the second arguement as GtkNotebook* when it should be gpointer and then cast as needed.
* Your refreshwin function is declared incorrectly
The textview displays exactly how it should so I don't know why you mention it in your question. Did you want the g_print to go to the textview? I'm not sure whether you really want to use g_print, it send info to stdout which on most machines is the terminal, i.e. it won't be seen unless you run the program from the terminal. You would likely be much better setting up a statusbar and pushing the text there each time instead.
The /n you are putting on the end of the strings. You would be better off setting up a macro with conditional compilation to capture both the unix and Windows versions of line endings.
Here is a correction of the code (still using g_print: run from the terminal to see its output)
void clicked_cb(GtkWidget *widget, gpointer data)
GtkWidget *lbl, *txtview;
g_snprintf(str, 15, "Page %d", ++n);
lbl = gtk_label_new(str);
txtview = gtk_text_view_new();
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txtview));
mark = gtk_text_buffer_get_insert(buffer);
gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
gtk_text_buffer_insert(buffer, &iter, "Buffer", -1);
gtk_notebook_append_page(GTK_NOTEBOOK(data), txtview, lbl); //加入页面
void refreshwin(GtkWidget* widget, gpointer data)
num = gtk_notebook_current_page(GTK_NOTEBOOK(widget));
g_print("Current Page Number: %d, Total Number of Pages = %d\n", ++num, pagenum);
int main(int argc, char **argv)
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
vbox = gtk_vbox_new(FALSE, 0);
nb = gtk_notebook_new();
gtk_box_pack_start(GTK_BOX(vbox), nb, TRUE, TRUE, 0);
button = gtk_button_new_with_label("Add Page");
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(clicked_cb), (gpointer)nb);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);