| Index: chrome/browser/gtk/api_permissions_panel_gtk.cc
|
| ===================================================================
|
| --- chrome/browser/gtk/api_permissions_panel_gtk.cc (revision 0)
|
| +++ chrome/browser/gtk/api_permissions_panel_gtk.cc (revision 0)
|
| @@ -0,0 +1,557 @@
|
| +// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/gtk/api_permissions_panel_gtk.h"
|
| +
|
| +#include <gdk/gdkkeysyms.h>
|
| +
|
| +#include <algorithm>
|
| +#include <vector>
|
| +
|
| +#include "app/l10n_util.h"
|
| +#include "app/resource_bundle.h"
|
| +#include "base/gfx/gtk_util.h"
|
| +#include "base/logging.h"
|
| +#include "chrome/browser/browser_list.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/browser_window.h"
|
| +#include "chrome/browser/gtk/custom_button.h"
|
| +#include "chrome/browser/gtk/gtk_chrome_button.h"
|
| +#include "chrome/browser/gtk/gtk_chrome_link_button.h"
|
| +#include "chrome/browser/gtk/menu_gtk.h"
|
| +#include "chrome/browser/tab_contents/tab_contents.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"
|
| +#include "grit/theme_resources.h"
|
| +#include "webkit/chaos/GeolocationPowerbox.h"
|
| +
|
| +namespace {
|
| +
|
| +// The task manager window default size.
|
| +const int kDefaultWidth = 460;
|
| +const int kDefaultHeight = 270;
|
| +
|
| +// The resource id for the 'End process' button.
|
| +const gint kApiPermissionsPanelResponseKill = 1;
|
| +
|
| +enum ApiPermissionsPanelColumn {
|
| + kApiPermissionsPanelIcon,
|
| + kApiPermissionsPanelPage,
|
| + kApiPermissionsPanelPermissions,
|
| + kApiPermissionsPanelColumnCount,
|
| +};
|
| +
|
| +ApiPermissionsPanelColumn ApiPermissionsPanelResourceIDToColumnID(int id) {
|
| + switch (id) {
|
| + case IDS_API_PERMISSIONS_PANEL_PAGE_COLUMN:
|
| + return kApiPermissionsPanelPage;
|
| + case IDS_API_PERMISSIONS_PANEL_PERMISSIONS_COLUMN:
|
| + return kApiPermissionsPanelPermissions;
|
| + default:
|
| + NOTREACHED();
|
| + return static_cast<ApiPermissionsPanelColumn>(-1);
|
| + }
|
| +}
|
| +
|
| +int ApiPermissionsPanelColumnIDToResourceID(int id) {
|
| + switch (id) {
|
| + case kApiPermissionsPanelPage:
|
| + return IDS_API_PERMISSIONS_PANEL_PAGE_COLUMN;
|
| + case kApiPermissionsPanelPermissions:
|
| + return IDS_API_PERMISSIONS_PANEL_PERMISSIONS_COLUMN;
|
| + default:
|
| + NOTREACHED();
|
| + return -1;
|
| + }
|
| +}
|
| +
|
| +// Should be used for all gtk_tree_view functions that require a column index on
|
| +// input.
|
| +//
|
| +// We need colid - 1 because the gtk_tree_view function is asking for the
|
| +// column index, not the column id, and both kApiPermissionsPanelIcon and
|
| +// kApiPermissionsPanelPage are in the same column index, so all column IDs are off by
|
| +// one.
|
| +int TreeViewColumnIndexFromID(ApiPermissionsPanelColumn colid) {
|
| + return colid - 1;
|
| +}
|
| +
|
| +// Shows or hides a treeview column.
|
| +void TreeViewColumnSetVisible(GtkWidget* treeview, ApiPermissionsPanelColumn colid,
|
| + bool visible) {
|
| + GtkTreeViewColumn* column = gtk_tree_view_get_column(
|
| + GTK_TREE_VIEW(treeview), TreeViewColumnIndexFromID(colid));
|
| + gtk_tree_view_column_set_visible(column, visible);
|
| +}
|
| +
|
| +bool TreeViewColumnIsVisible(GtkWidget* treeview, ApiPermissionsPanelColumn colid) {
|
| + GtkTreeViewColumn* column = gtk_tree_view_get_column(
|
| + GTK_TREE_VIEW(treeview), TreeViewColumnIndexFromID(colid));
|
| + return gtk_tree_view_column_get_visible(column);
|
| +}
|
| +
|
| +void TreeViewInsertColumnWithPixbuf(GtkWidget* treeview, int resid) {
|
| + int colid = ApiPermissionsPanelResourceIDToColumnID(resid);
|
| + GtkTreeViewColumn* column = gtk_tree_view_column_new();
|
| + gtk_tree_view_column_set_title(column,
|
| + l10n_util::GetStringUTF8(resid).c_str());
|
| + GtkCellRenderer* image_renderer = gtk_cell_renderer_pixbuf_new();
|
| + gtk_tree_view_column_pack_start(column, image_renderer, FALSE);
|
| + gtk_tree_view_column_add_attribute(column, image_renderer,
|
| + "pixbuf", kApiPermissionsPanelIcon);
|
| + GtkCellRenderer* text_renderer = gtk_cell_renderer_text_new();
|
| + gtk_tree_view_column_pack_start(column, text_renderer, TRUE);
|
| + gtk_tree_view_column_add_attribute(column, text_renderer, "text", colid);
|
| + gtk_tree_view_column_set_resizable(column, TRUE);
|
| + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
| +}
|
| +
|
| +// Inserts a column with a column id of |colid| and |name|.
|
| +void TreeViewInsertColumnWithName(GtkWidget* treeview,
|
| + ApiPermissionsPanelColumn colid, const char* name) {
|
| + GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
|
| + gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1,
|
| + name, renderer,
|
| + "text", colid,
|
| + NULL);
|
| + GtkTreeViewColumn* column = gtk_tree_view_get_column(
|
| + GTK_TREE_VIEW(treeview), TreeViewColumnIndexFromID(colid));
|
| + gtk_tree_view_column_set_resizable(column, TRUE);
|
| +}
|
| +
|
| +// Loads the column name from |resid| and uses the corresponding
|
| +// ApiPermissionsPanelColumn value as the column id to insert into the treeview.
|
| +void TreeViewInsertColumn(GtkWidget* treeview, int resid) {
|
| + TreeViewInsertColumnWithName(treeview,
|
| + ApiPermissionsPanelResourceIDToColumnID(resid),
|
| + l10n_util::GetStringUTF8(resid).c_str());
|
| +}
|
| +
|
| +// Get the row number corresponding to |path|.
|
| +gint GetRowNumForPath(GtkTreePath* path) {
|
| + gint* indices = gtk_tree_path_get_indices(path);
|
| + if (!indices) {
|
| + NOTREACHED();
|
| + return -1;
|
| + }
|
| + return indices[0];
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +ApiPermissionsPanelGtk::ApiPermissionsPanelGtk()
|
| + : //task_manager_(ApiPermissionsPanel::GetInstance()),
|
| + //model_(ApiPermissionsPanel::GetInstance()->model()),
|
| + dialog_(NULL),
|
| + treeview_(NULL),
|
| + site_list_(NULL),
|
| + site_count_(0) {
|
| + Init();
|
| +}
|
| +
|
| +// static
|
| +ApiPermissionsPanelGtk* ApiPermissionsPanelGtk::instance_ = NULL;
|
| +
|
| +ApiPermissionsPanelGtk::~ApiPermissionsPanelGtk() {
|
| + //task_manager_->OnWindowClosed();
|
| + //model_->RemoveObserver(this);
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ApiPermissionsPanelGtk, ApiPermissionsPanelModelObserver implementation:
|
| +/*
|
| +void ApiPermissionsPanelGtk::OnModelChanged() {
|
| + // Nothing to do.
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::OnItemsChanged(int start, int length) {
|
| + GtkTreeIter iter;
|
| + gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(process_list_), &iter,
|
| + NULL, start);
|
| +
|
| + for (int i = start; i < start + length; i++) {
|
| + SetRowDataFromModel(i, &iter);
|
| + gtk_tree_model_iter_next(GTK_TREE_MODEL(process_list_), &iter);
|
| + }
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::OnItemsAdded(int start, int length) {
|
| + GtkTreeIter iter;
|
| + if (start == 0) {
|
| + gtk_list_store_prepend(process_list_, &iter);
|
| + } else if (start >= process_count_) {
|
| + gtk_list_store_append(process_list_, &iter);
|
| + } else {
|
| + GtkTreeIter sibling;
|
| + gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(process_list_), &sibling,
|
| + NULL, start);
|
| + gtk_list_store_insert_before(process_list_, &iter, &sibling);
|
| + }
|
| +
|
| + SetRowDataFromModel(start, &iter);
|
| +
|
| + for (int i = start + 1; i < start + length; i++) {
|
| + gtk_list_store_insert_after(process_list_, &iter, &iter);
|
| + SetRowDataFromModel(i, &iter);
|
| + }
|
| +
|
| + process_count_ += length;
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::OnItemsRemoved(int start, int length) {
|
| + GtkTreeIter iter;
|
| + gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(process_list_), &iter,
|
| + NULL, start);
|
| +
|
| + for (int i = 0; i < length; i++) {
|
| + // |iter| is moved to the next valid node when the current node is removed.
|
| + gtk_list_store_remove(process_list_, &iter);
|
| + }
|
| +
|
| + process_count_ -= length;
|
| +}
|
| +*/
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ApiPermissionsPanelGtk, public:
|
| +
|
| +// static
|
| +void ApiPermissionsPanelGtk::Show() {
|
| + if (instance_) {
|
| + // If there's a Task manager window open already, just activate it.
|
| + gtk_window_present(GTK_WINDOW(instance_->dialog_));
|
| + } else {
|
| + instance_ = new ApiPermissionsPanelGtk;
|
| + //instance_->model_->StartUpdating();
|
| + }
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ApiPermissionsPanelGtk, private:
|
| +
|
| +void ApiPermissionsPanelGtk::Init() {
|
| + dialog_ = gtk_dialog_new_with_buttons(
|
| + l10n_util::GetStringUTF8(IDS_API_PERMISSIONS_PANEL_TITLE).c_str(),
|
| + // Task Manager window is shared between all browsers.
|
| + NULL,
|
| + GTK_DIALOG_NO_SEPARATOR,
|
| + l10n_util::GetStringUTF8(IDS_API_PERMISSIONS_PANEL_KILL).c_str(),
|
| + kApiPermissionsPanelResponseKill,
|
| + NULL);
|
| +
|
| + /*
|
| + GtkWidget* link = gtk_chrome_link_button_new(
|
| + l10n_util::GetStringUTF8(IDS_API_PERMISSIONS_PANEL_ABOUT_MEMORY_LINK).c_str());
|
| + gtk_dialog_add_action_widget(GTK_DIALOG(dialog_), link,
|
| + kApiPermissionsPanelAboutMemoryLink);
|
| +
|
| + // Setting the link widget to secondary positions the button on the left side
|
| + // of the action area (vice versa for RTL layout).
|
| + gtk_button_box_set_child_secondary(
|
| + GTK_BUTTON_BOX(GTK_DIALOG(dialog_)->action_area), link, TRUE);
|
| + */
|
| + ConnectAccelerators();
|
| +
|
| + gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox),
|
| + gtk_util::kContentAreaSpacing);
|
| + gtk_util::SetWindowIcon(GTK_WINDOW(dialog_));
|
| +
|
| + g_signal_connect(G_OBJECT(dialog_), "response", G_CALLBACK(OnResponse), this);
|
| + g_signal_connect(G_OBJECT(dialog_), "button-release-event",
|
| + G_CALLBACK(OnButtonReleaseEvent), this);
|
| + gtk_widget_add_events(dialog_,
|
| + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
|
| +
|
| + // Wrap the treeview widget in a scrolled window in order to have a frame.
|
| + GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL);
|
| + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
|
| + GTK_SHADOW_ETCHED_IN);
|
| + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
|
| + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
| +
|
| + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), scrolled);
|
| +
|
| + CreateApiPermissionsPanelTreeview();
|
| + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview_), FALSE);
|
| + gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview_), FALSE);
|
| + gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(treeview_),
|
| + GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
|
| + g_signal_connect(G_OBJECT(treeview_), "button-press-event",
|
| + G_CALLBACK(OnButtonPressEvent), this);
|
| + gtk_widget_add_events(treeview_,
|
| + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
|
| +
|
| + // Hide some columns by default
|
| + /*
|
| + TreeViewColumnSetVisible(treeview_, kApiPermissionsPanelSharedMem, false);
|
| + TreeViewColumnSetVisible(treeview_, kApiPermissionsPanelPrivateMem, false);
|
| + TreeViewColumnSetVisible(treeview_, kApiPermissionsPanelProcessID, false);
|
| + TreeViewColumnSetVisible(treeview_, kApiPermissionsPanelGoatsTeleported, false);
|
| + */
|
| +
|
| + // |selection| is owned by |treeview_|.
|
| + GtkTreeSelection* selection = gtk_tree_view_get_selection(
|
| + GTK_TREE_VIEW(treeview_));
|
| + gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
|
| + g_signal_connect(G_OBJECT(selection), "changed",
|
| + G_CALLBACK(OnSelectionChanged), this);
|
| +
|
| + gtk_container_add(GTK_CONTAINER(scrolled), treeview_);
|
| +
|
| + GtkTreeIter iter;
|
| + gtk_list_store_prepend(site_list_, &iter);
|
| + SetRowDataFromModel(0, &iter);
|
| + // FIXME(benl) pass this down into SetRowDataFromModel.
|
| + std::vector<WebCore::GeolocationBrowserPowerbox::DecisionPair> decisions
|
| + = WebCore::GeolocationBrowserPowerbox::powerbox.decisions();
|
| + for (unsigned i = 1; i < decisions.size(); i++) {
|
| + gtk_list_store_insert_after(site_list_, &iter, &iter);
|
| + SetRowDataFromModel(i, &iter);
|
| + }
|
| +
|
| + site_count_ += decisions.size();
|
| +
|
| + SetInitialDialogSize();
|
| + gtk_widget_show_all(dialog_);
|
| +
|
| + //model_->AddObserver(this);
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::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::kApiPermissionsPanelWindowPlacement);
|
| + 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 ApiPermissionsPanelGtk::ConnectAccelerators() {
|
| + GtkAccelGroup* accel_group = gtk_accel_group_new();
|
| + gtk_window_add_accel_group(GTK_WINDOW(dialog_), accel_group);
|
| +
|
| + // Drop the initial ref on |accel_group| so |dialog_| will own it.
|
| + g_object_unref(accel_group);
|
| +
|
| + gtk_accel_group_connect(accel_group,
|
| + GDK_w, GDK_CONTROL_MASK, GtkAccelFlags(0),
|
| + g_cclosure_new(G_CALLBACK(OnGtkAccelerator),
|
| + this, NULL));
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::CreateApiPermissionsPanelTreeview() {
|
| + treeview_ = gtk_tree_view_new();
|
| +
|
| + TreeViewInsertColumnWithPixbuf(treeview_,
|
| + IDS_API_PERMISSIONS_PANEL_PAGE_COLUMN);
|
| + TreeViewInsertColumn(treeview_, IDS_API_PERMISSIONS_PANEL_PERMISSIONS_COLUMN);
|
| +
|
| +
|
| + site_list_ = gtk_list_store_new(kApiPermissionsPanelColumnCount,
|
| + GDK_TYPE_PIXBUF, G_TYPE_STRING,
|
| + G_TYPE_STRING);
|
| + // gtk_chrome_link_button_get_type());
|
| +
|
| + gtk_tree_view_set_model(GTK_TREE_VIEW(treeview_),
|
| + GTK_TREE_MODEL(site_list_));
|
| + g_object_unref(site_list_);
|
| +}
|
| +
|
| +std::string ApiPermissionsPanelGtk::GetModelText(int row, int col_id) {
|
| + // FIXME(benl): inefficient
|
| + std::vector<WebCore::GeolocationBrowserPowerbox::DecisionPair> decisions
|
| + = WebCore::GeolocationBrowserPowerbox::powerbox.decisions();
|
| + switch (col_id) {
|
| + case IDS_API_PERMISSIONS_PANEL_PAGE_COLUMN:
|
| + return decisions[row].first.spec();
|
| + case IDS_API_PERMISSIONS_PANEL_PERMISSIONS_COLUMN:
|
| + return WebCore::GeolocationBrowserPowerbox::powerbox.decisionAsString(
|
| + decisions[row].second);
|
| + default:
|
| + return WideToUTF8(std::wstring(L"Hey!"));
|
| + }
|
| +}
|
| +
|
| +GdkPixbuf* ApiPermissionsPanelGtk::GetModelIcon(int row) {
|
| + SkBitmap *icon = ResourceBundle::GetSharedInstance().GetBitmapNamed(
|
| + IDR_INFOBAR_RESTORE_SESSION);
|
| + return gfx::GdkPixbufFromSkBitmap(icon);
|
| +
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::SetRowDataFromModel(int row, GtkTreeIter* iter) {
|
| + GdkPixbuf* icon = GetModelIcon(row);
|
| + std::string page = GetModelText(row, IDS_API_PERMISSIONS_PANEL_PAGE_COLUMN);
|
| + std::string permissions =
|
| + GetModelText(row, IDS_API_PERMISSIONS_PANEL_PERMISSIONS_COLUMN);
|
| + gtk_list_store_set(site_list_, iter,
|
| + kApiPermissionsPanelIcon, icon,
|
| + kApiPermissionsPanelPage, page.c_str(),
|
| + kApiPermissionsPanelPermissions, permissions.c_str(),
|
| + -1);
|
| + g_object_unref(icon);
|
| +}
|
| +
|
| +// FIXME(benl): we should probably only be looking for browsers with
|
| +// the current profile.
|
| +static TabContents *FindTabWithURL(const GURL &url) {
|
| + for (BrowserList::const_iterator b = BrowserList::begin() ;
|
| + b != BrowserList::end() ; ++b) {
|
| + Browser *browser = *b;
|
| + for(int n = 0 ; n < browser->tab_count() ; ++n) {
|
| + TabContents *tab = browser->GetTabContentsAt(n);
|
| + if (tab->GetURL() == url)
|
| + return tab;
|
| + }
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| +void ApiPermissionsPanelGtk::ActivateFocusedTab() {
|
| + GtkTreeSelection* selection = gtk_tree_view_get_selection(
|
| + GTK_TREE_VIEW(treeview_));
|
| +
|
| + // If the user has just double clicked, only one item is selected.
|
| + GtkTreeModel* model;
|
| + GList* selected = gtk_tree_selection_get_selected_rows(selection, &model);
|
| + int row = GetRowNumForPath(reinterpret_cast<GtkTreePath*>(selected->data));
|
| + //task_manager_->ActivateProcess(row);
|
| + LOG(WARNING) << "double clicked on row " << row;
|
| + // FIXME(benl): we make the bogus assumption that the decision map
|
| + // hasn't changed.
|
| + std::vector<WebCore::GeolocationBrowserPowerbox::DecisionPair> decisions
|
| + = WebCore::GeolocationBrowserPowerbox::powerbox.decisions();
|
| + const GURL &url = decisions[row].first;
|
| + TabContents *tab = FindTabWithURL(url);
|
| + if (!tab) {
|
| + LOG(WARNING) << "tab not found for URL " << url;
|
| + return;
|
| + }
|
| +
|
| + // Delete the decision so the dialog is shown again. Not 100% clear
|
| + // this is right, we should just perhaps force the dialog in case
|
| + // the user doesn't complete it.
|
| + WebCore::GeolocationBrowserPowerbox::powerbox.deleteDecision(url);
|
| +
|
| + tab->Activate();
|
| + // Ask it to choose the provider again.
|
| + tab->render_view_host()->ChooseGeolocationProvider(url);
|
| +}
|
| +
|
| +void Clear(gpointer data, gpointer model) {
|
| + GtkTreePath *path =
|
| + reinterpret_cast<GtkTreePath*>(data);
|
| + gtk_tree_path_free(path);
|
| +}
|
| +
|
| +// static
|
| +void ApiPermissionsPanelGtk::OnResponse(GtkDialog* dialog, gint response_id,
|
| + ApiPermissionsPanelGtk* 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::kApiPermissionsPanelWindowPlacement);
|
| + // 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 == kApiPermissionsPanelResponseKill) {
|
| + GtkTreeModel *model = GTK_TREE_MODEL(task_manager->site_list_);
|
| + GtkTreeSelection *selection =
|
| + gtk_tree_view_get_selection(GTK_TREE_VIEW(task_manager->treeview_));
|
| + GList *selected_items;
|
| + // This is kludgey, but I was having a problem with removing items and
|
| + // invalidating the GtkTreePaths. This works for now.
|
| + while ( (selected_items = gtk_tree_selection_get_selected_rows(selection,
|
| + &model)) ) {
|
| + GtkTreePath *path =
|
| + reinterpret_cast<GtkTreePath*>(selected_items->data);
|
| + LOG(WARNING) << gtk_tree_path_to_string(path);
|
| + GtkTreeIter iter;
|
| + gtk_tree_model_get_iter(GTK_TREE_MODEL(task_manager->site_list_),
|
| + &iter,
|
| + path);
|
| + gtk_list_store_remove(GTK_LIST_STORE(task_manager->site_list_), &iter);
|
| + g_list_foreach(selected_items, Clear, NULL);
|
| + g_list_free(selected_items);
|
| + }
|
| + }
|
| +}
|
| +
|
| +// static
|
| +void ApiPermissionsPanelGtk::OnSelectionChanged(GtkTreeSelection* selection,
|
| + ApiPermissionsPanelGtk* task_manager) {
|
| +}
|
| +
|
| +// static
|
| +gboolean ApiPermissionsPanelGtk::OnButtonPressEvent(GtkWidget* widget,
|
| + GdkEventButton* event,
|
| + ApiPermissionsPanelGtk* task_manager) {
|
| + if (event->type == GDK_2BUTTON_PRESS)
|
| + task_manager->ActivateFocusedTab();
|
| + return FALSE;
|
| +}
|
| +
|
| +// static
|
| +gboolean ApiPermissionsPanelGtk::OnButtonReleaseEvent(GtkWidget* widget,
|
| + GdkEventButton* event,
|
| + ApiPermissionsPanelGtk* task_manager) {
|
| + // We don't want to open the context menu in the treeview.
|
| + if (gtk_util::WidgetContainsCursor(task_manager->treeview_))
|
| + return FALSE;
|
| +
|
| + return FALSE;
|
| +}
|
| +
|
| +// static
|
| +gboolean ApiPermissionsPanelGtk::OnGtkAccelerator(GtkAccelGroup* accel_group,
|
| + GObject* acceleratable,
|
| + guint keyval,
|
| + GdkModifierType modifier,
|
| + ApiPermissionsPanelGtk* task_manager) {
|
| + if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) {
|
| + // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget
|
| + // is destroyed. The deleted object will receive gtk signals otherwise.
|
| + gtk_dialog_response(GTK_DIALOG(task_manager->dialog_),
|
| + GTK_RESPONSE_DELETE_EVENT);
|
| + gtk_widget_destroy(task_manager->dialog_);
|
| + }
|
| +
|
| + return TRUE;
|
| +}
|
|
|
| Property changes on: chrome/browser/gtk/api_permissions_panel_gtk.cc
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|