(gtk) use replace strcmp() with g_strcmp0() everywhere
This commit is contained in:
parent
313fe8ae94
commit
d1571bda02
|
@ -611,7 +611,7 @@ gtr_text_buffer_set_text (GtkTextBuffer * b, const char * str)
|
|||
gtk_text_buffer_get_bounds (b, &start, &end);
|
||||
old_str = gtk_text_buffer_get_text (b, &start, &end, FALSE);
|
||||
|
||||
if ((old_str == NULL) || strcmp (old_str, str))
|
||||
if ((old_str == NULL) || g_strcmp0 (old_str, str))
|
||||
gtk_text_buffer_set_text (b, str, -1);
|
||||
|
||||
g_free (old_str);
|
||||
|
@ -688,7 +688,7 @@ refreshInfo (struct DetailsImpl * di, tr_torrent ** torrents, int n)
|
|||
|
||||
for (i=1; i<n; ++i)
|
||||
{
|
||||
mixed_creator |= strcmp (creator, infos[i]->creator ? infos[i]->creator : "");
|
||||
mixed_creator |= g_strcmp0 (creator, infos[i]->creator ? infos[i]->creator : "");
|
||||
mixed_date |= (date != infos[i]->dateCreated);
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ refreshInfo (struct DetailsImpl * di, tr_torrent ** torrents, int n)
|
|||
const char * baseline = infos[0]->comment ? infos[0]->comment : "";
|
||||
|
||||
for (i=1; i<n; ++i)
|
||||
if (strcmp (baseline, infos[i]->comment ? infos[i]->comment : ""))
|
||||
if (g_strcmp0 (baseline, infos[i]->comment ? infos[i]->comment : ""))
|
||||
break;
|
||||
|
||||
if (i==n)
|
||||
|
@ -742,7 +742,7 @@ refreshInfo (struct DetailsImpl * di, tr_torrent ** torrents, int n)
|
|||
const char * baseline = tr_torrentGetDownloadDir (torrents[0]);
|
||||
|
||||
for (i=1; i<n; ++i)
|
||||
if (strcmp (baseline, tr_torrentGetDownloadDir (torrents[i])))
|
||||
if (g_strcmp0 (baseline, tr_torrentGetDownloadDir (torrents[i])))
|
||||
break;
|
||||
|
||||
if (i==n)
|
||||
|
@ -981,7 +981,7 @@ refreshInfo (struct DetailsImpl * di, tr_torrent ** torrents, int n)
|
|||
const char * baseline = stats[0]->errorString;
|
||||
|
||||
for (i=1; i<n; ++i)
|
||||
if (strcmp (baseline, stats[i]->errorString))
|
||||
if (g_strcmp0 (baseline, stats[i]->errorString))
|
||||
break;
|
||||
|
||||
if (i==n)
|
||||
|
@ -1281,7 +1281,7 @@ initPeerRow (GtkListStore * store,
|
|||
char collated_name[128];
|
||||
const char * client = peer->client;
|
||||
|
||||
if (!client || !strcmp (client, "Unknown Client"))
|
||||
if (!client || !g_strcmp0 (client, "Unknown Client"))
|
||||
client = "";
|
||||
|
||||
if (sscanf (peer->addr, "%d.%d.%d.%d", q, q+1, q+2, q+3) != 4)
|
||||
|
|
|
@ -484,7 +484,7 @@ find_child (GNode* parent, const char * name)
|
|||
GNode * child = parent->children;
|
||||
while (child) {
|
||||
const struct row_struct * child_data = child->data;
|
||||
if ((*child_data->name == *name) && !strcmp (child_data->name, name))
|
||||
if ((*child_data->name == *name) && !g_strcmp0 (child_data->name, name))
|
||||
break;
|
||||
child = child->next;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ enum
|
|||
static int
|
||||
pstrcmp (const void * a, const void * b)
|
||||
{
|
||||
return strcmp (* (const char**)a, * (const char**)b);
|
||||
return g_strcmp0 (* (const char**)a, * (const char**)b);
|
||||
}
|
||||
|
||||
/* human-readable name; ie, Legaltorrents */
|
||||
|
@ -163,7 +163,7 @@ tracker_filter_model_update (gpointer gstore)
|
|||
}
|
||||
|
||||
for (k=0; k<keyCount; ++k)
|
||||
if (!strcmp (keys[k], key))
|
||||
if (!g_strcmp0 (keys[k], key))
|
||||
break;
|
||||
|
||||
if (k==keyCount)
|
||||
|
@ -214,7 +214,7 @@ tracker_filter_model_update (gpointer gstore)
|
|||
int cmp;
|
||||
char * host;
|
||||
gtk_tree_model_get (model, &iter, TRACKER_FILTER_COL_HOST, &host, -1);
|
||||
cmp = strcmp (host, hosts->pdata[i]);
|
||||
cmp = g_strcmp0 (host, hosts->pdata[i]);
|
||||
|
||||
if (cmp < 0)
|
||||
remove_row = TRUE;
|
||||
|
@ -447,7 +447,7 @@ test_tracker (tr_torrent * tor, int active_tracker_type, const char * host)
|
|||
for (i=0; i<inf->trackerCount; ++i)
|
||||
{
|
||||
gtr_get_host_from_url (tmp, sizeof (tmp), inf->trackers[i].announce);
|
||||
if (!strcmp (tmp, host))
|
||||
if (!g_strcmp0 (tmp, host))
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h> /* strcmp */
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gio/gio.h>
|
||||
|
|
68
gtk/main.c
68
gtk/main.c
|
@ -160,7 +160,7 @@ show_details_dialog_for_selected_torrents (struct cbdata * data)
|
|||
char * key = get_details_dialog_key (ids);
|
||||
|
||||
for (l=data->details; dialog==NULL && l!=NULL; l=l->next)
|
||||
if (!strcmp (key, g_object_get_data (l->data, "key")))
|
||||
if (!g_strcmp0 (key, g_object_get_data (l->data, "key")))
|
||||
dialog = l->data;
|
||||
|
||||
if (dialog == NULL)
|
||||
|
@ -393,7 +393,7 @@ on_rpc_changed_idle (gpointer gdata)
|
|||
{
|
||||
char * a = tr_variantToStr (oldval, TR_VARIANT_FMT_BENC, NULL);
|
||||
char * b = tr_variantToStr (newval, TR_VARIANT_FMT_BENC, NULL);
|
||||
changed = strcmp (a, b) != 0;
|
||||
changed = g_strcmp0 (a, b) != 0;
|
||||
tr_free (b);
|
||||
tr_free (a);
|
||||
}
|
||||
|
@ -1492,35 +1492,35 @@ gtr_actions_handler (const char * action_name, gpointer user_data)
|
|||
gboolean changed = FALSE;
|
||||
struct cbdata * data = user_data;
|
||||
|
||||
if (!strcmp (action_name, "open-torrent-from-url"))
|
||||
if (!g_strcmp0 (action_name, "open-torrent-from-url"))
|
||||
{
|
||||
GtkWidget * w = gtr_torrent_open_from_url_dialog_new (data->wind, data->core);
|
||||
gtk_widget_show (w);
|
||||
}
|
||||
else if (!strcmp (action_name, "open-torrent-menu")
|
||||
|| !strcmp (action_name, "open-torrent-toolbar"))
|
||||
else if (!g_strcmp0 (action_name, "open-torrent-menu")
|
||||
|| !g_strcmp0 (action_name, "open-torrent-toolbar"))
|
||||
{
|
||||
GtkWidget * w = gtr_torrent_open_from_file_dialog_new (data->wind, data->core);
|
||||
gtk_widget_show (w);
|
||||
}
|
||||
else if (!strcmp (action_name, "show-stats"))
|
||||
else if (!g_strcmp0 (action_name, "show-stats"))
|
||||
{
|
||||
GtkWidget * dialog = gtr_stats_dialog_new (data->wind, data->core);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
else if (!strcmp (action_name, "donate"))
|
||||
else if (!g_strcmp0 (action_name, "donate"))
|
||||
{
|
||||
gtr_open_uri ("http://www.transmissionbt.com/donate.php");
|
||||
}
|
||||
else if (!strcmp (action_name, "pause-all-torrents"))
|
||||
else if (!g_strcmp0 (action_name, "pause-all-torrents"))
|
||||
{
|
||||
pause_all_torrents (data);
|
||||
}
|
||||
else if (!strcmp (action_name, "start-all-torrents"))
|
||||
else if (!g_strcmp0 (action_name, "start-all-torrents"))
|
||||
{
|
||||
start_all_torrents (data);
|
||||
}
|
||||
else if (!strcmp (action_name, "copy-magnet-link-to-clipboard"))
|
||||
else if (!g_strcmp0 (action_name, "copy-magnet-link-to-clipboard"))
|
||||
{
|
||||
tr_torrent * tor = get_first_selected_torrent (data);
|
||||
if (tor != NULL)
|
||||
|
@ -1528,7 +1528,7 @@ gtr_actions_handler (const char * action_name, gpointer user_data)
|
|||
copy_magnet_link_to_clipboard (GTK_WIDGET (data->wind), tor);
|
||||
}
|
||||
}
|
||||
else if (!strcmp (action_name, "relocate-torrent"))
|
||||
else if (!g_strcmp0 (action_name, "relocate-torrent"))
|
||||
{
|
||||
GSList * ids = get_selected_torrent_ids (data);
|
||||
if (ids != NULL)
|
||||
|
@ -1538,52 +1538,52 @@ gtr_actions_handler (const char * action_name, gpointer user_data)
|
|||
gtk_widget_show (w);
|
||||
}
|
||||
}
|
||||
else if (!strcmp (action_name, "torrent-start")
|
||||
|| !strcmp (action_name, "torrent-start-now")
|
||||
|| !strcmp (action_name, "torrent-stop")
|
||||
|| !strcmp (action_name, "torrent-reannounce")
|
||||
|| !strcmp (action_name, "torrent-verify")
|
||||
|| !strcmp (action_name, "queue-move-top")
|
||||
|| !strcmp (action_name, "queue-move-up")
|
||||
|| !strcmp (action_name, "queue-move-down")
|
||||
|| !strcmp (action_name, "queue-move-bottom"))
|
||||
else if (!g_strcmp0 (action_name, "torrent-start")
|
||||
|| !g_strcmp0 (action_name, "torrent-start-now")
|
||||
|| !g_strcmp0 (action_name, "torrent-stop")
|
||||
|| !g_strcmp0 (action_name, "torrent-reannounce")
|
||||
|| !g_strcmp0 (action_name, "torrent-verify")
|
||||
|| !g_strcmp0 (action_name, "queue-move-top")
|
||||
|| !g_strcmp0 (action_name, "queue-move-up")
|
||||
|| !g_strcmp0 (action_name, "queue-move-down")
|
||||
|| !g_strcmp0 (action_name, "queue-move-bottom"))
|
||||
{
|
||||
changed |= call_rpc_for_selected_torrents (data, action_name);
|
||||
}
|
||||
else if (!strcmp (action_name, "open-torrent-folder"))
|
||||
else if (!g_strcmp0 (action_name, "open-torrent-folder"))
|
||||
{
|
||||
gtk_tree_selection_selected_foreach (data->sel, open_folder_foreach, data->core);
|
||||
}
|
||||
else if (!strcmp (action_name, "show-torrent-properties"))
|
||||
else if (!g_strcmp0 (action_name, "show-torrent-properties"))
|
||||
{
|
||||
show_details_dialog_for_selected_torrents (data);
|
||||
}
|
||||
else if (!strcmp (action_name, "new-torrent"))
|
||||
else if (!g_strcmp0 (action_name, "new-torrent"))
|
||||
{
|
||||
GtkWidget * w = gtr_torrent_creation_dialog_new (data->wind, data->core);
|
||||
gtk_widget_show (w);
|
||||
}
|
||||
else if (!strcmp (action_name, "remove-torrent"))
|
||||
else if (!g_strcmp0 (action_name, "remove-torrent"))
|
||||
{
|
||||
remove_selected (data, FALSE);
|
||||
}
|
||||
else if (!strcmp (action_name, "delete-torrent"))
|
||||
else if (!g_strcmp0 (action_name, "delete-torrent"))
|
||||
{
|
||||
remove_selected (data, TRUE);
|
||||
}
|
||||
else if (!strcmp (action_name, "quit"))
|
||||
else if (!g_strcmp0 (action_name, "quit"))
|
||||
{
|
||||
on_app_exit (data);
|
||||
}
|
||||
else if (!strcmp (action_name, "select-all"))
|
||||
else if (!g_strcmp0 (action_name, "select-all"))
|
||||
{
|
||||
gtk_tree_selection_select_all (data->sel);
|
||||
}
|
||||
else if (!strcmp (action_name, "deselect-all"))
|
||||
else if (!g_strcmp0 (action_name, "deselect-all"))
|
||||
{
|
||||
gtk_tree_selection_unselect_all (data->sel);
|
||||
}
|
||||
else if (!strcmp (action_name, "edit-preferences"))
|
||||
else if (!g_strcmp0 (action_name, "edit-preferences"))
|
||||
{
|
||||
if (NULL == data->prefs)
|
||||
{
|
||||
|
@ -1593,7 +1593,7 @@ gtr_actions_handler (const char * action_name, gpointer user_data)
|
|||
}
|
||||
gtr_window_present (GTK_WINDOW (data->prefs));
|
||||
}
|
||||
else if (!strcmp (action_name, "toggle-message-log"))
|
||||
else if (!g_strcmp0 (action_name, "toggle-message-log"))
|
||||
{
|
||||
if (!data->msgwin)
|
||||
{
|
||||
|
@ -1608,19 +1608,19 @@ gtr_actions_handler (const char * action_name, gpointer user_data)
|
|||
data->msgwin = NULL;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (action_name, "show-about-dialog"))
|
||||
else if (!g_strcmp0 (action_name, "show-about-dialog"))
|
||||
{
|
||||
show_about_dialog (data->wind);
|
||||
}
|
||||
else if (!strcmp (action_name, "help"))
|
||||
else if (!g_strcmp0 (action_name, "help"))
|
||||
{
|
||||
gtr_open_uri (gtr_get_help_uri ());
|
||||
}
|
||||
else if (!strcmp (action_name, "toggle-main-window"))
|
||||
else if (!g_strcmp0 (action_name, "toggle-main-window"))
|
||||
{
|
||||
toggleMainWindow (data);
|
||||
}
|
||||
else if (!strcmp (action_name, "present-main-window"))
|
||||
else if (!g_strcmp0 (action_name, "present-main-window"))
|
||||
{
|
||||
presentMainWindow (data);
|
||||
}
|
||||
|
|
12
gtk/notify.c
12
gtk/notify.c
|
@ -10,8 +10,6 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#include <string.h> /* strcmp () */
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
@ -67,7 +65,7 @@ get_capabilities_callback (GObject * source,
|
|||
g_variant_get (result, "(^a&s)", &caps);
|
||||
for (i=0; caps[i]; i++)
|
||||
{
|
||||
if (strcmp (caps[i], "actions") == 0)
|
||||
if (g_strcmp0 (caps[i], "actions") == 0)
|
||||
{
|
||||
server_supports_actions = TRUE;
|
||||
break;
|
||||
|
@ -96,12 +94,12 @@ g_signal_callback (GDBusProxy * proxy UNUSED,
|
|||
if (n == NULL)
|
||||
return;
|
||||
|
||||
if (strcmp (signal_name, "NotificationClosed") == 0)
|
||||
if (g_strcmp0 (signal_name, "NotificationClosed") == 0)
|
||||
{
|
||||
g_hash_table_remove (active_notifications,
|
||||
GINT_TO_POINTER ((int *) &n->id));
|
||||
}
|
||||
else if (strcmp (signal_name, "ActionInvoked") == 0 &&
|
||||
else if (g_strcmp0 (signal_name, "ActionInvoked") == 0 &&
|
||||
g_variant_is_of_type (params, G_VARIANT_TYPE ("(us)")))
|
||||
{
|
||||
char * action;
|
||||
|
@ -112,11 +110,11 @@ g_signal_callback (GDBusProxy * proxy UNUSED,
|
|||
return;
|
||||
|
||||
g_variant_get (params, "(u&s)", NULL, &action);
|
||||
if (strcmp (action, "folder") == 0)
|
||||
if (g_strcmp0 (action, "folder") == 0)
|
||||
{
|
||||
gtr_core_open_folder (n->core, n->torrent_id);
|
||||
}
|
||||
else if (strcmp (action, "file") == 0)
|
||||
else if (g_strcmp0 (action, "file") == 0)
|
||||
{
|
||||
const tr_info * inf = tr_torrentInfo (tor);
|
||||
const char * dir = tr_torrentGetDownloadDir (tor);
|
||||
|
|
|
@ -59,7 +59,7 @@ save_recent_destination (TrCore * core, const char * dir)
|
|||
return;
|
||||
|
||||
/* if it was already in the list, remove it */
|
||||
if ((l = g_slist_find_custom (list, dir, (GCompareFunc)strcmp)))
|
||||
if ((l = g_slist_find_custom (list, dir, (GCompareFunc)g_strcmp0)))
|
||||
list = g_slist_delete_link (list, l);
|
||||
|
||||
/* add it to the front of the list */
|
||||
|
|
|
@ -423,7 +423,7 @@ compare_by_name (GtkTreeModel * m,
|
|||
const char *ca, *cb;
|
||||
gtk_tree_model_get (m, a, MC_NAME_COLLATED, &ca, -1);
|
||||
gtk_tree_model_get (m, b, MC_NAME_COLLATED, &cb, -1);
|
||||
return tr_strcmp0 (ca, cb);
|
||||
return g_strcmp0 (ca, cb);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1666,7 +1666,7 @@ core_commit_prefs_change (TrCore * core, const tr_quark key)
|
|||
void
|
||||
gtr_core_set_pref (TrCore * self, const tr_quark key, const char * newval)
|
||||
{
|
||||
if (tr_strcmp0 (newval, gtr_pref_string_get (key)))
|
||||
if (g_strcmp0 (newval, gtr_pref_string_get (key)))
|
||||
{
|
||||
gtr_pref_string_set (key, newval);
|
||||
core_commit_prefs_change (self, key);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <ctype.h> /* isspace */
|
||||
#include <limits.h> /* USHRT_MAX */
|
||||
#include <string.h> /* strcmp () */
|
||||
#include <unistd.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <string.h> /* strlen() */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
@ -673,7 +673,7 @@ gtr_window_new (GtkApplication * app, GtkUIManager * ui_mgr, TrCore * core)
|
|||
const char * val = stats_modes[i].val;
|
||||
w = gtk_radio_menu_item_new_with_label (l, _ (stats_modes[i].i18n));
|
||||
l = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (w));
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), !strcmp (val, pch));
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), !g_strcmp0 (val, pch));
|
||||
g_object_set_data (G_OBJECT (w), STATS_MODE, (gpointer)stats_modes[i].val);
|
||||
g_signal_connect (w, "toggled", G_CALLBACK (status_menu_toggled_cb), p);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
|
||||
|
@ -806,13 +806,13 @@ updateStats (PrivateData * p)
|
|||
|
||||
/* update the stats */
|
||||
pch = gtr_pref_string_get (TR_KEY_statusbar_stats);
|
||||
if (!strcmp (pch, "session-ratio"))
|
||||
if (!g_strcmp0 (pch, "session-ratio"))
|
||||
{
|
||||
tr_sessionGetStats (session, &stats);
|
||||
tr_strlratio (ratio, stats.ratio, sizeof (ratio));
|
||||
g_snprintf (buf, sizeof (buf), _("Ratio: %s"), ratio);
|
||||
}
|
||||
else if (!strcmp (pch, "session-transfer"))
|
||||
else if (!g_strcmp0 (pch, "session-transfer"))
|
||||
{
|
||||
tr_sessionGetStats (session, &stats);
|
||||
tr_strlsize (up, stats.uploadedBytes, sizeof (up));
|
||||
|
@ -823,7 +823,7 @@ updateStats (PrivateData * p)
|
|||
g_snprintf (buf, sizeof (buf),
|
||||
Q_("Down: %1$s, Up: %2$s"), down, up);
|
||||
}
|
||||
else if (!strcmp (pch, "total-transfer"))
|
||||
else if (!g_strcmp0 (pch, "total-transfer"))
|
||||
{
|
||||
tr_sessionGetCumulativeStats (session, &stats);
|
||||
tr_strlsize (up, stats.uploadedBytes, sizeof (up));
|
||||
|
|
|
@ -629,7 +629,7 @@ gtr_label_set_text (GtkLabel * lb, const char * newstr)
|
|||
{
|
||||
const char * oldstr = gtk_label_get_text (lb);
|
||||
|
||||
if (tr_strcmp0 (oldstr, newstr))
|
||||
if (g_strcmp0 (oldstr, newstr))
|
||||
gtk_label_set_text (lb, newstr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue