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/gtk_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cstdarg> | 10 #include <cstdarg> |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/environment.h" | 13 #include "base/environment.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/nix/xdg_util.h" | 16 #include "base/nix/xdg_util.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 19 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
20 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 20 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
21 #include "chrome/browser/autocomplete/autocomplete_match.h" | 21 #include "chrome/browser/autocomplete/autocomplete_match.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/profiles/profile_info_cache.h" | 24 #include "chrome/browser/profiles/profile_info_cache.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_iterator.h" |
| 28 #include "chrome/browser/ui/browser_list_impl.h" |
28 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
29 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 30 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
30 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 31 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 32 #include "chrome/browser/ui/host_desktop.h" |
31 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
32 #include "grit/chrome_unscaled_resources.h" | 34 #include "grit/chrome_unscaled_resources.h" |
33 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
34 #include "ui/base/gtk/gtk_compat.h" | 36 #include "ui/base/gtk/gtk_compat.h" |
35 #include "ui/base/gtk/gtk_hig_constants.h" | 37 #include "ui/base/gtk/gtk_hig_constants.h" |
36 #include "ui/base/gtk/gtk_screen_util.h" | 38 #include "ui/base/gtk/gtk_screen_util.h" |
37 #include "ui/base/gtk/menu_label_accelerator_util.h" | 39 #include "ui/base/gtk/menu_label_accelerator_util.h" |
38 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
40 #include "ui/base/text/text_elider.h" | 42 #include "ui/base/text/text_elider.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 height == -1 ? -1 : std::max(height, requisition.height)); | 407 height == -1 ? -1 : std::max(height, requisition.height)); |
406 } | 408 } |
407 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); | 409 gtk_window_set_resizable(window, resizable ? TRUE : FALSE); |
408 } | 410 } |
409 | 411 |
410 void MakeAppModalWindowGroup() { | 412 void MakeAppModalWindowGroup() { |
411 // Older versions of GTK+ don't give us gtk_window_group_list() which is what | 413 // Older versions of GTK+ don't give us gtk_window_group_list() which is what |
412 // we need to add current non-browser modal dialogs to the list. If | 414 // we need to add current non-browser modal dialogs to the list. If |
413 // we have 2.14+ we can do things the correct way. | 415 // we have 2.14+ we can do things the correct way. |
414 GtkWindowGroup* window_group = gtk_window_group_new(); | 416 GtkWindowGroup* window_group = gtk_window_group_new(); |
415 for (BrowserList::const_iterator it = BrowserList::begin(); | 417 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
416 it != BrowserList::end(); ++it) { | |
417 // List all windows in this current group | 418 // List all windows in this current group |
418 GtkWindowGroup* old_group = | 419 GtkWindowGroup* old_group = |
419 gtk_window_get_group((*it)->window()->GetNativeWindow()); | 420 gtk_window_get_group((*it)->window()->GetNativeWindow()); |
420 | 421 |
421 GList* all_windows = gtk_window_group_list_windows(old_group); | 422 GList* all_windows = gtk_window_group_list_windows(old_group); |
422 for (GList* window = all_windows; window; window = window->next) { | 423 for (GList* window = all_windows; window; window = window->next) { |
423 gtk_window_group_add_window(window_group, GTK_WINDOW(window->data)); | 424 gtk_window_group_add_window(window_group, GTK_WINDOW(window->data)); |
424 } | 425 } |
425 g_list_free(all_windows); | 426 g_list_free(all_windows); |
426 } | 427 } |
427 g_object_unref(window_group); | 428 g_object_unref(window_group); |
428 } | 429 } |
429 | 430 |
430 void AppModalDismissedUngroupWindows() { | 431 void AppModalDismissedUngroupWindows() { |
431 if (BrowserList::begin() != BrowserList::end()) { | 432 // GTK only has the native desktop. |
| 433 const chrome::BrowserListImpl* native_browser_list = |
| 434 chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 435 if (!native_browser_list->empty()) { |
432 std::vector<GtkWindow*> transient_windows; | 436 std::vector<GtkWindow*> transient_windows; |
433 | 437 |
434 // All windows should be part of one big modal group right now. | 438 // All windows should be part of one big modal group right now. |
435 GtkWindowGroup* window_group = gtk_window_get_group( | 439 GtkWindowGroup* window_group = gtk_window_get_group( |
436 (*BrowserList::begin())->window()->GetNativeWindow()); | 440 native_browser_list->get(0)->window()->GetNativeWindow()); |
437 GList* windows = gtk_window_group_list_windows(window_group); | 441 GList* windows = gtk_window_group_list_windows(window_group); |
438 | 442 |
439 for (GList* item = windows; item; item = item->next) { | 443 for (GList* item = windows; item; item = item->next) { |
440 GtkWindow* window = GTK_WINDOW(item->data); | 444 GtkWindow* window = GTK_WINDOW(item->data); |
441 GtkWindow* transient_for = gtk_window_get_transient_for(window); | 445 GtkWindow* transient_for = gtk_window_get_transient_for(window); |
442 if (transient_for) { | 446 if (transient_for) { |
443 transient_windows.push_back(window); | 447 transient_windows.push_back(window); |
444 } else { | 448 } else { |
445 GtkWindowGroup* window_group = gtk_window_group_new(); | 449 GtkWindowGroup* window_group = gtk_window_group_new(); |
446 gtk_window_group_add_window(window_group, window); | 450 gtk_window_group_add_window(window_group, window); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 if (gtk_window_get_modal(GTK_WINDOW(dialog))) { | 990 if (gtk_window_get_modal(GTK_WINDOW(dialog))) { |
987 // Work around a KDE 3 window manager bug. | 991 // Work around a KDE 3 window manager bug. |
988 scoped_ptr<base::Environment> env(base::Environment::Create()); | 992 scoped_ptr<base::Environment> env(base::Environment::Create()); |
989 if (base::nix::DESKTOP_ENVIRONMENT_KDE3 == | 993 if (base::nix::DESKTOP_ENVIRONMENT_KDE3 == |
990 base::nix::GetDesktopEnvironment(env.get())) | 994 base::nix::GetDesktopEnvironment(env.get())) |
991 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); | 995 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); |
992 } | 996 } |
993 } | 997 } |
994 | 998 |
995 } // namespace gtk_util | 999 } // namespace gtk_util |
OLD | NEW |