| 87 |
static void really_quit_dialog_no(GtkWidget *widget, gint *flag); |
static void really_quit_dialog_no(GtkWidget *widget, gint *flag); |
| 88 |
static gboolean not_yet_save_changes_really_quit(GtkTextBuffer *buffer); |
static gboolean not_yet_save_changes_really_quit(GtkTextBuffer *buffer); |
| 89 |
static gboolean delete_event_handler(GtkWidget *widget, GdkEvent *event, GtkWidget *buffer); |
static gboolean delete_event_handler(GtkWidget *widget, GdkEvent *event, GtkWidget *buffer); |
|
static GtkWidget *new_scrolled_text_buffer(ShikiTabInfo **tabinfo); |
|
| 90 |
static void open_file(GtkNotebook *notebook, gchar *filename); |
static void open_file(GtkNotebook *notebook, gchar *filename); |
| 91 |
static void open_file_from_notebook(GtkNotebook *notebook); |
static void open_file_from_notebook(GtkNotebook *notebook); |
| 92 |
static void open_file_handler(GtkWidget *widget, GtkWidget *notebook); |
static void open_file_handler(GtkWidget *widget, GtkWidget *notebook); |
| 112 |
static void shiki_editor_window_init(int argc, char **argv); |
static void shiki_editor_window_init(int argc, char **argv); |
| 113 |
|
|
| 114 |
|
|
| 115 |
/* タブの生成と削除 : 基本的に,ShikiTabInfo の中身に格納する情報を増やしたかったら,この 2 つだけを変更すれば良い (ようにする…) */ |
/* タブの生成と削除 : 基本的に,ShikiTabInfo の中身に格納する情報を増やしたかったら,この 2 つの関数だけを変更すれば良い (ようにする…) */ |
| 116 |
static void append_tabpage(GtkNotebook *notebook, gchar *filename); |
static void append_tabpage(GtkNotebook *notebook, gchar *filename); |
| 117 |
static void remove_tabpage(GtkNotebook *notebook); |
static void remove_tabpage(GtkNotebook *notebook); |
| 118 |
|
|
| 119 |
/* ノートブックにタブとページ (バッファ) を追加 */ |
/* ノートブックにタブとページ (バッファ) を追加 */ |
| 120 |
static void append_tabpage(GtkNotebook *notebook, gchar *filename) { |
static void append_tabpage(GtkNotebook *notebook, gchar *filename) { |
| 121 |
ShikiTabInfo *tabinfo; |
/*-------------------- 新しいタブを作る ----------------------------------*/ |
| 122 |
GtkWidget *tabpage = new_scrolled_text_buffer(&tabinfo); |
/* ShikiTabInfo には,タブに関連する情報が全て保持されている */ |
| 123 |
|
ShikiTabInfo *tabinfo = g_malloc(sizeof(ShikiTabInfo)); |
| 124 |
tabinfo->filename = filename; |
tabinfo->filename = filename; |
| 125 |
tabinfo->tabpage_label = g_path_get_basename(filename); |
tabinfo->tabpage_label = g_path_get_basename(filename); |
| 126 |
gtk_notebook_append_page(notebook, tabpage, gtk_label_new(tabinfo->tabpage_label)); |
|
| 127 |
|
/* スクロールウィンドウ (タブの中身の大外) を作る */ |
| 128 |
|
tabinfo->tabpage = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); |
| 129 |
|
gtk_scrolled_window_set_policy (tabinfo->tabpage, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 130 |
|
|
| 131 |
|
/* 枠の中に格納するテキストビューワと,テキストバッファを作る */ |
| 132 |
|
tabinfo->text_view = GTK_TEXT_VIEW(gtk_text_view_new()); |
| 133 |
|
tabinfo->text_buffer = gtk_text_view_get_buffer(tabinfo->text_view); |
| 134 |
|
gtk_container_add(GTK_CONTAINER(tabinfo->tabpage), GTK_WIDGET(tabinfo->text_view)); |
| 135 |
|
gtk_widget_set_size_request(GTK_WIDGET(tabinfo->text_view), 500, 500); |
| 136 |
|
g_signal_connect(tabinfo->text_buffer, "mark_set", G_CALLBACK(text_buffer_cursor_moved_handler), tabinfo->text_view); |
| 137 |
|
/* タブを削除する際,デリートハンドラを削除しておかないと警告が出るから */ |
| 138 |
|
tabinfo->delete_handler_id = g_signal_connect(Shiki_EDITOR_WINDOW, "delete_event", G_CALLBACK(delete_event_handler), tabinfo->text_buffer); |
| 139 |
|
/* 様々な初期化処理 */ |
| 140 |
|
/* 括弧の強調表示のためのタグを作る */ |
| 141 |
|
gtk_text_buffer_create_tag (tabinfo->text_buffer, "parent_emphasis_background", "background", "green", NULL); |
| 142 |
|
|
| 143 |
|
/* タブをノートブックに登録する */ |
| 144 |
|
gtk_notebook_append_page(notebook, GTK_WIDGET(tabinfo->tabpage), gtk_label_new(tabinfo->tabpage_label)); |
| 145 |
|
/* 対応するタブ情報を大域テーブルに保存しておく */ |
| 146 |
Shiki_EDITOR_TAB_INFO_LIST = g_list_append(Shiki_EDITOR_TAB_INFO_LIST, tabinfo); |
Shiki_EDITOR_TAB_INFO_LIST = g_list_append(Shiki_EDITOR_TAB_INFO_LIST, tabinfo); |
| 147 |
|
gtk_widget_show_all(GTK_WIDGET(notebook)); |
| 148 |
|
/* 開いたページに移動する */ |
| 149 |
gtk_notebook_set_current_page(notebook, g_list_length(Shiki_EDITOR_TAB_INFO_LIST) - 1); |
gtk_notebook_set_current_page(notebook, g_list_length(Shiki_EDITOR_TAB_INFO_LIST) - 1); |
|
gtk_widget_show_all(GTK_WIDGET(notebook)); |
|
|
gtk_notebook_set_current_page(notebook, Shiki_CURRENT_TAB_NUM); |
|
| 150 |
} |
} |
| 151 |
|
|
| 152 |
/* ノートブックからタブとページ (バッファ) を削除 */ |
/* ノートブックからタブとページ (バッファ) を削除 */ |
| 436 |
return not_yet_save_changes_really_quit(GTK_TEXT_BUFFER(buffer)); |
return not_yet_save_changes_really_quit(GTK_TEXT_BUFFER(buffer)); |
| 437 |
} |
} |
| 438 |
|
|
|
/* 新しいタブを作る */ |
|
|
static GtkWidget *new_scrolled_text_buffer(ShikiTabInfo **tabinfo) { |
|
|
|
|
|
/* タブに対応するタブ情報を作る */ |
|
|
*tabinfo = g_malloc(sizeof(ShikiTabInfo)); |
|
|
|
|
|
/* スクロールウィンドを作る */ |
|
|
(*tabinfo)->tabpage = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); |
|
|
gtk_scrolled_window_set_policy ((*tabinfo)->tabpage, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
|
|
|
|
|
/* テキストビューワとバッファを作る */ |
|
|
(*tabinfo)->text_view = GTK_TEXT_VIEW(gtk_text_view_new()); |
|
|
(*tabinfo)->text_buffer = gtk_text_view_get_buffer((*tabinfo)->text_view); |
|
|
gtk_container_add(GTK_CONTAINER((*tabinfo)->tabpage), GTK_WIDGET((*tabinfo)->text_view)); |
|
|
gtk_widget_set_size_request(GTK_WIDGET((*tabinfo)->text_view), 500, 600); |
|
|
g_signal_connect((*tabinfo)->text_buffer, "mark_set", G_CALLBACK(text_buffer_cursor_moved_handler), (*tabinfo)->text_view); |
|
|
/* タブを削除する際,デリートハンドラを削除しておかないと警告が出るから */ |
|
|
(*tabinfo)->delete_handler_id = g_signal_connect(Shiki_EDITOR_WINDOW, "delete_event", G_CALLBACK(delete_event_handler), (*tabinfo)->text_buffer); |
|
|
/* 様々な初期化処理 */ |
|
|
/* 括弧の強調表示のためのタグを作る */ |
|
|
gtk_text_buffer_create_tag ((*tabinfo)->text_buffer, "parent_emphasis_background", "background", "green", NULL); |
|
|
|
|
|
return GTK_WIDGET((*tabinfo)->tabpage); |
|
|
} |
|
|
|
|
| 439 |
/* ファイルを開く */ |
/* ファイルを開く */ |
| 440 |
static void open_file(GtkNotebook *notebook, gchar *filename) { |
static void open_file(GtkNotebook *notebook, gchar *filename) { |
| 441 |
gchar *contents, *text; |
gchar *contents, *text; |