summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/script/script-buffer.c20
-rw-r--r--src/plugins/script/script-repo.c82
-rw-r--r--src/plugins/script/script-repo.h2
3 files changed, 86 insertions, 18 deletions
diff --git a/src/plugins/script/script-buffer.c b/src/plugins/script/script-buffer.c
index 87e6c8b74..239c8a01c 100644
--- a/src/plugins/script/script-buffer.c
+++ b/src/plugins/script/script-buffer.c
@@ -428,27 +428,11 @@ script_buffer_display_detail_script (struct t_repo_script *script)
else
{
weechat_printf_y (script_buffer, line + 1,
- "%s: %s%s (%s%s%s%s%s%s%s%s%s%s%s%s )",
+ "%s: %s%s (%s)",
script_buffer_detail_label (_(labels[line]), max_length),
script_repo_get_status_for_display (script, "*iaHrN", 1),
weechat_color ("chat"),
- (script->popularity > 0) ? " " : "",
- (script->popularity > 0) ? _("popular") : "",
- (script->status & SCRIPT_STATUS_INSTALLED) ? " " : "",
- /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
- (script->status & SCRIPT_STATUS_INSTALLED) ? _("installed") : "",
- (script->status & SCRIPT_STATUS_AUTOLOADED) ? " " : "",
- /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
- (script->status & SCRIPT_STATUS_AUTOLOADED) ? _("autoloaded") : "",
- (script->status & SCRIPT_STATUS_HELD) ? " " : "",
- /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
- (script->status & SCRIPT_STATUS_HELD) ? _("held") : "",
- (script->status & SCRIPT_STATUS_RUNNING) ? " " : "",
- /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
- (script->status & SCRIPT_STATUS_RUNNING) ? _("running") : "",
- (script->status & SCRIPT_STATUS_NEW_VERSION) ? " " : "",
- /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
- (script->status & SCRIPT_STATUS_NEW_VERSION) ? _("obsolete") : "");
+ script_repo_get_status_desc_for_display (script, "*iaHrN"));
}
line++;
tm = localtime (&script->date_added);
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index 2afa13611..4d5be3fe5 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -205,6 +205,88 @@ script_repo_get_status_for_display (struct t_repo_script *script,
}
/*
+ * script_repo_get_status_desc_for_display: get status description for display
+ * (exemple of string returned:
+ * "popular installed autoloaded loaded")
+ */
+
+const char *
+script_repo_get_status_desc_for_display (struct t_repo_script *script,
+ const char *list)
+{
+ static char str_status[256];
+ const char *ptr_list;
+
+ str_status[0] = '\0';
+
+ if (!script)
+ return str_status;
+
+ for (ptr_list = list; ptr_list[0]; ptr_list++)
+ {
+ switch (ptr_list[0])
+ {
+ case '*':
+ if (script->popularity > 0)
+ {
+ if (str_status[0])
+ strcat (str_status, " ");
+ /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
+ strcat (str_status, _("popular"));
+ }
+ break;
+ case 'i':
+ if (script->status & SCRIPT_STATUS_INSTALLED)
+ {
+ if (str_status[0])
+ strcat (str_status, " ");
+ /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
+ strcat (str_status, _("installed"));
+ }
+ break;
+ case 'a':
+ if (script->status & SCRIPT_STATUS_AUTOLOADED)
+ {
+ if (str_status[0])
+ strcat (str_status, " ");
+ /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
+ strcat (str_status, _("autoloaded"));
+ }
+ break;
+ case 'H':
+ if (script->status & SCRIPT_STATUS_HELD)
+ {
+ if (str_status[0])
+ strcat (str_status, " ");
+ /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
+ strcat (str_status, _("held"));
+ }
+ break;
+ case 'r':
+ if (script->status & SCRIPT_STATUS_RUNNING)
+ {
+ if (str_status[0])
+ strcat (str_status, " ");
+ /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
+ strcat (str_status, _("running"));
+ }
+ break;
+ case 'N':
+ if (script->status & SCRIPT_STATUS_NEW_VERSION)
+ {
+ if (str_status[0])
+ strcat (str_status, " ");
+ /* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
+ strcat (str_status, _("obsolete"));
+ }
+ break;
+ }
+ }
+
+ return str_status;
+}
+
+/*
* script_repo_alloc: allocate a script structure
*/
diff --git a/src/plugins/script/script-repo.h b/src/plugins/script/script-repo.h
index 51e494f9f..5f8b97298 100644
--- a/src/plugins/script/script-repo.h
+++ b/src/plugins/script/script-repo.h
@@ -67,6 +67,8 @@ extern struct t_repo_script *script_repo_search_by_name_ext (const char *name_wi
extern const char *script_repo_get_status_for_display (struct t_repo_script *script,
const char *list,
int collapse);
+extern const char *script_repo_get_status_desc_for_display (struct t_repo_script *script,
+ const char *list);
extern void script_repo_remove_all ();
extern void script_repo_update_status (struct t_repo_script *script);
extern void script_repo_update_status_all ();