summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/about.c16
-rw-r--r--gtk/compat.c31
-rw-r--r--gtk/compat.h34
3 files changed, 63 insertions, 18 deletions
diff --git a/gtk/about.c b/gtk/about.c
index 9ab600f9a..5e8818cdc 100644
--- a/gtk/about.c
+++ b/gtk/about.c
@@ -87,18 +87,10 @@ void nsgtk_about_dialog_init(GtkWindow *parent)
pixbufs = gtk_window_get_default_icon_list();
if (pixbufs != NULL) {
- GtkIconSet *icon_set;
GtkWidget *image;
- icon_set = gtk_icon_set_new_from_pixbuf(GDK_PIXBUF(g_list_nth_data(pixbufs, 0)));
-
- image = gtk_image_new();
-
- gtk_image_set_from_icon_set(GTK_IMAGE(image),
- icon_set,
- GTK_ICON_SIZE_DIALOG);
-
- gtk_icon_set_unref(icon_set);
+ image = nsgtk_image_new_from_pixbuf_icon(GDK_PIXBUF(g_list_nth_data(pixbufs, 0)),
+ GTK_ICON_SIZE_DIALOG);
g_list_free(pixbufs);
gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0);
@@ -131,14 +123,14 @@ void nsgtk_about_dialog_init(GtkWindow *parent)
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
/* Add the credits button */
- button = gtk_button_new_from_stock ("Credits");
+ button = nsgtk_button_new_from_stock("Credits");
gtk_box_pack_end(GTK_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))),
button, FALSE, TRUE, 0);
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE);
g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_info), (gpointer)"about:credits");
/* Add the Licence button */
- button = gtk_button_new_from_stock ("Licence");
+ button = nsgtk_button_new_from_stock("Licence");
gtk_box_pack_end(GTK_BOX (nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))),
button, FALSE, TRUE, 0);
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(nsgtk_dialog_get_action_area(GTK_DIALOG(dialog))), button, TRUE);
diff --git a/gtk/compat.c b/gtk/compat.c
index fe57ba285..3248254fd 100644
--- a/gtk/compat.c
+++ b/gtk/compat.c
@@ -316,7 +316,7 @@ const PangoFontDescription* nsgtk_style_context_get_font(GtkStyleContext *style,
GtkStateFlags state)
{
#if GTK_CHECK_VERSION(3,8,0)
- const PangoFontDescription* fontdesc;
+ const PangoFontDescription* fontdesc = NULL;
gtk_style_context_get(style, state, GTK_STYLE_PROPERTY_FONT, &fontdesc, NULL);
return fontdesc;
#else
@@ -454,3 +454,32 @@ void nsgtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation)
allocation->height = widget->allocation.height;
#endif
}
+
+/* exported interface documented in gtk/compat.h */
+GtkWidget *nsgtk_image_new_from_pixbuf_icon(GdkPixbuf *pixbuf, GtkIconSize size)
+{
+#if GTK_CHECK_VERSION(3,10,0)
+ return gtk_image_new_from_pixbuf(pixbuf);
+#else
+ GtkIconSet *icon_set;
+ GtkWidget *image;
+
+ icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
+
+ image = gtk_image_new_from_icon_set(icon_set, size);
+
+ gtk_icon_set_unref(icon_set);
+
+ return image;
+#endif
+}
+
+/* exported interface documented in gtk/compat.h */
+GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id)
+{
+#if GTK_CHECK_VERSION(3,10,0)
+ return gtk_button_new_with_label(stock_id);
+#else
+ return nsgtk_button_new_from_stock(stock_id);
+#endif
+}
diff --git a/gtk/compat.h b/gtk/compat.h
index 4f83aac46..42deab2ac 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -73,6 +73,14 @@ GtkWidget *nsgtk_combo_box_text_new(void);
void nsgtk_combo_box_text_append_text(GtkWidget *combo_box, const gchar *text);
gchar *nsgtk_combo_box_text_get_active_text(GtkWidget *combo_box);
+/**
+ * creates a new image widget of an appropriate icon size from a pixbuf.
+ *
+ * \param pixbuf The pixbuf to use as a source.
+ * \param size The size of icon to create
+ * \return An image widget.
+ */
+GtkWidget *nsgtk_image_new_from_pixbuf_icon(GdkPixbuf *pixbuf, GtkIconSize size);
/* GTK prior to 2.16 needs the sexy interface for icons */
#if !GTK_CHECK_VERSION(2,16,0)
@@ -111,23 +119,39 @@ enum {
#endif
-GtkWidget *nsgtk_entry_new(void);
-void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf);
/**
- * Sets the icon shown in the entry at the specified position from a stock image.
+ * Sets the icon shown in the entry at the specified position from a
+ * stock image.
+ *
+ * Compatability interface for original deprecated in GTK 3.10
*
- * Compatability interface for interface deprecated in 3.10
+ * \param stock_id the name of the stock item
*/
void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
/**
* Creates a GtkImage displaying a stock icon.
*
- * Compatability interface for interface deprecated in 3.10
+ * Compatability interface for original deprecated in GTK 3.10
+ *
+ * \param stock_id the name of the stock item
*/
GtkWidget *nsgtk_image_new_from_stock(const gchar *stock_id, GtkIconSize size);
+/**
+ * Creates a new GtkButton containing the image and text from a stock item.
+ *
+ * Compatability interface for original deprecated in GTK 3.10
+ *
+ * \param stock_id the name of the stock item
+ */
+GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id);
+
+GtkWidget *nsgtk_entry_new(void);
+
+void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf);
+
void nsgtk_widget_override_background_color(GtkWidget *widget, GtkStateFlags state, uint16_t a, uint16_t r, uint16_t g, uint16_t b);
GtkWidget* nsgtk_hbox_new(gboolean homogeneous, gint spacing);
GtkWidget* nsgtk_vbox_new(gboolean homogeneous, gint spacing);