diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-10-16 17:53:16 +0000 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2006-10-16 17:53:16 +0000 | 
| commit | e46568349c49cadc870f5c0fc84dcce2f7c461b1 (patch) | |
| tree | 139332ea64b814967711035cf388438a2c9fa302 /hardinfo2 | |
| parent | 3722c94e232b39d2a05ef359a60d25ac0cbe7887 (diff) | |
Use g_str_equal instead of strcmp.
About box cleanups
Use g_build_filename instead of building paths on my own
Better BinReloc support (should work even if binreloc initialization fails)
Diffstat (limited to 'hardinfo2')
| -rw-r--r-- | hardinfo2/arch/common/blowfish.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/common/md5.h | 3 | ||||
| -rw-r--r-- | hardinfo2/arch/common/printers.h | 3 | ||||
| -rw-r--r-- | hardinfo2/arch/common/sha1.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/common/zlib.h | 4 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/modules.h | 2 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/storage.h | 2 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/x86/processor.h | 2 | ||||
| -rw-r--r-- | hardinfo2/benchmark.c | 3 | ||||
| -rw-r--r-- | hardinfo2/callbacks.c | 10 | ||||
| -rw-r--r-- | hardinfo2/computer.c | 8 | ||||
| -rw-r--r-- | hardinfo2/hardinfo.c | 18 | ||||
| -rw-r--r-- | hardinfo2/iconcache.c | 7 | ||||
| -rw-r--r-- | hardinfo2/menu.c | 2 | ||||
| -rw-r--r-- | hardinfo2/shell.c | 11 | ||||
| -rw-r--r-- | hardinfo2/socket.c | 4 | ||||
| -rw-r--r-- | hardinfo2/util.c | 3 | 
17 files changed, 48 insertions, 42 deletions
| diff --git a/hardinfo2/arch/common/blowfish.h b/hardinfo2/arch/common/blowfish.h index d4671e45..3a237baf 100644 --- a/hardinfo2/arch/common/blowfish.h +++ b/hardinfo2/arch/common/blowfish.h @@ -36,9 +36,7 @@ benchmark_fish(void)      gchar *bdata_path; -    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", -                                 path_data); - +    bdata_path = g_build_filename(path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {          g_free(bdata_path);          return g_strdup("[Error]\n" diff --git a/hardinfo2/arch/common/md5.h b/hardinfo2/arch/common/md5.h index 41a65e97..b539b2c7 100644 --- a/hardinfo2/arch/common/md5.h +++ b/hardinfo2/arch/common/md5.h @@ -33,8 +33,7 @@ benchmark_md5(void)      gchar *bdata_path; -    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", -                                 path_data); +    bdata_path = g_build_filename(path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {          g_free(bdata_path);          return g_strdup("[Error]\n" diff --git a/hardinfo2/arch/common/printers.h b/hardinfo2/arch/common/printers.h index 59d49dfa..3bb98f4c 100644 --- a/hardinfo2/arch/common/printers.h +++ b/hardinfo2/arch/common/printers.h @@ -71,8 +71,7 @@ scan_printers(void)  	printer_list = g_strdup_printf("[Printers (CUPS)]\n");  	for (i = 0; i < noprinters; i++) {  	    printer_list = g_strconcat(printer_list, printers[i], -				       !strcmp(default_printer, -					       printers[i]) ? +				       g_str_equal(default_printer, printers[i]) ?  				       "=<i>(Default)</i>\n" : "=\n",  				       NULL);  	    g_free(printers[i]); diff --git a/hardinfo2/arch/common/sha1.h b/hardinfo2/arch/common/sha1.h index 53616bfc..cbf8e2a3 100644 --- a/hardinfo2/arch/common/sha1.h +++ b/hardinfo2/arch/common/sha1.h @@ -32,9 +32,7 @@ benchmark_sha1(void)      gchar *bdata_path; -    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", -                                 path_data); - +    bdata_path = g_build_filename(path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {          g_free(bdata_path);          return g_strdup("[Error]\n" diff --git a/hardinfo2/arch/common/zlib.h b/hardinfo2/arch/common/zlib.h index 0b83a6a7..3fb7fd17 100644 --- a/hardinfo2/arch/common/zlib.h +++ b/hardinfo2/arch/common/zlib.h @@ -53,9 +53,7 @@ benchmark_zlib(void)      glong srclen = 65536;      gchar *bdata_path; -    bdata_path = g_strdup_printf("%s/hardinfo/benchmark.data", -                                 path_data); - +    bdata_path = g_build_filename(path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {          g_free(bdata_path);          return g_strdup("[Error]\n" diff --git a/hardinfo2/arch/linux/common/modules.h b/hardinfo2/arch/linux/common/modules.h index 69f7ebd6..9c335f18 100644 --- a/hardinfo2/arch/linux/common/modules.h +++ b/hardinfo2/arch/linux/common/modules.h @@ -72,7 +72,7 @@ scan_modules(void)  	/* old modutils displays <none> when there's no value for a  	   given field; this is not desirable in the module name   	   display, so change it to an empty string */ -	if (description && !strcmp(description, "<none>")) { +	if (description && g_str_equal(description, "<none>")) {  	    g_free(description);  	    description = g_strdup("");  	} diff --git a/hardinfo2/arch/linux/common/storage.h b/hardinfo2/arch/linux/common/storage.h index 7321f70e..3f65b04e 100644 --- a/hardinfo2/arch/linux/common/storage.h +++ b/hardinfo2/arch/linux/common/storage.h @@ -107,7 +107,7 @@ scan_scsi(void)                  int i;                  for (i = 0; type2icon[i].type != NULL; i++) -                    if (!strcmp(buf + 8, type2icon[i].type)) +                    if (g_str_equal(buf + 8, type2icon[i].type))                          break;                  type = type2icon[i].label; diff --git a/hardinfo2/arch/linux/x86/processor.h b/hardinfo2/arch/linux/x86/processor.h index f13c9dcc..1897a3e7 100644 --- a/hardinfo2/arch/linux/x86/processor.h +++ b/hardinfo2/arch/linux/x86/processor.h @@ -246,7 +246,7 @@ processor_get_capabilities_from_flags(gchar * strflags)      while (flags[j]) {  	gchar *meaning = "";  	for (i = 0; flag_meaning[i].name != NULL; i++) { -	    if (!strcmp(flags[j], flag_meaning[i].name)) { +	    if (g_str_equal(flags[j], flag_meaning[i].name)) {  		meaning = flag_meaning[i].meaning;  		break;  	    } diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index 9bd1fc65..8b4ea0b9 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -46,8 +46,7 @@ benchmark_include_results(gchar *results, const gchar *benchmark)      int i;      conf = g_key_file_new(); -    bconf_path = g_strdup_printf("%s/hardinfo/benchmark.conf", -                                 path_data); +    bconf_path = g_build_filename(path_data, "benchmark.conf", NULL);      g_key_file_load_from_file(conf, bconf_path, 0, NULL);      machines = g_key_file_get_keys(conf, benchmark, NULL, NULL); diff --git a/hardinfo2/callbacks.c b/hardinfo2/callbacks.c index b04043d2..9f5c5233 100644 --- a/hardinfo2/callbacks.c +++ b/hardinfo2/callbacks.c @@ -53,12 +53,19 @@ void cb_about()      GtkWidget *about;      const gchar *authors[] = {          "Leandro A. F. Pereira", +        "",          "SCSI support by Pascal F. Martin",          "MD5 implementation by Colin Plumb",          "SHA1 implementation by Steve Raid",          "Blowfish implementation by Paul Kocher", +        "",          "Some code partly based on x86cpucaps by Osamu Kayasono", -        "Artwork by the GNOME Project and Tango Project", +        "Vendor list based on GtkSysInfo by Pissens Sebastien", +        NULL +    }; +    const gchar *artists[] = { +        "The GNOME Project", +        "Tango Project",          NULL      }; @@ -89,6 +96,7 @@ void cb_about()  #endif      gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about), authors); +    gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(about), artists);      gtk_dialog_run(GTK_DIALOG(about));      gtk_widget_destroy(about); diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index ee430d77..43c57644 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -166,21 +166,21 @@ hi_get_field(gchar * field)  {      gchar *tmp; -    if (!strcmp(field, "Memory")) { +    if (g_str_equal(field, "Memory")) {  	MemoryInfo *mi;  	mi = computer_get_memory();  	tmp = g_strdup_printf("%dMB (%dMB used)", mi->total, mi->used);  	g_free(mi); -    } else if (!strcmp(field, "Uptime")) { +    } else if (g_str_equal(field, "Uptime")) {  	tmp = computer_get_formatted_uptime(); -    } else if (!strcmp(field, "Date/Time")) { +    } else if (g_str_equal(field, "Date/Time")) {  	time_t t = time(NULL);  	tmp = g_new0(gchar, 32);  	strftime(tmp, 32, "%D / %R", localtime(&t)); -    } else if (!strcmp(field, "Load Average")) { +    } else if (g_str_equal(field, "Load Average")) {  	tmp = computer_get_formatted_loadavg();      } else {  	tmp = g_strdup(""); diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index a1331948..7cf13875 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -34,10 +34,22 @@ main(int argc, char **argv)      gtk_init(&argc, &argv);      if (!gbr_init(&error)) { -        g_error("BinReloc cannot be initialized: %s", error->message);       +        path_data = g_build_filename(PREFIX, "share", "hardinfo", NULL); +        path_lib = g_build_filename(PREFIX, "lib", "hardinfo", NULL); +         +        g_warning("Cannot initialize BinReloc (%s); using \"%s\" as data dir and " \ +                  "\"%s\" as lib dir.", error->message, path_data, path_lib); +        g_error_free(error);      } else { -        path_data = gbr_find_data_dir(PREFIX); -        path_lib = gbr_find_lib_dir(PREFIX); +        gchar *tmp; +         +        tmp = gbr_find_data_dir(PREFIX); +        path_data = g_build_filename(tmp, "hardinfo", NULL); +        g_free(tmp); +         +        tmp = gbr_find_lib_dir(PREFIX); +        path_lib = g_build_filename(tmp, "hardinfo", NULL); +        g_free(tmp);      }      icon_cache_init(); diff --git a/hardinfo2/iconcache.c b/hardinfo2/iconcache.c index ee5d2f4f..91b26d4d 100644 --- a/hardinfo2/iconcache.c +++ b/hardinfo2/iconcache.c @@ -36,9 +36,7 @@ GdkPixbuf *icon_cache_get_pixbuf(const gchar *file)      icon = g_hash_table_lookup(cache, file);      if (!icon) { -        gchar *tmp = g_strdup_printf("%s/hardinfo/pixmaps/%s", -                                     path_data, file); -         +        gchar *tmp = g_build_filename(path_data, "pixmaps", file, NULL);          icon = gdk_pixbuf_new_from_file(tmp, NULL);          g_hash_table_insert(cache, g_strdup(file), icon); @@ -63,8 +61,7 @@ GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar *file, gint wid, gint hei)      icon = g_hash_table_lookup(cache, file);      if (!icon) { -        gchar *tmp = g_strdup_printf("%s/hardinfo/pixmaps/%s", -                                     path_data, file); +        gchar *tmp = g_build_filename(path_data, "pixmaps", file, NULL);          icon = gdk_pixbuf_new_from_file_at_size(tmp, wid, hei, NULL);          g_hash_table_insert(cache, g_strdup(file), icon); diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c index 09ced371..61bde7bd 100644 --- a/hardinfo2/menu.c +++ b/hardinfo2/menu.c @@ -108,7 +108,7 @@ void menu_init(Shell *shell)      /* Read in the UI from our XML file */      error = NULL; -    uidefs_path = g_strdup_printf("%s/hardinfo/uidefs.xml", path_data); +    uidefs_path = g_build_filename(path_data, "uidefs.xml", NULL);      gtk_ui_manager_add_ui_from_file(menu_manager, uidefs_path, &error);      g_free(uidefs_path); diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 1990d0dc..e979a8c4 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -118,7 +118,7 @@ gboolean shell_action_get_active(const gchar *action_name)      GtkAction	*action;      GSList	*proxies; -    /* FIXME: Ugh. Are you sure there isn't any simpler way? O_o */ +   /* FIXME: Ugh. Are you sure there isn't any simpler way? O_o */      action = gtk_action_group_get_action(shell->action_group, action_name);      if (action) { @@ -305,7 +305,7 @@ shell_tree_modules_load(ShellTree * shelltree)      keyfile = g_key_file_new(); -    modules_conf = g_strdup_printf("%s/hardinfo/modules.conf", path_data); +    modules_conf = g_build_filename(path_data, "modules.conf", NULL);      g_key_file_load_from_file(keyfile, modules_conf, 0, NULL);      g_free(modules_conf); @@ -326,8 +326,11 @@ shell_tree_modules_load(ShellTree * shelltree)  	module->icon = icon_cache_get_pixbuf(tmp);  	g_free(tmp); -	tmp = g_strdup_printf("%s/hardinfo/modules/%s.so", -	                      path_lib, iname); +	tmp = g_strdup_printf("%s.so", iname); +	g_free(iname); +	iname = tmp; + +	tmp = g_build_filename(path_lib, "modules", iname, NULL);  	module->dll = g_module_open(tmp, G_MODULE_BIND_LAZY);  	g_free(tmp); diff --git a/hardinfo2/socket.c b/hardinfo2/socket.c index 556466d0..2e0bbcb7 100644 --- a/hardinfo2/socket.c +++ b/hardinfo2/socket.c @@ -43,9 +43,7 @@ Socket *sock_connect(gchar * host, gint port)  	server.sin_addr.s_addr = inet_addr(host);  	server.sin_port = htons(port); -	if (connect -	    (sock, (struct sockaddr *) (void *) &server, -	     sizeof(server)) < 0) { +	if (connect(sock, (struct sockaddr *) (void *) &server, sizeof(server)) < 0) {  	    return NULL;  	} diff --git a/hardinfo2/util.c b/hardinfo2/util.c index b1c11174..6ca71fca 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -91,6 +91,3 @@ nonblock_sleep(guint msec)          g_timeout_add(msec, (GSourceFunc)__nonblock_cb, NULL);          gtk_main();  } - - - | 
