Commit 383b7c95 authored by Jan Djärv's avatar Jan Djärv

Don't use deprecated functions when compiling with Gtk3.

* gtkutil.c (gtk_scrollbar_new, gtk_box_new): Define when HAVE_GTK3 is
not defined (Bug#11768).
(xg_create_frame_widgets): Use gtk_plug_new_for_display (Bug#11768).
(xg_create_frame_widgets, create_dialog, xg_get_file_with_chooser)
(make_widget_for_menu_item, xg_make_tool_item): Use gtk_box_new
followed by gtk_box_set_homogeneous (Bug#11768).
(xg_update_menu_item): Use GTK_IS_BOX (Bug#11768).
(update_theme_scrollbar_width, xg_create_scroll_bar): Use
gtk_scrollbar_new (Bug#11768).
(xg_event_is_for_scrollbar): Use Gdk Device functions for HAVE_GTK3.
(is_box_type): New function (Bug#11768).
(xg_tool_item_stale_p): Call is_box_type.
(xg_initialize): Get settings by calling gtk_settings_get_for_screen
with default display (Bug#11768).
parent ea2ac797
2012-07-05 Jan Djärv <jan.h.d@swipnet.se>
* gtkutil.c (gtk_scrollbar_new, gtk_box_new): Define when HAVE_GTK3 is
not defined (Bug#11768).
(xg_create_frame_widgets): Use gtk_plug_new_for_display (Bug#11768).
(xg_create_frame_widgets, create_dialog, xg_get_file_with_chooser)
(make_widget_for_menu_item, xg_make_tool_item): Use gtk_box_new
followed by gtk_box_set_homogeneous (Bug#11768).
(xg_update_menu_item): Use GTK_IS_BOX (Bug#11768).
(update_theme_scrollbar_width, xg_create_scroll_bar): Use
gtk_scrollbar_new (Bug#11768).
(xg_event_is_for_scrollbar): Use Gdk Device functions for HAVE_GTK3.
(is_box_type): New function (Bug#11768).
(xg_tool_item_stale_p): Call is_box_type.
(xg_initialize): Get settings by calling gtk_settings_get_for_screen
with default display (Bug#11768).
2012-07-05 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (window_hscroll_limited): New function.
......
......@@ -83,10 +83,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
gdk_window_get_geometry (w, a, b, c, d, 0)
#define gdk_x11_window_lookup_for_display(d, w) \
gdk_xid_table_lookup_for_display (d, w)
#define gtk_box_new(ori, spacing) \
((ori) == GTK_ORIENTATION_HORIZONTAL \
? gtk_hbox_new (FALSE, (spacing)) : gtk_vbox_new (FALSE, (spacing)))
#define gtk_scrollbar_new(ori, spacing) \
((ori) == GTK_ORIENTATION_HORIZONTAL \
? gtk_hscrollbar_new ((spacing)) : gtk_vscrollbar_new ((spacing)))
#ifndef GDK_KEY_g
#define GDK_KEY_g GDK_g
#endif
#endif
#endif /* HAVE_GTK3 */
#define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
......@@ -1097,7 +1103,10 @@ xg_create_frame_widgets (FRAME_PTR f)
BLOCK_INPUT;
if (FRAME_X_EMBEDDED_P (f))
wtop = gtk_plug_new (f->output_data.x->parent_desc);
{
GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
wtop = gtk_plug_new_for_display (gdpy, f->output_data.x->parent_desc);
}
else
wtop = gtk_window_new (GTK_WINDOW_TOPLEVEL);
......@@ -1111,8 +1120,10 @@ xg_create_frame_widgets (FRAME_PTR f)
xg_set_screen (wtop, f);
wvbox = gtk_vbox_new (FALSE, 0);
whbox = gtk_hbox_new (FALSE, 0);
wvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
whbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (wvbox), FALSE);
gtk_box_set_homogeneous (GTK_BOX (whbox), FALSE);
#ifdef HAVE_GTK3
wfixed = emacs_fixed_new (f);
......@@ -1487,9 +1498,12 @@ create_dialog (widget_value *wv,
if (make_two_rows)
{
GtkWidget *wvbox = gtk_vbox_new (TRUE, button_spacing);
GtkWidget *whbox_up = gtk_hbox_new (FALSE, 0);
whbox_down = gtk_hbox_new (FALSE, 0);
GtkWidget *wvbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, button_spacing);
GtkWidget *whbox_up = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (wvbox), TRUE);
gtk_box_set_homogeneous (GTK_BOX (whbox_up), FALSE);
whbox_down = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (whbox_down), FALSE);
gtk_box_pack_start (cur_box, wvbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (wvbox), whbox_up, FALSE, FALSE, 0);
......@@ -1777,7 +1791,8 @@ xg_get_file_with_chooser (FRAME_PTR f,
NULL);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filewin), TRUE);
wbox = gtk_vbox_new (FALSE, 0);
wbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous (GTK_BOX (wbox), FALSE);
gtk_widget_show (wbox);
wtoggle = gtk_check_button_new_with_label ("Show hidden files.");
......@@ -2189,7 +2204,8 @@ make_widget_for_menu_item (const char *utf8_label, const char *utf8_key)
GtkWidget *wkey;
GtkWidget *wbox;
wbox = gtk_hbox_new (FALSE, 0);
wbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (wbox), FALSE);
wlbl = gtk_label_new (utf8_label);
wkey = gtk_label_new (utf8_key);
......@@ -2846,7 +2862,7 @@ xg_update_menu_item (widget_value *val,
utf8_key = get_utf8_string (val->key);
/* See if W is a menu item with a key. See make_menu_item above. */
if (GTK_IS_HBOX (wchild))
if (GTK_IS_BOX (wchild))
{
GList *list = gtk_container_get_children (GTK_CONTAINER (wchild));
......@@ -3400,7 +3416,7 @@ update_theme_scrollbar_width (void)
int w = 0, b = 0;
vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1);
wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj));
wscroll = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT (vadj));
g_object_ref_sink (G_OBJECT (wscroll));
gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL);
gtk_widget_destroy (wscroll);
......@@ -3477,7 +3493,7 @@ xg_create_scroll_bar (FRAME_PTR f,
vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX,
0.1, 0.1, 0.1);
wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj));
wscroll = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT (vadj));
webox = gtk_event_box_new ();
gtk_widget_set_name (wscroll, scroll_bar_name);
#ifndef HAVE_GTK3
......@@ -3710,8 +3726,15 @@ xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event)
{
/* Check if press occurred outside the edit widget. */
GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
retval = gdk_display_get_window_at_pointer (gdpy, NULL, NULL)
!= gtk_widget_get_window (f->output_data.x->edit_widget);
GdkWindow *gwin;
#ifdef HAVE_GTK3
GdkDevice *gdev = gdk_device_manager_get_client_pointer
(gdk_display_get_device_manager (gdpy));
gdk_device_get_window_at_position (gdev, NULL, NULL);
#else
gwin = gdk_display_get_window_at_pointer (gdpy, NULL, NULL);
#endif
retval = gwin != gtk_widget_get_window (f->output_data.x->edit_widget);
}
else if (f
&& ((event->type == ButtonRelease && event->xbutton.button < 4)
......@@ -4232,11 +4255,16 @@ xg_make_tool_item (FRAME_PTR f,
int i, int horiz, int text_image)
{
GtkToolItem *ti = gtk_tool_item_new ();
GtkWidget *vb = horiz ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0);
GtkWidget *vb = gtk_box_new (horiz
? GTK_ORIENTATION_HORIZONTAL
: GTK_ORIENTATION_VERTICAL,
0);
GtkWidget *wb = gtk_button_new ();
/* The eventbox is here so we can have tooltips on disabled items. */
GtkWidget *weventbox = gtk_event_box_new ();
gtk_box_set_homogeneous (GTK_BOX (vb), FALSE);
if (wimage && !text_image)
gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
if (label)
......@@ -4303,6 +4331,24 @@ xg_make_tool_item (FRAME_PTR f,
return ti;
}
static int
is_box_type (GtkWidget *vb, int is_horizontal)
{
#ifdef HAVE_GTK3
int ret = 0;
if (GTK_IS_BOX (vb))
{
GtkOrientation ori = gtk_orientable_get_orientation (GTK_ORIENTABLE (vb));
ret = (ori == GTK_ORIENTATION_HORIZONTAL && is_horizontal)
|| (ori == GTK_ORIENTATION_VERTICAL && ! is_horizontal);
}
return ret;
#else
return is_horizontal ? GTK_IS_VBOX (vb) : GTK_IS_HBOX (vb);
#endif
}
static int
xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
const char *icon_name, const struct image *img,
......@@ -4331,14 +4377,14 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
else if (wimage)
{
gpointer gold_img = g_object_get_data (G_OBJECT (wimage),
XG_TOOL_BAR_IMAGE_DATA);
XG_TOOL_BAR_IMAGE_DATA);
Pixmap old_img = (Pixmap) gold_img;
if (old_img != img->pixmap)
return 1;
}
/* Check button configuration and label. */
if ((horiz ? GTK_IS_VBOX (vb) : GTK_IS_HBOX (vb))
if (is_box_type (vb, horiz)
|| (label ? (wlbl == NULL) : (wlbl != NULL)))
return 1;
......@@ -4715,6 +4761,7 @@ void
xg_initialize (void)
{
GtkBindingSet *binding_set;
GtkSettings *settings;
#if HAVE_XFT
/* Work around a bug with corrupted data if libXft gets unloaded. This way
......@@ -4731,17 +4778,19 @@ xg_initialize (void)
id_to_widget.max_size = id_to_widget.used = 0;
id_to_widget.widgets = 0;
settings = gtk_settings_get_for_screen (gdk_display_get_default_screen
(gdk_display_get_default ()));
/* Remove F10 as a menu accelerator, it does not mix well with Emacs key
bindings. It doesn't seem to be any way to remove properties,
so we set it to VoidSymbol which in X means "no key". */
gtk_settings_set_string_property (gtk_settings_get_default (),
gtk_settings_set_string_property (settings,
"gtk-menu-bar-accel",
"VoidSymbol",
EMACS_CLASS);
/* Make GTK text input widgets use Emacs style keybindings. This is
Emacs after all. */
gtk_settings_set_string_property (gtk_settings_get_default (),
gtk_settings_set_string_property (settings,
"gtk-key-theme-name",
"Emacs",
EMACS_CLASS);
......
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