From 3bfbcbee4014c60dded6e996721b5eca88d22bdb Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 19 Nov 2020 17:43:15 -0300 Subject: [PATCH] Styling dialog section. --- src/dialogs/popups.c | 3 +-- src/dialogs/tools.c | 9 +++------ src/include/v3270/tools.h | 3 +++ src/tools/entry.c | 8 -------- src/tools/widget.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ v3270.cbp | 3 +++ 6 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 src/tools/widget.c diff --git a/src/dialogs/popups.c b/src/dialogs/popups.c index d246d59..51c5d9f 100644 --- a/src/dialogs/popups.c +++ b/src/dialogs/popups.c @@ -38,8 +38,7 @@ static void v3270_dialog_add_class_for_response(GtkWidget *dialog, gint response_id, const char *className) { GtkWidget * widget = gtk_dialog_get_widget_for_response(GTK_DIALOG(dialog),response_id); - GtkStyleContext *context = gtk_widget_get_style_context(widget); - gtk_style_context_add_class(context,className); + gtk_widget_add_class(widget,className); } GtkResponseType v3270_popup_dialog_show(GtkWidget *widget, const LIB3270_POPUP *popup, gboolean wait) { diff --git a/src/dialogs/tools.c b/src/dialogs/tools.c index da418c0..82af615 100644 --- a/src/dialogs/tools.c +++ b/src/dialogs/tools.c @@ -29,6 +29,7 @@ #include #include + #include /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -50,7 +51,7 @@ // https://developer.gnome.org/hig/stable/visual-layout.html.en GtkFrame * frame = GTK_FRAME(gtk_frame_new("")); - GtkWidget * label = gtk_label_new(NULL); + GtkWidget * label = gtk_label_new(title); #ifdef G_OS_UNIX { @@ -58,16 +59,12 @@ g_autofree gchar * markup = g_strdup_printf("%s",title); gtk_label_set_markup(GTK_LABEL(label),markup); + gtk_widget_add_class(label,"separator"); g_object_set(G_OBJECT(frame),"margin-top",6,NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE); } -#else - { - // Non Unix/Linux, use the windows style. - gtk_label_set_text(GTK_LABEL(label),title); - } #endif // G_OS_UNIX gtk_frame_set_label_widget(GTK_FRAME(frame),label); diff --git a/src/include/v3270/tools.h b/src/include/v3270/tools.h index 8f1cca8..e68e20f 100644 --- a/src/include/v3270/tools.h +++ b/src/include/v3270/tools.h @@ -37,6 +37,9 @@ /// @brief Bind pointer to widget; release it when widget is destroyed. LIB3270_EXPORT void gtk_widget_bind_ptr(GtkWidget *widget, gpointer ptr); + /// @brief Add style to widget. + LIB3270_EXPORT void gtk_widget_add_class(GtkWidget *widget, const char *className); + /// @brief Bind file chooser with entry field. LIB3270_EXPORT void gtk_entry_bind_to_filechooser(GtkWidget *widget, GtkFileChooserAction action, const gchar *title, const gchar *icon_name, const gchar *pattern, const gchar *name); diff --git a/src/tools/entry.c b/src/tools/entry.c index b445859..7991ff2 100644 --- a/src/tools/entry.c +++ b/src/tools/entry.c @@ -139,14 +139,6 @@ } - static void release_ptr(GtkWidget G_GNUC_UNUSED(*object), gpointer ptr) { - g_free(ptr); - } - - LIB3270_EXPORT void gtk_widget_bind_ptr(GtkWidget *widget, gpointer ptr) { - g_signal_connect(widget,"destroy",G_CALLBACK(release_ptr),ptr); - } - LIB3270_EXPORT void gtk_entry_bind_to_filechooser(GtkWidget *widget, GtkFileChooserAction action, const gchar *title, const gchar *icon_name, const gchar *pattern, const gchar *name) { gtk_entry_set_icon_from_icon_name( diff --git a/src/tools/widget.c b/src/tools/widget.c new file mode 100644 index 0000000..7de079c --- /dev/null +++ b/src/tools/widget.c @@ -0,0 +1,49 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + /** + * @brief Useful extensions for GtkWidget. + * + */ + + #include + + LIB3270_EXPORT void gtk_widget_add_class(GtkWidget *widget, const char *className) { + GtkStyleContext *context = gtk_widget_get_style_context(widget); + gtk_style_context_add_class(context,className); + } + + static void release_ptr(GtkWidget G_GNUC_UNUSED(*object), gpointer ptr) { + g_free(ptr); + } + + LIB3270_EXPORT void gtk_widget_bind_ptr(GtkWidget *widget, gpointer ptr) { + g_signal_connect(widget,"destroy",G_CALLBACK(release_ptr),ptr); + } + diff --git a/v3270.cbp b/v3270.cbp index 65928bd..fa51a4f 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -408,6 +408,9 @@ + + -- libgit2 0.21.2