diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2000-02-27 05:36:01 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2000-02-27 05:36:01 +0000 |
commit | 035cc3d2bca13dc95eca96e93bc7d858fa702ab6 (patch) | |
tree | 421a6825f8229aa179253d4e9f7abd6d01d26477 /src | |
parent | ed2fe36fed4a09bde1c1e63849ad09e421e33b72 (diff) | |
download | nautilus-035cc3d2bca13dc95eca96e93bc7d858fa702ab6.tar.gz |
made index tabs receive and display dropped colors
made index tabs receive and display dropped colors
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-index-tabs.c | 25 | ||||
-rw-r--r-- | src/nautilus-index-tabs.h | 3 | ||||
-rw-r--r-- | src/nautilus-information-panel.c | 26 | ||||
-rw-r--r-- | src/nautilus-sidebar-tabs.c | 25 | ||||
-rw-r--r-- | src/nautilus-sidebar-tabs.h | 3 | ||||
-rw-r--r-- | src/nautilus-sidebar.c | 26 | ||||
-rw-r--r-- | src/ntl-index-panel.c | 26 |
7 files changed, 123 insertions, 11 deletions
diff --git a/src/nautilus-index-tabs.c b/src/nautilus-index-tabs.c index c472461ad..513cc8ede 100644 --- a/src/nautilus-index-tabs.c +++ b/src/nautilus-index-tabs.c @@ -500,6 +500,31 @@ nautilus_index_tabs_select_tab(NautilusIndexTabs *index_tabs, int which_tab) gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); } +/* receive a dropped color */ + +void +nautilus_index_tabs_receive_dropped_color(NautilusIndexTabs* index_tabs, gint x, gint y, GtkSelectionData *selection_data) +{ + guint16 *channels; + char *color_spec; + + /* Convert the selection data into a color spec. */ + if (selection_data->length != 8 || selection_data->format != 16) { + g_warning ("received invalid color data"); + return; + } + + channels = (guint16 *)selection_data->data; + color_spec = g_strdup_printf ("rgb:%04hX/%04hX/%04hX", channels[0], channels[1], channels[2]); + + 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); + + gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); + 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) diff --git a/src/nautilus-index-tabs.h b/src/nautilus-index-tabs.h index 11060b011..f26bf0a82 100644 --- a/src/nautilus-index-tabs.h +++ b/src/nautilus-index-tabs.h @@ -64,8 +64,9 @@ GtkType nautilus_index_tabs_get_type(void); GtkWidget* nautilus_index_tabs_new(void); gboolean nautilus_index_tabs_add_view(NautilusIndexTabs *index_tabs, const gchar *name, GtkWidget *new_view, gint page_num); -gchar* nautilus_index_tabs_get_title_from_index(NautilusIndexTabs *index_tabs, gint which_tab); +gchar* nautilus_index_tabs_get_title_from_index(NautilusIndexTabs *index_tabs, gint which_tab); gint nautilus_index_tabs_hit_test(NautilusIndexTabs *index_tabs, double x, double y); +void nautilus_index_tabs_receive_dropped_color(NautilusIndexTabs* index_tabs, gint x, gint y, GtkSelectionData *selection_data); void nautilus_index_tabs_remove_view(NautilusIndexTabs *index_tabs, const gchar *name); void nautilus_index_tabs_prelite_tab(NautilusIndexTabs *index_tabs, gint which_tab); void nautilus_index_tabs_select_tab(NautilusIndexTabs *index_tabs, gint which_tab); diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index 74db6fc6c..a90fdbf2e 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -219,6 +219,7 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont gint x, gint y, GtkSelectionData *selection_data, guint info, guint time) { + NautilusIndexPanel *index_panel; g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (widget)); switch (info) @@ -238,9 +239,28 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont case TARGET_COLOR: /* Let the background change based on the dropped color. */ - nautilus_background_receive_dropped_color - (nautilus_get_widget_background (widget), - widget, x, y, selection_data); + index_panel = NAUTILUS_INDEX_PANEL (widget); + + /* if the click is in the main tabs, tell them about it */ + if (y >= index_panel->details->index_tabs->allocation.y) { + nautilus_index_tabs_receive_dropped_color + (NAUTILUS_INDEX_TABS(index_panel->details->index_tabs), + x, y, selection_data); + + } + /* try the title tab */ + else + if ((y >= index_panel->details->title_tab->allocation.y) && + (y <= (index_panel->details->title_tab->allocation.y + index_panel->details->title_tab->allocation.height))) + nautilus_index_tabs_receive_dropped_color + (NAUTILUS_INDEX_TABS(index_panel->details->title_tab), + x, y, selection_data); + + /* otherwise, pass it along to the index panel background */ + else + nautilus_background_receive_dropped_color + (nautilus_get_widget_background (widget), + widget, x, y, selection_data); break; default: diff --git a/src/nautilus-sidebar-tabs.c b/src/nautilus-sidebar-tabs.c index c472461ad..513cc8ede 100644 --- a/src/nautilus-sidebar-tabs.c +++ b/src/nautilus-sidebar-tabs.c @@ -500,6 +500,31 @@ nautilus_index_tabs_select_tab(NautilusIndexTabs *index_tabs, int which_tab) gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); } +/* receive a dropped color */ + +void +nautilus_index_tabs_receive_dropped_color(NautilusIndexTabs* index_tabs, gint x, gint y, GtkSelectionData *selection_data) +{ + guint16 *channels; + char *color_spec; + + /* Convert the selection data into a color spec. */ + if (selection_data->length != 8 || selection_data->format != 16) { + g_warning ("received invalid color data"); + return; + } + + channels = (guint16 *)selection_data->data; + color_spec = g_strdup_printf ("rgb:%04hX/%04hX/%04hX", channels[0], channels[1], channels[2]); + + 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); + + gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); + 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) diff --git a/src/nautilus-sidebar-tabs.h b/src/nautilus-sidebar-tabs.h index 11060b011..f26bf0a82 100644 --- a/src/nautilus-sidebar-tabs.h +++ b/src/nautilus-sidebar-tabs.h @@ -64,8 +64,9 @@ GtkType nautilus_index_tabs_get_type(void); GtkWidget* nautilus_index_tabs_new(void); gboolean nautilus_index_tabs_add_view(NautilusIndexTabs *index_tabs, const gchar *name, GtkWidget *new_view, gint page_num); -gchar* nautilus_index_tabs_get_title_from_index(NautilusIndexTabs *index_tabs, gint which_tab); +gchar* nautilus_index_tabs_get_title_from_index(NautilusIndexTabs *index_tabs, gint which_tab); gint nautilus_index_tabs_hit_test(NautilusIndexTabs *index_tabs, double x, double y); +void nautilus_index_tabs_receive_dropped_color(NautilusIndexTabs* index_tabs, gint x, gint y, GtkSelectionData *selection_data); void nautilus_index_tabs_remove_view(NautilusIndexTabs *index_tabs, const gchar *name); void nautilus_index_tabs_prelite_tab(NautilusIndexTabs *index_tabs, gint which_tab); void nautilus_index_tabs_select_tab(NautilusIndexTabs *index_tabs, gint which_tab); diff --git a/src/nautilus-sidebar.c b/src/nautilus-sidebar.c index 74db6fc6c..a90fdbf2e 100644 --- a/src/nautilus-sidebar.c +++ b/src/nautilus-sidebar.c @@ -219,6 +219,7 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont gint x, gint y, GtkSelectionData *selection_data, guint info, guint time) { + NautilusIndexPanel *index_panel; g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (widget)); switch (info) @@ -238,9 +239,28 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont case TARGET_COLOR: /* Let the background change based on the dropped color. */ - nautilus_background_receive_dropped_color - (nautilus_get_widget_background (widget), - widget, x, y, selection_data); + index_panel = NAUTILUS_INDEX_PANEL (widget); + + /* if the click is in the main tabs, tell them about it */ + if (y >= index_panel->details->index_tabs->allocation.y) { + nautilus_index_tabs_receive_dropped_color + (NAUTILUS_INDEX_TABS(index_panel->details->index_tabs), + x, y, selection_data); + + } + /* try the title tab */ + else + if ((y >= index_panel->details->title_tab->allocation.y) && + (y <= (index_panel->details->title_tab->allocation.y + index_panel->details->title_tab->allocation.height))) + nautilus_index_tabs_receive_dropped_color + (NAUTILUS_INDEX_TABS(index_panel->details->title_tab), + x, y, selection_data); + + /* otherwise, pass it along to the index panel background */ + else + nautilus_background_receive_dropped_color + (nautilus_get_widget_background (widget), + widget, x, y, selection_data); break; default: diff --git a/src/ntl-index-panel.c b/src/ntl-index-panel.c index 74db6fc6c..a90fdbf2e 100644 --- a/src/ntl-index-panel.c +++ b/src/ntl-index-panel.c @@ -219,6 +219,7 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont gint x, gint y, GtkSelectionData *selection_data, guint info, guint time) { + NautilusIndexPanel *index_panel; g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (widget)); switch (info) @@ -238,9 +239,28 @@ nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *cont case TARGET_COLOR: /* Let the background change based on the dropped color. */ - nautilus_background_receive_dropped_color - (nautilus_get_widget_background (widget), - widget, x, y, selection_data); + index_panel = NAUTILUS_INDEX_PANEL (widget); + + /* if the click is in the main tabs, tell them about it */ + if (y >= index_panel->details->index_tabs->allocation.y) { + nautilus_index_tabs_receive_dropped_color + (NAUTILUS_INDEX_TABS(index_panel->details->index_tabs), + x, y, selection_data); + + } + /* try the title tab */ + else + if ((y >= index_panel->details->title_tab->allocation.y) && + (y <= (index_panel->details->title_tab->allocation.y + index_panel->details->title_tab->allocation.height))) + nautilus_index_tabs_receive_dropped_color + (NAUTILUS_INDEX_TABS(index_panel->details->title_tab), + x, y, selection_data); + + /* otherwise, pass it along to the index panel background */ + else + nautilus_background_receive_dropped_color + (nautilus_get_widget_background (widget), + widget, x, y, selection_data); break; default: |