diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2011-12-03 11:21:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2011-12-03 11:21:57 +0100 |
| commit | 56f0f398a96146cae851c1847f656a4ff66964dc (patch) | |
| tree | 0d9136b400201c7701e0999b5d0d4dad365e48b6 | |
| parent | 98df387ba96f83f364b1ba1be5f9a3ae9f79e931 (diff) | |
Tooltips uses markup even if column uses text. So change column to markup and escape any '&'
| -rw-r--r-- | gui/viewtorrents.glade | 38 | ||||
| -rw-r--r-- | src/main.c | 57 |
2 files changed, 76 insertions, 19 deletions
diff --git a/gui/viewtorrents.glade b/gui/viewtorrents.glade index 7aee1f2..5f95115 100644 --- a/gui/viewtorrents.glade +++ b/gui/viewtorrents.glade @@ -5,18 +5,20 @@ <object class="GtkAccelGroup" id="accelgroup1"/> <object class="GtkActionGroup" id="actiongroup"> <child> - <object class="GtkAction" id="connectaction"> - <property name="label" translatable="yes">Connect</property> - <property name="tooltip" translatable="yes">Connect to rTorrent</property> - <property name="stock_id">gtk-connect</property> + <object class="GtkAction" id="rehashaction"> + <property name="label" translatable="yes">Rehash</property> + <property name="tooltip" translatable="yes">Rehash selected torrent</property> + <property name="stock_id">gtk-refresh</property> </object> + <accelerator key="r" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="disconnectaction"> - <property name="label" translatable="yes">Disconnect</property> - <property name="tooltip" translatable="yes">Disconnect from rTorrent</property> - <property name="stock_id">gtk-disconnect</property> + <object class="GtkAction" id="stopaction"> + <property name="label" translatable="yes">Stop</property> + <property name="tooltip" translatable="yes">Stop selected torrent</property> + <property name="stock_id">gtk-media-stop</property> </object> + <accelerator key="d" modifiers="GDK_CONTROL_MASK"/> </child> <child> <object class="GtkAction" id="startaction"> @@ -27,20 +29,18 @@ <accelerator key="s" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="stopaction"> - <property name="label" translatable="yes">Stop</property> - <property name="tooltip" translatable="yes">Stop selected torrent</property> - <property name="stock_id">gtk-media-stop</property> + <object class="GtkAction" id="disconnectaction"> + <property name="label" translatable="yes">Disconnect</property> + <property name="tooltip" translatable="yes">Disconnect from rTorrent</property> + <property name="stock_id">gtk-disconnect</property> </object> - <accelerator key="d" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="rehashaction"> - <property name="label" translatable="yes">Rehash</property> - <property name="tooltip" translatable="yes">Rehash selected torrent</property> - <property name="stock_id">gtk-refresh</property> + <object class="GtkAction" id="connectaction"> + <property name="label" translatable="yes">Connect</property> + <property name="tooltip" translatable="yes">Connect to rTorrent</property> + <property name="stock_id">gtk-connect</property> </object> - <accelerator key="r" modifiers="GDK_CONTROL_MASK"/> </child> </object> <object class="GtkAboutDialog" id="aboutdialog"> @@ -568,7 +568,7 @@ If authentication is needed, enter username and password as well.</property> <child> <object class="GtkCellRendererText" id="cellrenderertitle"/> <attributes> - <attribute name="text">1</attribute> + <attribute name="markup">1</attribute> </attributes> </child> </object> @@ -1977,6 +1977,8 @@ gint liststore_default_compare_func(GtkTreeModel* model, } } +static gchar* safe_str(gchar* str); + gboolean hashlist_item_sync(worker_data_t* data, xmlrpc_env * const env, const xmlrpc_value * const line, torrent_data_t* torrent_data) @@ -2046,6 +2048,7 @@ gboolean hashlist_item_sync(worker_data_t* data, xmlrpc_env * const env, } g_free(torrent_data->title); torrent_data->title = (gchar*)tmpstr; + torrent_data->title = safe_str(torrent_data->title); /* d.size_bytes */ xmlrpc_array_read_item(env, line, 5, &item); @@ -2357,3 +2360,57 @@ gboolean do_buttonpressed(GtkWidget *treeview, GdkEventButton *event, return FALSE; } + +gchar* safe_str(gchar* str) +{ + gchar* pos; + gchar* ret = NULL; + gsize size = 0, alloc = 0; + pos = strchr(str, '&'); + if (pos == NULL) + { + return str; + } + size = strlen(str); + alloc = size + 10; + ret = g_malloc(alloc); + if (ret == NULL) + { + return str; + } + memcpy(ret, str, size + 1); + pos = ret + (pos - str); + g_free(str); + for (;;) + { + gchar* last; + if (size + 5 >= alloc) + { + size_t p = pos - ret; + size_t na = alloc * 2; + gchar* tmp; + if (na < size + 10) + { + na = size + 10; + } + tmp = g_realloc(ret, na); + if (tmp == NULL) + { + break; + } + ret = tmp; + alloc = na; + pos = ret + p; + } + last = pos + 5; + memmove(last, pos + 1, size - (pos - ret)); + memcpy(pos + 1, "amp;", 4); + size += 4; + pos = strchr(last, '&'); + if (pos == NULL) + { + break; + } + } + return ret; +} |
