diff options
author | Darin Adler <darin@src.gnome.org> | 2000-06-09 02:05:35 +0000 |
---|---|---|
committer | Darin Adler <darin@src.gnome.org> | 2000-06-09 02:05:35 +0000 |
commit | f9d22365cf9da11621306b89e420bfe6a0d5651f (patch) | |
tree | 1c038e5d6fd5d61f3f8ca67e0456b32fd4f037cc | |
parent | 2b5c47669ab40739403125969410a46b60076458 (diff) | |
download | nautilus-f9d22365cf9da11621306b89e420bfe6a0d5651f.tar.gz |
Added NAUTILUS_PREFIX so we can locate our installed files correctly
* acconfig.h:
* configure.in:
Added NAUTILUS_PREFIX so we can locate our installed files
correctly instead of assuming they are in the gnome-libs prefix.
* components/help/hyperbola-filefmt.c: (fmt_map_entry):
* components/websearch/ntl-web-search.c:
(web_search_populate_engines):
* libnautilus-extensions/nautilus-file-utilities.c:
(nautilus_get_user_main_directory):
* libnautilus-extensions/nautilus-link-set.c:
(get_link_set_document):
* src/file-manager/fm-properties-window.c: (get_property_names):
* src/nautilus-property-browser.c:
(nautilus_property_browser_drag_data_get), (make_drag_image),
(get_xml_path), (make_properties_from_directory):
Use NAUTILUS_PREFIX instead of gnome_datadir_file so we get the
files from the right directory. Since gnome_datadir_file does a
check to see if the file exists, had to add some explicit checks
in various places.
* components/html/glib-www-callbacks.c:
Got rid of some warnings.
* components/services/time/command-line/.cvsignore:
* components/services/time/nautilus-view/.cvsignore:
* components/services/time/service/.cvsignore:
Ignore the new time stamp files.
* libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h:
Fixed formatting.
* RENAMING:
* src/nautilus-sidebar-tabs.c:
* src/nautilus-sidebar-tabs.h:
* src/nautilus-sidebar-title.c:
* src/nautilus-sidebar-title.h:
* src/nautilus-sidebar.c:
Renamed IndexTabs and IndexTitle to SidebarTabs
and SidebarTitle as planned.
24 files changed, 597 insertions, 598 deletions
@@ -1,3 +1,46 @@ +2000-06-08 Darin Adler <darin@eazel.com> + + * acconfig.h: + * configure.in: + Added NAUTILUS_PREFIX so we can locate our installed files + correctly instead of assuming they are in the gnome-libs prefix. + + * components/help/hyperbola-filefmt.c: (fmt_map_entry): + * components/websearch/ntl-web-search.c: + (web_search_populate_engines): + * libnautilus-extensions/nautilus-file-utilities.c: + (nautilus_get_user_main_directory): + * libnautilus-extensions/nautilus-link-set.c: + (get_link_set_document): + * src/file-manager/fm-properties-window.c: (get_property_names): + * src/nautilus-property-browser.c: + (nautilus_property_browser_drag_data_get), (make_drag_image), + (get_xml_path), (make_properties_from_directory): + Use NAUTILUS_PREFIX instead of gnome_datadir_file so we get the + files from the right directory. Since gnome_datadir_file does a + check to see if the file exists, had to add some explicit checks + in various places. + + * components/html/glib-www-callbacks.c: + Got rid of some warnings. + + * components/services/time/command-line/.cvsignore: + * components/services/time/nautilus-view/.cvsignore: + * components/services/time/service/.cvsignore: + Ignore the new time stamp files. + + * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h: + Fixed formatting. + + * RENAMING: + * src/nautilus-sidebar-tabs.c: + * src/nautilus-sidebar-tabs.h: + * src/nautilus-sidebar-title.c: + * src/nautilus-sidebar-title.h: + * src/nautilus-sidebar.c: + Renamed IndexTabs and IndexTitle to SidebarTabs + and SidebarTitle as planned. + 2000-06-08 Maciej Stachowiak <mjs@eazel.com> * libnautilus-extensions/nautilus-view-identifier.h, @@ -15,19 +15,17 @@ components/websearch/ntl-web-search.c -> components/websearch/nautilus-web-searc src/file-manager/fm-* -> ? src/file-manager/dfos* -> ? - -------------------------- Random vestiges of "ntl" -------------------------- libntl-file-manager.* -> libnautilus-file-manager.* *ntl* -> *nautilus* header file guard #defines, *NTL* -> *NAUTILUS* + (change to match header file instead with perl script to check?) ---------------------------- classes and other data types ---------------------------- -NautilusIndexTabs -> NautilusSidebarTabs -NautilusIndexTitle -> NautilusSidebarTitle NavigationRequestInfo -> NavigationRequest NautilusApp -> NautilusApplication NavigationInfo -> Location diff --git a/acconfig.h b/acconfig.h index 42748b806..fba81f9c6 100644 --- a/acconfig.h +++ b/acconfig.h @@ -3,8 +3,7 @@ #undef HAVE_CATGETS #undef HAVE_GETTEXT #undef HAVE_LC_MESSAGES -#undef HAVE_STPCPY - -#undef HAVE_RPM #undef HAVE_PAM - +#undef HAVE_RPM +#undef HAVE_STPCPY +#undef NAUTILUS_PREFIX diff --git a/components/help/hyperbola-filefmt.c b/components/help/hyperbola-filefmt.c index ccfe0a0a0..fb29bc944 100644 --- a/components/help/hyperbola-filefmt.c +++ b/components/help/hyperbola-filefmt.c @@ -264,24 +264,23 @@ fmt_map_entry(HyperbolaDocTree *tree, const char *name, char section) if(!tinfo) { GList *langlist, *cur; - char mapfile[PATH_MAX], *tmapfile; + char mapfile[PATH_MAX]; + const char *tmapfile; tinfo = tree->user_data = g_new0(TreeInfo, 1); /* Because mapping entries are prepended, we have to read the items in reverse order of preference */ - tmapfile = gnome_datadir_file("hyperbola/maps/pages.map"); - fmt_read_mapping(tinfo, tmapfile?tmapfile:"pages.map"); - g_free(tmapfile); + tmapfile = NAUTILUS_PREFIX "/share/hyperbola/maps/pages.map"; + fmt_read_mapping(tinfo, g_file_exists(tmapfile)?tmapfile:"pages.map"); for(cur = langlist = g_list_reverse(g_list_copy(gnome_i18n_get_language_list(NULL))); cur; cur = cur->next) { - g_snprintf(mapfile, sizeof(mapfile), "hyperbola/maps/pages.map.%s", (char *)cur->data); - - tmapfile = gnome_datadir_file(mapfile); - fmt_read_mapping(tinfo, tmapfile?tmapfile:g_basename(mapfile)); - g_free(tmapfile); + g_snprintf(mapfile, sizeof(mapfile), + NAUTILUS_PREFIX "/share/hyperbola/maps/pages.map.%s", + (char *)cur->data); + fmt_read_mapping(tinfo, g_file_exists(mapfile)?mapfile:g_basename(mapfile)); } g_list_free(langlist); } diff --git a/components/html/glibwww-callbacks.c b/components/html/glibwww-callbacks.c index 0a36ebf07..21ff83d7c 100644 --- a/components/html/glibwww-callbacks.c +++ b/components/html/glibwww-callbacks.c @@ -2,6 +2,8 @@ #include "glibwww.h" #include <HTEvent.h> #include <HTTimer.h> +#undef PACKAGE +#undef VERSION #include <config.h> #define WWW_HIGH_PRIORITY (G_PRIORITY_HIGH_IDLE + 50) diff --git a/components/services/time/command-line/.cvsignore b/components/services/time/command-line/.cvsignore index fd9f01115..70d328d58 100644 --- a/components/services/time/command-line/.cvsignore +++ b/components/services/time/command-line/.cvsignore @@ -2,9 +2,10 @@ .libs Makefile Makefile.in +eazel-time trilobite-eazel-time-service-cli trilobite-eazel-time-service-common.c trilobite-eazel-time-service-skels.c trilobite-eazel-time-service-stubs.c trilobite-eazel-time-service.h -eazel-time +trilobite_eazel_time_service_idl_stamp diff --git a/components/services/time/nautilus-view/.cvsignore b/components/services/time/nautilus-view/.cvsignore index 780b4049f..ca8d96ad3 100644 --- a/components/services/time/nautilus-view/.cvsignore +++ b/components/services/time/nautilus-view/.cvsignore @@ -7,3 +7,4 @@ trilobite-eazel-time-service-skels.c trilobite-eazel-time-service-stubs.c trilobite-eazel-time-service.h trilobite-eazel-time-view +trilobite_eazel_time_service_idl_stamp diff --git a/components/services/time/service/.cvsignore b/components/services/time/service/.cvsignore index 25a1d9ea1..e9d6bb15e 100644 --- a/components/services/time/service/.cvsignore +++ b/components/services/time/service/.cvsignore @@ -7,3 +7,4 @@ trilobite-eazel-time-service-common.c trilobite-eazel-time-service-skels.c trilobite-eazel-time-service-stubs.c trilobite-eazel-time-service.h +trilobite_eazel_time_service_idl_stamp diff --git a/components/websearch/ntl-web-search.c b/components/websearch/ntl-web-search.c index 282c0fda5..ed61e2f7c 100644 --- a/components/websearch/ntl-web-search.c +++ b/components/websearch/ntl-web-search.c @@ -114,14 +114,9 @@ static void web_search_populate_engines(WebSearchView *hview) { FILE *fh; - char *fn; char aline[LINE_MAX]; - fn = gnome_datadir_file("ntl-web-search/standard.eng"); - g_return_if_fail(fn); - - fh = fopen(fn, "r"); - g_free(fn); + fh = fopen(NAUTILUS_PREFIX "/share/ntl-web-search/standard.eng", "r"); g_return_if_fail(fh); while(fgets(aline, sizeof(aline), fh)) diff --git a/configure.in b/configure.in index 4ca044577..8e692c877 100644 --- a/configure.in +++ b/configure.in @@ -39,6 +39,17 @@ if test "$GCC" = "yes"; then fi AC_SUBST(WERROR) + +dnl prefix so Nautilus can find its installed files +if test "x$prefix" = "xNONE"; then + nautilus_prefix=${ac_default_prefix} +else + nautilus_prefix=${prefix} +fi +AC_DEFINE_UNQUOTED(NAUTILUS_PREFIX, "${nautilus_prefix}") + + + dnl ORBit AM_PATH_ORBIT diff --git a/libnautilus-extensions/nautilus-file-utilities.c b/libnautilus-extensions/nautilus-file-utilities.c index 377c646b4..7876cd27c 100644 --- a/libnautilus-extensions/nautilus-file-utilities.c +++ b/libnautilus-extensions/nautilus-file-utilities.c @@ -42,8 +42,6 @@ #define NAUTILUS_USER_MAIN_DIRECTORY_NAME "Nautilus" - - /** * nautilus_make_path: * @@ -139,6 +137,8 @@ nautilus_get_user_main_directory (void) { static char *user_main_directory = NULL; NautilusFile *file; + char *command, *file_uri, *image_uri, *temp_str; + if (user_main_directory == NULL) { @@ -147,16 +147,12 @@ nautilus_get_user_main_directory (void) NAUTILUS_USER_MAIN_DIRECTORY_NAME); if (!g_file_exists (user_main_directory)) { - char *src; - char *command; - char *file_uri, *image_uri, *temp_str; - - src = gnome_datadir_file ("nautilus/top"); - /* FIXME bugzilla.eazel.com 1285: * Is it OK to use cp like this? What about quoting the parameters? */ - command = g_strdup_printf ("cp -R %s %s", src, user_main_directory); + command = g_strdup_printf ("cp -R %s %s", + NAUTILUS_PREFIX "/share/nautilus/top", + user_main_directory); /* FIXME bugzilla.eazel.com 1286: * Is a g_warning good enough here? This seems like a big problem. @@ -166,7 +162,6 @@ nautilus_get_user_main_directory (void) command); } - g_free (src); g_free (command); /* assign a custom image for the directory icon */ diff --git a/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h b/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h index 5fc948806..f19e5b185 100644 --- a/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h +++ b/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h @@ -55,9 +55,8 @@ void nautilus_gdk_pixbuf_render_to_drawable_tiled (GdkPixbu GdkRgbDither dither, int x_dither, int y_dither); +GdkPixbuf * nautilus_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, + int max_width, + int max_height); - -GdkPixbuf * nautilus_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, - int max_width, - int max_height); #endif /* NAUTILUS_GDK_PIXBUF_EXTENSIONS_H */ diff --git a/libnautilus-extensions/nautilus-link-set.c b/libnautilus-extensions/nautilus-link-set.c index 5719cd205..affd65513 100644 --- a/libnautilus-extensions/nautilus-link-set.c +++ b/libnautilus-extensions/nautilus-link-set.c @@ -72,15 +72,14 @@ create_new_link (const char *directory_path, const char *name, const char *image /* utility to return link set path */ static xmlDocPtr -get_link_set_document(const char* link_set_name) +get_link_set_document(const char *link_set_name) { - char *link_set_path, *temp_str; + char *link_set_path; xmlDocPtr document; - temp_str = g_strdup_printf ("nautilus/linksets/%s.xml", link_set_name); - link_set_path = gnome_datadir_file (temp_str); - g_free (temp_str); - + link_set_path = g_strdup_printf ("%s/share/nautilus/linksets/%s.xml", + NAUTILUS_PREFIX, + link_set_name); document = xmlParseFile (link_set_path); g_free (link_set_path); diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c index 377c646b4..7876cd27c 100644 --- a/libnautilus-private/nautilus-file-utilities.c +++ b/libnautilus-private/nautilus-file-utilities.c @@ -42,8 +42,6 @@ #define NAUTILUS_USER_MAIN_DIRECTORY_NAME "Nautilus" - - /** * nautilus_make_path: * @@ -139,6 +137,8 @@ nautilus_get_user_main_directory (void) { static char *user_main_directory = NULL; NautilusFile *file; + char *command, *file_uri, *image_uri, *temp_str; + if (user_main_directory == NULL) { @@ -147,16 +147,12 @@ nautilus_get_user_main_directory (void) NAUTILUS_USER_MAIN_DIRECTORY_NAME); if (!g_file_exists (user_main_directory)) { - char *src; - char *command; - char *file_uri, *image_uri, *temp_str; - - src = gnome_datadir_file ("nautilus/top"); - /* FIXME bugzilla.eazel.com 1285: * Is it OK to use cp like this? What about quoting the parameters? */ - command = g_strdup_printf ("cp -R %s %s", src, user_main_directory); + command = g_strdup_printf ("cp -R %s %s", + NAUTILUS_PREFIX "/share/nautilus/top", + user_main_directory); /* FIXME bugzilla.eazel.com 1286: * Is a g_warning good enough here? This seems like a big problem. @@ -166,7 +162,6 @@ nautilus_get_user_main_directory (void) command); } - g_free (src); g_free (command); /* assign a custom image for the directory icon */ diff --git a/libnautilus-private/nautilus-gdk-pixbuf-extensions.h b/libnautilus-private/nautilus-gdk-pixbuf-extensions.h index 5fc948806..f19e5b185 100644 --- a/libnautilus-private/nautilus-gdk-pixbuf-extensions.h +++ b/libnautilus-private/nautilus-gdk-pixbuf-extensions.h @@ -55,9 +55,8 @@ void nautilus_gdk_pixbuf_render_to_drawable_tiled (GdkPixbu GdkRgbDither dither, int x_dither, int y_dither); +GdkPixbuf * nautilus_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, + int max_width, + int max_height); - -GdkPixbuf * nautilus_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, - int max_width, - int max_height); #endif /* NAUTILUS_GDK_PIXBUF_EXTENSIONS_H */ diff --git a/libnautilus-private/nautilus-link-set.c b/libnautilus-private/nautilus-link-set.c index 5719cd205..affd65513 100644 --- a/libnautilus-private/nautilus-link-set.c +++ b/libnautilus-private/nautilus-link-set.c @@ -72,15 +72,14 @@ create_new_link (const char *directory_path, const char *name, const char *image /* utility to return link set path */ static xmlDocPtr -get_link_set_document(const char* link_set_name) +get_link_set_document(const char *link_set_name) { - char *link_set_path, *temp_str; + char *link_set_path; xmlDocPtr document; - temp_str = g_strdup_printf ("nautilus/linksets/%s.xml", link_set_name); - link_set_path = gnome_datadir_file (temp_str); - g_free (temp_str); - + link_set_path = g_strdup_printf ("%s/share/nautilus/linksets/%s.xml", + NAUTILUS_PREFIX, + link_set_name); document = xmlParseFile (link_set_path); g_free (link_set_path); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index edd45b1a2..80d629a9f 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -660,19 +660,15 @@ get_property_names_from_uri (const char *directory_uri, GList *property_list) } static GList * -get_property_names () +get_property_names (void) { - char *directory_path, *directory_uri; + char *directory_uri; GList *property_list; - directory_path = gnome_datadir_file ("nautilus/emblems"); - directory_uri = g_strdup_printf ("file://%s", directory_path); - g_free (directory_path); - - property_list = get_property_names_from_uri (directory_uri, NULL); - g_free (directory_uri); + property_list = get_property_names_from_uri + ("file://" NAUTILUS_PREFIX "/share/nautilus/emblems", NULL); - directory_uri = g_strdup_printf ("file://%s/emblems", nautilus_get_user_directory()); + directory_uri = g_strdup_printf ("file://%s/emblems", nautilus_get_user_directory ()); property_list = get_property_names_from_uri (directory_uri, property_list); g_free (directory_uri); diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index 77f678a2c..67f3b75ff 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -51,10 +51,10 @@ struct NautilusSidebarDetails { GtkVBox *container; - NautilusIndexTitle *title; + NautilusSidebarTitle *title; GtkNotebook *notebook; - NautilusIndexTabs *index_tabs; - NautilusIndexTabs *title_tab; + NautilusSidebarTabs *sidebar_tabs; + NautilusSidebarTabs *title_tab; GtkHBox *button_box_centerer; GtkVBox *button_box; gboolean has_buttons; @@ -207,23 +207,23 @@ nautilus_sidebar_initialize (GtkObject *object) GTK_WIDGET (sidebar->details->container)); /* allocate and install the index title widget */ - sidebar->details->title = NAUTILUS_INDEX_TITLE (nautilus_index_title_new ()); + sidebar->details->title = NAUTILUS_SIDEBAR_TITLE (nautilus_sidebar_title_new ()); gtk_widget_show (GTK_WIDGET (sidebar->details->title)); gtk_box_pack_start (GTK_BOX (sidebar->details->container), GTK_WIDGET (sidebar->details->title), FALSE, FALSE, GNOME_PAD); /* first, allocate the index tabs */ - sidebar->details->index_tabs = NAUTILUS_INDEX_TABS (nautilus_index_tabs_new ()); + sidebar->details->sidebar_tabs = NAUTILUS_SIDEBAR_TABS (nautilus_sidebar_tabs_new ()); sidebar->details->selected_index = -1; /* also, allocate the title tab */ - sidebar->details->title_tab = NAUTILUS_INDEX_TABS (nautilus_index_tabs_new ()); - nautilus_index_tabs_set_title_mode (sidebar->details->title_tab, TRUE); + sidebar->details->title_tab = NAUTILUS_SIDEBAR_TABS (nautilus_sidebar_tabs_new ()); + nautilus_sidebar_tabs_set_title_mode (sidebar->details->title_tab, TRUE); - gtk_widget_show (GTK_WIDGET (sidebar->details->index_tabs)); + gtk_widget_show (GTK_WIDGET (sidebar->details->sidebar_tabs)); gtk_box_pack_end (GTK_BOX (sidebar->details->container), - GTK_WIDGET (sidebar->details->index_tabs), + GTK_WIDGET (sidebar->details->sidebar_tabs), FALSE, FALSE, 0); sidebar->details->old_width = widget->allocation.width; @@ -273,7 +273,7 @@ static SidebarPart hit_test (NautilusSidebar *sidebar, int x, int y) { - if (nautilus_point_in_widget (GTK_WIDGET (sidebar->details->index_tabs), x, y)) { + if (nautilus_point_in_widget (GTK_WIDGET (sidebar->details->sidebar_tabs), x, y)) { return TABS_PART; } @@ -281,7 +281,7 @@ hit_test (NautilusSidebar *sidebar, return TITLE_TAB_PART; } - if (nautilus_index_title_hit_test_icon (sidebar->details->title, x, y)) { + if (nautilus_sidebar_title_hit_test_icon (sidebar->details->title, x, y)) { return ICON_PART; } @@ -331,8 +331,8 @@ receive_dropped_uri_list (NautilusSidebar *sidebar, case BACKGROUND_PART: if (exactly_one && uri_is_local_image (uris[0])) { nautilus_background_set_tile_image_uri - (nautilus_get_widget_background (GTK_WIDGET (sidebar)), - uris[0]); + (nautilus_get_widget_background (GTK_WIDGET (sidebar)), + uris[0]); } else if (exactly_one) { gtk_signal_emit (GTK_OBJECT (sidebar), @@ -356,6 +356,10 @@ receive_dropped_uri_list (NautilusSidebar *sidebar, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL, uris[0]); + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_ICON_SCALE, + NULL, + NULL); nautilus_file_unref (file); } } @@ -387,8 +391,8 @@ receive_dropped_color (NautilusSidebar *sidebar, break; case TABS_PART: /* color dropped on main tabs */ - nautilus_index_tabs_receive_dropped_color - (sidebar->details->index_tabs, + nautilus_sidebar_tabs_receive_dropped_color + (sidebar->details->sidebar_tabs, x, y, selection_data); nautilus_directory_set_metadata @@ -400,7 +404,7 @@ receive_dropped_color (NautilusSidebar *sidebar, break; case TITLE_TAB_PART: /* color dropped on title tab */ - nautilus_index_tabs_receive_dropped_color + nautilus_sidebar_tabs_receive_dropped_color (sidebar->details->title_tab, x, y, selection_data); @@ -450,7 +454,7 @@ receive_dropped_keyword (NautilusSidebar *sidebar, nautilus_file_unref(file); /* regenerate the display */ - title = nautilus_index_title_get_text(sidebar->details->title); + title = nautilus_sidebar_title_get_text(sidebar->details->title); nautilus_sidebar_update_info (sidebar, title); g_free(title); } @@ -472,12 +476,10 @@ nautilus_sidebar_drag_data_received (GtkWidget *widget, GdkDragContext *context, case TARGET_URI_LIST: receive_dropped_uri_list (sidebar, x, y, selection_data); break; - case TARGET_COLOR: receive_dropped_color (sidebar, x, y, selection_data); break; case TARGET_BGIMAGE: - if (hit_test (sidebar, x, y) == BACKGROUND_PART) receive_dropped_uri_list (sidebar, x, y, selection_data); break; @@ -512,7 +514,7 @@ nautilus_sidebar_add_panel (NautilusSidebar *sidebar, NautilusViewFrame *panel) GTK_WIDGET (panel)); /* tell the index tabs about it */ - nautilus_index_tabs_add_view (sidebar->details->index_tabs, + nautilus_sidebar_tabs_add_view (sidebar->details->sidebar_tabs, description, GTK_WIDGET (panel), page_num); g_free (description); @@ -538,7 +540,7 @@ nautilus_sidebar_remove_panel (NautilusSidebar *sidebar, description = nautilus_view_frame_get_label (panel); /* Remove the tab associated with this panel */ - nautilus_index_tabs_remove_view (sidebar->details->index_tabs, description); + nautilus_sidebar_tabs_remove_view (sidebar->details->sidebar_tabs, description); g_free (description); } @@ -568,10 +570,10 @@ nautilus_sidebar_activate_panel (NautilusSidebar *sidebar, int which_view) } sidebar->details->selected_index = which_view; - title = nautilus_index_tabs_get_title_from_index (sidebar->details->index_tabs, + title = nautilus_sidebar_tabs_get_title_from_index (sidebar->details->sidebar_tabs, which_view); - nautilus_index_tabs_set_title (sidebar->details->title_tab, title); - nautilus_index_tabs_prelight_tab (sidebar->details->title_tab, -1); + nautilus_sidebar_tabs_set_title (sidebar->details->title_tab, title); + nautilus_sidebar_tabs_prelight_tab (sidebar->details->title_tab, -1); g_free (title); @@ -592,7 +594,7 @@ nautilus_sidebar_deactivate_panel(NautilusSidebar *sidebar) gtk_widget_show (GTK_WIDGET (sidebar->details->button_box)); sidebar->details->selected_index = -1; - nautilus_index_tabs_select_tab (sidebar->details->index_tabs, -1); + nautilus_sidebar_tabs_select_tab (sidebar->details->sidebar_tabs, -1); } /* handle mouse motion events by passing it to the tabs if necessary for pre-lighting */ @@ -603,17 +605,17 @@ nautilus_sidebar_motion_event (GtkWidget *widget, GdkEventMotion *event) int which_tab; int title_top, title_bottom; NautilusSidebar *sidebar; - NautilusIndexTabs *index_tabs, *title_tab; + NautilusSidebarTabs *sidebar_tabs, *title_tab; sidebar = NAUTILUS_SIDEBAR (widget); gtk_widget_get_pointer(widget, &x, &y); /* if the click is in the main tabs, tell them about it */ - index_tabs = sidebar->details->index_tabs; - if (y >= GTK_WIDGET (index_tabs)->allocation.y) { - which_tab = nautilus_index_tabs_hit_test (index_tabs, x, y); - nautilus_index_tabs_prelight_tab (index_tabs, which_tab); + sidebar_tabs = sidebar->details->sidebar_tabs; + if (y >= GTK_WIDGET (sidebar_tabs)->allocation.y) { + which_tab = nautilus_sidebar_tabs_hit_test (sidebar_tabs, x, y); + nautilus_sidebar_tabs_prelight_tab (sidebar_tabs, which_tab); } /* also handle prelighting in the title tab if necessary */ @@ -622,11 +624,11 @@ nautilus_sidebar_motion_event (GtkWidget *widget, GdkEventMotion *event) title_top = GTK_WIDGET (title_tab)->allocation.y; title_bottom = title_top + GTK_WIDGET (title_tab)->allocation.height; if (y >= title_top && y < title_bottom) { - which_tab = nautilus_index_tabs_hit_test (title_tab, x, y); + which_tab = nautilus_sidebar_tabs_hit_test (title_tab, x, y); } else { which_tab = -1; } - nautilus_index_tabs_prelight_tab (title_tab, which_tab); + nautilus_sidebar_tabs_prelight_tab (title_tab, which_tab); } return TRUE; @@ -638,11 +640,11 @@ static gboolean nautilus_sidebar_leave_event (GtkWidget *widget, GdkEventCrossing *event) { NautilusSidebar *sidebar; - NautilusIndexTabs *index_tabs; + NautilusSidebarTabs *sidebar_tabs; sidebar = NAUTILUS_SIDEBAR (widget); - index_tabs = sidebar->details->index_tabs; - nautilus_index_tabs_prelight_tab (index_tabs, -1); + sidebar_tabs = sidebar->details->sidebar_tabs; + nautilus_sidebar_tabs_prelight_tab (sidebar_tabs, -1); return TRUE; } @@ -654,21 +656,21 @@ nautilus_sidebar_press_event (GtkWidget *widget, GdkEventButton *event) { int title_top, title_bottom; NautilusSidebar *sidebar; - NautilusIndexTabs *index_tabs; - NautilusIndexTabs *title_tab; + NautilusSidebarTabs *sidebar_tabs; + NautilusSidebarTabs *title_tab; int rounded_y; int which_tab; sidebar = NAUTILUS_SIDEBAR (widget); - index_tabs = sidebar->details->index_tabs; + sidebar_tabs = sidebar->details->sidebar_tabs; title_tab = sidebar->details->title_tab; rounded_y = floor (event->y + .5); /* if the click is in the main tabs, tell them about it */ - if (rounded_y >= GTK_WIDGET (sidebar->details->index_tabs)->allocation.y) { - which_tab = nautilus_index_tabs_hit_test (index_tabs, event->x, event->y); + if (rounded_y >= GTK_WIDGET (sidebar->details->sidebar_tabs)->allocation.y) { + which_tab = nautilus_sidebar_tabs_hit_test (sidebar_tabs, event->x, event->y); if (which_tab >= 0) { - nautilus_index_tabs_select_tab (index_tabs, which_tab); + nautilus_sidebar_tabs_select_tab (sidebar_tabs, which_tab); nautilus_sidebar_activate_panel (sidebar, which_tab); gtk_widget_queue_draw (widget); } @@ -679,7 +681,7 @@ nautilus_sidebar_press_event (GtkWidget *widget, GdkEventButton *event) title_top = GTK_WIDGET (sidebar->details->title_tab)->allocation.y; title_bottom = title_top + GTK_WIDGET (sidebar->details->title_tab)->allocation.height; if (rounded_y >= title_top && rounded_y <= title_bottom) { - which_tab = nautilus_index_tabs_hit_test (title_tab, event->x, event->y); + which_tab = nautilus_sidebar_tabs_hit_test (title_tab, event->x, event->y); if (which_tab >= 0) { /* the user clicked in the title tab, so deactivate the panel */ nautilus_sidebar_deactivate_panel (sidebar); @@ -883,18 +885,18 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar, color_spec = nautilus_directory_get_metadata (directory, NAUTILUS_METADATA_KEY_SIDEBAR_TAB_COLOR, DEFAULT_TAB_COLOR); - nautilus_index_tabs_set_color(sidebar->details->index_tabs, color_spec); + nautilus_sidebar_tabs_set_color(sidebar->details->sidebar_tabs, color_spec); g_free (color_spec); color_spec = nautilus_directory_get_metadata (directory, NAUTILUS_METADATA_KEY_SIDEBAR_TITLE_TAB_COLOR, DEFAULT_TAB_COLOR); - nautilus_index_tabs_set_color(sidebar->details->title_tab, color_spec); + nautilus_sidebar_tabs_set_color(sidebar->details->title_tab, color_spec); g_free (color_spec); /* tell the title widget about it */ - nautilus_index_title_set_uri (sidebar->details->title, + nautilus_sidebar_title_set_uri (sidebar->details->title, sidebar->details->uri, initial_title); @@ -924,8 +926,8 @@ nautilus_sidebar_set_uri (NautilusSidebar *sidebar, void nautilus_sidebar_set_title (NautilusSidebar *sidebar, const char* new_title) { - nautilus_index_title_set_text (sidebar->details->title, - new_title); + nautilus_sidebar_title_set_text (sidebar->details->title, + new_title); } /* we override size allocate so we can remember our size when it changes, since the paned widget diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index 98d5204bc..c24b5e75a 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -371,26 +371,25 @@ nautilus_property_browser_drag_data_get (GtkWidget *widget, return; } - temp_str = g_strdup_printf("nautilus/%s", property_browser->details->category); - path = gnome_datadir_file (temp_str); - image_file_name = g_strdup_printf("%s/%s", path, property_browser->details->dragged_file); + image_file_name = g_strdup_printf ("%s/share/nautilus/%s/%s", + NAUTILUS_PREFIX, + property_browser->details->category, + property_browser->details->dragged_file); - - if (!g_file_exists(image_file_name)) { - g_free(image_file_name); - image_file_name = g_strdup_printf("%s/%s/%s", - nautilus_get_user_directory (), - property_browser->details->category, - property_browser->details->dragged_file); + if (!g_file_exists (image_file_name)) { + g_free (image_file_name); + image_file_name = g_strdup_printf ("%s/%s/%s", + nautilus_get_user_directory (), + property_browser->details->category, + property_browser->details->dragged_file); } - image_file_uri = g_strdup_printf("file://%s", image_file_name); - gtk_selection_data_set(selection_data, selection_data->target, 8, image_file_uri, strlen(image_file_uri)); + image_file_uri = g_strdup_printf ("file://%s", image_file_name); + gtk_selection_data_set (selection_data, selection_data->target, 8, image_file_uri, strlen(image_file_uri)); - g_free(temp_str); - g_free(path); - g_free(image_file_name); - g_free(image_file_uri); + g_free (path); + g_free (image_file_name); + g_free (image_file_uri); break; default: @@ -428,14 +427,16 @@ ensure_uri_is_image(const char *uri) } /* create the appropriate pixbuf for the passed in file */ -static GdkPixbuf* +static GdkPixbuf * make_drag_image(NautilusPropertyBrowser *property_browser, const char* file_name) { GdkPixbuf *pixbuf; - char *temp_str = g_strdup_printf ("nautilus/%s", property_browser->details->category); - char *path = gnome_datadir_file (temp_str); + char *image_file_name; - char *image_file_name = nautilus_make_path(path, file_name); + image_file_name = g_strdup_printf ("%s/share/nautilus/%s/%s", + NAUTILUS_PREFIX, + property_browser->details->category, + file_name); if (!g_file_exists (image_file_name)) { g_free (image_file_name); @@ -445,12 +446,10 @@ make_drag_image(NautilusPropertyBrowser *property_browser, const char* file_name file_name); } - pixbuf = nautilus_gdk_pixbuf_scale_to_fit(gdk_pixbuf_new_from_file(image_file_name), - MAX_ICON_WIDTH, MAX_ICON_HEIGHT); + pixbuf = nautilus_gdk_pixbuf_scale_to_fit (gdk_pixbuf_new_from_file (image_file_name), + MAX_ICON_WIDTH, MAX_ICON_HEIGHT); - g_free(image_file_name); - g_free(temp_str); - g_free(path); + g_free (image_file_name); return pixbuf; } @@ -632,23 +631,26 @@ dialog_destroy (GtkWidget *widget, gpointer data) static char * get_xml_path(NautilusPropertyBrowser *property_browser) { - char *temp_str; - /* first try the user's home directory */ char *xml_path; - xml_path = nautilus_make_path (nautilus_get_user_directory(), + /* first try the user's home directory */ + xml_path = nautilus_make_path (nautilus_get_user_directory (), property_browser->details->path); if (g_file_exists (xml_path)) { return xml_path; } + g_free (xml_path); /* next try the shared directory */ - g_free (xml_path); - temp_str = g_strdup_printf ("nautilus/%s", + xml_path = g_strdup_printf ("%s/share/nautilus/%s", + NAUTILUS_PREFIX, property_browser->details->path); - xml_path = gnome_datadir_file (temp_str); - g_free (temp_str); - return xml_path; + if (g_file_exists (xml_path)) { + return xml_path; + } + g_free (xml_path); + + return NULL; } /* utility to set up the emblem image from the passed-in file */ @@ -1251,20 +1253,16 @@ make_properties_from_directory_path(NautilusPropertyBrowser *property_browser, c static void make_properties_from_directory(NautilusPropertyBrowser *property_browser, const char* path) { - char *temp_str, *directory_path, *directory_uri; + char *directory_uri; int new_index; int index = 0; /* first, make properties from the shared space */ if (!property_browser->details->remove_mode) { - temp_str = g_strdup_printf("nautilus/%s", property_browser->details->category); - directory_path = gnome_datadir_file (temp_str); - directory_uri = g_strdup_printf("file://%s", directory_path); - - index = make_properties_from_directory_path(property_browser, directory_uri, index); - - g_free(temp_str); - g_free(directory_path); + directory_uri = g_strdup_printf ("file://%s/share/nautilus/%s", + NAUTILUS_PREFIX, + property_browser->details->category); + index = make_properties_from_directory_path (property_browser, directory_uri, index); g_free(directory_uri); } diff --git a/src/nautilus-sidebar-tabs.c b/src/nautilus-sidebar-tabs.c index b42dec825..6cd89e965 100644 --- a/src/nautilus-sidebar-tabs.c +++ b/src/nautilus-sidebar-tabs.c @@ -19,7 +19,7 @@ * * Author: Andy Hertzfeld <andy@eazel.com> * - * This is the tabs widget for the index panel, which represents metaviews as nice tabs as specified + * This is the tabs widget for the sidebar, which represents panels as nice tabs */ #include <config.h> @@ -43,7 +43,7 @@ typedef struct { GtkWidget *tab_view; } TabItem; -struct NautilusIndexTabsDetails { +struct NautilusSidebarTabsDetails { int tab_count; int total_height; gboolean title_mode; @@ -71,26 +71,26 @@ struct NautilusIndexTabsDetails { /* headers */ -static void nautilus_index_tabs_initialize_class (NautilusIndexTabsClass *klass); -static void nautilus_index_tabs_initialize (NautilusIndexTabs *pixmap); -static int nautilus_index_tabs_expose (GtkWidget *widget, +static void nautilus_sidebar_tabs_initialize_class (NautilusSidebarTabsClass *klass); +static void nautilus_sidebar_tabs_initialize (NautilusSidebarTabs *pixmap); +static int nautilus_sidebar_tabs_expose (GtkWidget *widget, GdkEventExpose *event); -static void nautilus_index_tabs_destroy (GtkObject *object); -static void nautilus_index_tabs_size_allocate (GtkWidget *widget, +static void nautilus_sidebar_tabs_destroy (GtkObject *object); +static void nautilus_sidebar_tabs_size_allocate (GtkWidget *widget, GtkAllocation *allocatoin); -static void nautilus_index_tabs_size_request (GtkWidget *widget, +static void nautilus_sidebar_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition); -static int draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, +static int draw_or_hit_test_all_tabs (NautilusSidebarTabs *sidebar_tabs, gboolean draw_flag, int test_x, int test_y); -static TabItem* tab_item_find_by_name (NautilusIndexTabs *index_tabs, +static TabItem* tab_item_find_by_name (NautilusSidebarTabs *sidebar_tabs, const char *name); -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIndexTabs, nautilus_index_tabs, GTK_TYPE_WIDGET) +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSidebarTabs, nautilus_sidebar_tabs, GTK_TYPE_WIDGET) static void -nautilus_index_tabs_initialize_class (NautilusIndexTabsClass *class) +nautilus_sidebar_tabs_initialize_class (NautilusSidebarTabsClass *class) { GtkObjectClass *object_class; GtkWidgetClass *widget_class; @@ -98,75 +98,75 @@ nautilus_index_tabs_initialize_class (NautilusIndexTabsClass *class) object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; - object_class->destroy = nautilus_index_tabs_destroy; - widget_class->expose_event = nautilus_index_tabs_expose; - widget_class->size_request = nautilus_index_tabs_size_request; - widget_class->size_allocate = nautilus_index_tabs_size_allocate; + object_class->destroy = nautilus_sidebar_tabs_destroy; + widget_class->expose_event = nautilus_sidebar_tabs_expose; + widget_class->size_request = nautilus_sidebar_tabs_size_request; + widget_class->size_allocate = nautilus_sidebar_tabs_size_allocate; } /* utilities to set up the text color alternatives */ static void -setup_light_text(NautilusIndexTabs *index_tabs) +setup_light_text(NautilusSidebarTabs *sidebar_tabs) { - gdk_color_parse ("rgb:ff/ff/ff", &index_tabs->details->text_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->text_color, FALSE, TRUE); + gdk_color_parse ("rgb:ff/ff/ff", &sidebar_tabs->details->text_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->text_color, FALSE, TRUE); } static void -setup_dark_text(NautilusIndexTabs *index_tabs) +setup_dark_text(NautilusSidebarTabs *sidebar_tabs) { - gdk_color_parse ("rgb:00/00/00", &index_tabs->details->text_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->text_color, FALSE, TRUE); + gdk_color_parse ("rgb:00/00/00", &sidebar_tabs->details->text_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->text_color, FALSE, TRUE); } static void -nautilus_index_tabs_initialize (NautilusIndexTabs *index_tabs) +nautilus_sidebar_tabs_initialize (NautilusSidebarTabs *sidebar_tabs) { - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(index_tabs), GTK_NO_WINDOW); + GTK_WIDGET_SET_FLAGS (GTK_WIDGET(sidebar_tabs), GTK_NO_WINDOW); - index_tabs->details = g_new0 (NautilusIndexTabsDetails, 1); + sidebar_tabs->details = g_new0 (NautilusSidebarTabsDetails, 1); /* Initialize private members */ - index_tabs->details->tab_items = NULL; - index_tabs->details->tab_count = 0; - index_tabs->details->total_height = 0; - index_tabs->details->title_mode = FALSE; - index_tabs->details->title = NULL; - index_tabs->details->title_prelit = FALSE; + sidebar_tabs->details->tab_items = NULL; + sidebar_tabs->details->tab_count = 0; + sidebar_tabs->details->total_height = 0; + sidebar_tabs->details->title_mode = FALSE; + sidebar_tabs->details->title = NULL; + sidebar_tabs->details->title_prelit = FALSE; /* set up the colors */ - gdk_color_parse ("rgb:99/99/99", &index_tabs->details->tab_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->tab_color, FALSE, TRUE); + gdk_color_parse ("rgb:99/99/99", &sidebar_tabs->details->tab_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->tab_color, FALSE, TRUE); - gdk_color_parse ("rgb:ee/ee/ee", &index_tabs->details->prelight_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->prelight_color, FALSE, TRUE); + gdk_color_parse ("rgb:ee/ee/ee", &sidebar_tabs->details->prelight_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->prelight_color, FALSE, TRUE); - gdk_color_parse ("rgb:ff/ff/ff", &index_tabs->details->background_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->background_color, FALSE, TRUE); + gdk_color_parse ("rgb:ff/ff/ff", &sidebar_tabs->details->background_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->background_color, FALSE, TRUE); - gdk_color_parse ("rgb:00/00/00", &index_tabs->details->line_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->line_color, FALSE, TRUE); + gdk_color_parse ("rgb:00/00/00", &sidebar_tabs->details->line_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->line_color, FALSE, TRUE); - gdk_color_parse ("rgb:d6/d6/d6", &index_tabs->details->hilight_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->hilight_color, FALSE, TRUE); + gdk_color_parse ("rgb:d6/d6/d6", &sidebar_tabs->details->hilight_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->hilight_color, FALSE, TRUE); - setup_light_text(index_tabs); + setup_light_text(sidebar_tabs); - index_tabs->details->title_prelit = FALSE; + sidebar_tabs->details->title_prelit = FALSE; } GtkWidget* -nautilus_index_tabs_new (void) +nautilus_sidebar_tabs_new (void) { - return GTK_WIDGET (gtk_type_new (nautilus_index_tabs_get_type ())); + return GTK_WIDGET (gtk_type_new (nautilus_sidebar_tabs_get_type ())); } /* utility to destroy all the storage used by a tab item */ @@ -179,23 +179,23 @@ tab_item_destroy (TabItem *item) } static void -nautilus_index_tabs_destroy (GtkObject *object) +nautilus_sidebar_tabs_destroy (GtkObject *object) { - NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(object); + NautilusSidebarTabs *sidebar_tabs = NAUTILUS_SIDEBAR_TABS(object); /* release the tab list, if any */ - if (index_tabs->details->tab_items != NULL) { + if (sidebar_tabs->details->tab_items != NULL) { GList *next_tab; - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { + for (next_tab = sidebar_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { tab_item_destroy ((TabItem*)next_tab->data); } - g_list_free (index_tabs->details->tab_items); + g_list_free (sidebar_tabs->details->tab_items); } - g_free (index_tabs->details->title); + g_free (sidebar_tabs->details->title); - g_free (index_tabs->details); + g_free (sidebar_tabs->details); NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); } @@ -203,64 +203,64 @@ nautilus_index_tabs_destroy (GtkObject *object) /* determine the tab associated with the passed-in coordinates, and pass back the notebook page index associated with it */ -int nautilus_index_tabs_hit_test(NautilusIndexTabs *index_tabs, int x, int y) +int nautilus_sidebar_tabs_hit_test(NautilusSidebarTabs *sidebar_tabs, int x, int y) { - return draw_or_hit_test_all_tabs (index_tabs, FALSE, x, y); + return draw_or_hit_test_all_tabs (sidebar_tabs, FALSE, x, y); } /* resize the widget based on the number of tabs */ static void -recalculate_size(NautilusIndexTabs *index_tabs) +recalculate_size(NautilusSidebarTabs *sidebar_tabs) { - GtkWidget *widget = GTK_WIDGET (index_tabs); + GtkWidget *widget = GTK_WIDGET (sidebar_tabs); /* dummy hit test to make sure height measurement is valid */ - draw_or_hit_test_all_tabs(index_tabs, FALSE, -1000, -1000); + draw_or_hit_test_all_tabs(sidebar_tabs, FALSE, -1000, -1000); widget->requisition.width = widget->parent ? widget->parent->allocation.width: 136; - if (index_tabs->details->title_mode) + if (sidebar_tabs->details->title_mode) widget->requisition.height = TAB_HEIGHT; else - widget->requisition.height = index_tabs->details->total_height + TAB_TOP_GAP; + widget->requisition.height = sidebar_tabs->details->total_height + TAB_TOP_GAP; gtk_widget_queue_resize (widget); } static void -nautilus_index_tabs_size_allocate(GtkWidget *widget, GtkAllocation *allocation) +nautilus_sidebar_tabs_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { - NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(widget); + NautilusSidebarTabs *sidebar_tabs = NAUTILUS_SIDEBAR_TABS(widget); NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation)); /* dummy hit test to mesure height */ - draw_or_hit_test_all_tabs(index_tabs, FALSE, -1000, -1000); + draw_or_hit_test_all_tabs(sidebar_tabs, FALSE, -1000, -1000); - if (!index_tabs->details->title_mode) { - gint delta_height = widget->allocation.height - (index_tabs->details->total_height + TAB_TOP_GAP); + if (!sidebar_tabs->details->title_mode) { + gint delta_height = widget->allocation.height - (sidebar_tabs->details->total_height + TAB_TOP_GAP); widget->allocation.height -= delta_height; widget->allocation.y += delta_height; } } static void -nautilus_index_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition) +nautilus_sidebar_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition) { - NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(widget); + NautilusSidebarTabs *sidebar_tabs = NAUTILUS_SIDEBAR_TABS(widget); /* dummy hit test to make sure height measurement is valid */ - draw_or_hit_test_all_tabs(index_tabs, FALSE, -1000, -1000); + draw_or_hit_test_all_tabs(sidebar_tabs, FALSE, -1000, -1000); requisition->width = widget->parent ? widget->parent->allocation.width: 136; - if (index_tabs->details->title_mode) + if (sidebar_tabs->details->title_mode) requisition->height = TAB_HEIGHT; else - requisition->height = index_tabs->details->total_height + TAB_TOP_GAP; + requisition->height = sidebar_tabs->details->total_height + TAB_TOP_GAP; } /* draw a single tab at the passed-in position, return the total width */ static int -draw_one_tab (NautilusIndexTabs *index_tabs, GdkGC *gc, +draw_one_tab (NautilusSidebarTabs *sidebar_tabs, GdkGC *gc, char *tab_name, int x, int y, gboolean prelight_flag) { int text_y_offset; @@ -270,14 +270,13 @@ draw_one_tab (NautilusIndexTabs *index_tabs, GdkGC *gc, int total_width; GtkWidget *widget; - g_assert (index_tabs != NULL); - g_assert (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_assert (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); /* measure the name and compute the bounding box */ - name_width = gdk_string_width (GTK_WIDGET (index_tabs)->style->font, tab_name); + name_width = gdk_string_width (GTK_WIDGET (sidebar_tabs)->style->font, tab_name); total_width = name_width + 2*TAB_MARGIN; - widget = GTK_WIDGET (index_tabs); + widget = GTK_WIDGET (sidebar_tabs); /* FIXME bugzilla.eazel.com 668: * we must "ellipsize" the name if it doesn't fit, for now, assume it does @@ -285,33 +284,33 @@ draw_one_tab (NautilusIndexTabs *index_tabs, GdkGC *gc, /* fill the tab rectangle with the tab color */ - gdk_gc_set_foreground (gc, prelight_flag ? &index_tabs->details->prelight_color : &index_tabs->details->tab_color); + gdk_gc_set_foreground (gc, prelight_flag ? &sidebar_tabs->details->prelight_color : &sidebar_tabs->details->tab_color); gdk_draw_rectangle (widget->window, gc, TRUE, x, y + 1, total_width, TAB_HEIGHT - 1); /* draw the border */ - gdk_gc_set_foreground (gc, &index_tabs->details->line_color); + gdk_gc_set_foreground (gc, &sidebar_tabs->details->line_color); gdk_draw_line(widget->window, gc, x + 1, y, x + total_width - 2, y); gdk_draw_line(widget->window, gc, x, y + 1, x, y + TAB_HEIGHT - 1); gdk_draw_line(widget->window, gc, x + total_width - 1, y + 1, x + total_width - 1, y + TAB_HEIGHT - 1); /* draw the highlights for extra dimensionality */ - gdk_gc_set_foreground (gc, &index_tabs->details->hilight_color); + gdk_gc_set_foreground (gc, &sidebar_tabs->details->hilight_color); gdk_draw_line(widget->window, gc, x + 2, y + 2, x + total_width - 3, y + 2); gdk_draw_line(widget->window, gc, x + 2, y + 2, x + 2, y + TAB_HEIGHT - 1); /* draw the metaview name */ text_y_offset = y + (TAB_HEIGHT >> 1) + 5; - gdk_gc_set_foreground (gc, prelight_flag ? &index_tabs->details->prelit_text_color : &index_tabs->details->text_color); + gdk_gc_set_foreground (gc, prelight_flag ? &sidebar_tabs->details->prelit_text_color : &sidebar_tabs->details->text_color); gdk_draw_string (widget->window, - GTK_WIDGET (index_tabs)->style->font, + GTK_WIDGET (sidebar_tabs)->style->font, gc, x + TAB_MARGIN, text_y_offset, tab_name); /* draw the bottom lines */ tab_bottom = y + TAB_HEIGHT - 1; - gdk_gc_set_foreground (gc, &index_tabs->details->line_color); + gdk_gc_set_foreground (gc, &sidebar_tabs->details->line_color); tab_right = x + 2*TAB_MARGIN + name_width; - gdk_gc_set_foreground (gc, &index_tabs->details->line_color); + gdk_gc_set_foreground (gc, &sidebar_tabs->details->line_color); gdk_draw_line(widget->window, gc, tab_right, tab_bottom, widget->parent->allocation.width, tab_bottom); gdk_draw_line(widget->window, gc, 0, tab_bottom, x, tab_bottom); @@ -321,7 +320,7 @@ draw_one_tab (NautilusIndexTabs *index_tabs, GdkGC *gc, /* draw or hit test all of the currently visible tabs */ static int -draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, gboolean draw_flag, int test_x, int test_y) +draw_or_hit_test_all_tabs (NautilusSidebarTabs *sidebar_tabs, gboolean draw_flag, int test_x, int test_y) { GdkGC *temp_gc; int name_width; @@ -332,26 +331,25 @@ draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, gboolean draw_flag, in int y_pos; int total_height; - g_assert (index_tabs != NULL); - g_assert (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_assert (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); - next_tab = index_tabs->details->tab_items; + next_tab = sidebar_tabs->details->tab_items; - widget = GTK_WIDGET (index_tabs); + widget = GTK_WIDGET (sidebar_tabs); x_pos = widget->allocation.x + 4; y_pos = widget->allocation.y + widget->allocation.height - TAB_HEIGHT; total_height = TAB_HEIGHT; /* handle hit-testing for title mode */ - if (index_tabs->details->title_mode && !draw_flag) { + if (sidebar_tabs->details->title_mode && !draw_flag) { int edge_width = 2 * TAB_MARGIN; - if (index_tabs->details->title == NULL) { + if (sidebar_tabs->details->title == NULL) { return -1; } - name_width = gdk_string_width (GTK_WIDGET (index_tabs)->style->font, - index_tabs->details->title); - index_tabs->details->total_height = total_height; + name_width = gdk_string_width (GTK_WIDGET (sidebar_tabs)->style->font, + sidebar_tabs->details->title); + sidebar_tabs->details->total_height = total_height; if ((test_x >= TITLE_TAB_OFFSET) && (test_x < (TITLE_TAB_OFFSET + name_width + edge_width))) { return 0; } @@ -363,7 +361,7 @@ draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, gboolean draw_flag, in int y_top = widget->allocation.y + TAB_HEIGHT + TAB_TOP_GAP; int fill_height = widget->allocation.y + widget->allocation.height - y_top; temp_gc = gdk_gc_new(widget->window); - gdk_gc_set_foreground (temp_gc, &index_tabs->details->background_color); + gdk_gc_set_foreground (temp_gc, &sidebar_tabs->details->background_color); gdk_draw_rectangle (widget->window, temp_gc, TRUE, widget->allocation.x, y_top, widget->allocation.width, fill_height); } @@ -373,10 +371,10 @@ draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, gboolean draw_flag, in TabItem *this_item = next_tab->data; if (draw_flag && this_item->visible) - tab_width = draw_one_tab(index_tabs, temp_gc, this_item->tab_text, x_pos, y_pos, this_item->prelit); + tab_width = draw_one_tab(sidebar_tabs, temp_gc, this_item->tab_text, x_pos, y_pos, this_item->prelit); else { int edge_width = 2 * TAB_MARGIN; - name_width = gdk_string_width(GTK_WIDGET (index_tabs)->style->font, + name_width = gdk_string_width(GTK_WIDGET (sidebar_tabs)->style->font, this_item->tab_text); tab_width = name_width + edge_width; if (!draw_flag && (test_y >= y_pos) && (test_y <= (y_pos + TAB_HEIGHT)) && @@ -402,21 +400,20 @@ draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, gboolean draw_flag, in if (draw_flag) gdk_gc_unref(temp_gc); - index_tabs->details->total_height = total_height; + sidebar_tabs->details->total_height = total_height; return -1; } /* find a tab with a given name, or return NULL if we can't find one */ static TabItem * -tab_item_find_by_name (NautilusIndexTabs *index_tabs, const char *name) +tab_item_find_by_name (NautilusSidebarTabs *sidebar_tabs, const char *name) { GList *iterator; - g_return_val_if_fail (index_tabs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs), NULL); + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs), NULL); g_return_val_if_fail (name != NULL, NULL); - for (iterator = index_tabs->details->tab_items; iterator != NULL; iterator = iterator->next) { + for (iterator = sidebar_tabs->details->tab_items; iterator != NULL; iterator = iterator->next) { TabItem *tab_item = iterator->data; g_assert (tab_item != NULL); @@ -433,31 +430,30 @@ tab_item_find_by_name (NautilusIndexTabs *index_tabs, const char *name) /* handle an expose event by drawing the tabs */ static int -nautilus_index_tabs_expose (GtkWidget *widget, GdkEventExpose *event) +nautilus_sidebar_tabs_expose (GtkWidget *widget, GdkEventExpose *event) { - NautilusIndexTabs *index_tabs; + NautilusSidebarTabs *sidebar_tabs; - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (widget), FALSE); + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_TABS (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); if (widget->window == NULL) { return FALSE; } - index_tabs = NAUTILUS_INDEX_TABS (widget); + sidebar_tabs = NAUTILUS_SIDEBAR_TABS (widget); /* draw the tabs */ - if (index_tabs->details->title_mode) { + if (sidebar_tabs->details->title_mode) { GdkGC* temp_gc = gdk_gc_new(widget->window); int x_pos = widget->allocation.x; int y_pos = widget->allocation.y; - draw_one_tab (index_tabs, temp_gc, index_tabs->details->title, x_pos + TITLE_TAB_OFFSET, y_pos, index_tabs->details->title_prelit); + draw_one_tab (sidebar_tabs, temp_gc, sidebar_tabs->details->title, x_pos + TITLE_TAB_OFFSET, y_pos, sidebar_tabs->details->title_prelit); gdk_gc_unref (temp_gc); } else { - if (index_tabs->details->tab_count > 0) { - draw_or_hit_test_all_tabs (index_tabs, TRUE, 0, 0); + if (sidebar_tabs->details->tab_count > 0) { + draw_or_hit_test_all_tabs (sidebar_tabs, TRUE, 0, 0); } } @@ -467,18 +463,17 @@ nautilus_index_tabs_expose (GtkWidget *widget, GdkEventExpose *event) /* add a new tab entry, return TRUE if we succeed */ gboolean -nautilus_index_tabs_add_view (NautilusIndexTabs *index_tabs, const char *name, GtkWidget *new_view, int page_num) +nautilus_sidebar_tabs_add_view (NautilusSidebarTabs *sidebar_tabs, const char *name, GtkWidget *new_view, int page_num) { TabItem *new_tab_item; - g_return_val_if_fail (index_tabs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs), FALSE); + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs), FALSE); g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (new_view != NULL, FALSE); /* Check to see if we already have one with this name, if so, refuse to add it */ - if (tab_item_find_by_name (index_tabs, name)) { - g_warning ("nautilus_index_tabs_add_view: Trying to add duplicate item '%s'", name); + if (tab_item_find_by_name (sidebar_tabs, name)) { + g_warning ("nautilus_sidebar_tabs_add_view: Trying to add duplicate item '%s'", name); return FALSE; } @@ -491,11 +486,11 @@ nautilus_index_tabs_add_view (NautilusIndexTabs *index_tabs, const char *name, G new_tab_item->notebook_page = page_num; /* add it to the list */ - index_tabs->details->tab_items = g_list_append(index_tabs->details->tab_items, new_tab_item); + sidebar_tabs->details->tab_items = g_list_append(sidebar_tabs->details->tab_items, new_tab_item); - index_tabs->details->tab_count += 1; - recalculate_size (index_tabs); - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); + sidebar_tabs->details->tab_count += 1; + recalculate_size (sidebar_tabs); + gtk_widget_queue_draw (GTK_WIDGET (sidebar_tabs)); return TRUE; } @@ -503,14 +498,13 @@ nautilus_index_tabs_add_view (NautilusIndexTabs *index_tabs, const char *name, G /* return the name of the tab with the passed in index */ char* -nautilus_index_tabs_get_title_from_index (NautilusIndexTabs *index_tabs, int which_tab) +nautilus_sidebar_tabs_get_title_from_index (NautilusSidebarTabs *sidebar_tabs, int which_tab) { GList *next_tab; - g_return_val_if_fail (index_tabs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs), NULL); + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs), NULL); - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { + for (next_tab = sidebar_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { TabItem *item = next_tab->data; if (item->notebook_page == which_tab) return g_strdup (item->tab_text); @@ -523,55 +517,53 @@ nautilus_index_tabs_get_title_from_index (NautilusIndexTabs *index_tabs, int whi /* remove the specified tab entry */ void -nautilus_index_tabs_remove_view (NautilusIndexTabs *index_tabs, const char *name) +nautilus_sidebar_tabs_remove_view (NautilusSidebarTabs *sidebar_tabs, const char *name) { TabItem *tab_item; - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); g_return_if_fail (name != NULL); /* Look up the item */ - tab_item = tab_item_find_by_name (index_tabs, name); + tab_item = tab_item_find_by_name (sidebar_tabs, name); if (tab_item == NULL) { - g_warning ("nautilus_index_tabs_remove_view: Trying to remove a non-existing item '%s'", name); + g_warning ("nautilus_sidebar_tabs_remove_view: Trying to remove a non-existing item '%s'", name); return; } /* Remove the item from the list */ - index_tabs->details->tab_items = g_list_remove (index_tabs->details->tab_items, tab_item); + sidebar_tabs->details->tab_items = g_list_remove (sidebar_tabs->details->tab_items, tab_item); tab_item_destroy (tab_item); - index_tabs->details->tab_count -= 1; + sidebar_tabs->details->tab_count -= 1; - recalculate_size (index_tabs); - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); + recalculate_size (sidebar_tabs); + gtk_widget_queue_draw (GTK_WIDGET (sidebar_tabs)); } /* prelight a tab, from its associated notebook page number, by setting the prelight flag of the proper tab and clearing the others */ void -nautilus_index_tabs_prelight_tab (NautilusIndexTabs *index_tabs, int which_tab) +nautilus_sidebar_tabs_prelight_tab (NautilusSidebarTabs *sidebar_tabs, int which_tab) { GList *next_tab; gboolean is_prelit; gboolean changed = FALSE; - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); - if (index_tabs->details->title_mode) { + if (sidebar_tabs->details->title_mode) { gboolean is_prelit = which_tab != -1; - if (index_tabs->details->title_prelit != is_prelit) { - index_tabs->details->title_prelit = is_prelit; + if (sidebar_tabs->details->title_prelit != is_prelit) { + sidebar_tabs->details->title_prelit = is_prelit; changed = TRUE; } } else - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { + for (next_tab = sidebar_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { TabItem *item = next_tab->data; is_prelit = (item->notebook_page == which_tab); if (item->prelit != is_prelit) { @@ -581,28 +573,27 @@ nautilus_index_tabs_prelight_tab (NautilusIndexTabs *index_tabs, int which_tab) } if (changed) - gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); + gtk_widget_queue_draw(GTK_WIDGET(sidebar_tabs)); } /* select a tab, from its associated notebook page number, by making it invisible and all the others visible */ void -nautilus_index_tabs_select_tab (NautilusIndexTabs *index_tabs, int which_tab) +nautilus_sidebar_tabs_select_tab (NautilusSidebarTabs *sidebar_tabs, int which_tab) { GList *next_tab; - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { + for (next_tab = sidebar_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { TabItem *item = next_tab->data; item->visible = (item->notebook_page != which_tab); item->prelit = FALSE; } - recalculate_size(index_tabs); - gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); + recalculate_size(sidebar_tabs); + gtk_widget_queue_draw(GTK_WIDGET(sidebar_tabs)); } /* utility routine that returns true if the passed-in color is lighter than average @@ -619,37 +610,35 @@ is_light_color(GdkColor *color) /* set the background color associated with a tab */ void -nautilus_index_tabs_set_color (NautilusIndexTabs *index_tabs, +nautilus_sidebar_tabs_set_color (NautilusSidebarTabs *sidebar_tabs, const char *color_spec) { - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); g_return_if_fail (color_spec != NULL); - gdk_color_parse (color_spec, &index_tabs->details->tab_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->tab_color, FALSE, TRUE); + gdk_color_parse (color_spec, &sidebar_tabs->details->tab_color); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (sidebar_tabs)), + &sidebar_tabs->details->tab_color, FALSE, TRUE); - if (is_light_color(&index_tabs->details->tab_color)) - setup_dark_text(index_tabs); + if (is_light_color(&sidebar_tabs->details->tab_color)) + setup_dark_text(sidebar_tabs); else - setup_light_text(index_tabs); + setup_light_text(sidebar_tabs); - gtk_widget_queue_draw (GTK_WIDGET(index_tabs)); + gtk_widget_queue_draw (GTK_WIDGET(sidebar_tabs)); } /* receive a dropped color */ void -nautilus_index_tabs_receive_dropped_color (NautilusIndexTabs *index_tabs, +nautilus_sidebar_tabs_receive_dropped_color (NautilusSidebarTabs *sidebar_tabs, int x, int y, GtkSelectionData *selection_data) { guint16 *channels; char *color_spec; - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); g_return_if_fail (selection_data != NULL); /* Convert the selection data into a color spec. */ @@ -660,60 +649,57 @@ nautilus_index_tabs_receive_dropped_color (NautilusIndexTabs *index_tabs, channels = (guint16 *) selection_data->data; color_spec = g_strdup_printf ("rgb:%04hX/%04hX/%04hX", channels[0], channels[1], channels[2]); - nautilus_index_tabs_set_color(index_tabs, color_spec); + nautilus_sidebar_tabs_set_color(sidebar_tabs, color_spec); g_free (color_spec); } /* set the title (used in title mode only) */ void -nautilus_index_tabs_set_title (NautilusIndexTabs *index_tabs, const char *new_title) +nautilus_sidebar_tabs_set_title (NautilusSidebarTabs *sidebar_tabs, const char *new_title) { - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); g_return_if_fail (new_title != NULL); - g_free(index_tabs->details->title); - index_tabs->details->title = g_strdup (new_title); + g_free(sidebar_tabs->details->title); + sidebar_tabs->details->title = g_strdup (new_title); } /* set the title mode boolean */ void -nautilus_index_tabs_set_title_mode (NautilusIndexTabs *index_tabs, gboolean is_title_mode) +nautilus_sidebar_tabs_set_title_mode (NautilusSidebarTabs *sidebar_tabs, gboolean is_title_mode) { - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); - if (index_tabs->details->title_mode != !!is_title_mode) { - index_tabs->details->title_mode = !!is_title_mode; - recalculate_size (index_tabs); - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); + if (sidebar_tabs->details->title_mode != !!is_title_mode) { + sidebar_tabs->details->title_mode = !!is_title_mode; + recalculate_size (sidebar_tabs); + gtk_widget_queue_draw (GTK_WIDGET (sidebar_tabs)); } } /* set the visibility of the selected tab */ void -nautilus_index_tabs_set_visible (NautilusIndexTabs *index_tabs, +nautilus_sidebar_tabs_set_visible (NautilusSidebarTabs *sidebar_tabs, const char *name, gboolean is_visible) { TabItem *tab_item; - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs)); g_return_if_fail (name != NULL); /* Look up the item */ - tab_item = tab_item_find_by_name (index_tabs, name); + tab_item = tab_item_find_by_name (sidebar_tabs, name); if (tab_item == NULL) { - g_warning ("nautilus_index_tabs_set_visible: Trying to munge a non-existing item '%s'", name); + g_warning ("nautilus_sidebar_tabs_set_visible: Trying to munge a non-existing item '%s'", name); return; } if (tab_item->visible != is_visible) { tab_item->visible = is_visible; - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); + gtk_widget_queue_draw (GTK_WIDGET (sidebar_tabs)); } } diff --git a/src/nautilus-sidebar-tabs.h b/src/nautilus-sidebar-tabs.h index b8adaab51..41b9f7dc1 100644 --- a/src/nautilus-sidebar-tabs.h +++ b/src/nautilus-sidebar-tabs.h @@ -27,65 +27,54 @@ #include <gtk/gtkmisc.h> -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#define NAUTILUS_TYPE_SIDEBAR_TABS (nautilus_sidebar_tabs_get_type ()) +#define NAUTILUS_SIDEBAR_TABS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SIDEBAR_TABS, NautilusSidebarTabs)) +#define NAUTILUS_SIDEBAR_TABS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SIDEBAR_TABS, NautilusSidebarTabsClass)) +#define NAUTILUS_IS_SIDEBAR_TABS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR_TABS)) +#define NAUTILUS_IS_SIDEBAR_TABS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SIDEBAR_TABS)) -#define NAUTILUS_TYPE_INDEX_TABS (nautilus_index_tabs_get_type ()) -#define NAUTILUS_INDEX_TABS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_INDEX_TABS, NautilusIndexTabs)) -#define NAUTILUS_INDEX_TABS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_INDEX_TABS, NautilusIndexTabsClass)) -#define NAUTILUS_IS_INDEX_TABS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_INDEX_TABS)) -#define NAUTILUS_IS_INDEX_TABS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_INDEX_TABS)) +typedef struct NautilusSidebarTabsDetails NautilusSidebarTabsDetails; -typedef struct NautilusIndexTabs NautilusIndexTabs; -typedef struct NautilusIndexTabsClass NautilusIndexTabsClass; -typedef struct NautilusIndexTabsDetails NautilusIndexTabsDetails; - -struct NautilusIndexTabs +typedef struct { - GtkMisc base; - NautilusIndexTabsDetails *details; -}; + GtkMisc base_slot; + NautilusSidebarTabsDetails *details; +} NautilusSidebarTabs; -struct NautilusIndexTabsClass +typedef struct { - GtkMiscClass parent_class; -}; - -GtkType nautilus_index_tabs_get_type (void); -GtkWidget *nautilus_index_tabs_new (void); -gboolean nautilus_index_tabs_add_view (NautilusIndexTabs *index_tabs, - const char *name, - GtkWidget *new_view, - int page_number); -char * nautilus_index_tabs_get_title_from_index (NautilusIndexTabs *index_tabs, - int which_tab); -int nautilus_index_tabs_hit_test (NautilusIndexTabs *index_tabs, - int x, - int y); -void nautilus_index_tabs_set_color (NautilusIndexTabs *index_tabs, - const char *color_spec); - -void nautilus_index_tabs_receive_dropped_color (NautilusIndexTabs *index_tabs, - int x, - int y, - GtkSelectionData *selection_data); -void nautilus_index_tabs_remove_view (NautilusIndexTabs *index_tabs, - const char *name); -void nautilus_index_tabs_prelight_tab (NautilusIndexTabs *index_tabs, - int which_tab); -void nautilus_index_tabs_select_tab (NautilusIndexTabs *index_tabs, - int which_tab); -void nautilus_index_tabs_set_title (NautilusIndexTabs *index_tabs, - const char *new_title); -void nautilus_index_tabs_set_title_mode (NautilusIndexTabs *index_tabs, - gboolean is_title_mode); -void nautilus_index_tabs_set_visible (NautilusIndexTabs *index_tabs, - const char *name, - gboolean is_visible); + GtkMiscClass base_slot; +} NautilusSidebarTabsClass; -#ifdef __cplusplus -} -#endif /* __cplusplus */ +GtkType nautilus_sidebar_tabs_get_type (void); +GtkWidget *nautilus_sidebar_tabs_new (void); +gboolean nautilus_sidebar_tabs_add_view (NautilusSidebarTabs *sidebar_tabs, + const char *name, + GtkWidget *new_view, + int page_number); +char * nautilus_sidebar_tabs_get_title_from_index (NautilusSidebarTabs *sidebar_tabs, + int which_tab); +int nautilus_sidebar_tabs_hit_test (NautilusSidebarTabs *sidebar_tabs, + int x, + int y); +void nautilus_sidebar_tabs_set_color (NautilusSidebarTabs *sidebar_tabs, + const char *color_spec); +void nautilus_sidebar_tabs_receive_dropped_color (NautilusSidebarTabs *sidebar_tabs, + int x, + int y, + GtkSelectionData *selection_data); +void nautilus_sidebar_tabs_remove_view (NautilusSidebarTabs *sidebar_tabs, + const char *name); +void nautilus_sidebar_tabs_prelight_tab (NautilusSidebarTabs *sidebar_tabs, + int which_tab); +void nautilus_sidebar_tabs_select_tab (NautilusSidebarTabs *sidebar_tabs, + int which_tab); +void nautilus_sidebar_tabs_set_title (NautilusSidebarTabs *sidebar_tabs, + const char *new_title); +void nautilus_sidebar_tabs_set_title_mode (NautilusSidebarTabs *sidebar_tabs, + gboolean is_title_mode); +void nautilus_sidebar_tabs_set_visible (NautilusSidebarTabs *sidebar_tabs, + const char *name, + gboolean is_visible); #endif /* NAUTILUS_SIDEBAR_TABS_H */ diff --git a/src/nautilus-sidebar-title.c b/src/nautilus-sidebar-title.c index 014b3472e..e5fef6d38 100644 --- a/src/nautilus-sidebar-title.c +++ b/src/nautilus-sidebar-title.c @@ -45,16 +45,16 @@ #include <libnautilus-extensions/nautilus-metadata.h> #include <libnautilus-extensions/nautilus-font-factory.h> -static void nautilus_index_title_initialize_class (NautilusIndexTitleClass *klass); -static void nautilus_index_title_destroy (GtkObject *object); -static void nautilus_index_title_initialize (NautilusIndexTitle *pixmap); -static gboolean nautilus_index_title_button_press_event (GtkWidget *widget, - GdkEventButton *event); -static void nautilus_index_title_update_icon (NautilusIndexTitle *index_title); -static void nautilus_index_title_update_label (NautilusIndexTitle *index_title); -static void nautilus_index_title_update_info (NautilusIndexTitle *index_title); - -struct NautilusIndexTitleDetails { +static void nautilus_sidebar_title_initialize_class (NautilusSidebarTitleClass *klass); +static void nautilus_sidebar_title_destroy (GtkObject *object); +static void nautilus_sidebar_title_initialize (NautilusSidebarTitle *pixmap); +static gboolean nautilus_sidebar_title_button_press_event (GtkWidget *widget, + GdkEventButton *event); +static void nautilus_sidebar_title_update_icon (NautilusSidebarTitle *sidebar_title); +static void nautilus_sidebar_title_update_label (NautilusSidebarTitle *sidebar_title); +static void nautilus_sidebar_title_update_info (NautilusSidebarTitle *sidebar_title); + +struct NautilusSidebarTitleDetails { NautilusFile *file; guint file_changed_connection; char *requested_text; @@ -72,10 +72,10 @@ struct NautilusIndexTitleDetails { /* button assignments */ -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIndexTitle, nautilus_index_title, gtk_vbox_get_type ()) +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSidebarTitle, nautilus_sidebar_title, gtk_vbox_get_type ()) static void -nautilus_index_title_initialize_class (NautilusIndexTitleClass *class) +nautilus_sidebar_title_initialize_class (NautilusSidebarTitleClass *class) { GtkObjectClass *object_class; GtkWidgetClass *widget_class; @@ -83,53 +83,53 @@ nautilus_index_title_initialize_class (NautilusIndexTitleClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - object_class->destroy = nautilus_index_title_destroy; - widget_class->button_press_event = nautilus_index_title_button_press_event; + object_class->destroy = nautilus_sidebar_title_destroy; + widget_class->button_press_event = nautilus_sidebar_title_button_press_event; } static void -nautilus_index_title_initialize (NautilusIndexTitle *index_title) +nautilus_sidebar_title_initialize (NautilusSidebarTitle *sidebar_title) { - index_title->details = g_new0 (NautilusIndexTitleDetails, 1); + sidebar_title->details = g_new0 (NautilusSidebarTitleDetails, 1); /* Register to find out about icon theme changes */ gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (), "icons_changed", - nautilus_index_title_update_icon, - GTK_OBJECT (index_title)); + nautilus_sidebar_title_update_icon, + GTK_OBJECT (sidebar_title)); } /* destroy by throwing away private storage */ static void -release_file (NautilusIndexTitle *index_title) +release_file (NautilusSidebarTitle *sidebar_title) { - if (index_title->details->file_changed_connection != 0) { - gtk_signal_disconnect (GTK_OBJECT (index_title->details->file), - index_title->details->file_changed_connection); - index_title->details->file_changed_connection = 0; + if (sidebar_title->details->file_changed_connection != 0) { + gtk_signal_disconnect (GTK_OBJECT (sidebar_title->details->file), + sidebar_title->details->file_changed_connection); + sidebar_title->details->file_changed_connection = 0; } - if (index_title->details->file != NULL) { - if (nautilus_file_is_directory (index_title->details->file)) { - nautilus_file_monitor_remove (index_title->details->file, index_title); + if (sidebar_title->details->file != NULL) { + if (nautilus_file_is_directory (sidebar_title->details->file)) { + nautilus_file_monitor_remove (sidebar_title->details->file, sidebar_title); } - nautilus_file_unref (index_title->details->file); - index_title->details->file = NULL; + nautilus_file_unref (sidebar_title->details->file); + sidebar_title->details->file = NULL; } } static void -nautilus_index_title_destroy (GtkObject *object) +nautilus_sidebar_title_destroy (GtkObject *object) { - NautilusIndexTitle *index_title; + NautilusSidebarTitle *sidebar_title; - index_title = NAUTILUS_INDEX_TITLE (object); + sidebar_title = NAUTILUS_SIDEBAR_TITLE (object); - release_file (index_title); + release_file (sidebar_title); - g_free (index_title->details->requested_text); - g_free (index_title->details); + g_free (sidebar_title->details->requested_text); + g_free (sidebar_title->details); NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); } @@ -137,24 +137,24 @@ nautilus_index_title_destroy (GtkObject *object) /* return a new index title object */ GtkWidget * -nautilus_index_title_new (void) +nautilus_sidebar_title_new (void) { - return GTK_WIDGET (gtk_type_new (nautilus_index_title_get_type ())); + return GTK_WIDGET (gtk_type_new (nautilus_sidebar_title_get_type ())); } /* set up the icon image */ static void -nautilus_index_title_update_icon (NautilusIndexTitle *index_title) +nautilus_sidebar_title_update_icon (NautilusSidebarTitle *sidebar_title) { GdkPixmap *pixmap; GdkBitmap *mask; GdkPixbuf *pixbuf; /* NULL can happen because nautilus_file_get returns NULL for the root. */ - if (index_title->details->file == NULL) { + if (sidebar_title->details->file == NULL) { return; } - pixbuf = nautilus_icon_factory_get_pixbuf_for_file (index_title->details->file, + pixbuf = nautilus_icon_factory_get_pixbuf_for_file (sidebar_title->details->file, NAUTILUS_ICON_SIZE_STANDARD); /* make a pixmap and mask to pass to the widget */ @@ -162,29 +162,29 @@ nautilus_index_title_update_icon (NautilusIndexTitle *index_title) gdk_pixbuf_unref (pixbuf); /* if there's no pixmap so far, so allocate one */ - if (index_title->details->icon != NULL) { - gtk_pixmap_set (GTK_PIXMAP (index_title->details->icon), + if (sidebar_title->details->icon != NULL) { + gtk_pixmap_set (GTK_PIXMAP (sidebar_title->details->icon), pixmap, mask); } else { - index_title->details->icon = GTK_WIDGET (gtk_pixmap_new (pixmap, mask)); - gtk_widget_show (index_title->details->icon); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->icon, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->icon, 0); + sidebar_title->details->icon = GTK_WIDGET (gtk_pixmap_new (pixmap, mask)); + gtk_widget_show (sidebar_title->details->icon); + gtk_box_pack_start (GTK_BOX (sidebar_title), sidebar_title->details->icon, 0, 0, 0); + gtk_box_reorder_child (GTK_BOX (sidebar_title), sidebar_title->details->icon, 0); } } /* set up the filename label */ static void -nautilus_index_title_update_label (NautilusIndexTitle *index_title) +nautilus_sidebar_title_update_label (NautilusSidebarTitle *sidebar_title) { GdkFont *label_font; char *displayed_text; - if (index_title->details->requested_text == NULL) { + if (sidebar_title->details->requested_text == NULL) { /* Use empty string to replace previous contents. */ displayed_text = g_strdup (""); } else { - displayed_text = g_strdup (index_title->details->requested_text); + displayed_text = g_strdup (sidebar_title->details->requested_text); } /* split the filename into two lines if necessary */ @@ -211,58 +211,58 @@ nautilus_index_title_update_label (NautilusIndexTitle *index_title) /* free up the old string and replace it with the new one with the return inserted */ - g_free(displayed_text); + g_free (displayed_text); displayed_text = buffer; break; } } } - if (index_title->details->title != NULL) { - gtk_label_set_text (GTK_LABEL (index_title->details->title), displayed_text); + if (sidebar_title->details->title != NULL) { + gtk_label_set_text (GTK_LABEL (sidebar_title->details->title), displayed_text); } else { - index_title->details->title = GTK_WIDGET (gtk_label_new (displayed_text)); - gtk_label_set_line_wrap (GTK_LABEL (index_title->details->title), TRUE); - gtk_widget_show (index_title->details->title); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->title, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->title, 1); + sidebar_title->details->title = GTK_WIDGET (gtk_label_new (displayed_text)); + gtk_label_set_line_wrap (GTK_LABEL (sidebar_title->details->title), TRUE); + gtk_widget_show (sidebar_title->details->title); + gtk_box_pack_start (GTK_BOX (sidebar_title), sidebar_title->details->title, 0, 0, 0); + gtk_box_reorder_child (GTK_BOX (sidebar_title), sidebar_title->details->title, 1); } /* FIXME bugzilla.eazel.com 1103: * Make this use the font factory */ - label_font = nautilus_get_largest_fitting_font (displayed_text, GTK_WIDGET (index_title)->allocation.width - 4, + label_font = nautilus_get_largest_fitting_font (displayed_text, GTK_WIDGET (sidebar_title)->allocation.width - 4, "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*"); - nautilus_gtk_widget_set_font (index_title->details->title, label_font); + nautilus_gtk_widget_set_font (sidebar_title->details->title, label_font); g_free (displayed_text); } /* add a pixbuf to the emblem box */ static void -nautilus_index_title_add_pixbuf(NautilusIndexTitle *index_title, GdkPixbuf *pixbuf) +nautilus_sidebar_title_add_pixbuf(NautilusSidebarTitle *sidebar_title, GdkPixbuf *pixbuf) { GdkPixmap *pixmap; GdkBitmap *mask; GtkWidget *pixmap_widget; - if (index_title->details->emblem_box == NULL) { + if (sidebar_title->details->emblem_box == NULL) { /* alllocate a new emblem box */ - index_title->details->emblem_box = gtk_hbox_new(FALSE, 0); - gtk_widget_show(index_title->details->emblem_box); - gtk_box_pack_start(GTK_BOX (index_title), index_title->details->emblem_box, 0, 0, 0); + sidebar_title->details->emblem_box = gtk_hbox_new(FALSE, 0); + gtk_widget_show(sidebar_title->details->emblem_box); + gtk_box_pack_start(GTK_BOX (sidebar_title), sidebar_title->details->emblem_box, 0, 0, 0); } gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); pixmap_widget = GTK_WIDGET (gtk_pixmap_new (pixmap, mask)); gtk_widget_show (pixmap_widget); - gtk_container_add(GTK_CONTAINER(index_title->details->emblem_box), pixmap_widget); + gtk_container_add(GTK_CONTAINER(sidebar_title->details->emblem_box), pixmap_widget); } /* set up more info about the file */ void -nautilus_index_title_update_info (NautilusIndexTitle *index_title) +nautilus_sidebar_title_update_info (NautilusSidebarTitle *sidebar_title) { NautilusFile *file; GList *emblem_icons, *current_emblem; @@ -272,7 +272,7 @@ nautilus_index_title_update_info (NautilusIndexTitle *index_title) GdkFont *font; /* NULL can happen because nautilus_file_get returns NULL for the root. */ - file = index_title->details->file; + file = sidebar_title->details->file; if (file == NULL) { return; } @@ -301,9 +301,9 @@ nautilus_index_title_update_info (NautilusIndexTitle *index_title) } /* set up the emblems if necessary. First, deallocate any existing ones */ - if (index_title->details->emblem_box) { - gtk_widget_destroy(index_title->details->emblem_box); - index_title->details->emblem_box = NULL; + if (sidebar_title->details->emblem_box) { + gtk_widget_destroy(sidebar_title->details->emblem_box); + sidebar_title->details->emblem_box = NULL; } /* fetch the emblem icons from metadata */ @@ -318,7 +318,7 @@ nautilus_index_title_update_info (NautilusIndexTitle *index_title) NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_ICON_SIZE_STANDARD); if (emblem_pixbuf != NULL) { - nautilus_index_title_add_pixbuf (index_title, emblem_pixbuf); + nautilus_sidebar_title_add_pixbuf (sidebar_title, emblem_pixbuf); gdk_pixbuf_unref (emblem_pixbuf); } } @@ -328,126 +328,119 @@ nautilus_index_title_update_info (NautilusIndexTitle *index_title) /* set up the additional text info */ - if (index_title->details->more_info) - gtk_label_set_text(GTK_LABEL(index_title->details->more_info), info_string); + if (sidebar_title->details->more_info) + gtk_label_set_text(GTK_LABEL(sidebar_title->details->more_info), info_string); else { - index_title->details->more_info = GTK_WIDGET(gtk_label_new(info_string)); - gtk_widget_show (index_title->details->more_info); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->more_info, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->more_info, 2); + sidebar_title->details->more_info = GTK_WIDGET(gtk_label_new(info_string)); + gtk_widget_show (sidebar_title->details->more_info); + gtk_box_pack_start (GTK_BOX (sidebar_title), sidebar_title->details->more_info, 0, 0, 0); + gtk_box_reorder_child (GTK_BOX (sidebar_title), sidebar_title->details->more_info, 2); } font = nautilus_font_factory_get_font_from_preferences (12); - nautilus_gtk_widget_set_font (index_title->details->more_info, font); + nautilus_gtk_widget_set_font (sidebar_title->details->more_info, font); gdk_font_unref (font); - g_free(info_string); + g_free (info_string); /* see if there are any notes for this file. If so, display them */ notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_NOTES, NULL); if (notes_text != NULL) { - if (index_title->details->notes != NULL) - gtk_label_set_text(GTK_LABEL(index_title->details->notes), notes_text); + if (sidebar_title->details->notes != NULL) + gtk_label_set_text(GTK_LABEL(sidebar_title->details->notes), notes_text); else { - index_title->details->notes = GTK_WIDGET(gtk_label_new(notes_text)); - gtk_label_set_line_wrap(GTK_LABEL(index_title->details->notes), TRUE); - gtk_widget_show (index_title->details->notes); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->notes, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->notes, 3); + sidebar_title->details->notes = GTK_WIDGET(gtk_label_new(notes_text)); + gtk_label_set_line_wrap(GTK_LABEL(sidebar_title->details->notes), TRUE); + gtk_widget_show (sidebar_title->details->notes); + gtk_box_pack_start (GTK_BOX (sidebar_title), sidebar_title->details->notes, 0, 0, 0); + gtk_box_reorder_child (GTK_BOX (sidebar_title), sidebar_title->details->notes, 3); } font = nautilus_font_factory_get_font_from_preferences (12); - nautilus_gtk_widget_set_font (index_title->details->notes, font); + nautilus_gtk_widget_set_font (sidebar_title->details->notes, font); gdk_font_unref (font); g_free (notes_text); - } else if (index_title->details->notes != NULL) { - gtk_label_set_text (GTK_LABEL (index_title->details->notes), ""); + } else if (sidebar_title->details->notes != NULL) { + gtk_label_set_text (GTK_LABEL (sidebar_title->details->notes), ""); } } /* return the filename text */ - char * -nautilus_index_title_get_text(NautilusIndexTitle *index_title) +nautilus_sidebar_title_get_text(NautilusSidebarTitle *sidebar_title) { - if (index_title->details->requested_text) - return g_strdup(index_title->details->requested_text); - return NULL; + return g_strdup (sidebar_title->details->requested_text); } /* set up the filename text */ - void -nautilus_index_title_set_text (NautilusIndexTitle *index_title, const char* new_text) +nautilus_sidebar_title_set_text (NautilusSidebarTitle *sidebar_title, const char* new_text) { - g_free (index_title->details->requested_text); - index_title->details->requested_text = g_strdup (new_text); + g_free (sidebar_title->details->requested_text); + sidebar_title->details->requested_text = g_strdup (new_text); /* Recompute the displayed text. */ - nautilus_index_title_update_label (index_title); + nautilus_sidebar_title_update_label (sidebar_title); } static void -update (NautilusIndexTitle *index_title) +update (NautilusSidebarTitle *sidebar_title) { /* add the icon */ - nautilus_index_title_update_icon (index_title); + nautilus_sidebar_title_update_icon (sidebar_title); /* add the name, in a variable-sized label */ - nautilus_index_title_update_label (index_title); + nautilus_sidebar_title_update_label (sidebar_title); /* add various info */ - nautilus_index_title_update_info (index_title); + nautilus_sidebar_title_update_info (sidebar_title); } void -nautilus_index_title_set_uri (NautilusIndexTitle *index_title, +nautilus_sidebar_title_set_uri (NautilusSidebarTitle *sidebar_title, const char* new_uri, const char* initial_text) { GList *attributes; - release_file (index_title); + release_file (sidebar_title); - index_title->details->file = nautilus_file_get (new_uri); - if (index_title->details->file != NULL) { - index_title->details->file_changed_connection = - gtk_signal_connect_object (GTK_OBJECT (index_title->details->file), + sidebar_title->details->file = nautilus_file_get (new_uri); + if (sidebar_title->details->file != NULL) { + sidebar_title->details->file_changed_connection = + gtk_signal_connect_object (GTK_OBJECT (sidebar_title->details->file), "changed", update, - GTK_OBJECT (index_title)); + GTK_OBJECT (sidebar_title)); /* Monitor the item count so we can update when it is known. */ - if (nautilus_file_is_directory (index_title->details->file)) { + if (nautilus_file_is_directory (sidebar_title->details->file)) { attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT); - nautilus_file_monitor_add (index_title->details->file, index_title, + nautilus_file_monitor_add (sidebar_title->details->file, sidebar_title, attributes, FALSE); g_list_free (attributes); } } - g_free (index_title->details->requested_text); - index_title->details->requested_text = g_strdup (initial_text); + g_free (sidebar_title->details->requested_text); + sidebar_title->details->requested_text = g_strdup (initial_text); - update (index_title); + update (sidebar_title); } -/* handle a button press */ - static gboolean -nautilus_index_title_button_press_event (GtkWidget *widget, GdkEventButton *event) +nautilus_sidebar_title_button_press_event (GtkWidget *widget, GdkEventButton *event) { - /* - NautilusIndexTitle *index_title = NAUTILUS_INDEX_TITLE (widget); - */ + /* FIXME: We must do something other than a g_message here. + * NautilusSidebarTitle *sidebar_title = NAUTILUS_SIDEBAR_TITLE (widget); + */ g_message ("button press"); - return TRUE; } gboolean -nautilus_index_title_hit_test_icon (NautilusIndexTitle *title, int x, int y) +nautilus_sidebar_title_hit_test_icon (NautilusSidebarTitle *title, int x, int y) { return nautilus_point_in_widget (title->details->icon, x, y); } diff --git a/src/nautilus-sidebar-title.h b/src/nautilus-sidebar-title.h index 5b29d6c9e..63efcd591 100644 --- a/src/nautilus-sidebar-title.h +++ b/src/nautilus-sidebar-title.h @@ -19,46 +19,43 @@ * * Author: Andy Hertzfeld <andy@eazel.com> * - * This is the header file for the index title panel, which is part of the index panel - * + * This is the header file for the sidebar title, which is part of the sidebar. */ -#ifndef NAUTILUS_INDEX_TITLE_H -#define NAUTILUS_INDEX_TITLE_H +#ifndef NAUTILUS_SIDEBAR_TITLE_H +#define NAUTILUS_SIDEBAR_TITLE_H #include <gtk/gtkvbox.h> -#define NAUTILUS_TYPE_INDEX_TITLE (nautilus_index_title_get_type ()) -#define NAUTILUS_INDEX_TITLE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_INDEX_TITLE, NautilusIndexTitle)) -#define NAUTILUS_INDEX_TITLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_INDEX_TITLE, NautilusIndexTitleClass)) -#define NAUTILUS_IS_INDEX_TITLE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_INDEX_TITLE)) -#define NAUTILUS_IS_INDEX_TITLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_INDEX_TITLE)) +#define NAUTILUS_TYPE_SIDEBAR_TITLE (nautilus_sidebar_title_get_type ()) +#define NAUTILUS_SIDEBAR_TITLE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SIDEBAR_TITLE, NautilusSidebarTitle)) +#define NAUTILUS_SIDEBAR_TITLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SIDEBAR_TITLE, NautilusSidebarTitleClass)) +#define NAUTILUS_IS_SIDEBAR_TITLE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR_TITLE)) +#define NAUTILUS_IS_SIDEBAR_TITLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SIDEBAR_TITLE)) -typedef struct NautilusIndexTitle NautilusIndexTitle; -typedef struct NautilusIndexTitleClass NautilusIndexTitleClass; -typedef struct NautilusIndexTitleDetails NautilusIndexTitleDetails; +typedef struct NautilusSidebarTitleDetails NautilusSidebarTitleDetails; -struct NautilusIndexTitle +typedef struct { GtkVBox box; - NautilusIndexTitleDetails *details; -}; + NautilusSidebarTitleDetails *details; +} NautilusSidebarTitle; -struct NautilusIndexTitleClass +typedef struct { GtkVBoxClass parent_class; -}; - -GtkType nautilus_index_title_get_type (void); -GtkWidget *nautilus_index_title_new (void); -void nautilus_index_title_set_uri (NautilusIndexTitle *index_title, - const char *new_uri, - const char *initial_text); -void nautilus_index_title_set_text (NautilusIndexTitle *index_title, - const char *new_title); -char* nautilus_index_title_get_text (NautilusIndexTitle *index_title); -gboolean nautilus_index_title_hit_test_icon (NautilusIndexTitle *index_title, - int x, - int y); - -#endif /* NAUTILUS_INDEX_TITLE_H */ +} NautilusSidebarTitleClass; + +GtkType nautilus_sidebar_title_get_type (void); +GtkWidget *nautilus_sidebar_title_new (void); +void nautilus_sidebar_title_set_uri (NautilusSidebarTitle *sidebar_title, + const char *new_uri, + const char *initial_text); +void nautilus_sidebar_title_set_text (NautilusSidebarTitle *sidebar_title, + const char *new_title); +char * nautilus_sidebar_title_get_text (NautilusSidebarTitle *sidebar_title); +gboolean nautilus_sidebar_title_hit_test_icon (NautilusSidebarTitle *sidebar_title, + int x, + int y); + +#endif /* NAUTILUS_SIDEBAR_TITLE_H */ diff --git a/src/nautilus-sidebar.c b/src/nautilus-sidebar.c index 77f678a2c..67f3b75ff 100644 --- a/src/nautilus-sidebar.c +++ b/src/nautilus-sidebar.c @@ -51,10 +51,10 @@ struct NautilusSidebarDetails { GtkVBox *container; - NautilusIndexTitle *title; + NautilusSidebarTitle *title; GtkNotebook *notebook; - NautilusIndexTabs *index_tabs; - NautilusIndexTabs *title_tab; + NautilusSidebarTabs *sidebar_tabs; + NautilusSidebarTabs *title_tab; GtkHBox *button_box_centerer; GtkVBox *button_box; gboolean has_buttons; @@ -207,23 +207,23 @@ nautilus_sidebar_initialize (GtkObject *object) GTK_WIDGET (sidebar->details->container)); /* allocate and install the index title widget */ - sidebar->details->title = NAUTILUS_INDEX_TITLE (nautilus_index_title_new ()); + sidebar->details->title = NAUTILUS_SIDEBAR_TITLE (nautilus_sidebar_title_new ()); gtk_widget_show (GTK_WIDGET (sidebar->details->title)); gtk_box_pack_start (GTK_BOX (sidebar->details->container), GTK_WIDGET (sidebar->details->title), FALSE, FALSE, GNOME_PAD); /* first, allocate the index tabs */ - sidebar->details->index_tabs = NAUTILUS_INDEX_TABS (nautilus_index_tabs_new ()); + sidebar->details->sidebar_tabs = NAUTILUS_SIDEBAR_TABS (nautilus_sidebar_tabs_new ()); sidebar->details->selected_index = -1; /* also, allocate the title tab */ - sidebar->details->title_tab = NAUTILUS_INDEX_TABS (nautilus_index_tabs_new ()); - nautilus_index_tabs_set_title_mode (sidebar->details->title_tab, TRUE); + sidebar->details->title_tab = NAUTILUS_SIDEBAR_TABS (nautilus_sidebar_tabs_new ()); + nautilus_sidebar_tabs_set_title_mode (sidebar->details->title_tab, TRUE); - gtk_widget_show (GTK_WIDGET (sidebar->details->index_tabs)); + gtk_widget_show (GTK_WIDGET (sidebar->details->sidebar_tabs)); gtk_box_pack_end (GTK_BOX (sidebar->details->container), - GTK_WIDGET (sidebar->details->index_tabs), + GTK_WIDGET (sidebar->details->sidebar_tabs), FALSE, FALSE, 0); sidebar->details->old_width = widget->allocation.width; @@ -273,7 +273,7 @@ static SidebarPart hit_test (NautilusSidebar *sidebar, int x, int y) { - if (nautilus_point_in_widget (GTK_WIDGET (sidebar->details->index_tabs), x, y)) { + if (nautilus_point_in_widget (GTK_WIDGET (sidebar->details->sidebar_tabs), x, y)) { return TABS_PART; } @@ -281,7 +281,7 @@ hit_test (NautilusSidebar *sidebar, return TITLE_TAB_PART; } - if (nautilus_index_title_hit_test_icon (sidebar->details->title, x, y)) { + if (nautilus_sidebar_title_hit_test_icon (sidebar->details->title, x, y)) { return ICON_PART; } @@ -331,8 +331,8 @@ receive_dropped_uri_list (NautilusSidebar *sidebar, case BACKGROUND_PART: if (exactly_one && uri_is_local_image (uris[0])) { nautilus_background_set_tile_image_uri - (nautilus_get_widget_background (GTK_WIDGET (sidebar)), - uris[0]); + (nautilus_get_widget_background (GTK_WIDGET (sidebar)), + uris[0]); } else if (exactly_one) { gtk_signal_emit (GTK_OBJECT (sidebar), @@ -356,6 +356,10 @@ receive_dropped_uri_list (NautilusSidebar *sidebar, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL, uris[0]); + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_ICON_SCALE, + NULL, + NULL); nautilus_file_unref (file); } } @@ -387,8 +391,8 @@ receive_dropped_color (NautilusSidebar *sidebar, break; case TABS_PART: /* color dropped on main tabs */ - nautilus_index_tabs_receive_dropped_color - (sidebar->details->index_tabs, + nautilus_sidebar_tabs_receive_dropped_color + (sidebar->details->sidebar_tabs, x, y, selection_data); nautilus_directory_set_metadata @@ -400,7 +404,7 @@ receive_dropped_color (NautilusSidebar *sidebar, break; case TITLE_TAB_PART: /* color dropped on title tab */ - nautilus_index_tabs_receive_dropped_color + nautilus_sidebar_tabs_receive_dropped_color (sidebar->details->title_tab, x, y, selection_data); @@ -450,7 +454,7 @@ receive_dropped_keyword (NautilusSidebar *sidebar, nautilus_file_unref(file); /* regenerate the display */ - title = nautilus_index_title_get_text(sidebar->details->title); + title = nautilus_sidebar_title_get_text(sidebar->details->title); nautilus_sidebar_update_info (sidebar, title); g_free(title); } @@ -472,12 +476,10 @@ nautilus_sidebar_drag_data_received (GtkWidget *widget, GdkDragContext *context, case TARGET_URI_LIST: receive_dropped_uri_list (sidebar, x, y, selection_data); break; - case TARGET_COLOR: receive_dropped_color (sidebar, x, y, selection_data); break; case TARGET_BGIMAGE: - if (hit_test (sidebar, x, y) == BACKGROUND_PART) receive_dropped_uri_list (sidebar, x, y, selection_data); break; @@ -512,7 +514,7 @@ nautilus_sidebar_add_panel (NautilusSidebar *sidebar, NautilusViewFrame *panel) GTK_WIDGET (panel)); /* tell the index tabs about it */ - nautilus_index_tabs_add_view (sidebar->details->index_tabs, + nautilus_sidebar_tabs_add_view (sidebar->details->sidebar_tabs, description, GTK_WIDGET (panel), page_num); g_free (description); @@ -538,7 +540,7 @@ nautilus_sidebar_remove_panel (NautilusSidebar *sidebar, description = nautilus_view_frame_get_label (panel); /* Remove the tab associated with this panel */ - nautilus_index_tabs_remove_view (sidebar->details->index_tabs, description); + nautilus_sidebar_tabs_remove_view (sidebar->details->sidebar_tabs, description); g_free (description); } @@ -568,10 +570,10 @@ nautilus_sidebar_activate_panel (NautilusSidebar *sidebar, int which_view) } sidebar->details->selected_index = which_view; - title = nautilus_index_tabs_get_title_from_index (sidebar->details->index_tabs, + title = nautilus_sidebar_tabs_get_title_from_index (sidebar->details->sidebar_tabs, which_view); - nautilus_index_tabs_set_title (sidebar->details->title_tab, title); - nautilus_index_tabs_prelight_tab (sidebar->details->title_tab, -1); + nautilus_sidebar_tabs_set_title (sidebar->details->title_tab, title); + nautilus_sidebar_tabs_prelight_tab (sidebar->details->title_tab, -1); g_free (title); @@ -592,7 +594,7 @@ nautilus_sidebar_deactivate_panel(NautilusSidebar *sidebar) gtk_widget_show (GTK_WIDGET (sidebar->details->button_box)); sidebar->details->selected_index = -1; - nautilus_index_tabs_select_tab (sidebar->details->index_tabs, -1); + nautilus_sidebar_tabs_select_tab (sidebar->details->sidebar_tabs, -1); } /* handle mouse motion events by passing it to the tabs if necessary for pre-lighting */ @@ -603,17 +605,17 @@ nautilus_sidebar_motion_event (GtkWidget *widget, GdkEventMotion *event) int which_tab; int title_top, title_bottom; NautilusSidebar *sidebar; - NautilusIndexTabs *index_tabs, *title_tab; + NautilusSidebarTabs *sidebar_tabs, *title_tab; sidebar = NAUTILUS_SIDEBAR (widget); gtk_widget_get_pointer(widget, &x, &y); /* if the click is in the main tabs, tell them about it */ - index_tabs = sidebar->details->index_tabs; - if (y >= GTK_WIDGET (index_tabs)->allocation.y) { - which_tab = nautilus_index_tabs_hit_test (index_tabs, x, y); - nautilus_index_tabs_prelight_tab (index_tabs, which_tab); + sidebar_tabs = sidebar->details->sidebar_tabs; + if (y >= GTK_WIDGET (sidebar_tabs)->allocation.y) { + which_tab = nautilus_sidebar_tabs_hit_test (sidebar_tabs, x, y); + nautilus_sidebar_tabs_prelight_tab (sidebar_tabs, which_tab); } /* also handle prelighting in the title tab if necessary */ @@ -622,11 +624,11 @@ nautilus_sidebar_motion_event (GtkWidget *widget, GdkEventMotion *event) title_top = GTK_WIDGET (title_tab)->allocation.y; title_bottom = title_top + GTK_WIDGET (title_tab)->allocation.height; if (y >= title_top && y < title_bottom) { - which_tab = nautilus_index_tabs_hit_test (title_tab, x, y); + which_tab = nautilus_sidebar_tabs_hit_test (title_tab, x, y); } else { which_tab = -1; } - nautilus_index_tabs_prelight_tab (title_tab, which_tab); + nautilus_sidebar_tabs_prelight_tab (title_tab, which_tab); } return TRUE; @@ -638,11 +640,11 @@ static gboolean nautilus_sidebar_leave_event (GtkWidget *widget, GdkEventCrossing *event) { NautilusSidebar *sidebar; - NautilusIndexTabs *index_tabs; + NautilusSidebarTabs *sidebar_tabs; sidebar = NAUTILUS_SIDEBAR (widget); - index_tabs = sidebar->details->index_tabs; - nautilus_index_tabs_prelight_tab (index_tabs, -1); + sidebar_tabs = sidebar->details->sidebar_tabs; + nautilus_sidebar_tabs_prelight_tab (sidebar_tabs, -1); return TRUE; } @@ -654,21 +656,21 @@ nautilus_sidebar_press_event (GtkWidget *widget, GdkEventButton *event) { int title_top, title_bottom; NautilusSidebar *sidebar; - NautilusIndexTabs *index_tabs; - NautilusIndexTabs *title_tab; + NautilusSidebarTabs *sidebar_tabs; + NautilusSidebarTabs *title_tab; int rounded_y; int which_tab; sidebar = NAUTILUS_SIDEBAR (widget); - index_tabs = sidebar->details->index_tabs; + sidebar_tabs = sidebar->details->sidebar_tabs; title_tab = sidebar->details->title_tab; rounded_y = floor (event->y + .5); /* if the click is in the main tabs, tell them about it */ - if (rounded_y >= GTK_WIDGET (sidebar->details->index_tabs)->allocation.y) { - which_tab = nautilus_index_tabs_hit_test (index_tabs, event->x, event->y); + if (rounded_y >= GTK_WIDGET (sidebar->details->sidebar_tabs)->allocation.y) { + which_tab = nautilus_sidebar_tabs_hit_test (sidebar_tabs, event->x, event->y); if (which_tab >= 0) { - nautilus_index_tabs_select_tab (index_tabs, which_tab); + nautilus_sidebar_tabs_select_tab (sidebar_tabs, which_tab); nautilus_sidebar_activate_panel (sidebar, which_tab); gtk_widget_queue_draw (widget); } @@ -679,7 +681,7 @@ nautilus_sidebar_press_event (GtkWidget *widget, GdkEventButton *event) title_top = GTK_WIDGET (sidebar->details->title_tab)->allocation.y; title_bottom = title_top + GTK_WIDGET (sidebar->details->title_tab)->allocation.height; if (rounded_y >= title_top && rounded_y <= title_bottom) { - which_tab = nautilus_index_tabs_hit_test (title_tab, event->x, event->y); + which_tab = nautilus_sidebar_tabs_hit_test (title_tab, event->x, event->y); if (which_tab >= 0) { /* the user clicked in the title tab, so deactivate the panel */ nautilus_sidebar_deactivate_panel (sidebar); @@ -883,18 +885,18 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar, color_spec = nautilus_directory_get_metadata (directory, NAUTILUS_METADATA_KEY_SIDEBAR_TAB_COLOR, DEFAULT_TAB_COLOR); - nautilus_index_tabs_set_color(sidebar->details->index_tabs, color_spec); + nautilus_sidebar_tabs_set_color(sidebar->details->sidebar_tabs, color_spec); g_free (color_spec); color_spec = nautilus_directory_get_metadata (directory, NAUTILUS_METADATA_KEY_SIDEBAR_TITLE_TAB_COLOR, DEFAULT_TAB_COLOR); - nautilus_index_tabs_set_color(sidebar->details->title_tab, color_spec); + nautilus_sidebar_tabs_set_color(sidebar->details->title_tab, color_spec); g_free (color_spec); /* tell the title widget about it */ - nautilus_index_title_set_uri (sidebar->details->title, + nautilus_sidebar_title_set_uri (sidebar->details->title, sidebar->details->uri, initial_title); @@ -924,8 +926,8 @@ nautilus_sidebar_set_uri (NautilusSidebar *sidebar, void nautilus_sidebar_set_title (NautilusSidebar *sidebar, const char* new_title) { - nautilus_index_title_set_text (sidebar->details->title, - new_title); + nautilus_sidebar_title_set_text (sidebar->details->title, + new_title); } /* we override size allocate so we can remember our size when it changes, since the paned widget |