static void extended_buddy_menu_cb(PurpleBlistNode *node, GList **menu) {
	PurpleMenuAction *action = NULL;
	GList *submenu = NULL;

	if(
		!PURPLE_BLIST_NODE_IS_CONTACT(node) &&
		!PURPLE_BLIST_NODE_IS_BUDDY(node) &&
		!PURPLE_BLIST_NODE_IS_CHAT(node)
	) {
		return;
	}

	if(purple_blist_node_get_flags(node) & PURPLE_BLIST_NODE_FLAG_NO_SAVE) {
		return;
	}

	if(
		purple_prefs_get_int(PLUGIN_PREFS_PREFIX "/sort1") != SORT_METHOD_PRIORITY &&
		purple_prefs_get_int(PLUGIN_PREFS_PREFIX "/sort2") != SORT_METHOD_PRIORITY &&
		purple_prefs_get_int(PLUGIN_PREFS_PREFIX "/sort3") != SORT_METHOD_PRIORITY
	) {
		return;
	}

	submenu = menu_append(submenu, node, PRIORITY_VERY_HIGH, _("Very High"));
	submenu = menu_append(submenu, node, PRIORITY_HIGH, _("High"));
	submenu = menu_append(submenu, node, PRIORITY_NORMAL, _("Normal"));
	submenu = menu_append(submenu, node, PRIORITY_LOW, _("Low"));
	submenu = menu_append(submenu, node, PRIORITY_VERY_LOW, _("Very Low"));

	action = purple_menu_action_new(_("Set Priority"), NULL, NULL, submenu);
	*menu = g_list_append(*menu, action);
}
static gboolean should_hide_notice(PurpleConversation *conv, const char *name,
                                   GHashTable *users)
{
	PurpleConvChat *chat;
	int threshold;
	struct joinpart_key key;
	time_t *last_said;

	g_return_val_if_fail(conv != NULL, FALSE);
	g_return_val_if_fail(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT, FALSE);

	/* If the room is small, don't bother. */
	chat = PURPLE_CONV_CHAT(conv);
	threshold = purple_prefs_get_int(THRESHOLD_PREF);
	if (g_list_length(purple_conv_chat_get_users(chat)) < threshold)
		return FALSE;

	if (!purple_prefs_get_bool(HIDE_BUDDIES_PREF) &&
	    purple_find_buddy(purple_conversation_get_account(conv), name))
		return FALSE;

	/* Only show the notice if the user has spoken recently. */
	key.conv = conv;
	key.user = (gchar *)name;
	last_said = g_hash_table_lookup(users, &key);
	if (last_said != NULL)
	{
		int delay = purple_prefs_get_int(DELAY_PREF);
		if (delay > 0 && (*last_said + (delay * 60)) >= time(NULL))
			return FALSE;
	}

	return TRUE;
}
예제 #3
0
/* create message queue and prepare timer callbacks */
static void
split_and_send(message_to_conv *msg_to_conv, const char **message) {
	gint message_delay_ms;

	g_return_if_fail( msg_to_conv != NULL );
	g_return_if_fail( message     != NULL );
	g_return_if_fail( *message    != NULL );

	/* read and validate preferences */
	current_split_size = purple_prefs_get_int("/plugins/core/splitter/split_size");
	if( current_split_size > MAX_SPLIT_SIZE ) current_split_size = MAX_SPLIT_SIZE;
	if( current_split_size < MIN_SPLIT_SIZE ) current_split_size = MIN_SPLIT_SIZE;

	message_delay_ms = purple_prefs_get_int("/plugins/core/splitter/delay_ms");
	if( message_delay_ms > MAX_DELAY_MS ) message_delay_ms = MAX_DELAY_MS;
	if( message_delay_ms < MIN_DELAY_MS ) message_delay_ms = MIN_DELAY_MS;

	/* prepare message queue */
	msg_to_conv->messages = create_message_queue(*message);
	g_return_if_fail( msg_to_conv->messages != NULL );

	/* initialize message send timer */
	purple_timeout_add( (g_queue_get_length(msg_to_conv->messages) > 1) ? message_delay_ms : 0,
			  (GSourceFunc)send_message_timer_cb,
			  msg_to_conv);

	/* free the original message and ensure it does not get sent */
	g_free((char*)*message);
	*message = NULL;
}
예제 #4
0
static void blist_create_cb(PurpleBuddyList *purple_blist, void *data) {
	purple_debug_info(WINPREFS_PLUGIN_ID, "buddy list created\n");

	blist = PIDGIN_BLIST(purple_blist)->window;

	if(purple_prefs_get_bool(PREF_DBLIST_DOCKABLE)) {
		blist_set_dockable(TRUE);
		if(purple_prefs_get_bool(PREF_DBLIST_DOCKED)) {
			blist_ab->undocked_height = purple_prefs_get_int(PREF_DBLIST_HEIGHT);
			if(!(gdk_window_get_state(gtk_widget_get_window(blist))
					& GDK_WINDOW_STATE_WITHDRAWN)) {
				gtk_appbar_dock(blist_ab,
					purple_prefs_get_int(PREF_DBLIST_SIDE));
				if(purple_prefs_get_int(PREF_BLIST_ON_TOP)
						== BLIST_TOP_DOCKED)
					blist_set_ontop(TRUE);
			} else {
				g_idle_add(listen_for_blist_visible_cb, NULL);
			}
		}
	}

	if(purple_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS)
		blist_set_ontop(TRUE);

}
예제 #5
0
static gboolean
plugin_load(PurplePlugin *plugin, GError **error)
{
	GList *convs = purple_conversations_get_all();
	PurpleSavedStatus *saved_status;
	void *conv_handle = purple_conversations_get_handle();
	void *gtk_conv_handle = pidgin_conversations_get_handle();
	void *savedstat_handle = purple_savedstatuses_get_handle();

	purple_prefs_add_none("/plugins/gtk");
	purple_prefs_add_none("/plugins/gtk/unity");
	purple_prefs_add_int("/plugins/gtk/unity/launcher_count", LAUNCHER_COUNT_SOURCES);
	purple_prefs_add_int("/plugins/gtk/unity/messaging_menu_text", MESSAGING_MENU_COUNT);
	purple_prefs_add_bool("/plugins/gtk/unity/alert_chat_nick", TRUE);

	alert_chat_nick = purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick");

	mmapp = messaging_menu_app_new("pidgin.desktop");
	g_object_ref(mmapp);
	messaging_menu_app_register(mmapp);
	messaging_menu_text = purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text");

	g_signal_connect(mmapp, "activate-source",
			G_CALLBACK(message_source_activated), NULL);
	g_signal_connect(mmapp, "status-changed",
			G_CALLBACK(messaging_menu_status_changed), NULL);

	saved_status = purple_savedstatus_get_current();
	status_changed_cb(saved_status);

	purple_signal_connect(savedstat_handle, "savedstatus-changed", plugin,
			PURPLE_CALLBACK(status_changed_cb), NULL);

	launcher = unity_launcher_entry_get_for_desktop_id("pidgin.desktop");
	g_object_ref(launcher);
	launcher_count = purple_prefs_get_int("/plugins/gtk/unity/launcher_count");

	purple_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin,
			PURPLE_CALLBACK(message_displayed_cb), NULL);
	purple_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin,
			PURPLE_CALLBACK(message_displayed_cb), NULL);
	purple_signal_connect(conv_handle, "sent-im-msg", plugin,
			PURPLE_CALLBACK(im_sent_im), NULL);
	purple_signal_connect(conv_handle, "sent-chat-msg", plugin,
			PURPLE_CALLBACK(chat_sent_im), NULL);
	purple_signal_connect(conv_handle, "conversation-created", plugin,
			PURPLE_CALLBACK(conv_created), NULL);
	purple_signal_connect(conv_handle, "deleting-conversation", plugin,
			PURPLE_CALLBACK(deleting_conv), NULL);

	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;
		attach_signals(conv);
		convs = convs->next;
	}

	return TRUE;
}
예제 #6
0
static void blist_dock_cb(gboolean val) {
	if(val) {
		purple_debug_info(WINPREFS_PLUGIN_ID, "Blist Docking...\n");
		if(purple_prefs_get_int(PREF_BLIST_ON_TOP) != BLIST_TOP_NEVER)
			blist_set_ontop(TRUE);
	} else {
		purple_debug_info(WINPREFS_PLUGIN_ID, "Blist Undocking...\n");
		blist_set_ontop(purple_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS);
	}
}
예제 #7
0
static void
init_plugin(PurplePlugin *plugin)
{
	gboolean dates = FALSE, ims = FALSE, chats = FALSE;

	purple_prefs_add_none(PREF_ROOT_GPPATH);
	purple_prefs_add_none(PREF_ROOT_PPATH);
	purple_prefs_add_none(PREF_ROOT_PATH);

	if(purple_prefs_exists("/plugins/core/enhanced_history/int")) {
		if(strcmp(purple_prefs_get_string("/plugins/core/enhanced_history/string_date"), "no"))
			dates = TRUE;
		if(strcmp(purple_prefs_get_string("/plugins/core/enhanced_history/string_im"), "no"))
			ims = TRUE;
		if(strcmp(purple_prefs_get_string("/plugins/core/enhanced_history/string_chat"), "no"))
			chats = TRUE;

		purple_prefs_add_int(PREF_NUMBER_PATH, purple_prefs_get_int("/plugins/core/enhanced_history/int"));
		purple_prefs_add_int(PREF_BYTES_PATH, purple_prefs_get_int("/plugins/core/enhanced_history/bytes"));
		purple_prefs_add_int(PREF_MINS_PATH, purple_prefs_get_int("/plugins/core/enhanced_history/mins"));
		purple_prefs_add_int(PREF_HOURS_PATH, purple_prefs_get_int("/plugins/core/enhanced_history/hours"));
		purple_prefs_add_int(PREF_DAYS_PATH, purple_prefs_get_int("/plugins/core/enhanced_history/days"));
		purple_prefs_add_bool(PREF_DATES_PATH, dates);
		purple_prefs_add_bool(PREF_IM_PATH, ims);
		purple_prefs_add_bool(PREF_CHAT_PATH, chats);

		purple_prefs_remove("/plugins/core/enhanced_history/int");
		purple_prefs_remove("/plugins/core/enhanced_history/bytes");
		purple_prefs_remove("/plugins/core/enhanced_history/mins");
		purple_prefs_remove("/plugins/core/enhanced_history/hours");
		purple_prefs_remove("/plugins/core/enhanced_history/days");
		purple_prefs_remove("/plugins/core/enhanced_history/string_date");
		purple_prefs_remove("/plugins/core/enhanced_history/string_im");
		purple_prefs_remove("/plugins/core/enhanced_history/string_chat");
		purple_prefs_remove("/plugins/core/enhanced_history");
	} else {
		/* Create these prefs with sensible defaults */
		purple_prefs_add_int(PREF_NUMBER_PATH, 10);
		purple_prefs_add_int(PREF_BYTES_PATH, 4096);
		purple_prefs_add_int(PREF_MINS_PATH, 0);
		purple_prefs_add_int(PREF_HOURS_PATH, 0);
		purple_prefs_add_int(PREF_DAYS_PATH, 0);
		purple_prefs_add_bool(PREF_DATES_PATH, TRUE);
		purple_prefs_add_bool(PREF_IM_PATH, TRUE);
		purple_prefs_add_bool(PREF_CHAT_PATH, FALSE);
	}

	info.name = _("Enhanced History");
	info.summary = _("An enhanced version of the history plugin.");
	info.description = _("An enhanced versoin of the history plugin. Grants ability to "
			"select the number of previous conversations to show instead of just one.");
}
예제 #8
0
static void
fl_show_with_account(PurpleAccount *account)
{
	setup_roomlist(account);
	g_signal_handlers_disconnect_matched(G_OBJECT(froomlist.window), G_SIGNAL_MATCH_FUNC,
			0, 0, NULL, G_CALLBACK(size_changed_cb), NULL);
	gnt_widget_show(froomlist.window);
	gnt_screen_resize_widget(froomlist.window,
			purple_prefs_get_int(PREF_ROOT "/size/width"),
			purple_prefs_get_int(PREF_ROOT "/size/height"));
	g_signal_connect(G_OBJECT(froomlist.window), "size_changed", G_CALLBACK(size_changed_cb), NULL);
	gnt_window_present(froomlist.window);
}
예제 #9
0
/* Listen for the first time the window stops being withdrawn */
static void blist_visible_cb(const char *pref, PurplePrefType type,
		gconstpointer value, gpointer user_data) {
	if(purple_prefs_get_bool(pref)) {
		gtk_appbar_dock(blist_ab,
			purple_prefs_get_int(PREF_DBLIST_SIDE));

		if(purple_prefs_get_int(PREF_BLIST_ON_TOP)
				== BLIST_TOP_DOCKED)
			blist_set_ontop(TRUE);

		/* We only need to be notified about this once */
		purple_prefs_disconnect_callback(blist_visible_cb_id);
	}
}
예제 #10
0
static GdkPixbuf *make_scaled_pixbuf(const guchar * url_text, gsize len)
{
    /* make pixbuf */
    GdkPixbufLoader *loader;
    GdkPixbuf      *src = NULL,
        *dest = NULL;

    g_return_val_if_fail(url_text != NULL, NULL);
    g_return_val_if_fail(len > 0, NULL);

    loader = gdk_pixbuf_loader_new();
    gdk_pixbuf_loader_write(loader, url_text, len, NULL);
    gdk_pixbuf_loader_close(loader, NULL);

    src = gdk_pixbuf_loader_get_pixbuf(loader);

    if (src) {
        dest = gdk_pixbuf_scale_simple(src, purple_prefs_get_int(TWITTER_PREF_CONV_ICON_SIZE), purple_prefs_get_int(TWITTER_PREF_CONV_ICON_SIZE), GDK_INTERP_HYPER);
    } else {
        dest = NULL;
    }

    g_object_unref(G_OBJECT(loader));

    return dest;
}
예제 #11
0
static gboolean
purple_sound_play_required(const PurpleAccount *account)
{
	gint pref_status = purple_prefs_get_int("/purple/sound/while_status");

	if (pref_status == PURPLE_SOUND_STATUS_ALWAYS)
	{
		/* Play sounds: Always */
		return TRUE;
	}

	if (account != NULL)
	{
		PurpleStatus *status = purple_account_get_active_status(account);

		if (purple_status_is_online(status))
		{
			gboolean available = purple_status_is_available(status);
			return (( available && pref_status == PURPLE_SOUND_STATUS_AVAILABLE) ||
			        (!available && pref_status == PURPLE_SOUND_STATUS_AWAY));
		}
	}

	/* We get here a couple of ways.  Either the request has been OK'ed
	 * by purple_sound_play_event() and we're here because the UI has
	 * called purple_sound_play_file(), or we're here for something
	 * not related to an account (like testing a sound). */
	return TRUE;
}
예제 #12
0
static void set_conv_window_trans(PidginWindow *oldwin, PidginWindow *newwin) {
	GtkWidget *win = newwin->window;

	/* check prefs to see if we want trans */
	if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
		set_wintrans(win, purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
			TRUE, purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));

		if (purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) {
			add_slider(win);
		}
	}

	/* If we're moving from one window to another,
	 * add the focus listeners to the new window if not already there */
	if (oldwin != NULL && oldwin != newwin) {
		if (pidgin_conv_window_get_gtkconv_count(newwin) == 0) {
			g_signal_connect(G_OBJECT(win), "focus_in_event",
				G_CALLBACK(focus_conv_win_cb), win);
			g_signal_connect(G_OBJECT(win), "focus_out_event",
				G_CALLBACK(focus_conv_win_cb), win);
		}

		/* If we've moved the last conversation, cleanup the window */
		if (pidgin_conv_window_get_gtkconv_count(oldwin) == 1)
			cleanup_conv_window(oldwin);
	}
}
예제 #13
0
파일: main.c 프로젝트: bf4/pidgin-mac
static void
conv_created_cb(PurpleConversation *conv, gpointer null)
{
    PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);

    twitter_debug("called\n");

    g_return_if_fail(gtkconv != NULL);

    gint service = get_service_type(conv);
    /* only attach to twitter conversation window */
    switch(service) {
    case twitter_service:
        get_status_with_api((gpointer)conv);
        source.id = g_timeout_add_seconds(
            purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL),
            get_status_with_api, (gpointer)conv);
        source.conv = conv;
        attach_to_conv(conv, NULL);
        break;
    case wassr_service:
    case identica_service:
    case jisko_service:
    case ffeed_service:
        attach_to_conv(conv, NULL);
        break;
    default:
        twitter_debug("unknown service\n");
        break;
    }
}
예제 #14
0
void
get_lastfm_ws_info(struct TrackInfo* ti)
{
  const char *user = purple_prefs_get_string(PREF_LASTFM);
  if (!strcmp(user,""))
    {
      trace("No last.fm user name");
      return;
    }
  trace("Got user name: %s",user);

  // Check if it's time to check again
  static int count = 0;
  if (count < 0)
    {
      trace("last.fm ratelimit %d",count);
    }
  else
    {
      count = count - purple_prefs_get_int(PREF_LASTFM_INTERVAL);

      char *url = g_strdup_printf(LASTFM_WS_URL, user, LASTFM_WS_API_KEY);
      trace("URL is %s", url);

      purple_util_fetch_url_request(url, TRUE, USER_AGENT, FALSE, NULL, FALSE, lastfm_ws_fetch, NULL);

      g_free(url);
    }
  count = count + INTERVAL_SECONDS;

  *ti = lastfm_ws_ti;
}
예제 #15
0
static void
test_cb(GntWidget *button, gpointer null)
{
	PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events)));
	FinchSoundEvent * event = &sounds[id];
	char *enabled, *file, *tmpfile, *volpref;
	gboolean temp_value;
	int volume;

	enabled = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",
			finch_sound_get_active_profile(), event->pref);
	file = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",
			finch_sound_get_active_profile(), event->pref);
	volpref = g_strdup(make_pref("/volume"));

	temp_value = purple_prefs_get_bool(enabled);
	tmpfile = g_strdup(purple_prefs_get_path(file));
	volume = purple_prefs_get_int(volpref);

	purple_prefs_set_path(file, event->file);
	if (!temp_value) purple_prefs_set_bool(enabled, TRUE);
	purple_prefs_set_int(volpref, gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume)));

	purple_sound_play_event(id, NULL);

	if (!temp_value) purple_prefs_set_bool(enabled, FALSE);
	purple_prefs_set_path(file, tmpfile);
	purple_prefs_set_int(volpref, volume);

	g_free(enabled);
	g_free(file);
	g_free(tmpfile);
	g_free(volpref);
}
예제 #16
0
void get_lastfm_ws_pref(GtkBox *box)
{
  GtkWidget *widget, *vbox, *hbox, *label;
  GtkAdjustment *interval_spinner_adj = (GtkAdjustment *) gtk_adjustment_new(purple_prefs_get_int(PREF_LASTFM_INTERVAL),
                                                                             INTERVAL_SECONDS, 600.0, INTERVAL_SECONDS, INTERVAL_SECONDS*5.0, INTERVAL_SECONDS*5.0);

  vbox = gtk_vbox_new(FALSE, 5);
  gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, FALSE, 0);

  hbox = gtk_hbox_new(FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

  gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Username:"******"changed", G_CALLBACK(cb_lastfm_ws_username_changed), (gpointer) PREF_LASTFM);

  hbox = gtk_hbox_new(FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

  gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("poll interval:")), FALSE, FALSE, 0);
  widget = gtk_spin_button_new(interval_spinner_adj, INTERVAL_SECONDS, 0);
  gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
  g_signal_connect(G_OBJECT(widget), "value-changed", G_CALLBACK(cb_lastfm_ws_interval_changed), (gpointer) PREF_LASTFM_INTERVAL);

  label = gtk_label_new(_("This is the interval (in seconds) at which we check Last.fm for changes"));
  gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
  gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
}
static void
pref_size_on_change(const char *name, PurplePrefType type, gconstpointer val,
			  gpointer user_data)
{
  g_size = purple_prefs_get_int(PREF_SIZE);
  PurpleGroup * grp = purple_find_group(GROUP_NAME);
  if (!grp) return;
  rc_pop_contacts(grp);
}
예제 #18
0
static void set_blist_trans(GtkWidget *w, const char *pref) {
	gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
	purple_prefs_set_bool(pref, enabled);
	if (blist) {
		set_wintrans(blist, purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
			purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED),
			purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));
	}
}
static gboolean clean_users_hash(GHashTable *users)
{
	int delay = purple_prefs_get_int(DELAY_PREF);
	time_t limit = time(NULL) - (60 * delay);

	g_hash_table_foreach_remove(users, (GHRFunc)check_expire_time, &limit);

	return TRUE;
}
예제 #20
0
static void
winprefs_set_blist_ontop(const char *pref, PurplePrefType type,
		gconstpointer value, gpointer user_data)
{
	gint setting = purple_prefs_get_int(PREF_BLIST_ON_TOP);
	if((setting == BLIST_TOP_DOCKED && blist_ab && blist_ab->docked)
		|| setting == BLIST_TOP_ALWAYS)
		blist_set_ontop(TRUE);
	else
		blist_set_ontop(FALSE);
}
예제 #21
0
static guint
update_countdown (PurplePlugin * plugin) {
    GtkWidget *progress_bar = NULL;

    g_assert (plugin != NULL && plugin->extra != NULL);

    if (PLUGIN (countdown_dialog) == NULL)      /* forced or canceled  */
        return FALSE;

    progress_bar =
        g_object_get_data (G_OBJECT (PLUGIN (countdown_dialog)),
                           "progress-bar");

    if (progress_bar != NULL) {
        gdouble val =
            gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress_bar));

        gdouble incr = 250.0 / ((gdouble)
                                ((purple_prefs_get_int
                                  (PREF_WAIT_BEFORE_SCREENSHOT) -
                                  1)) * 1000.0);
        if (val < 0.99) {
            gchar *text = NULL;
            text = g_strdup_printf ("%.02f sec.", ((gdouble)
                                                   purple_prefs_get_int
                                                   (PREF_WAIT_BEFORE_SCREENSHOT))
                                    * (1.0 - (val + incr)));
            gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
                                           MIN (val + incr, 1.0));
            gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress_bar), text);
            g_free (text);

            return TRUE;
        }
        else {
            gtk_widget_destroy (PLUGIN (countdown_dialog));
            PLUGIN (countdown_dialog) = NULL;
        }
    }
    return FALSE;
}
예제 #22
0
파일: usercast.c 프로젝트: santa01/usercast
static void
cast_nick(PidginConversation* conv, const gchar* nick)
{
    Policy prefix_policy = purple_prefs_get_int(USERCAST_CONF_PREFIX_POLICY);
    Policy postfix_policy = purple_prefs_get_int(USERCAST_CONF_POSTFIX_POLICY);

    const gchar* user_prefix = purple_prefs_get_string(USERCAST_CONF_PREFIX);
    const gchar* user_postfix = purple_prefs_get_string(USERCAST_CONF_POSTFIX);
    gchar* user_cast = NULL;
    gchar* user_part = NULL;

    gint cursor_position = 0;
    gint text_length = 0;
    gchar* text = NULL;

    g_object_get(conv->entry_buffer, "cursor-position", &cursor_position, NULL);
    g_object_get(conv->entry_buffer, "text", &text, NULL);
    text_length = strlen(text);

    if (prefix_policy == POLICY_ALWAYS ||
            (prefix_policy == POLICY_FIRST_WORD && cursor_position == 0) ||
            (prefix_policy == POLICY_LAST_WORD && cursor_position == text_length))
        user_part = g_strdup_printf("%s%s", user_prefix, nick);
    else
        user_part = g_strdup_printf("%s", nick);

    if (postfix_policy == POLICY_ALWAYS ||
            (postfix_policy == POLICY_FIRST_WORD && cursor_position == 0) ||
            (postfix_policy == POLICY_LAST_WORD && cursor_position == text_length))
    {
        user_cast = g_strdup_printf("%s%s", user_part, user_postfix);
        g_free(user_part);
    }
    else
        user_cast = user_part;

    gtk_text_buffer_insert_at_cursor(conv->entry_buffer, user_cast, -1);
    g_free(user_cast);
}
static PurplePluginPrefFrame *
get_plugin_pref_frame (PurplePlugin *plugin)
{
	PurplePluginPrefFrame *frame;
	PurplePluginPref *ppref;

	frame = purple_plugin_pref_frame_new ();

	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/newmsg",
                            _("New messages"));
	purple_plugin_pref_frame_add (frame, ppref);
	
	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/newmsgtxt",
                            _("Show new messages text"));
	purple_plugin_pref_frame_add (frame, ppref);

	if (purple_prefs_get_int("/plugins/gtk/libnotify/timeout") == 0) {
		/* 3 seconds is the default timeout */
		purple_prefs_set_int("/plugins/gtk/libnotify/timeout", 3000);
	}

	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/timeout",
                            _("Display timeout (msec)"));
	purple_plugin_pref_set_bounds(ppref, 100, 100000);
	purple_plugin_pref_frame_add (frame, ppref);

	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/blocked",
                            _("Ignore events from blocked users"));
	purple_plugin_pref_frame_add (frame, ppref);

	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/signon",
                            _("Buddy signs on"));
	purple_plugin_pref_frame_add (frame, ppref);

	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/signoff",
                            _("Buddy signs off"));
	purple_plugin_pref_frame_add (frame, ppref);

	ppref = purple_plugin_pref_new_with_name_and_label (
                            "/plugins/gtk/libnotify/only_available",
                            _("Only when available"));
	purple_plugin_pref_frame_add (frame, ppref);

	return frame;
}
예제 #24
0
파일: merge.c 프로젝트: LQYMGT/window_merge
/**
 * A callback for when the total size of a GtkPaned changes
 *
 * This should be called after a new GtkPaned finds its parent and calculates
 * its "max-position" property.  It is only intended to be run on this single
 * occassion, so it removes itself on completion.  The call is used to set the
 * initial size of the Buddy List to the user's preference.
 *
 * @param[in] gobject    Pointer to the GtkPaned structure that was resized
 * @param[in] pspec      Unused
 * @param[in] data       Pointer to the Buddy List that is a parent of gobject
**/
static void notify_max_position_cb(GObject *gobject, U GParamSpec *pspec,
				   gpointer data)
{
	PidginBuddyList *
	    gtkblist;      /*< Buddy List window containing these panes */
	gint max_position; /*< The "max-position" property of gobject   */
	gint size;	 /*< Desired size of the Buddy List pane      */

	gtkblist = data;

	/* Fetch the user's preferred Buddy List size (depending on
	 * orientation). */
	if (GTK_IS_VPANED(gobject))
		size = purple_prefs_get_int(PREF_HEIGHT);
	else
		size = purple_prefs_get_int(PREF_WIDTH);

	/* If the Buddy List is not the first pane, invert the size preference.
	 */
	if (gtk_paned_get_child1(GTK_PANED(gobject)) != gtkblist->notebook) {
		g_object_get(gobject, "max-position", &max_position, NULL);
		size = max_position - size;
	}

	/* Adjust the panes' slider to set the Buddy List to its desired size.
	 */
	gtk_paned_set_position(GTK_PANED(gobject), size);

	/* Disconnect this callback.  This initial setting was only needed once.
	 */
	g_object_disconnect(gobject, "any_signal",
			    G_CALLBACK(notify_max_position_cb), data, NULL);

	/* Now that system-induced slider changes are done, monitor user
	 * changes. */
	g_object_connect(gobject, "signal::notify::position",
			 G_CALLBACK(notify_position_cb), data, NULL);
}
예제 #25
0
static void
pidgin_mini_dialog_init(PidginMiniDialog *self)
{
	GtkBox *self_box = GTK_BOX(self);
	guint blist_width = purple_prefs_get_int(BLIST_WIDTH_PREF);
	guint label_width = blist_width - BLIST_WIDTH_OTHER_THAN_LABEL;

	PidginMiniDialogPrivate *priv = g_new0(PidginMiniDialogPrivate, 1);
	self->priv = priv;

	gtk_container_set_border_width(GTK_CONTAINER(self), PIDGIN_HIG_BOX_SPACE);

	priv->title_box = GTK_BOX(gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE));

	priv->icon = GTK_IMAGE(gtk_image_new());
	gtk_misc_set_alignment(GTK_MISC(priv->icon), 0, 0);

	priv->title = GTK_LABEL(gtk_label_new(NULL));
	gtk_widget_set_size_request(GTK_WIDGET(priv->title), label_width, -1);
	gtk_label_set_line_wrap(priv->title, TRUE);
	gtk_label_set_selectable(priv->title, TRUE);
	gtk_misc_set_alignment(GTK_MISC(priv->title), 0, 0);

	gtk_box_pack_start(priv->title_box, GTK_WIDGET(priv->icon), FALSE, FALSE, 0);
	gtk_box_pack_start(priv->title_box, GTK_WIDGET(priv->title), TRUE, TRUE, 0);

	priv->desc = GTK_LABEL(gtk_label_new(NULL));
	gtk_widget_set_size_request(GTK_WIDGET(priv->desc), label_width, -1);
	gtk_label_set_line_wrap(priv->desc, TRUE);
	gtk_misc_set_alignment(GTK_MISC(priv->desc), 0, 0);
	gtk_label_set_selectable(priv->desc, TRUE);
	/* make calling show_all() on the minidialog not affect desc even though
	 * it's packed inside it.
	 */
	g_object_set(G_OBJECT(priv->desc), "no-show-all", TRUE, NULL);

	purple_prefs_connect_callback(self, BLIST_WIDTH_PREF,
		blist_width_changed_cb, self);

	self->contents = GTK_BOX(gtk_vbox_new(FALSE, 0));

	priv->buttons = GTK_BOX(gtk_hbox_new(FALSE, 0));

	gtk_box_pack_start(self_box, GTK_WIDGET(priv->title_box), FALSE, FALSE, 0);
	gtk_box_pack_start(self_box, GTK_WIDGET(priv->desc), FALSE, FALSE, 0);
	gtk_box_pack_start(self_box, GTK_WIDGET(self->contents), TRUE, TRUE, 0);
	gtk_box_pack_start(self_box, GTK_WIDGET(priv->buttons), FALSE, FALSE, 0);

	gtk_widget_show_all(GTK_WIDGET(self));
}
예제 #26
0
gboolean finch_sound_is_enabled(void)
{
	const char *pref = make_pref("/method");
	const char *method = purple_prefs_get_string(pref);

	if (!method)
		return FALSE;
	if (strcmp(method, "nosound") == 0)
		return FALSE;
	if (purple_prefs_get_int(make_pref("/volume")) <= 0)
		return FALSE;

	return TRUE;
}
예제 #27
0
static void
load_pref_window(const char * profile)
{
	gint i;

	finch_sound_set_active_profile(profile);

	gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->method), (gchar *)purple_prefs_get_string(make_pref("/method")));

	gnt_entry_set_text(GNT_ENTRY(pref_dialog->command), purple_prefs_get_path(make_pref("/command")));

	gnt_check_box_set_checked(GNT_CHECK_BOX(pref_dialog->conv_focus), purple_prefs_get_bool(make_pref("/conv_focus")));

	gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status), GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status")));

	gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume), CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100));

	for (i = 0; i < PURPLE_NUM_SOUNDS; i++) {
		FinchSoundEvent * event = &sounds[i];
		gchar *boolpref;
		gchar *filepref, *basename = NULL;
		const char * profile = finch_sound_get_active_profile();

		filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", profile, event->pref);

		g_free(event->file);
		event->file = g_strdup(purple_prefs_get_path(filepref));

		g_free(filepref);
		if (event->label == NULL) {
			continue;
		}

		boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", profile, event->pref);

		gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), 0, event->label);
		gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), 1,
				event->file[0] ? (basename = g_path_get_basename(event->file)) : _("(default)"));
		g_free(basename);

		gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), purple_prefs_get_bool(boolpref));

		g_free(boolpref);
	}

	gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles), (gchar *)finch_sound_get_active_profile());

	gnt_widget_draw(pref_dialog->window);
}
예제 #28
0
static void blist_set_dockable(gboolean val) {
	if(val) {
		if(blist_ab == NULL && blist != NULL) {
			blist_ab = gtk_appbar_add(blist);
			gtk_appbar_add_dock_cb(blist_ab, blist_dock_cb);
		}
	} else {
		if(blist_ab != NULL) {
			gtk_appbar_remove(blist_ab);
			blist_ab = NULL;
		}

		blist_set_ontop(purple_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS);
	}
}
예제 #29
0
static void
im_recv_im(PurpleAccount *account, char *who, char *what,
	    PurpleConversation * conv, PurpleMessageFlags flags)
{
  int wasPlaying = 0;

  if(system("dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.IsPlaying")){
    wasPlaying = 1;
    system("dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.PlayPause");
  }

  char *stripped;
  const char *alias = get_best_name(account, who);
  silent_joins = NULL;

  GString *buffer= g_string_new("");

/*  msg_utf8=purple_utf8_try_convert(what) */

  stripped = (char *)purple_markup_strip_html(/*msg_utf8?msg_utf8:*/what);
    
  if(purple_prefs_get_bool("/plugins/gtk/festival/speaker/replace_url"))
    stripped = unlinkify_text(stripped);

  if (strlen(stripped) <= purple_prefs_get_int("/plugins/gtk/festival/speaker/maxlength")) {

    if(purple_prefs_get_bool("/plugins/gtk/festival/speaker/prepend_who") &&
       strcmp(alias, prev_alias))
      g_string_printf(buffer,"%s %s %s", alias, _("says"), stripped);
    else
      g_string_printf(buffer,"%s", stripped);

    strcpy(prev_alias, alias);
    speak(buffer);
  } else {
    g_string_printf(buffer, "message overflow");
    speak(buffer);
  }

  g_free(stripped);
/*  if (msg_utf8) g_free(msg_utf8); */
  g_string_free(buffer,TRUE);

  if(wasPlaying==1 && !system("dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.IsPlaying")){
    sleep(5);
    system("dbus-send --print-reply --dest=net.kevinmehall.Pithos /net/kevinmehall/Pithos net.kevinmehall.Pithos.PlayPause");
  }
}
예제 #30
0
static void
blist_created_cb(PurpleBuddyList *purple_blist, gpointer data) {
	if (blist) {
		if (purple_prefs_get_bool(OPT_WINTRANS_BL_ENABLED)) {
			set_wintrans(blist,
				purple_prefs_get_int(OPT_WINTRANS_BL_ALPHA),
				TRUE,
				purple_prefs_get_bool(OPT_WINTRANS_BL_ONTOP));
		}

		g_signal_connect(G_OBJECT(blist), "focus_in_event",
			G_CALLBACK(focus_blist_win_cb), blist);
		g_signal_connect(G_OBJECT(blist), "focus_out_event",
			G_CALLBACK(focus_blist_win_cb), blist);
	}
}