| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_UTILS_GTK_H_ | |
| 6 #define CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_UTILS_GTK_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/strings/string16.h" | |
| 12 #include "ui/base/glib/glib_integers.h" | |
| 13 | |
| 14 class BookmarkModel; | |
| 15 class BookmarkNode; | |
| 16 class GtkThemeService; | |
| 17 class GURL; | |
| 18 class Profile; | |
| 19 | |
| 20 typedef struct _GdkDragContext GdkDragContext; | |
| 21 typedef struct _GdkPixbuf GdkPixbuf; | |
| 22 typedef struct _GtkSelectionData GtkSelectionData; | |
| 23 typedef struct _GtkWidget GtkWidget; | |
| 24 | |
| 25 extern const char kBookmarkNode[]; | |
| 26 | |
| 27 // Get the image that is used to represent the node. This function adds a ref | |
| 28 // to the returned pixbuf, so it requires a matching call to g_object_unref(). | |
| 29 GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, | |
| 30 BookmarkModel* model, | |
| 31 bool native); | |
| 32 | |
| 33 // Returns a GtkWindow with a visual hierarchy for passing to | |
| 34 // gtk_drag_set_icon_widget(). | |
| 35 GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, | |
| 36 const base::string16& title, | |
| 37 GtkThemeService* provider); | |
| 38 GtkWidget* GetDragRepresentationForNode(const BookmarkNode* node, | |
| 39 BookmarkModel* model, | |
| 40 GtkThemeService* provider); | |
| 41 | |
| 42 // Helper function that sets visual properties of GtkButton |button| to the | |
| 43 // contents of |node|. | |
| 44 void ConfigureButtonForNode(const BookmarkNode* node, | |
| 45 BookmarkModel* model, | |
| 46 GtkWidget* button, | |
| 47 GtkThemeService* provider); | |
| 48 | |
| 49 // Helper function to set the visual properties for the apps page shortcut | |
| 50 // |button|. | |
| 51 void ConfigureAppsShortcutButton(GtkWidget* button, GtkThemeService* provider); | |
| 52 | |
| 53 // Returns the tooltip. | |
| 54 std::string BuildTooltipFor(const BookmarkNode* node); | |
| 55 | |
| 56 // Returns the label that should be in pull down menus. | |
| 57 std::string BuildMenuLabelFor(const BookmarkNode* node); | |
| 58 | |
| 59 // Returns the "bookmark-node" property of |widget| casted to the correct type. | |
| 60 const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget); | |
| 61 | |
| 62 // Set the colors on |label| as per the theme. | |
| 63 void SetButtonTextColors(GtkWidget* label, GtkThemeService* provider); | |
| 64 | |
| 65 // Drag and drop. -------------------------------------------------------------- | |
| 66 | |
| 67 // Get the DnD target mask for a bookmark drag. This will vary based on whether | |
| 68 // the node in question is a folder. | |
| 69 int GetCodeMask(bool folder); | |
| 70 | |
| 71 // Pickle a node into a GtkSelection. | |
| 72 void WriteBookmarkToSelection(const BookmarkNode* node, | |
| 73 GtkSelectionData* selection_data, | |
| 74 guint target_type, | |
| 75 Profile* profile); | |
| 76 | |
| 77 // Pickle a vector of nodes into a GtkSelection. | |
| 78 void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, | |
| 79 GtkSelectionData* selection_data, | |
| 80 guint target_type, | |
| 81 Profile* profile); | |
| 82 | |
| 83 // Un-pickle node(s) from a GtkSelection. | |
| 84 // The last two arguments are out parameters. | |
| 85 std::vector<const BookmarkNode*> GetNodesFromSelection( | |
| 86 GdkDragContext* context, | |
| 87 GtkSelectionData* selection_data, | |
| 88 guint target_type, | |
| 89 Profile* profile, | |
| 90 gboolean* delete_selection_data, | |
| 91 gboolean* dnd_success); | |
| 92 | |
| 93 // Unpickle a new bookmark of the CHROME_NAMED_URL drag type, and put it in | |
| 94 // the appropriate location in the model. | |
| 95 bool CreateNewBookmarkFromNamedUrl(GtkSelectionData* selection_data, | |
| 96 BookmarkModel* model, | |
| 97 const BookmarkNode* parent, | |
| 98 int idx); | |
| 99 | |
| 100 // Add the URIs in |selection_data| into the model at the given position. They | |
| 101 // will be added whether or not the URL is valid. | |
| 102 bool CreateNewBookmarksFromURIList(GtkSelectionData* selection_data, | |
| 103 BookmarkModel* model, | |
| 104 const BookmarkNode* parent, | |
| 105 int idx); | |
| 106 | |
| 107 // Add the "url\ntitle" combination into the model at the given position. | |
| 108 bool CreateNewBookmarkFromNetscapeURL(GtkSelectionData* selection_data, | |
| 109 BookmarkModel* model, | |
| 110 const BookmarkNode* parent, | |
| 111 int idx); | |
| 112 | |
| 113 // Returns a name for the given URL. Used for drags into bookmark areas when | |
| 114 // the source doesn't specify a title. | |
| 115 base::string16 GetNameForURL(const GURL& url); | |
| 116 | |
| 117 #endif // CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_UTILS_GTK_H_ | |
| OLD | NEW |