diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 21:39:16 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 21:39:16 +0000 |
commit | 2f4514d606aa6cb299517998438d4d93122986bd (patch) | |
tree | 2994a227511de4d2136cdfa21c31d5a1be6b7146 /chrome/browser/gtk | |
parent | 142e8a7a1d1de7ba1c601bdff823704f2acbc0fd (diff) | |
download | chromium_src-2f4514d606aa6cb299517998438d4d93122986bd.zip chromium_src-2f4514d606aa6cb299517998438d4d93122986bd.tar.gz chromium_src-2f4514d606aa6cb299517998438d4d93122986bd.tar.bz2 |
GTK: Add a bunch more widget names for parasite.
Also, change slightly how we apply custom styles to certain buttons.
BUG=22096
Review URL: http://codereview.chromium.org/210019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/bookmark_bar_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_button.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_link_button.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/view_id_util.cc | 60 | ||||
-rw-r--r-- | chrome/browser/gtk/view_id_util.h | 2 |
5 files changed, 64 insertions, 6 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 67207d2..1ecf5c9 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -593,8 +593,6 @@ void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget) { G_CALLBACK(OnButtonPressed), this); g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(OnFolderClicked), this); - - ViewIDUtil::SetID(widget, VIEW_ID_BOOKMARK_MENU); } const BookmarkNode* BookmarkBarGtk::GetNodeForToolButton(GtkWidget* widget) { diff --git a/chrome/browser/gtk/gtk_chrome_button.cc b/chrome/browser/gtk/gtk_chrome_button.cc index 35cd4f2..01d6db7 100644 --- a/chrome/browser/gtk/gtk_chrome_button.cc +++ b/chrome/browser/gtk/gtk_chrome_button.cc @@ -44,7 +44,7 @@ static void gtk_chrome_button_class_init(GtkChromeButtonClass* button_class) { " GtkButton::child-displacement-x = 0" " GtkButton::child-displacement-y = 0" "}" - "widget \"*chrome-button\" style \"chrome-button\""); + "widget_class \"*.<GtkChromeButton>\" style \"chrome-button\""); GObjectClass* gobject_class = G_OBJECT_CLASS(button_class); GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>( @@ -81,7 +81,6 @@ static void gtk_chrome_button_init(GtkChromeButton* button) { priv->paint_state = -1; priv->use_gtk_rendering = FALSE; - gtk_widget_set_name(GTK_WIDGET(button), "chrome-button"); gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); diff --git a/chrome/browser/gtk/gtk_chrome_link_button.cc b/chrome/browser/gtk/gtk_chrome_link_button.cc index defb188..886da8e 100644 --- a/chrome/browser/gtk/gtk_chrome_link_button.cc +++ b/chrome/browser/gtk/gtk_chrome_link_button.cc @@ -30,7 +30,7 @@ void SetLinkButtonStyle() { " xthickness = 0" " ythickness = 0" "}" - "widget \"*chrome-link-button\" style \"chrome-link-button\""); + "widget_class \"*.<GtkChromeLinkButton>\" style \"chrome-link-button\""); } } // namespace @@ -187,7 +187,6 @@ static void gtk_chrome_link_button_init(GtkChromeLinkButton* button) { button->text = NULL; gtk_container_add(GTK_CONTAINER(button), button->label); - gtk_widget_set_name(GTK_WIDGET(button), "chrome-link-button"); gtk_widget_set_app_paintable(GTK_WIDGET(button), TRUE); } diff --git a/chrome/browser/gtk/view_id_util.cc b/chrome/browser/gtk/view_id_util.cc index fe6501f..9a8a875 100644 --- a/chrome/browser/gtk/view_id_util.cc +++ b/chrome/browser/gtk/view_id_util.cc @@ -5,9 +5,12 @@ #include "chrome/browser/gtk/view_id_util.h" #include <stdint.h> +#include <string> #include <gtk/gtk.h> +#include "base/logging.h" + namespace { const char kViewIDString[] = "__VIEW_ID__"; @@ -54,9 +57,66 @@ void SearchForWidgetWithViewID(GtkWidget* widget, gpointer data) { } } +const char* GetNameFromID(ViewID id) { + switch (id) { + case VIEW_ID_TOOLBAR: + return "chrome-toolbar"; + + case VIEW_ID_BACK_BUTTON: + return "chrome-toolbar-back-button"; + + case VIEW_ID_FORWARD_BUTTON: + return "chrome-toolbar-forward-button"; + + case VIEW_ID_RELOAD_BUTTON: + return "chrome-toolbar-reload-button"; + + case VIEW_ID_HOME_BUTTON: + return "chrome-toolbar-home-button"; + + case VIEW_ID_STAR_BUTTON: + return "chrome-toolbar-star-button"; + + case VIEW_ID_LOCATION_BAR: + return "chrome-location-bar"; + + case VIEW_ID_GO_BUTTON: + return "chrome-toolbar-go-button"; + + case VIEW_ID_PAGE_MENU: + return "chrome-page-menu"; + + case VIEW_ID_APP_MENU: + return "chrome-app-menu"; + + case VIEW_ID_AUTOCOMPLETE: + return "chrome-autocomplete-edit"; + + case VIEW_ID_BOOKMARK_MENU: + return "chrome-bookmark-menu"; + + case VIEW_ID_BOOKMARK_BAR: + return "chrome-bookmark-bar"; + + case VIEW_ID_FIND_IN_PAGE_TEXT_FIELD: + return "chrome-find-in-page-entry"; + + // These are never hit because the tab container uses the delegate to + // set its ID. + case VIEW_ID_TAB_CONTAINER: + case VIEW_ID_TAB_CONTAINER_FOCUS_VIEW: + default: + NOTREACHED(); + return NULL; + } +} + } // namespace void ViewIDUtil::SetID(GtkWidget* widget, ViewID id) { + const char* name = GetNameFromID(id); + if (name) + gtk_widget_set_name(widget, name); g_object_set_data(G_OBJECT(widget), kViewIDString, reinterpret_cast<void*>(id)); } diff --git a/chrome/browser/gtk/view_id_util.h b/chrome/browser/gtk/view_id_util.h index 1ec65e8..23e67a6 100644 --- a/chrome/browser/gtk/view_id_util.h +++ b/chrome/browser/gtk/view_id_util.h @@ -17,6 +17,8 @@ class ViewIDUtil { virtual GtkWidget* GetWidgetForViewID(ViewID id) = 0; }; + // If you set the ID via this function, it will also set the name of your + // widget to a human-readable value for debugging. static void SetID(GtkWidget* widget, ViewID id); static GtkWidget* GetWidget(GtkWidget* root, ViewID id); |