Renders a frame around the rectangle defined by x , y , width , height , leaving a gap on one side. Renders the icon in pixbuf at the specified x and y coordinates. Renders the icon specified by source at the given size , returning the result in a pixbuf.
Renders the icon in surface at the specified x and y coordinates. Renders a slider as in GtkScale in the rectangle defined by x , y , width , height. Appends a specified target to the list of supported targets for a given widget and selection.
Prepends a table of targets to the list of supported targets for a given widget and selection. Requests the contents of a selection. Claims ownership of a given selection for a particular widget, or, if widget is NULL , release ownership of the selection. Claim ownership of a given selection for a particular widget, or, if widget is NULL , release ownership of the selection.
Removes all handlers and unsets ownership of all selections for a widget. Called when widget is being destroyed. This function will not generally be called by applications. The constructed dialog is associated with the parent window and reused for future invocations of this function.
A convenience function for launching the default application to show the uri. This is a convenience function for launching the default application to show the uri. The uri must be of a form understood by GIO i. Registers each of the stock items in items. If an item already exists with the same stock ID as one of the items , the old item gets replaced.
Determines if any of the targets in targets can be used to provide a GdkPixbuf. Determines if any of the targets in targets can be used to provide an uri list. Each button is created with a label and a ::clicked signal handler that incremrents the integer stored in nump.
Such as finding a button or text entry widget, given its corresponding label widget. This is most useful for automated GUI testing, e.
Retrive the literal adjustment value for GtkRange based widgets and spin buttons. The adjustment value of these widgets is set to a value between the lower and upper limits, according to the percentage argument.
This function will generate a button click button press and button release event in the middle of the first GdkWindow found that belongs to widget. This function will generate keyboard press and release events in the middle of the first GdkWindow found that belongs to widget. In this context that means it waits for the frame clock of widget to have run a full styling, layout and drawing cycle.
Constant to return from a signal handler for the GtkSpinButton::input signal in case of conversion failure. A CSS class that gets added to windows which have client-side decorations. A CSS class used when an action usually a button is one that is expected to remove or destroy something visible to the user.
A CSS class for an area displaying an error message, such as those in infobars. A CSS class that is added when widgets that usually have a frame or border like buttons or entries should appear without it. A CSS class defining a frame delimiting content, such as GtkFrame or the scrolled window frame around the scrollable area. A CSS class defining a highlighted area, such as headings in assistants and calendars.
A CSS class for an area displaying an informational message, such as those in infobars. A CSS class used when rendering a drag handle for the insertion cursor position. A CSS class used when rendering a level indicator, such as a battery charge level, or a password strength. A CSS class to match a linked area, such as a box containing buttons belonging to the same control. A CSS class that is added to text view that should use a monospace font.
A CSS class used when an element needs the user attention, for instance a button in a stack switcher corresponding to a hidden page that changed state. A CSS class that is added on the visual hints that happen when scrolling is attempted past the limits of a scrollable area. A CSS class to use when rendering a pulse in an indeterminate progress bar.
A CSS class for an area displaying a question to the user, such as those in infobars. A CSS class to match a raised control, such as a raised button on a toolbar.
A CSS class to match scale widgets with marks attached, all the marks are above for horizontal GtkScale. A CSS class defining a sidebar, such as the left side in a file chooser. A CSS class used for the subtitle label in a titlebar in a toplevel window.
A CSS class used when an action usually a button is the primary suggested action in a specific context. A CSS class used for the title label in a titlebar in a toplevel window.
A CSS class for an area displaying a warning message, such as those in infobars. Used by GtkPaned. A property holding the font properties used when rendering text as a PangoFontDescription. The margin is defined as the spacing between the border of the element and its surrounding elements.
The padding is defined as the spacing between the inner part of the element border and its child. A priority that can be used when adding a GtkStyleProvider for application-specific style information.
The priority at which the text view validates onscreen lines in an idle job in the background. Gtk API Version: 3. Classes AboutDialog The GtkAboutDialog offers a simple way to display information about a program like its logo, name, copyright, website and license.
AccelMap Accelerator maps are used to define runtime configurable accelerators. Accessible The GtkAccessible class is the base class for accessible implementations for GtkWidget subclasses. ActionBar GtkActionBar is designed to present contextual actions. ActionGroup Actions are organised into groups. Adjustment The GtkAdjustment object represents a value which has an associated lower and upper bound, together with step and page increments, and a page size.
Alignment The GtkAlignment widget controls the alignment and size of its child widget. ApplicationWindow GtkApplicationWindow is a GtkWindow subclass that offers some extra functionality for better integration with GtkApplication features. Arrow GtkArrow should be used to draw simple arrows that need to point in one of the four cardinal directions up, down, left, or right.
ArrowAccessible AspectFrame The GtkAspectFrame is useful when you want pack a widget so that it can resize but always retains the same aspect ratio. Assistant A GtkAssistant is a widget used to represent a generally complex operation splitted in several steps, guiding the user through its pages and controlling the page flow to collect the necessary data.
Bin The GtkBin widget is a container with just one child. BooleanCellAccessible Box The GtkBox widget arranges child widgets into a single row or column, depending upon the value of its GtkOrientable:orientation property. Builder A GtkBuilder is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects. Button The GtkButton widget is generally used to trigger a callback function that is called when the button is pressed.
CellRendererText A GtkCellRendererText renders a given text in its cell, using the font, color and style information provided by its properties. CheckMenuItemAccessible Clipboard The GtkClipboard object represents a clipboard of data shared between different processes or between different widgets in the same process. ColorButton The GtkColorButton is a button which displays the currently selected color and allows to open a color selection dialog to change the color. Dialog Dialog boxes are a convenient way to prompt the user for a small amount of input, e.
After creating a drawing area, the application may want to connect to: Entry The GtkEntry widget is a single line text entry widget. EntryCompletion GtkEntryCompletion is an auxiliary object to be used in conjunction with GtkEntry to provide the completion functionality. EventController GtkEventController is a base, low-level implementation for event controllers. EventControllerKey GtkEventControllerKey is an event controller meant for situations where you need access to key events.
EventControllerMotion GtkEventControllerMotion is an event controller meant for situations where you need to track the position of the pointer.
EventControllerScroll GtkEventControllerScroll is an event controller meant to handle scroll events from mice and touchpads. Expander A GtkExpander allows the user to hide or show its child by clicking on an expander triangle similar to the triangles used in a GtkTreeView.
Fixed The GtkFixed widget is a container which can place child widgets at fixed positions and with fixed sizes, given in pixels. FontSelection FontSelectionDialog Frame The frame widget is a bin that surrounds its child with a decorative frame and an optional label.
FrameAccessible Gesture GtkGesture is the base object for gesture recognition, although this object is quite generalized to serve as a base for multi-touch gestures, it is suitable to implement single-touch and pointer-based gestures using the special NULL GdkEventSequence value for these.
GesturePan GtkGesturePan is a GtkGesture implementation able to recognize pan gestures, those are drags that are locked to happen along one axis. GestureRotate GtkGestureRotate is a GtkGesture implementation able to recognize 2-finger rotations, whenever the angle between both handled sequences changes, the GtkGestureRotate::angle-changed signal is emitted. GestureSingle GtkGestureSingle is a subclass of GtkGesture , optimized although not restricted for dealing with mouse and single-touch gestures.
HBox GtkHBox is a container that organizes child widgets into a single row. HSeparator The GtkHSeparator widget is a horizontal separator, used to group the widgets within a window.
IconInfo Contains information found when looking up an icon in an icon theme. IconTheme GtkIconTheme provides a facility for looking up icons by name and size. Interfaces Actionable This interface provides a convenient way of associating widgets with actions on a GtkApplicationWindow or GtkApplication.
Activatable Activatable widgets can be connected to a GtkAction and reflects the state of its action. AppChooser GtkAppChooser is an interface that can be implemented by widgets which allow the user to choose an application typically for the purpose of opening a file. ColorChooser GtkColorChooser is an interface that is implemented by widgets for choosing colors. FileChooser GtkFileChooser is an interface that can be implemented by file selection widgets. FontChooser GtkFontChooser is an interface that can be implemented by widgets displaying the list of fonts.
Orientable The GtkOrientable interface is implemented by all widgets that can be oriented horizontally or vertically. PrintOperationPreview RecentChooser GtkRecentChooser is an interface that can be implemented by widgets displaying the list of recently used files.
Scrollable GtkScrollable is an interface that is implemented by widgets with native scrolling ability. TreeSortable GtkTreeSortable is an interface to be implemented by tree models which support sorting. BindingEntry Each key binding element of a binding sets binding list is represented by a GtkBindingEntry. BindingSet A binding set maintains a list of activatable key bindings.
BindingSignal A GtkBindingSignal stores the necessary information to activate a widget in response to a key press via a signal emission. Border A struct that specifies a border around a rectangular area that can be of different width on each side. FixedChild Gradient GtkGradient is a boxed type that represents a gradient. PaperSize GtkPaperSize handles paper sizes. RcContext RcProperty Deprecated. RequestedSize Represents a request of a screen object in a given orientation.
Requisition A GtkRequisition -struct represents the desired size of a widget. TableChild TableRowCol TargetEntry A GtkTargetEntry represents a single type of data than can be supplied for by a widget for a selection or for supplied or received during drag-and-drop.
TextBTree TextIter You may wish to begin by reading the [text widget conceptual overview][TextWidget] which gives an overview of all the objects and data types related to the text widget and how they work together. WidgetPath GtkWidgetPath is a boxed type that represents a widget hierarchy from the topmost widget, typically a toplevel, to any child. Aliases Allocation A GtkAllocation -struct of a widget represents region which has been allocated to the widget by its parent. Enumerations Align Controls how a widget deals with extra space in a single x or y dimension.
ArrowPlacement Used to specify the placement of scroll arrows in scrolling menus. ArrowType Used to indicate the direction in which an arrow should point. BaselinePosition Whenever a container has some form of natural row it may align children in that row along a common typographical baseline.
BorderStyle Describes how the border of a UI element should be rendered. ButtonsType Prebuilt sets of buttons for the dialog. CellRendererMode Identifies how the user can interact with a particular cell.
CornerType Specifies which corner a child widget should be placed in when packed into a GtkScrolledWindow. DeleteType See also: GtkEntry::delete-from-cursor. DirectionType Focus movement types. DragResult Gives an indication why a drag operation failed. EntryIconPosition Specifies the side of the entry at which an icon is placed. FileChooserAction Describes whether a GtkFileChooser is being used to open existing files or to save to a possibly new file.
IconSize Built-in stock icon sizes. IconViewDropPosition An enum for determining where a dropped item goes. ImageType Describes the image data representation used by a GtkImage. IMPreeditStyle Style for input method preedit. See also GtkSettings:gtk-im-preedit-style.
IMStatusStyle Style for input method status. See also GtkSettings:gtk-im-status-style. InputPurpose Describes primary purpose of the input widget. Justification Used for justifying the text inside a GtkLabel widget. License The type of license for an application. MenuDirectionType An enumeration representing directional movements within a menu.
MessageType The type of message being displayed in the dialog. Orientation Represents the orientation of widgets and other objects which can be switched between horizontal and vertical orientation on the fly, like GtkToolbar or GtkGesturePan. PackDirection Determines how widgets should be packed inside menubars and menuitems contained in menubars.
PackType Represents the packing location GtkBox children. PadActionType The type of a pad action. PathPriorityType Priorities for path lookups. PathType Widget path types. PolicyType Determines how the size should be computed to achieve the one of the visibility mode for the scrollbars.
PopoverConstraint Describes constraints to positioning of popovers. PositionType Describes which edge of a widget a certain feature is positioned at, e. PrintStatus The status gives a rough indication of the completion of a running print operation. RecentSortType Used to specify the sorting method to be applyed to the recently used resource list. ReliefStyle Indicated the relief to be drawn around a GtkButton.
RevealerTransitionType These enumeration values describe the possible transitions when the child of a GtkRevealer widget is shown or hidden.
ScrollablePolicy Defines the policy to be used in a scrollable widget when updating the scrolled window adjustments in a given orientation. ScrollStep ScrollType Scrolling types. SelectionMode Used to control what selections users are allowed to make. ShadowType Used to change the appearance of an outline typically provided by a GtkFrame. ShortcutType GtkShortcutType specifies the kind of shortcut that is being described.
SizeGroupMode The mode of the size group determines the directions in which the size group affects the requested sizes of its component widgets.
SizeRequestMode Specifies a preference for height-for-width or width-for-height geometry management. SortType Determines the direction of a sort. SpinButtonUpdatePolicy The spin button update policy determines whether the spin button displays values even if they are outside the bounds of its adjustment. StackTransitionType These enumeration values describe the possible transitions between pages in a GtkStack widget. StateType This type indicates the current state of a widget; the state determines how the widget is drawn.
TextDirection Reading directions for text. TextExtendSelection Granularity types that extend the text selection. ToolbarSpaceStyle Whether spacers are vertical lines or just blank. ToolbarStyle Used to customize the appearance of a GtkToolbar.
TreeViewColumnSizing The sizing method the column uses to determine its width. TreeViewDropPosition An enum for determining where a dropped row goes. TreeViewGridLines Used to indicate which grid lines to draw in a tree view. WidgetHelpType Kinds of widget-specific help. Used by the ::show-help signal. WindowPosition Window placement can be influenced using this enumeration.
WindowType A GtkWindow can be one of these types. WrapMode Describes a type of line wrapping. AttachOptions Denotes the expansion properties that a widget will have when it or its parent is resized.
CalendarDisplayOptions These options can be used to influence the display and behaviour of a GtkCalendar. CellRendererState Tells how a cell is to be rendered. DebugFlag DestDefaults The GtkDestDefaults enumeration specifies the various types of action that will be taken on behalf of the user for a drag destination site. DialogFlags Flags used to influence dialog construction. FontChooserLevel This enumeration specifies the granularity of font selection that is desired in a font chooser.
JunctionSides Describes how a rendered element connects to adjacent elements. PlacesOpenFlags These flags serve two purposes. RcFlags Deprecated. RegionFlags Describes a region within a widget. StateFlags Describes a widget state. TextSearchFlags Flags affecting how a search is done.
ToolPaletteDragTargets Flags used to specify the supported drag targets. BuilderConnectFunc This is the signature of a function used to connect signals. CalendarDetailFunc This kind of functions provide Pango markup with detail information for the specified day. Callback The type of the callback functions used for e. ClipboardClearFunc A function that will be called when the contents of the clipboard are changed or cleared. ClipboardGetFunc A function that will be called to provide the contents of the selection.
FlowBoxFilterFunc A function that will be called whenrever a child changes or is added. FlowBoxSortFunc A function to compare two children to determine which should come first. KeySnoopFunc Key snooper functions are called before normal event delivery. ListBoxFilterFunc Will be called whenever the row changes or is added and lets you control if the row should be visible or not.
ListBoxSortFunc Compare two rows to determine which should be first. ListBoxUpdateHeaderFunc Whenever row changes or which row is before row changes this is called, which lets you update the header on row. TextBufferSerializeFunc A function that is called to serialize the content of a text buffer. TranslateFunc The function used to translate messages in e. TreeCellDataFunc A function to set the properties of a cell instead of just using the straight mapping between the cell and the model.
TreeViewRowSeparatorFunc Function type for determining whether the row pointed to by iter should be rendered as a separator. TreeViewSearchEqualFunc A function used for checking whether a row in model matches a search key string entered by the user. The icon has an RTL variant.
A GtkFlowBox positions child widgets in sequence according to its orientation. GtkHBox is a container that organizes child widgets into a single row. Contains information found when looking up an icon in an icon theme.
A GtkImageMenuItem is a menu item which has an icon next to the text label. This should not be accessed directly. Use the accessor functions below. GtkSettings provide a mechanism to share global settings between applications. Widget that displays any object that implements the GtkTreeModel interface. A GtkVBox is a container that organizes child widgets into a single column. Controls how a widget deals with extra space in a single x or y dimension. Used to specify the placement of scroll arrows in scrolling menus.
Used to indicate the direction in which an arrow should point. Describes how the border of a UI element should be rendered. The role specifies the desired appearance of a GtkModelButton. Identifies how the user can interact with a particular cell. Specifies the side of the entry at which an icon is placed. Used to specify the style of the expanders drawn by a GtkTreeView. Style for input method preedit. Style for input method status.
An enumeration representing directional movements within a menu. Used to determine the layout of pages on a sheet when printing multiple pages per sheet. Describes the panning direction of a GtkGesturePan. Priorities for path lookups. The status gives a rough indication of the completion of a running print operation. Describes the stage at which events are fed into a GtkEventController. Used to specify the sorting method to be applyed to the recently used resource list.
Indicated the relief to be drawn around a GtkButton. Used to change the appearance of an outline typically provided by a GtkFrame. Specifies a preference for height-for-width or width-for-height geometry management. Kinds of widget-specific help. These options can be used to influence the display and behaviour of a GtkCalendar. Describes the behavior of a GtkEventControllerScroll.
Describes how a rendered element connects to adjacent elements. These flags indicate various properties of a GtkTreeModel. Error codes that identify various errors that can occur while using GtkBuilder. A function to compare two children to determine which should come first.
A function which decides whether the row indicated by iter is visible. Gets a list of all accel groups which are attached to object.
Sets the icon for a given drag from a stock ID. Makes the innermost invocation of the main loop return when it regains control. Draws a diamond in the given rectangle on window using the given parameters. Draws a flat box on cr with the given parameters. Draws a layout on cr using the given parameters. Draws a resize grip in the given rectangle on cr using the given parameters. Draws a spinner on window using the given parameters.
Draws a text caret on cr at the specified index of layout. Renders layout on the coordinates x , y. Remove all targets registered for the given selection for the widget. Sets a function to be used for translating the label of a stock item. Determines if any of the targets in targets can be used to provide rich text.
Determines if any of the targets in targets can be used to provide text. The name used for the stock full offset included by GtkLevelBar. The name used for the stock high offset included by GtkLevelBar. The name used for the stock low offset included by GtkLevelBar. GTK is a widget toolkit.
Each user interface created by GTK consists of widgets. This is implemented in C using GObject , an object-oriented framework for C. Widgets are organized in a hierarchy. The window widget is the main container. The user interface is then built by adding buttons, drop-down menus, input fields, and other widgets to the window.
If you are creating complex user interfaces it is recommended to use GtkBuilder and its GTK -specific markup description language, instead of assembling the interface manually. You can also use a visual user interface editor, like Glade. GTK is event-driven. The toolkit listens for events such as a click on a button, and passes the event to your application. This chapter contains some tutorial information to get you started with GTK programming. It assumes that you have GTK , its dependencies and a C compiler installed and ready to use.
The compiler will abort with an error if any other header is directly included. In a GTK application, the purpose of the main function is to create a GtkApplication object and run it. For this example org. For choosing an identifier for your application, see this guide.
Next the activate signal is connected to the activate function above the main function. Your application can override the command line handling, e. This is where we construct our GTK window, so that a window is shown when the application is launched. The window will have a frame, a title bar, and window controls depending on the platform. This function takes a GtkWindow pointer and a string as input. More information about this convention can be found in the GObject documentation.
Finally the status integer is returned and the application exits. While the program is running, GTK is receiving events. These are typically input events caused by the user interacting with your program, but also things like messages from the window manager or other applications. GTK processes these and as a result, signals may be emitted on your widgets. Connecting handlers for these signals is how you normally make your program do something in response to user input.
The following example is slightly more complex, and tries to showcase some of the capabilities of GTK. In the long tradition of programming languages and libraries, this example is called Hello, World.
As seen above, example Two new GtkWidget pointers are declared to accomplish this, button and box. The buttons which this box will contain can either be laid out horizontally or vertically.
This does not matter in this particular case, as we are dealing with only one button. Next the button variable is initialized in similar manner. Afterwards button is added to our box. This has the effect that when the button is clicked, the whole GTK window is destroyed. Save Article. Like Article. Last Updated : 19 Feb, Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more!
Check out our Data Structures in C course to start learning today. Previous Python Numpy np. Next Python Numpy np. Recommended Articles. Article Contributed By :.
0コメント