OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ |
6 #define CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <vector> | 9 #include <vector> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 class BookmarkModel; | 12 class BookmarkModel; |
13 class BookmarkNode; | 13 class BookmarkNode; |
14 class Profile; | 14 class Profile; |
15 | 15 |
16 namespace bookmark_utils { | 16 namespace bookmark_utils { |
17 | 17 |
18 extern const char kBookmarkNode[]; | 18 extern const char kBookmarkNode[]; |
19 | 19 |
| 20 // Padding between the image and the label of a bookmark bar button. |
| 21 extern const int kBarButtonPadding; |
| 22 |
20 // These functions do not add a ref to the returned pixbuf, and it should not be | 23 // These functions do not add a ref to the returned pixbuf, and it should not be |
21 // unreffed. | 24 // unreffed. |
22 GdkPixbuf* GetFolderIcon(); | 25 GdkPixbuf* GetFolderIcon(); |
23 GdkPixbuf* GetDefaultFavicon(); | 26 GdkPixbuf* GetDefaultFavicon(); |
24 | 27 |
25 // Get the image that is used to represent the node. This function adds a ref | 28 // Get the image that is used to represent the node. This function adds a ref |
26 // to the returned pixbuf, so it requires a matching call to g_object_unref(). | 29 // to the returned pixbuf, so it requires a matching call to g_object_unref(). |
27 GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model); | 30 GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model); |
28 | 31 |
29 // Returns a GtkWindow with a visual hierarchy for passing to | 32 // Returns a GtkWindow with a visual hierarchy for passing to |
30 // gtk_drag_set_icon_widget(). | 33 // gtk_drag_set_icon_widget(). |
31 GtkWidget* GetDragRepresentation(const BookmarkNode* node, | 34 GtkWidget* GetDragRepresentation(const BookmarkNode* node, |
32 BookmarkModel* model); | 35 BookmarkModel* model); |
33 | 36 |
34 // Helper function that sets visual properties of GtkButton |button| to the | 37 // Helper function that sets visual properties of GtkButton |button| to the |
35 // contents of |node|. | 38 // contents of |node|. |
36 void ConfigureButtonForNode(const BookmarkNode* node, BookmarkModel* model, | 39 void ConfigureButtonForNode(const BookmarkNode* node, BookmarkModel* model, |
37 GtkWidget* button); | 40 GtkWidget* button); |
38 | 41 |
39 // Returns the tooltip. | 42 // Returns the tooltip. |
40 std::string BuildTooltipFor(const BookmarkNode* node); | 43 std::string BuildTooltipFor(const BookmarkNode* node); |
41 | 44 |
42 // Returns the "bookmark-node" property of |widget| casted to the correct type. | 45 // Returns the "bookmark-node" property of |widget| casted to the correct type. |
43 const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget); | 46 const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget); |
44 | 47 |
45 // This function is a temporary hack to fix fonts on dark system themes. | 48 // This function is a temporary hack to fix fonts on dark system themes. |
46 // NOTE: this makes assumptions about GtkButton internals. Also, it only works | |
47 // if you call it after the last time you edit the button. | |
48 // TODO(estade): remove this function. | 49 // TODO(estade): remove this function. |
49 void SetButtonTextColors(GtkWidget* button); | 50 void SetButtonTextColors(GtkWidget* label); |
50 | 51 |
51 // Drag and drop. -------------------------------------------------------------- | 52 // Drag and drop. -------------------------------------------------------------- |
52 | 53 |
53 // Pickle a node into a GtkSelection. | 54 // Pickle a node into a GtkSelection. |
54 void WriteBookmarkToSelection(const BookmarkNode* node, | 55 void WriteBookmarkToSelection(const BookmarkNode* node, |
55 GtkSelectionData* selection_data, | 56 GtkSelectionData* selection_data, |
56 guint target_type, | 57 guint target_type, |
57 Profile* profile); | 58 Profile* profile); |
58 | 59 |
59 // Pickle a vector of nodes into a GtkSelection. | 60 // Pickle a vector of nodes into a GtkSelection. |
60 void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, | 61 void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, |
61 GtkSelectionData* selection_data, | 62 GtkSelectionData* selection_data, |
62 guint target_type, | 63 guint target_type, |
63 Profile* profile); | 64 Profile* profile); |
64 | 65 |
65 // Un-pickle node(s) from a GtkSelection. | 66 // Un-pickle node(s) from a GtkSelection. |
66 // The last two arguments are out parameters. | 67 // The last two arguments are out parameters. |
67 std::vector<const BookmarkNode*> GetNodesFromSelection( | 68 std::vector<const BookmarkNode*> GetNodesFromSelection( |
68 GdkDragContext* context, | 69 GdkDragContext* context, |
69 GtkSelectionData* selection_data, | 70 GtkSelectionData* selection_data, |
70 guint target_type, | 71 guint target_type, |
71 Profile* profile, | 72 Profile* profile, |
72 gboolean* delete_selection_data, | 73 gboolean* delete_selection_data, |
73 gboolean* dnd_success); | 74 gboolean* dnd_success); |
74 | 75 |
75 } // namespace bookmark_utils | 76 } // namespace bookmark_utils |
76 | 77 |
77 #endif // CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ | 78 #endif // CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ |
OLD | NEW |