| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 12 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/theme_properties.h" | 15 #include "chrome/browser/themes/theme_properties.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 16 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 18 #include "chrome/browser/ui/gtk/gtk_util.h" | 18 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 20 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 21 #include "grit/ui_strings.h" | 21 #include "grit/ui_strings.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 #include "ui/base/dragdrop/gtk_dnd_util.h" | 23 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 24 #include "ui/base/gtk/gtk_hig_constants.h" | 24 #include "ui/base/gtk/gtk_hig_constants.h" |
| 25 #include "ui/base/gtk/gtk_screen_util.h" | 25 #include "ui/base/gtk/gtk_screen_util.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/canvas_skia_paint.h" | 28 #include "ui/gfx/canvas_skia_paint.h" |
| 29 #include "ui/gfx/font.h" | 29 #include "ui/gfx/font_list.h" |
| 30 #include "ui/gfx/geometry/rect.h" |
| 30 #include "ui/gfx/image/image.h" | 31 #include "ui/gfx/image/image.h" |
| 31 #include "ui/gfx/text_elider.h" | 32 #include "ui/gfx/text_elider.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 // Spacing between the favicon and the text. | 36 // Spacing between the favicon and the text. |
| 36 const int kBarButtonPadding = 4; | 37 const int kBarButtonPadding = 4; |
| 37 | 38 |
| 38 // Used in gtk_selection_data_set(). (I assume from this parameter that gtk has | 39 // Used in gtk_selection_data_set(). (I assume from this parameter that gtk has |
| 39 // to some really exotic hardware...) | 40 // to some really exotic hardware...) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 cairo_paint(cr); | 145 cairo_paint(cr); |
| 145 cairo_destroy(cr); | 146 cairo_destroy(cr); |
| 146 | 147 |
| 147 GtkAllocation allocation; | 148 GtkAllocation allocation; |
| 148 gtk_widget_get_allocation(sender, &allocation); | 149 gtk_widget_get_allocation(sender, &allocation); |
| 149 | 150 |
| 150 // Paint the title text. | 151 // Paint the title text. |
| 151 gfx::CanvasSkiaPaint canvas(event, false); | 152 gfx::CanvasSkiaPaint canvas(event, false); |
| 152 int text_x = gdk_pixbuf_get_width(data->favicon) + kBarButtonPadding; | 153 int text_x = gdk_pixbuf_get_width(data->favicon) + kBarButtonPadding; |
| 153 int text_width = allocation.width - text_x; | 154 int text_width = allocation.width - text_x; |
| 154 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 155 const gfx::Rect rect(text_x, 0, text_width, allocation.height); |
| 155 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 156 canvas.DrawStringRectWithFlags(data->text, gfx::FontList(), data->text_color, |
| 156 canvas.DrawStringInt(data->text, base_font, data->text_color, | 157 rect, gfx::Canvas::NO_SUBPIXEL_RENDERING); |
| 157 text_x, 0, text_width, allocation.height, | |
| 158 gfx::Canvas::NO_SUBPIXEL_RENDERING); | |
| 159 | 158 |
| 160 return TRUE; | 159 return TRUE; |
| 161 } | 160 } |
| 162 | 161 |
| 163 void OnDragIconDestroy(GtkWidget* drag_icon, DragRepresentationData* data) { | 162 void OnDragIconDestroy(GtkWidget* drag_icon, DragRepresentationData* data) { |
| 164 g_object_unref(drag_icon); | 163 g_object_unref(drag_icon); |
| 165 delete data; | 164 delete data; |
| 166 } | 165 } |
| 167 | 166 |
| 168 } // namespace | 167 } // namespace |
| (...skipping 29 matching lines...) Expand all Loading... |
| 198 if (ui::IsScreenComposited() && | 197 if (ui::IsScreenComposited() && |
| 199 gtk_util::AddWindowAlphaChannel(window)) { | 198 gtk_util::AddWindowAlphaChannel(window)) { |
| 200 DragRepresentationData* data = new DragRepresentationData( | 199 DragRepresentationData* data = new DragRepresentationData( |
| 201 pixbuf, title, | 200 pixbuf, title, |
| 202 provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); | 201 provider->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); |
| 203 g_signal_connect(window, "expose-event", G_CALLBACK(OnDragIconExpose), | 202 g_signal_connect(window, "expose-event", G_CALLBACK(OnDragIconExpose), |
| 204 data); | 203 data); |
| 205 g_object_ref(window); | 204 g_object_ref(window); |
| 206 g_signal_connect(window, "destroy", G_CALLBACK(OnDragIconDestroy), data); | 205 g_signal_connect(window, "destroy", G_CALLBACK(OnDragIconDestroy), data); |
| 207 | 206 |
| 208 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 209 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | |
| 210 gtk_widget_set_size_request(window, kDragRepresentationWidth, | 207 gtk_widget_set_size_request(window, kDragRepresentationWidth, |
| 211 base_font.GetHeight()); | 208 gfx::FontList().GetHeight()); |
| 212 } else { | 209 } else { |
| 213 if (!provider->UsingNativeTheme()) { | 210 if (!provider->UsingNativeTheme()) { |
| 214 GdkColor color = provider->GetGdkColor( | 211 GdkColor color = provider->GetGdkColor( |
| 215 ThemeProperties::COLOR_TOOLBAR); | 212 ThemeProperties::COLOR_TOOLBAR); |
| 216 gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color); | 213 gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color); |
| 217 } | 214 } |
| 218 gtk_widget_realize(window); | 215 gtk_widget_realize(window); |
| 219 | 216 |
| 220 GtkWidget* frame = gtk_frame_new(NULL); | 217 GtkWidget* frame = gtk_frame_new(NULL); |
| 221 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); | 218 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 return net::GetSuggestedFilename(url, | 481 return net::GetSuggestedFilename(url, |
| 485 std::string(), | 482 std::string(), |
| 486 std::string(), | 483 std::string(), |
| 487 std::string(), | 484 std::string(), |
| 488 std::string(), | 485 std::string(), |
| 489 std::string()); | 486 std::string()); |
| 490 } else { | 487 } else { |
| 491 return l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); | 488 return l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); |
| 492 } | 489 } |
| 493 } | 490 } |
| OLD | NEW |