mcabber/mcabber/screen.c
changeset 2292 f181418db215
parent 2291 0d350e979bde
child 2304 fa8365fb6ac2
equal deleted inserted replaced
2291:0d350e979bde 2292:f181418db215
   154 static int    chatstate; /* (0=active, 1=composing, 2=paused) */
   154 static int    chatstate; /* (0=active, 1=composing, 2=paused) */
   155 static bool   lock_chatstate;
   155 static bool   lock_chatstate;
   156 static time_t chatstate_timestamp;
   156 static time_t chatstate_timestamp;
   157 static guint  chatstate_timeout_id = 0;
   157 static guint  chatstate_timeout_id = 0;
   158 
   158 
   159 int update_roster;
   159 int _update_roster;
   160 int utf8_mode;
   160 int utf8_mode;
   161 gboolean chatstates_disabled;
   161 gboolean chatstates_disabled;
   162 gboolean Autoaway;
   162 gboolean Autoaway;
   163 
   163 
   164 #define MAX_KEYSEQ_LENGTH 8
   164 #define MAX_KEYSEQ_LENGTH 8
   380   for (head = rostercolrules; head; head = g_slist_next(head)) {
   380   for (head = rostercolrules; head; head = g_slist_next(head)) {
   381     free_rostercolrule(head->data);
   381     free_rostercolrule(head->data);
   382   }
   382   }
   383   g_slist_free(rostercolrules);
   383   g_slist_free(rostercolrules);
   384   rostercolrules = NULL;
   384   rostercolrules = NULL;
       
   385   scr_update_roster();
   385 }
   386 }
   386 
   387 
   387 // Adds, modifies or removes roster coloring rule
   388 // Adds, modifies or removes roster coloring rule
   388 // color set to "-" removes the rule,
   389 // color set to "-" removes the rule,
   389 // otherwise it is modified (if exists) or added
   390 // otherwise it is modified (if exists) or added
   405   }
   406   }
   406   if (!strcmp(color,"-")) { // Delete the rule
   407   if (!strcmp(color,"-")) { // Delete the rule
   407     if (found) {
   408     if (found) {
   408       free_rostercolrule(found->data);
   409       free_rostercolrule(found->data);
   409       rostercolrules = g_slist_delete_link(rostercolrules, found);
   410       rostercolrules = g_slist_delete_link(rostercolrules, found);
       
   411       scr_update_roster();
   410       return TRUE;
   412       return TRUE;
   411     } else {
   413     } else {
   412       scr_LogPrint(LPRINT_NORMAL, "No such color rule, nothing removed");
   414       scr_LogPrint(LPRINT_NORMAL, "No such color rule, nothing removed");
   413       return FALSE;
   415       return FALSE;
   414     }
   416     }
   428       rc->wildcard = g_strdup(wildcard);
   430       rc->wildcard = g_strdup(wildcard);
   429       rc->compiled = g_pattern_spec_new(wildcard);
   431       rc->compiled = g_pattern_spec_new(wildcard);
   430       rc->color = cl;
   432       rc->color = cl;
   431       rostercolrules = g_slist_prepend(rostercolrules, rc);
   433       rostercolrules = g_slist_prepend(rostercolrules, rc);
   432     }
   434     }
       
   435     scr_update_roster();
   433     return TRUE;
   436     return TRUE;
   434   }
   437   }
   435 }
   438 }
   436 
   439 
   437 static void parse_colors(void)
   440 static void parse_colors(void)
  1403   chatmode = TRUE;
  1406   chatmode = TRUE;
  1404   if (!win_entry->bd->lock)
  1407   if (!win_entry->bd->lock)
  1405     roster_msg_setflag(winId, special, FALSE);
  1408     roster_msg_setflag(winId, special, FALSE);
  1406   if (!special)
  1409   if (!special)
  1407     roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
  1410     roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
  1408   update_roster = TRUE;
  1411   scr_update_roster();
  1409 
  1412 
  1410   // Refresh the window
  1413   // Refresh the window
  1411   scr_update_window(win_entry);
  1414   scr_update_window(win_entry);
  1412 
  1415 
  1413   // Finished :)
  1416   // Finished :)
  1553     setmsgflg = TRUE;
  1556     setmsgflg = TRUE;
  1554   }
  1557   }
  1555   if (!special) {
  1558   if (!special) {
  1556     if (clearmsgflg) {
  1559     if (clearmsgflg) {
  1557       roster_msg_setflag(winId, FALSE, FALSE);
  1560       roster_msg_setflag(winId, FALSE, FALSE);
  1558       update_roster = TRUE;
  1561       scr_update_roster();
  1559     } else if (setmsgflg) {
  1562     } else if (setmsgflg) {
  1560       roster_msg_setflag(winId, FALSE, TRUE);
  1563       roster_msg_setflag(winId, FALSE, TRUE);
  1561       update_roster = TRUE;
  1564       scr_update_roster();
  1562     }
  1565     }
  1563   }
  1566   }
  1564 }
  1567 }
  1565 
  1568 
  1566 static char *attention_sign_guard(const gchar *key, const gchar *new_value)
  1569 static char *attention_sign_guard(const gchar *key, const gchar *new_value)
  1567 {
  1570 {
  1568   update_roster = TRUE;
  1571   scr_update_roster();
  1569   if (g_strcmp0(settings_opt_get(key), new_value)) {
  1572   if (g_strcmp0(settings_opt_get(key), new_value)) {
  1570     guint sign;
  1573     guint sign;
  1571     char *c;
  1574     char *c;
  1572     if (!new_value || !*new_value)
  1575     if (!new_value || !*new_value)
  1573       return NULL;
  1576       return NULL;
  1817     replace_panel(mainstatusPanel, mainstatusWnd);
  1820     replace_panel(mainstatusPanel, mainstatusWnd);
  1818     replace_panel(inputPanel, inputWnd);
  1821     replace_panel(inputPanel, inputWnd);
  1819   }
  1822   }
  1820 
  1823 
  1821   // We'll need to redraw the roster
  1824   // We'll need to redraw the roster
  1822   update_roster = TRUE;
  1825   scr_update_roster();
  1823   return;
  1826   return;
  1824 }
  1827 }
  1825 
  1828 
  1826 static void resize_win_buffer(gpointer key, gpointer value, gpointer data)
  1829 static void resize_win_buffer(gpointer key, gpointer value, gpointer data)
  1827 {
  1830 {
  2084   int x_pos;
  2087   int x_pos;
  2085   int prefix_length;
  2088   int prefix_length;
  2086   char space[2] = " ";
  2089   char space[2] = " ";
  2087 
  2090 
  2088   // We can reset update_roster
  2091   // We can reset update_roster
  2089   update_roster = FALSE;
  2092   if (_update_roster == FALSE)
       
  2093     return;
       
  2094   _update_roster = FALSE;
  2090 
  2095 
  2091   buddylist_build();
  2096   buddylist_build();
  2092 
  2097 
  2093   getmaxyx(rosterWnd, maxy, maxx);
  2098   getmaxyx(rosterWnd, maxy, maxx);
  2094   maxx--;  // Last char is for vertical border
  2099   maxx--;  // Last char is for vertical border
  2297   top_panel(inputPanel);
  2302   top_panel(inputPanel);
  2298   update_panels();
  2303   update_panels();
  2299   curs_set(cursor_backup);
  2304   curs_set(cursor_backup);
  2300 }
  2305 }
  2301 
  2306 
       
  2307 void scr_update_roster(void)
       
  2308 {
       
  2309   _update_roster = TRUE;
       
  2310 }
       
  2311 
       
  2312 
  2302 //  scr_roster_visibility(status)
  2313 //  scr_roster_visibility(status)
  2303 // Set the roster visibility:
  2314 // Set the roster visibility:
  2304 // status=1   Show roster
  2315 // status=1   Show roster
  2305 // status=0   Hide roster
  2316 // status=0   Hide roster
  2306 // status=-1  Toggle roster status
  2317 // status=-1  Toggle roster status
  2536   if (chatmode) {
  2547   if (chatmode) {
  2537     buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
  2548     buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
  2538     // Remove the readmark if it is at the end of the buffer
  2549     // Remove the readmark if it is at the end of the buffer
  2539     scr_buffer_readmark(-1);
  2550     scr_buffer_readmark(-1);
  2540   }
  2551   }
  2541   // We should rebuild the buddylist but not everytime
  2552   // We should rebuild the buddylist when the last selected buddy isn't
       
  2553   // displayed anymore
  2542   if (!(buddylist_get_filter() & 1<<prev_st))
  2554   if (!(buddylist_get_filter() & 1<<prev_st))
  2543     buddylist_defer_build();
  2555     buddylist_defer_build();
  2544   update_roster = TRUE;
  2556   scr_update_roster();
  2545 }
  2557 }
  2546 
  2558 
  2547 //  scr_roster_top()
  2559 //  scr_roster_top()
  2548 // Go to the first buddy in the buddylist
  2560 // Go to the first buddy in the buddylist
  2549 void scr_roster_top(void)
  2561 void scr_roster_top(void)
  2777     for (budstate = 0; budstate < imstatus_size-1; budstate++)
  2789     for (budstate = 0; budstate < imstatus_size-1; budstate++)
  2778       if (strchr(filter, imstatus2char[budstate]) || show_all)
  2790       if (strchr(filter, imstatus2char[budstate]) || show_all)
  2779         status |= 1<<budstate;
  2791         status |= 1<<budstate;
  2780     buddylist_set_filter(status);
  2792     buddylist_set_filter(status);
  2781     buddylist_defer_build();
  2793     buddylist_defer_build();
  2782     update_roster = TRUE;
  2794     scr_update_roster();
  2783     return;
  2795     return;
  2784   }
  2796   }
  2785 
  2797 
  2786   // Display current filter
  2798   // Display current filter
  2787   psfilter = strfilter;
  2799   psfilter = strfilter;
  2965 
  2977 
  2966     win_entry->bd->cleared = FALSE;
  2978     win_entry->bd->cleared = FALSE;
  2967     win_entry->bd->top = NULL;
  2979     win_entry->bd->top = NULL;
  2968   }
  2980   }
  2969 
  2981 
  2970   update_roster = TRUE;
  2982   scr_update_roster();
  2971 
  2983 
  2972   // Refresh the window
  2984   // Refresh the window
  2973   scr_update_buddy_window();
  2985   scr_update_buddy_window();
  2974 
  2986 
  2975   // Finished :)
  2987   // Finished :)
  3318   } else {
  3330   } else {
  3319     current_id = NULL;
  3331     current_id = NULL;
  3320   }
  3332   }
  3321   if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) {
  3333   if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) {
  3322     roster_msg_setflag(bjid, special, TRUE);
  3334     roster_msg_setflag(bjid, special, TRUE);
  3323     update_roster = TRUE;
  3335     scr_update_roster();
  3324   }
  3336   }
  3325 }
  3337 }
  3326 
  3338 
  3327 //  scr_setattentionflag_if_needed(bare_jid, special, value, action)
  3339 //  scr_setattentionflag_if_needed(bare_jid, special, value, action)
  3328 // Set the attention flag unless we're already in the jid buffer window
  3340 // Set the attention flag unless we're already in the jid buffer window
  3355     current_id = NULL;
  3367     current_id = NULL;
  3356   }
  3368   }
  3357 
  3369 
  3358   if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) {
  3370   if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) {
  3359     roster_setuiprio(bjid, special, value, action);
  3371     roster_setuiprio(bjid, special, value, action);
  3360     update_roster = TRUE;
  3372     scr_update_roster();
  3361   }
  3373   }
  3362 }
  3374 }
  3363 
  3375 
  3364 //  scr_set_multimode()
  3376 //  scr_set_multimode()
  3365 // Public function to (un)set multimode...
  3377 // Public function to (un)set multimode...