Use gtkinfobar in case we have gtk+ >= 2.17.1

parent d11b28ee
......@@ -235,6 +235,16 @@ fi
AM_CONDITIONAL(BUILD_SEXY, test "$gtkatleast" = "no")
dnl FIXME: Remove this when removing gedit-message-area
if $PKG_CONFIG --atleast-version 2.17.1 gtk+-2.0; then
gtkatleast=
else
gtkatleast=no
fi
AM_CONDITIONAL(BUILD_MESSAGE_AREA, test "$gtkatleast" = "no")
if test "$platform_osx" = "no" &&
test "$os_win32" = no; then
PKG_CHECK_MODULES(EGG_SMCLIENT, [
......
......@@ -88,7 +88,6 @@ INST_H_FILES = \
gedit-encodings-option-menu.h \
gedit-file-chooser-dialog.h \
gedit-help.h \
gedit-message-area.h \
gedit-message-bus.h \
gedit-message-type.h \
gedit-message.h \
......@@ -148,7 +147,6 @@ libgedit_la_SOURCES = \
gedit-history-entry.c \
gedit-io-error-message-area.c \
gedit-language-manager.c \
gedit-message-area.c \
gedit-message-bus.c \
gedit-message-type.c \
gedit-message.c \
......@@ -233,4 +231,8 @@ if BUILD_SEXY
libgedit_la_SOURCES += sexy-icon-entry.c sexy-icon-entry.h
endif
if BUILD_MESSAGE_AREA
libgedit_la_SOURCES += gedit-message-area.h gedit-message-area.c
endif
-include $(top_srcdir)/git.mk
......@@ -46,10 +46,13 @@
#include "gedit-convert.h"
#include "gedit-document.h"
#include "gedit-io-error-message-area.h"
#include "gedit-message-area.h"
#include "gedit-prefs-manager.h"
#include <gedit/gedit-encodings-option-menu.h>
#if !GTK_CHECK_VERSION (2, 17, 1)
#include "gedit-message-area.h"
#endif
#define MAX_URI_IN_DIALOG_LENGTH 50
static gboolean
......@@ -82,7 +85,40 @@ is_gio_error (const GError *error,
}
static void
set_message_area_text_and_icon (GeditMessageArea *message_area,
set_contents (GtkWidget *area,
GtkWidget *contents)
{
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (area),
contents);
#else
GtkWidget *content_area;
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (area));
gtk_container_add (GTK_CONTAINER (content_area), contents);
#endif
}
#if GTK_CHECK_VERSION (2, 17, 1)
static void
info_bar_add_stock_button_with_text (GtkInfoBar *infobar,
const gchar *text,
const gchar *stock_id,
gint response_id)
{
GtkWidget *button;
button = gedit_gtk_button_new_with_stock_icon (text, stock_id);
gtk_widget_show (button);
gtk_info_bar_add_action_widget (infobar,
button,
response_id);
}
#endif
static void
set_message_area_text_and_icon (GtkWidget *message_area,
const gchar *icon_stock_id,
const gchar *primary_text,
const gchar *secondary_text)
......@@ -133,8 +169,7 @@ set_message_area_text_and_icon (GeditMessageArea *message_area,
gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
}
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (message_area),
hbox_content);
set_contents (message_area, hbox_content);
}
static GtkWidget *
......@@ -143,11 +178,19 @@ create_io_loading_error_message_area (const gchar *primary_text,
{
GtkWidget *message_area;
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = gedit_message_area_new_with_buttons (
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
#else
message_area = gtk_info_bar_new_with_buttons (
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_ERROR);
#endif
set_message_area_text_and_icon (GEDIT_MESSAGE_AREA (message_area),
set_message_area_text_and_icon (message_area,
"gtk-dialog-error",
primary_text,
secondary_text);
......@@ -386,10 +429,17 @@ gedit_io_loading_error_message_area_new (const gchar *uri,
if (is_recoverable_error (error))
{
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
_("_Retry"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
#else
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Retry"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
#endif
}
g_free (uri_for_display);
......@@ -502,17 +552,31 @@ create_conversion_error_message_area (const gchar *primary_text,
gchar *secondary_markup;
GtkWidget *primary_label;
GtkWidget *secondary_label;
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = gedit_message_area_new ();
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
_("_Retry"),
GTK_STOCK_REDO,
GTK_RESPONSE_OK);
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Retry"),
GTK_STOCK_REDO,
GTK_RESPONSE_OK);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_ERROR);
#endif
hbox_content = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox_content);
......@@ -552,9 +616,9 @@ create_conversion_error_message_area (const gchar *primary_text,
}
create_option_menu (message_area, vbox);
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (message_area),
hbox_content);
set_contents (message_area, hbox_content);
return message_area;
}
......@@ -683,8 +747,12 @@ const GeditEncoding *
gedit_conversion_error_message_area_get_encoding (GtkWidget *message_area)
{
gpointer menu;
#if !GTK_CHECK_VERSION (2, 17, 1)
g_return_val_if_fail (GEDIT_IS_MESSAGE_AREA (message_area), NULL);
#else
g_return_val_if_fail (GTK_IS_INFO_BAR (message_area), NULL);
#endif
menu = g_object_get_data (G_OBJECT (message_area),
"gedit-message-area-encoding-menu");
......@@ -723,7 +791,8 @@ gedit_file_already_open_warning_message_area_new (const gchar *uri)
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = gedit_message_area_new ();
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
_("_Edit Anyway"),
......@@ -731,7 +800,18 @@ gedit_file_already_open_warning_message_area_new (const gchar *uri)
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
_("_Don't Edit"),
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new ();
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
_("_Edit Anyway"),
GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
_("_Don't Edit"),
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
#endif
hbox_content = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox_content);
......@@ -773,8 +853,8 @@ gedit_file_already_open_warning_message_area_new (const gchar *uri)
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (message_area),
hbox_content);
set_contents (message_area, hbox_content);
return message_area;
}
......@@ -815,6 +895,7 @@ gedit_externally_modified_saving_error_message_area_new (
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = gedit_message_area_new ();
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
_("S_ave Anyway"),
......@@ -823,6 +904,19 @@ gedit_externally_modified_saving_error_message_area_new (
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("S_ave Anyway"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
#endif
hbox_content = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox_content);
......@@ -868,8 +962,7 @@ gedit_externally_modified_saving_error_message_area_new (
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (message_area),
hbox_content);
set_contents (message_area, hbox_content);
return message_area;
}
......@@ -912,6 +1005,7 @@ gedit_no_backup_saving_error_message_area_new (const gchar *uri,
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = gedit_message_area_new ();
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
_("S_ave Anyway"),
......@@ -920,6 +1014,19 @@ gedit_no_backup_saving_error_message_area_new (const gchar *uri,
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("S_ave Anyway"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
#endif
hbox_content = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox_content);
......@@ -971,8 +1078,7 @@ gedit_no_backup_saving_error_message_area_new (const gchar *uri,
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5);
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (message_area),
hbox_content);
set_contents (message_area, hbox_content);
return message_area;
}
......@@ -1135,13 +1241,9 @@ gedit_externally_modified_message_area_new (const gchar *uri,
else
secondary_text = _("Do you want to reload the file?");
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = gedit_message_area_new ();
set_message_area_text_and_icon (GEDIT_MESSAGE_AREA (message_area),
"gtk-dialog-warning",
primary_text,
secondary_text);
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
_("_Reload"),
GTK_STOCK_REFRESH,
......@@ -1150,6 +1252,24 @@ gedit_externally_modified_message_area_new (const gchar *uri,
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Reload"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
#endif
set_message_area_text_and_icon (message_area,
"gtk-dialog-warning",
primary_text,
secondary_text);
return message_area;
}
......
......@@ -55,16 +55,26 @@ struct _GeditProgressMessageAreaPrivate
GtkWidget *progress;
};
#if !GTK_CHECK_VERSION (2, 17, 1)
G_DEFINE_TYPE(GeditProgressMessageArea, gedit_progress_message_area, GEDIT_TYPE_MESSAGE_AREA)
#else
G_DEFINE_TYPE(GeditProgressMessageArea, gedit_progress_message_area, GTK_TYPE_INFO_BAR)
#endif
static void
gedit_progress_message_area_set_has_cancel_button (GeditProgressMessageArea *area,
gboolean has_button)
{
if (has_button)
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_add_button (GEDIT_MESSAGE_AREA (area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_add_button (GTK_INFO_BAR (area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#endif
g_object_notify (G_OBJECT (area), "has-cancel-button");
}
......@@ -163,9 +173,16 @@ gedit_progress_message_area_init (GeditProgressMessageArea *area)
gtk_widget_show (area->priv->progress);
gtk_box_pack_start (GTK_BOX (vbox), area->priv->progress, TRUE, FALSE, 0);
gtk_widget_set_size_request (area->priv->progress, -1, 15);
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (area),
vbox);
#else
GtkWidget *content;
content = gtk_info_bar_get_content_area (GTK_INFO_BAR (area));
gtk_container_add (GTK_CONTAINER (content), vbox);
#endif
}
GtkWidget *
......
......@@ -31,7 +31,11 @@
#ifndef __GEDIT_PROGRESS_MESSAGE_AREA_H__
#define __GEDIT_PROGRESS_MESSAGE_AREA_H__
#if !GTK_CHECK_VERSION (2, 17, 1)
#include <gedit/gedit-message-area.h>
#else
#include <gtk/gtk.h>
#endif
G_BEGIN_DECLS
......@@ -55,7 +59,11 @@ typedef struct _GeditProgressMessageArea GeditProgressMessageArea;
struct _GeditProgressMessageArea
{
#if !GTK_CHECK_VERSION (2, 17, 1)
GeditMessageArea parent;
#else
GtkInfoBar parent;
#endif
/*< private > */
GeditProgressMessageAreaPrivate *priv;
......@@ -68,7 +76,11 @@ typedef struct _GeditProgressMessageAreaClass GeditProgressMessageAreaClass;
struct _GeditProgressMessageAreaClass
{
#if !GTK_CHECK_VERSION (2, 17, 1)
GeditMessageAreaClass parent_class;
#else
GtkInfoBarClass parent_class;
#endif
};
/*
......
......@@ -37,7 +37,6 @@
#include "gedit-notebook.h"
#include "gedit-tab.h"
#include "gedit-utils.h"
#include "gedit-message-area.h"
#include "gedit-io-error-message-area.h"
#include "gedit-print-job.h"
#include "gedit-print-preview.h"
......@@ -47,6 +46,10 @@
#include "gedit-convert.h"
#include "gedit-enum-types.h"
#if !GTK_CHECK_VERSION (2, 17, 1)
#include "gedit-message-area.h"
#endif
#define GEDIT_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_TAB, GeditTabPrivate))
#define GEDIT_TAB_KEY "GEDIT_TAB_KEY"
......@@ -462,7 +465,7 @@ remove_tab (GeditTab *tab)
}
static void
io_loading_error_message_area_response (GeditMessageArea *message_area,
io_loading_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -495,7 +498,7 @@ io_loading_error_message_area_response (GeditMessageArea *message_area,
}
static void
conversion_loading_error_message_area_response (GeditMessageArea *message_area,
conversion_loading_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -563,7 +566,7 @@ file_already_open_warning_message_area_response (GtkWidget *message_area,
}
static void
load_cancelled (GeditMessageArea *area,
load_cancelled (GtkWidget *area,
gint response_id,
GeditTab *tab)
{
......@@ -575,7 +578,7 @@ load_cancelled (GeditMessageArea *area,
}
static void
unrecoverable_reverting_error_message_area_response (GeditMessageArea *message_area,
unrecoverable_reverting_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -993,8 +996,13 @@ document_loaded (GeditDocument *document,
tab);
}
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_set_default_response (GEDIT_MESSAGE_AREA (emsg),
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg),
GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (emsg);
......@@ -1043,8 +1051,13 @@ document_loaded (GeditDocument *document,
set_message_area (tab, w);
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_set_default_response (GEDIT_MESSAGE_AREA (w),
GTK_RESPONSE_CANCEL);
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (w),
GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (w);
......@@ -1147,7 +1160,7 @@ end_saving (GeditTab *tab)
}
static void
unrecoverable_saving_error_message_area_response (GeditMessageArea *message_area,
unrecoverable_saving_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -1168,7 +1181,7 @@ unrecoverable_saving_error_message_area_response (GeditMessageArea *message_area
}
static void
no_backup_error_message_area_response (GeditMessageArea *message_area,
no_backup_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -1203,7 +1216,7 @@ no_backup_error_message_area_response (GeditMessageArea *message_area,
}
static void
externally_modified_error_message_area_response (GeditMessageArea *message_area,
externally_modified_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -1237,7 +1250,7 @@ externally_modified_error_message_area_response (GeditMessageArea *message_area,
}
static void
recoverable_saving_error_message_area_response (GeditMessageArea *message_area,
recoverable_saving_error_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -1372,9 +1385,14 @@ document_saved (GeditDocument *document,
G_CALLBACK (recoverable_saving_error_message_area_response),
tab);
}
#if !GTK_CHECK_VERSION (2, 17, 1)
gedit_message_area_set_default_response (GEDIT_MESSAGE_AREA (emsg),
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg),
GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (emsg);
}
......@@ -1399,7 +1417,7 @@ document_saved (GeditDocument *document,
}
static void
externally_modified_notification_message_area_response (GeditMessageArea *message_area,
externally_modified_notification_message_area_response (GtkWidget *message_area,
gint response_id,
GeditTab *tab)
{
......@@ -2453,7 +2471,7 @@ preview_finished_cb (GtkSourcePrintJob *pjob, GeditTab *tab)
#endif
static void
print_cancelled (GeditMessageArea *area,
print_cancelled (GtkWidget *area,
gint response_id,
GeditTab *tab)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment