[yelp] Remove bookmark directory from page, no editor, use symbolic



commit a6dc2bb02b13abfacb6f6d6fa8dc467e837fb0ed
Author: Shaun McCance <shaunm gnome org>
Date:   Wed Feb 9 13:06:33 2011 -0500

    Remove bookmark directory from page, no editor, use symbolic
    
    I've removed the bookmarks editor dialog, because you can't do
    much editing anyway. Instead, you can now remove a bookmark to
    the page you're on. There's a menu item for this, and the icon
    in the location entry is now a toggle.
    
    I did the toggle icon with the new symbolic icons, changing
    the fill color for bookmarked/unbookmarked. And while I was
    in there, I used symbolic icons for the search and clear
    icons in the search entry as well.

 configure.ac                                       |    2 +
 data/icons/hicolor/Makefile.am                     |    2 +-
 data/icons/hicolor/scalable/Makefile.am            |    1 +
 data/icons/hicolor/scalable/actions/Makefile.am    |    5 +
 .../scalable/actions/yelp-bookmark-symbolic.svg    |  146 +++++++++
 libyelp/yelp-location-entry.c                      |  158 ++++++++--
 src/yelp-window.c                                  |  340 ++------------------
 7 files changed, 315 insertions(+), 339 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9900164..807e493 100644
--- a/configure.ac
+++ b/configure.ac
@@ -212,6 +212,8 @@ data/icons/Makefile
 data/icons/hicolor/Makefile
 data/icons/hicolor/16x16/Makefile
 data/icons/hicolor/16x16/status/Makefile
+data/icons/hicolor/scalable/Makefile
+data/icons/hicolor/scalable/actions/Makefile
 po/Makefile.in
 tests/Makefile
 yelp.desktop.in
