This is an automated email from the git hooks/post-receive script. a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository apps/xfce4-dict.
commit bc968c2f61df384368bfa5d65586aa5b0d510c40 Author: Andre Miranda <andre...@xfce.org> Date: Sat May 26 17:20:33 2018 -0300 Get rid of custom label widget --- lib/Makefile.am | 10 ++-- lib/prefs.c | 17 +++--- lib/speedreader.c | 4 +- lib/wraplabel.c | 165 ------------------------------------------------------ lib/wraplabel.h | 46 --------------- 5 files changed, 15 insertions(+), 227 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index 44f9c4e..c8f023a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,9 +18,7 @@ libdict_la_SOURCES = \ speedreader.c \ speedreader.h \ spell.c \ - spell.h \ - wraplabel.c \ - wraplabel.h + spell.h libdict_la_CFLAGS = \ -I$(top_srcdir) \ @@ -35,9 +33,9 @@ libdict_la_LIBADD = \ @GTHREAD_LIBS@ DISTCLEANFILES = \ - resources.c \ - resources.h \ - dbus.c \ + resources.c \ + resources.h \ + dbus.c \ dbus.h gui.c: resources.c dbus.c diff --git a/lib/prefs.c b/lib/prefs.c index 3f10a1a..830f632 100644 --- a/lib/prefs.c +++ b/lib/prefs.c @@ -31,7 +31,6 @@ #include "prefs.h" #include "dictd.h" #include "spell.h" -#include "wraplabel.h" typedef struct @@ -271,6 +270,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_window_set_icon_name(GTK_WINDOW(dialog), "xfce4-dict"); + gtk_window_set_default_size (GTK_WINDOW(dialog), 500, 450); if (! dd->is_plugin) /* the response callback is run by the plugin's callback */ g_signal_connect(dialog, "response", G_CALLBACK(dict_prefs_dialog_response), dd); @@ -284,7 +284,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) /* * Page: general */ -#define PAGE_GENERAL /* only for navigation in Geany's symbol list ;-) */ +#define PAGE_GENERAL { GtkWidget *radio_button, *label, *grid, *label4; GtkWidget *color_link, *color_phon, *color_success, *color_error; @@ -444,7 +444,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) /* * Page: DICTD */ -#define PAGE_DICTD /* only for navigation in Geany's symbol list ;-) */ +#define PAGE_DICTD { GtkWidget *grid, *button_get_list, *button_get_info; GtkWidget *server_entry, *port_spinner, *dict_combo; @@ -494,7 +494,6 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) } } - g_object_set_data(G_OBJECT(dialog), "server_entry", server_entry); g_object_set_data(G_OBJECT(dialog), "port_spinner", port_spinner); g_object_set_data(G_OBJECT(dialog), "dict_combo", dict_combo); @@ -550,7 +549,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) /* * Page: WEB */ -#define PAGE_WEB /* only for navigation in Geany's symbol list ;-) */ +#define PAGE_WEB { GtkWidget *label, *web_entry_label, *web_entry, *web_entry_box, *web_dicts_table; @@ -587,7 +586,8 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) g_object_set_data(G_OBJECT(dialog), "web_entry", web_entry); - label1 = xfd_wrap_label_new(_("Enter the URL of a web site which offers translation or dictionary services. Use {word} as placeholder for the searched word.")); + label1 = gtk_label_new(_("Enter the URL of a web site which offers translation or dictionary services. Use {word} as placeholder for the searched word.")); + gtk_label_set_line_wrap(GTK_LABEL(label1), TRUE); gtk_widget_show(label1); gtk_box_pack_start(GTK_BOX(inner_vbox), label1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(notebook_vbox), inner_vbox, TRUE, TRUE, 5); @@ -596,7 +596,7 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) /* * Page: SPELL */ -#define PAGE_SPELL /* only for navigation in Geany's symbol list ;-) */ +#define PAGE_SPELL { GtkWidget *grid, *label_help, *spell_entry, *spell_combo, *button_refresh, *icon; @@ -624,10 +624,11 @@ GtkWidget *dict_prefs_dialog_show(GtkWidget *parent, DictData *dd) g_signal_connect(spell_entry, "activate", G_CALLBACK(spell_entry_activate_cb), dd); gtk_widget_show(spell_entry); - label_help = xfd_wrap_label_new(_( + label_help = gtk_label_new(_( "<i>The spell check program can be 'enchant', 'aspell', 'ispell' or any other spell check " "program which is compatible to the ispell command.\nThe icon shows whether the entered " "command exists.</i>")); + gtk_label_set_line_wrap(GTK_LABEL(label_help), TRUE); gtk_label_set_use_markup(GTK_LABEL(label_help), TRUE); gtk_widget_show(label_help); diff --git a/lib/speedreader.c b/lib/speedreader.c index 0cd43ef..f4670ff 100644 --- a/lib/speedreader.c +++ b/lib/speedreader.c @@ -23,7 +23,6 @@ #include <glib/gi18n.h> #include "common.h" -#include "wraplabel.h" #include "speedreader.h" @@ -605,9 +604,10 @@ static void xfd_speed_reader_init(XfdSpeedReader *dialog) gtk_widget_set_name(GTK_WIDGET(dialog), "Xfce4Dict"); /* First page */ - label_intro = xfd_wrap_label_new( + label_intro = gtk_label_new( _("This is an easy speed reading utility to help train you to read faster. " "It does this by flashing words at a rapid rate on the screen.")); + gtk_label_set_line_wrap (GTK_LABEL (label_intro), TRUE); gtk_label_set_line_wrap ( GTK_LABEL (label_intro), TRUE); label_words = gtk_label_new_with_mnemonic(_("_Words per Minute:")); diff --git a/lib/wraplabel.c b/lib/wraplabel.c deleted file mode 100644 index b1d10cf..0000000 --- a/lib/wraplabel.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * wraplabel.c - * - * Copyright 2008-2011 Enrico Tröger <enrico(at)xfce(dot)org> - * Copyright 2008-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * A GtkLabel subclass that can wrap to any width, unlike GtkLabel which has a fixed wrap point. - * (inspired by libview's WrapLabel, http://view.sourceforge.net) - */ - - -#include <gtk/gtk.h> -#include "wraplabel.h" - - - -#define XFD_WRAP_LABEL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ - XFD_WRAP_LABEL_TYPE, XfdWrapLabelPrivate)) - -struct _XfdWrapLabelClass -{ - GtkLabelClass parent_class; -}; - -struct _XfdWrapLabel -{ - GtkLabel parent; -}; - -typedef struct -{ - gsize wrap_width; -} XfdWrapLabelPrivate; - - -G_DEFINE_TYPE(XfdWrapLabel, xfd_wrap_label, GTK_TYPE_LABEL); - -static void xfd_wrap_label_size_request (GtkWidget *widget, GtkRequisition *req); -static void xfd_wrap_label_size_allocate (GtkWidget *widget, GtkAllocation *alloc); -static void xfd_wrap_label_set_wrap_width (GtkWidget *widget, gsize width); -static void xfd_wrap_label_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width); -static void xfd_wrap_label_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height); - - -static void xfd_wrap_label_class_init(XfdWrapLabelClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - - widget_class->get_preferred_width = xfd_wrap_label_get_preferred_width; - widget_class->get_preferred_height = xfd_wrap_label_get_preferred_height; - widget_class->size_allocate = xfd_wrap_label_size_allocate; - - g_type_class_add_private(klass, sizeof (XfdWrapLabelPrivate)); -} - - -static void xfd_wrap_label_init(XfdWrapLabel *self) -{ - XfdWrapLabelPrivate *priv = XFD_WRAP_LABEL_GET_PRIVATE(self); - - priv->wrap_width = 0; -} - - -/* Sets the point at which the text should wrap. */ -static void xfd_wrap_label_set_wrap_width(GtkWidget *widget, gsize width) -{ - XfdWrapLabelPrivate *priv; - - if (width == 0) - return; - - /* - * We may need to reset the wrap width, so do this regardless of whether - * or not we've changed the width. - */ - pango_layout_set_width(gtk_label_get_layout(GTK_LABEL(widget)), width * PANGO_SCALE); - - priv = XFD_WRAP_LABEL_GET_PRIVATE(widget); - if (priv->wrap_width != width) - { - priv->wrap_width = width; - gtk_widget_queue_resize(widget); - } -} - - -/* Forces the height to be the size necessary for the Pango layout, while allowing the - * width to be flexible. */ -static void xfd_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req) -{ - gint height; - - pango_layout_get_pixel_size(gtk_label_get_layout(GTK_LABEL(widget)), NULL, &height); - - req->width = 0; - req->height = height; -} - - -/* Sets the wrap width to the width allocated to us. */ -static void xfd_wrap_label_size_allocate(GtkWidget *widget, GtkAllocation *alloc) -{ - (* GTK_WIDGET_CLASS(xfd_wrap_label_parent_class)->size_allocate)(widget, alloc); - - xfd_wrap_label_set_wrap_width(widget, alloc->width); -} - - -static void -xfd_wrap_label_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width) -{ - GtkRequisition requisition; - - xfd_wrap_label_size_request (widget, &requisition); - *minimal_width = *natural_width = requisition.width; -} - -static void -xfd_wrap_label_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height) -{ - GtkRequisition requisition; - - xfd_wrap_label_size_request (widget, &requisition); - *minimal_height = *natural_height = requisition.height; -} - - -void xfd_wrap_label_set_text(GtkLabel *label, const gchar *text) -{ - XfdWrapLabelPrivate *priv = XFD_WRAP_LABEL_GET_PRIVATE(label); - - gtk_label_set_text(label, text); - xfd_wrap_label_set_wrap_width(GTK_WIDGET(label), priv->wrap_width); -} - - -GtkWidget *xfd_wrap_label_new(const gchar *text) -{ - GtkWidget *l = g_object_new(XFD_WRAP_LABEL_TYPE, NULL); - - if (text != NULL && text[0] != '\0') - gtk_label_set_text(GTK_LABEL(l), text); - - pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(l)), PANGO_WRAP_WORD_CHAR); - - return l; -} diff --git a/lib/wraplabel.h b/lib/wraplabel.h deleted file mode 100644 index bef344f..0000000 --- a/lib/wraplabel.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * wraplabel.h - * - * Copyright 2008-2011 Enrico Tröger <enrico(at)xfce(dot)org> - * Copyright 2008-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef __WRAP_LABEL_H__ -#define __WRAP_LABEL_H__ - -G_BEGIN_DECLS - - -#define XFD_WRAP_LABEL_TYPE (xfd_wrap_label_get_type()) -#define XFD_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFD_WRAP_LABEL_TYPE, XfdWrapLabel)) -#define XFD_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFD_WRAP_LABEL_TYPE, XfdWrapLabelClass)) -#define IS_XFD_WRAP_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFD_WRAP_LABEL_TYPE)) -#define IS_XFD_WRAP_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFD_WRAP_LABEL_TYPE)) - - -typedef struct _XfdWrapLabel XfdWrapLabel; -typedef struct _XfdWrapLabelClass XfdWrapLabelClass; - -GType xfd_wrap_label_get_type (void); -GtkWidget* xfd_wrap_label_new (const gchar *text); -void xfd_wrap_label_set_text (GtkLabel *label, const gchar *text); - - -G_END_DECLS - -#endif /* __WRAP_LABEL_H__ */ -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits