1 /* 2 * xed-utils.h 3 * This file is part of xed 4 * 5 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence 6 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 7 * Copyright (C) 2002 - 2005 Paolo Maggi 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, 22 * Boston, MA 02110-1301, USA. 23 */ 24 25 /* 26 * Modified by the xed Team, 1998-2005. See the AUTHORS file for a 27 * list of people on the xed Team. 28 * See the ChangeLog files for a list of changes. 29 * 30 * $Id$ 31 */ 32 33 #ifndef __XED_UTILS_H__ 34 #define __XED_UTILS_H__ 35 36 #include <glib.h> 37 #include <gtk/gtk.h> 38 #include <atk/atk.h> 39 #include <gtksourceview/gtksource.h> 40 41 G_BEGIN_DECLS 42 43 /* useful macro */ 44 #define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1)) 45 #define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT(i) == 2) ? TRUE : FALSE)) 46 47 #define IS_VALID_BOOLEAN(v) (((v == TRUE) || (v == FALSE)) ? TRUE : FALSE) 48 49 enum { XED_ALL_WORKSPACES = 0xffffffff }; 50 51 gchar *xed_gdk_color_to_string (GdkColor color); 52 53 gint xed_string_to_clamped_gint (const gchar *text); 54 55 gchar *xed_utils_escape_underscores (const gchar *text, 56 gssize length); 57 58 gchar *xed_utils_str_middle_truncate (const gchar *string, 59 guint truncate_length); 60 61 gchar *xed_utils_str_end_truncate (const gchar *string, 62 guint truncate_length); 63 64 gboolean g_utf8_caselessnmatch (const char *s1, 65 const char *s2, 66 gssize n1, 67 gssize n2); 68 69 void xed_utils_set_atk_name_description (GtkWidget *widget, 70 const gchar *name, 71 const gchar *description); 72 73 void xed_utils_set_atk_relation (GtkWidget *obj1, 74 GtkWidget *obj2, 75 AtkRelationType rel_type); 76 77 void xed_warning (GtkWindow *parent, 78 const gchar *format, 79 ...) G_GNUC_PRINTF(2, 3); 80 81 gchar *xed_utils_make_valid_utf8 (const char *name); 82 83 /* Note that this function replace home dir with ~ */ 84 gchar *xed_utils_uri_get_dirname (const char *uri); 85 86 gchar *xed_utils_location_get_dirname_for_display (GFile *location); 87 88 gchar *xed_utils_replace_home_dir_with_tilde (const gchar *uri); 89 90 guint xed_utils_get_current_workspace (GdkScreen *screen); 91 92 guint xed_utils_get_window_workspace (GtkWindow *gtkwindow); 93 94 void xed_utils_get_current_viewport (GdkScreen *screen, 95 gint *x, 96 gint *y); 97 98 gboolean xed_utils_is_valid_location (GFile *location); 99 100 gboolean xed_utils_get_ui_objects (const gchar *filename, 101 gchar **root_objects, 102 GtkWidget **error_widget, 103 const gchar *object_name, 104 ...) G_GNUC_NULL_TERMINATED; 105 106 gboolean xed_utils_file_has_parent (GFile *gfile); 107 108 /* Return NULL if str is not a valid URI and/or filename */ 109 gchar *xed_utils_make_canonical_uri_from_shell_arg (const gchar *str); 110 111 gchar *xed_utils_basename_for_display (GFile *location); 112 113 gboolean xed_utils_decode_uri (const gchar *uri, 114 gchar **scheme, 115 gchar **user, 116 gchar **port, 117 gchar **host, 118 gchar **path); 119 120 121 /* Turns data from a drop into a list of well formatted uris */ 122 gchar **xed_utils_drop_get_uris (GtkSelectionData *selection_data); 123 124 /* Private */ 125 GSList *_xed_utils_encoding_strv_to_list (const gchar * const *enc_str); 126 127 gchar **_xed_utils_encoding_list_to_strv (const GSList *enc_list); 128 129 G_END_DECLS 130 131 #endif /* __XED_UTILS_H__ */ 132 133 134