diff --git a/data/icons/hicolor/Makefile.am b/data/icons/hicolor/Makefile.am
index 9eb5fc4..8197cbd 100644
--- a/data/icons/hicolor/Makefile.am
+++ b/data/icons/hicolor/Makefile.am
@@ -1 +1 @@
-SUBDIRS = 16x16
+SUBDIRS = 16x16 scalable
diff --git a/data/icons/hicolor/scalable/Makefile.am b/data/icons/hicolor/scalable/Makefile.am
new file mode 100644
index 0000000..0224d45
--- /dev/null
+++ b/data/icons/hicolor/scalable/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = actions
diff --git a/data/icons/hicolor/scalable/actions/Makefile.am b/data/icons/hicolor/scalable/actions/Makefile.am
new file mode 100644
index 0000000..c53189a
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/Makefile.am
@@ -0,0 +1,5 @@
+icondir = $(datadir)/yelp/icons/hicolor/scalable/actions
+
+icon_DATA = yelp-bookmark-symbolic.svg
+
+EXTRA_DIST = $(icon_DATA)
diff --git a/data/icons/hicolor/scalable/actions/yelp-bookmark-symbolic.svg b/data/icons/hicolor/scalable/actions/yelp-bookmark-symbolic.svg
new file mode 100644
index 0000000..c439033
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/yelp-bookmark-symbolic.svg
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   id="svg7384"
+   version="1.1"
+   inkscape:version="0.48.0 r9654"
+   height="16"
+   sodipodi:docname="user-bookmarks-symbolic.svg"
+   width="16">
+  <metadata
+     id="metadata90">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title>Gnome Symbolic Icon Theme</dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     inkscape:cy="8.5334717"
+     inkscape:current-layer="layer13"
+     inkscape:window-width="1502"
+     pagecolor="#555753"
+     showborder="false"
+     showguides="true"
+     inkscape:snap-nodes="false"
+     objecttolerance="10"
+     showgrid="false"
+     inkscape:object-nodes="true"
+     inkscape:pageshadow="2"
+     inkscape:guide-bbox="true"
+     inkscape:window-x="52"
+     inkscape:snap-bbox="true"
+     bordercolor="#666666"
+     id="namedview88"
+     inkscape:window-maximized="0"
+     inkscape:snap-global="true"
+     inkscape:window-y="25"
+     gridtolerance="10"
+     inkscape:zoom="45.254834"
+     inkscape:window-height="957"
+     borderopacity="1"
+     guidetolerance="10"
+     inkscape:cx="9.2503058"
+     inkscape:bbox-paths="false"
+     inkscape:snap-grids="true"
+     inkscape:pageopacity="1"
+     inkscape:snap-to-guides="true">
+    <inkscape:grid
+       visible="true"
+       spacingx="1px"
+       type="xygrid"
+       spacingy="1px"
+       id="grid4866"
+       empspacing="2"
+       enabled="true"
+       snapvisiblegridlinesonly="true" />
+  </sodipodi:namedview>
+  <title
+     id="title9167">Gnome Symbolic Icon Theme</title>
+  <defs
+     id="defs7386" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer9"
+     inkscape:label="status"
+     style="display:inline" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer10"
+     inkscape:label="devices" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer11"
+     inkscape:label="apps" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer12"
+     inkscape:label="actions" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer13"
+     inkscape:label="places">
+    <g
+       transform="translate(294.0002,-820)"
+       id="g11910"
+       inkscape:label="folder-remote" />
+    <path
+       sodipodi:r2="3.8276224"
+       sodipodi:cy="180.96373"
+       inkscape:randomized="0"
+       transform="matrix(1.0472113,-0.00871584,0.00871584,1.0472113,-23.35454,-0.84575)"
+       inkscape:flatsided="false"
+       inkscape:rounded="0.2104596"
+       sodipodi:type="star"
+       d="m 530.9488,186.70897 c -0.77941,0.55189 -3.15759,-1.90601 -4.11253,-1.9179 -0.95532,-0.0119 -3.39494,2.38585 -4.16096,1.8149 -0.76573,-0.57072 0.83698,-3.59203 0.55319,-4.50391 -0.2839,-0.91223 -3.31818,-2.49151 -3.01189,-3.39647 0.30617,-0.90461 3.67487,-0.31399 4.45442,-0.86567 0.77986,-0.5519 1.3442,-3.92569 2.29952,-3.91404 0.95494,0.0116 1.43421,3.39798 2.19979,3.9689 0.76588,0.57114 4.14893,0.0653 4.43307,0.97746 0.28402,0.9118 -2.78848,2.41405 -3.09488,3.31858 -0.30652,0.90489 1.21999,3.96605 0.44027,4.51815 z"
+       inkscape:transform-center-x="-0.0094346789"
+       id="path11922"
+       inkscape:transform-center-y="-0.69491065"
+       sodipodi:r1="7.0383992"
+       sodipodi:arg1="0.95492637"
+       sodipodi:cx="526.88293"
+       class="success"
+       style="color:#000000;fill:#fce94f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       sodipodi:arg2="1.5829876"
+       sodipodi:sides="5" />
+    <path
+       style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#babdb6;fill-opacity:1;stroke:none;stroke-width:0.95488404999999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
+       d="m 530.00474,176.18698 c -0.27249,-0.001 -0.51142,0.15025 -0.68478,0.30025 -0.17335,0.15 -0.30149,0.32965 -0.42107,0.52715 -0.23917,0.395 -0.42432,0.86102 -0.61061,1.34691 -0.18629,0.4859 -0.37373,0.99085 -0.5449,1.3791 -0.17116,0.38825 -0.35613,0.63535 -0.38725,0.65777 -0.031,0.0223 -0.3617,0.13095 -0.78405,0.17017 -0.42235,0.0392 -0.95236,0.0551 -1.4721,0.0777 -0.51973,0.0226 -1.02097,0.0743 -1.47127,0.17588 -0.22516,0.0508 -0.45543,0.11764 -0.6526,0.23452 -0.19718,0.11689 -0.40104,0.30159 -0.48625,0.56042 -0.0852,0.25883 -0.0177,0.50818 0.0714,0.71941 0.0891,0.21123 0.214,0.4113 0.36488,0.58606 0.30176,0.34953 0.68383,0.67818 1.08838,1.0055 0.40455,0.32732 0.83666,0.62403 1.15301,0.90678 0.31635,0.28275 0.51709,0.5809 0.52878,0.61742 0.0116,0.0363 0.002,0.37243 -0.0916,0.78623 -0.0932,0.41379 -0.24189,0.90917 -0.381,1.41046 -0.1391,0.50128 -0.27245,1.01571 -0.31499,1.47536 -0.0213,0.22983 -0.0121,0.4306 0.0382,0.65424 0.0502,0.22363 0.14559,0.49048 0.36542,0.6515
 1 0.21984,0.16102 0.49291,0.17709 0.72132,0.15763 0.22842,-0.0195 0.44031,-0.0796 0.65315,-0.16907 0.42567,-0.17899 0.86671,-0.44725 1.30302,-0.73086 0.43632,-0.2836 0.87035,-0.58226 1.23703,-0.79575 0.36668,-0.2135 0.71187,-0.30096 0.75023,-0.3008 0.0382,1.6e-4 0.35794,0.10475 0.72268,0.32126 0.36474,0.21652 0.78361,0.48812 1.21738,0.77534 0.43376,0.28721 0.85882,0.59228 1.28282,0.77478 0.21201,0.0913 0.42765,0.13685 0.65587,0.15818 0.22822,0.0213 0.49752,-0.0103 0.7186,-0.16962 0.22107,-0.15931 0.33545,-0.4018 0.38753,-0.62505 0.0521,-0.22325 0.0793,-0.42498 0.06,-0.65505 -0.0387,-0.46015 -0.17189,-0.9676 -0.30679,-1.47019 -0.13489,-0.50259 -0.28222,-1.02222 -0.37196,-1.43692 -0.0897,-0.4147 -0.084,-0.74843 -0.072,-0.78486 0.0119,-0.0362 0.20008,-0.31344 0.51871,-0.59342 0.31863,-0.27997 0.73057,-0.60206 1.13776,-0.92584 0.40719,-0.32378 0.79989,-0.64416 1.10449,-0.99102 0.1523,-0.17343 0.29725,-0.34915 0.38807,-0.5596 0.0908,-0.21045 0.14239,-0.49374 0.0592,-0.75323 -0.08
 32,-0.25948 -0.26655,-0.43399 -0.46279,-0.55252 -0.19623,-0.11852 -0.43189,-0.20365 -0.65668,-0.25635 -0.44958,-0.1054 -0.95433,-0.12435 -1.47401,-0.15137 -0.51967,-0.027 -1.05131,-0.0431 -1.47345,-0.0859 -0.42214,-0.0428 -0.72338,-0.16741 -0.75432,-0.19009 -0.0308,-0.0225 -0.26334,-0.29414 -0.43115,-0.68369 -0.16781,-0.38956 -0.32022,-0.88307 -0.50232,-1.37038 -0.1821,-0.48731 -0.36474,-0.97269 -0.6005,-1.36956 -0.11787,-0.19844 -0.25769,-0.36866 -0.42978,-0.52007 -0.16518,-0.1453 -0.39812,-0.27852 -0.65696,-0.28908 l -0.0327,2.7e-4 z m 0.008,1.01449 c -0.0225,-8e-5 -0.0186,-0.0129 0.033,0.0325 0.0515,0.0453 0.11362,0.14949 0.19881,0.2929 0.17038,0.28681 0.35708,0.73389 0.53368,1.20648 0.1766,0.47258 0.34536,0.96185 0.53532,1.40283 0.18996,0.44098 0.35665,0.83362 0.72922,1.10667 0.37257,0.27305 0.80145,0.30091 1.27928,0.34936 0.47783,0.0485 1.00221,0.0594 1.50619,0.0856 0.50397,0.0262 0.98536,0.0765 1.31037,0.15274 0.1625,0.0381 0.30217,0.0923 0.36107,0.1279 -8.6e-4,0.003 0
 .0139,0.001 2.7e-4,0.0327 -0.0272,0.063 -0.0836,0.20355 -0.19363,0.32888 -0.22012,0.25068 -0.61253,0.54531 -1.0074,0.85931 -0.39487,0.31399 -0.80953,0.6419 -1.17021,0.95884 -0.36069,0.31693 -0.66515,0.58259 -0.8097,1.02129 -0.14454,0.43871 -0.0577,0.87205 0.0439,1.34147 0.10157,0.46942 0.24114,0.94951 0.37196,1.43692 0.13082,0.4874 0.24473,0.97419 0.2727,1.30683 0.014,0.16632 0.0186,0.29297 0.003,0.35998 -0.0156,0.067 -0.0179,0.0458 2.8e-4,0.0327 0.0182,-0.0131 0.003,0.007 -0.0655,5.4e-4 -0.0684,-0.006 -0.17486,-0.0295 -0.32807,-0.0954 -0.30643,-0.1319 -0.73047,-0.39918 -1.15111,-0.6777 -0.42065,-0.27852 -0.83776,-0.59541 -1.25065,-0.84051 -0.41289,-0.24509 -0.78547,-0.4459 -1.24737,-0.4478 -0.4619,-0.002 -0.82471,0.22684 -1.23975,0.4685 -0.41505,0.24166 -0.84663,0.521 -1.26976,0.79603 -0.42312,0.27503 -0.83221,0.53466 -1.13994,0.66404 -0.15386,0.0647 -0.2906,0.0953 -0.35916,0.10117 -0.0686,0.006 -0.0508,-0.0129 -0.0327,2.8e-4 0.0181,0.0133 0.0148,0.0343 -2.7e-4,-0.0327 -0.0
 151,-0.067 -0.0184,-0.19389 -0.003,-0.35998 0.0308,-0.33219 0.11627,-0.79233 0.25118,-1.27846 0.13491,-0.48614 0.30766,-1.00777 0.41317,-1.47619 0.10551,-0.46841 0.19549,-0.86968 0.0546,-1.30956 -0.14093,-0.43988 -0.46876,-0.72033 -0.82685,-1.0404 -0.35809,-0.32006 -0.76123,-0.6548 -1.15356,-0.97222 -0.39233,-0.31743 -0.77097,-0.62274 -0.98911,-0.87542 -0.10908,-0.12634 -0.17207,-0.22949 -0.19881,-0.29289 -0.0267,-0.0634 -0.0263,-0.0864 -0.0333,-0.0652 -0.007,0.0213 0.006,0.0345 0.0655,-5.5e-4 0.0591,-0.035 0.16345,-0.0969 0.32617,-0.13362 0.32543,-0.0734 0.80417,-0.0871 1.30819,-0.10907 0.50403,-0.0219 1.02673,-0.0336 1.50483,-0.078 0.47809,-0.0444 0.89848,-0.10065 1.27329,-0.3706 0.3748,-0.26996 0.54995,-0.64673 0.74369,-1.0862 0.19375,-0.43947 0.36397,-0.94061 0.54462,-1.41182 0.18065,-0.47121 0.37363,-0.89719 0.54653,-1.18275 0.0865,-0.14277 0.17459,-0.25141 0.22662,-0.29643 0.052,-0.045 0.0548,-0.0329 0.0325,-0.033 z"
