2010-04-13 21:13:52 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Rob Kendrick <rjek@netsurf-browser.org>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Compatibility functions for older GTK versions (interface)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NETSURF_GTK_COMPAT_H_
|
|
|
|
#define NETSURF_GTK_COMPAT_H_
|
|
|
|
|
2014-02-03 19:21:55 +04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2010-04-13 21:13:52 +04:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2015-04-09 00:21:30 +03:00
|
|
|
/* gtk 3.10 depricated the use of stock names */
|
|
|
|
#if GTK_CHECK_VERSION(3,10,0)
|
2015-04-11 02:28:32 +03:00
|
|
|
#define NSGTK_USE_ICON_NAME
|
|
|
|
#else
|
|
|
|
#undef NSGTK_USE_ICON_NAME
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* icon names instead of stock */
|
|
|
|
#ifdef NSGTK_USE_ICON_NAME
|
2015-04-09 00:21:30 +03:00
|
|
|
#define NSGTK_STOCK_ADD "list-add"
|
2015-04-11 02:28:32 +03:00
|
|
|
#define NSGTK_STOCK_CANCEL "_Cancel"
|
2015-04-09 00:21:30 +03:00
|
|
|
#define NSGTK_STOCK_CLEAR "edit-clear"
|
|
|
|
#define NSGTK_STOCK_CLOSE "window-close"
|
|
|
|
#define NSGTK_STOCK_FIND "edit-find"
|
|
|
|
#define NSGTK_STOCK_GO_BACK "go-previous"
|
|
|
|
#define NSGTK_STOCK_GO_FORWARD "go-next"
|
|
|
|
#define NSGTK_STOCK_HOME "go-home"
|
|
|
|
#define NSGTK_STOCK_INFO "dialog-information"
|
|
|
|
#define NSGTK_STOCK_REFRESH "view-refresh"
|
|
|
|
#define NSGTK_STOCK_SAVE "document-save"
|
|
|
|
#define NSGTK_STOCK_SAVE_AS "document-save-as"
|
|
|
|
#define NSGTK_STOCK_STOP "process-stop"
|
2015-04-11 02:28:32 +03:00
|
|
|
#define NSGTK_STOCK_OK "_OK"
|
|
|
|
#define NSGTK_STOCK_OPEN "_Open"
|
2015-04-09 00:21:30 +03:00
|
|
|
#else
|
|
|
|
#define NSGTK_STOCK_ADD GTK_STOCK_ADD
|
|
|
|
#define NSGTK_STOCK_CANCEL GTK_STOCK_CANCEL
|
|
|
|
#define NSGTK_STOCK_CLEAR GTK_STOCK_CLEAR
|
|
|
|
#define NSGTK_STOCK_CLOSE GTK_STOCK_CLOSE
|
|
|
|
#define NSGTK_STOCK_FIND GTK_STOCK_FIND
|
|
|
|
#define NSGTK_STOCK_GO_BACK GTK_STOCK_GO_BACK
|
|
|
|
#define NSGTK_STOCK_GO_FORWARD GTK_STOCK_GO_FORWARD
|
|
|
|
#define NSGTK_STOCK_HOME GTK_STOCK_HOME
|
|
|
|
#define NSGTK_STOCK_INFO GTK_STOCK_INFO
|
|
|
|
#define NSGTK_STOCK_REFRESH GTK_STOCK_REFRESH
|
|
|
|
#define NSGTK_STOCK_SAVE GTK_STOCK_SAVE
|
|
|
|
#define NSGTK_STOCK_SAVE_AS GTK_STOCK_SAVE_AS
|
|
|
|
#define NSGTK_STOCK_STOP GTK_STOCK_STOP
|
|
|
|
#define NSGTK_STOCK_OK GTK_STOCK_OK
|
|
|
|
#define NSGTK_STOCK_OPEN GTK_STOCK_OPEN
|
|
|
|
#endif
|
|
|
|
|
2015-04-11 17:20:52 +03:00
|
|
|
/* widget alignment only available since 3.0 */
|
|
|
|
#if !GTK_CHECK_VERSION(3,0,0)
|
|
|
|
typedef enum {
|
|
|
|
GTK_ALIGN_FILL,
|
|
|
|
GTK_ALIGN_START,
|
|
|
|
GTK_ALIGN_END,
|
|
|
|
GTK_ALIGN_CENTER,
|
|
|
|
GTK_ALIGN_BASELINE
|
|
|
|
} GtkAlign;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the alignment of a widget.
|
|
|
|
*
|
|
|
|
* sets both the horizontal and vertical alignement of a widget
|
|
|
|
*
|
|
|
|
* @note this type of alignemnt was not available prior to GTK 3.0 so
|
|
|
|
* we emulate it using gtk_misc_set_alignment.
|
|
|
|
*
|
|
|
|
* \param widget The widget to set alignent on.
|
|
|
|
* \param halign The horizontal alignment to set.
|
|
|
|
* \param valign The vertical alignment to set
|
|
|
|
*/
|
|
|
|
void nsgtk_widget_set_alignment(GtkWidget *widget, GtkAlign halign, GtkAlign valign);
|
|
|
|
|
2015-04-11 20:41:00 +03:00
|
|
|
/**
|
|
|
|
* Set the margins of a widget
|
|
|
|
*
|
|
|
|
* Sets the margin all round a widget.
|
|
|
|
*
|
|
|
|
* @note this type of margin was not available prior to GTK 3.0 so
|
|
|
|
* we emulate it using gtk_misc_set_padding.
|
|
|
|
*
|
|
|
|
* \param widget The widget to set alignent on.
|
|
|
|
* \param hmargin The horizontal margin.
|
|
|
|
* \param vmargin The vertical margin.
|
|
|
|
*/
|
|
|
|
void nsgtk_widget_set_margins(GtkWidget *widget, gint hmargin, gint vmargin);
|
|
|
|
|
2010-10-23 18:12:33 +04:00
|
|
|
void nsgtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
|
2010-04-13 21:13:52 +04:00
|
|
|
gboolean nsgtk_widget_has_focus(GtkWidget *widget);
|
|
|
|
gboolean nsgtk_widget_get_visible(GtkWidget *widget);
|
|
|
|
gboolean nsgtk_widget_get_realized(GtkWidget *widget);
|
|
|
|
gboolean nsgtk_widget_get_mapped(GtkWidget *widget);
|
|
|
|
gboolean nsgtk_widget_is_drawable(GtkWidget *widget);
|
2011-03-13 12:52:40 +03:00
|
|
|
void nsgtk_dialog_set_has_separator(GtkDialog *dialog, gboolean setting);
|
2011-06-07 21:23:39 +04:00
|
|
|
GtkWidget *nsgtk_combo_box_text_new(void);
|
|
|
|
void nsgtk_combo_box_text_append_text(GtkWidget *combo_box, const gchar *text);
|
|
|
|
gchar *nsgtk_combo_box_text_get_active_text(GtkWidget *combo_box);
|
2010-04-13 21:13:52 +04:00
|
|
|
|
2015-04-10 01:25:05 +03:00
|
|
|
/**
|
|
|
|
* creates a new image widget of an appropriate icon size from a pixbuf.
|
|
|
|
*
|
|
|
|
* \param pixbuf The pixbuf to use as a source.
|
|
|
|
* \param size The size of icon to create
|
|
|
|
* \return An image widget.
|
|
|
|
*/
|
|
|
|
GtkWidget *nsgtk_image_new_from_pixbuf_icon(GdkPixbuf *pixbuf, GtkIconSize size);
|
2015-04-09 13:41:06 +03:00
|
|
|
|
|
|
|
/* GTK prior to 2.16 needs the sexy interface for icons */
|
2011-12-31 03:22:18 +04:00
|
|
|
#if !GTK_CHECK_VERSION(2,16,0)
|
2015-04-09 13:41:06 +03:00
|
|
|
|
2011-12-31 03:22:18 +04:00
|
|
|
#include "gtk/sexy_icon_entry.h"
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GTK_ENTRY_ICON_PRIMARY = SEXY_ICON_ENTRY_PRIMARY,
|
|
|
|
GTK_ENTRY_ICON_SECONDARY = SEXY_ICON_ENTRY_SECONDARY
|
|
|
|
} GtkEntryIconPosition;
|
2015-04-09 13:41:06 +03:00
|
|
|
|
|
|
|
GtkStateType nsgtk_widget_get_state(GtkWidget *widget);
|
|
|
|
|
2011-12-31 03:22:18 +04:00
|
|
|
#endif
|
|
|
|
|
2012-05-16 23:57:43 +04:00
|
|
|
#if GTK_CHECK_VERSION (2, 90, 7)
|
|
|
|
#define GDK_KEY(symbol) GDK_KEY_##symbol
|
|
|
|
#else
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#define GDK_KEY(symbol) GDK_##symbol
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !GTK_CHECK_VERSION(3,0,0)
|
|
|
|
typedef GtkStateType GtkStateFlags;
|
|
|
|
typedef GtkStyle GtkStyleContext;
|
2013-06-28 16:20:05 +04:00
|
|
|
|
|
|
|
#if GTK_CHECK_VERSION(2,22,0)
|
|
|
|
enum {
|
|
|
|
GTK_IN_DESTRUCTION = 1 << 0,
|
|
|
|
};
|
|
|
|
#define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT (obj)->flags)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define gtk_widget_in_destruction(widget) \
|
|
|
|
(GTK_OBJECT_FLAGS(GTK_OBJECT(widget)) & GTK_IN_DESTRUCTION)
|
|
|
|
|
2012-05-16 23:57:43 +04:00
|
|
|
#endif
|
|
|
|
|
2015-04-09 16:10:14 +03:00
|
|
|
|
|
|
|
/**
|
2015-04-10 01:25:05 +03:00
|
|
|
* Sets the icon shown in the entry at the specified position from a
|
|
|
|
* stock image.
|
|
|
|
*
|
|
|
|
* Compatability interface for original deprecated in GTK 3.10
|
2015-04-09 16:10:14 +03:00
|
|
|
*
|
2015-04-12 23:42:33 +03:00
|
|
|
* \param entry The entry widget to set the icon on.
|
|
|
|
* \param icon_pos The position of the icon.
|
|
|
|
* \param stock_id the name of the stock item.
|
2015-04-09 16:10:14 +03:00
|
|
|
*/
|
2012-01-02 16:11:07 +04:00
|
|
|
void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
|
2015-04-09 00:21:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a GtkImage displaying a stock icon.
|
|
|
|
*
|
2015-04-10 01:25:05 +03:00
|
|
|
* Compatability interface for original deprecated in GTK 3.10
|
|
|
|
*
|
2015-04-12 23:42:33 +03:00
|
|
|
* \param stock_id the name of the stock item.
|
|
|
|
* \param size The size of icon to create.
|
|
|
|
* \return The created image widget or NULL on error
|
2015-04-09 00:21:30 +03:00
|
|
|
*/
|
|
|
|
GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
|
|
|
|
|
2015-04-10 01:25:05 +03:00
|
|
|
/**
|
|
|
|
* Creates a new GtkButton containing the image and text from a stock item.
|
|
|
|
*
|
|
|
|
* Compatability interface for original deprecated in GTK 3.10
|
|
|
|
*
|
|
|
|
* \param stock_id the name of the stock item
|
|
|
|
*/
|
|
|
|
GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id);
|
|
|
|
|
2015-04-10 02:06:48 +03:00
|
|
|
/**
|
|
|
|
* Fills item with the registered values for stock_id.
|
|
|
|
*
|
|
|
|
* Compatability interface for original deprecated in GTK 3.10
|
|
|
|
*
|
2015-04-12 23:42:33 +03:00
|
|
|
* \param stock_id the name of the stock item.
|
|
|
|
* \param item The structure to update if the stock_id was known.
|
2015-04-10 02:06:48 +03:00
|
|
|
* \return TRUE if stock_id was known.
|
|
|
|
*/
|
|
|
|
gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item);
|
|
|
|
|
2015-04-10 02:36:47 +03:00
|
|
|
void nsgtk_window_set_opacity(GtkWindow *window, gdouble opacity);
|
|
|
|
|
|
|
|
void nsgtk_scrolled_window_add_with_viewport(GtkScrolledWindow *window, GtkWidget *child);
|
|
|
|
|
2015-04-10 01:25:05 +03:00
|
|
|
GtkWidget *nsgtk_entry_new(void);
|
|
|
|
|
|
|
|
void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf);
|
|
|
|
|
2012-05-16 23:57:43 +04:00
|
|
|
void nsgtk_widget_override_background_color(GtkWidget *widget, GtkStateFlags state, uint16_t a, uint16_t r, uint16_t g, uint16_t b);
|
|
|
|
GtkWidget* nsgtk_hbox_new(gboolean homogeneous, gint spacing);
|
|
|
|
GtkWidget* nsgtk_vbox_new(gboolean homogeneous, gint spacing);
|
|
|
|
GtkStateFlags nsgtk_widget_get_state_flags(GtkWidget *widget);
|
|
|
|
GtkStyleContext* nsgtk_widget_get_style_context(GtkWidget *widget);
|
|
|
|
const PangoFontDescription* nsgtk_style_context_get_font(GtkStyleContext *style, GtkStateFlags state);
|
|
|
|
gulong nsgtk_connect_draw_event(GtkWidget *widget, GCallback callback, gpointer g);
|
|
|
|
void nsgdk_cursor_unref(GdkCursor *cursor);
|
|
|
|
void nsgtk_widget_modify_font(GtkWidget *widget, PangoFontDescription *font_desc);
|
2012-05-17 20:48:20 +04:00
|
|
|
GdkWindow *nsgtk_widget_get_window(GtkWidget *widget);
|
|
|
|
GtkWidget *nsgtk_dialog_get_content_area(GtkDialog *dialog);
|
|
|
|
gboolean nsgtk_show_uri(GdkScreen *screen, const gchar *uri, guint32 timestamp, GError **error);
|
|
|
|
GdkWindow *nsgtk_layout_get_bin_window(GtkLayout *layout);
|
|
|
|
void nsgtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation);
|
|
|
|
|
2015-04-10 18:39:23 +03:00
|
|
|
gboolean nsgtk_icon_size_lookup_for_settings (GtkSettings *settings, GtkIconSize size, gint *width, gint *height);
|
|
|
|
|
2012-05-17 20:48:20 +04:00
|
|
|
GtkAdjustment *nsgtk_layout_get_vadjustment(GtkLayout *layout);
|
|
|
|
GtkAdjustment *nsgtk_layout_get_hadjustment(GtkLayout *layout);
|
|
|
|
void nsgtk_layout_set_hadjustment(GtkLayout *layout, GtkAdjustment *adj);
|
|
|
|
void nsgtk_layout_set_vadjustment(GtkLayout *layout, GtkAdjustment *adj);
|
|
|
|
gdouble nsgtk_adjustment_get_step_increment(GtkAdjustment *adjustment);
|
|
|
|
gdouble nsgtk_adjustment_get_upper(GtkAdjustment *adjustment);
|
|
|
|
gdouble nsgtk_adjustment_get_lower(GtkAdjustment *adjustment);
|
|
|
|
gdouble nsgtk_adjustment_get_page_increment(GtkAdjustment *adjustment);
|
|
|
|
|
2015-04-10 18:20:55 +03:00
|
|
|
/* menu compatability */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new GtkImageMenuItem containing a label.
|
|
|
|
*
|
|
|
|
* Compatability interface for original deprecated in GTK 3.10.
|
|
|
|
* @note post 3.10 this creates a GtkMenuItem.
|
|
|
|
*
|
|
|
|
* \param label The text of the button, with an underscore in front of
|
|
|
|
* the mnemonic character.
|
|
|
|
* \return a new GtkMenuItem
|
|
|
|
*/
|
|
|
|
GtkWidget *nsgtk_image_menu_item_new_with_mnemonic(const gchar *label);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the image of image_menu_item to the given widget.
|
|
|
|
*
|
|
|
|
* Compatability interface for original deprecated in GTK 3.10.
|
|
|
|
* @note post 3.10 this is empty as menu creation generates GtkMenuItem.
|
|
|
|
*
|
|
|
|
* \param image_menu_item The image menu entry item.
|
|
|
|
* \param image The image to set.
|
|
|
|
*/
|
|
|
|
void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *image);
|
2012-01-02 16:11:07 +04:00
|
|
|
|
2010-04-13 21:13:52 +04:00
|
|
|
#endif /* NETSURF_GTK_COMPAT_H */
|