Drop support for gtk+ < 2.24

* Bump required gtk+2 version
* Remove pluma-spinner
* Remove pluma-message-are
This commit is contained in:
infirit 2014-05-19 15:45:02 +02:00
parent 51291bf1b2
commit cc28312a3f
25 changed files with 1 additions and 2211 deletions

View File

@ -280,7 +280,7 @@ AC_MSG_RESULT([$with_gtk])
case "$with_gtk" in case "$with_gtk" in
2.0) GTK_API_VERSION=2.0 2.0) GTK_API_VERSION=2.0
GTK_REQUIRED=2.20.0 GTK_REQUIRED=2.24.0
;; ;;
3.0) GTK_API_VERSION=3.0 3.0) GTK_API_VERSION=3.0
GTK_REQUIRED=3.0.0 GTK_REQUIRED=3.0.0
@ -315,29 +315,6 @@ PLUMA_LIBS="$PLUMA_LIBS $X11_LIBS"
AC_SUBST(PLUMA_CFLAGS) AC_SUBST(PLUMA_CFLAGS)
AC_SUBST(PLUMA_LIBS) AC_SUBST(PLUMA_LIBS)
dnl FIXME: Remove this when removing pluma-message-area
if $PKG_CONFIG --atleast-version 2.17.1 gtk+-$GTK_API_VERSION; then
gtkatleast=
else
gtkatleast=no
fi
AM_CONDITIONAL(BUILD_MESSAGE_AREA, test "$gtkatleast" = "no")
dnl FIXME: Remove this when removing pluma-spinner
if $PKG_CONFIG --atleast-version 2.19.0 gtk+-$GTK_API_VERSION; then
gtkatleast=
else
gtkatleast=no
fi
AM_CONDITIONAL(BUILD_SPINNER, test "$gtkatleast" = "no")
if test "$gtkatleast" = "no"; then
AC_DEFINE([BUILD_SPINNER],[1],[Whether to use PlumaSpinner instead of GtkSpinner])
fi
if test "$os_osx" = "no" && if test "$os_osx" = "no" &&
test "$os_win32" = "no"; then test "$os_win32" = "no"; then
PKG_CHECK_MODULES(EGG_SMCLIENT, [ PKG_CHECK_MODULES(EGG_SMCLIENT, [

View File

@ -46,13 +46,11 @@ IGNORE_HFILES= \
pluma-documents-panel.h \ pluma-documents-panel.h \
pluma-io-error-message-area.h \ pluma-io-error-message-area.h \
pluma-languages-manager.h \ pluma-languages-manager.h \
pluma-message-area.h \
pluma-object-module.h \ pluma-object-module.h \
pluma-plugin-manager.h \ pluma-plugin-manager.h \
pluma-plugins-engine.h \ pluma-plugins-engine.h \
pluma-prefs-manager-private.h \ pluma-prefs-manager-private.h \
pluma-session.h \ pluma-session.h \
pluma-spinner.h \
pluma-ui.h \ pluma-ui.h \
pluma-window-private.h \ pluma-window-private.h \
pluma-output-window.h \ pluma-output-window.h \

View File

@ -31,10 +31,6 @@
#include <gio/gio.h> #include <gio/gio.h>
#if !GTK_CHECK_VERSION(2, 17, 1)
#include <pluma/pluma-message-area.h>
#endif
#define SETTINGS_SCHEMA "org.mate.pluma.plugins.checkupdate" #define SETTINGS_SCHEMA "org.mate.pluma.plugins.checkupdate"
#define SETTINGS_IGNORE_VERSION "ignore-version" #define SETTINGS_IGNORE_VERSION "ignore-version"
@ -141,15 +137,10 @@ static void
set_contents (GtkWidget *infobar, set_contents (GtkWidget *infobar,
GtkWidget *contents) GtkWidget *contents)
{ {
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_contents (PLUMA_MESSAGE_AREA (infobar),
contents);
#else
GtkWidget *content_area; GtkWidget *content_area;
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar)); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar));
gtk_container_add (GTK_CONTAINER (content_area), contents); gtk_container_add (GTK_CONTAINER (content_area), contents);
#endif
} }
static void static void
@ -278,21 +269,6 @@ create_infobar (PlumaWindow *window,
GtkWidget *infobar; GtkWidget *infobar;
gchar *message; gchar *message;
#if !GTK_CHECK_VERSION (2, 17, 1)
infobar = pluma_message_area_new ();
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (infobar),
_("_Download"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (infobar),
_("_Ignore Version"),
GTK_STOCK_DISCARD,
GTK_RESPONSE_NO);
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (infobar),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#else
GtkWidget *button; GtkWidget *button;
infobar = gtk_info_bar_new (); infobar = gtk_info_bar_new ();
@ -319,7 +295,6 @@ create_infobar (PlumaWindow *window,
gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar),
GTK_MESSAGE_INFO); GTK_MESSAGE_INFO);
#endif
message = g_strdup_printf ("%s (%s)", _("There is a new version of pluma"), version); message = g_strdup_printf ("%s (%s)", _("There is a new version of pluma"), version);
set_message_area_text_and_icon (infobar, set_message_area_text_and_icon (infobar,

View File

@ -997,11 +997,7 @@ create_toolbar (PlumaFileBrowserWidget * obj,
"DirectoryPrevious"); "DirectoryPrevious");
g_object_set (action, "is_important", TRUE, "short_label", g_object_set (action, "is_important", TRUE, "short_label",
_("Previous location"), NULL); _("Previous location"), NULL);
#if GTK_CHECK_VERSION (2, 16, 0)
gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action); gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
#else
gtk_action_connect_proxy (action, widget);
#endif
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 0); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 0);
/* Next directory menu tool item */ /* Next directory menu tool item */
@ -1022,11 +1018,7 @@ create_toolbar (PlumaFileBrowserWidget * obj,
"DirectoryNext"); "DirectoryNext");
g_object_set (action, "is_important", TRUE, "short_label", g_object_set (action, "is_important", TRUE, "short_label",
_("Previous location"), NULL); _("Previous location"), NULL);
#if GTK_CHECK_VERSION (2, 16, 0)
gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action); gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
#else
gtk_action_connect_proxy (action, widget);
#endif
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 1); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 1);
gtk_box_pack_start (GTK_BOX (obj), toolbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (obj), toolbar, FALSE, FALSE, 0);

View File

@ -238,14 +238,4 @@ else
BACON_DIR= BACON_DIR=
endif endif
if BUILD_MESSAGE_AREA
libpluma_la_SOURCES += pluma-message-area.c
INST_H_FILES += pluma-message-area.h
endif
if BUILD_SPINNER
libpluma_la_SOURCES += pluma-spinner.c
NOINST_H_FILES += pluma-spinner.h
endif
-include $(top_srcdir)/git.mk -include $(top_srcdir)/git.mk

View File

@ -42,23 +42,6 @@
#include "pluma-tab.h" #include "pluma-tab.h"
#include "pluma-debug.h" #include "pluma-debug.h"
#if !GTK_CHECK_VERSION (2, 17, 4)
void
_pluma_cmd_file_page_setup (GtkAction *action,
PlumaWindow *window)
{
PlumaTab *tab;
pluma_debug (DEBUG_COMMANDS);
tab = pluma_window_get_active_tab (window);
if (tab == NULL)
return;
_pluma_tab_page_setup (tab);
}
#endif
void void
_pluma_cmd_file_print_preview (GtkAction *action, _pluma_cmd_file_print_preview (GtkAction *action,
PlumaWindow *window) PlumaWindow *window)

View File

@ -154,13 +154,6 @@ void _pluma_cmd_file_close_tab (PlumaTab *tab,
void _pluma_cmd_file_save_documents_list (PlumaWindow *window, void _pluma_cmd_file_save_documents_list (PlumaWindow *window,
GList *docs); GList *docs);
#if !GTK_CHECK_VERSION (2, 17, 4)
void _pluma_cmd_file_page_setup (GtkAction *action,
PlumaWindow *window);
#endif
G_END_DECLS G_END_DECLS
#endif /* __PLUMA_COMMANDS_H__ */ #endif /* __PLUMA_COMMANDS_H__ */

View File

@ -191,11 +191,7 @@ add_or_remove (PlumaEncodingsComboBox *menu,
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu)); GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
#if !GTK_CHECK_VERSION (2, 18, 0)
if (!GTK_WIDGET_TOPLEVEL (toplevel))
#else
if (!gtk_widget_is_toplevel (toplevel)) if (!gtk_widget_is_toplevel (toplevel))
#endif
toplevel = NULL; toplevel = NULL;
g_signal_handler_block (menu, menu->priv->changed_id); g_signal_handler_block (menu, menu->priv->changed_id);

View File

