summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/task_manager_gtk.cc
diff options
context:
space:
mode:
authorderat@google.com <derat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 21:52:28 +0000
committerderat@google.com <derat@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 21:52:28 +0000
commita5eb6fc090ff177d70e886b263f02055aedd04dc (patch)
tree1167f8ea3616706d118df8c1a5f22f30d2bae3c5 /chrome/browser/gtk/task_manager_gtk.cc
parent7d1e0d0bd5b0a3d56471bbfa7542aff36607463d (diff)
downloadchromium_src-a5eb6fc090ff177d70e886b263f02055aedd04dc.zip
chromium_src-a5eb6fc090ff177d70e886b263f02055aedd04dc.tar.gz
chromium_src-a5eb6fc090ff177d70e886b263f02055aedd04dc.tar.bz2
Linux: Save and restore bookmark manager and task manager window size.
To test, did the following under Metacity/GNOME: - remove window_placement prefs from "Local State" file - start chrome - open bookmark manager with Ctrl-Shift-B - resize window to be small and close it - reopen bookmark manager and confirm that its window is the same size as when closed - maximize bookmark manager and close it - reopen bookmark manager and confirm that it's still small - minimize bookmark manager before closing it; confirm that the size remains the same - restart chrome and confirm that the window size is still saved - repeat the above tests with the task manager (which is a bit quicker, since it doesn't allow maximizing or minimizing) BUG=15488 TEST=see above Review URL: http://codereview.chromium.org/160330 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22001 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/task_manager_gtk.cc')
-rw-r--r--chrome/browser/gtk/task_manager_gtk.cc48
1 files changed, 47 insertions, 1 deletions
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc
index 012705e..5e55a2af 100644
--- a/chrome/browser/gtk/task_manager_gtk.cc
+++ b/chrome/browser/gtk/task_manager_gtk.cc
@@ -11,8 +11,11 @@
#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
#include "base/logging.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/common/gtk_util.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -360,12 +363,37 @@ void TaskManagerGtk::Init() {
gtk_container_add(GTK_CONTAINER(scrolled), treeview_);
- gtk_window_resize(GTK_WINDOW(dialog_), kDefaultWidth, kDefaultHeight);
+ SetInitialDialogSize();
gtk_widget_show_all(dialog_);
model_->AddObserver(this);
}
+void TaskManagerGtk::SetInitialDialogSize() {
+ // If we previously saved the dialog's bounds, use them.
+ if (g_browser_process->local_state()) {
+ const DictionaryValue* placement_pref =
+ g_browser_process->local_state()->GetDictionary(
+ prefs::kTaskManagerWindowPlacement);
+ int top = 0, left = 0, bottom = 1, right = 1;
+ if (placement_pref &&
+ placement_pref->GetInteger(L"top", &top) &&
+ placement_pref->GetInteger(L"left", &left) &&
+ placement_pref->GetInteger(L"bottom", &bottom) &&
+ placement_pref->GetInteger(L"right", &right)) {
+ gtk_window_resize(GTK_WINDOW(dialog_),
+ std::max(1, right - left),
+ std::max(1, bottom - top));
+ return;
+ }
+ }
+
+ // Otherwise, just set a default size (GTK will override this if it's not
+ // large enough to hold the window's contents).
+ gtk_window_set_default_size(
+ GTK_WINDOW(dialog_), kDefaultWidth, kDefaultHeight);
+}
+
void TaskManagerGtk::ConnectAccelerators() {
GtkAccelGroup* accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(dialog_), accel_group);
@@ -510,6 +538,24 @@ void TaskManagerGtk::ActivateFocusedTab() {
void TaskManagerGtk::OnResponse(GtkDialog* dialog, gint response_id,
TaskManagerGtk* task_manager) {
if (response_id == GTK_RESPONSE_DELETE_EVENT) {
+ // Store the dialog's size so we can restore it the next time it's opened.
+ if (g_browser_process->local_state()) {
+ gint x = 0, y = 0, width = 1, height = 1;
+ gtk_window_get_position(GTK_WINDOW(dialog), &x, &y);
+ gtk_window_get_size(GTK_WINDOW(dialog), &width, &height);
+
+ DictionaryValue* placement_pref =
+ g_browser_process->local_state()->GetMutableDictionary(
+ prefs::kTaskManagerWindowPlacement);
+ // Note that we store left/top for consistency with Windows, but that we
+ // *don't* restore them.
+ placement_pref->SetInteger(L"left", x);
+ placement_pref->SetInteger(L"top", y);
+ placement_pref->SetInteger(L"right", x + width);
+ placement_pref->SetInteger(L"bottom", y + height);
+ placement_pref->SetBoolean(L"maximized", false);
+ }
+
instance_ = NULL;
delete task_manager;
} else if (response_id == kTaskManagerResponseKill) {