Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 8311014: GTK: add TEXT_URI_LIST as a data type for drags from the omnibox. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/ui/toolbar/toolbar_model.h" 26 #include "chrome/browser/ui/toolbar/toolbar_model.h"
27 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
28 #include "content/browser/tab_contents/tab_contents.h" 28 #include "content/browser/tab_contents/tab_contents.h"
29 #include "content/common/notification_service.h" 29 #include "content/common/notification_service.h"
30 #include "googleurl/src/gurl.h" 30 #include "googleurl/src/gurl.h"
31 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
32 #include "net/base/escape.h" 32 #include "net/base/escape.h"
33 #include "third_party/undoview/undo_view.h" 33 #include "third_party/undoview/undo_view.h"
34 #include "ui/base/animation/multi_animation.h" 34 #include "ui/base/animation/multi_animation.h"
35 #include "ui/base/dragdrop/drag_drop_types.h" 35 #include "ui/base/dragdrop/drag_drop_types.h"
36 #include "ui/base/dragdrop/gtk_dnd_util.h"
36 #include "ui/base/gtk/gtk_hig_constants.h" 37 #include "ui/base/gtk/gtk_hig_constants.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/gfx/color_utils.h" 40 #include "ui/gfx/color_utils.h"
40 #include "ui/gfx/font.h" 41 #include "ui/gfx/font.h"
41 #include "ui/gfx/gtk_util.h" 42 #include "ui/gfx/gtk_util.h"
42 #include "ui/gfx/skia_utils_gtk.h" 43 #include "ui/gfx/skia_utils_gtk.h"
43 44
44 #if defined(TOOLKIT_VIEWS) 45 #if defined(TOOLKIT_VIEWS)
45 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" 46 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 alignment_.Own(gtk_alignment_new(0., 0.5, 1.0, 0.0)); 238 alignment_.Own(gtk_alignment_new(0., 0.5, 1.0, 0.0));
238 gtk_widget_set_name(alignment_.get(), 239 gtk_widget_set_name(alignment_.get(),
239 "chrome-autocomplete-edit-view"); 240 "chrome-autocomplete-edit-view");
240 241
241 // The GtkTagTable and GtkTextBuffer are not initially unowned, so we have 242 // The GtkTagTable and GtkTextBuffer are not initially unowned, so we have
242 // our own reference when we create them, and we own them. Adding them to 243 // our own reference when we create them, and we own them. Adding them to
243 // the other objects adds a reference; it doesn't adopt them. 244 // the other objects adds a reference; it doesn't adopt them.
244 tag_table_ = gtk_text_tag_table_new(); 245 tag_table_ = gtk_text_tag_table_new();
245 text_buffer_ = gtk_text_buffer_new(tag_table_); 246 text_buffer_ = gtk_text_buffer_new(tag_table_);
246 g_object_set_data(G_OBJECT(text_buffer_), kOmniboxViewGtkKey, this); 247 g_object_set_data(G_OBJECT(text_buffer_), kOmniboxViewGtkKey, this);
248 GtkTargetList* targets = gtk_text_buffer_get_copy_target_list(text_buffer_);
249 gtk_target_list_add_uri_targets(targets, ui::TEXT_URI_LIST);
Evan Stade 2011/10/17 21:55:59 this isn't right, if I select just a small part of
SanjoyPal 2011/10/18 08:15:30 Yes, then it will be treated as TEXT_PLAIN. "Basi
Evan Stade 2011/10/18 16:27:31 we don't display the scheme in the http:// case. H
247 250
248 // We need to run this two handlers before undo manager's handlers, so that 251 // We need to run this two handlers before undo manager's handlers, so that
249 // text iterators modified by these handlers can be passed down to undo 252 // text iterators modified by these handlers can be passed down to undo
250 // manager's handlers. 253 // manager's handlers.
251 g_signal_connect(text_buffer_, "delete-range", 254 g_signal_connect(text_buffer_, "delete-range",
252 G_CALLBACK(&HandleDeleteRangeThunk), this); 255 G_CALLBACK(&HandleDeleteRangeThunk), this);
253 g_signal_connect(text_buffer_, "mark-set", 256 g_signal_connect(text_buffer_, "mark-set",
254 G_CALLBACK(&HandleMarkSetAlwaysThunk), this); 257 G_CALLBACK(&HandleMarkSetAlwaysThunk), this);
255 258
256 text_view_ = gtk_undo_view_new(text_buffer_); 259 text_view_ = gtk_undo_view_new(text_buffer_);
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 guint target_type, 1606 guint target_type,
1604 guint time) { 1607 guint time) {
1605 DCHECK(text_view_); 1608 DCHECK(text_view_);
1606 // If GTK put the normal textual version of the selection in our drag data, 1609 // If GTK put the normal textual version of the selection in our drag data,
1607 // put our doctored selection that might have the 'http://' prefix. Also, GTK 1610 // put our doctored selection that might have the 'http://' prefix. Also, GTK
1608 // is confused about signedness of its datatypes, leading to the weird switch 1611 // is confused about signedness of its datatypes, leading to the weird switch
1609 // statement (no set of casts fixes this). 1612 // statement (no set of casts fixes this).
1610 switch (target_type) { 1613 switch (target_type) {
1611 case GTK_TEXT_BUFFER_TARGET_INFO_TEXT: { 1614 case GTK_TEXT_BUFFER_TARGET_INFO_TEXT: {
1612 gtk_selection_data_set_text(selection_data, dragged_text_.c_str(), -1); 1615 gtk_selection_data_set_text(selection_data, dragged_text_.c_str(), -1);
1616 break;
1617 }
1618 case ui::TEXT_URI_LIST: {
1619 ui::WriteURLWithName(selection_data, GURL(dragged_text_),
1620 UTF8ToUTF16(dragged_text_), target_type);
Evan Stade 2011/10/17 21:55:59 the name should be the tab title
SanjoyPal 2011/10/18 08:15:30 The title is not being used in TEXT_URI_LIST case
Evan Stade 2011/10/18 16:27:31 well, don't use TEXT_URI_LIST then
1621 break;
1613 } 1622 }
1614 } 1623 }
1615 } 1624 }
1616 1625
1617 void OmniboxViewGtk::HandleDragBegin(GtkWidget* widget, 1626 void OmniboxViewGtk::HandleDragBegin(GtkWidget* widget,
1618 GdkDragContext* context) { 1627 GdkDragContext* context) {
1619 dragged_text_ = selected_text_; 1628 dragged_text_ = selected_text_;
1620 } 1629 }
1621 1630
1622 void OmniboxViewGtk::HandleDragEnd(GtkWidget* widget, 1631 void OmniboxViewGtk::HandleDragEnd(GtkWidget* widget,
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 // baseline, so we need to move the |instant_view_| down to make sure it 2361 // baseline, so we need to move the |instant_view_| down to make sure it
2353 // has the same baseline as the |text_view_|. 2362 // has the same baseline as the |text_view_|.
2354 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2363 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2355 int height; 2364 int height;
2356 pango_layout_get_size(layout, NULL, &height); 2365 pango_layout_get_size(layout, NULL, &height);
2357 PangoLayoutIter* iter = pango_layout_get_iter(layout); 2366 PangoLayoutIter* iter = pango_layout_get_iter(layout);
2358 int baseline = pango_layout_iter_get_baseline(iter); 2367 int baseline = pango_layout_iter_get_baseline(iter);
2359 pango_layout_iter_free(iter); 2368 pango_layout_iter_free(iter);
2360 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2369 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2361 } 2370 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698