@ -48,10 +48,6 @@
#include "pluma-prefs-manager.h" #include "pluma-prefs-manager.h"
#include <pluma/pluma-encodings-combo-box.h> #include <pluma/pluma-encodings-combo-box.h>
#if !GTK_CHECK_VERSION (2, 17, 1)
#include "pluma-message-area.h"
#endif
#define MAX_URI_IN_DIALOG_LENGTH 50 #define MAX_URI_IN_DIALOG_LENGTH 50
static gboolean static gboolean
@ -87,18 +83,12 @@ static void
set_contents (GtkWidget *area, set_contents (GtkWidget *area,
GtkWidget *contents) GtkWidget *contents)
{ {
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_contents (PLUMA_MESSAGE_AREA (area),
contents);
#else
GtkWidget *content_area; GtkWidget *content_area;
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (area)); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (area));
gtk_container_add (GTK_CONTAINER (content_area), contents); gtk_container_add (GTK_CONTAINER (content_area), contents);
#endif
} }
#if GTK_CHECK_VERSION (2, 17, 1)
static void static void
info_bar_add_stock_button_with_text (GtkInfoBar *infobar, info_bar_add_stock_button_with_text (GtkInfoBar *infobar,
const gchar *text, const gchar *text,
@ -112,7 +102,6 @@ info_bar_add_stock_button_with_text (GtkInfoBar *infobar,
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_image (GTK_BUTTON (button), image);
} }
#endif
static void static void
set_message_area_text_and_icon (GtkWidget *message_area, set_message_area_text_and_icon (GtkWidget *message_area,
@ -172,17 +161,11 @@ create_io_loading_error_message_area (const gchar *primary_text,
{ {
GtkWidget *message_area; GtkWidget *message_area;
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = pluma_message_area_new_with_buttons (
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
#else
message_area = gtk_info_bar_new_with_buttons ( message_area = gtk_info_bar_new_with_buttons (
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL); NULL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_ERROR); GTK_MESSAGE_ERROR);
#endif
set_message_area_text_and_icon (message_area, set_message_area_text_and_icon (message_area,
"gtk-dialog-error", "gtk-dialog-error",
@ -191,17 +174,10 @@ create_io_loading_error_message_area (const gchar *primary_text,
if (recoverable_error) if (recoverable_error)
{ {
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (message_area),
_("_Retry"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
#else
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Retry"), _("_Retry"),
GTK_STOCK_REFRESH, GTK_STOCK_REFRESH,
GTK_RESPONSE_OK); GTK_RESPONSE_OK);
#endif
} }
return message_area; return message_area;
@ -498,30 +474,6 @@ create_conversion_error_message_area (const gchar *primary_text,
GtkWidget *primary_label; GtkWidget *primary_label;
GtkWidget *secondary_label; GtkWidget *secondary_label;
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = pluma_message_area_new ();
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (message_area),
_("_Retry"),
GTK_STOCK_REDO,
GTK_RESPONSE_OK);
if (edit_anyway)
{
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
_("Edit Any_way"),
GTK_RESPONSE_YES);
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
_("D_on't Edit"),
GTK_RESPONSE_NO);
}
else
{
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
}
#else
message_area = gtk_info_bar_new (); message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
@ -552,7 +504,6 @@ create_conversion_error_message_area (const gchar *primary_text,
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_ERROR); GTK_MESSAGE_ERROR);
} }
#endif
hbox_content = gtk_hbox_new (FALSE, 8); hbox_content = gtk_hbox_new (FALSE, 8);
@ -765,11 +716,7 @@ pluma_conversion_error_message_area_get_encoding (GtkWidget *message_area)
{ {
gpointer menu; gpointer menu;
#if !GTK_CHECK_VERSION (2, 17, 1)
g_return_val_if_fail (PLUMA_IS_MESSAGE_AREA (message_area), NULL);
#else
g_return_val_if_fail (GTK_IS_INFO_BAR (message_area), NULL); g_return_val_if_fail (GTK_IS_INFO_BAR (message_area), NULL);
#endif
menu = g_object_get_data (G_OBJECT (message_area), menu = g_object_get_data (G_OBJECT (message_area),
"pluma-message-area-encoding-menu"); "pluma-message-area-encoding-menu");
@ -809,15 +756,6 @@ pluma_file_already_open_warning_message_area_new (const gchar *uri)
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display); uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display); g_free (temp_uri_for_display);
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = pluma_message_area_new ();
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
_("Edit Any_way"),
GTK_RESPONSE_YES);
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
_("D_on't Edit"),
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new (); message_area = gtk_info_bar_new ();
gtk_info_bar_add_button (GTK_INFO_BAR (message_area), gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
/* Translators: the access key chosen for this string should be /* Translators: the access key chosen for this string should be
@ -831,7 +769,6 @@ pluma_file_already_open_warning_message_area_new (const gchar *uri)
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING); GTK_MESSAGE_WARNING);
#endif
hbox_content = gtk_hbox_new (FALSE, 8); hbox_content = gtk_hbox_new (FALSE, 8);
@ -912,16 +849,6 @@ pluma_externally_modified_saving_error_message_area_new (
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display); uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display); g_free (temp_uri_for_display);
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = pluma_message_area_new ();
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (message_area),
_("S_ave Anyway"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new (); message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
@ -933,7 +860,6 @@ pluma_externally_modified_saving_error_message_area_new (
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING); GTK_MESSAGE_WARNING);
#endif
hbox_content = gtk_hbox_new (FALSE, 8); hbox_content = gtk_hbox_new (FALSE, 8);
@ -1018,16 +944,6 @@ pluma_no_backup_saving_error_message_area_new (const gchar *uri,
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display); uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display); g_free (temp_uri_for_display);
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = pluma_message_area_new ();
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (message_area),
_("S_ave Anyway"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new (); message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
@ -1039,7 +955,6 @@ pluma_no_backup_saving_error_message_area_new (const gchar *uri,
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING); GTK_MESSAGE_WARNING);
#endif
hbox_content = gtk_hbox_new (FALSE, 8); hbox_content = gtk_hbox_new (FALSE, 8);
@ -1253,18 +1168,6 @@ pluma_externally_modified_message_area_new (const gchar *uri,
else else
secondary_text = _("Do you want to reload the file?"); secondary_text = _("Do you want to reload the file?");
#if !GTK_CHECK_VERSION (2, 17, 1)
message_area = pluma_message_area_new ();
pluma_message_area_add_stock_button_with_text (PLUMA_MESSAGE_AREA (message_area),
_("_Reload"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#else
message_area = gtk_info_bar_new (); message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
@ -1276,7 +1179,6 @@ pluma_externally_modified_message_area_new (const gchar *uri,
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING); GTK_MESSAGE_WARNING);
#endif
set_message_area_text_and_icon (message_area, set_message_area_text_and_icon (message_area,
"gtk-dialog-warning", "gtk-dialog-warning",

View File

@ -1,626 +0,0 @@
/*
* pluma-message-area.c
* This file is part of pluma
*
* Copyright (C) 2005 - Paolo Maggi
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the pluma Team, 2005. See the AUTHORS file for a
* list of people on the pluma Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
/* TODO: Style properties */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include "pluma-message-area.h"
#define PLUMA_MESSAGE_AREA_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
PLUMA_TYPE_MESSAGE_AREA, \
PlumaMessageAreaPrivate))
struct _PlumaMessageAreaPrivate
{
GtkWidget *main_hbox;
GtkWidget *contents;
GtkWidget *action_area;
gboolean changing_style;
};
typedef struct _ResponseData ResponseData;
struct _ResponseData
{
gint response_id;
};
enum {
RESPONSE,
CLOSE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(PlumaMessageArea, pluma_message_area, GTK_TYPE_HBOX)
static void
pluma_message_area_finalize (GObject *object)
{
/*
PlumaMessageArea *message_area = PLUMA_MESSAGE_AREA (object);
*/
G_OBJECT_CLASS (pluma_message_area_parent_class)->finalize (object);
}
static ResponseData *
get_response_data (GtkWidget *widget,
gboolean create)
{
ResponseData *ad = g_object_get_data (G_OBJECT (widget),
"pluma-message-area-response-data");
if (ad == NULL && create)
{
ad = g_new (ResponseData, 1);
g_object_set_data_full (G_OBJECT (widget),
"pluma-message-area-response-data",
ad,
g_free);
}
return ad;
}
static GtkWidget *
find_button (PlumaMessageArea *message_area,
gint response_id)
{
GList *children, *tmp_list;
GtkWidget *child = NULL;
children = gtk_container_get_children (
GTK_CONTAINER (message_area->priv->action_area));
for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
{
ResponseData *rd = get_response_data (tmp_list->data, FALSE);
if (rd && rd->response_id == response_id)
{
child = tmp_list->data;
break;
}
}
g_list_free (children);
return child;
}
static void
pluma_message_area_close (PlumaMessageArea *message_area)
{
if (!find_button (message_area, GTK_RESPONSE_CANCEL))
return;
/* emit response signal */
pluma_message_area_response (PLUMA_MESSAGE_AREA (message_area),
GTK_RESPONSE_CANCEL);
}
static gboolean
paint_message_area (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
{
gtk_paint_flat_box (widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL,
widget,
"tooltip",
widget->allocation.x + 1,
widget->allocation.y + 1,
widget->allocation.width - 2,
widget->allocation.height - 2);
return FALSE;
}
static void
pluma_message_area_class_init (PlumaMessageAreaClass *klass)
{
GObjectClass *object_class;
GtkBindingSet *binding_set;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = pluma_message_area_finalize;
klass->close = pluma_message_area_close;
g_type_class_add_private (object_class, sizeof(PlumaMessageAreaPrivate));
signals[RESPONSE] = g_signal_new ("response",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PlumaMessageAreaClass, response),
NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1,
G_TYPE_INT);
signals[CLOSE] = g_signal_new ("close",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (PlumaMessageAreaClass, close),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "close", 0);
}
static void
style_set (GtkWidget *widget,
GtkStyle *prev_style,
PlumaMessageArea *message_area)
{
GtkWidget *window;
GtkStyle *style;
if (message_area->priv->changing_style)
return;
/* This is a hack needed to use the tooltip background color */
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_name (window, "gtk-tooltip");
gtk_widget_ensure_style (window);
style = gtk_widget_get_style (window);
message_area->priv->changing_style = TRUE;
gtk_widget_set_style (GTK_WIDGET (message_area), style);
message_area->priv->changing_style = FALSE;
gtk_widget_destroy (window);
gtk_widget_queue_draw (GTK_WIDGET (message_area));
}
static void
pluma_message_area_init (PlumaMessageArea *message_area)
{
message_area->priv = PLUMA_MESSAGE_AREA_GET_PRIVATE (message_area);
message_area->priv->main_hbox = gtk_hbox_new (FALSE, 16); /* FIXME: use style properties */
gtk_widget_show (message_area->priv->main_hbox);
gtk_container_set_border_width (GTK_CONTAINER (message_area->priv->main_hbox),
8); /* FIXME: use style properties */
message_area->priv->action_area = gtk_vbox_new (TRUE, 10); /* FIXME: use style properties */
gtk_widget_show (message_area->priv->action_area);
gtk_box_pack_end (GTK_BOX (message_area->priv->main_hbox),
message_area->priv->action_area,
FALSE,
TRUE,
0);
gtk_box_pack_start (GTK_BOX (message_area),
message_area->priv->main_hbox,
TRUE,
TRUE,
0);
gtk_widget_set_app_paintable (GTK_WIDGET (message_area), TRUE);
g_signal_connect (message_area,
"expose-event",
G_CALLBACK (paint_message_area),
NULL);
/* Note that we connect to style-set on one of the internal
* widgets, not on the message area itself, since gtk does
* not deliver any further style-set signals for a widget on
* which the style has been forced with gtk_widget_set_style() */
g_signal_connect (message_area->priv->main_hbox,
"style-set",
G_CALLBACK (style_set),
message_area);
}
static gint
get_response_for_widget (PlumaMessageArea *message_area,
GtkWidget *widget)
{
ResponseData *rd;
rd = get_response_data (widget, FALSE);
if (!rd)
return GTK_RESPONSE_NONE;
else
return rd->response_id;
}
static void
action_widget_activated (GtkWidget *widget, PlumaMessageArea *message_area)
{
gint response_id;
response_id = get_response_for_widget (message_area, widget);
pluma_message_area_response (message_area, response_id);
}
void
pluma_message_area_add_action_widget (PlumaMessageArea *message_area,
GtkWidget *child,
gint response_id)
{
ResponseData *ad;
guint signal_id;
g_return_if_fail (PLUMA_IS_MESSAGE_AREA (message_area));
g_return_if_fail (GTK_IS_WIDGET (child));
ad = get_response_data (child, TRUE);
ad->response_id = response_id;
if (GTK_IS_BUTTON (child))
signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON);
else
signal_id = GTK_WIDGET_GET_CLASS (child)->activate_signal;
if (signal_id)
{
GClosure *closure;
closure = g_cclosure_new_object (G_CALLBACK (action_widget_activated),
G_OBJECT (message_area));
g_signal_connect_closure_by_id (child,
signal_id,
0,
closure,
FALSE);
}
else
g_warning ("Only 'activatable' widgets can be packed into the action area of a PlumaMessageArea");
if (response_id != GTK_RESPONSE_HELP)
gtk_box_pack_start (GTK_BOX (message_area->priv->action_area),
child,
FALSE,
FALSE,
0);
else
gtk_box_pack_end (GTK_BOX (message_area->priv->action_area),
child,
FALSE,
FALSE,
0);
}
/**
* pluma_message_area_set_contents:
* @message_area: a #PlumaMessageArea
* @contents: widget you want to add to the contents area
*
* Adds the @contents widget to the contents area of #PlumaMessageArea.
*/
void
pluma_message_area_set_contents (PlumaMessageArea *message_area,
GtkWidget *contents)
{
g_return_if_fail (PLUMA_IS_MESSAGE_AREA (message_area));
g_return_if_fail (GTK_IS_WIDGET (contents));
message_area->priv->contents = contents;
gtk_box_pack_start (GTK_BOX (message_area->priv->main_hbox),
message_area->priv->contents,
TRUE,
TRUE,
0);
}
/**
* pluma_message_area_add_button:
* @message_area: a #PlumaMessageArea
* @button_text: text of button, or stock ID
* @response_id: response ID for the button
*
* Adds a button with the given text (or a stock button, if button_text is a stock ID)
* and sets things up so that clicking the button will emit the "response" signal
* with the given response_id. The button is appended to the end of the message area's
* action area. The button widget is returned, but usually you don't need it.
*
* Returns: the button widget that was added
*/
GtkWidget*
pluma_message_area_add_button (PlumaMessageArea *message_area,
const gchar *button_text,
gint response_id)
{
GtkWidget *button;
g_return_val_if_fail (PLUMA_IS_MESSAGE_AREA (message_area), NULL);
g_return_val_if_fail (button_text != NULL, NULL);
button = gtk_button_new_from_stock (button_text);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_show (button);
pluma_message_area_add_action_widget (message_area,
button,
response_id);
return button;
}
static void
add_buttons_valist (PlumaMessageArea *message_area,
const gchar *first_button_text,
va_list args)
{
const gchar* text;
gint response_id;
g_return_if_fail (PLUMA_IS_MESSAGE_AREA (message_area));
if (first_button_text == NULL)
return;
text = first_button_text;
response_id = va_arg (args, gint);
while (text != NULL)
{
pluma_message_area_add_button (message_area,
text,
response_id);
text = va_arg (args, gchar*);
if (text == NULL)
break;
response_id = va_arg (args, int);
}
}
/**
* pluma_message_area_add_buttons:
* @message_area: a #PlumaMessageArea
* @first_button_text: button text or stock ID
* @...: response ID for first button, then more text-response_id pairs
*
* Adds more buttons, same as calling pluma_message_area_add_button() repeatedly.
* The variable argument list should be NULL-terminated as with
* pluma_message_area_new_with_buttons(). Each button must have both text and response ID.
*/
void
pluma_message_area_add_buttons (PlumaMessageArea *message_area,
const gchar *first_button_text,
...)
{
va_list args;
va_start (args, first_button_text);
add_buttons_valist (message_area,
first_button_text,
args);
va_end (args);
}
/**
* pluma_message_area_new:
*
* Creates a new #PlumaMessageArea object.
*
* Returns: a new #PlumaMessageArea object
*/
GtkWidget *
pluma_message_area_new (void)
{
return g_object_new (PLUMA_TYPE_MESSAGE_AREA, NULL);
}
/**
* pluma_message_area_new_with_buttons:
* @first_button_text: stock ID or text to go in first button, or NULL
* @...: response ID for first button, then additional buttons, ending with NULL
*
* Creates a new #PlumaMessageArea with buttons. Button text/response ID pairs
* should be listed, with a NULL pointer ending the list. Button text can be either
* a stock ID such as GTK_STOCK_OK, or some arbitrary text. A response ID can be any
* positive number, or one of the values in the GtkResponseType enumeration. If
* the user clicks one of these dialog buttons, PlumaMessageArea will emit the "response"
* signal with the corresponding response ID.
*
* Returns: a new #PlumaMessageArea
*/
GtkWidget *
pluma_message_area_new_with_buttons (const gchar *first_button_text,
...)
{
PlumaMessageArea *message_area;
va_list args;
message_area = PLUMA_MESSAGE_AREA (pluma_message_area_new ());
va_start (args, first_button_text);
add_buttons_valist (message_area,
first_button_text,
args);
va_end (args);
return GTK_WIDGET (message_area);
}
/**
* pluma_message_area_set_response_sensitive:
* @message_area: a #PlumaMessageArea
* @response_id: a response ID
* @setting: TRUE for sensitive
*
* Calls gtk_widget_set_sensitive (widget, setting) for each widget in the dialog's
* action area with the given response_id. A convenient way to sensitize/desensitize
* dialog buttons.
*/
void
pluma_message_area_set_response_sensitive (PlumaMessageArea *message_area,
gint response_id,
gboolean setting)
{
GList *children;
GList *tmp_list;
g_return_if_fail (PLUMA_IS_MESSAGE_AREA (message_area));
children = gtk_container_get_children (GTK_CONTAINER (message_area->priv->action_area));
tmp_list = children;
while (tmp_list != NULL)
{
GtkWidget *widget = tmp_list->data;
ResponseData *rd = get_response_data (widget, FALSE);
if (rd && rd->response_id == response_id)
gtk_widget_set_sensitive (widget, setting);
tmp_list = g_list_next (tmp_list);
}
g_list_free (children);
}
/**
* pluma_message_area_set_default_response:
* @message_area: a #PlumaMessageArea
* @response_id: a response ID
*
* Sets the last widget in the message area's action area with the given response_id
* as the default widget for the dialog. Pressing "Enter" normally activates the
* default widget.
*/
void
pluma_message_area_set_default_response (PlumaMessageArea *message_area,
gint response_id)
{
GList *children;
GList *tmp_list;
g_return_if_fail (PLUMA_IS_MESSAGE_AREA (message_area));
children = gtk_container_get_children (GTK_CONTAINER (message_area->priv->action_area));
tmp_list = children;
while (tmp_list != NULL)
{
GtkWidget *widget = tmp_list->data;
ResponseData *rd = get_response_data (widget, FALSE);
if (rd && rd->response_id == response_id)
gtk_widget_grab_default (widget);
tmp_list = g_list_next (tmp_list);
}
g_list_free (children);
}
/**
* pluma_message_area_set_default_response:
* @message_area: a #PlumaMessageArea
* @response_id: a response ID
*
* Emits the 'response' signal with the given @response_id.
*/
void
pluma_message_area_response (PlumaMessageArea *message_area,
gint response_id)
{
g_return_if_fail (PLUMA_IS_MESSAGE_AREA (message_area));
g_signal_emit (message_area,
signals[RESPONSE],
0,
response_id);
}
/**
* pluma_message_area_add_stock_button_with_text:
* @message_area: a #PlumaMessageArea
* @text: the text to visualize in the button
* @stock_id: the stock ID of the button
* @response_id: a response ID
*
* Same as pluma_message_area_add_button() but with a specific text.
*/
GtkWidget *
pluma_message_area_add_stock_button_with_text (PlumaMessageArea *message_area,
const gchar *text,
const gchar *stock_id,
gint response_id)
{
GtkWidget *button;
g_return_val_if_fail (PLUMA_IS_MESSAGE_AREA (message_area), NULL);
g_return_val_if_fail (text != NULL, NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
button = gtk_button_new_with_mnemonic (text);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (stock_id,
GTK_ICON_SIZE_BUTTON));
gtk_widget_set_can_default (button, TRUE);
gtk_widget_show (button);
pluma_message_area_add_action_widget (message_area,
button,
response_id);
return button;
}

View File

@ -1,129 +0,0 @@
/*
* pluma-message-area.h
* This file is part of pluma
*
* Copyright (C) 2005 - Paolo Maggi
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the pluma Team, 2005. See the AUTHORS file for a
* list of people on the pluma Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __PLUMA_MESSAGE_AREA_H__
#define __PLUMA_MESSAGE_AREA_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define PLUMA_TYPE_MESSAGE_AREA (pluma_message_area_get_type())
#define PLUMA_MESSAGE_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PLUMA_TYPE_MESSAGE_AREA, PlumaMessageArea))
#define PLUMA_MESSAGE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PLUMA_TYPE_MESSAGE_AREA, PlumaMessageAreaClass))
#define PLUMA_IS_MESSAGE_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PLUMA_TYPE_MESSAGE_AREA))
#define PLUMA_IS_MESSAGE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_MESSAGE_AREA))
#define PLUMA_MESSAGE_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_MESSAGE_AREA, PlumaMessageAreaClass))
/* Private structure type */
typedef struct _PlumaMessageAreaPrivate PlumaMessageAreaPrivate;
/*
* Main object structure
*/
typedef struct _PlumaMessageArea PlumaMessageArea;
struct _PlumaMessageArea
{
GtkHBox parent;
/*< private > */
PlumaMessageAreaPrivate *priv;
};
/*
* Class definition
*/
typedef struct _PlumaMessageAreaClass PlumaMessageAreaClass;
struct _PlumaMessageAreaClass
{
GtkHBoxClass parent_class;
/* Signals */
void (* response) (PlumaMessageArea *message_area, gint response_id);
/* Keybinding signals */
void (* close) (PlumaMessageArea *message_area);
/* Padding for future expansion */
void (*_pluma_reserved1) (void);
void (*_pluma_reserved2) (void);
};
/*
* Public methods
*/
GType pluma_message_area_get_type (void) G_GNUC_CONST;
GtkWidget *pluma_message_area_new (void);
GtkWidget *pluma_message_area_new_with_buttons (const gchar *first_button_text,
...);
void pluma_message_area_set_contents (PlumaMessageArea *message_area,
GtkWidget *contents);
void pluma_message_area_add_action_widget (PlumaMessageArea *message_area,
GtkWidget *child,
gint response_id);
GtkWidget *pluma_message_area_add_button (PlumaMessageArea *message_area,
const gchar *button_text,
gint response_id);
GtkWidget *pluma_message_area_add_stock_button_with_text
(PlumaMessageArea *message_area,
const gchar *text,
const gchar *stock_id,
gint response_id);
void pluma_message_area_add_buttons (PlumaMessageArea *message_area,
const gchar *first_button_text,
...);
void pluma_message_area_set_response_sensitive
(PlumaMessageArea *message_area,
gint response_id,
gboolean setting);
void pluma_message_area_set_default_response
(PlumaMessageArea *message_area,
gint response_id);
/* Emit response signal */
void pluma_message_area_response (PlumaMessageArea *message_area,
gint response_id);
G_END_DECLS
#endif /* __PLUMA_MESSAGE_AREA_H__ */

View File

@ -49,10 +49,6 @@
#include "pluma-marshal.h" #include "pluma-marshal.h"
#include "pluma-window.h" #include "pluma-window.h"
#ifdef BUILD_SPINNER
#include "pluma-spinner.h"
#endif
#define AFTER_ALL_TABS -1 #define AFTER_ALL_TABS -1
#define NOT_IN_APP_WINDOWS -2 #define NOT_IN_APP_WINDOWS -2

View File

@ -145,11 +145,7 @@ static void
pluma_panel_focus_document (PlumaPanel *panel) pluma_panel_focus_document (PlumaPanel *panel)
{ {
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel)); GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
#if !GTK_CHECK_VERSION (2, 18, 0)
if (GTK_WIDGET_TOPLEVEL (toplevel) && PLUMA_IS_WINDOW (toplevel))
#else
if (gtk_widget_is_toplevel (toplevel) && PLUMA_IS_WINDOW (toplevel)) if (gtk_widget_is_toplevel (toplevel) && PLUMA_IS_WINDOW (toplevel))
#endif
{ {
PlumaView *view; PlumaView *view;

View File

@ -761,9 +761,7 @@ pluma_print_job_print (PlumaPrintJob *job,
gtk_print_operation_set_job_name (priv->operation, job_name); gtk_print_operation_set_job_name (priv->operation, job_name);
g_free (job_name); g_free (job_name);
#if GTK_CHECK_VERSION (2, 17, 4)
gtk_print_operation_set_embed_page_setup (priv->operation, TRUE); gtk_print_operation_set_embed_page_setup (priv->operation, TRUE);
#endif
gtk_print_operation_set_custom_tab_label (priv->operation, gtk_print_operation_set_custom_tab_label (priv->operation,
_("Text Editor")); _("Text Editor"));

View File

@ -55,26 +55,16 @@ struct _PlumaProgressMessageAreaPrivate
GtkWidget *progress; GtkWidget *progress;
}; };
#if !GTK_CHECK_VERSION (2, 17, 1)
G_DEFINE_TYPE(PlumaProgressMessageArea, pluma_progress_message_area, PLUMA_TYPE_MESSAGE_AREA)
#else
G_DEFINE_TYPE(PlumaProgressMessageArea, pluma_progress_message_area, GTK_TYPE_INFO_BAR) G_DEFINE_TYPE(PlumaProgressMessageArea, pluma_progress_message_area, GTK_TYPE_INFO_BAR)
#endif
static void static void
pluma_progress_message_area_set_has_cancel_button (PlumaProgressMessageArea *area, pluma_progress_message_area_set_has_cancel_button (PlumaProgressMessageArea *area,
gboolean has_button) gboolean has_button)
{ {
if (has_button) if (has_button)
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_add_button (PLUMA_MESSAGE_AREA (area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_add_button (GTK_INFO_BAR (area), gtk_info_bar_add_button (GTK_INFO_BAR (area),
GTK_STOCK_CANCEL, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
#endif
g_object_notify (G_OBJECT (area), "has-cancel-button"); g_object_notify (G_OBJECT (area), "has-cancel-button");
} }
@ -174,15 +164,10 @@ pluma_progress_message_area_init (PlumaProgressMessageArea *area)
gtk_box_pack_start (GTK_BOX (vbox), area->priv->progress, TRUE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), area->priv->progress, TRUE, FALSE, 0);
gtk_widget_set_size_request (area->priv->progress, -1, 15); gtk_widget_set_size_request (area->priv->progress, -1, 15);
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_contents (PLUMA_MESSAGE_AREA (area),
vbox);
#else
GtkWidget *content; GtkWidget *content;
content = gtk_info_bar_get_content_area (GTK_INFO_BAR (area)); content = gtk_info_bar_get_content_area (GTK_INFO_BAR (area));
gtk_container_add (GTK_CONTAINER (content), vbox); gtk_container_add (GTK_CONTAINER (content), vbox);
#endif
} }
GtkWidget * GtkWidget *

View File

@ -31,11 +31,7 @@
#ifndef __PLUMA_PROGRESS_MESSAGE_AREA_H__ #ifndef __PLUMA_PROGRESS_MESSAGE_AREA_H__
#define __PLUMA_PROGRESS_MESSAGE_AREA_H__ #define __PLUMA_PROGRESS_MESSAGE_AREA_H__
#if !GTK_CHECK_VERSION (2, 17, 1)
#include <pluma/pluma-message-area.h>
#else
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif
G_BEGIN_DECLS G_BEGIN_DECLS
@ -59,11 +55,7 @@ typedef struct _PlumaProgressMessageArea PlumaProgressMessageArea;
struct _PlumaProgressMessageArea struct _PlumaProgressMessageArea
{ {
#if !GTK_CHECK_VERSION (2, 17, 1)
PlumaMessageArea parent;
#else
GtkInfoBar parent; GtkInfoBar parent;
#endif
/*< private > */ /*< private > */
PlumaProgressMessageAreaPrivate *priv; PlumaProgressMessageAreaPrivate *priv;
@ -76,11 +68,7 @@ typedef struct _PlumaProgressMessageAreaClass PlumaProgressMessageAreaClass;
struct _PlumaProgressMessageAreaClass struct _PlumaProgressMessageAreaClass
{ {
#if !GTK_CHECK_VERSION (2, 17, 1)
PlumaMessageAreaClass parent_class;
#else
GtkInfoBarClass parent_class; GtkInfoBarClass parent_class;
#endif
}; };
/* /*

View File

@ -1,989 +0,0 @@
/*
* pluma-spinner.c
* This file is part of pluma
*
* Copyright (C) 2005 - Paolo Maggi
* Copyright (C) 2002-2004 Marco Pesenti Gritti
* Copyright (C) 2004 Christian Persch
* Copyright (C) 2000 - Eazel, Inc.
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* This widget was originally written by Andy Hertzfeld <andy@eazel.com> for
* Caja. It was then modified by Marco Pesenti Gritti and Christian Persch
* for Epiphany.
*
* Modified by the pluma Team, 2005. See the AUTHORS file for a
* list of people on the pluma Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "pluma-spinner.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
/* Spinner cache implementation */
#define PLUMA_TYPE_SPINNER_CACHE (pluma_spinner_cache_get_type())
#define PLUMA_SPINNER_CACHE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), PLUMA_TYPE_SPINNER_CACHE, PlumaSpinnerCache))
#define PLUMA_SPINNER_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PLUMA_TYPE_SPINNER_CACHE, PlumaSpinnerCacheClass))
#define PLUMA_IS_SPINNER_CACHE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), PLUMA_TYPE_SPINNER_CACHE))
#define PLUMA_IS_SPINNER_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PLUMA_TYPE_SPINNER_CACHE))
#define PLUMA_SPINNER_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_SPINNER_CACHE, PlumaSpinnerCacheClass))
typedef struct _PlumaSpinnerCache PlumaSpinnerCache;
typedef struct _PlumaSpinnerCacheClass PlumaSpinnerCacheClass;
typedef struct _PlumaSpinnerCachePrivate PlumaSpinnerCachePrivate;
struct _PlumaSpinnerCacheClass
{
GObjectClass parent_class;
};
struct _PlumaSpinnerCache
{
GObject parent_object;
/*< private >*/
PlumaSpinnerCachePrivate *priv;
};
#define PLUMA_SPINNER_CACHE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_SPINNER_CACHE, PlumaSpinnerCachePrivate))
struct _PlumaSpinnerCachePrivate
{
/* Hash table of GdkScreen -> PlumaSpinnerCacheData */
GHashTable *hash;
};
typedef struct
{
guint ref_count;
GtkIconSize size;
gint width;
gint height;
GdkPixbuf **animation_pixbufs;
guint n_animation_pixbufs;
} PlumaSpinnerImages;
#define LAST_ICON_SIZE GTK_ICON_SIZE_DIALOG + 1
#define SPINNER_ICON_NAME "process-working"
#define SPINNER_FALLBACK_ICON_NAME "mate-spinner"
#define PLUMA_SPINNER_IMAGES_INVALID ((PlumaSpinnerImages *) 0x1)
typedef struct
{
GdkScreen *screen;
GtkIconTheme *icon_theme;
PlumaSpinnerImages *images[LAST_ICON_SIZE];
} PlumaSpinnerCacheData;
static void pluma_spinner_cache_class_init (PlumaSpinnerCacheClass *klass);
static void pluma_spinner_cache_init (PlumaSpinnerCache *cache);
static GObjectClass *pluma_spinner_cache_parent_class;
static GType
pluma_spinner_cache_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0))
{
const GTypeInfo our_info =
{
sizeof (PlumaSpinnerCacheClass),
NULL,
NULL,
(GClassInitFunc) pluma_spinner_cache_class_init,
NULL,
NULL,
sizeof (PlumaSpinnerCache),
0,
(GInstanceInitFunc) pluma_spinner_cache_init
};
type = g_type_register_static (G_TYPE_OBJECT,
"PlumaSpinnerCache",
&our_info, 0);
}
return type;
}
static PlumaSpinnerImages *
pluma_spinner_images_ref (PlumaSpinnerImages *images)
{
g_return_val_if_fail (images != NULL, NULL);
images->ref_count++;
return images;
}
static void
pluma_spinner_images_unref (PlumaSpinnerImages *images)
{
g_return_if_fail (images != NULL);
images->ref_count--;
if (images->ref_count == 0)
{
guint i;
/* LOG ("Freeing spinner images %p for size %d", images, images->size); */
for (i = 0; i < images->n_animation_pixbufs; ++i)
{
g_object_unref (images->animation_pixbufs[i]);
}
g_free (images->animation_pixbufs);
g_free (images);
}
}
static void
pluma_spinner_cache_data_unload (PlumaSpinnerCacheData *data)
{
GtkIconSize size;
PlumaSpinnerImages *images;
g_return_if_fail (data != NULL);
/* LOG ("PlumaSpinnerDataCache unload for screen %p", data->screen); */
for (size = GTK_ICON_SIZE_INVALID; size < LAST_ICON_SIZE; ++size)
{
images = data->images[size];
data->images[size] = NULL;
if (images != NULL && images != PLUMA_SPINNER_IMAGES_INVALID)
{
pluma_spinner_images_unref (images);
}
}
}
static GdkPixbuf *
extract_frame (GdkPixbuf *grid_pixbuf,
int x,
int y,
int size)
{
GdkPixbuf *pixbuf;
if (x + size > gdk_pixbuf_get_width (grid_pixbuf) ||
y + size > gdk_pixbuf_get_height (grid_pixbuf))
{
return NULL;
}
pixbuf = gdk_pixbuf_new_subpixbuf (grid_pixbuf,
x, y,
size, size);
g_return_val_if_fail (pixbuf != NULL, NULL);
return pixbuf;
}
static GdkPixbuf *
scale_to_size (GdkPixbuf *pixbuf,
int dw,
int dh)
{
GdkPixbuf *result;
int pw, ph;
g_return_val_if_fail (pixbuf != NULL, NULL);
pw = gdk_pixbuf_get_width (pixbuf);
ph = gdk_pixbuf_get_height (pixbuf);
if (pw != dw || ph != dh)
{
result = gdk_pixbuf_scale_simple (pixbuf, dw, dh,
GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
return result;
}
return pixbuf;
}
static PlumaSpinnerImages *
pluma_spinner_images_load (GdkScreen *screen,
GtkIconTheme *icon_theme,
GtkIconSize icon_size)
{
PlumaSpinnerImages *images;
GdkPixbuf *icon_pixbuf, *pixbuf;
GtkIconInfo *icon_info = NULL;
int grid_width, grid_height, x, y, requested_size, size, isw, ish, n;
const char *icon;
GSList *list = NULL, *l;
/* LOG ("PlumaSpinnerCacheData loading for screen %p at size %d", screen, icon_size); */
/* START_PROFILER ("loading spinner animation") */
if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
icon_size, &isw, &ish))
goto loser;
requested_size = MAX (ish, isw);
/* Load the animation. The 'rest icon' is the 0th frame */
icon_info = gtk_icon_theme_lookup_icon (icon_theme,
SPINNER_ICON_NAME,
requested_size, 0);
if (icon_info == NULL)
{
g_warning ("Throbber animation not found");
/* If the icon naming spec compliant name wasn't found, try the old name */
icon_info = gtk_icon_theme_lookup_icon (icon_theme,
SPINNER_FALLBACK_ICON_NAME,
requested_size, 0);
if (icon_info == NULL)
{
g_warning ("Throbber fallback animation not found either");
goto loser;
}
}
g_assert (icon_info != NULL);
size = gtk_icon_info_get_base_size (icon_info);
icon = gtk_icon_info_get_filename (icon_info);
if (icon == NULL)
goto loser;
icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL);
gtk_icon_info_free (icon_info);
icon_info = NULL;
if (icon_pixbuf == NULL)
{
g_warning ("Could not load the spinner file");
goto loser;
}
grid_width = gdk_pixbuf_get_width (icon_pixbuf);
grid_height = gdk_pixbuf_get_height (icon_pixbuf);
n = 0;
for (y = 0; y < grid_height; y += size)
{
for (x = 0; x < grid_width ; x += size)
{
pixbuf = extract_frame (icon_pixbuf, x, y, size);
if (pixbuf)
{
list = g_slist_prepend (list, pixbuf);
++n;
}
else
{
g_warning ("Cannot extract frame (%d, %d) from the grid\n", x, y);
}
}
}
g_object_unref (icon_pixbuf);
if (list == NULL)
goto loser;
/* g_assert (n > 0); */
if (size > requested_size)
{
for (l = list; l != NULL; l = l->next)
{
l->data = scale_to_size (l->data, isw, ish);
}
}
/* Now we've successfully got all the data */
images = g_new (PlumaSpinnerImages, 1);
images->ref_count = 1;
images->size = icon_size;
images->width = images->height = requested_size;
images->n_animation_pixbufs = n;
images->animation_pixbufs = g_new (GdkPixbuf *, n);
for (l = list; l != NULL; l = l->next)
{
g_assert (l->data != NULL);
images->animation_pixbufs[--n] = l->data;
}
g_assert (n == 0);
g_slist_free (list);
/* STOP_PROFILER ("loading spinner animation") */
return images;
loser:
if (icon_info)
{
gtk_icon_info_free (icon_info);
}
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
/* STOP_PROFILER ("loading spinner animation") */
return NULL;
}
static PlumaSpinnerCacheData *
pluma_spinner_cache_data_new (GdkScreen *screen)
{
PlumaSpinnerCacheData *data;
data = g_new0 (PlumaSpinnerCacheData, 1);
data->screen = screen;
data->icon_theme = gtk_icon_theme_get_for_screen (screen);
g_signal_connect_swapped (data->icon_theme,
"changed",
G_CALLBACK (pluma_spinner_cache_data_unload),
data);
return data;
}
static void
pluma_spinner_cache_data_free (PlumaSpinnerCacheData *data)
{
g_return_if_fail (data != NULL);
g_return_if_fail (data->icon_theme != NULL);
g_signal_handlers_disconnect_by_func (data->icon_theme,
G_CALLBACK (pluma_spinner_cache_data_unload),
data);
pluma_spinner_cache_data_unload (data);
g_free (data);
}
static PlumaSpinnerImages *
pluma_spinner_cache_get_images (PlumaSpinnerCache *cache,
GdkScreen *screen,
GtkIconSize icon_size)
{
PlumaSpinnerCachePrivate *priv = cache->priv;
PlumaSpinnerCacheData *data;
PlumaSpinnerImages *images;
/* LOG ("Getting animation images for screen %p at size %d", screen, icon_size); */
g_return_val_if_fail (icon_size >= 0 && icon_size < LAST_ICON_SIZE, NULL);
/* Backward compat: "invalid" meant "native" size which doesn't exist anymore */
if (icon_size == GTK_ICON_SIZE_INVALID)
{
icon_size = GTK_ICON_SIZE_DIALOG;
}
data = g_hash_table_lookup (priv->hash, screen);
if (data == NULL)
{
data = pluma_spinner_cache_data_new (screen);
/* FIXME: think about what happens when the screen's display is closed later on */
g_hash_table_insert (priv->hash, screen, data);
}
images = data->images[icon_size];
if (images == PLUMA_SPINNER_IMAGES_INVALID)
{
/* Load failed, but don't try endlessly again! */
return NULL;
}
if (images != NULL)
{
/* Return cached data */
return pluma_spinner_images_ref (images);
}
images = pluma_spinner_images_load (screen, data->icon_theme, icon_size);
if (images == NULL)
{
/* Mark as failed-to-load */
data->images[icon_size] = PLUMA_SPINNER_IMAGES_INVALID;
return NULL;
}
data->images[icon_size] = images;
return pluma_spinner_images_ref (images);
}
static void
pluma_spinner_cache_init (PlumaSpinnerCache *cache)
{
PlumaSpinnerCachePrivate *priv;
priv = cache->priv = PLUMA_SPINNER_CACHE_GET_PRIVATE (cache);
/* LOG ("PlumaSpinnerCache initialising"); */
priv->hash = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) pluma_spinner_cache_data_free);
}
static void
pluma_spinner_cache_finalize (GObject *object)
{
PlumaSpinnerCache *cache = PLUMA_SPINNER_CACHE (object);
PlumaSpinnerCachePrivate *priv = cache->priv;
g_hash_table_destroy (priv->hash);
/* LOG ("PlumaSpinnerCache finalised"); */
G_OBJECT_CLASS (pluma_spinner_cache_parent_class)->finalize (object);
}
static void
pluma_spinner_cache_class_init (PlumaSpinnerCacheClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
pluma_spinner_cache_parent_class = g_type_class_peek_parent (klass);
object_class->finalize = pluma_spinner_cache_finalize;
g_type_class_add_private (object_class, sizeof (PlumaSpinnerCachePrivate));
}
static PlumaSpinnerCache *spinner_cache = NULL;
static PlumaSpinnerCache *
pluma_spinner_cache_ref (void)
{
if (spinner_cache == NULL)
{
PlumaSpinnerCache **cache_ptr;
spinner_cache = g_object_new (PLUMA_TYPE_SPINNER_CACHE, NULL);
cache_ptr = &spinner_cache;
g_object_add_weak_pointer (G_OBJECT (spinner_cache),
(gpointer *) cache_ptr);
return spinner_cache;
}
return g_object_ref (spinner_cache);
}
/* Spinner implementation */
#define SPINNER_TIMEOUT 125 /* ms */
#define PLUMA_SPINNER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_SPINNER, PlumaSpinnerPrivate))
struct _PlumaSpinnerPrivate
{
GtkIconTheme *icon_theme;
PlumaSpinnerCache *cache;
GtkIconSize size;
PlumaSpinnerImages *images;
guint current_image;
guint timeout;
guint timer_task;
guint spinning : 1;
guint need_load : 1;
};
static void pluma_spinner_class_init (PlumaSpinnerClass *class);
static void pluma_spinner_init (PlumaSpinner *spinner);
static GObjectClass *parent_class;
GType
pluma_spinner_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0))
{
const GTypeInfo our_info =
{
sizeof (PlumaSpinnerClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) pluma_spinner_class_init,
NULL,
NULL, /* class_data */
sizeof (PlumaSpinner),
0, /* n_preallocs */
(GInstanceInitFunc) pluma_spinner_init
};
type = g_type_register_static (GTK_TYPE_WIDGET,
"PlumaSpinner",
&our_info, 0);
}
return type;
}
static gboolean
pluma_spinner_load_images (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv = spinner->priv;
if (priv->need_load)
{
/* START_PROFILER ("pluma_spinner_load_images") */
priv->images =
pluma_spinner_cache_get_images (priv->cache,
gtk_widget_get_screen (GTK_WIDGET (spinner)),
priv->size);
/* STOP_PROFILER ("pluma_spinner_load_images") */
priv->current_image = 0; /* 'rest' icon */
priv->need_load = FALSE;
}
return priv->images != NULL;
}
static void
pluma_spinner_unload_images (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv = spinner->priv;
if (priv->images != NULL)
{
pluma_spinner_images_unref (priv->images);
priv->images = NULL;
}
priv->current_image = 0;
priv->need_load = TRUE;
}
static void
icon_theme_changed_cb (GtkIconTheme *icon_theme,
PlumaSpinner *spinner)
{
pluma_spinner_unload_images (spinner);
gtk_widget_queue_resize (GTK_WIDGET (spinner));
}
static void
pluma_spinner_init (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv;
priv = spinner->priv = PLUMA_SPINNER_GET_PRIVATE (spinner);
gtk_widget_set_has_window (GTK_WIDGET (spinner), FALSE);
priv->cache = pluma_spinner_cache_ref ();
priv->size = GTK_ICON_SIZE_DIALOG;
priv->spinning = FALSE;
priv->timeout = SPINNER_TIMEOUT;
priv->need_load = TRUE;
}
static int
pluma_spinner_expose (GtkWidget *widget,
GdkEventExpose *event)
{
PlumaSpinner *spinner = PLUMA_SPINNER (widget);
PlumaSpinnerPrivate *priv = spinner->priv;
PlumaSpinnerImages *images;
GdkPixbuf *pixbuf;
GdkGC *gc;
int x_offset, y_offset, width, height;
GdkRectangle pix_area, dest;
if (!GTK_WIDGET_DRAWABLE (spinner))
{
return FALSE;
}
if (priv->need_load &&
!pluma_spinner_load_images (spinner))
{
return FALSE;
}
images = priv->images;
if (images == NULL)
{
return FALSE;
}
/* Otherwise |images| will be NULL anyway */
g_assert (images->n_animation_pixbufs > 0);
g_assert (priv->current_image >= 0 &&
priv->current_image < images->n_animation_pixbufs);
pixbuf = images->animation_pixbufs[priv->current_image];
g_assert (pixbuf != NULL);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
/* Compute the offsets for the image centered on our allocation */
x_offset = (widget->allocation.width - width) / 2;
y_offset = (widget->allocation.height - height) / 2;
pix_area.x = x_offset + widget->allocation.x;
pix_area.y = y_offset + widget->allocation.y;
pix_area.width = width;
pix_area.height = height;
if (!gdk_rectangle_intersect (&event->area, &pix_area, &dest))
{
return FALSE;
}
gc = gdk_gc_new (widget->window);
gdk_draw_pixbuf (widget->window, gc, pixbuf,
dest.x - x_offset - widget->allocation.x,
dest.y - y_offset - widget->allocation.y,
dest.x, dest.y,
dest.width, dest.height,
GDK_RGB_DITHER_MAX, 0, 0);
g_object_unref (gc);
return FALSE;
}
static gboolean
bump_spinner_frame_cb (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv = spinner->priv;
/* This can happen when we've unloaded the images on a theme
* change, but haven't been in the queued size request yet.
* Just skip this update.
*/
if (priv->images == NULL)
return TRUE;
priv->current_image++;
if (priv->current_image >= priv->images->n_animation_pixbufs)
{
/* the 0th frame is the 'rest' icon */
priv->current_image = MIN (1, priv->images->n_animation_pixbufs);
}
gtk_widget_queue_draw (GTK_WIDGET (spinner));
/* run again */
return TRUE;
}
/**
* pluma_spinner_start:
* @spinner: a #PlumaSpinner
*
* Start the spinner animation.
**/
void
pluma_spinner_start (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv = spinner->priv;
priv->spinning = TRUE;
if (GTK_WIDGET_MAPPED (GTK_WIDGET (spinner)) &&
priv->timer_task == 0 &&
pluma_spinner_load_images (spinner))
{
/* the 0th frame is the 'rest' icon */
priv->current_image = MIN (1, priv->images->n_animation_pixbufs);
priv->timer_task = g_timeout_add_full (G_PRIORITY_LOW,
priv->timeout,
(GSourceFunc) bump_spinner_frame_cb,
spinner,
NULL);
}
}
static void
pluma_spinner_remove_update_callback (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv = spinner->priv;
if (priv->timer_task != 0)
{
g_source_remove (priv->timer_task);
priv->timer_task = 0;
}
}
/**
* pluma_spinner_stop:
* @spinner: a #PlumaSpinner
*
* Stop the spinner animation.
**/
void
pluma_spinner_stop (PlumaSpinner *spinner)
{
PlumaSpinnerPrivate *priv = spinner->priv;
priv->spinning = FALSE;
priv->current_image = 0;
if (priv->timer_task != 0)
{
pluma_spinner_remove_update_callback (spinner);
if (GTK_WIDGET_MAPPED (GTK_WIDGET (spinner)))
gtk_widget_queue_draw (GTK_WIDGET (spinner));
}
}
/*
* pluma_spinner_set_size:
* @spinner: a #PlumaSpinner
* @size: the size of type %GtkIconSize
*
* Set the size of the spinner.
**/
void
pluma_spinner_set_size (PlumaSpinner *spinner,
GtkIconSize size)
{
if (size == GTK_ICON_SIZE_INVALID)
{
size = GTK_ICON_SIZE_DIALOG;
}
if (size != spinner->priv->size)
{
pluma_spinner_unload_images (spinner);
spinner->priv->size = size;
gtk_widget_queue_resize (GTK_WIDGET (spinner));
}
}
#if 0
/*
* pluma_spinner_set_timeout:
* @spinner: a #PlumaSpinner
* @timeout: time delay between updates to the spinner.
*
* Sets the timeout delay for spinner updates.
**/
void
pluma_spinner_set_timeout (PlumaSpinner *spinner,
guint timeout)
{
PlumaSpinnerPrivate *priv = spinner->priv;
if (timeout != priv->timeout)
{
pluma_spinner_stop (spinner);
priv->timeout = timeout;
if (priv->spinning)
{
pluma_spinner_start (spinner);
}
}
}
#endif
static void
pluma_spinner_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
PlumaSpinner *spinner = PLUMA_SPINNER (widget);
PlumaSpinnerPrivate *priv = spinner->priv;
if ((priv->need_load &&
!pluma_spinner_load_images (spinner)) ||
priv->images == NULL)
{
requisition->width = requisition->height = 0;
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
priv->size,
&requisition->width,
&requisition->height);
return;
}
requisition->width = priv->images->width;
requisition->height = priv->images->height;
/* FIXME fix this hack */
/* allocate some extra margin so we don't butt up against toolbar edges */
if (priv->size != GTK_ICON_SIZE_MENU)
{
requisition->width += 2;
requisition->height += 2;
}
}
static void
pluma_spinner_map (GtkWidget *widget)
{
PlumaSpinner *spinner = PLUMA_SPINNER (widget);
PlumaSpinnerPrivate *priv = spinner->priv;
GTK_WIDGET_CLASS (parent_class)->map (widget);
if (priv->spinning)
{
pluma_spinner_start (spinner);
}
}
static void
pluma_spinner_unmap (GtkWidget *widget)
{
PlumaSpinner *spinner = PLUMA_SPINNER (widget);
pluma_spinner_remove_update_callback (spinner);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
pluma_spinner_dispose (GObject *object)
{
PlumaSpinner *spinner = PLUMA_SPINNER (object);
g_signal_handlers_disconnect_by_func
(spinner->priv->icon_theme,
G_CALLBACK (icon_theme_changed_cb), spinner);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
pluma_spinner_finalize (GObject *object)
{
PlumaSpinner *spinner = PLUMA_SPINNER (object);
pluma_spinner_remove_update_callback (spinner);
pluma_spinner_unload_images (spinner);
g_object_unref (spinner->priv->cache);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
pluma_spinner_screen_changed (GtkWidget *widget,
GdkScreen *old_screen)
{
PlumaSpinner *spinner = PLUMA_SPINNER (widget);
PlumaSpinnerPrivate *priv = spinner->priv;
GdkScreen *screen;
if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
{
GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, old_screen);
}
screen = gtk_widget_get_screen (widget);
/* FIXME: this seems to be happening when then spinner is destroyed!? */
if (old_screen == screen)
return;
/* We'll get mapped again on the new screen, but not unmapped from
* the old screen, so remove timeout here.
*/
pluma_spinner_remove_update_callback (spinner);
pluma_spinner_unload_images (spinner);
if (old_screen != NULL)
{
g_signal_handlers_disconnect_by_func
(gtk_icon_theme_get_for_screen (old_screen),
G_CALLBACK (icon_theme_changed_cb), spinner);
}
priv->icon_theme = gtk_icon_theme_get_for_screen (screen);
g_signal_connect (priv->icon_theme, "changed",
G_CALLBACK (icon_theme_changed_cb), spinner);
}
static void
pluma_spinner_class_init (PlumaSpinnerClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
parent_class = g_type_class_peek_parent (class);
object_class->dispose = pluma_spinner_dispose;
object_class->finalize = pluma_spinner_finalize;
widget_class->expose_event = pluma_spinner_expose;
widget_class->size_request = pluma_spinner_size_request;
widget_class->map = pluma_spinner_map;
widget_class->unmap = pluma_spinner_unmap;
widget_class->screen_changed = pluma_spinner_screen_changed;
g_type_class_add_private (object_class, sizeof (PlumaSpinnerPrivate));
}
/*
* pluma_spinner_new:
*
* Create a new #PlumaSpinner. The spinner is a widget
* that gives the user feedback about network status with
* an animated image.
*
* Return Value: the spinner #GtkWidget
**/
GtkWidget *
pluma_spinner_new (void)
{
return GTK_WIDGET (g_object_new (PLUMA_TYPE_SPINNER, NULL));
}

View File

@ -1,95 +0,0 @@
/*
* pluma-spinner.h
* This file is part of pluma
*
* Copyright (C) 2005 - Paolo Maggi
* Copyright (C) 2000 - Eazel, Inc.
*
* 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 St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* This widget was originally written by Andy Hertzfeld <andy@eazel.com> for
* Caja.
*
* Modified by the pluma Team, 2005. See the AUTHORS file for a
* list of people on the pluma Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __PLUMA_SPINNER_H__
#define __PLUMA_SPINNER_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define PLUMA_TYPE_SPINNER (pluma_spinner_get_type ())
#define PLUMA_SPINNER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PLUMA_TYPE_SPINNER, PlumaSpinner))
#define PLUMA_SPINNER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PLUMA_TYPE_SPINNER, PlumaSpinnerClass))
#define PLUMA_IS_SPINNER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PLUMA_TYPE_SPINNER))
#define PLUMA_IS_SPINNER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PLUMA_TYPE_SPINNER))
#define PLUMA_SPINNER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PLUMA_TYPE_SPINNER, PlumaSpinnerClass))
/* Private structure type */
typedef struct _PlumaSpinnerPrivate PlumaSpinnerPrivate;
/*
* Main object structure
*/
typedef struct _PlumaSpinner PlumaSpinner;
struct _PlumaSpinner
{
GtkWidget parent;
/*< private >*/
PlumaSpinnerPrivate *priv;
};
/*
* Class definition
*/
typedef struct _PlumaSpinnerClass PlumaSpinnerClass;
struct _PlumaSpinnerClass
{
GtkWidgetClass parent_class;
};
/*
* Public methods
*/
GType pluma_spinner_get_type (void) G_GNUC_CONST;
GtkWidget *pluma_spinner_new (void);
void pluma_spinner_start (PlumaSpinner *throbber);
void pluma_spinner_stop (PlumaSpinner *throbber);
void pluma_spinner_set_size (PlumaSpinner *spinner,
GtkIconSize size);
G_END_DECLS
#endif /* __PLUMA_SPINNER_H__ */

View File

@ -29,10 +29,6 @@
#include "pluma-tab-label.h" #include "pluma-tab-label.h"
#include "pluma-close-button.h" #include "pluma-close-button.h"
#ifdef BUILD_SPINNER
#include "pluma-spinner.h"
#endif
#define PLUMA_TAB_LABEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), PLUMA_TYPE_TAB_LABEL, PlumaTabLabelPrivate)) #define PLUMA_TAB_LABEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), PLUMA_TYPE_TAB_LABEL, PlumaTabLabelPrivate))
/* Signals */ /* Signals */
@ -169,11 +165,7 @@ sync_state (PlumaTab *tab, GParamSpec *pspec, PlumaTabLabel *tab_label)
gtk_widget_hide (tab_label->priv->icon); gtk_widget_hide (tab_label->priv->icon);
gtk_widget_show (tab_label->priv->spinner); gtk_widget_show (tab_label->priv->spinner);
#ifdef BUILD_SPINNER
pluma_spinner_start (PLUMA_SPINNER (tab_label->priv->spinner));
#else
gtk_spinner_start (GTK_SPINNER (tab_label->priv->spinner)); gtk_spinner_start (GTK_SPINNER (tab_label->priv->spinner));
#endif
} }
else else
{ {
@ -188,11 +180,7 @@ sync_state (PlumaTab *tab, GParamSpec *pspec, PlumaTabLabel *tab_label)
gtk_widget_show (tab_label->priv->icon); gtk_widget_show (tab_label->priv->icon);
gtk_widget_hide (tab_label->priv->spinner); gtk_widget_hide (tab_label->priv->spinner);
#ifdef BUILD_SPINNER
pluma_spinner_stop (PLUMA_SPINNER (tab_label->priv->spinner));
#else
gtk_spinner_stop (GTK_SPINNER (tab_label->priv->spinner)); gtk_spinner_stop (GTK_SPINNER (tab_label->priv->spinner));
#endif
} }
/* sync tip since encoding is known only after load/save end */ /* sync tip since encoding is known only after load/save end */
@ -291,12 +279,7 @@ pluma_tab_label_init (PlumaTabLabel *tab_label)
G_CALLBACK (close_button_clicked_cb), G_CALLBACK (close_button_clicked_cb),
tab_label); tab_label);
#ifdef BUILD_SPINNER
spinner = pluma_spinner_new ();
pluma_spinner_set_size (PLUMA_SPINNER (spinner), GTK_ICON_SIZE_MENU);
#else
spinner = gtk_spinner_new (); spinner = gtk_spinner_new ();
#endif
gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
tab_label->priv->spinner = spinner; tab_label->priv->spinner = spinner;

