summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-11 19:01:06 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-11 19:01:06 +0200
commita3f41662865d5a0582c4ccd22a38317907b59154 (patch)
tree3960311239d33ba11640a1b99576a8b9deffe6d6 /src
parentcabf20199ae4c645c07d7f2a765b3b13b66d56a8 (diff)
downloadvim-a3f41662865d5a0582c4ccd22a38317907b59154.zip
Avoid use of the GTK mail_loop() so that the GtkFileChooser can be used.
(James Vega)
Diffstat (limited to 'src')
-rw-r--r--src/gui_gtk.c29
-rw-r--r--src/gui_gtk_x11.c62
2 files changed, 11 insertions, 80 deletions
diff --git a/src/gui_gtk.c b/src/gui_gtk.c
index 52d75e4a2..1533c647c 100644
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -420,10 +420,6 @@ gui_mch_add_menu(vimmenu_T *menu, int idx)
menu_item_activate(GtkWidget *widget UNUSED, gpointer data)
{
gui_menu_cb((vimmenu_T *)data);
-
- /* make sure the menu action is taken immediately */
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
void
@@ -731,9 +727,6 @@ adjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
}
gui_drag_scrollbar(sb, value, dragging);
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
/* SBAR_VERT or SBAR_HORIZ */
@@ -780,10 +773,7 @@ gui_mch_destroy_scrollbar(scrollbar_T *sb)
* Implementation of the file selector related stuff
*/
#if GTK_CHECK_VERSION(2,4,0)
-/* This has been disabled, because the GTK library rewrites
- * ~/.recently-used.xbel every time the main loop is quit. For Vim that means
- * on just about any event. */
-/* # define USE_FILE_CHOOSER */
+# define USE_FILE_CHOOSER
#endif
#ifndef USE_FILE_CHOOSER
@@ -798,8 +788,6 @@ browse_ok_cb(GtkWidget *widget UNUSED, gpointer cbdata)
vw->browse_fname = (char_u *)g_strdup(gtk_file_selection_get_filename(
GTK_FILE_SELECTION(vw->filedlg)));
gtk_widget_hide(vw->filedlg);
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
static void
@@ -813,8 +801,6 @@ browse_cancel_cb(GtkWidget *widget UNUSED, gpointer cbdata)
vw->browse_fname = NULL;
}
gtk_widget_hide(vw->filedlg);
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
static gboolean
@@ -826,10 +812,7 @@ browse_destroy_cb(GtkWidget *widget UNUSED)
gui.browse_fname = NULL;
}
gui.filedlg = NULL;
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
+ gtk_main_quit();
return FALSE;
}
#endif
@@ -882,6 +865,8 @@ gui_mch_browse(int saving UNUSED,
NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
(const gchar *)dirbuf);
+ if (saving && dflt != NULL && *dflt != NUL)
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt);
gui.browse_fname = NULL;
if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT)
@@ -929,8 +914,7 @@ gui_mch_browse(int saving UNUSED,
(const gchar *)dirbuf);
gtk_widget_show(gui.filedlg);
- while (gui.filedlg && GTK_WIDGET_DRAWABLE(gui.filedlg))
- gtk_main_iteration_do(TRUE);
+ gtk_main();
#endif
CONVERT_TO_UTF8_FREE(title);
@@ -1840,9 +1824,6 @@ find_replace_cb(GtkWidget *widget UNUSED, gpointer data)
rc = gui_do_findrepl(flags, find_text, repl_text, direction_down);
CONVERT_FROM_UTF8_FREE(repl_text);
CONVERT_FROM_UTF8_FREE(find_text);
-
- if (rc && gtk_main_level() > 0)
- gtk_main_quit(); /* make sure cmd will be handled immediately */
}
/* our usual callback function */
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 84aa710c0..05cbe0b4d 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -652,9 +652,6 @@ property_event(GtkWidget *widget,
xev.xproperty.window = commWindow;
xev.xproperty.state = PropertyNewValue;
serverEventProc(GDK_WINDOW_XDISPLAY(widget->window), &xev);
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
return FALSE;
}
@@ -788,10 +785,6 @@ focus_in_event(GtkWidget *widget,
if (widget != gui.drawarea)
gtk_widget_grab_focus(gui.drawarea);
- /* make sure the input buffer is read */
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
return TRUE;
}
@@ -805,10 +798,6 @@ focus_out_event(GtkWidget *widget UNUSED,
if (blink_state != BLINK_NONE)
gui_mch_stop_blink();
- /* make sure the input buffer is read */
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
return TRUE;
}
@@ -1130,9 +1119,6 @@ key_press_event(GtkWidget *widget UNUSED,
if (p_mh)
gui_mch_mousehide(TRUE);
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
return TRUE;
}
@@ -1167,9 +1153,6 @@ selection_clear_event(GtkWidget *widget UNUSED,
else
clip_lose_selection(&clip_star);
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
return TRUE;
}
@@ -1205,9 +1188,6 @@ selection_received_cb(GtkWidget *widget UNUSED,
received_selection = RS_FAIL;
/* clip_free_selection(cbd); ??? */
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
return;
}
@@ -1287,9 +1267,6 @@ selection_received_cb(GtkWidget *widget UNUSED,
received_selection = RS_OK;
vim_free(tmpbuf);
g_free(tmpbuf_utf8);
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
/*
@@ -1515,9 +1492,6 @@ process_motion_notify(int x, int y, GdkModifierType state)
/* inform the editor engine about the occurrence of this event */
gui_send_mouse_event(button, x, y, FALSE, vim_modifiers);
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
/*
* Auto repeat timer handling.
*/
@@ -1700,8 +1674,6 @@ button_press_event(GtkWidget *widget,
vim_modifiers = modifiers_gdk2mouse(event->state);
gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers);
- if (gtk_main_level() > 0)
- gtk_main_quit(); /* make sure the above will be handled immediately */
return TRUE;
}
@@ -1743,9 +1715,6 @@ scroll_event(GtkWidget *widget,
gui_send_mouse_event(button, (int)event->x, (int)event->y,
FALSE, vim_modifiers);
- if (gtk_main_level() > 0)
- gtk_main_quit(); /* make sure the above will be handled immediately */
-
return TRUE;
}
@@ -1775,8 +1744,6 @@ button_release_event(GtkWidget *widget UNUSED,
vim_modifiers = modifiers_gdk2mouse(event->state);
gui_send_mouse_event(MOUSE_RELEASE, x, y, FALSE, vim_modifiers);
- if (gtk_main_level() > 0)
- gtk_main_quit(); /* make sure it will be handled immediately */
return TRUE;
}
@@ -1930,9 +1897,6 @@ drag_handle_text(GdkDragContext *context,
add_to_input_buf(dropkey, (int)sizeof(dropkey));
else
add_to_input_buf(dropkey + 3, (int)(sizeof(dropkey) - 3));
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
/*
@@ -2846,9 +2810,6 @@ tabline_menu_handler(GtkMenuItem *item UNUSED, gpointer user_data)
{
/* Add the string cmd into input buffer */
send_tabline_menu_event(clicked_page, (int)(long)user_data);
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
static void
@@ -2924,8 +2885,7 @@ on_tabline_menu(GtkWidget *widget, GdkEvent *event)
{
/* Click after all tabs moves to next tab page. When "x" is
* small guess it's the left button. */
- if (send_tabline_event(x < 50 ? -1 : 0) && gtk_main_level() > 0)
- gtk_main_quit();
+ send_tabline_event(x < 50 ? -1 : 0);
}
}
}
@@ -2946,8 +2906,7 @@ on_select_tab(
{
if (!ignore_tabline_evt)
{
- if (send_tabline_event(idx + 1) && gtk_main_level() > 0)
- gtk_main_quit();
+ send_tabline_event(idx + 1);
}
}
@@ -3855,9 +3814,6 @@ gui_mch_exit(int rc UNUSED)
{
if (gui.mainwin != NULL)
gtk_widget_destroy(gui.mainwin);
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
/*
@@ -5407,8 +5363,8 @@ gui_mch_draw_part_cursor(int w, int h, guicolor_T color)
void
gui_mch_update(void)
{
- while (gtk_events_pending() && !vim_is_input_buf_full())
- gtk_main_iteration_do(FALSE);
+ while (g_main_context_pending(NULL) && !vim_is_input_buf_full())
+ g_main_context_iteration(NULL, TRUE);
}
static gint
@@ -5419,9 +5375,6 @@ input_timer_cb(gpointer data)
/* Just inform the caller about the occurrence of it */
*timed_out = TRUE;
- if (gtk_main_level() > 0)
- gtk_main_quit();
-
return FALSE; /* don't happen again */
}
@@ -5438,9 +5391,6 @@ sniff_request_cb(
static char_u bytes[3] = {CSI, (int)KS_EXTRA, (int)KE_SNIFF};
add_to_input_buf(bytes, 3);
-
- if (gtk_main_level() > 0)
- gtk_main_quit();
}
#endif
@@ -5515,7 +5465,7 @@ gui_mch_wait_for_chars(long wtime)
* situations, sort of race condition).
*/
if (!input_available())
- gtk_main();
+ g_main_context_iteration(NULL, TRUE);
/* Got char, return immediately */
if (input_available())
@@ -5707,7 +5657,7 @@ clip_mch_request_selection(VimClipboard *cbd)
* during the FocusGained event. */
start = time(NULL);
while (received_selection == RS_NONE && time(NULL) < start + 3)
- gtk_main(); /* wait for selection_received_cb */
+ g_main_context_iteration(NULL, TRUE); /* wait for selection_received_cb */
if (received_selection != RS_FAIL)
return;