/** @brief Main menu widgets */
GtkItemFactory *mainmenufactory;
-static void about_popup_got_version(void *v, const char *value);
+static void about_popup_got_version(void *v,
+ const char *error,
+ const char *value);
/** @brief Called when the quit option is activated
*
* need not.
*/
void menu_update(int page) {
- GtkWidget *tab = gtk_notebook_get_nth_page
- (GTK_NOTEBOOK(tabs),
- page < 0 ? gtk_notebook_current_page(GTK_NOTEBOOK(tabs)) : page);
- const struct tabtype *t = g_object_get_data(G_OBJECT(tab), "type");
+ if(tabs) {
+ GtkWidget *tab = gtk_notebook_get_nth_page
+ (GTK_NOTEBOOK(tabs),
+ page < 0 ? gtk_notebook_current_page(GTK_NOTEBOOK(tabs)) : page);
+ const struct tabtype *t = g_object_get_data(G_OBJECT(tab), "type");
- assert(t != 0);
- gtk_widget_set_sensitive(properties_widget,
- (t->properties_sensitive(tab)
- && (disorder_eclient_state(client) & DISORDER_CONNECTED)));
- gtk_widget_set_sensitive(selectall_widget,
- t->selectall_sensitive(tab));
- gtk_widget_set_sensitive(selectnone_widget,
- t->selectnone_sensitive(tab));
- /* TODO Users should only be sensitive if have RIGHT_ADMIN */
+ assert(t != 0);
+ gtk_widget_set_sensitive(properties_widget,
+ (t->properties_sensitive(tab)
+ && (disorder_eclient_state(client) & DISORDER_CONNECTED)));
+ gtk_widget_set_sensitive(selectall_widget,
+ t->selectall_sensitive(tab));
+ gtk_widget_set_sensitive(selectnone_widget,
+ t->selectnone_sensitive(tab));
+ }
}
/** @brief Fetch version in order to display the about... popup */
/** @brief Called when version arrives, displays about... popup */
static void about_popup_got_version(void attribute((unused)) *v,
+ const char attribute((unused)) *error,
const char *value) {
GtkWidget *w;
char *server_version_string;
char *short_version_string;
GtkWidget *hbox, *vbox, *title;
+ if(!value)
+ value = "[error]";
byte_xasprintf(&server_version_string, "Server version %s", value);
byte_xasprintf(&short_version_string, "Disobedience %s",
disorder_short_version_string);
}
/** @brief Called with current user's rights string */
-static void menu_got_rights(void attribute((unused)) *v, const char *value) {
+static void menu_got_rights(void attribute((unused)) *v,
+ const char *error,
+ const char *value) {
rights_type r;
- if(parse_rights(value, &r, 0))
+ if(error) {
+ popup_protocol_error(0, error);
r = 0;
+ } else {
+ if(parse_rights(value, &r, 0))
+ r = 0;
+ }
users_set_sensitive(!!(r & RIGHT_ADMIN));
}
-/** @brief Called when we need to reset state */
-static void menu_reset(void) {
+/** @brief Called after a fresh login */
+static void menu_logged_in(const char attribute((unused)) *event,
+ void attribute((unused)) *eventdata,
+ void attribute((unused)) *callbackdata) {
users_set_sensitive(0); /* until we know better */
disorder_eclient_userinfo(client, menu_got_rights, config->username, "rights",
0);
assert(selectall_widget != 0);
assert(selectnone_widget != 0);
assert(properties_widget != 0);
- register_reset(menu_reset);
- menu_reset();
+ event_register("logged-in", menu_logged_in, 0);
+ menu_logged_in(0, 0, 0);
m = gtk_item_factory_get_widget(mainmenufactory,
"<GdisorderMain>");
set_tool_colors(m);