View File

@ -45,10 +45,6 @@
#include "pluma-prefs-manager-app.h" #include "pluma-prefs-manager-app.h"
#include "pluma-enum-types.h" #include "pluma-enum-types.h"
#if !GTK_CHECK_VERSION (2, 17, 1)
#include "pluma-message-area.h"
#endif
#define PLUMA_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_TAB, PlumaTabPrivate)) #define PLUMA_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_TAB, PlumaTabPrivate))
#define PLUMA_TAB_KEY "PLUMA_TAB_KEY" #define PLUMA_TAB_KEY "PLUMA_TAB_KEY"
@ -947,13 +943,8 @@ document_loaded (PlumaDocument *document,
set_message_area (tab, emsg); set_message_area (tab, emsg);
} }
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_default_response (PLUMA_MESSAGE_AREA (emsg),
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg), gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg),
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (emsg); gtk_widget_show (emsg);
@ -995,13 +986,8 @@ document_loaded (PlumaDocument *document,
G_CALLBACK (io_loading_error_message_area_response), G_CALLBACK (io_loading_error_message_area_response),
tab); tab);
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_default_response (PLUMA_MESSAGE_AREA (emsg),
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg), gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg),
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (emsg); gtk_widget_show (emsg);
} }
@ -1035,13 +1021,8 @@ document_loaded (PlumaDocument *document,
set_message_area (tab, w); set_message_area (tab, w);
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_default_response (PLUMA_MESSAGE_AREA (w),
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (w), gtk_info_bar_set_default_response (GTK_INFO_BAR (w),
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (w); gtk_widget_show (w);
@ -1352,13 +1333,8 @@ document_saved (PlumaDocument *document,
tab); tab);
} }
#if !GTK_CHECK_VERSION (2, 17, 1)
pluma_message_area_set_default_response (PLUMA_MESSAGE_AREA (emsg),
GTK_RESPONSE_CANCEL);
#else
gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg), gtk_info_bar_set_default_response (GTK_INFO_BAR (emsg),
GTK_RESPONSE_CANCEL); GTK_RESPONSE_CANCEL);
#endif
gtk_widget_show (emsg); gtk_widget_show (emsg);
} }
@ -2518,52 +2494,6 @@ show_printing_message_area (PlumaTab *tab, gboolean preview)
set_message_area (tab, area); set_message_area (tab, area);
} }
#if !GTK_CHECK_VERSION (2, 17, 4)
static void
page_setup_done_cb (GtkPageSetup *setup,
PlumaTab *tab)
{
if (setup != NULL)
{
PlumaDocument *doc;
doc = pluma_tab_get_document (tab);
/* remember it for this document */
g_object_set_data_full (G_OBJECT (doc),
PLUMA_PAGE_SETUP_KEY,
g_object_ref (setup),
(GDestroyNotify)g_object_unref);
/* make it the default */
_pluma_app_set_default_page_setup (pluma_app_get_default(),
setup);
}
}
void
_pluma_tab_page_setup (PlumaTab *tab)
{
GtkPageSetup *setup;
GtkPrintSettings *settings;
g_return_if_fail (PLUMA_IS_TAB (tab));
setup = get_page_setup (tab);
settings = get_print_settings (tab);
gtk_print_run_page_setup_dialog_async (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))),
setup,
settings,
(GtkPageSetupDoneFunc) page_setup_done_cb,
tab);
/* CHECK: should we unref setup and settings? */
}
#endif
static void static void
pluma_tab_print_or_print_preview (PlumaTab *tab, pluma_tab_print_or_print_preview (PlumaTab *tab,
GtkPrintOperationAction print_action) GtkPrintOperationAction print_action)

