You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
675 lines
23 KiB
675 lines
23 KiB
/*
|
|
* 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_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
/* gtk 3.10 depricated the use of stock names */
|
|
#if GTK_CHECK_VERSION(3,10,0)
|
|
#define NSGTK_USE_ICON_NAME
|
|
#else
|
|
#undef NSGTK_USE_ICON_NAME
|
|
#endif
|
|
|
|
/* icon names instead of stock */
|
|
#ifdef NSGTK_USE_ICON_NAME
|
|
#define NSGTK_STOCK_ADD "list-add"
|
|
#define NSGTK_STOCK_CANCEL "_Cancel"
|
|
#define NSGTK_STOCK_CLEAR "edit-clear"
|
|
#define NSGTK_STOCK_CLOSE "window-close"
|
|
#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"
|
|
#define NSGTK_STOCK_OK "_OK"
|
|
#define NSGTK_STOCK_OPEN "_Open"
|
|
#define NSGTK_STOCK_OPEN_MENU "open-menu"
|
|
#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_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
|
|
#define NSGTK_STOCK_OPEN_MENU GTK_STOCK_JUSTIFY_FILL
|
|
#endif
|
|
|
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
/* widget alignment only available since 3.0 */
|
|
#else
|
|
typedef enum {
|
|
GTK_ALIGN_FILL,
|
|
GTK_ALIGN_START,
|
|
GTK_ALIGN_END,
|
|
GTK_ALIGN_CENTER,
|
|
GTK_ALIGN_BASELINE
|
|
} GtkAlign;
|
|
#endif
|
|
|
|
/* value init since gtk 2.30 */
|
|
#ifndef G_VALUE_INIT
|
|
#define G_VALUE_INIT { 0, { { 0 } } }
|
|
#endif
|
|
|
|
|
|
#if GTK_CHECK_VERSION(4,0,0)
|
|
/* TODO: this is mostly rubbish just to see how big a pile of fail it really is */
|
|
|
|
/*
|
|
the GTK 4 API has removed 80 interfaces
|
|
The highlights are:
|
|
- removal of main event loop
|
|
- removal of all the gdk events
|
|
- removal of all menus!
|
|
- removal of toolbar and all its sub widgets
|
|
- removal of numerous widgets including container, bin and layout
|
|
- removal of acelerators
|
|
- removal various window and widget methods including widget delete?!?
|
|
*/
|
|
|
|
/* GDK first */
|
|
typedef GdkSurface GdkWindow;
|
|
typedef int GdkWindowTypeHint;
|
|
typedef void GdkScreen;
|
|
typedef void GdkEventFocus;
|
|
typedef int GdkAtom;
|
|
typedef struct {uint keyval; int state;} GdkEventKey;
|
|
typedef struct {int type;int button; int state;int x;int y;} GdkEventButton;
|
|
typedef struct {int state;int x;int y;} GdkEventMotion;
|
|
typedef struct {int direction;int x;int y;} GdkEventScroll;
|
|
typedef enum
|
|
{
|
|
GDK_X_CURSOR = 0,
|
|
GDK_ARROW = 2,
|
|
GDK_BASED_ARROW_DOWN = 4,
|
|
GDK_BASED_ARROW_UP = 6,
|
|
GDK_BOAT = 8,
|
|
GDK_BOGOSITY = 10,
|
|
GDK_BOTTOM_LEFT_CORNER = 12,
|
|
GDK_BOTTOM_RIGHT_CORNER = 14,
|
|
GDK_BOTTOM_SIDE = 16,
|
|
GDK_BOTTOM_TEE = 18,
|
|
GDK_BOX_SPIRAL = 20,
|
|
GDK_CENTER_PTR = 22,
|
|
GDK_CIRCLE = 24,
|
|
GDK_CLOCK = 26,
|
|
GDK_COFFEE_MUG = 28,
|
|
GDK_CROSS = 30,
|
|
GDK_CROSS_REVERSE = 32,
|
|
GDK_CROSSHAIR = 34,
|
|
GDK_DIAMOND_CROSS = 36,
|
|
GDK_DOT = 38,
|
|
GDK_DOTBOX = 40,
|
|
GDK_DOUBLE_ARROW = 42,
|
|
GDK_DRAFT_LARGE = 44,
|
|
GDK_DRAFT_SMALL = 46,
|
|
GDK_DRAPED_BOX = 48,
|
|
GDK_EXCHANGE = 50,
|
|
GDK_FLEUR = 52,
|
|
GDK_GOBBLER = 54,
|
|
GDK_GUMBY = 56,
|
|
GDK_HAND1 = 58,
|
|
GDK_HAND2 = 60,
|
|
GDK_HEART = 62,
|
|
GDK_ICON = 64,
|
|
GDK_IRON_CROSS = 66,
|
|
GDK_LEFT_PTR = 68,
|
|
GDK_LEFT_SIDE = 70,
|
|
GDK_LEFT_TEE = 72,
|
|
GDK_LEFTBUTTON = 74,
|
|
GDK_LL_ANGLE = 76,
|
|
GDK_LR_ANGLE = 78,
|
|
GDK_MAN = 80,
|
|
GDK_MIDDLEBUTTON = 82,
|
|
GDK_MOUSE = 84,
|
|
GDK_PENCIL = 86,
|
|
GDK_PIRATE = 88,
|
|
GDK_PLUS = 90,
|
|
GDK_QUESTION_ARROW = 92,
|
|
GDK_RIGHT_PTR = 94,
|
|
GDK_RIGHT_SIDE = 96,
|
|
GDK_RIGHT_TEE = 98,
|
|
GDK_RIGHTBUTTON = 100,
|
|
GDK_RTL_LOGO = 102,
|
|
GDK_SAILBOAT = 104,
|
|
GDK_SB_DOWN_ARROW = 106,
|
|
GDK_SB_H_DOUBLE_ARROW = 108,
|
|
GDK_SB_LEFT_ARROW = 110,
|
|
GDK_SB_RIGHT_ARROW = 112,
|
|
GDK_SB_UP_ARROW = 114,
|
|
GDK_SB_V_DOUBLE_ARROW = 116,
|
|
GDK_SHUTTLE = 118,
|
|
GDK_SIZING = 120,
|
|
GDK_SPIDER = 122,
|
|
GDK_SPRAYCAN = 124,
|
|
GDK_STAR = 126,
|
|
GDK_TARGET = 128,
|
|
GDK_TCROSS = 130,
|
|
GDK_TOP_LEFT_ARROW = 132,
|
|
GDK_TOP_LEFT_CORNER = 134,
|
|
GDK_TOP_RIGHT_CORNER = 136,
|
|
GDK_TOP_SIDE = 138,
|
|
GDK_TOP_TEE = 140,
|
|
GDK_TREK = 142,
|
|
GDK_UL_ANGLE = 144,
|
|
GDK_UMBRELLA = 146,
|
|
GDK_UR_ANGLE = 148,
|
|
GDK_WATCH = 150,
|
|
GDK_XTERM = 152,
|
|
GDK_LAST_CURSOR,
|
|
GDK_CURSOR_IS_PIXMAP = -1
|
|
} GdkCursorType;
|
|
typedef enum
|
|
{
|
|
GDK_EXPOSURE_MASK = 1 << 1,
|
|
GDK_POINTER_MOTION_MASK = 1 << 2,
|
|
GDK_POINTER_MOTION_HINT_MASK = 1 << 3,
|
|
GDK_BUTTON_MOTION_MASK = 1 << 4,
|
|
GDK_BUTTON1_MOTION_MASK = 1 << 5,
|
|
GDK_BUTTON2_MOTION_MASK = 1 << 6,
|
|
GDK_BUTTON3_MOTION_MASK = 1 << 7,
|
|
GDK_BUTTON_PRESS_MASK = 1 << 8,
|
|
GDK_BUTTON_RELEASE_MASK = 1 << 9,
|
|
GDK_KEY_PRESS_MASK = 1 << 10,
|
|
GDK_KEY_RELEASE_MASK = 1 << 11,
|
|
GDK_ENTER_NOTIFY_MASK = 1 << 12,
|
|
GDK_LEAVE_NOTIFY_MASK = 1 << 13,
|
|
GDK_FOCUS_CHANGE_MASK = 1 << 14,
|
|
GDK_STRUCTURE_MASK = 1 << 15,
|
|
GDK_PROPERTY_CHANGE_MASK = 1 << 16,
|
|
GDK_VISIBILITY_NOTIFY_MASK = 1 << 17,
|
|
GDK_PROXIMITY_IN_MASK = 1 << 18,
|
|
GDK_PROXIMITY_OUT_MASK = 1 << 19,
|
|
GDK_SUBSTRUCTURE_MASK = 1 << 20,
|
|
GDK_SCROLL_MASK = 1 << 21,
|
|
GDK_TOUCH_MASK = 1 << 22,
|
|
GDK_SMOOTH_SCROLL_MASK = 1 << 23,
|
|
GDK_TOUCHPAD_GESTURE_MASK = 1 << 24,
|
|
GDK_TABLET_PAD_MASK = 1 << 25,
|
|
GDK_ALL_EVENTS_MASK = 0x3FFFFFE
|
|
} GdkEventMask;
|
|
typedef enum
|
|
{
|
|
GDK_DESTROY = 1,
|
|
GDK_2BUTTON_PRESS = 5,
|
|
GDK_3BUTTON_PRESS = 6,
|
|
} NSGdkEventType;
|
|
|
|
GdkScreen* gdk_screen_get_default(void);
|
|
gdouble gdk_screen_get_resolution(GdkScreen* screen);
|
|
PangoContext* gdk_pango_context_get(void);
|
|
GdkCursor* gdk_cursor_new_from_pixbuf(GdkDisplay* display, GdkPixbuf* pixbuf, gint x, gint y);
|
|
gboolean gdk_event_get_scroll_deltas(const GdkEvent* event, gdouble* delta_x, gdouble* delta_y);
|
|
|
|
/* GTK next */
|
|
typedef GtkFixed GtkLayout; /* GTK4 removed layout widget, substitute with GtkFixed */
|
|
#define GTK_LAYOUT GTK_FIXED
|
|
typedef void GtkMenuItem;
|
|
typedef void GtkMenu;
|
|
typedef void GtkMenuBar;
|
|
typedef void GtkMenuShell;
|
|
typedef void GtkCheckMenuItem;
|
|
typedef void GtkAccelGroup;
|
|
typedef void GtkClipboard;
|
|
typedef GtkBox GtkToolbar;
|
|
typedef void GtkToolButton;
|
|
typedef void GtkStyle;
|
|
typedef void GtkToolItem;
|
|
typedef void GdkDragContext;
|
|
typedef void GtkSelectionData;
|
|
typedef GtkWidget GtkContainer;
|
|
typedef void GtkBin;
|
|
typedef int GtkReliefStyle;
|
|
typedef struct GtkTargetEntry {
|
|
gchar* target;
|
|
guint flags;
|
|
guint info;
|
|
} GtkTargetEntry;
|
|
typedef int GtkAccelFlags;
|
|
typedef int GtkDestDefaults;
|
|
typedef void(* GtkCallback) (GtkWidget* widget, gpointer data);
|
|
|
|
#define GTK_RELIEF_NONE 0
|
|
#define GDK_MOD1_MASK 0
|
|
typedef enum {
|
|
GTK_ICON_SIZE_INVALID=0,
|
|
GTK_ICON_SIZE_MENU=1,
|
|
GTK_ICON_SIZE_SMALL_TOOLBAR=2,
|
|
GTK_ICON_SIZE_LARGE_TOOLBAR=3,
|
|
GTK_ICON_SIZE_BUTTON=4,
|
|
GTK_ICON_SIZE_DND=5,
|
|
GTK_ICON_SIZE_DIALOG=6,
|
|
} NSGtkIconSize;
|
|
typedef enum {
|
|
GTK_TOOLBAR_ICONS=0,
|
|
GTK_TOOLBAR_TEXT=1,
|
|
GTK_TOOLBAR_BOTH=2,
|
|
GTK_TOOLBAR_BOTH_HORIZ=3,
|
|
} GtkToolbarStyle;
|
|
#define GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU 0
|
|
#define GTK_ACCEL_VISIBLE 0
|
|
#define GDK_SELECTION_CLIPBOARD 0
|
|
#define GTK_TARGET_SAME_APP 0
|
|
#define GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER 0
|
|
#define GTK_DEST_DEFAULT_MOTION 0
|
|
#define GTK_DEST_DEFAULT_DROP 0
|
|
#define GDK_WINDOW_STATE_FULLSCREEN 0
|
|
|
|
#define GTK_BIN(x) x
|
|
#define GTK_CONTAINER(x) x
|
|
|
|
#define GTK_MENU(x) x
|
|
#define GTK_MENU_BAR(x) x
|
|
#define GTK_MENU_ITEM(x) x
|
|
#define GTK_MENU_SHELL(x) x
|
|
#define GTK_CHECK_MENU_ITEM(x) x
|
|
|
|
#define GTK_TOOLBAR(x) x
|
|
#define GTK_TOOL_BUTTON(x) x
|
|
#define GTK_TOOL_ITEM(x) x
|
|
|
|
gboolean gtk_main_iteration_do(gboolean blocking);
|
|
gboolean gtk_main_iteration(void);
|
|
|
|
void gtk_window_set_default_icon(GdkPixbuf* icon);
|
|
void gtk_window_set_type_hint(GtkWindow* window, GdkWindowTypeHint hint);
|
|
void gtk_window_set_screen(GtkWindow* window, GdkScreen* screen);
|
|
void gtk_window_get_size(GtkWindow* window, gint* width, gint* height);
|
|
void gtk_window_resize(GtkWindow* window, gint width, gint height);
|
|
void gtk_window_move(GtkWindow* window, gint x, gint y);
|
|
void gtk_window_get_position(GtkWindow* window, gint* root_x, gint* root_y);
|
|
void gtk_window_add_accel_group(GtkWindow* window, GtkAccelGroup* accel_group);
|
|
|
|
void gtk_widget_show_all(GtkWidget *widget);
|
|
void gtk_widget_destroy(GtkWidget* widget);
|
|
void gtk_widget_set_events(GtkWidget* widget, gint events);
|
|
void gtk_widget_add_events(GtkWidget* widget, gint events );
|
|
void gtk_widget_set_allocation(GtkWidget* widget, const GtkAllocation* allocation);
|
|
GdkWindow* gtk_widget_get_parent_window(GtkWidget* widget);
|
|
GtkWidget* gtk_widget_get_toplevel(GtkWidget* widget);
|
|
GdkScreen* gtk_widget_get_screen(GtkWidget* widget);
|
|
void gtk_widget_add_accelerator(GtkWidget* widget, const gchar* accel_signal, GtkAccelGroup* accel_group, guint accel_key, GdkModifierType accel_mods, GtkAccelFlags accel_flags);
|
|
void gtk_widget_queue_draw_area(GtkWidget* widget, gint x, gint y, gint width, gint height);
|
|
|
|
GtkWidget* gtk_menu_new(void);
|
|
void gtk_menu_shell_append(GtkMenuShell* menu_shell, GtkWidget* child);
|
|
void gtk_menu_item_set_submenu(GtkMenuItem* menu_item, GtkWidget* submenu);
|
|
GtkWidget*gtk_menu_item_new_with_mnemonic(const gchar* label);
|
|
void gtk_menu_popup_at_pointer(GtkMenu* menu, const GdkEvent* trigger_event);
|
|
void gtk_menu_set_accel_group (GtkMenu *menu, GtkAccelGroup *accel_group);
|
|
|
|
GtkWidget* gtk_check_menu_item_new_with_label(const gchar* label);
|
|
void gtk_check_menu_item_set_active(GtkCheckMenuItem* check_menu_item, gboolean is_active);
|
|
gboolean gtk_check_menu_item_get_active(GtkCheckMenuItem* check_menu_item);
|
|
GtkWidget* gtk_separator_menu_item_new(void);
|
|
GtkWidget* gtk_check_menu_item_new_with_mnemonic(const gchar* label);
|
|
|
|
GtkWidget* gtk_toolbar_new(void);
|
|
void gtk_toolbar_set_icon_size(GtkToolbar* toolbar, GtkIconSize icon_size);
|
|
void gtk_toolbar_set_style(GtkToolbar* toolbar, GtkToolbarStyle style);
|
|
void gtk_toolbar_set_show_arrow(GtkToolbar* toolbar, gboolean show_arrow);
|
|
gint gtk_toolbar_get_drop_index(GtkToolbar* toolbar, gint x, gint y);
|
|
void gtk_toolbar_insert(GtkToolbar* toolbar, GtkToolItem* item, gint pos);
|
|
void gtk_toolbar_set_drop_highlight_item(GtkToolbar* toolbar, GtkToolItem* tool_item, gint index_);
|
|
GtkToolItem* gtk_tool_button_new(GtkWidget* icon_widget, const gchar* label);
|
|
GtkToolItem* gtk_tool_item_new(void);
|
|
void gtk_tool_button_set_icon_widget(GtkToolButton* button, GtkWidget* icon_widget);
|
|
void gtk_tool_item_set_expand(GtkToolItem *tool_item, gboolean expand);
|
|
void gtk_tool_button_set_icon_name(GtkToolButton* button, const gchar* icon_name);
|
|
void gtk_tool_item_set_use_drag_window(GtkToolItem *tool_item, gboolean use_drag_window);
|
|
void gtk_tool_button_set_label(GtkToolButton *button, const gchar *label);
|
|
|
|
void gtk_container_add(GtkContainer* container, GtkWidget* widget);
|
|
void gtk_container_remove(GtkContainer* container, GtkWidget* widget);
|
|
void gtk_container_foreach(GtkContainer* container, GtkCallback callback, gpointer callback_data);
|
|
|
|
gint gtk_dialog_run(GtkDialog* dialog);
|
|
|
|
void gtk_editable_cut_clipboard(GtkEditable* editable);
|
|
void gtk_editable_copy_clipboard(GtkEditable* editable);
|
|
void gtk_editable_paste_clipboard(GtkEditable *editable);
|
|
|
|
GtkClipboard*gtk_clipboard_get(GdkAtom selection);
|
|
void gtk_clipboard_set_text(GtkClipboard* clipboard, const gchar* text, gint len);
|
|
gchar* gtk_clipboard_wait_for_text(GtkClipboard* clipboard);
|
|
|
|
void gtk_entry_set_text (GtkEntry* entry, const gchar* text );
|
|
void gtk_entry_set_width_chars(GtkEntry* entry,gint n_chars);
|
|
const gchar* gtk_entry_get_text(GtkEntry* entry);
|
|
|
|
void gtk_drag_source_set(GtkWidget* widget, GdkModifierType start_button_mask, const GtkTargetEntry* targets, gint n_targets, GdkDragAction actions);
|
|
void gtk_drag_finish(GdkDragContext* context, gboolean success, gboolean del, guint32 time_);
|
|
void gtk_drag_dest_set(GtkWidget* widget, GtkDestDefaults flags, const GtkTargetEntry* targets, gint n_targets, GdkDragAction actions);
|
|
|
|
void gtk_box_pack_start(GtkBox* box, GtkWidget* child, gboolean expand, gboolean fill, guint padding);
|
|
void gtk_label_set_line_wrap(GtkLabel* label, gboolean wrap);
|
|
gboolean gtk_show_uri_on_window(GtkWindow* parent, const char* uri, guint32 timestamp, GError** error);
|
|
gboolean gtk_icon_size_lookup (GtkIconSize size, gint* width, gint* height);
|
|
void gtk_builder_connect_signals(GtkBuilder* builder, gpointer user_data);
|
|
void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window);
|
|
void gtk_file_chooser_set_do_overwrite_confirmation(GtkFileChooser* chooser, gboolean do_overwrite_confirmation);
|
|
gchar* gtk_file_chooser_get_filename(GtkFileChooser* chooser);
|
|
void gtk_button_set_image(GtkButton* button, GtkWidget* image);
|
|
GtkIconTheme* gtk_icon_theme_get_default(void);
|
|
gboolean gtk_events_pending(void);
|
|
GtkWidget* gtk_event_box_new(void);
|
|
GtkWidget* gtk_bin_get_child(GtkBin* bin);
|
|
void gtk_button_set_relief(GtkButton* button, GtkReliefStyle relief);
|
|
GtkAccelGroup* gtk_accel_group_new(void);
|
|
void gtk_layout_set_size(GtkLayout* layout, guint width, guint height);
|
|
GdkCursor* gdk_cursor_new_for_display(GdkDisplay* display, GdkCursorType cursor_type);
|
|
|
|
|
|
#endif
|
|
|
|
void nsgtk_widget_size_allocate(GtkWidget* widget, const GtkAllocation* allocation, int baseline);
|
|
|
|
/**
|
|
* Adds child to box, packed with reference to the start of box.
|
|
* The child is packed after any other child packed with reference to the start
|
|
* of box.
|
|
*/
|
|
void nsgtk_box_pack_start(GtkBox* box, GtkWidget* child, gboolean expand, gboolean fill, guint padding);
|
|
|
|
/**
|
|
* Gets the value set by gtk_window_set_default_icon_list()
|
|
*/
|
|
GList *nsgtk_window_get_default_icon_list(void);
|
|
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
void nsgtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
|
|
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);
|
|
void nsgtk_dialog_set_has_separator(GtkDialog *dialog, gboolean setting);
|
|
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);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/* GTK prior to 2.16 needs the sexy interface for icons */
|
|
#if !GTK_CHECK_VERSION(2,16,0)
|
|
|
|
#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;
|
|
|
|
GtkStateType nsgtk_widget_get_state(GtkWidget *widget);
|
|
|
|
#endif
|
|
|
|
#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;
|
|
|
|
/* gtk 3 changed the enum name for the state flags */
|
|
#define GTK_STATE_FLAG_NORMAL GTK_STATE_NORMAL
|
|
|
|
#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)
|
|
|
|
#endif
|
|
|
|
|
|
void nsgtk_init(int* argc, char*** argv);
|
|
|
|
GtkWidget* nsgtk_image_new_from_icon_name(const gchar* icon_name, GtkIconSize size);
|
|
|
|
/**
|
|
* Sets the icon shown in the entry at the specified position from an
|
|
* icon name.
|
|
*
|
|
* Compatability interface for original introduced in 2.16
|
|
*
|
|
* \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.
|
|
*/
|
|
void nsgtk_entry_set_icon_from_icon_name(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
|
|
|
|
/**
|
|
* Creates a GtkImage displaying a stock icon.
|
|
*
|
|
* Compatability interface for original deprecated in GTK 3.10
|
|
*
|
|
* \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
|
|
*/
|
|
GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
|
|
/**
|
|
* Sets whether the button will grab focus when it is clicked with the mouse.
|
|
*
|
|
* Compatability interface for original deprecated in GTK 3.20
|
|
*
|
|
* \param button The button alter
|
|
* \param focus_on_click whether the button grabs focus when clicked with the mouse
|
|
*/
|
|
void nsgtk_button_set_focus_on_click(GtkButton *button, gboolean focus_on_click);
|
|
|
|
gboolean nsgtk_file_chooser_set_current_folder(GtkFileChooser* chooser, GFile* file);
|
|
|
|
/**
|
|
* destroy a gtk window
|
|
*/
|
|
void nsgtk_window_destroy(GtkWindow *window);
|
|
|
|
/**
|
|
* set the window to be hidden on close
|
|
*/
|
|
void nsgtk_window_set_hide_on_close(GtkWindow *window, gboolean);
|
|
|
|
void nsgtk_window_set_opacity(GtkWindow *window, gdouble opacity);
|
|
|
|
void nsgtk_scrolled_window_add_with_viewport(GtkScrolledWindow *window, GtkWidget *child);
|
|
|
|
GtkWidget *nsgtk_entry_new(void);
|
|
|
|
void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf);
|
|
|
|
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);
|
|
|
|
/**
|
|
* set cursor on a widget
|
|
*
|
|
* /param widget The widget upon which to set the cursor.
|
|
* /param cursor The gdk cursor to set.
|
|
*/
|
|
void nsgtk_widget_set_cursor(GtkWidget *widget, GdkCursor *cursor);
|
|
|
|
/**
|
|
* set input manager on client widget
|
|
*/
|
|
void nsgtk_im_context_set_client_widget(GtkIMContext* context, GtkWidget* widget);
|
|
|
|
GtkWidget *nsgtk_dialog_get_content_area(GtkDialog *dialog);
|
|
gboolean nsgtk_show_uri(GdkScreen *screen, const gchar *uri, guint32 timestamp, GError **error);
|
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
/* not required */
|
|
#else
|
|
GdkWindow *nsgtk_widget_get_window(GtkWidget *widget);
|
|
GdkWindow *nsgtk_layout_get_bin_window(GtkLayout *layout);
|
|
#endif
|
|
|
|
void nsgtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation);
|
|
|
|
gboolean nsgtk_icon_size_lookup_for_settings (GtkSettings *settings, GtkIconSize size, gint *width, gint *height);
|
|
|
|
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);
|
|
|
|
/* 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);
|
|
|
|
/**
|
|
* Displays menu and makes it available for selection
|
|
*
|
|
* Compatability interface for gtk_menu_popup deprecated in GTK 3.22.
|
|
*
|
|
* \param image_menu_item The image menu entry item.
|
|
* \param trigger_event the GdkEvent that initiated this request or NULL if it's the current event.
|
|
*/
|
|
void nsgtk_menu_popup_at_pointer(GtkMenu *menu, const GdkEvent *trigger_event);
|
|
|
|
/**
|
|
* Parses a resource file containing a GtkBuilder UI definition and
|
|
* merges it with the current contents of builder.
|
|
*
|
|
* Compatability interface as this did not exist prior to GTK 3.4
|
|
*
|
|
* GTK prior to 3.4 can have the resources in a GResource but
|
|
* gtk_builder cannot directly instantiate from them
|
|
*
|
|
* GTK 3.4 onwards can use gtk_builder_add_from_resource() to add
|
|
* directly from resources. The gtk_builder_new_ type operations
|
|
* cannot be used because they are only available post 3.10 and handle
|
|
* all errors by aborting the application
|
|
*
|
|
* @note prior to GLIB 2.32 resources did not exist and this wrapper
|
|
* returns the error code.
|
|
*
|
|
* \param builder a GtkBuilder
|
|
* \param resource_path the path of the resource file to parse
|
|
* \param error return location for an error, or NULL.
|
|
* \return A positive value on success, 0 if an error occurred.
|
|
*/
|
|
guint nsgtk_builder_add_from_resource(GtkBuilder *builder, const gchar *resource_path, GError **error);
|
|
|
|
#endif /* NETSURF_GTK_COMPAT_H */
|