+       id="path2993"
+       inkscape:connector-curvature="0" />
+  </g>
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer14"
+     inkscape:label="mimetypes" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="layer15"
+     inkscape:label="emblems"
+     style="display:inline" />
+  <g
+     transform="translate(-522,-176)"
+     inkscape:groupmode="layer"
+     id="g4953"
+     inkscape:label="categories"
+     style="display:inline" />
+</svg>
diff --git a/libyelp/yelp-location-entry.c b/libyelp/yelp-location-entry.c
index b206afd..c851157 100644
--- a/libyelp/yelp-location-entry.c
+++ b/libyelp/yelp-location-entry.c
@@ -191,6 +191,12 @@ struct _YelpLocationEntryPrivate
     gboolean   search_mode;
     guint      pulse;
     gulong bookmarks_changed;
+
+    GdkPixbuf *icon_edit_clear;
+    GdkPixbuf *icon_edit_find;
+    GdkPixbuf *icon_bookmark_add;
+    GdkPixbuf *icon_bookmark_remove;
+    gboolean   icon_is_clear;
 };
 
 enum {
@@ -369,9 +375,55 @@ yelp_location_entry_class_init (YelpLocationEntryClass *klass)
 static void
 yelp_location_entry_init (YelpLocationEntry *entry)
 {
+    YelpSettings *settings;
+    GtkIconTheme *theme;
+    GtkIconInfo *icon;
+    gchar *color;
+    GdkRGBA gray, white, border, fill;
     YelpLocationEntryPrivate *priv = GET_PRIV (entry);
+
     priv->search_mode = FALSE;
     g_object_set (entry, "entry-text-column", HISTORY_COL_TITLE, NULL);
+
+    settings = yelp_settings_get_default ();
+    g_object_get (settings, "gtk-icon-theme", &theme, NULL);
+
+    color = yelp_settings_get_color (settings, YELP_SETTINGS_COLOR_GRAY_BORDER);
+    gdk_rgba_parse (&gray, color);
+    g_free (color);
+    color = yelp_settings_get_color (settings, YELP_SETTINGS_COLOR_BASE);
+    gdk_rgba_parse (&white, color);
+    g_free (color);
+    color = yelp_settings_get_color (settings, YELP_SETTINGS_COLOR_YELLOW_BORDER);
+    gdk_rgba_parse (&border, color);
+    g_free (color);
+    color = yelp_settings_get_color (settings, YELP_SETTINGS_COLOR_YELLOW_BASE);
+    gdk_rgba_parse (&fill, color);
+    g_free (color);
+
+    icon = gtk_icon_theme_lookup_icon (theme, "edit-clear-symbolic", 16,
+                                       GTK_ICON_LOOKUP_FORCE_SVG);
+    priv->icon_edit_clear = gtk_icon_info_load_symbolic (icon, &gray,
+                                                         NULL, NULL, NULL,
+                                                         NULL, NULL);
+    gtk_icon_info_free (icon);
+
+    icon = gtk_icon_theme_lookup_icon (theme, "edit-find-symbolic", 16,
+                                       GTK_ICON_LOOKUP_FORCE_SVG);
+    priv->icon_edit_find = gtk_icon_info_load_symbolic (icon, &gray,
+                                                        NULL, NULL, NULL,
+                                                        NULL, NULL);
+    gtk_icon_info_free (icon);
+
+    icon = gtk_icon_theme_lookup_icon (theme, "yelp-bookmark-symbolic", 16,
+                                       GTK_ICON_LOOKUP_FORCE_SVG);
+    priv->icon_bookmark_add = gtk_icon_info_load_symbolic (icon, &gray, &white,
+                                                           NULL, NULL, NULL, NULL);
+    priv->icon_bookmark_remove = gtk_icon_info_load_symbolic (icon, &border, &fill,
+                                                              NULL, NULL, NULL, NULL);
+    gtk_icon_info_free (icon);
+
+    g_object_unref (theme);
 }
 
 static void
@@ -528,6 +580,26 @@ location_entry_dispose (GObject *object)
         priv->pulse = 0;
     }
 