View File

@ -156,10 +156,6 @@ void _pluma_tab_mark_for_closing (PlumaTab *tab);
gboolean _pluma_tab_can_close (PlumaTab *tab); gboolean _pluma_tab_can_close (PlumaTab *tab);
#if !GTK_CHECK_VERSION (2, 17, 4)
void _pluma_tab_page_setup (PlumaTab *tab);
#endif
G_END_DECLS G_END_DECLS
#endif /* __PLUMA_TAB_H__ */ #endif /* __PLUMA_TAB_H__ */

View File

@ -83,10 +83,6 @@ static const GtkActionEntry pluma_menu_entries[] =
N_("Save the current file with a different name"), G_CALLBACK (_pluma_cmd_file_save_as) }, N_("Save the current file with a different name"), G_CALLBACK (_pluma_cmd_file_save_as) },
{ "FileRevert", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL, { "FileRevert", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL,
N_("Revert to a saved version of the file"), G_CALLBACK (_pluma_cmd_file_revert) }, N_("Revert to a saved version of the file"), G_CALLBACK (_pluma_cmd_file_revert) },
#if !GTK_CHECK_VERSION (2, 17, 4)
{ "FilePageSetup", GTK_STOCK_PAGE_SETUP, N_("Page Set_up..."), NULL,
N_("Set up the page settings"), G_CALLBACK (_pluma_cmd_file_page_setup) },
#endif
{ "FilePrintPreview", GTK_STOCK_PRINT_PREVIEW, N_("Print Previe_w"),"<control><shift>P", { "FilePrintPreview", GTK_STOCK_PRINT_PREVIEW, N_("Print Previe_w"),"<control><shift>P",
N_("Print preview"), G_CALLBACK (_pluma_cmd_file_print_preview) }, N_("Print preview"), G_CALLBACK (_pluma_cmd_file_print_preview) },
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P", { "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",

