| OLD | NEW | 
|---|
| 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_popup_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h" | 
| 6 | 6 | 
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <string> | 10 #include <string> | 
| 11 | 11 | 
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" | 
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" | 
| 14 #include "base/logging.h" | 14 #include "base/logging.h" | 
| 15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" | 
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" | 
| 17 #include "chrome/browser/autocomplete/autocomplete.h" | 17 #include "chrome/browser/autocomplete/autocomplete.h" | 
| 18 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 18 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 
| 19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 
| 20 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 20 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 
| 21 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" | 
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" | 
| 23 #include "chrome/browser/search_engines/template_url.h" | 23 #include "chrome/browser/search_engines/template_url.h" | 
| 24 #include "chrome/browser/search_engines/template_url_service.h" | 24 #include "chrome/browser/search_engines/template_url_service.h" | 
| 25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 
| 26 #include "chrome/browser/ui/gtk/gtk_util.h" | 26 #include "chrome/browser/ui/gtk/gtk_util.h" | 
| 27 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 27 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 
|  | 28 #include "chrome/common/chrome_notification_types.h" | 
| 28 #include "content/common/notification_service.h" | 29 #include "content/common/notification_service.h" | 
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" | 
| 30 #include "ui/base/gtk/gtk_windowing.h" | 31 #include "ui/base/gtk/gtk_windowing.h" | 
| 31 #include "ui/gfx/color_utils.h" | 32 #include "ui/gfx/color_utils.h" | 
| 32 #include "ui/gfx/font.h" | 33 #include "ui/gfx/font.h" | 
| 33 #include "ui/gfx/gtk_util.h" | 34 #include "ui/gfx/gtk_util.h" | 
| 34 #include "ui/gfx/rect.h" | 35 #include "ui/gfx/rect.h" | 
| 35 #include "ui/gfx/skia_utils_gtk.h" | 36 #include "ui/gfx/skia_utils_gtk.h" | 
| 36 | 37 | 
| 37 namespace { | 38 namespace { | 
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 304   g_signal_connect(window_, "motion-notify-event", | 305   g_signal_connect(window_, "motion-notify-event", | 
| 305                    G_CALLBACK(HandleMotionThunk), this); | 306                    G_CALLBACK(HandleMotionThunk), this); | 
| 306   g_signal_connect(window_, "button-press-event", | 307   g_signal_connect(window_, "button-press-event", | 
| 307                    G_CALLBACK(HandleButtonPressThunk), this); | 308                    G_CALLBACK(HandleButtonPressThunk), this); | 
| 308   g_signal_connect(window_, "button-release-event", | 309   g_signal_connect(window_, "button-release-event", | 
| 309                    G_CALLBACK(HandleButtonReleaseThunk), this); | 310                    G_CALLBACK(HandleButtonReleaseThunk), this); | 
| 310   g_signal_connect(window_, "expose-event", | 311   g_signal_connect(window_, "expose-event", | 
| 311                    G_CALLBACK(HandleExposeThunk), this); | 312                    G_CALLBACK(HandleExposeThunk), this); | 
| 312 | 313 | 
| 313   registrar_.Add(this, | 314   registrar_.Add(this, | 
| 314                  NotificationType::BROWSER_THEME_CHANGED, | 315                  chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 
| 315                  NotificationService::AllSources()); | 316                  NotificationService::AllSources()); | 
| 316   theme_service_->InitThemesFor(this); | 317   theme_service_->InitThemesFor(this); | 
| 317 | 318 | 
| 318   // TODO(erg): There appears to be a bug somewhere in something which shows | 319   // TODO(erg): There appears to be a bug somewhere in something which shows | 
| 319   // itself when we're in NX. Previously, we called | 320   // itself when we're in NX. Previously, we called | 
| 320   // gtk_util::ActAsRoundedWindow() to make this popup have rounded | 321   // gtk_util::ActAsRoundedWindow() to make this popup have rounded | 
| 321   // corners. This worked on the standard xorg server (both locally and | 322   // corners. This worked on the standard xorg server (both locally and | 
| 322   // remotely), but broke over NX. My current hypothesis is that it can't | 323   // remotely), but broke over NX. My current hypothesis is that it can't | 
| 323   // handle shaping top-level windows during an expose event, but I'm not sure | 324   // handle shaping top-level windows during an expose event, but I'm not sure | 
| 324   // how else to get accurate shaping information. | 325   // how else to get accurate shaping information. | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 381 | 382 | 
| 382 void OmniboxPopupViewGtk::PaintUpdatesNow() { | 383 void OmniboxPopupViewGtk::PaintUpdatesNow() { | 
| 383   // Paint our queued invalidations now, synchronously. | 384   // Paint our queued invalidations now, synchronously. | 
| 384   gdk_window_process_updates(window_->window, FALSE); | 385   gdk_window_process_updates(window_->window, FALSE); | 
| 385 } | 386 } | 
| 386 | 387 | 
| 387 void OmniboxPopupViewGtk::OnDragCanceled() { | 388 void OmniboxPopupViewGtk::OnDragCanceled() { | 
| 388   ignore_mouse_drag_ = true; | 389   ignore_mouse_drag_ = true; | 
| 389 } | 390 } | 
| 390 | 391 | 
| 391 void OmniboxPopupViewGtk::Observe(NotificationType type, | 392 void OmniboxPopupViewGtk::Observe(int type, | 
| 392                                   const NotificationSource& source, | 393                                   const NotificationSource& source, | 
| 393                                   const NotificationDetails& details) { | 394                                   const NotificationDetails& details) { | 
| 394   DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 395   DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); | 
| 395 | 396 | 
| 396   if (theme_service_->UsingNativeTheme()) { | 397   if (theme_service_->UsingNativeTheme()) { | 
| 397     gtk_util::UndoForceFontSize(window_); | 398     gtk_util::UndoForceFontSize(window_); | 
| 398 | 399 | 
| 399     border_color_ = theme_service_->GetBorderColor(); | 400     border_color_ = theme_service_->GetBorderColor(); | 
| 400 | 401 | 
| 401     gtk_util::GetTextColors( | 402     gtk_util::GetTextColors( | 
| 402         &background_color_, &selected_background_color_, | 403         &background_color_, &selected_background_color_, | 
| 403         &content_text_color_, &selected_content_text_color_); | 404         &content_text_color_, &selected_content_text_color_); | 
| 404 | 405 | 
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 680                           (text_width - actual_content_width - | 681                           (text_width - actual_content_width - | 
| 681                            (actual_description_width / PANGO_SCALE)), | 682                            (actual_description_width / PANGO_SCALE)), | 
| 682                       content_y, layout_); | 683                       content_y, layout_); | 
| 683     } | 684     } | 
| 684   } | 685   } | 
| 685 | 686 | 
| 686   g_object_unref(gc); | 687   g_object_unref(gc); | 
| 687 | 688 | 
| 688   return TRUE; | 689   return TRUE; | 
| 689 } | 690 } | 
| OLD | NEW | 
|---|