app/widgets/Makefile.am app/widgets/widgets-types.h new GtkVBox subclass
2004-08-11 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpprogressbox.[ch]: new GtkVBox subclass featuring a label and a progressbar. Implements GimpProgressIterface. * app/widgets/gimpprogressdialog.[ch]: replaced label and progress by a GimpProgressBox. Delegate most progress functionality to it. * app/widgets/gimpwidgets-utils.[ch]: factored out utility function gimp_dialog_set_sensitive(). * app/widgets/gimpfiledialog.c (gimp_file_dialog_set_sensitive): use it. * app/gui/file-open-location-dialog.c (file_open_location_response): embed the called file procedure's progress using a GimpProgressBox.
This commit is contained in:

committed by
Michael Natterer

parent
95607cce19
commit
06ea7dbd96
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
2004-08-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpprogressbox.[ch]: new GtkVBox subclass featuring
|
||||
a label and a progressbar. Implements GimpProgressIterface.
|
||||
|
||||
* app/widgets/gimpprogressdialog.[ch]: replaced label and progress
|
||||
by a GimpProgressBox. Delegate most progress functionality to it.
|
||||
|
||||
* app/widgets/gimpwidgets-utils.[ch]: factored out utility
|
||||
function gimp_dialog_set_sensitive().
|
||||
|
||||
* app/widgets/gimpfiledialog.c (gimp_file_dialog_set_sensitive):
|
||||
use it.
|
||||
|
||||
* app/gui/file-open-location-dialog.c (file_open_location_response):
|
||||
embed the called file procedure's progress using a GimpProgressBox.
|
||||
|
||||
2004-08-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpfiledialog.[ch]
|
||||
|
@ -28,19 +28,22 @@
|
||||
#include "gui-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
#include "file/file-open.h"
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#include "widgets/gimpcontainerentry.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpprogressbox.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "file-open-location-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void file_open_location_response (GtkWidget *dialog,
|
||||
static void file_open_location_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
Gimp *gimp);
|
||||
|
||||
@ -123,16 +126,27 @@ file_open_location_dialog_show (Gimp *gimp,
|
||||
}
|
||||
|
||||
static void
|
||||
file_open_location_response (GtkWidget *dialog,
|
||||
file_open_location_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
Gimp *gimp)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
GtkWidget *box;
|
||||
const gchar *text = NULL;
|
||||
|
||||
gtk_widget_set_sensitive (dialog, FALSE);
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
{
|
||||
box = g_object_get_data (G_OBJECT (dialog), "progress-box");
|
||||
|
||||
if (box && GIMP_PROGRESS_BOX (box)->active)
|
||||
gimp_progress_cancel (GIMP_PROGRESS (box));
|
||||
else
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_dialog_set_sensitive (dialog, FALSE);
|
||||
|
||||
entry = g_object_get_data (G_OBJECT (dialog), "location-entry");
|
||||
|
||||
@ -157,12 +171,17 @@ file_open_location_response (GtkWidget *dialog,
|
||||
{
|
||||
uri = file_utils_filename_to_uri (gimp->load_procs, text, NULL);
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: add progress bar to open location dialog
|
||||
#endif
|
||||
|
||||
box = gimp_progress_box_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
||||
gtk_box_pack_end (GTK_BOX (dialog->vbox), box, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box);
|
||||
|
||||
g_object_set_data (G_OBJECT (dialog), "progress-box", box);
|
||||
|
||||
image = file_open_with_proc_and_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
GIMP_PROGRESS (box),
|
||||
uri, text, NULL,
|
||||
&status, &error);
|
||||
|
||||
@ -179,9 +198,8 @@ file_open_location_response (GtkWidget *dialog,
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -28,19 +28,22 @@
|
||||
#include "gui-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
#include "file/file-open.h"
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#include "widgets/gimpcontainerentry.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpprogressbox.h"
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "file-open-location-dialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void file_open_location_response (GtkWidget *dialog,
|
||||
static void file_open_location_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
Gimp *gimp);
|
||||
|
||||
@ -123,16 +126,27 @@ file_open_location_dialog_show (Gimp *gimp,
|
||||
}
|
||||
|
||||
static void
|
||||
file_open_location_response (GtkWidget *dialog,
|
||||
file_open_location_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
Gimp *gimp)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
GtkWidget *box;
|
||||
const gchar *text = NULL;
|
||||
|
||||
gtk_widget_set_sensitive (dialog, FALSE);
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
{
|
||||
box = g_object_get_data (G_OBJECT (dialog), "progress-box");
|
||||
|
||||
if (box && GIMP_PROGRESS_BOX (box)->active)
|
||||
gimp_progress_cancel (GIMP_PROGRESS (box));
|
||||
else
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_dialog_set_sensitive (dialog, FALSE);
|
||||
|
||||
entry = g_object_get_data (G_OBJECT (dialog), "location-entry");
|
||||
|
||||
@ -157,12 +171,17 @@ file_open_location_response (GtkWidget *dialog,
|
||||
{
|
||||
uri = file_utils_filename_to_uri (gimp->load_procs, text, NULL);
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: add progress bar to open location dialog
|
||||
#endif
|
||||
|
||||
box = gimp_progress_box_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (box), 12);
|
||||
gtk_box_pack_end (GTK_BOX (dialog->vbox), box, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box);
|
||||
|
||||
g_object_set_data (G_OBJECT (dialog), "progress-box", box);
|
||||
|
||||
image = file_open_with_proc_and_display (gimp,
|
||||
gimp_get_user_context (gimp),
|
||||
NULL,
|
||||
GIMP_PROGRESS (box),
|
||||
uri, text, NULL,
|
||||
&status, &error);
|
||||
|
||||
@ -179,9 +198,8 @@ file_open_location_response (GtkWidget *dialog,
|
||||
|
||||
g_free (uri);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -206,6 +206,8 @@ libappwidgets_a_sources = \
|
||||
gimppreviewrendererlayer.h \
|
||||
gimppreviewrenderervectors.c \
|
||||
gimppreviewrenderervectors.h \
|
||||
gimpprogressbox.c \
|
||||
gimpprogressbox.h \
|
||||
gimpprogressdialog.c \
|
||||
gimpprogressdialog.h \
|
||||
gimppropwidgets.c \
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "gimppreview.h"
|
||||
#include "gimppreviewrendererimagefile.h"
|
||||
#include "gimpthumbbox.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -336,31 +337,9 @@ void
|
||||
gimp_file_dialog_set_sensitive (GimpFileDialog *dialog,
|
||||
gboolean sensitive)
|
||||
{
|
||||
GList *children;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
|
||||
|
||||
children =
|
||||
gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox));
|
||||
|
||||
for (list = children; list; list = g_list_next (list))
|
||||
{
|
||||
/* skip the last item (the action area) */
|
||||
if (! g_list_next (list))
|
||||
break;
|
||||
|
||||
gtk_widget_set_sensitive (list->data, sensitive);
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
if (sensitive)
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_CANCEL, sensitive);
|
||||
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_OK, sensitive);
|
||||
gimp_dialog_set_sensitive (GTK_DIALOG (dialog), sensitive);
|
||||
|
||||
dialog->busy = ! sensitive;
|
||||
dialog->canceled = FALSE;
|
||||
|
219
app/widgets/gimpprogressbox.c
Normal file
219
app/widgets/gimpprogressbox.c
Normal file
@ -0,0 +1,219 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpprogressbox.c
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
#include "gimpprogressbox.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_progress_box_class_init (GimpProgressBoxClass *klass);
|
||||
static void gimp_progress_box_init (GimpProgressBox *box);
|
||||
static void gimp_progress_box_progress_iface_init (GimpProgressInterface *progress_iface);
|
||||
|
||||
static GimpProgress *
|
||||
gimp_progress_box_progress_start (GimpProgress *progress,
|
||||
const gchar *message,
|
||||
gboolean cancelable);
|
||||
static void gimp_progress_box_progress_end (GimpProgress *progress);
|
||||
static void gimp_progress_box_progress_set_text (GimpProgress *progress,
|
||||
const gchar *message);
|
||||
static void gimp_progress_box_progress_set_value (GimpProgress *progress,
|
||||
gdouble percentage);
|
||||
static gdouble gimp_progress_box_progress_get_value (GimpProgress *progress);
|
||||
|
||||
|
||||
static GtkVBoxClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_progress_box_get_type (void)
|
||||
{
|
||||
static GType box_type = 0;
|
||||
|
||||
if (! box_type)
|
||||
{
|
||||
static const GTypeInfo box_info =
|
||||
{
|
||||
sizeof (GimpProgressBoxClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_progress_box_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpProgressBox),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_progress_box_init,
|
||||
};
|
||||
|
||||
static const GInterfaceInfo progress_iface_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gimp_progress_box_progress_iface_init,
|
||||
NULL, /* iface_finalize */
|
||||
NULL /* iface_data */
|
||||
};
|
||||
|
||||
box_type = g_type_register_static (GTK_TYPE_VBOX,
|
||||
"GimpProgressBox",
|
||||
&box_info, 0);
|
||||
|
||||
g_type_add_interface_static (box_type, GIMP_TYPE_PROGRESS,
|
||||
&progress_iface_info);
|
||||
}
|
||||
|
||||
return box_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_progress_box_class_init (GimpProgressBoxClass *klass)
|
||||
{
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_progress_box_init (GimpProgressBox *box)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_progress_box_progress_iface_init (GimpProgressInterface *progress_iface)
|
||||
{
|
||||
progress_iface->start = gimp_progress_box_progress_start;
|
||||
progress_iface->end = gimp_progress_box_progress_end;
|
||||
progress_iface->set_text = gimp_progress_box_progress_set_text;
|
||||
progress_iface->set_value = gimp_progress_box_progress_set_value;
|
||||
progress_iface->get_value = gimp_progress_box_progress_get_value;
|
||||
}
|
||||
|
||||
static GimpProgress *
|
||||
gimp_progress_box_progress_start (GimpProgress *progress,
|
||||
const gchar *message,
|
||||
gboolean cancelable)
|
||||
{
|
||||
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
|
||||
|
||||
if (! box->active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (box->label), message);
|
||||
gtk_progress_bar_set_fraction (bar, 0.0);
|
||||
|
||||
box->active = TRUE;
|
||||
box->cancelable = cancelable;
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_progress_box_progress_end (GimpProgress *progress)
|
||||
{
|
||||
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
|
||||
|
||||
if (box->active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (box->label), "");
|
||||
gtk_progress_bar_set_fraction (bar, 0.0);
|
||||
|
||||
box->active = FALSE;
|
||||
box->cancelable = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_progress_box_progress_set_text (GimpProgress *progress,
|
||||
const gchar *message)
|
||||
{
|
||||
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
|
||||
|
||||
if (box->active)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (box->label), message);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_progress_box_progress_set_value (GimpProgress *progress,
|
||||
gdouble percentage)
|
||||
{
|
||||
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
|
||||
|
||||
if (box->active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
|
||||
|
||||
gtk_progress_bar_set_fraction (bar, percentage);
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (box->progress))
|
||||
gdk_window_process_updates (box->progress->window, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static gdouble
|
||||
gimp_progress_box_progress_get_value (GimpProgress *progress)
|
||||
{
|
||||
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
|
||||
|
||||
if (box->active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
|
||||
|
||||
return gtk_progress_bar_get_fraction (bar);
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_progress_box_new (void)
|
||||
{
|
||||
GimpProgressBox *box;
|
||||
|
||||
box = g_object_new (GIMP_TYPE_PROGRESS_BOX,
|
||||
"spacing", 12,
|
||||
NULL);
|
||||
|
||||
box->label = gtk_label_new ("");
|
||||
gtk_misc_set_alignment (GTK_MISC (box->label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (box), box->label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box->label);
|
||||
|
||||
box->progress = gtk_progress_bar_new ();
|
||||
gtk_widget_set_size_request (box->progress, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (box), box->progress, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box->progress);
|
||||
|
||||
return GTK_WIDGET (box);
|
||||
}
|
64
app/widgets/gimpprogressbox.h
Normal file
64
app/widgets/gimpprogressbox.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpprogressbox.h
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PROGRESS_BOX_H__
|
||||
#define __GIMP_PROGRESS_BOX_H__
|
||||
|
||||
#include <gtk/gtkvbox.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GIMP_TYPE_PROGRESS_BOX (gimp_progress_box_get_type ())
|
||||
#define GIMP_PROGRESS_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROGRESS_BOX, GimpProgressBox))
|
||||
#define GIMP_PROGRESS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PROGRESS_BOX, GimpProgressBoxClass))
|
||||
#define GIMP_IS_PROGRESS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROGRESS_BOX))
|
||||
#define GIMP_IS_PROGRESS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PROGRESS_BOX))
|
||||
#define GIMP_PROGRESS_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PROGRESS_BOX, GimpProgressBoxClass))
|
||||
|
||||
|
||||
typedef struct _GimpProgressBoxClass GimpProgressBoxClass;
|
||||
|
||||
struct _GimpProgressBox
|
||||
{
|
||||
GtkVBox parent_instance;
|
||||
|
||||
gboolean active;
|
||||
gboolean cancelable;
|
||||
|
||||
GtkWidget *label;
|
||||
GtkWidget *progress;
|
||||
};
|
||||
|
||||
struct _GimpProgressBoxClass
|
||||
{
|
||||
GtkVBoxClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_progress_box_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_progress_box_new (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_PROGRESS_BOX_H__ */
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "core/gimpprogress.h"
|
||||
|
||||
#include "gimpprogressbox.h"
|
||||
#include "gimpprogressdialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
@ -107,6 +108,15 @@ gimp_progress_dialog_class_init (GimpProgressDialogClass *klass)
|
||||
static void
|
||||
gimp_progress_dialog_init (GimpProgressDialog *dialog)
|
||||
{
|
||||
dialog->box = gimp_progress_box_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog->box), 12);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
|
||||
dialog->box);
|
||||
gtk_widget_show (dialog->box);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -123,7 +133,9 @@ static void
|
||||
gimp_progress_dialog_response (GtkDialog *dialog,
|
||||
gint response_id)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_CANCEL)
|
||||
GimpProgressDialog *progress_dialog = GIMP_PROGRESS_DIALOG (dialog);
|
||||
|
||||
if (GIMP_PROGRESS_BOX (progress_dialog->box)->cancelable)
|
||||
gimp_progress_cancel (GIMP_PROGRESS (dialog));
|
||||
}
|
||||
|
||||
@ -134,19 +146,13 @@ gimp_progress_dialog_progress_start (GimpProgress *progress,
|
||||
{
|
||||
GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);
|
||||
|
||||
if (! dialog->progress_active)
|
||||
if (gimp_progress_start (GIMP_PROGRESS (dialog->box), message, cancelable))
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (dialog->progressbar);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (dialog->label), message);
|
||||
gtk_progress_bar_set_fraction (bar, 0.0);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_CANCEL, cancelable);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
|
||||
dialog->progress_active = TRUE;
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@ -158,18 +164,14 @@ gimp_progress_dialog_progress_end (GimpProgress *progress)
|
||||
{
|
||||
GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);
|
||||
|
||||
if (dialog->progress_active)
|
||||
if (GIMP_PROGRESS_BOX (dialog->box)->active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (dialog->progressbar);
|
||||
gimp_progress_end (GIMP_PROGRESS (dialog->box));
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (dialog->label), "");
|
||||
gtk_progress_bar_set_fraction (bar, 0.0);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
GTK_RESPONSE_CANCEL, FALSE);
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||
|
||||
dialog->progress_active = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,10 +181,7 @@ gimp_progress_dialog_progress_set_text (GimpProgress *progress,
|
||||
{
|
||||
GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);
|
||||
|
||||
if (dialog->progress_active)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (dialog->label), message);
|
||||
}
|
||||
gimp_progress_set_text (GIMP_PROGRESS (dialog->box), message);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -191,15 +190,7 @@ gimp_progress_dialog_progress_set_value (GimpProgress *progress,
|
||||
{
|
||||
GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);
|
||||
|
||||
if (dialog->progress_active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (dialog->progressbar);
|
||||
|
||||
gtk_progress_bar_set_fraction (bar, percentage);
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (dialog->progressbar))
|
||||
gdk_window_process_updates (dialog->progressbar->window, TRUE);
|
||||
}
|
||||
gimp_progress_set_value (GIMP_PROGRESS (dialog->box), percentage);
|
||||
}
|
||||
|
||||
static gdouble
|
||||
@ -207,45 +198,15 @@ gimp_progress_dialog_progress_get_value (GimpProgress *progress)
|
||||
{
|
||||
GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);
|
||||
|
||||
if (dialog->progress_active)
|
||||
{
|
||||
GtkProgressBar *bar = GTK_PROGRESS_BAR (dialog->progressbar);
|
||||
|
||||
return gtk_progress_bar_get_fraction (bar);
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
return gimp_progress_get_value (GIMP_PROGRESS (dialog->box));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_progress_dialog_new (void)
|
||||
{
|
||||
GimpProgressDialog *dialog;
|
||||
GtkWidget *vbox;
|
||||
|
||||
dialog = g_object_new (GIMP_TYPE_PROGRESS_DIALOG,
|
||||
return g_object_new (GIMP_TYPE_PROGRESS_DIALOG,
|
||||
"title", _("Progress"),
|
||||
"role", "progress",
|
||||
"resizable", FALSE,
|
||||
NULL);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
dialog->label = gtk_label_new ("");
|
||||
gtk_misc_set_alignment (GTK_MISC (dialog->label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), dialog->label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (dialog->label);
|
||||
|
||||
dialog->progressbar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_size_request (dialog->progressbar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), dialog->progressbar, FALSE, FALSE, 0);
|
||||
gtk_widget_show (dialog->progressbar);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
@ -41,9 +41,7 @@ struct _GimpProgressDialog
|
||||
{
|
||||
GimpDialog parent_instance;
|
||||
|
||||
gboolean progress_active;
|
||||
GtkWidget *label;
|
||||
GtkWidget *progressbar;
|
||||
GtkWidget *box;
|
||||
};
|
||||
|
||||
struct _GimpProgressDialogClass
|
||||
|
@ -864,3 +864,31 @@ gimp_window_set_hint (GtkWindow *window,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_dialog_set_sensitive (GtkDialog *dialog,
|
||||
gboolean sensitive)
|
||||
{
|
||||
GList *children;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (dialog->vbox));
|
||||
|
||||
for (list = children; list; list = g_list_next (list))
|
||||
{
|
||||
/* skip the last item (the action area) */
|
||||
if (! g_list_next (list))
|
||||
break;
|
||||
|
||||
gtk_widget_set_sensitive (list->data, sensitive);
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
if (sensitive)
|
||||
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_CANCEL, sensitive);
|
||||
|
||||
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
|
||||
}
|
||||
|
@ -72,5 +72,8 @@ void gimp_rgb_set_gdk_color (GimpRGB *rgb,
|
||||
void gimp_window_set_hint (GtkWindow *window,
|
||||
GimpWindowHint hint);
|
||||
|
||||
void gimp_dialog_set_sensitive (GtkDialog *dialog,
|
||||
gboolean sensitive);
|
||||
|
||||
|
||||
#endif /* __GIMP_WIDGETS_UTILS_H__ */
|
||||
|
@ -154,6 +154,7 @@ typedef struct _GimpFileProcView GimpFileProcView;
|
||||
typedef struct _GimpGridEditor GimpGridEditor;
|
||||
typedef struct _GimpHistogramBox GimpHistogramBox;
|
||||
typedef struct _GimpHistogramView GimpHistogramView;
|
||||
typedef struct _GimpProgressBox GimpProgressBox;
|
||||
typedef struct _GimpStrokeEditor GimpStrokeEditor;
|
||||
typedef struct _GimpTemplateEditor GimpTemplateEditor;
|
||||
typedef struct _GimpThumbBox GimpThumbBox;
|
||||
|
Reference in New Issue
Block a user