Commit e1005445 authored by Paolo Borelli's avatar Paolo Borelli

Remove glade-project-window.h dep from

glade-utils.
parent 4a30c02b
2003-08-07 Paolo BOrelli <pborelli@katamail.com>
* src/glade-utils.[ch]: remove dependency on glade-project-window.h.
* src/glade-project-window.c: fix for the above.
* src/glade-widget.c: fix for the above.
* src/glade-command.c: fix for the above.
2003-08-06 Paolo Borelli <pborelli@katamail.com>
* src/glade-editor.c: remove dependency on glade-project-window.h.
......
......@@ -902,14 +902,15 @@ glade_command_paste (GladePlaceholder *placeholder)
GladeWidget *widget;
GladeWidget *parent;
if (placeholder == NULL) {
glade_util_ui_warn (_("Placeholder not selected!"));
gpw = glade_project_window_get ();
if (!placeholder) {
glade_util_ui_warn (gpw->window, _("Placeholder not selected!"));
return;
}
g_return_if_fail (GLADE_IS_PLACEHOLDER (placeholder));
gpw = glade_project_window_get ();
widget = gpw->clipboard->curr;
if (widget == NULL)
......@@ -923,8 +924,12 @@ glade_command_paste (GladePlaceholder *placeholder)
void
glade_command_cut (GladeWidget *widget)
{
if (widget == NULL) {
glade_util_ui_warn (_("No widget selected!"));
GladeProjectWindow *gpw;
gpw = glade_project_window_get ();
if (!widget) {
glade_util_ui_warn (gpw->window, _("No widget selected!"));
return;
}
......@@ -932,3 +937,4 @@ glade_command_cut (GladeWidget *widget)
glade_command_cut_paste_common (widget, NULL, widget->project, TRUE);
}
......@@ -2,8 +2,10 @@
#ifndef __GLADE_PLACEHOLDER_H__
#define __GLADE_PLACEHOLDER_H__
G_BEGIN_DECLS
#define GLADE_PLACEHOLDER(p) ((GladePlaceholder *) p)
GladePlaceholder * glade_placeholder_new ();
......
......@@ -107,7 +107,10 @@ gpw_on_open_filesel_ok (GtkWidget *widget, gpointer not_used)
project = glade_project_open (path);
if (!project) {
glade_util_ui_warn (_("Could not open project."));
GladeProjectWindow *gpw;
gpw = glade_project_window_get ();
glade_util_ui_warn (gpw->window, _("Could not open project."));
return;
}
......@@ -149,13 +152,17 @@ gpw_on_save_filesel_ok (GtkWidget *widget, GladeProject *project)
gpw = glade_project_window_get ();
if (!glade_project_save (project, path)) {
glade_util_ui_warn (_("Invalid file name"));
GladeProjectWindow *gpw;
gpw = glade_project_window_get ();
glade_util_ui_warn (gpw->window, _("Invalid file name"));
return;
}
gpw_refresh_project_entry (project);
gpw_refresh_title (gpw);
glade_util_flash_message (gpw->statusbar_actions_context_id,
glade_util_flash_message (gpw->statusbar,
gpw->statusbar_actions_context_id,
_("Project '%s' saved"), project->name);
}
......@@ -171,6 +178,9 @@ gpw_save_cb (void)
if (project->path != NULL) {
glade_project_save (project, project->path);
glade_util_flash_message (gpw->statusbar,
gpw->statusbar_actions_context_id,
_("Project '%s' saved"), project->name);
return;
}
......@@ -401,15 +411,24 @@ gpw_paste_cb (void)
selection = glade_project_selection_get (gpw->project);
if (selection != NULL && selection->next == NULL && GLADE_IS_PLACEHOLDER (selection->data))
glade_command_paste ((GladePlaceholder*) selection->data);
glade_command_paste (GLADE_PLACEHOLDER (selection->data));
}
static void
gpw_delete_cb (void)
{
GladeProjectWindow *gpw;
gpw = glade_project_window_get ();
if (!gpw->project) {
g_warning ("Why is delete sensitive ? it shouldn't not be because "
"we don't have a project");
return;
}
/* glade_util_delete_selection performs a glade_command_delete
* on each of the selected widgets */
glade_util_delete_selection ();
glade_util_delete_selection (gpw->project);
}
static void
......
......@@ -26,7 +26,6 @@
#include <gdk/gdkkeysyms.h>
#include <gmodule.h>
#include "glade.h"
#include "glade-project-window.h"
#include "glade-project.h"
#include "glade-command.h"
#include "glade-debug.h"
......@@ -84,13 +83,11 @@ glade_util_get_type_from_name (const gchar *name)
}
void
glade_util_ui_warn (const gchar *warning)
glade_util_ui_warn (GtkWidget *parent, const gchar *warning)
{
GladeProjectWindow *gpw;
GtkWidget *dialog;
gpw = glade_project_window_get ();
dialog = gtk_message_dialog_new (GTK_WINDOW (gpw->window),
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
......@@ -120,29 +117,28 @@ remove_message_timeout (FlashInfo * fi)
/**
* glade_utils_flash_message:
* @statusbar: The statusbar
* @context_id: The message context_id
* @format: The message to flash on the statusbar
*
* Flash a temporary message on the statusbar.
**/
*/
void
glade_util_flash_message (guint context_id, gchar *format, ...)
glade_util_flash_message (GtkWidget *statusbar, guint context_id, gchar *format, ...)
{
va_list args;
GladeProjectWindow *gpw;
FlashInfo *fi;
gchar *message;
g_return_if_fail (format != NULL);
gpw = glade_project_window_get ();
g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
g_return_if_fail (format != NULL);
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
fi = g_new (FlashInfo, 1);
fi->statusbar = GTK_STATUSBAR (gpw->statusbar);
fi->statusbar = GTK_STATUSBAR (statusbar);
fi->context_id = context_id;
fi->message_id = gtk_statusbar_push (fi->statusbar, fi->context_id, message);
......@@ -397,9 +393,6 @@ glade_util_duplicate_underscores (const char *name)
return underscored_name;
}
static GtkWidget *selected = NULL;
static gint id_expose = 0;
static gboolean
glade_util_draw_nodes (GtkWidget *widget, GdkEventExpose *expose, gpointer unused)
{
......@@ -470,33 +463,31 @@ glade_util_has_nodes (GtkWidget *widget)
}
void
glade_util_delete_selection (void)
glade_util_delete_selection (GladeProject *project)
{
GladeProject *project;
GladeWidget *glade_widget;
GList *selection;
GList *free_me;
GList *list;
project = glade_project_window_get_project ();
if (!project) {
g_warning ("Why is delete sensitive ? it shouldn't not be because "
"we don't have a project");
return;
}
g_return_if_fail (GLADE_IS_PROJECT (project));
selection = glade_project_selection_get (project);
if (!selection)
return;
/* We have to be careful when deleting widgets from the selection
* because when we delete each widget, the selection pointer changes
* due to the g_list_remove performed by glade_command_delete.
* Copy the list and free it after we are done
*/
list = g_list_copy (selection);
free_me = list;
for (; list; list = list->next)
if ((glade_widget = glade_widget_get_from_gtk_widget (list->data)) != NULL)
free_me = g_list_copy (selection);
for (list = free_me; list; list = list->next) {
GladeWidget *glade_widget;
glade_widget = glade_widget_get_from_gtk_widget (list->data);
if (glade_widget)
glade_command_delete (glade_widget);
}
g_list_free (free_me);
}
......
......@@ -4,6 +4,7 @@
G_BEGIN_DECLS
/* Function is a GNU extension */
#ifndef __GNUC__
#define __FUNCTION__ ""
......@@ -19,8 +20,10 @@ typedef enum
void glade_util_widget_set_tooltip (GtkWidget *widget, const gchar *str);
GType glade_util_get_type_from_name (const gchar *name);
void glade_util_ui_warn (const gchar *warning);
void glade_util_flash_message (guint context_id, gchar *format, ...);
void glade_util_ui_warn (GtkWidget *parent, const gchar *warning);
void glade_util_flash_message (GtkWidget *statusbar,
guint context_id,
gchar *format, ...);
/* This is a GCompareFunc for comparing the labels of 2 stock items, ignoring
any '_' characters. It isn't particularly efficient. */
......@@ -35,12 +38,13 @@ GtkWidget *glade_util_file_selection_new (const gchar *title, GtkWindow *parent)
void glade_util_replace (char *str, char a, char b);
char *glade_util_duplicate_underscores (const char *name);
void glade_util_delete_selection (void);
void glade_util_delete_selection (GladeProject *project);
void glade_util_add_nodes (GtkWidget *widget);
void glade_util_remove_nodes (GtkWidget *widget);
gboolean glade_util_has_nodes (GtkWidget *widget);
G_END_DECLS
#endif /* __GLADE_UTILS_H__ */
......@@ -379,9 +379,9 @@ glade_widget_connect_mouse_signals (GladeWidget *glade_widget)
}
static gboolean
glade_widget_key_press(GtkWidget *event_widget,
GdkEventKey *event,
gpointer user_data)
glade_widget_key_press (GtkWidget *event_widget,
GdkEventKey *event,
gpointer user_data)
{
GladeWidget *glade_widget = GLADE_WIDGET (user_data);
......@@ -390,7 +390,7 @@ glade_widget_key_press(GtkWidget *event_widget,
/* We will delete all the selected items */
if (event->keyval == GDK_Delete)
glade_util_delete_selection ();
glade_util_delete_selection (glade_widget->project);
g_debug(("glade_widget_key_press\n"));
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment