summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkenums.h13
-rw-r--r--gtk/gtkmessagedialog.c80
-rw-r--r--gtk/gtkmessagedialog.h9
-rw-r--r--gtk/gtkstatusbar.c73
-rw-r--r--gtk/gtktextview.c101
-rw-r--r--gtk/gtkwindow.c27
-rw-r--r--gtk/gtkwindow.h1
7 files changed, 296 insertions, 8 deletions
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 9a9fe3601..f8c0fab04 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -193,7 +193,8 @@ typedef enum
GTK_CENTIMETERS
} GtkMetricType;
-typedef enum {
+typedef enum
+{
GTK_MOVEMENT_LOGICAL_POSITIONS, /* move by forw/back graphemes */
GTK_MOVEMENT_VISUAL_POSITIONS, /* move by left/right graphemes */
GTK_MOVEMENT_WORDS, /* move by forward/back words */
@@ -206,6 +207,16 @@ typedef enum {
GTK_MOVEMENT_HORIZONTAL_PAGES /* move horizontally by pages */
} GtkMovementStep;
+typedef enum
+{
+ GTK_SCROLL_STEPS,
+ GTK_SCROLL_PAGES,
+ GTK_SCROLL_ENDS,
+ GTK_SCROLL_HORIZONTAL_STEPS,
+ GTK_SCROLL_HORIZONTAL_PAGES,
+ GTK_SCROLL_HORIZONTAL_ENDS
+} GtkScrollStep;
+
/* Orientation for toolbars, etc. */
typedef enum
{
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index 66bf533fd..7381584c1 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -18,7 +18,7 @@
*/
/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2003. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
@@ -302,7 +302,10 @@ gtk_message_dialog_new (GtkWindow *parent,
GtkDialog *dialog;
gchar* msg = 0;
va_list args;
-
+
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
+ g_return_val_if_fail (message_format != NULL, NULL);
+
widget = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
"message_type", type,
"buttons", buttons,
@@ -344,6 +347,79 @@ gtk_message_dialog_new (GtkWindow *parent,
return widget;
}
+/**
+ * gtk_message_dialog_new_with_markup:
+ * @parent: transient parent, or %NULL for none
+ * @flags: flags
+ * @type: type of message
+ * @buttons: set of buttons to use
+ * @message_format: printf()-style format string, or %NULL
+ * @Varargs: arguments for @message_format
+ *
+ * Creates a new message dialog, which is a simple dialog with an icon
+ * indicating the dialog type (error, warning, etc.) and some text which
+ * is marked up with the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
+ * When the user clicks a button a "response" signal is emitted with
+ * response IDs from #GtkResponseType. See #GtkDialog for more details.
+ *
+ * Please note that if you have strings in the printf() arguments
+ * passed to this function, you might need to protect against
+ * them being interpreted as markup. You can do this using
+ * g_markup_escape_text() as in the following example:
+ * <informalexample><programlisting>
+ * const gchar *error_text =
+ * "&lt;span weight=\"bold\" size=\"larger\"&gt;"
+ * "Could not open document '%s'."
+ * "&lt;/span&gt;\n\n"
+ * "You do not have appropriate permission to access this file.";
+ * gchar *tmp;
+ * GtkWidget *dialog;
+ *
+ * tmp = g_markup_escape_text (filename, -1);
+ * dialog = gtk_message_dialog_new_with_markup (main_application_window,
+ * GTK_DIALOG_DESTROY_WITH_PARENT,
+ * GTK_MESSAGE_ERROR,
+ * GTK_BUTTONS_CLOSE,
+ * error_text, tmp);
+ * g_free (tmp);
+ * </programlisting></informalexample>
+ *
+ * Return value: a new #GtkMessageDialog
+ *
+ * Since: 2.4
+ **/
+GtkWidget*
+gtk_message_dialog_new_with_markup (GtkWindow *parent,
+ GtkDialogFlags flags,
+ GtkMessageType type,
+ GtkButtonsType buttons,
+ const gchar *message_format,
+ ...)
+{
+ GtkWidget *widget;
+ gchar* msg = 0;
+ va_list args;
+
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
+ g_return_val_if_fail (message_format != NULL, NULL);
+
+ widget = gtk_message_dialog_new (parent, flags, type, buttons, "");
+
+ if (message_format)
+ {
+ va_start (args, message_format);
+ msg = g_strdup_vprintf(message_format, args);
+ va_end (args);
+
+ gtk_label_set_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (widget)->label),
+ msg);
+
+ g_free (msg);
+ }
+
+ return widget;
+}
+
static void
gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog,
GtkButtonsType buttons)
diff --git a/gtk/gtkmessagedialog.h b/gtk/gtkmessagedialog.h
index 68c1b409f..d35014772 100644
--- a/gtk/gtkmessagedialog.h
+++ b/gtk/gtkmessagedialog.h
@@ -18,7 +18,7 @@
*/
/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2003. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
@@ -91,6 +91,13 @@ GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
GtkButtonsType buttons,
const gchar *message_format,
...) G_GNUC_PRINTF (5, 6);
+
+GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent,
+ GtkDialogFlags flags,
+ GtkMessageType type,
+ GtkButtonsType buttons,
+ const gchar *message_format,
+ ...) G_GNUC_PRINTF (5, 6);
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index 2ed850cbe..ba89ef3dd 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -48,6 +48,12 @@ enum
SIGNAL_LAST
};
+enum
+{
+ PROP_ZERO,
+ PROP_HAS_RESIZE_GRIP
+};
+
static void gtk_statusbar_class_init (GtkStatusbarClass *class);
static void gtk_statusbar_init (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy (GtkObject *object);
@@ -70,6 +76,14 @@ static void gtk_statusbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_statusbar_create_window (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar);
+static void gtk_statusbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gtk_statusbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
static GtkContainerClass *parent_class;
static guint statusbar_signals[SIGNAL_LAST] = { 0 };
@@ -104,16 +118,21 @@ gtk_statusbar_get_type (void)
static void
gtk_statusbar_class_init (GtkStatusbarClass *class)
{
+ GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
+ gobject_class = (GObjectClass *) class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
container_class = (GtkContainerClass *) class;
parent_class = g_type_class_peek_parent (class);
+ gobject_class->set_property = gtk_statusbar_set_property;
+ gobject_class->get_property = gtk_statusbar_get_property;
+
object_class->destroy = gtk_statusbar_destroy;
widget_class->realize = gtk_statusbar_realize;
@@ -135,6 +154,20 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
class->text_pushed = gtk_statusbar_update;
class->text_popped = gtk_statusbar_update;
+ /**
+ * GtkStatusbar:has-resize-grip:
+ *
+ * Whether the statusbar has a grip for resizing the toplevel window.
+ *
+ * Since: 2.4
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_HAS_RESIZE_GRIP,
+ g_param_spec_boolean ("has_resize_grip",
+ _("Has Resize Grip"),
+ _("Whether the statusbar has a grip for resizing the toplevel"),
+ TRUE,
+ G_PARAM_READWRITE));
statusbar_signals[SIGNAL_TEXT_PUSHED] =
g_signal_new ("text_pushed",
G_OBJECT_CLASS_TYPE (class),
@@ -379,6 +412,8 @@ gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,
else if (!statusbar->has_resize_grip && statusbar->grip_window != NULL)
gtk_statusbar_destroy_window (statusbar);
}
+
+ g_object_notify (G_OBJECT (statusbar), "has_resize_grip");
}
}
@@ -421,6 +456,44 @@ gtk_statusbar_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
+static void
+gtk_statusbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkStatusbar *statusbar = GTK_STATUSBAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_HAS_RESIZE_GRIP:
+ gtk_statusbar_set_has_resize_grip (statusbar, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_statusbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkStatusbar *statusbar = GTK_STATUSBAR (object);
+
+ switch (prop_id)
+ {
+ case PROP_HAS_RESIZE_GRIP:
+ g_value_set_boolean (value, statusbar->has_resize_grip);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static GdkWindowEdge
get_grip_edge (GtkStatusbar *statusbar)
{
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index ff2437a43..bcc779bf0 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -117,6 +117,7 @@ enum
PASTE_CLIPBOARD,
TOGGLE_OVERWRITE,
MOVE_FOCUS,
+ MOVE_VIEWPORT,
SELECT_ALL,
LAST_SIGNAL
};
@@ -239,6 +240,9 @@ static void gtk_text_view_move_cursor (GtkTextView *text_view,
static void gtk_text_view_page_horizontally (GtkTextView *text_view,
gint count,
gboolean extend_selection);
+static void gtk_text_view_move_viewport (GtkTextView *text_view,
+ GtkScrollStep step,
+ gint count);
static void gtk_text_view_set_anchor (GtkTextView *text_view);
static void gtk_text_view_scroll_pages (GtkTextView *text_view,
gint count,
@@ -688,6 +692,17 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
G_TYPE_INT,
G_TYPE_BOOLEAN);
+ signals[MOVE_VIEWPORT] =
+ _gtk_binding_signal_new ("move_viewport",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_CALLBACK (gtk_text_view_move_viewport),
+ NULL, NULL,
+ _gtk_marshal_VOID__ENUM_INT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_SCROLL_STEP,
+ G_TYPE_INT);
+
signals[SET_ANCHOR] =
g_signal_new ("set_anchor",
G_OBJECT_CLASS_TYPE (gobject_class),
@@ -4497,6 +4512,44 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view,
gint cursor_x_pos = 0;
+ if (!text_view->cursor_visible)
+ {
+ GtkScrollStep scroll_step;
+
+ switch (step)
+ {
+ case GTK_MOVEMENT_LOGICAL_POSITIONS:
+ case GTK_MOVEMENT_VISUAL_POSITIONS:
+ case GTK_MOVEMENT_WORDS:
+ scroll_step = GTK_SCROLL_HORIZONTAL_STEPS;
+ break;
+ case GTK_MOVEMENT_DISPLAY_LINE_ENDS:
+ scroll_step = GTK_SCROLL_HORIZONTAL_ENDS;
+ break;
+ case GTK_MOVEMENT_DISPLAY_LINES:
+ case GTK_MOVEMENT_PARAGRAPHS:
+ case GTK_MOVEMENT_PARAGRAPH_ENDS:
+ scroll_step = GTK_SCROLL_STEPS;
+ break;
+ case GTK_MOVEMENT_PAGES:
+ scroll_step = GTK_SCROLL_PAGES;
+ break;
+ case GTK_MOVEMENT_HORIZONTAL_PAGES:
+ scroll_step = GTK_SCROLL_HORIZONTAL_PAGES;
+ break;
+ case GTK_MOVEMENT_BUFFER_ENDS:
+ scroll_step = GTK_SCROLL_ENDS;
+ break;
+ default:
+ scroll_step = GTK_SCROLL_PAGES;
+ break;
+ }
+
+ gtk_text_view_move_viewport (text_view, scroll_step, count);
+
+ return;
+ }
+
gtk_text_view_reset_im_context (text_view);
if (step == GTK_MOVEMENT_PAGES)
@@ -4638,6 +4691,54 @@ gtk_text_view_page_horizontally (GtkTextView *text_view,
count, extend_selection);
}
+
+static void
+gtk_text_view_move_viewport (GtkTextView *text_view,
+ GtkScrollStep step,
+ gint count)
+{
+ GtkAdjustment *adjustment;
+ gdouble increment;
+
+ switch (step)
+ {
+ case GTK_SCROLL_STEPS:
+ case GTK_SCROLL_PAGES:
+ case GTK_SCROLL_ENDS:
+ adjustment = get_vadjustment (text_view);
+ break;
+ case GTK_SCROLL_HORIZONTAL_STEPS:
+ case GTK_SCROLL_HORIZONTAL_PAGES:
+ case GTK_SCROLL_HORIZONTAL_ENDS:
+ adjustment = get_hadjustment (text_view);
+ break;
+ default:
+ adjustment = get_vadjustment (text_view);
+ break;
+ }
+
+ switch (step)
+ {
+ case GTK_SCROLL_STEPS:
+ case GTK_SCROLL_HORIZONTAL_STEPS:
+ increment = adjustment->step_increment;
+ break;
+ case GTK_SCROLL_PAGES:
+ case GTK_SCROLL_HORIZONTAL_PAGES:
+ increment = adjustment->page_increment;
+ break;
+ case GTK_SCROLL_ENDS:
+ case GTK_SCROLL_HORIZONTAL_ENDS:
+ increment = adjustment->upper - adjustment->lower;
+ break;
+ default:
+ increment = 0.0;
+ break;
+ }
+
+ set_adjustment_clamped (adjustment, adjustment->value + count * increment);
+}
+
static void
gtk_text_view_set_anchor (GtkTextView *text_view)
{
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 37649fe6b..cad9232f4 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2784,6 +2784,25 @@ gtk_window_set_default_icon_list (GList *list)
}
/**
+ * gtk_window_set_default_icon:
+ * @pixbuf: the icon
+ *
+ * Sets an icon to be used as fallback for windows that haven't
+ * had gtk_window_set_icon() called on them from a pixbuf.
+ *
+ * Since: 2.4
+ **/
+void
+gtk_window_set_default_icon (GdkPixbuf *pixbuf)
+{
+ g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+
+ GList *list = g_list_prepend (NULL, pixbuf);
+ gtk_window_set_default_icon_list (list);
+ g_list_free (list);
+}
+
+/**
* gtk_window_set_default_icon_from_file:
* @filename: location of icon file
* @err: location to store error, or %NULL.
@@ -2804,10 +2823,7 @@ gtk_window_set_default_icon_from_file (const gchar *filename,
if (pixbuf)
{
- GList *list = g_list_prepend (NULL, pixbuf);
- gtk_window_set_default_icon_list (list);
- g_list_free (list);
-
+ gtk_window_set_default_icon (pixbuf);
g_object_unref (pixbuf);
return TRUE;
@@ -3791,7 +3807,10 @@ gtk_window_realize (GtkWidget *widget)
gdk_window_set_type_hint (widget->window, window->type_hint);
if (gtk_window_get_skip_pager_hint (window))
+ {
+ g_print ("setting skip pager when realizing\n");
gdk_window_set_skip_pager_hint (widget->window, TRUE);
+ }
if (gtk_window_get_skip_taskbar_hint (window))
gdk_window_set_skip_taskbar_hint (widget->window, TRUE);
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 60d43b3d4..1c982cb03 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -252,6 +252,7 @@ gboolean gtk_window_set_icon_from_file (GtkWindow *window,
GdkPixbuf* gtk_window_get_icon (GtkWindow *window);
void gtk_window_set_default_icon_list (GList *list);
GList* gtk_window_get_default_icon_list (void);
+void gtk_window_set_default_icon (GdkPixbuf *icon);
gboolean gtk_window_set_default_icon_from_file (const gchar *filename,
GError **err);