+    if (priv->icon_edit_clear) {
+        g_object_unref (priv->icon_edit_clear);
+        priv->icon_edit_clear = NULL;
+    }
+
+    if (priv->icon_edit_find) {
+        g_object_unref (priv->icon_edit_find);
+        priv->icon_edit_find = NULL;
+    }
+
+    if (priv->icon_bookmark_add) {
+        g_object_unref (priv->icon_bookmark_add);
+        priv->icon_bookmark_add = NULL;
+    }
+
+    if (priv->icon_bookmark_remove) {
+        g_object_unref (priv->icon_bookmark_remove);
+        priv->icon_bookmark_remove = NULL;
+    }
+
     G_OBJECT_CLASS (yelp_location_entry_parent_class)->dispose (object);
 }
 
@@ -618,21 +690,31 @@ static void
 location_entry_bookmark_clicked  (YelpLocationEntry *entry)
 {
     YelpUri *uri;
-    gchar *doc_uri, *page_id, *icon, *title;
+    gchar *doc_uri, *page_id;
     YelpLocationEntryPrivate *priv = GET_PRIV (entry);
 
     g_object_get (priv->view,
                   "yelp-uri", &uri,
                   "page-id", &page_id,
-                  "page-icon", &icon,
-                  "page-title", &title,
                   NULL);
     doc_uri = yelp_uri_get_document_uri (uri);
-    yelp_bookmarks_add_bookmark (priv->bookmarks, doc_uri, page_id, icon, title);
+    if (priv->bookmarks && doc_uri && page_id) {
+        if (!yelp_bookmarks_is_bookmarked (priv->bookmarks, doc_uri, page_id)) {
+            gchar *icon, *title;
+            g_object_get (priv->view,
+                          "page-icon", &icon,
+                          "page-title", &title,
+                          NULL);
+            yelp_bookmarks_add_bookmark (priv->bookmarks, doc_uri, page_id, icon, title);
+            g_free (icon);
+            g_free (title);
+        }
+        else {
+            yelp_bookmarks_remove_bookmark (priv->bookmarks, doc_uri, page_id);
+        }
+    }
     g_free (doc_uri);
     g_free (page_id);
-    g_free (icon);
-    g_free (title);
     g_object_unref (uri);
 }
 
