Kaydet (Commit) 93f66de4 authored tarafından Enrico Tröger's avatar Enrico Tröger

Add MessageWindow::scribble and use it instead of searching the widget pointer everytime.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4499 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 16f67dc7
......@@ -12,6 +12,10 @@
* src/document.c:
When closing a document after it was deleted from the filesystem,
don't ask whether it should be saved first.
* src/keybindings.c, src/keyfile.c, src/main.c, src/msgwindow.c,
src/msgwindow.h, src/prefs.c:
Add MessageWindow::scribble and use it instead of searching the
widget pointer everytime.
2009-12-20 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
......
......@@ -1003,11 +1003,6 @@ static gboolean check_menu_key(GeanyDocument *doc, guint keyval, guint state, gu
if ((keyval == GDK_Menu && state == 0) || (keyval == GDK_F10 && state == GDK_SHIFT_MASK))
{
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
static GtkWidget *scribble = NULL;
if (scribble == NULL)
scribble = ui_lookup_widget(main_widgets.window, "textview_scribble");
if (doc != NULL)
{
if (focusw == doc->priv->tag_tree)
......@@ -1033,7 +1028,7 @@ static gboolean check_menu_key(GeanyDocument *doc, guint keyval, guint state, gu
|| focusw == msgwindow.tree_status
|| focusw == msgwindow.tree_compiler
|| focusw == msgwindow.tree_msg
|| focusw == scribble
|| focusw == msgwindow.scribble
#ifdef HAVE_VTE
|| (vte_info.have_vte && focusw == vc->vte)
#endif
......@@ -2399,14 +2394,11 @@ static gboolean cb_func_select_action(guint key_id)
GeanyDocument *doc;
ScintillaObject *sci;
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
static GtkWidget *scribble_widget = NULL;
/* special case for Select All in the scribble widget */
if (scribble_widget == NULL) /* lookup the scribble widget only once */
scribble_widget = ui_lookup_widget(main_widgets.window, "textview_scribble");
if (key_id == GEANY_KEYS_SELECT_ALL && focusw == scribble_widget)
if (key_id == GEANY_KEYS_SELECT_ALL && focusw == msgwindow.scribble)
{
g_signal_emit_by_name(scribble_widget, "select-all", TRUE);
g_signal_emit_by_name(msgwindow.scribble, "select-all", TRUE);
return TRUE;
}
......
......@@ -476,7 +476,7 @@ static void save_ui_prefs(GKeyFile *config)
GtkTextIter start, end, iter;
GtkTextMark *mark;
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui_lookup_widget(main_widgets.window, "textview_scribble")));
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(msgwindow.scribble));
gtk_text_buffer_get_bounds(buffer, &start, &end);
scribble_text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
g_key_file_set_string(config, PACKAGE, "scribble_text", scribble_text);
......@@ -1051,8 +1051,7 @@ void configuration_apply_settings(void)
{ /* update the scribble widget, because now it's realized */
GtkTextIter iter;
GtkTextBuffer *buffer =
gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui_lookup_widget(main_widgets.window,
"textview_scribble")));
gtk_text_view_get_buffer(GTK_TEXT_VIEW(msgwindow.scribble));
gtk_text_buffer_set_text(buffer, scribble_text, -1);
gtk_text_buffer_get_iter_at_offset(buffer, &iter, scribble_pos);
......
......@@ -1001,8 +1001,7 @@ gint main(gint argc, gchar **argv)
g_signal_connect(main_widgets.window, "delete-event", G_CALLBACK(on_exit_clicked), NULL);
g_signal_connect(main_widgets.window, "window-state-event", G_CALLBACK(on_window_state_event), NULL);
g_signal_connect(ui_lookup_widget(main_widgets.window, "textview_scribble"),
"motion-notify-event", G_CALLBACK(on_motion_event), NULL);
g_signal_connect(msgwindow.scribble, "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
#ifdef HAVE_VTE
vte_init();
......
......@@ -75,12 +75,13 @@ static gboolean on_msgwin_button_press_event(GtkWidget *widget, GdkEventButton *
static void on_scribble_populate(GtkTextView *textview, GtkMenu *arg1, gpointer user_data);
void msgwin_init()
void msgwin_init(void)
{
msgwindow.notebook = ui_lookup_widget(main_widgets.window, "notebook_info");
msgwindow.tree_status = ui_lookup_widget(main_widgets.window, "treeview3");
msgwindow.tree_msg = ui_lookup_widget(main_widgets.window, "treeview4");
msgwindow.tree_compiler = ui_lookup_widget(main_widgets.window, "treeview5");
msgwindow.scribble = ui_lookup_widget(main_widgets.window, "textview_scribble");
msgwindow.find_in_files_dir = NULL;
prepare_status_tree_view();
......@@ -90,15 +91,12 @@ void msgwin_init()
msgwindow.popup_msg_menu = create_message_popup_menu(MSG_MESSAGE);
msgwindow.popup_compiler_menu = create_message_popup_menu(MSG_COMPILER);
ui_widget_modify_font_from_string(
ui_lookup_widget(main_widgets.window, "textview_scribble"), interface_prefs.msgwin_font);
g_signal_connect(ui_lookup_widget(main_widgets.window, "textview_scribble"),
"populate-popup", G_CALLBACK(on_scribble_populate), NULL);
ui_widget_modify_font_from_string(msgwindow.scribble, interface_prefs.msgwin_font);
g_signal_connect(msgwindow.scribble, "populate-popup", G_CALLBACK(on_scribble_populate), NULL);
}
void msgwin_finalize()
void msgwin_finalize(void)
{
g_free(msgwindow.find_in_files_dir);
}
......@@ -629,7 +627,7 @@ static gboolean goto_compiler_file_line(const gchar *filename, gint line)
}
gboolean msgwin_goto_compiler_file_line()
gboolean msgwin_goto_compiler_file_line(void)
{
GtkTreeIter iter;
GtkTreeModel *model;
......@@ -942,7 +940,7 @@ void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir,
}
gboolean msgwin_goto_messages_file_line()
gboolean msgwin_goto_messages_file_line(void)
{
GtkTreeIter iter;
GtkTreeModel *model;
......@@ -1075,7 +1073,7 @@ void msgwin_switch_tab(gint tabnum, gboolean show)
switch (tabnum)
{
case MSG_SCRATCH: widget = ui_lookup_widget(main_widgets.window, "textview_scribble"); break;
case MSG_SCRATCH: widget = msgwindow.scribble; break;
case MSG_COMPILER: widget = msgwindow.tree_compiler; break;
case MSG_STATUS: widget = msgwindow.tree_status; break;
case MSG_MESSAGE: widget = msgwindow.tree_msg; break;
......
......@@ -64,6 +64,7 @@ typedef struct
GtkWidget *tree_compiler;
GtkWidget *tree_status;
GtkWidget *tree_msg;
GtkWidget *scribble;
GtkWidget *popup_status_menu;
GtkWidget *popup_msg_menu;
GtkWidget *popup_compiler_menu;
......
......@@ -1192,9 +1192,7 @@ static void on_prefs_font_choosed(GtkFontButton *widget, gpointer user_data)
ui_widget_modify_font_from_string(msgwindow.tree_compiler, interface_prefs.msgwin_font);
ui_widget_modify_font_from_string(msgwindow.tree_msg, interface_prefs.msgwin_font);
ui_widget_modify_font_from_string(msgwindow.tree_status, interface_prefs.msgwin_font);
ui_widget_modify_font_from_string(
ui_lookup_widget(main_widgets.window, "textview_scribble"),
interface_prefs.msgwin_font);
ui_widget_modify_font_from_string(msgwindow.scribble, interface_prefs.msgwin_font);
break;
}
case 3:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment