/usr/share/help/de/gnome-devel-demos/tooltip.c.page is in gnome-devel-docs 3.28.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | <?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="tooltip.c" xml:lang="de">
<info>
<title type="text">Tooltip (C)</title>
<link type="guide" xref="c#misc"/>
<link type="seealso" xref="toolbar.c"/>
<revision version="0.1" date="2013-07-02" status="review"/>
<credit type="author copyright">
<name>Tiffany Antopolski</name>
<email its:translate="no">tiffany.antopolski@gmail.com</email>
<years>2013</years>
</credit>
<desc>Add tips to your widgets</desc>
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
<mal:name>Mario Blättermann</mal:name>
<mal:email>mario.blaettermann@gmail.com</mal:email>
<mal:years>2011, 2013</mal:years>
</mal:credit>
</info>
<title>Tooltip</title>
<media type="image" mime="image/png" src="media/tooltip.png"/>
<p>A toolbar with a tooltip (with an image) for a button.</p>
<note><p>This example builds on the <link xref="toolbar.c">Toolbar</link> example.</p></note>
<links type="section"/>
<section id="code">
<title>Code used to generate this example</title>
<code mime="text/x-crsc" style="numbered">#include <gtk/gtk.h>
static gboolean
undo_tooltip_callback (GtkStatusIcon *status_icon,
gint x,
gint y,
gboolean keyboard_mode,
GtkTooltip *tooltip,
gpointer user_data)
{
/* set the text for the tooltip */
gtk_tooltip_set_text (tooltip, "Undo your last action");
/* set an icon fot the tooltip */
gtk_tooltip_set_icon_from_stock(tooltip, "gtk-undo", GTK_ICON_SIZE_MENU);
/* show the tooltip */
return TRUE;
}
static void
undo_callback (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
g_print ("You clicked \"Undo\".\n");
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *grid;
GtkWidget *window;
GtkWidget *toolbar;
GtkToolItem *new_button;
GtkToolItem *open_button;
GtkToolItem *undo_button;
GtkStyleContext *style_context;
GSimpleAction *undo_action;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Toolbar with Tooltips Example");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 200);
/* Here we begin to create the toolbar */
toolbar = gtk_toolbar_new ();
/* Set the toolbar to be the primary toolbar of the application */
style_context = gtk_widget_get_style_context (toolbar);
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
/* Create a button for the "new" action, with a stock image */
new_button = gtk_tool_button_new_from_stock (GTK_STOCK_NEW);
gtk_tool_item_set_is_important (new_button, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), new_button, 0);
gtk_widget_show (GTK_WIDGET (new_button));
/* Set the action name for the "new" action. We use "app.new" to
* indicate that the action controls the application.
*/
gtk_actionable_set_action_name (GTK_ACTIONABLE (new_button), "app.new");
/*******************************
* Tooltip for the New ToolItem:
* a tooltip with text
*******************************/
gtk_tool_item_set_tooltip_text (new_button, "Create a new file");
/* "Open" */
open_button = gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
gtk_tool_item_set_is_important (open_button, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), open_button, 1);
gtk_widget_show (GTK_WIDGET (open_button));
gtk_actionable_set_action_name (GTK_ACTIONABLE (open_button), "app.open");
/*******************************
* Tooltip for the Open ToolItem:
* a tooltip using Pango markup
* language
*******************************/
gtk_tool_item_set_tooltip_text (open_button, "Open an <i>existing</i> file");
/* "Undo" */
undo_button = gtk_tool_button_new_from_stock (GTK_STOCK_UNDO);
gtk_tool_item_set_is_important (undo_button, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), undo_button, 2);
gtk_widget_show (GTK_WIDGET (undo_button));
/* In this case, we use "win.undo" to indicate that
* the action controls only the window
*/
gtk_actionable_set_action_name (GTK_ACTIONABLE (undo_button), "win.undo");
/*******************************
* Tooltip for the Undo ToolItem:
* a tooltip with an image
*******************************/
gtk_widget_set_has_tooltip (GTK_WIDGET (undo_button), TRUE);
// Next, we connect the query_tooltip signal
g_signal_connect (undo_button, "query-tooltip", G_CALLBACK (undo_tooltip_callback), NULL);
gtk_widget_set_hexpand (toolbar, TRUE);
gtk_widget_show (toolbar);
grid = gtk_grid_new ();
gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 1);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (grid));
gtk_widget_show (GTK_WIDGET (grid));
/* Use the action names to create the actions that control the window, and
* connect them to the appropriate callbackfunctions.
*/
undo_action = g_simple_action_new ("undo", NULL);
g_signal_connect (undo_action, "activate", G_CALLBACK (undo_callback),
GTK_WINDOW (window));
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (undo_action));
gtk_widget_show (window);
}
/* Callback function for the new action */
static void
new_callback (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
g_print ("You clicked \"New\".\n");
}
/* Callback function for the open action */
static void
open_callback (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
g_print ("You clicked \"Open\".\n");
}
/* In this function, we create the actions in which control the window, and
* connect their signals to the appropriate callback function.
*/
static void
startup (GApplication *app,
gpointer user_data)
{
GSimpleAction *new_action;
GSimpleAction *open_action;
new_action = g_simple_action_new ("new", NULL);
g_signal_connect (new_action, "activate", G_CALLBACK (new_callback), app);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (new_action));
open_action = g_simple_action_new ("open", NULL);
g_signal_connect (open_action, "activate", G_CALLBACK (open_callback), app);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (open_action));
}
/* Startup function for the application */
int
main (int argc, char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
</code>
</section>
<section id="references">
<title>API-Referenzen</title>
<p>In this sample we used the following:</p>
<list>
<item><p><link href="http://developer.gnome.org/gtk3/stable/GtkTooltip.html">GtkTooltip</link></p></item>
<item><p><link href="http://developer.gnome.org/gtk3/stable/GtkToolbar.html">GtkToolbar</link></p></item>
<item><p><link href="http://developer.gnome.org/gtk3/stable/GtkWidget.html">GtkWidget</link></p></item>
<item><p><link href="http://developer.gnome.org/gtk3/stable/gtk3-Stock-Items.html">Stock Items</link></p></item>
</list>
</section>
</page>
|