@@ -734,17 +816,22 @@ location_entry_set_entry (YelpLocationEntry *entry, gboolean emit)
     gchar *icon_name;
 
     if (priv->search_mode) {
-        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
-                                           GTK_ENTRY_ICON_PRIMARY,
-                                           "system-search");
-        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
-                                           GTK_ENTRY_ICON_SECONDARY,
-                                           "edit-clear");
+        gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->text_entry),
+                                        GTK_ENTRY_ICON_PRIMARY,
+                                        priv->icon_edit_find);
+        gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->text_entry),
+                                        GTK_ENTRY_ICON_SECONDARY,
+                                        priv->icon_edit_clear);
         gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->text_entry),
                                          GTK_ENTRY_ICON_SECONDARY,
                                          "Clear the search text");
+        priv->icon_is_clear = TRUE;
         return;
     }
+    else {
+        priv->icon_is_clear = FALSE;
+    }
+
 
     if (priv->row)
         path = gtk_tree_row_reference_get_path (priv->row);
@@ -775,19 +862,27 @@ location_entry_set_entry (YelpLocationEntry *entry, gboolean emit)
         }
         if (priv->bookmarks && doc_uri && page_id) {
             if (!yelp_bookmarks_is_bookmarked (priv->bookmarks, doc_uri, page_id)) {
-                gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
-                                                   GTK_ENTRY_ICON_SECONDARY,
-                                                   "bookmark-new");
+                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->text_entry),
+                                                GTK_ENTRY_ICON_SECONDARY,
+                                                priv->icon_bookmark_add);
                 gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->text_entry),
                                                  GTK_ENTRY_ICON_SECONDARY,
                                                  "Bookmark this page");
             }
             else {
-                gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
-                                                   GTK_ENTRY_ICON_SECONDARY,
-                                                   NULL);
+                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->text_entry),
+                                                GTK_ENTRY_ICON_SECONDARY,
+                                                priv->icon_bookmark_remove);
+                gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->text_entry),
+                                                 GTK_ENTRY_ICON_SECONDARY,
+                                                 "Remove bookmark");
             }
         }
+        else {
+            gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
+                                               GTK_ENTRY_ICON_SECONDARY,
+                                               NULL);
+        }
         g_free (doc_uri);
         g_free (page_id);
         gtk_entry_set_text (GTK_ENTRY (priv->text_entry), text);
@@ -956,13 +1051,10 @@ entry_icon_press_cb (GtkEntry            *gtkentry,
     YelpLocationEntryPrivate *priv = GET_PRIV (entry);
 
     if (icon_pos == GTK_ENTRY_ICON_SECONDARY) {
-        const gchar *name = gtk_entry_get_icon_name (gtkentry, icon_pos);
-        if (g_str_equal (name, "edit-clear")) {
+        if (priv->icon_is_clear)
             location_entry_cancel_search (entry);
-        }
-        else if  (g_str_equal (name, "bookmark-new")) {
+        else
             g_signal_emit (entry, location_entry_signals[BOOKMARK_CLICKED], 0);
-        }
     }
 }
 
@@ -1462,19 +1554,27 @@ bookmarks_changed (YelpBookmarks      *bookmarks,
                             -1);
         if (this_uri && g_str_equal (this_uri, doc_uri) && page_id) {
             if (!yelp_bookmarks_is_bookmarked (priv->bookmarks, doc_uri, page_id)) {
-                gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
-                                                   GTK_ENTRY_ICON_SECONDARY,
-                                                   "bookmark-new");
+                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->text_entry),
+                                                GTK_ENTRY_ICON_SECONDARY,
+                                                priv->icon_bookmark_add);
                 gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->text_entry),
                                                  GTK_ENTRY_ICON_SECONDARY,
                                                  "Bookmark this page");
             }
             else {
-                gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
-                                                   GTK_ENTRY_ICON_SECONDARY,
-                                                   NULL);
+                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->text_entry),
+                                                GTK_ENTRY_ICON_SECONDARY,
+                                                priv->icon_bookmark_remove);
+                gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->text_entry),
+                                                 GTK_ENTRY_ICON_SECONDARY,
+                                                 "Remove bookmark");
             }
         }
+        else {
+            gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->text_entry),
+                                               GTK_ENTRY_ICON_SECONDARY,
+                                               NULL);
+        }
         g_free (this_uri);
         g_free (page_id);
     }
diff --git a/src/yelp-window.c b/src/yelp-window.c
index c15c252..5e5eeeb 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -75,7 +75,7 @@ static void          window_go_all                (GtkAction          *action,
                                                    YelpWindow         *window);
 static void          window_add_bookmark          (GtkAction          *action,
                                                    YelpWindow         *window);