View File

@ -916,13 +916,6 @@ send_focus_change (GtkWidget *widget,
g_object_ref (widget); g_object_ref (widget);
#if !GTK_CHECK_VERSION (2, 21, 0)
if (in)
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
#endif
fevent->focus_change.type = GDK_FOCUS_CHANGE; fevent->focus_change.type = GDK_FOCUS_CHANGE;
#if GTK_CHECK_VERSION (3, 0, 0) #if GTK_CHECK_VERSION (3, 0, 0)
fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget)); fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget));

View File

@ -1574,30 +1574,6 @@ create_menu_bar_and_toolbar (PlumaWindow *window,
} }
g_free (ui_file); g_free (ui_file);
#if !GTK_CHECK_VERSION (2, 17, 4)
/* merge page setup menu manually since we cannot have conditional
* sections in pluma-ui.xml */
{
guint merge_id;
PlumaLockdownMask lockdown;
merge_id = gtk_ui_manager_new_merge_id (manager);
gtk_ui_manager_add_ui (manager,
merge_id,
"/MenuBar/FileMenu/FileOps_5",
"FilePageSetupMenu",
"FilePageSetup",
GTK_UI_MANAGER_MENUITEM,
FALSE);
lockdown = pluma_app_get_lockdown (pluma_app_get_default ());
action = gtk_action_group_get_action (window->priv->action_group,
"FilePageSetup");
gtk_action_set_sensitive (action,
!(lockdown & PLUMA_LOCKDOWN_PRINT_SETUP));
}
#endif
/* show tooltips in the statusbar */ /* show tooltips in the statusbar */
g_signal_connect (manager, g_signal_connect (manager,
"connect_proxy", "connect_proxy",
@ -2661,12 +2637,6 @@ _pluma_window_set_lockdown (PlumaWindow *window,
!(window->priv->state & PLUMA_WINDOW_STATE_PRINTING) && !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING) &&
!(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK)); !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
#if !GTK_CHECK_VERSION (2, 17, 4)
action = gtk_action_group_get_action (window->priv->action_group,
"FilePageSetup");
gtk_action_set_sensitive (action,
!(lockdown & PLUMA_LOCKDOWN_PRINT_SETUP));
#endif
} }
static void static void

