[glade3] * gladeui/glade-utils.[ch]: Some cleanup in glade-utils, removed lots of obsolete stuff.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3] * gladeui/glade-utils.[ch]: Some cleanup in glade-utils, removed lots of obsolete stuff.
- Date: Sat, 8 Jan 2011 08:21:04 +0000 (UTC)
commit b7456a23e115475bf5ef36a884d5d9c28e49e885
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat Jan 8 16:49:33 2011 +0900
* gladeui/glade-utils.[ch]: Some cleanup in glade-utils, removed lots of obsolete stuff.
ChangeLog | 2 +
gladeui/glade-design-layout.c | 32 ++++----
gladeui/glade-utils.c | 189 +----------------------------------------
gladeui/glade-utils.h | 187 ++++++++++++++++------------------------
4 files changed, 95 insertions(+), 315 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 79ce51c..0050693 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
gladeui/glade-widget-adaptor.c, gladeui/glade-editor-property.c:
Removed glade_util_class_implements_interface() in favor of g_type_is_a() (closes bug 455734).
+ * gladeui/glade-utils.[ch]: Some cleanup in glade-utils, removed lots of obsolete stuff.
+
2011-01-07 Emilio Pozuelo Monfort <pochu27 gmail com>
* configure.ac: Bump the minimum GTK+ version to 2.99.0.
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index 29eedee..8ee46ce 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -856,22 +856,22 @@ glade_design_layout_class_init (GladeDesignLayoutClass * klass)
klass->widget_event = glade_design_layout_widget_event_impl;
- /**
- * GladeDesignLayout::widget-event:
- * @glade_design_layout: the #GladeDesignLayout containing the #GladeWidget.
- * @signal_editor: the #GladeWidget which received the signal.
- * @event: the #GdkEvent
- *
- * Emitted when a widget event received.
- * Connect before the default handler to block glade logic,
- * such as selecting or resizing, by returning #GLADE_WIDGET_EVENT_STOP_EMISSION.
- * If you want to handle the event after it passed the glade logic,
- * but before it reaches the widget, you should connect after the default handler.
- *
- * Returns: #GLADE_WIDGET_EVENT_STOP_EMISSION flag to abort futher emission of the signal.
- * #GLADE_WIDGET_EVENT_RETURN_TRUE flag in the last handler
- * to stop propagating of the event to the appropriate widget.
- */
+ /**
+ * GladeDesignLayout::widget-event:
+ * @glade_design_layout: the #GladeDesignLayout containing the #GladeWidget.
+ * @signal_editor: the #GladeWidget which received the signal.
+ * @event: the #GdkEvent
+ *
+ * Emitted when a widget event received.
+ * Connect before the default handler to block glade logic,
+ * such as selecting or resizing, by returning #GLADE_WIDGET_EVENT_STOP_EMISSION.
+ * If you want to handle the event after it passed the glade logic,
+ * but before it reaches the widget, you should connect after the default handler.
+ *
+ * Returns: #GLADE_WIDGET_EVENT_STOP_EMISSION flag to abort futher emission of the signal.
+ * #GLADE_WIDGET_EVENT_RETURN_TRUE flag in the last handler
+ * to stop propagating of the event to the appropriate widget.
+ */
glade_design_layout_signals[WIDGET_EVENT] =
g_signal_new ("widget-event",
G_TYPE_FROM_CLASS (object_class),
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index afe0324..6017b0c 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -309,7 +309,7 @@ static gboolean
remove_message_timeout (FlashInfo * fi)
{
gtk_statusbar_remove (fi->statusbar, fi->context_id, fi->message_id);
- g_free (fi);
+ g_slice_free (FlashInfo, fi);
/* remove the timeout */
return FALSE;
@@ -338,7 +338,7 @@ glade_util_flash_message (GtkWidget * statusbar, guint context_id,
message = g_strdup_vprintf (format, args);
va_end (args);
- fi = g_new (FlashInfo, 1);
+ fi = g_slice_new0 (FlashInfo);
fi->statusbar = GTK_STATUSBAR (statusbar);
fi->context_id = context_id;
fi->message_id = gtk_statusbar_push (fi->statusbar, fi->context_id, message);
@@ -430,29 +430,6 @@ glade_util_compare_stock_labels (gconstpointer a, gconstpointer b)
}
/**
- * glade_util_hide_window:
- * @window: a #GtkWindow
- *
- * If you use this function to handle the delete_event of a window, when it
- * will be shown again it will appear in the position where it was before
- * beeing hidden.
- */
-void
-glade_util_hide_window (GtkWindow * window)
-{
- gint x, y;
-
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- /* remember position of window for when it is used again */
- gtk_window_get_position (window, &x, &y);
-
- gtk_widget_hide (GTK_WIDGET (window));
-
- gtk_window_move (window, x, y);
-}
-
-/**
* glade_util_file_dialog_new:
* @title: dialog title
* @project: a #GladeProject used when saving
@@ -894,26 +871,6 @@ glade_util_find_iter_by_widget (GtkTreeModel * model,
return NULL;
}
-gboolean
-glade_util_basenames_match (const gchar * path1, const gchar * path2)
-{
- gboolean match = FALSE;
- gchar *bname1;
- gchar *bname2;
-
- if (path1 && path2)
- {
- bname1 = g_path_get_basename (path1);
- bname2 = g_path_get_basename (path2);
-
- match = !strcmp (bname1, bname2);
-
- g_free (bname1);
- g_free (bname2);
- }
- return match;
-}
-
/**
* glade_util_purify_list:
* @list: A #GList
@@ -1037,148 +994,6 @@ glade_util_canonical_path (const gchar * path)
return direct_name;
}
-static gboolean
-glade_util_canonical_match (const gchar * src_path, const gchar * dest_path)
-{
- gchar *canonical_src, *canonical_dest;
- gboolean match;
- canonical_src = glade_util_canonical_path (src_path);
- canonical_dest = glade_util_canonical_path (dest_path);
-
- match = (strcmp (canonical_src, canonical_dest) == 0);
-
- g_free (canonical_src);
- g_free (canonical_dest);
-
- return match;
-}
-
-/**
- * glade_util_copy_file:
- * @src_path: the path to the source file
- * @dest_path: the path to the destination file to create or overwrite.
- *
- * Copies a file from @src to @dest, queries the user
- * if it involves overwriting the target and displays an
- * error message upon failure.
- *
- * Returns: True if the copy was successfull.
- */
-gboolean
-glade_util_copy_file (const gchar * src_path, const gchar * dest_path)
-{
- GIOChannel *src, *dest;
- GError *error = NULL;
- GIOStatus read_status, write_status = G_IO_STATUS_ERROR;
- gchar buffer[GLADE_UTIL_COPY_BUFFSIZE];
- gsize bytes_read, bytes_written, written;
- gboolean success = FALSE;
-
- /* FIXME: This may break if src_path & dest_path are actually
- * the same file, right now the canonical comparison is the
- * best check I have.
- */
- if (glade_util_canonical_match (src_path, dest_path))
- return FALSE;
-
- if (g_file_test (dest_path, G_FILE_TEST_IS_REGULAR) != FALSE)
- if (glade_util_ui_message
- (glade_app_get_window (), GLADE_UI_YES_OR_NO, NULL,
- _("%s exists.\nDo you want to replace it?"), dest_path) == FALSE)
- return FALSE;
-
-
- if ((src = g_io_channel_new_file (src_path, "r", &error)) != NULL)
- {
- g_io_channel_set_encoding (src, NULL, NULL);
-
- if ((dest = g_io_channel_new_file (dest_path, "w", &error)) != NULL)
- {
- g_io_channel_set_encoding (dest, NULL, NULL);
-
- while ((read_status = g_io_channel_read_chars
- (src, buffer, GLADE_UTIL_COPY_BUFFSIZE,
- &bytes_read, &error)) != G_IO_STATUS_ERROR)
- {
- bytes_written = 0;
- while ((write_status = g_io_channel_write_chars
- (dest, buffer + bytes_written,
- bytes_read - bytes_written,
- &written, &error)) != G_IO_STATUS_ERROR &&
- (bytes_written + written) < bytes_read)
- bytes_written += written;
-
- if (write_status == G_IO_STATUS_ERROR)
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_ERROR, NULL,
- _("Error writing to %s: %s"),
- dest_path, error->message);
- error = (g_error_free (error), NULL);
- break;
- }
-
- /* Break on EOF & ERROR but not AGAIN and not NORMAL */
- if (read_status == G_IO_STATUS_EOF)
- break;
- }
-
- if (read_status == G_IO_STATUS_ERROR)
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_ERROR, NULL,
- _("Error reading %s: %s"),
- src_path, error->message);
- error = (g_error_free (error), NULL);
- }
-
-
- /* From here on, unless we have problems shutting down, succuss ! */
- success = (read_status == G_IO_STATUS_EOF &&
- write_status == G_IO_STATUS_NORMAL);
-
- if (g_io_channel_shutdown (dest, TRUE, &error) != G_IO_STATUS_NORMAL)
- {
- glade_util_ui_message
- (glade_app_get_window (),
- GLADE_UI_ERROR, NULL,
- _("Error shutting down I/O channel %s: %s"),
- dest_path, error->message);
- error = (g_error_free (error), NULL);
- success = FALSE;
- }
- }
- else
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_ERROR, NULL,
- _("Failed to open %s for writing: %s"),
- dest_path, error->message);
- error = (g_error_free (error), NULL);
-
- }
-
-
- if (g_io_channel_shutdown (src, TRUE, &error) != G_IO_STATUS_NORMAL)
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_ERROR, NULL,
- _("Error shutting down I/O channel %s: %s"),
- src_path, error->message);
- success = FALSE;
- }
- }
- else
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_ERROR, NULL,
- _("Failed to open %s for reading: %s"),
- src_path, error->message);
- error = (g_error_free (error), NULL);
- }
- return success;
-}
-
static GModule *
try_load_library (const gchar * library_path, const gchar * library_name)
{
diff --git a/gladeui/glade-utils.h b/gladeui/glade-utils.h
index 357100a..8ac854a 100644
--- a/gladeui/glade-utils.h
+++ b/gladeui/glade-utils.h
@@ -10,162 +10,125 @@ G_BEGIN_DECLS
typedef enum _GladeUtilFileDialogType
{
- GLADE_FILE_DIALOG_ACTION_OPEN,
- GLADE_FILE_DIALOG_ACTION_SAVE
+ GLADE_FILE_DIALOG_ACTION_OPEN,
+ GLADE_FILE_DIALOG_ACTION_SAVE
} GladeUtilFileDialogType;
typedef enum
{
- GLADE_UI_INFO,
- GLADE_UI_WARN,
- GLADE_UI_ERROR,
- GLADE_UI_ARE_YOU_SURE,
- GLADE_UI_YES_OR_NO
+ GLADE_UI_INFO,
+ GLADE_UI_WARN,
+ GLADE_UI_ERROR,
+ GLADE_UI_ARE_YOU_SURE,
+ GLADE_UI_YES_OR_NO
} GladeUIMessageType;
-GType glade_util_get_type_from_name (const gchar *name, gboolean have_func);
+/* UI interaction */
+gboolean glade_util_ui_message (GtkWidget *parent,
+ GladeUIMessageType type,
+ GtkWidget *widget,
+ const gchar *format, ...);
-GParamSpec *glade_utils_get_pspec_from_funcname (const gchar *funcname);
-
-gboolean glade_util_ui_message (GtkWidget *parent,
- GladeUIMessageType type,
- GtkWidget *widget,
- const gchar *format, ...);
-
-void glade_util_flash_message (GtkWidget *statusbar,
+void glade_util_flash_message (GtkWidget *statusbar,
guint context_id,
gchar *format, ...);
-
-gboolean glade_util_check_and_warn_scrollable (GladeWidget *parent,
- GladeWidgetAdaptor *child_adaptor,
- GtkWidget *parent_widget);
-
-/* This is a GCompareFunc for comparing the labels of 2 stock items, ignoring
- any '_' characters. It isn't particularly efficient. */
-
-gint glade_util_compare_stock_labels (gconstpointer a, gconstpointer b);
-
-
-void glade_util_hide_window (GtkWindow *window);
-
-
+gboolean glade_util_url_show (const gchar *url);
GtkWidget *glade_util_file_dialog_new (const gchar *title,
GladeProject *project,
GtkWindow *parent,
GladeUtilFileDialogType action);
+/* Strings */
+gint glade_util_compare_stock_labels (gconstpointer a, gconstpointer b);
void glade_util_replace (gchar *str, gchar a, gchar b);
-
gchar *glade_util_read_prop_name (const gchar *str);
-
gchar *glade_util_duplicate_underscores (const gchar *name);
-void glade_util_add_selection (GtkWidget *widget);
-
-void glade_util_remove_selection (GtkWidget *widget);
-
-gboolean glade_util_has_selection (GtkWidget *widget);
-void glade_util_clear_selection (void);
-
-GList *glade_util_get_selection (void);
-
-void glade_util_draw_selection_nodes (GtkWidget* expose_widget, cairo_t *cr);
-
-GList *glade_util_container_get_all_children (GtkContainer *container);
-
-gint glade_util_count_placeholders (GladeWidget *parent);
-
-GtkTreeIter *glade_util_find_iter_by_widget (GtkTreeModel *model,
- GladeWidget *findme,
- gint column);
-
-gboolean glade_util_basenames_match (const gchar *path1,
- const gchar *path2);
-
-GList *glade_util_purify_list (GList *list);
-
-GList *glade_util_added_in_list (GList *old_list,
- GList *new_list);
-
-GList *glade_util_removed_from_list (GList *old_list,
- GList *new_list);
-
-gchar *glade_util_canonical_path (const gchar *path);
-
-
-gboolean glade_util_copy_file (const gchar *src_path,
- const gchar *dest_path);
+/* GModule stuff */
+GType glade_util_get_type_from_name (const gchar *name, gboolean have_func);
+GParamSpec *glade_utils_get_pspec_from_funcname (const gchar *funcname);
GModule *glade_util_load_library (const gchar *library_name);
-gboolean glade_util_file_is_writeable (const gchar *path);
+/* String/Value utilities */
+gint glade_utils_enum_value_from_string (GType enum_type, const gchar *strval);
+gchar *glade_utils_enum_string_from_value (GType enum_type, gint value);
+gint glade_utils_flags_value_from_string (GType enum_type, const gchar *strval);
+gchar *glade_utils_flags_string_from_value (GType enum_type, gint value);
+gchar *glade_utils_flags_string_from_value_displayable (GType flags_type, gint value);
+gchar *glade_utils_enum_string_from_value_displayable (GType flags_type, gint value);
+GValue *glade_utils_value_from_string (GType type,
+ const gchar *string,
+ GladeProject *project,
+ GladeWidget *widget);
+gchar *glade_utils_string_from_value (const GValue *value);
+/* Selection (TODO, Move to GladeProject) */
+void glade_util_add_selection (GtkWidget *widget);
+void glade_util_remove_selection (GtkWidget *widget);
+gboolean glade_util_has_selection (GtkWidget *widget);
+void glade_util_clear_selection (void);
+GList *glade_util_get_selection (void);
+/* Devhelp */
gboolean glade_util_have_devhelp (void);
-
GtkWidget *glade_util_get_devhelp_icon (GtkIconSize size);
-
void glade_util_search_devhelp (const gchar *book,
const gchar *page,
const gchar *search);
-GtkWidget *glade_util_get_placeholder_from_pointer (GtkContainer *container);
-
-
-gboolean glade_util_object_is_loading (GObject *object);
-
-
-gboolean glade_util_url_show (const gchar *url);
-
-
+/* Files/Filenames*/
+gchar *glade_utils_replace_home_dir_with_tilde (const gchar *path);
+gchar *glade_util_canonical_path (const gchar *path);
time_t glade_util_get_file_mtime (const gchar *filename, GError **error);
-
+gboolean glade_util_file_is_writeable (const gchar *path);
gchar *glade_util_filename_to_icon_name (const gchar *value);
-
gchar *glade_util_icon_name_to_filename (const gchar *value);
-gint glade_utils_enum_value_from_string (GType enum_type, const gchar *strval);
-gchar *glade_utils_enum_string_from_value (GType enum_type, gint value);
-gint glade_utils_flags_value_from_string (GType enum_type, const gchar *strval);
-gchar *glade_utils_flags_string_from_value (GType enum_type, gint value);
-gchar *glade_utils_flags_string_from_value_displayable (GType flags_type, gint value);
-gchar *glade_utils_enum_string_from_value_displayable (GType flags_type, gint value);
+/* Cairo utilities */
+void glade_utils_cairo_draw_line (cairo_t *cr,
+ GdkColor *color,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2);
-GValue *glade_utils_value_from_string (GType type,
- const gchar *string,
- GladeProject *project,
- GladeWidget *widget);
+void glade_utils_cairo_draw_rectangle (cairo_t *cr,
+ GdkColor *color,
+ gboolean filled,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
-gchar *glade_utils_string_from_value (const GValue *value);
+void glade_util_draw_selection_nodes (GtkWidget* expose_widget, cairo_t *cr);
-GtkListStore *glade_utils_liststore_from_enum_type (GType enum_type, gboolean include_empty);
+/* Lists */
+GList *glade_util_purify_list (GList *list);
+GList *glade_util_added_in_list (GList *old_list,
+ GList *new_list);
+GList *glade_util_removed_from_list (GList *old_list,
+ GList *new_list);
+/* Other utilities */
+GtkListStore *glade_utils_liststore_from_enum_type (GType enum_type, gboolean include_empty);
gint glade_utils_hijack_key_press (GtkWindow *win,
GdkEventKey *event,
gpointer user_data);
-
-
-void glade_utils_cairo_draw_line (cairo_t *cr,
- GdkColor *color,
- gint x1,
- gint y1,
- gint x2,
- gint y2);
-
-
-void glade_utils_cairo_draw_rectangle (cairo_t *cr,
- GdkColor *color,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height);
-
-gchar *glade_utils_replace_home_dir_with_tilde (const gchar *path);
+gboolean glade_util_check_and_warn_scrollable (GladeWidget *parent,
+ GladeWidgetAdaptor *child_adaptor,
+ GtkWidget *parent_widget);
+GList *glade_util_container_get_all_children (GtkContainer *container);
+gint glade_util_count_placeholders (GladeWidget *parent);
+GtkTreeIter *glade_util_find_iter_by_widget (GtkTreeModel *model,
+ GladeWidget *findme,
+ gint column);
+GtkWidget *glade_util_get_placeholder_from_pointer (GtkContainer *container);
+gboolean glade_util_object_is_loading (GObject *object);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]