summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang Xianwei <[email protected]>2018-01-07 16:07:12 +0800
committerZhang Xianwei <[email protected]>2018-01-11 09:59:45 +0800
commitafcb324eb181a9c6cb0b3c8e8589ed99391a63a0 (patch)
tree3fe5cf0b331c06cb7b86c658e41a548cd2bbc460
parenta34ea4de6c653e184bf5eeef17dd2d73a9955fb1 (diff)
downloadmate-control-center-afcb324eb181a9c6cb0b3c8e8589ed99391a63a0.tar.bz2
mate-control-center-afcb324eb181a9c6cb0b3c8e8589ed99391a63a0.tar.xz
libslab: fix search icon misaligned
Make use GtkSearchEntry instead of builtin NldSearchEntry fixes #299 Signed-off-by: Zhang Xianwei <[email protected]>
-rw-r--r--libslab/Makefile.am21
-rw-r--r--libslab/search-bar.c13
-rw-r--r--libslab/search-entry-watermark.svg58
-rw-r--r--libslab/search-entry.c148
-rw-r--r--libslab/search-entry.h54
-rw-r--r--libslab/slab.h1
6 files changed, 9 insertions, 286 deletions
diff --git a/libslab/Makefile.am b/libslab/Makefile.am
index e4f2ffdc..93a728d0 100644
--- a/libslab/Makefile.am
+++ b/libslab/Makefile.am
@@ -18,7 +18,6 @@ HEADER_FILES= \
nameplate-tile.h \
search-bar.h \
search-context-picker.h \
- search-entry.h \
shell-window.h \
slab-mate-util.h \
slab-section.h \
@@ -39,8 +38,6 @@ libmate_slab_la_SOURCES = \
nameplate-tile.c \
search-bar.c \
search-context-picker.c \
- search-entry-watermark.h \
- search-entry.c \
shell-window.c \
slab-mate-util.c \
slab-section.c \
@@ -53,12 +50,6 @@ libmate_slab_includedir = $(includedir)/libmate-slab
libmate_slab_include_HEADERS = $(HEADER_FILES)
libmate_slab_la_LIBADD = $(LIBSLAB_LIBS)
-search-entry-watermark.h: search-entry-watermark.svg
- echo '#define SEARCH_ENTRY_WATERMARK_SVG "\' > $@; \
- sed -e 's/"/\\"/g' -e 's/$$/\\/' -e 's/#000000/#%s/g' $< >> $@; \
- echo '"' >> $@
-
-
MARSHAL_GENERATED = nld-marshal.c nld-marshal.h
nld-marshal.h: nld-marshal.list
@@ -72,16 +63,10 @@ nld-marshal.c: nld-marshal.h
|| ( rm -f nld-marshal.tmp && exit 1 )
-BUILT_SOURCES = \
- search-entry-watermark.h \
- $(MARSHAL_GENERATED)
+BUILT_SOURCES = $(MARSHAL_GENERATED)
-CLEANFILES = \
- search-entry-watermark.h \
- $(MARSHAL_GENERATED)
+CLEANFILES = $(MARSHAL_GENERATED)
-EXTRA_DIST= \
- search-entry-watermark.svg \
- nld-marshal.list
+EXTRA_DIST = nld-marshal.list
-include $(top_srcdir)/git.mk
diff --git a/libslab/search-bar.c b/libslab/search-bar.c
index fd480f34..7645c0fa 100644
--- a/libslab/search-bar.c
+++ b/libslab/search-bar.c
@@ -21,7 +21,6 @@
#include "search-bar.h"
#include "config.h"
-#include "search-entry.h"
#include "search-context-picker.h"
#include "nld-marshal.h"
@@ -31,7 +30,7 @@ typedef struct
{
GtkWidget *hbox;
NldSearchContextPicker *context_picker;
- GtkEntry *entry;
+ GtkSearchEntry *entry;
GtkWidget *button;
int search_timeout;
@@ -92,10 +91,10 @@ nld_search_bar_init (NldSearchBar * search_bar)
priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_box_pack_start (GTK_BOX (search_bar), priv->hbox, TRUE, FALSE, 0);
- entry = nld_search_entry_new ();
+ entry = gtk_search_entry_new ();
gtk_widget_set_halign (entry, GTK_ALIGN_START);
gtk_widget_set_valign (entry, GTK_ALIGN_CENTER);
- priv->entry = GTK_ENTRY (entry);
+ priv->entry = GTK_SEARCH_ENTRY (entry);
gtk_widget_show (entry);
gtk_box_pack_start (GTK_BOX (priv->hbox), entry, TRUE, TRUE, 0);
@@ -151,7 +150,7 @@ nld_search_bar_clear (NldSearchBar * search_bar)
NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
priv->block_signal = TRUE;
- gtk_entry_set_text (priv->entry, "");
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
if (priv->context_picker)
nld_search_context_picker_set_context (priv->context_picker, 0);
priv->block_signal = FALSE;
@@ -325,7 +324,7 @@ nld_search_bar_get_text (NldSearchBar * search_bar)
{
NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
- return gtk_entry_get_text (priv->entry);
+ return gtk_entry_get_text (GTK_ENTRY (priv->entry));
}
void
@@ -333,7 +332,7 @@ nld_search_bar_set_text (NldSearchBar * search_bar, const char *text, gboolean a
{
NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
- gtk_entry_set_text (priv->entry, text);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
if (activate)
emit_search (search_bar);
}
diff --git a/libslab/search-entry-watermark.svg b/libslab/search-entry-watermark.svg
deleted file mode 100644
index f72efff1..00000000
--- a/libslab/search-entry-watermark.svg
+++ /dev/null
@@ -1,58 +0,0 @@
-<?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://web.resource.org/cc/"
- 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://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="24"
- height="16"
- id="svg5418"
- sodipodi:version="0.32"
- inkscape:version="0.42+devel"
- version="1.0"
- sodipodi:docbase="/home/jimmac/Desktop"
- sodipodi:docname="search-control-watermark.svg">
- <defs
- id="defs5420" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#d0d0d0"
- borderopacity="1"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="11.313708"
- inkscape:cx="16.668254"
- inkscape:cy="7.6484815"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- inkscape:showpageshadow="false"
- inkscape:window-width="770"
- inkscape:window-height="580"
- inkscape:window-x="218"
- inkscape:window-y="121" />
- <metadata
- id="metadata5423">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1">
- <path
- style="opacity:0.15340911;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- d="M 3.4291453,1.1191527 C 2.6305762,2.3552041 2.1745042,3.8208445 2.1745042,5.400878 C 2.174511,9.770892 5.7107317,13.327038 10.080746,13.327038 C 11.948965,13.327031 13.605421,12.578488 14.959918,11.494855 C 14.849633,12.035463 14.910326,12.599456 15.358218,12.988478 L 17.807759,15.099467 L 22.627183,15.099467 L 17.429377,10.578766 C 17.423744,10.573876 17.415133,10.563637 17.409459,10.558855 C 17.055382,10.268755 16.617709,10.181311 16.194648,10.240213 C 17.261341,8.891261 18.006906,7.252857 18.006906,5.400878 C 18.006906,3.8201565 17.531556,2.355531 16.732353,1.1191527 L 14.481959,1.1191527 C 15.505805,2.208877 16.1349,3.6692927 16.1349,5.281383 C 16.134907,8.642939 13.402473,11.375366 10.040917,11.375366 C 6.679374,11.375366 3.9469402,8.642939 3.9469402,5.281383 C 3.9469402,3.6706415 4.5775542,2.2085978 5.5998813,1.1191527 L 3.4291453,1.1191527 z "
- id="path5105" />
- </g>
-</svg>
diff --git a/libslab/search-entry.c b/libslab/search-entry.c
deleted file mode 100644
index 4e843ca4..00000000
--- a/libslab/search-entry.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * This file is part of libslab.
- *
- * Copyright (c) 2006 Novell, Inc.
- *
- * Libslab is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * Libslab is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libslab; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "search-entry.h"
-#include "search-entry-watermark.h"
-
-#include <librsvg/rsvg.h>
-#include <string.h>
-
-typedef struct
-{
- GdkPixbuf *watermark;
- int width, height;
-} NldSearchEntryPrivate;
-
-#define NLD_SEARCH_ENTRY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NLD_TYPE_SEARCH_ENTRY, NldSearchEntryPrivate))
-
-static void nld_search_entry_class_init (NldSearchEntryClass *);
-static void nld_search_entry_init (NldSearchEntry *);
-static void nld_search_entry_finalize (GObject *);
-
-static void nld_search_entry_realize (GtkWidget * widget);
-static gboolean nld_search_entry_draw (GtkWidget * widget, cairo_t * cr);
-
-G_DEFINE_TYPE (NldSearchEntry, nld_search_entry, GTK_TYPE_ENTRY)
-
-static void nld_search_entry_class_init (NldSearchEntryClass * nld_search_entry_class)
-{
- GObjectClass *g_obj_class = G_OBJECT_CLASS (nld_search_entry_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (nld_search_entry_class);
-
- g_type_class_add_private (nld_search_entry_class, sizeof (NldSearchEntryPrivate));
-
- widget_class->realize = nld_search_entry_realize;
- widget_class->draw = nld_search_entry_draw;
-
- g_obj_class->finalize = nld_search_entry_finalize;
-}
-
-static void
-nld_search_entry_init (NldSearchEntry * entry)
-{
-}
-
-static void
-nld_search_entry_finalize (GObject * object)
-{
- NldSearchEntryPrivate *priv = NLD_SEARCH_ENTRY_GET_PRIVATE (object);
-
- if (priv->watermark)
- g_object_unref (priv->watermark);
-
- G_OBJECT_CLASS (nld_search_entry_parent_class)->finalize (object);
-}
-
-static void
-rsvg_size_callback (int *width, int *height, gpointer user_data)
-{
- NldSearchEntryPrivate *priv = user_data;
-
- *width = priv->width = priv->height * (double) *width / (double) *height;
- *height = priv->height;
-}
-
-static void
-nld_search_entry_realize (GtkWidget * widget)
-{
- NldSearchEntryPrivate *priv = NLD_SEARCH_ENTRY_GET_PRIVATE (widget);
- int height;
- GdkColor *gdkcolor;
- char *svg, color[7];
- RsvgHandle *rsvg;
- GdkRectangle text_area;
-
- GTK_WIDGET_CLASS (nld_search_entry_parent_class)->realize (widget);
-
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
- height = text_area.height;
-
- if (height - 2 == priv->height)
- return;
- priv->height = height - 2;
-
- gdkcolor = &gtk_widget_get_style (widget)->fg[gtk_widget_get_state (widget)];
- snprintf (color, 7, "%02x%02x%02x", gdkcolor->red >> 8, gdkcolor->green >> 8,
- gdkcolor->blue >> 8);
- svg = g_strdup_printf (SEARCH_ENTRY_WATERMARK_SVG, color, color);
-
- rsvg = rsvg_handle_new ();
- rsvg_handle_set_size_callback (rsvg, rsvg_size_callback, priv, NULL);
- rsvg_handle_write (rsvg, (const guchar *) svg, strlen (svg), NULL);
- rsvg_handle_close (rsvg, NULL);
- g_free (svg);
-
- if (priv->watermark)
- g_object_unref (priv->watermark);
- priv->watermark = rsvg_handle_get_pixbuf (rsvg);
- g_object_unref (rsvg);
-}
-
-static gboolean
-nld_search_entry_draw (GtkWidget * widget, cairo_t * cr)
-{
- NldSearchEntryPrivate *priv = NLD_SEARCH_ENTRY_GET_PRIVATE (widget);
- GdkRectangle text_area;
-
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
-
- GTK_WIDGET_CLASS (nld_search_entry_parent_class)->draw (widget, cr);
-
- int width, x;
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- {
- width = text_area.width;
- x = width - priv->width - 1;
- }
- else
- x = 1;
-
- gdk_cairo_set_source_pixbuf (cr, priv->watermark, x, 1);
- cairo_paint (cr);
-
- return FALSE;
-}
-
-GtkWidget *
-nld_search_entry_new (void)
-{
- return g_object_new (NLD_TYPE_SEARCH_ENTRY, NULL);
-}
diff --git a/libslab/search-entry.h b/libslab/search-entry.h
deleted file mode 100644
index 0cb07db2..00000000
--- a/libslab/search-entry.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This file is part of libslab.
- *
- * Copyright (c) 2006 Novell, Inc.
- *
- * Libslab is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * Libslab is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with libslab; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __NLD_SEARCH_ENTRY_H__
-#define __NLD_SEARCH_ENTRY_H__
-
-#include <gtk/gtk.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NLD_TYPE_SEARCH_ENTRY (nld_search_entry_get_type ())
-#define NLD_SEARCH_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NLD_TYPE_SEARCH_ENTRY, NldSearchEntry))
-#define NLD_SEARCH_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NLD_TYPE_SEARCH_ENTRY, NldSearchEntryClass))
-#define NLD_IS_SEARCH_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NLD_TYPE_SEARCH_ENTRY))
-#define NLD_IS_SEARCH_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NLD_TYPE_SEARCH_ENTRY))
-#define NLD_SEARCH_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NLD_TYPE_SEARCH_ENTRY, NldSearchEntryClass))
-
-typedef struct
-{
- GtkEntry parent;
-} NldSearchEntry;
-
-typedef struct
-{
- GtkEntryClass parent_class;
-} NldSearchEntryClass;
-
-GType nld_search_entry_get_type (void);
-
-GtkWidget *nld_search_entry_new (void);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __NLD_SEARCH_ENTRY_H__ */
diff --git a/libslab/slab.h b/libslab/slab.h
index 2e4b0575..a50dddf9 100644
--- a/libslab/slab.h
+++ b/libslab/slab.h
@@ -32,7 +32,6 @@
#include "nameplate-tile.h"
#include "search-bar.h"
#include "search-context-picker.h"
-#include "search-entry.h"
#include "shell-window.h"
#include "slab-mate-util.h"
#include "slab-section.h"