View File

@ -909,7 +909,6 @@ parse_link (EggDesktopFile *desktop_file,
return TRUE; return TRUE;
} }
#if GTK_CHECK_VERSION (2, 12, 0)
static char * static char *
start_startup_notification (GdkDisplay *display, start_startup_notification (GdkDisplay *display,
EggDesktopFile *desktop_file, EggDesktopFile *desktop_file,
@ -1020,7 +1019,6 @@ set_startup_notification_timeout (GdkDisplay *display,
g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH,
startup_notification_timeout, sn_data); startup_notification_timeout, sn_data);
} }
#endif /* GTK 2.12 */
static GPtrArray * static GPtrArray *
array_putenv (GPtrArray *env, char *variable) array_putenv (GPtrArray *env, char *variable)
@ -1207,7 +1205,6 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
} }
g_free (command); g_free (command);
#if GTK_CHECK_VERSION (2, 12, 0)
startup_id = start_startup_notification (display, desktop_file, startup_id = start_startup_notification (display, desktop_file,
argv[0], screen_num, argv[0], screen_num,
workspace, launch_time); workspace, launch_time);
@ -1218,9 +1215,6 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
env = array_putenv (env, startup_id_env); env = array_putenv (env, startup_id_env);
g_free (startup_id_env); g_free (startup_id_env);
} }
#else
startup_id = NULL;
#endif /* GTK 2.12 */
if (env != NULL) if (env != NULL)
g_ptr_array_add (env, NULL); g_ptr_array_add (env, NULL);
@ -1238,7 +1232,6 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
if (startup_id) if (startup_id)
{ {
#if GTK_CHECK_VERSION (2, 12, 0)
if (current_success) if (current_success)
{ {
set_startup_notification_timeout (display, startup_id); set_startup_notification_timeout (display, startup_id);
@ -1249,7 +1242,6 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
g_free (startup_id); g_free (startup_id);
} }
else else
#endif /* GTK 2.12 */
g_free (startup_id); g_free (startup_id);
} }
else if (ret_startup_id) else if (ret_startup_id)