-static void          window_edit_bookmarks        (GtkAction          *action,
+static void          window_remove_bookmark       (GtkAction          *action,
                                                    YelpWindow         *window);
 static void          window_load_bookmark         (GtkAction          *action,
                                                    YelpWindow         *window);
@@ -139,24 +139,6 @@ static gboolean      hidden_key_press             (GtkWidget          *widget,
                                                    GdkEventKey        *event,
                                                    YelpWindow         *window);
 
-static gboolean      bookmarks_closed             (GtkWindow          *bookmarks,
-                                                   GdkEvent           *event,
-                                                   YelpWindow         *window);
-static void          bookmarks_set_bookmarks      (YelpWindow         *window);
-static gboolean      bookmark_button_press        (GtkTreeView        *view,
-                                                   GdkEventButton     *event,
-                                                   YelpWindow         *window);
-static void          bookmark_opened              (GtkMenuItem        *item,
-                                                   YelpWindow         *window);
-static void          bookmark_activated           (GtkTreeView        *view,
-                                                   GtkTreePath        *path,
-                                                   GtkTreeViewColumn  *column,
-                                                   YelpWindow         *window);
-static gboolean      bookmark_key_release         (GtkTreeView        *view,
-                                                   GdkEventKey        *event,
-                                                   YelpWindow         *window);
-static void          bookmark_remove              (YelpWindow         *window);
-
 enum {
     PROP_0,
     PROP_APPLICATION
@@ -200,7 +182,7 @@ static const gchar *YELP_UI =
     "</menu>"
     "<menu action='BookmarksMenu'>"
     "<menuitem action='AddBookmark'/>"
-    "<menuitem action='EditBookmarks'/>"
+    "<menuitem action='RemoveBookmark'/>"
     "<separator/>"
     "<placeholder name='Bookmarks'/>"
     "</menu>"
@@ -217,10 +199,6 @@ struct _YelpWindowPrivate {
     GtkActionGroup *action_group;
     YelpApplication *application;
 
-    GtkWidget    *bookmarks_editor;
-    /* no ref */
-    GtkWidget    *bookmarks_list;
-    GtkListStore *bookmarks_store;
     gulong        bookmarks_changed;
     gulong        read_later_changed;
 
@@ -286,11 +264,10 @@ static const GtkActionEntry entries[] = {
       "<Control>D",
       NULL,
       G_CALLBACK (window_add_bookmark) },
-    { "EditBookmarks", NULL,
-      N_("_Edit Bookmarks"),
-      "<Control>B",
-      NULL,
-      G_CALLBACK (window_edit_bookmarks) },
+    { "RemoveBookmark", NULL,
+      N_("_Remove Bookmark"),
+      NULL, NULL,
+      G_CALLBACK (window_remove_bookmark) },
     { "Find", NULL,
       N_("Find in Page..."),
       "<Control>F",
@@ -401,11 +378,6 @@ yelp_window_dispose (GObject *object)
         priv->entry_color_animate = 0;
     }
 
-    if (priv->bookmarks_editor != NULL) {
-        gtk_widget_destroy (GTK_WIDGET (priv->bookmarks_editor));
-        priv->bookmarks_editor = NULL;
-    }
-
     G_OBJECT_CLASS (yelp_window_parent_class)->dispose (object);
 }
 
@@ -782,69 +754,24 @@ window_add_bookmark (GtkAction  *action,
 }
 
 static void
-window_edit_bookmarks (GtkAction  *action,
-                       YelpWindow *window)
+window_remove_bookmark (GtkAction  *action,
+                        YelpWindow *window)
 {
+    YelpUri *uri;
+    gchar *doc_uri, *page_id;
     YelpWindowPrivate *priv = GET_PRIV (window);
-    GtkWidget *scroll;
-    gchar *title;
-
-    if (priv->bookmarks_editor != NULL) {
-        gtk_window_present_with_time (GTK_WINDOW (priv->bookmarks_editor),
-                                      gtk_get_current_event_time ());
-        return;
-    }
-
-    priv->bookmarks_editor = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-    gtk_window_set_transient_for (GTK_WINDOW (priv->bookmarks_editor),
-                                  GTK_WINDOW (window));
-    /* %s will be replaced with the name of a document */
-    title = g_strdup_printf (_("Bookmarks for %s"),
-                             gtk_window_get_title (GTK_WINDOW (window)));
-    gtk_window_set_title (GTK_WINDOW (priv->bookmarks_editor), title);
-    g_free (title);
-    gtk_container_set_border_width (GTK_CONTAINER (priv->bookmarks_editor), 6);
-    gtk_window_set_icon_name (GTK_WINDOW (priv->bookmarks_editor), "bookmark");
-    gtk_window_set_default_size (GTK_WINDOW (priv->bookmarks_editor), 300, 300);
-    g_signal_connect (priv->bookmarks_editor, "delete-event",
-                      G_CALLBACK (bookmarks_closed), window);
 
-    scroll = gtk_scrolled_window_new (NULL, NULL);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
-                                    GTK_POLICY_AUTOMATIC,
-                                    GTK_POLICY_AUTOMATIC);
-    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
-                                         GTK_SHADOW_IN);
-    gtk_container_add (GTK_CONTAINER (priv->bookmarks_editor), scroll);
-
-    priv->bookmarks_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-    priv->bookmarks_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->bookmarks_store));
-    gtk_container_add (GTK_CONTAINER (scroll), priv->bookmarks_list);
-
-    g_signal_connect (priv->bookmarks_list, "button-press-event",
-                      G_CALLBACK (bookmark_button_press), window);
-    g_signal_connect (priv->bookmarks_list, "row-activated",
-                      G_CALLBACK (bookmark_activated), window);
-    g_signal_connect (priv->bookmarks_list, "key-release-event",
-                      G_CALLBACK (bookmark_key_release), window);
-
-    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->bookmarks_list), FALSE);
-    GtkCellRenderer *cell = gtk_cell_renderer_pixbuf_new ();
-    g_object_set (cell, "ypad", 2, "xpad", 2, NULL);
-    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->bookmarks_list), 0, NULL,
-                                                 cell,
-                                                 "icon-name", 1,
-                                                 NULL);
-    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->bookmarks_list), 1, NULL,
-                                                 gtk_cell_renderer_text_new (),
-                                                 "text", 2,
-                                                 NULL);
-
-    bookmarks_set_bookmarks (window);
-
-    gtk_widget_show_all (priv->bookmarks_editor);
+    g_object_get (priv->view,
+                  "yelp-uri", &uri,
+                  "page-id", &page_id,
+                  NULL);
+    doc_uri = yelp_uri_get_document_uri (uri);
+    yelp_application_remove_bookmark (YELP_BOOKMARKS (priv->application),
+                                      doc_uri, page_id);
+    g_free (doc_uri);
+    g_free (page_id);
+    g_object_unref (uri);
 }
