| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include "chrome/browser/ui/gtk/bookmark_utils_gtk.h" |
| 10 #include <string> | 10 // TODO(msw): remove this file once all includes have been updated. |
| 11 | |
| 12 #include "app/gtk_integers.h" | |
| 13 #include "base/string16.h" | |
| 14 | |
| 15 class BookmarkModel; | |
| 16 class BookmarkNode; | |
| 17 class GtkThemeProvider; | |
| 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 namespace bookmark_utils { | |
| 26 | |
| 27 extern const char kBookmarkNode[]; | |
| 28 | |
| 29 // Get the image that is used to represent the node. This function adds a ref | |
| 30 // to the returned pixbuf, so it requires a matching call to g_object_unref(). | |
| 31 GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model, | |
| 32 bool native); | |
| 33 | |
| 34 // Returns a GtkWindow with a visual hierarchy for passing to | |
| 35 // gtk_drag_set_icon_widget(). | |
| 36 GtkWidget* GetDragRepresentation(GdkPixbuf* pixbuf, | |
| 37 const string16& title, | |
| 38 GtkThemeProvider* provider); | |
| 39 GtkWidget* GetDragRepresentationForNode(const BookmarkNode* node, | |
| 40 BookmarkModel* model, | |
| 41 GtkThemeProvider* provider); | |
| 42 | |
| 43 // Helper function that sets visual properties of GtkButton |button| to the | |
| 44 // contents of |node|. | |
| 45 void ConfigureButtonForNode(const BookmarkNode* node, BookmarkModel* model, | |
| 46 GtkWidget* button, GtkThemeProvider* provider); | |
| 47 | |
| 48 // Returns the tooltip. | |
| 49 std::string BuildTooltipFor(const BookmarkNode* node); | |
| 50 | |
| 51 // Returns the "bookmark-node" property of |widget| casted to the correct type. | |
| 52 const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget); | |
| 53 | |
| 54 // Set the colors on |label| as per the theme. | |
| 55 void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider); | |
| 56 | |
| 57 // Drag and drop. -------------------------------------------------------------- | |
| 58 | |
| 59 // Get the DnD target mask for a bookmark drag. This will vary based on whether | |
| 60 // the node in question is a folder. | |
| 61 int GetCodeMask(bool folder); | |
| 62 | |
| 63 // Pickle a node into a GtkSelection. | |
| 64 void WriteBookmarkToSelection(const BookmarkNode* node, | |
| 65 GtkSelectionData* selection_data, | |
| 66 guint target_type, | |
| 67 Profile* profile); | |
| 68 | |
| 69 // Pickle a vector of nodes into a GtkSelection. | |
| 70 void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, | |
| 71 GtkSelectionData* selection_data, | |
| 72 guint target_type, | |
| 73 Profile* profile); | |
| 74 | |
| 75 // Un-pickle node(s) from a GtkSelection. | |
| 76 // The last two arguments are out parameters. | |
| 77 std::vector<const BookmarkNode*> GetNodesFromSelection( | |
| 78 GdkDragContext* context, | |
| 79 GtkSelectionData* selection_data, | |
| 80 guint target_type, | |
| 81 Profile* profile, | |
| 82 gboolean* delete_selection_data, | |
| 83 gboolean* dnd_success); | |
| 84 | |
| 85 // Unpickle a new bookmark of the CHROME_NAMED_URL drag type, and put it in | |
| 86 // the appropriate location in the model. | |
| 87 bool CreateNewBookmarkFromNamedUrl( | |
| 88 GtkSelectionData* selection_data, | |
| 89 BookmarkModel* model, | |
| 90 const BookmarkNode* parent, | |
| 91 int idx); | |
| 92 | |
| 93 // Add the URIs in |selection_data| into the model at the given position. They | |
| 94 // will be added whether or not the URL is valid. | |
| 95 bool CreateNewBookmarksFromURIList( | |
| 96 GtkSelectionData* selection_data, | |
| 97 BookmarkModel* model, | |
| 98 const BookmarkNode* parent, | |
| 99 int idx); | |
| 100 | |
| 101 // Add the "url\ntitle" combination into the model at the given position. | |
| 102 bool CreateNewBookmarkFromNetscapeURL( | |
| 103 GtkSelectionData* selection_data, | |
| 104 BookmarkModel* model, | |
| 105 const BookmarkNode* parent, | |
| 106 int idx); | |
| 107 | |
| 108 } // namespace bookmark_utils | |
| 109 | 11 |
| 110 #endif // CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ | 12 #endif // CHROME_BROWSER_GTK_BOOKMARK_UTILS_GTK_H_ |
| OLD | NEW |