Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1989)

Unified Diff: chrome/browser/gtk/location_bar_view_gtk.cc

Issue 291003: Implement badges for page actions. Also add badge text color API. (Closed)
Patch Set: argb Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/location_bar_view_gtk.h ('k') | chrome/browser/views/browser_actions_container.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/location_bar_view_gtk.cc
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index e36c8d3abc10d69c0c5037cb58d3751fd58bc6f8..9c38b9dfb1e184b25f67c90a339432e017096340 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "app/gfx/canvas_paint.h"
#include "app/gfx/gtk_util.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
@@ -684,6 +685,8 @@ LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk(
gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
g_signal_connect(event_box_.get(), "button-press-event",
G_CALLBACK(&OnButtonPressed), this);
+ g_signal_connect_after(event_box_.get(), "expose-event",
+ G_CALLBACK(OnExposeEvent), this);
image_.Own(gtk_image_new());
gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get());
@@ -793,3 +796,20 @@ gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed(
event->button);
return true;
}
+
+// static
+gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent(
+ GtkWidget* widget, GdkEventExpose* event, PageActionViewGtk* view) {
+ TabContents* contents = view->owner_->browser_->GetSelectedTabContents();
+ if (!contents)
+ return FALSE;
+ const ExtensionActionState* state =
+ contents->GetPageActionState(view->page_action_);
+ if (state->badge_text().empty())
+ return FALSE;
+
+ gfx::CanvasPaint canvas(event, false);
+ gfx::Rect bounding_rect(widget->allocation);
+ state->PaintBadge(&canvas, bounding_rect);
+ return FALSE;
+}
« no previous file with comments | « chrome/browser/gtk/location_bar_view_gtk.h ('k') | chrome/browser/views/browser_actions_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698