From 3fa7b939baf4c84f69681ad6ca8e72588dda5689 Mon Sep 17 00:00:00 2001 From: Stephen Watson Date: Sun, 24 Oct 2004 12:13:12 +0000 Subject: [PATCH] r3711: PinboardRemove SOAP call --- ROX-Filer/Help/Changes | 4 ++++ ROX-Filer/src/Docs/Manual.xml | 11 +++++++++-- ROX-Filer/src/panel.c | 16 ++++++++++------ ROX-Filer/src/panel.h | 3 ++- ROX-Filer/src/pinboard.c | 32 ++++++++++++++++++++++++++++++++ ROX-Filer/src/pinboard.h | 1 + ROX-Filer/src/remote.c | 30 +++++++++++++++++++++++++++--- 7 files changed, 85 insertions(+), 12 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 0190762a..3bebab15 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,10 @@ A RISC OS-like filer for X by Thomas Leonard +24-Oct-2004 +~~~~~~~~~~~ +Added PinboardRemove() SOAP call (Stephen Watson). + 20-Oct-2004 (Release 2.1.4) ~~~~~~~~~~~ Added Portuguese translation (Rodrigo Cesar Herefeld). diff --git a/ROX-Filer/src/Docs/Manual.xml b/ROX-Filer/src/Docs/Manual.xml index ee0f709b..f2c597f8 100644 --- a/ROX-Filer/src/Docs/Manual.xml +++ b/ROX-Filer/src/Docs/Manual.xml @@ -3184,8 +3184,10 @@ means that only files ending in .c are shown. PanelRemove(Side, - Path) - Remove Path from the panel on side Side. If more than one item matches, only one is removed. + Path, [Label]) + Remove Path from the panel on side +Side. If Label is given +then this must match the label of the item. If more than one item matches, only one is removed. Pinboard([Name]) @@ -3202,6 +3204,11 @@ means that only files ending in .c are shown. Label. + PinboardRemove(Path, [Label]) + Remove Path from the pinboard. If Label is given +then this must match the label of the item. If more than one item matches, only one is removed. + + SetBackdropApp(App) Make App (an application directory) the new handler for the current pinboard's backdrop. diff --git a/ROX-Filer/src/panel.c b/ROX-Filer/src/panel.c index 6130cca7..c3695381 100644 --- a/ROX-Filer/src/panel.c +++ b/ROX-Filer/src/panel.c @@ -746,7 +746,8 @@ static void panel_add_item(Panel *panel, gtk_widget_show(widget); } -static gboolean remove_item_from_side(GtkWidget *container, const gchar *path) +static gboolean remove_item_from_side(GtkWidget *container, const gchar *path, + const gchar *label) { GList *kids, *next; gboolean found = FALSE; @@ -760,7 +761,8 @@ static gboolean remove_item_from_side(GtkWidget *container, const gchar *path) if (!icon) continue; - if (strcmp(path, icon->src_path) == 0) + if (strcmp(path, icon->src_path) == 0 && + (!label || strcmp(label, icon->item->leafname)==0)) { icon_destroy(icon); found = TRUE; @@ -774,9 +776,11 @@ static gboolean remove_item_from_side(GtkWidget *container, const gchar *path) } /* Remove an item with this path. If more than one item matches, only - * one is removed. Returns TRUE if an item was successfully removed. + * one is removed. If label is not NULL then it must also match the item. + * Returns TRUE if an item was successfully removed. */ -gboolean panel_remove_item(PanelSide side, const gchar *path) +gboolean panel_remove_item(PanelSide side, const gchar *path, + const gchar *label) { Panel *panel; @@ -790,8 +794,8 @@ gboolean panel_remove_item(PanelSide side, const gchar *path) return FALSE; } - if (remove_item_from_side(panel->before, path) || - remove_item_from_side(panel->after, path)) + if (remove_item_from_side(panel->before, path, label) || + remove_item_from_side(panel->after, path, label)) { panel_save(panel); panel_update(panel); diff --git a/ROX-Filer/src/panel.h b/ROX-Filer/src/panel.h index 74655c97..ecf3829d 100644 --- a/ROX-Filer/src/panel.h +++ b/ROX-Filer/src/panel.h @@ -41,7 +41,8 @@ void panel_save(Panel *panel); gboolean panel_add(PanelSide side, const gchar *path, const gchar *label, gboolean after); -gboolean panel_remove_item(PanelSide side, const gchar *path); +gboolean panel_remove_item(PanelSide side, const gchar *path, + const gchar *label); void panel_mark_used(GdkRegion *used); void panel_update_size(void); diff --git a/ROX-Filer/src/pinboard.c b/ROX-Filer/src/pinboard.c index 6ec26ea3..78f26d86 100644 --- a/ROX-Filer/src/pinboard.c +++ b/ROX-Filer/src/pinboard.c @@ -545,6 +545,38 @@ void pinboard_pin(const gchar *path, const gchar *name, int x, int y, pinboard_pin_with_args(path, name, x, y, shortcut, NULL); } +/* + * Remove an icon from the background. The first icon with a matching + * path is removed. If name is not NULL then that also must match + */ +gboolean pinboard_remove(const gchar *path, const gchar *name) +{ + GList *item; + PinIcon *pi; + Icon *icon; + + g_return_if_fail(current_pinboard != NULL); + + for(item=current_pinboard->icons; item; item=g_list_next(item)) { + pi=(PinIcon *) item->data; + icon=(Icon *) pi; + + if(strcmp(icon->path, path)!=0) + continue; + + if(name && strcmp(name, icon->item->leafname)!=0) + continue; + + icon_destroy(icon); + + pinboard_save(); + + return TRUE; + } + + return FALSE; +} + /* Put a border around the icon, briefly. * If icon is NULL then cancel any existing wink. * The icon will automatically unhighlight unless timeout is FALSE, diff --git a/ROX-Filer/src/pinboard.h b/ROX-Filer/src/pinboard.h index c0f419b6..b0a0637b 100644 --- a/ROX-Filer/src/pinboard.h +++ b/ROX-Filer/src/pinboard.h @@ -25,6 +25,7 @@ void pinboard_pin(const gchar *path, const gchar *name, int x, int y, const gchar *shortcut); void pinboard_pin_with_arg(const gchar *path, const gchar *name, int x, int y, const gchar *shortcut, const char *arg); +gboolean pinboard_remove(const gchar *path, const gchar *name); void pinboard_move_icons(void); const gchar *pinboard_get_name(void); void pinboard_set_backdrop_box(void); diff --git a/ROX-Filer/src/remote.c b/ROX-Filer/src/remote.c index eb34b3cf..5b20cb47 100644 --- a/ROX-Filer/src/remote.c +++ b/ROX-Filer/src/remote.c @@ -97,6 +97,7 @@ static xmlNodePtr rpc_Mount(GList *args); static xmlNodePtr rpc_PanelAdd(GList *args); static xmlNodePtr rpc_PanelRemove(GList *args); static xmlNodePtr rpc_PinboardAdd(GList *args); +static xmlNodePtr rpc_PinboardRemove(GList *args); static xmlNodePtr rpc_SetBackdrop(GList *args); static xmlNodePtr rpc_SetBackdropApp(GList *args); @@ -142,8 +143,9 @@ gboolean remote_init(xmlDocPtr rpc, gboolean new_copy) soap_register("SetBackdrop", rpc_SetBackdrop, "Filename,Style", NULL); soap_register("SetBackdropApp", rpc_SetBackdropApp, "App", NULL); soap_register("PinboardAdd", rpc_PinboardAdd, "Path,X,Y", "Label"); + soap_register("PinboardRemove", rpc_PinboardRemove, "Path", "Label"); soap_register("PanelAdd", rpc_PanelAdd, "Side,Path", "Label,After"); - soap_register("PanelRemove", rpc_PanelRemove, "Side,Path", NULL); + soap_register("PanelRemove", rpc_PanelRemove, "Side,Path", "Label"); /* Look for a property on the root window giving the IPC window * of an already-running copy of this version of the filer, running @@ -802,6 +804,26 @@ static xmlNodePtr rpc_PinboardAdd(GList *args) pinboard_pin(path, name, x, y, NULL); g_free(path); + if(name) + g_free(name); + + return NULL; +} + +/* args = Path, [Label] */ +static xmlNodePtr rpc_PinboardRemove(GList *args) +{ + char *path = NULL; + gchar *name; + + path = string_value(ARG(0)); + name = string_value(ARG(1)); + + pinboard_remove(path, name); + + g_free(path); + if(name) + g_free(name); return NULL; } @@ -871,7 +893,7 @@ static xmlNodePtr rpc_PanelAdd(GList *args) static xmlNodePtr rpc_PanelRemove(GList *args) { PanelSide side; - char *path, *side_name; + char *path, *side_name, *label; side_name = string_value(ARG(0)); side = panel_name_to_side(side_name); @@ -879,10 +901,12 @@ static xmlNodePtr rpc_PanelRemove(GList *args) g_return_val_if_fail(side != PANEL_NUMBER_OF_SIDES, NULL); path = string_value(ARG(1)); + label = string_value(ARG(2)); - panel_remove_item(side, path); + panel_remove_item(side, path, label); g_free(path); + g_free(label); return NULL; } -- 2.11.4.GIT