-
 static void
 window_load_bookmark (GtkAction  *action,
                       YelpWindow *window)
@@ -879,8 +806,6 @@ app_bookmarks_changed (YelpApplication *app,
 
     if (g_str_equal (this_doc_uri, doc_uri)) {
         window_set_bookmarks (window, doc_uri);
-        if (priv->bookmarks_editor != NULL)
-            bookmarks_set_bookmarks (window);
     }
 
     g_free (this_doc_uri);
@@ -934,8 +859,6 @@ window_set_bookmarks (YelpWindow  *window,
         entry->title = title;
         entries = g_slist_insert_sorted (entries, entry, (GCompareFunc) entry_compare);
     }
-    gtk_action_set_sensitive (gtk_action_group_get_action (priv->action_group, "EditBookmarks"),
-                              entries != NULL);
     for ( ; entries != NULL; entries = g_slist_delete_link (entries, entries)) {
         GSList *cur;
         GtkAction *bookmark;
@@ -984,24 +907,28 @@ window_set_bookmark_action (YelpWindow *window)
 {
     YelpUri *uri = NULL;
     gchar *doc_uri = NULL, *page_id = NULL;
-    GtkAction *action;
+    GtkAction *action_add, *action_del;
+    gboolean bookmarked;
     YelpWindowPrivate *priv = GET_PRIV (window);
 
-    action = gtk_action_group_get_action (priv->action_group, "AddBookmark");
+    action_add = gtk_action_group_get_action (priv->action_group, "AddBookmark");
+    action_del = gtk_action_group_get_action (priv->action_group, "RemoveBookmark");
 
     g_object_get (priv->view,
                   "yelp-uri", &uri,
                   "page-id", &page_id,
                   NULL);
     if (page_id == NULL) {
-        gtk_action_set_sensitive (action, FALSE);
+        gtk_action_set_sensitive (action_add, FALSE);
+        gtk_action_set_sensitive (action_del, FALSE);
         goto done;
     }
     doc_uri = yelp_uri_get_document_uri (uri);
-    gtk_action_set_sensitive (
-        action,
-        !yelp_application_is_bookmarked (YELP_BOOKMARKS (priv->application),
-                                         doc_uri, page_id));
+    bookmarked = yelp_application_is_bookmarked (YELP_BOOKMARKS (priv->application),
+                                                 doc_uri, page_id);
+    gtk_action_set_sensitive (action_add, !bookmarked);
+    gtk_action_set_sensitive (action_del, bookmarked);
+
   done:
     g_free (page_id);
     g_free (doc_uri);
@@ -1573,208 +1500,3 @@ hidden_key_press (GtkWidget    *widget,
     }
     return FALSE;
 }
-
-static gboolean
-bookmarks_closed (GtkWindow   *bookmarks,
-                  GdkEvent    *event,
-                  YelpWindow  *window)
-{
-    YelpWindowPrivate *priv = GET_PRIV (window);
-
-    gtk_widget_destroy (GTK_WIDGET (bookmarks));
-    priv->bookmarks_editor = NULL;
-
-    return TRUE;
-}
-
-static void
-bookmarks_set_bookmarks (YelpWindow *window)
-{
-    GVariant *value;
-    GVariantIter *viter;
-    YelpUri *uri;
-    gchar *doc_uri;
-    GSList *entries = NULL;
-    gchar *page_id, *icon, *title; /* do not free */
-    YelpWindowPrivate *priv = GET_PRIV (window);
-
-    gtk_list_store_clear (priv->bookmarks_store);
-
-    g_object_get (priv->view, "yelp-uri", &uri, NULL);
-    doc_uri = yelp_uri_get_document_uri (uri);
-    value = yelp_application_get_bookmarks (priv->application, doc_uri);
-    g_free (doc_uri);
-    g_object_unref (uri);
-
-    g_variant_get (value, "a(sss)", &viter);
-    while (g_variant_iter_loop (viter, "(&s&s&s)", &page_id, &icon, &title)) {
-        YelpMenuEntry *entry = g_new0 (YelpMenuEntry, 1);
-        entry->page_id = page_id;
-        entry->icon = icon;
-        entry->title = title;
-        entries = g_slist_insert_sorted (entries, entry, (GCompareFunc) entry_compare);
-    }
-    for ( ; entries != NULL; entries = g_slist_delete_link (entries, entries)) {
-        GtkTreeIter iter;
-        YelpMenuEntry *entry = (YelpMenuEntry *) entries->data;
-        gtk_list_store_append (priv->bookmarks_store, &iter);
-        gtk_list_store_set (priv->bookmarks_store, &iter,
-                            0, entry->page_id,
-                            1, entry->icon,
-                            2, entry->title,
-                            -1);
-        g_free (entry);
-    }
-    g_variant_iter_free (viter);
-    g_variant_unref (value);
-}
-
-static gboolean
-bookmark_button_press (GtkTreeView    *view,
-                       GdkEventButton *event,
-                       YelpWindow     *window)
-{
-    if (event->button == 3) {
-        GtkTreePath *path = NULL;
-        GtkWidget *menu, *item;
-        GtkTreeSelection *sel = gtk_tree_view_get_selection (view);
-
-        gtk_tree_view_get_path_at_pos (view,
-                                       event->x, event->y,
-                                       &path, NULL,
-                                       NULL, NULL);
-        gtk_tree_selection_select_path (sel, path);
-        gtk_tree_path_free (path);
-
-        menu = gtk_menu_new ();
-        g_object_ref_sink (menu);
-
-        item = gtk_menu_item_new_with_mnemonic (_("_Open Bookmark"));
-        g_object_set_data ((GObject *) item, "new-window", (gpointer) FALSE);
-        g_signal_connect (item, "activate",
-                          G_CALLBACK (bookmark_opened), window);
-        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-        item = gtk_menu_item_new_with_mnemonic (_("Open Bookmark in New _Window"));
-        g_object_set_data ((GObject *) item, "new-window", (gpointer) TRUE);
-        g_signal_connect (item, "activate",
-                          G_CALLBACK (bookmark_opened), window);
-        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-        item = gtk_separator_menu_item_new ();
-        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-        item = gtk_menu_item_new_with_mnemonic (_("_Remove Bookmark"));
-        g_signal_connect_swapped (item, "activate",
-                                  G_CALLBACK (bookmark_remove), window);
-        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
-        gtk_widget_show_all (menu);
-        gtk_menu_popup (GTK_MENU (menu),
-                        NULL, NULL, NULL, NULL,
-                        event->button,
-                        event->time);
-
-        g_object_unref (menu);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-static void
-bookmark_opened (GtkMenuItem *item,
-                 YelpWindow  *window)
-{
-    YelpWindowPrivate *priv = GET_PRIV (window);
-    GtkTreeIter iter;
-    GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->bookmarks_list));
-
-    if (gtk_tree_selection_get_selected (sel, NULL, &iter)) {
-        YelpUri *base, *uri;
-        gchar *page_id, *xref;
-        gtk_tree_model_get (GTK_TREE_MODEL (priv->bookmarks_store), &iter,
-                            0, &page_id,
-                            -1);
-        xref = g_strconcat ("xref:", page_id, NULL);
-        g_object_get (priv->view, "yelp-uri", &base, NULL);
-        uri = yelp_uri_new_relative (base, xref);
-
-        if (g_object_get_data ((GObject *) item, "new-window"))
-            yelp_application_new_window_uri (priv->application, uri);
-        else
-            yelp_view_load_uri (priv->view, uri);
-
-        g_object_unref (base);
-        g_object_unref (uri);
-        g_free (page_id);
-        g_free (xref);
-    }
-}
-
-static void
-bookmark_activated (GtkTreeView        *view,
-                    GtkTreePath        *path,
-                    GtkTreeViewColumn  *column,
-                    YelpWindow         *window)
-{
-    GtkTreeIter iter;
-    YelpWindowPrivate *priv = GET_PRIV (window);
-
-    if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->bookmarks_store),
-                                 &iter, path)) {
-        YelpUri *base, *uri;
-        gchar *page_id, *xref;
-        gtk_tree_model_get (GTK_TREE_MODEL (priv->bookmarks_store), &iter,
-                            0, &page_id,
-                            -1);
-        xref = g_strconcat ("xref:", page_id, NULL);
-        g_object_get (priv->view, "yelp-uri", &base, NULL);
-        uri = yelp_uri_new_relative (base, xref);
-
-        yelp_view_load_uri (priv->view, uri);
-
-        g_object_unref (base);
-        g_object_unref (uri);
-        g_free (xref);
-        g_free (page_id);
-    }
-}
-
-static gboolean
-bookmark_key_release (GtkTreeView *view,
-                      GdkEventKey *event,
-                      YelpWindow  *window)
-{
-    if (event->keyval == GDK_KEY_Delete) {
-        bookmark_remove (window);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-static void
-bookmark_remove (YelpWindow  *window)
-{
-    YelpWindowPrivate *priv = GET_PRIV (window);
-    GtkTreeIter iter;
-    GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->bookmarks_list));
-
-    if (gtk_tree_selection_get_selected (sel, NULL, &iter)) {
-        YelpUri *uri;
-        gchar *doc_uri, *page_id;
-        gtk_tree_model_get (GTK_TREE_MODEL (priv->bookmarks_store), &iter,
-                            0, &page_id,
-                            -1);
-        g_object_get (priv->view, "yelp-uri", &uri, NULL);
-        doc_uri = yelp_uri_get_document_uri (uri);
-
-        yelp_application_remove_bookmark (
-            YELP_BOOKMARKS (priv->application),
-            doc_uri, page_id);
-
-        g_object_unref (uri);
-        g_free (doc_uri);
-        g_free (page_id);
-    }
-}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]