Added controls for applying suggested backgrounds and/or fonts from
2007-07-29 Denis Washington <denisw@svn.gnome.org> * data/appearance.glade: * appearance-themes.c: (theme_message_area_response_cb), (theme_message_area_update), (theme_selection_changed_cb), (themes_init), (themes_shutdown): * gedit-message-area.[ch]: * theme-util.h: Added controls for applying suggested backgrounds and/or fonts from metathemes. Copied over some code from gedit for the message area (GeditMessageArea). * Makefile.am: Added gedit-message-area.[ch]. svn path=/trunk/; revision=7921
This commit is contained in:
parent
23c161aa35
commit
35872177c1
8 changed files with 848 additions and 16 deletions
|
@ -1,3 +1,18 @@
|
|||
2007-07-29 Denis Washington <denisw@svn.gnome.org>
|
||||
|
||||
* data/appearance.glade:
|
||||
* appearance-themes.c: (theme_message_area_response_cb),
|
||||
(theme_message_area_update), (theme_selection_changed_cb),
|
||||
(themes_init), (themes_shutdown):
|
||||
* gedit-message-area.[ch]:
|
||||
* theme-util.h:
|
||||
Added controls for applying suggested backgrounds and/or fonts from
|
||||
metathemes. Copied over some code from gedit for the message area
|
||||
(GeditMessageArea).
|
||||
|
||||
* Makefile.am:
|
||||
Added gedit-message-area.[ch].
|
||||
|
||||
2007-07-29 Thomas Wood <thos@gnome.org>
|
||||
|
||||
* appearance-style.c: (cursor_theme_sort_func), (prepare_list),
|
||||
|
|
|
@ -18,6 +18,8 @@ gnome_appearance_properties_SOURCES = \
|
|||
appearance-style.h \
|
||||
appearance-ui.c \
|
||||
appearance-ui.h \
|
||||
gedit-message-area.c \
|
||||
gedit-message-area.h \
|
||||
gnome-wp-info.c \
|
||||
gnome-wp-info.h \
|
||||
gnome-wp-item.c \
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "theme-save.h"
|
||||
#include "theme-util.h"
|
||||
#include "gtkrc-utils.h"
|
||||
#include "gedit-message-area.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <libwindow-settings/gnome-wm-manager.h>
|
||||
|
@ -33,6 +34,12 @@
|
|||
|
||||
#define CUSTOM_THEME_NAME "__custom__"
|
||||
|
||||
enum
|
||||
{
|
||||
RESPONSE_APPLY_BG,
|
||||
RESPONSE_APPLY_FONT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TARGET_URI_LIST,
|
||||
|
@ -45,6 +52,9 @@ static const GtkTargetEntry drop_types[] =
|
|||
{"_NETSCAPE_URL", 0, TARGET_NS_URL}
|
||||
};
|
||||
|
||||
static void theme_message_area_update (gboolean show_apply_background, gboolean show_apply_font, AppearanceData *data);
|
||||
|
||||
|
||||
static void
|
||||
theme_thumbnail_done_cb (GdkPixbuf *pixbuf, gchar *theme_name, AppearanceData *data)
|
||||
{
|
||||
|
@ -314,6 +324,117 @@ theme_set_custom_from_theme (const GnomeThemeMetaInfo *info, AppearanceData *dat
|
|||
|
||||
/** GUI Callbacks **/
|
||||
|
||||
static void
|
||||
theme_message_area_response_cb (GtkWidget *w,
|
||||
gint response_id,
|
||||
AppearanceData *data)
|
||||
{
|
||||
gboolean show_apply_background = FALSE, show_apply_font = FALSE;
|
||||
GtkIconView *view = GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list"));
|
||||
const GnomeThemeMetaInfo *theme = theme_get_selected (view, data);
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
case RESPONSE_APPLY_BG:
|
||||
gconf_client_set_string (data->client, BACKGROUND_KEY,
|
||||
theme->background_image, NULL);
|
||||
|
||||
show_apply_font = (theme->application_font ||
|
||||
theme->desktop_font ||
|
||||
theme->monospace_font);
|
||||
break;
|
||||
|
||||
case RESPONSE_APPLY_FONT:
|
||||
if (theme->application_font)
|
||||
gconf_client_set_string (data->client, APPLICATION_FONT_KEY,
|
||||
theme->application_font, NULL);
|
||||
|
||||
if (theme->desktop_font)
|
||||
gconf_client_set_string (data->client, DESKTOP_FONT_KEY,
|
||||
theme->desktop_font, NULL);
|
||||
|
||||
if (theme->monospace_font)
|
||||
gconf_client_set_string (data->client, MONOSPACE_FONT_KEY,
|
||||
theme->monospace_font, NULL);
|
||||
|
||||
show_apply_background = (theme->background_image != NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
theme_message_area_update (show_apply_background, show_apply_font, data);
|
||||
}
|
||||
|
||||
static void
|
||||
theme_message_area_update (gboolean show_apply_background,
|
||||
gboolean show_apply_font,
|
||||
AppearanceData *data)
|
||||
{
|
||||
const gchar *message;
|
||||
|
||||
if (data->theme_message_area == NULL) {
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *icon;
|
||||
GtkWidget *parent;
|
||||
|
||||
if (!show_apply_background && !show_apply_font)
|
||||
return;
|
||||
|
||||
data->theme_message_area = gedit_message_area_new ();
|
||||
g_object_ref (data->theme_message_area);
|
||||
gtk_widget_set_no_show_all (data->theme_message_area, TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (data->theme_message_area), "response", (GCallback) theme_message_area_response_cb, data);
|
||||
|
||||
data->apply_background_button = gedit_message_area_add_button (
|
||||
GEDIT_MESSAGE_AREA (data->theme_message_area),
|
||||
_("Apply Background"),
|
||||
RESPONSE_APPLY_BG);
|
||||
data->apply_font_button = gedit_message_area_add_button (
|
||||
GEDIT_MESSAGE_AREA (data->theme_message_area),
|
||||
_("Apply Font"),
|
||||
RESPONSE_APPLY_FONT);
|
||||
|
||||
data->theme_message_label = gtk_label_new (NULL);
|
||||
gtk_widget_show (data->theme_message_label);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (data->theme_message_label), TRUE);
|
||||
gtk_misc_set_alignment (GTK_MISC (data->theme_message_label), 0.0, 0.5);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 9);
|
||||
gtk_widget_show (hbox);
|
||||
icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_widget_show (icon);
|
||||
gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), data->theme_message_label, TRUE, TRUE, 0);
|
||||
gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (data->theme_message_area), hbox);
|
||||
|
||||
parent = glade_xml_get_widget (data->xml, "theme_list_vbox");
|
||||
gtk_box_pack_start (GTK_BOX (parent), data->theme_message_area, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
if (show_apply_background && show_apply_font) {
|
||||
gtk_widget_show (data->theme_message_area);
|
||||
gtk_widget_show (data->apply_background_button);
|
||||
gtk_widget_show (data->apply_font_button);
|
||||
message = _("The current theme suggests a background and a font.");
|
||||
} else if (show_apply_background) {
|
||||
gtk_widget_show (data->theme_message_area);
|
||||
gtk_widget_show (data->apply_background_button);
|
||||
gtk_widget_hide (data->apply_font_button);
|
||||
message = _("The current theme suggests a background.");
|
||||
} else if (show_apply_font) {
|
||||
gtk_widget_show (data->theme_message_area);
|
||||
gtk_widget_hide (data->apply_background_button);
|
||||
gtk_widget_show (data->apply_font_button);
|
||||
message = _("The current theme suggests a font.");
|
||||
} else {
|
||||
gtk_widget_hide (data->theme_message_area);
|
||||
message = NULL;
|
||||
}
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (data->theme_message_label), message);
|
||||
}
|
||||
|
||||
static void
|
||||
theme_selection_changed_cb (GtkWidget *icon_view, AppearanceData *data)
|
||||
{
|
||||
|
@ -339,9 +460,19 @@ theme_selection_changed_cb (GtkWidget *icon_view, AppearanceData *data)
|
|||
else
|
||||
theme = gnome_theme_meta_info_find (name);
|
||||
|
||||
if (theme)
|
||||
if (theme) {
|
||||
gboolean show_apply_background = FALSE, show_apply_font = FALSE;
|
||||
gnome_meta_theme_set (theme);
|
||||
|
||||
if (theme->background_image)
|
||||
show_apply_background = TRUE;
|
||||
|
||||
if (theme->application_font || theme->desktop_font || theme->monospace_font)
|
||||
show_apply_font = TRUE;
|
||||
|
||||
theme_message_area_update (show_apply_background, show_apply_font, data);
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
g_list_foreach (selection, (GFunc) gtk_tree_path_free, NULL);
|
||||
g_list_free (selection);
|
||||
|
@ -560,6 +691,7 @@ themes_init (AppearanceData *data)
|
|||
gnome_wm_manager_init ();
|
||||
|
||||
data->theme_save_dialog = NULL;
|
||||
data->theme_message_area = NULL;
|
||||
data->theme_custom = gnome_theme_meta_info_new ();
|
||||
data->theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
|
||||
data->theme_store = theme_store =
|
||||
|
@ -661,4 +793,6 @@ themes_shutdown (AppearanceData *data)
|
|||
g_object_unref (data->theme_icon);
|
||||
if (data->theme_save_dialog)
|
||||
gtk_widget_destroy (data->theme_save_dialog);
|
||||
if (data->theme_message_area)
|
||||
gtk_widget_destroy (data->theme_message_area);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,10 @@ typedef struct {
|
|||
GnomeThemeMetaInfo *theme_custom;
|
||||
GdkPixbuf *theme_icon;
|
||||
GtkWidget *theme_save_dialog;
|
||||
GtkWidget *theme_message_area;
|
||||
GtkWidget *theme_message_label;
|
||||
GtkWidget *apply_background_button;
|
||||
GtkWidget *apply_font_button;
|
||||
|
||||
/* style */
|
||||
GdkPixbuf *gtk_theme_icon;
|
||||
|
|
|
@ -626,27 +626,34 @@
|
|||
<property name="border_width">12</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<widget class="GtkVBox" id="theme_list_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<child>
|
||||
<widget class="GtkIconView" id="theme_list">
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="selection_mode">GTK_SELECTION_BROWSE</property>
|
||||
<property name="pixbuf_column">0</property>
|
||||
<property name="markup_column">1</property>
|
||||
<property name="row_spacing">18</property>
|
||||
<property name="column_spacing">18</property>
|
||||
<property name="spacing">3</property>
|
||||
<property name="margin">18</property>
|
||||
<property name="width_request">1</property>
|
||||
<property name="item_width">150</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<child>
|
||||
<widget class="GtkIconView" id="theme_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="selection_mode">GTK_SELECTION_BROWSE</property>
|
||||
<property name="pixbuf_column">0</property>
|
||||
<property name="markup_column">1</property>
|
||||
<property name="row_spacing">18</property>
|
||||
<property name="column_spacing">18</property>
|
||||
<property name="spacing">3</property>
|
||||
<property name="margin">18</property>
|
||||
<property name="width_request">1</property>
|
||||
<property name="item_width">150</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
|
538
capplets/appearance/gedit-message-area.c
Normal file
538
capplets/appearance/gedit-message-area.c
Normal file
|
@ -0,0 +1,538 @@
|
|||
/*
|
||||
* gedit-message-area.c
|
||||
* This file is part of gedit
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the gedit Team, 2005. See the AUTHORS file for a
|
||||
* list of people on the gedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id: gedit-message-area.c 5080 2006-08-09 15:17:37Z pborelli $
|
||||
*/
|
||||
|
||||
/* 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 "gedit-message-area.h"
|
||||
|
||||
#define GEDIT_MESSAGE_AREA_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_MESSAGE_AREA, GeditMessageAreaPrivate))
|
||||
|
||||
struct _GeditMessageAreaPrivate
|
||||
{
|
||||
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(GeditMessageArea, gedit_message_area, GTK_TYPE_HBOX)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gedit_message_area_finalize (GObject *object)
|
||||
{
|
||||
/*
|
||||
GeditMessageArea *message_area = GEDIT_MESSAGE_AREA (object);
|
||||
*/
|
||||
|
||||
G_OBJECT_CLASS (gedit_message_area_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static ResponseData *
|
||||
get_response_data (GtkWidget *widget,
|
||||
gboolean create)
|
||||
{
|
||||
ResponseData *ad = g_object_get_data (G_OBJECT (widget),
|
||||
"gedit-message-area-response-data");
|
||||
|
||||
if (ad == NULL && create)
|
||||
{
|
||||
ad = g_new (ResponseData, 1);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (widget),
|
||||
"gedit-message-area-response-data",
|
||||
ad,
|
||||
g_free);
|
||||
}
|
||||
|
||||
return ad;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
find_button (GeditMessageArea *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
|
||||
gedit_message_area_close (GeditMessageArea *message_area)
|
||||
{
|
||||
if (!find_button (message_area, GTK_RESPONSE_CANCEL))
|
||||
return;
|
||||
|
||||
/* emit response signal */
|
||||
gedit_message_area_response (GEDIT_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,
|
||||
widget->allocation.y,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style)
|
||||
{
|
||||
GtkTooltips *tooltips;
|
||||
GtkStyle *style;
|
||||
|
||||
GeditMessageArea *message_area = GEDIT_MESSAGE_AREA (widget);
|
||||
|
||||
if (message_area->priv->changing_style)
|
||||
return;
|
||||
|
||||
tooltips = gtk_tooltips_new ();
|
||||
g_object_ref_sink (tooltips);
|
||||
|
||||
gtk_tooltips_force_window (tooltips);
|
||||
|
||||
if (GTK_IS_WIDGET (tooltips->tip_window)) {
|
||||
gtk_widget_ensure_style (tooltips->tip_window);
|
||||
style = gtk_widget_get_style (tooltips->tip_window);
|
||||
|
||||
message_area->priv->changing_style = TRUE;
|
||||
gtk_widget_set_style (GTK_WIDGET (widget), style);
|
||||
message_area->priv->changing_style = FALSE;
|
||||
}
|
||||
|
||||
g_object_unref (tooltips);
|
||||
}
|
||||
|
||||
static void
|
||||
gedit_message_area_class_init (GeditMessageAreaClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
object_class->finalize = gedit_message_area_finalize;
|
||||
|
||||
widget_class->style_set = style_set;
|
||||
|
||||
klass->close = gedit_message_area_close;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof(GeditMessageAreaPrivate));
|
||||
|
||||
signals[RESPONSE] = g_signal_new ("response",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GeditMessageAreaClass, 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 (GeditMessageAreaClass, 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
|
||||
gedit_message_area_init (GeditMessageArea *message_area)
|
||||
{
|
||||
message_area->priv = GEDIT_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);
|
||||
|
||||
/* CHECK: do we really need it? */
|
||||
gtk_widget_set_name (GTK_WIDGET (message_area), "gtk-tooltips");
|
||||
|
||||
g_signal_connect (message_area,
|
||||
"expose_event",
|
||||
G_CALLBACK (paint_message_area),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gint
|
||||
get_response_for_widget (GeditMessageArea *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, GeditMessageArea *message_area)
|
||||
{
|
||||
gint response_id;
|
||||
|
||||
response_id = get_response_for_widget (message_area, widget);
|
||||
|
||||
gedit_message_area_response (message_area, response_id);
|
||||
}
|
||||
|
||||
void
|
||||
gedit_message_area_add_action_widget (GeditMessageArea *message_area,
|
||||
GtkWidget *child,
|
||||
gint response_id)
|
||||
{
|
||||
ResponseData *ad;
|
||||
guint signal_id;
|
||||
|
||||
g_return_if_fail (GEDIT_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 GeditMessageArea");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
gedit_message_area_set_contents (GeditMessageArea *message_area,
|
||||
GtkWidget *contents)
|
||||
{
|
||||
g_return_if_fail (GEDIT_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);
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gedit_message_area_add_button (GeditMessageArea *message_area,
|
||||
const gchar *button_text,
|
||||
gint response_id)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
g_return_val_if_fail (GEDIT_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_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
gedit_message_area_add_action_widget (message_area,
|
||||
button,
|
||||
response_id);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
static void
|
||||
add_buttons_valist (GeditMessageArea *message_area,
|
||||
const gchar *first_button_text,
|
||||
va_list args)
|
||||
{
|
||||
const gchar* text;
|
||||
gint response_id;
|
||||
|
||||
g_return_if_fail (GEDIT_IS_MESSAGE_AREA (message_area));
|
||||
|
||||
if (first_button_text == NULL)
|
||||
return;
|
||||
|
||||
text = first_button_text;
|
||||
response_id = va_arg (args, gint);
|
||||
|
||||
while (text != NULL)
|
||||
{
|
||||
gedit_message_area_add_button (message_area,
|
||||
text,
|
||||
response_id);
|
||||
|
||||
text = va_arg (args, gchar*);
|
||||
if (text == NULL)
|
||||
break;
|
||||
|
||||
response_id = va_arg (args, int);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gedit_message_area_add_buttons (GeditMessageArea *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);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gedit_message_area_new (void)
|
||||
{
|
||||
return g_object_new (GEDIT_TYPE_MESSAGE_AREA, NULL);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gedit_message_area_new_with_buttons (const gchar *first_button_text,
|
||||
...)
|
||||
{
|
||||
GeditMessageArea *message_area;
|
||||
va_list args;
|
||||
|
||||
message_area = GEDIT_MESSAGE_AREA (gedit_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);
|
||||
}
|
||||
|
||||
void
|
||||
gedit_message_area_set_response_sensitive (GeditMessageArea *message_area,
|
||||
gint response_id,
|
||||
gboolean setting)
|
||||
{
|
||||
GList *children;
|
||||
GList *tmp_list;
|
||||
|
||||
g_return_if_fail (GEDIT_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);
|
||||
}
|
||||
|
||||
void
|
||||
gedit_message_area_set_default_response (GeditMessageArea *message_area,
|
||||
gint response_id)
|
||||
{
|
||||
GList *children;
|
||||
GList *tmp_list;
|
||||
|
||||
g_return_if_fail (GEDIT_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);
|
||||
}
|
||||
|
||||
void
|
||||
gedit_message_area_response (GeditMessageArea *message_area,
|
||||
gint response_id)
|
||||
{
|
||||
g_return_if_fail (GEDIT_IS_MESSAGE_AREA (message_area));
|
||||
|
||||
g_signal_emit (message_area,
|
||||
signals[RESPONSE],
|
||||
0,
|
||||
response_id);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gedit_message_area_add_stock_button_with_text (GeditMessageArea *message_area,
|
||||
const gchar *text,
|
||||
const gchar *stock_id,
|
||||
gint response_id)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
g_return_val_if_fail (GEDIT_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_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
gedit_message_area_add_action_widget (message_area,
|
||||
button,
|
||||
response_id);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
129
capplets/appearance/gedit-message-area.h
Normal file
129
capplets/appearance/gedit-message-area.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* gedit-message-area.h
|
||||
* This file is part of gedit
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the gedit Team, 2005. See the AUTHORS file for a
|
||||
* list of people on the gedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id: gedit-message-area.h 5666 2007-06-29 19:52:25Z sfre $
|
||||
*/
|
||||
|
||||
#ifndef __GEDIT_MESSAGE_AREA_H__
|
||||
#define __GEDIT_MESSAGE_AREA_H__
|
||||
|
||||
#include <gtk/gtkdialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define GEDIT_TYPE_MESSAGE_AREA (gedit_message_area_get_type())
|
||||
#define GEDIT_MESSAGE_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_MESSAGE_AREA, GeditMessageArea))
|
||||
#define GEDIT_MESSAGE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_MESSAGE_AREA, GeditMessageAreaClass))
|
||||
#define GEDIT_IS_MESSAGE_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GEDIT_TYPE_MESSAGE_AREA))
|
||||
#define GEDIT_IS_MESSAGE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_MESSAGE_AREA))
|
||||
#define GEDIT_MESSAGE_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_MESSAGE_AREA, GeditMessageAreaClass))
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _GeditMessageAreaPrivate GeditMessageAreaPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _GeditMessageArea GeditMessageArea;
|
||||
|
||||
struct _GeditMessageArea
|
||||
{
|
||||
GtkHBox parent;
|
||||
|
||||
/*< private > */
|
||||
GeditMessageAreaPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _GeditMessageAreaClass GeditMessageAreaClass;
|
||||
|
||||
struct _GeditMessageAreaClass
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (* response) (GeditMessageArea *message_area, gint response_id);
|
||||
|
||||
/* Keybinding signals */
|
||||
void (* close) (GeditMessageArea *message_area);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gedit_reserved1) (void);
|
||||
void (*_gedit_reserved2) (void);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType gedit_message_area_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *gedit_message_area_new (void);
|
||||
|
||||
GtkWidget *gedit_message_area_new_with_buttons (const gchar *first_button_text,
|
||||
...);
|
||||
|
||||
void gedit_message_area_set_contents (GeditMessageArea *message_area,
|
||||
GtkWidget *contents);
|
||||
|
||||
void gedit_message_area_add_action_widget (GeditMessageArea *message_area,
|
||||
GtkWidget *child,
|
||||
gint response_id);
|
||||
|
||||
GtkWidget *gedit_message_area_add_button (GeditMessageArea *message_area,
|
||||
const gchar *button_text,
|
||||
gint response_id);
|
||||
|
||||
GtkWidget *gedit_message_area_add_stock_button_with_text
|
||||
(GeditMessageArea *message_area,
|
||||
const gchar *text,
|
||||
const gchar *stock_id,
|
||||
gint response_id);
|
||||
|
||||
void gedit_message_area_add_buttons (GeditMessageArea *message_area,
|
||||
const gchar *first_button_text,
|
||||
...);
|
||||
|
||||
void gedit_message_area_set_response_sensitive
|
||||
(GeditMessageArea *message_area,
|
||||
gint response_id,
|
||||
gboolean setting);
|
||||
void gedit_message_area_set_default_response
|
||||
(GeditMessageArea *message_area,
|
||||
gint response_id);
|
||||
|
||||
/* Emit response signal */
|
||||
void gedit_message_area_response (GeditMessageArea *message_area,
|
||||
gint response_id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GEDIT_MESSAGE_AREA_H__ */
|
|
@ -27,6 +27,9 @@
|
|||
#define CURSOR_SIZE_KEY "/desktop/gnome/peripherals/mouse/cursor_size"
|
||||
#define LOCKDOWN_KEY "/desktop/gnome/lockdown/disable_theme_settings"
|
||||
#define BACKGROUND_KEY "/desktop/gnome/background/picture_filename"
|
||||
#define APPLICATION_FONT_KEY "/desktop/gnome/interface/font_name"
|
||||
#define DESKTOP_FONT_KEY "/apps/nautilus/preferences/desktop_font"
|
||||
#define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name"
|
||||
|
||||
enum {
|
||||
COL_THUMBNAIL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue