diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-04-11 11:00:03 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-04-11 12:14:41 -0400 |
commit | 9de34580ae525e1353ccc20c8f959219a3dc6b8c (patch) | |
tree | 735ae62a73014002c5e73a912a895ad89fb970c3 /eel | |
parent | 3032b3c30cc564fed55ed1bee2cb861bf6497666 (diff) | |
download | nautilus-9de34580ae525e1353ccc20c8f959219a3dc6b8c.tar.gz |
eel: remove unused code
All these functions are now unused and can be removed.
Diffstat (limited to 'eel')
-rw-r--r-- | eel/eel-gdk-extensions.c | 30 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.h | 1 | ||||
-rw-r--r-- | eel/eel-glib-extensions.c | 314 | ||||
-rw-r--r-- | eel/eel-glib-extensions.h | 25 | ||||
-rw-r--r-- | eel/eel-gtk-extensions.c | 26 | ||||
-rw-r--r-- | eel/eel-gtk-extensions.h | 3 | ||||
-rw-r--r-- | eel/eel-string.c | 30 | ||||
-rw-r--r-- | eel/eel-string.h | 7 |
8 files changed, 2 insertions, 434 deletions
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index 4c9c21f96..743503c39 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -73,33 +73,3 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return, return gdk_flags; } - -#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, 1)) -#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v)) - -void -eel_make_color_inactive (GdkRGBA *color) -{ - double intensity, saturation; - gdouble t; - - saturation = 0.7; - intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11; - color->red = SATURATE (color->red); - color->green = SATURATE (color->green); - color->blue = SATURATE (color->blue); - - if (intensity > 0.5) { - color->red *= 0.9; - color->green *= 0.9; - color->blue *= 0.9; - } else { - color->red *= 1.25; - color->green *= 1.25; - color->blue *= 1.25; - } - - color->red = CLAMP_COLOR (color->red); - color->green = CLAMP_COLOR (color->green); - color->blue = CLAMP_COLOR (color->blue); -} diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index a4d1424ad..dda7f5315 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -46,6 +46,5 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char int *y_return, guint *width_return, guint *height_return); -void eel_make_color_inactive (GdkRGBA *color); #endif /* EEL_GDK_EXTENSIONS_H */ diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index ed9e222f3..1274e3c38 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -46,27 +46,6 @@ #define SAFE_SHELL_CHARACTERS "-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" /** - * eel_g_date_new_tm: - * - * Get a new GDate * for the date represented by a tm struct. - * The caller is responsible for g_free-ing the result. - * @time_pieces: Pointer to a tm struct representing the date to be converted. - * - * Returns: Newly allocated date. - * - **/ -GDate * -eel_g_date_new_tm (struct tm *time_pieces) -{ - /* tm uses 0-based months; GDate uses 1-based months. - * tm_year needs 1900 added to get the full year. - */ - return g_date_new_dmy (time_pieces->tm_mday, - time_pieces->tm_mon + 1, - time_pieces->tm_year + 1900); -} - -/** * eel_strdup_strftime: * * Cover for standard date-and-time-formatting routine strftime that returns @@ -225,56 +204,6 @@ eel_strdup_strftime (const char *format, struct tm *time_pieces) } /** - * eel_g_list_exactly_one_item - * - * Like g_list_length (list) == 1, only O(1) instead of O(n). - * @list: List. - * - * Return value: TRUE if the list has exactly one item. - **/ -gboolean -eel_g_list_exactly_one_item (GList *list) -{ - return list != NULL && list->next == NULL; -} - -/** - * eel_g_list_more_than_one_item - * - * Like g_list_length (list) > 1, only O(1) instead of O(n). - * @list: List. - * - * Return value: TRUE if the list has more than one item. - **/ -gboolean -eel_g_list_more_than_one_item (GList *list) -{ - return list != NULL && list->next != NULL; -} - -/** - * eel_g_list_equal - * - * Compares two lists to see if they are equal. - * @list_a: First list. - * @list_b: Second list. - * - * Return value: TRUE if the lists are the same length with the same elements. - **/ -gboolean -eel_g_list_equal (GList *list_a, GList *list_b) -{ - GList *p, *q; - - for (p = list_a, q = list_b; p != NULL && q != NULL; p = p->next, q = q->next) { - if (p->data != q->data) { - return FALSE; - } - } - return p == NULL && q == NULL; -} - -/** * eel_g_str_list_equal * * Compares two lists of C strings to see if they are equal. @@ -315,62 +244,6 @@ eel_g_str_list_copy (GList *list) return result; } -/** - * eel_g_str_list_alphabetize - * - * Sort a list of strings using locale-sensitive rules. - * - * @list: List of strings and/or NULLs. - * - * Return value: @list, sorted. - **/ -GList * -eel_g_str_list_alphabetize (GList *list) -{ - return g_list_sort (list, (GCompareFunc) g_utf8_collate); -} - -int -eel_g_str_list_index (GList *str_list, - const char *str) -{ - int i; - GList *l; - for (i = 0, l = str_list; l != NULL; l = l->next, i++) { - if (!strcmp (str, (const char*)l->data)) { - return i; - } - } - return -1; -} - -/** - * eel_g_strv_find - * - * Get index of string in array of strings. - * - * @strv: NULL-terminated array of strings. - * @find_me: string to search for. - * - * Return value: index of array entry in @strv that - * matches @find_me, or -1 if no matching entry. - */ -int -eel_g_strv_find (char **strv, const char *find_me) -{ - int index; - - g_return_val_if_fail (find_me != NULL, -1); - - for (index = 0; strv[index] != NULL; ++index) { - if (strcmp (strv[index], find_me) == 0) { - return index; - } - } - - return -1; -} - gboolean eel_g_strv_equal (char **a, char **b) { @@ -491,20 +364,6 @@ eel_g_list_partition (GList *list, return predicate_true; } -/** - * eel_get_system_time - * - * Return value: number of microseconds since the machine was turned on - */ -gint64 -eel_get_system_time (void) -{ - struct timeval tmp; - - gettimeofday (&tmp, NULL); - return (gint64)tmp.tv_usec + (gint64)tmp.tv_sec * G_GINT64_CONSTANT (1000000); -} - typedef struct { GList *keys; GList *values; @@ -547,37 +406,6 @@ eel_g_hash_table_safe_for_each (GHashTable *hash_table, g_list_free (flattened.values); } -int -eel_round (double d) -{ - double val; - - val = floor (d + .5); - - /* The tests are needed because the result of floating-point to integral - * conversion is undefined if the floating point value is not representable - * in the new type. E.g. the magnititude is too large or a negative - * floating-point value being converted to an unsigned. - */ - g_return_val_if_fail (val <= INT_MAX, INT_MAX); - g_return_val_if_fail (val >= INT_MIN, INT_MIN); - - return val; -} - -/** - * eel_g_object_list_ref - * - * Ref all the objects in a list. - * @list: GList of objects. - **/ -GList * -eel_g_object_list_ref (GList *list) -{ - g_list_foreach (list, (GFunc) g_object_ref, NULL); - return list; -} - /** * eel_g_object_list_copy * @@ -587,129 +415,12 @@ eel_g_object_list_ref (GList *list) GList * eel_g_object_list_copy (GList *list) { - return g_list_copy (eel_g_object_list_ref (list)); -} - -/** - * eel_add_weak_pointer - * - * Nulls out a saved reference to an object when the object gets destroyed. - * - * @pointer_location: Address of the saved pointer. - **/ -void -eel_add_weak_pointer (gpointer pointer_location) -{ - gpointer *object_location; - - g_return_if_fail (pointer_location != NULL); - - object_location = (gpointer *) pointer_location; - if (*object_location == NULL) { - /* The reference is NULL, nothing to do. */ - return; - } - - g_return_if_fail (G_IS_OBJECT (*object_location)); - - g_object_add_weak_pointer (G_OBJECT (*object_location), - object_location); -} - -/** - * eel_remove_weak_pointer - * - * Removes the weak pointer that was added by eel_add_weak_pointer. - * Also nulls out the pointer. - * - * @pointer_location: Pointer that was passed to eel_add_weak_pointer. - **/ -void -eel_remove_weak_pointer (gpointer pointer_location) -{ - gpointer *object_location; - - g_return_if_fail (pointer_location != NULL); - - object_location = (gpointer *) pointer_location; - if (*object_location == NULL) { - /* The object was already destroyed and the reference - * nulled out, nothing to do. - */ - return; - } - - g_return_if_fail (G_IS_OBJECT (*object_location)); - - g_object_remove_weak_pointer (G_OBJECT (*object_location), - object_location); - - *object_location = NULL; -} - -static void -update_auto_strv_as_quarks (GSettings *settings, - const gchar *key, - gpointer user_data) -{ - GQuark **storage = user_data; - int i = 0; - char **value; - - value = g_settings_get_strv (settings, key); - - g_free (*storage); - *storage = g_new (GQuark, g_strv_length (value) + 1); - - for (i = 0; value[i] != NULL; ++i) { - (*storage)[i] = g_quark_from_string (value[i]); - } - (*storage)[i] = 0; - - g_strfreev (value); -} - -void -eel_g_settings_add_auto_strv_as_quarks (GSettings *settings, - const char *key, - GQuark **storage) -{ - char *signal; - - *storage = NULL; - update_auto_strv_as_quarks (settings, key, storage); - signal = g_strconcat ("changed::", key, NULL); - g_signal_connect (settings, signal, - G_CALLBACK(update_auto_strv_as_quarks), - storage); - - g_free (signal); + g_list_foreach (list, (GFunc) g_object_ref, NULL); + return g_list_copy (list); } #if !defined (EEL_OMIT_SELF_CHECK) -static void -check_tm_to_g_date (time_t time) -{ - struct tm *before_conversion; - struct tm after_conversion; - GDate *date; - - before_conversion = localtime (&time); - date = eel_g_date_new_tm (before_conversion); - - g_date_to_struct_tm (date, &after_conversion); - - g_date_free (date); - - EEL_CHECK_INTEGER_RESULT (after_conversion.tm_mday, - before_conversion->tm_mday); - EEL_CHECK_INTEGER_RESULT (after_conversion.tm_mon, - before_conversion->tm_mon); - EEL_CHECK_INTEGER_RESULT (after_conversion.tm_year, - before_conversion->tm_year); -} - static gboolean eel_test_predicate (gpointer data, gpointer callback_data) @@ -743,13 +454,11 @@ test_strftime (const char *format, void eel_self_check_glib_extensions (void) { - char **strv; GList *compare_list_1; GList *compare_list_2; GList *compare_list_3; GList *compare_list_4; GList *compare_list_5; - gint64 time1, time2; GList *list_to_partition; GList *expected_passed; GList *expected_failed; @@ -757,25 +466,6 @@ eel_self_check_glib_extensions (void) GList *actual_failed; char *huge_string; - check_tm_to_g_date (0); /* lower limit */ - check_tm_to_g_date ((time_t) -1); /* upper limit */ - check_tm_to_g_date (time (NULL)); /* current time */ - - strv = g_strsplit ("zero|one|two|three|four", "|", 0); - EEL_CHECK_INTEGER_RESULT (eel_g_strv_find (strv, "zero"), 0); - EEL_CHECK_INTEGER_RESULT (eel_g_strv_find (strv, "one"), 1); - EEL_CHECK_INTEGER_RESULT (eel_g_strv_find (strv, "four"), 4); - EEL_CHECK_INTEGER_RESULT (eel_g_strv_find (strv, "five"), -1); - EEL_CHECK_INTEGER_RESULT (eel_g_strv_find (strv, ""), -1); - EEL_CHECK_INTEGER_RESULT (eel_g_strv_find (strv, "o"), -1); - g_strfreev (strv); - - /* eel_get_system_time */ - time1 = eel_get_system_time (); - time2 = eel_get_system_time (); - EEL_CHECK_BOOLEAN_RESULT (time1 - time2 > -1000, TRUE); - EEL_CHECK_BOOLEAN_RESULT (time1 - time2 <= 0, TRUE); - /* eel_g_str_list_equal */ /* We g_strdup because identical string constants can be shared. */ diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index d32f88024..389eb5c29 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -38,15 +38,10 @@ typedef gboolean (* EelPredicateFunction) (gpointer data, gpointer callback_data); /* Date & time functions. */ -GDate * eel_g_date_new_tm (struct tm *time_pieces); char * eel_strdup_strftime (const char *format, struct tm *time_pieces); /* GList functions. */ -gboolean eel_g_list_exactly_one_item (GList *list); -gboolean eel_g_list_more_than_one_item (GList *list); -gboolean eel_g_list_equal (GList *list_a, - GList *list_b); gboolean eel_g_lists_sort_and_check_for_intersection (GList **list_a, GList **list_b); GList * eel_g_list_partition (GList *list, @@ -58,12 +53,8 @@ GList * eel_g_list_partition (GList * gboolean eel_g_str_list_equal (GList *str_list_a, GList *str_list_b); GList * eel_g_str_list_copy (GList *str_list); -GList * eel_g_str_list_alphabetize (GList *str_list); -int eel_g_str_list_index (GList *str_list, - const char *str); /* List functions for lists of objects */ -GList * eel_g_object_list_ref (GList *list); GList * eel_g_object_list_copy (GList *list); /* GHashTable functions */ @@ -72,23 +63,7 @@ void eel_g_hash_table_safe_for_each (GHashTable * gpointer callback_data); /* NULL terminated string arrays (strv). */ -int eel_g_strv_find (char **strv, - const char *find_me); gboolean eel_g_strv_equal (char **a, char **b); -/* return the time in microseconds since the machine was started */ -gint64 eel_get_system_time (void); - -/* math */ -int eel_round (double d); - -/* Better weak pointer functions */ -void eel_add_weak_pointer (gpointer pointer_location); -void eel_remove_weak_pointer (gpointer pointer_location); - -void eel_g_settings_add_auto_strv_as_quarks (GSettings *settings, - const char *key, - GQuark **storage); - #endif /* EEL_GLIB_EXTENSIONS_H */ diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index cc8a0f63e..01c5943a7 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -317,32 +317,6 @@ eel_gtk_menu_insert_separator (GtkMenu *menu, int index) return GTK_MENU_ITEM (menu_item); } -/** - * eel_gtk_label_make_bold. - * - * Switches the font of label to a bold equivalent. - * @label: The label. - **/ -void -eel_gtk_label_make_bold (GtkLabel *label) -{ - PangoFontDescription *font_desc; - - font_desc = pango_font_description_new (); - - pango_font_description_set_weight (font_desc, - PANGO_WEIGHT_BOLD); - - /* This will only affect the weight of the font, the rest is - * from the current state of the widget, which comes from the - * theme or user prefs, since the font desc only has the - * weight flag turned on. - */ - gtk_widget_override_font (GTK_WIDGET (label), font_desc); - - pango_font_description_free (font_desc); -} - static gboolean tree_view_button_press_callback (GtkWidget *tree_view, GdkEventButton *event, diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index e0ad9b4f1..dd9b3323f 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -56,9 +56,6 @@ GtkMenuItem * eel_gtk_menu_append_separator (GtkMenu GtkMenuItem * eel_gtk_menu_insert_separator (GtkMenu *menu, int index); -/* GtkLabel */ -void eel_gtk_label_make_bold (GtkLabel *label); - /* GtkTreeView */ void eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view, gboolean should_activate); diff --git a/eel/eel-string.c b/eel/eel-string.c index 3ecd9f276..0d0f7ca71 100644 --- a/eel/eel-string.c +++ b/eel/eel-string.c @@ -35,36 +35,6 @@ #include "eel-lib-self-check-functions.h" #endif -gboolean -eel_str_is_empty (const char *string_or_null) -{ - return g_strcmp0 (string_or_null, NULL) == 0; -} - -gboolean -eel_istr_has_prefix (const char *haystack, const char *needle) -{ - const char *h, *n; - char hc, nc; - - /* Eat one character at a time. */ - h = haystack == NULL ? "" : haystack; - n = needle == NULL ? "" : needle; - do { - if (*n == '\0') { - return TRUE; - } - if (*h == '\0') { - return FALSE; - } - hc = *h++; - nc = *n++; - hc = g_ascii_tolower (hc); - nc = g_ascii_tolower (nc); - } while (hc == nc); - return FALSE; -} - char * eel_str_double_underscores (const char *string) { diff --git a/eel/eel-string.h b/eel/eel-string.h index c0d697d75..fd2956795 100644 --- a/eel/eel-string.h +++ b/eel/eel-string.h @@ -37,13 +37,6 @@ /* NULL is allowed for all the str parameters to these functions. */ -/* Other basic string operations. */ -gboolean eel_str_is_empty (const char *str_or_null); -gboolean eel_str_is_equal (const char *str_a, - const char *str_b); -gboolean eel_istr_has_prefix (const char *target, - const char *prefix); - /* Escape function for '_' character. */ char * eel_str_double_underscores (const char *str); |