示例#1
0
static gboolean
plugin_load(PurplePlugin *plugin, GError **error)
{
	GList *convs = purple_conversations_get_all();
	void *gtk_conv_handle = pidgin_conversations_get_handle();

	purple_signal_connect(gtk_conv_handle, "conversation-displayed", plugin,
	                      PURPLE_CALLBACK(conversation_displayed_cb), NULL);
	/*
	purple_signal_connect(gtk_conv_handle, "conversation-hiding", plugin,
	                      PURPLE_CALLBACK(conversation_hiding_cb), NULL);
	 */

	while (convs) {

		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* Setup Send button */
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			create_send_button_pidgin(PIDGIN_CONVERSATION(conv));
		}

		convs = convs->next;
	}

	return TRUE;
}
示例#2
0
/**************************************************************************************************
    Load plugin
**************************************************************************************************/
static gboolean
plugin_load(PurplePlugin *plugin)
{
    PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist();
	GList *convs = purple_get_conversations();

    if (purple_prefs_get_bool("/plugins/core/hidemenu/default_state")) {
        hmb_is_menu_visible = FALSE;
    } else {
        hmb_is_menu_visible = TRUE;
    }

    // set callback for 'blist created' signal
    purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created", plugin, 
                          PURPLE_CALLBACK(hmb_blist_created_cb), NULL);
    // set callback for 'conversation displayed' signal
	purple_signal_connect(pidgin_conversations_get_handle(), "conversation-displayed", plugin,
	                      PURPLE_CALLBACK(hmb_conversation_displayed_cb), NULL);

	// hide blist menubar
    hmb_toggle_menubar(gtkblist, NULL);

    // hide conversations menubar
	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			hmb_toggle_menubar(NULL, PIDGIN_CONVERSATION(conv));
		}
		convs = convs->next;
	}

	return TRUE;
}
示例#3
0
static gboolean plugin_unload(PurplePlugin *plugin)
{
    GList *convs;
    for (convs = purple_get_conversations(); convs != NULL; convs = convs->next) {
        PurpleConversation *conv = (PurpleConversation *)convs->data;
        if(PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
            detach_from_conversation(conv);
        }
    }
    return TRUE;
}
示例#4
0
static gboolean
conversation_nick_clicked(PurpleConversation* conv, gchar* nick, guint button)
{
    GdkEvent* next_event = NULL;
    PidginConversation* pidgin_conv = NULL;
    gint event_timeout = 100; /* milliseconds */

    if (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_CHAT)
    {
        purple_debug_warning(USERCAST_PLUGIN_NAME, "Conversation `%s' is not a chat\n", conv->name);
        return FALSE;
    }

    if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
    {
        purple_debug_warning(USERCAST_PLUGIN_NAME, "Conversation `%s' is not a pidgin conversation\n",
                             conv->name);
        return FALSE;
    }

    if (button != 1)
        return FALSE;

    /* Wait for either GDK_2BUTTON_EVENT or something else to arrive */
    for (; event_timeout > 0; event_timeout--)
    {
        if ((next_event = gdk_event_peek()))
            break;
        g_usleep(1000); /* 1 millisecond */
    }

    /* Pingin handles GDK_2BUTTON_PRESS separately */
    if (next_event && next_event->type == GDK_2BUTTON_PRESS)
    {
        /* Remove GDK_2BUTTON_PRESS from event queue */
        gdk_event_free(next_event);
        gdk_event_free(gdk_event_get());

        pidgin_conv = PIDGIN_CONVERSATION(conv);
        cast_nick(pidgin_conv, nick);
        gtk_widget_grab_focus(pidgin_conv->entry);

        purple_debug_info(USERCAST_PLUGIN_NAME, "Casted user `%s' to `%s'\n", nick, conv->name);
        return TRUE;
    }

    return FALSE;
}
示例#5
0
文件: gestures.c 项目: bf4/pidgin-mac
static void
stroke_close(GtkWidget *widget, void *data)
{
	PurpleConversation *conv;
	PidginConversation *gtkconv;

	conv = (PurpleConversation *)data;

	/* Double-check */
	if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
		return;

	gtkconv = PIDGIN_CONVERSATION(conv);

	gstroke_cleanup(gtkconv->imhtml);
	purple_conversation_destroy(conv);
}
static gboolean plugin_unload(PurplePlugin *plugin)
{
	GList *convs = purple_get_conversations();

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

		/* Remove context menu item button */
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			remove_close_offline_menu_item_pidgin(PIDGIN_CONVERSATION(conv));
		}

		convs = convs->next;
	}
    
	return TRUE;
}
示例#7
0
static gboolean
plugin_unload(PurplePlugin *plugin, GError **error)
{
	GList *convs = purple_conversations_get_all();

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

		/* Remove Send button */
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			remove_send_button_pidgin(PIDGIN_CONVERSATION(conv));
		}

		convs = convs->next;
	}

	return TRUE;
}
static gboolean plugin_load(PurplePlugin *plugin)
{
     
	GList *convs = purple_get_conversations();
	void *gtk_conv_handle = pidgin_conversations_get_handle();

	purple_signal_connect(gtk_conv_handle, "conversation-displayed", plugin,
	                      PURPLE_CALLBACK(conversation_displayed_cb), NULL);
	while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;

		/* Setup context menu action */
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			create_close_offline_menu_item_pidgin(PIDGIN_CONVERSATION(conv));
		}

		convs = convs->next;
	}
	return TRUE;
}
示例#9
0
/*
 * play a sound event for a conversation, honoring make_sound flag
 * of conversation and checking for focus if conv_focus pref is set
 */
static void
play_conv_event(PurpleConversation *conv, PurpleSoundEventID event)
{
	/* If we should not play the sound for some reason, then exit early */
	if (conv != NULL && PIDGIN_IS_PIDGIN_CONVERSATION(conv))
	{
		PidginConversation *gtkconv;
		gboolean has_focus;

		gtkconv = PIDGIN_CONVERSATION(conv);
		has_focus = purple_conversation_has_focus(conv);

		if (!gtkconv->make_sound ||
			(has_focus && !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus")))
		{
			return;
		}
	}

	purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL);
}
示例#10
0
文件: gestures.c 项目: bf4/pidgin-mac
static gboolean
plugin_unload(PurplePlugin *plugin)
{
	PurpleConversation *conv;
	PidginConversation *gtkconv;
	GList *l;

	for (l = purple_get_conversations(); l != NULL; l = l->next) {
		conv = (PurpleConversation *)l->data;

		if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
			continue;

		gtkconv = PIDGIN_CONVERSATION(conv);

		gstroke_cleanup(gtkconv->imhtml);
		gstroke_disable(gtkconv->imhtml);
	}

	return TRUE;
}
示例#11
0
文件: gestures.c 项目: bf4/pidgin-mac
static gboolean
plugin_load(PurplePlugin *plugin)
{
	PurpleConversation *conv;
	GList *l;

	for (l = purple_get_conversations(); l != NULL; l = l->next) {
		conv = (PurpleConversation *)l->data;

		if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
			continue;

		attach_signals(conv);
	}

	purple_signal_connect(purple_conversations_get_handle(),
						"conversation-created",
						plugin, PURPLE_CALLBACK(new_conv_cb), NULL);

	return TRUE;
}
示例#12
0
/**************************************************************************************************
    Toggle menubars state
**************************************************************************************************/
static void 
hmb_toggle_menubar_state()
{
    PidginBuddyList *gtkblist = pidgin_blist_get_default_gtk_blist();
	GList *convs = purple_get_conversations();
   
    // toggle menu visibility status
    hmb_is_menu_visible = !hmb_is_menu_visible;
    
    // toggle blist
    hmb_toggle_menubar(gtkblist, NULL);
	
    // toggle conversations
    while (convs) {
		PurpleConversation *conv = (PurpleConversation *)convs->data;
		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
			hmb_toggle_menubar(NULL, PIDGIN_CONVERSATION(conv));
		}
		convs = convs->next;
	}
}
示例#13
0
void
remove_pidgin_menuitems (PurpleConversation * conv) {
    if (PIDGIN_IS_PIDGIN_CONVERSATION (conv)) {
        PurplePlugin *plugin;
        GtkWidget *screenshot_insert_menuitem;
        GtkWidget *screenshot_menuitem, *conversation_menu;
        GtkWidget *insert_menu;
        PidginWindow *win;
        PidginConversation *gtkconv;

        gtkconv = PIDGIN_CONVERSATION (conv);
        plugin = purple_plugins_find_with_id (PLUGIN_ID);

        win = pidgin_conv_get_window (gtkconv);
        if (win != NULL) {
            if ((conversation_menu =
                 gtk_item_factory_get_widget (win->menu.item_factory,
                                              N_("/Conversation"))) != NULL) {
                /* remove signal */
                gulong handler = g_signal_handler_find (conversation_menu,
                                                        G_SIGNAL_MATCH_FUNC,
                                                        0,
                                                        0,
                                                        NULL,
                                                        G_CALLBACK
                                                        (on_conversation_menu_show_cb),
                                                        NULL);
                if (handler)
                    g_signal_handler_disconnect (conversation_menu, handler);

                if ((screenshot_menuitem =
                     g_object_get_data (G_OBJECT (conversation_menu),
                                        "screenshot_menuitem")) != NULL) {
                    gtk_widget_destroy (screenshot_menuitem);
                    g_object_steal_data (G_OBJECT (conversation_menu),
                                         "screenshot_menuitem");
                    g_object_steal_data (G_OBJECT (conversation_menu),
                                         "img_menuitem");
#ifdef ENABLE_UPLOAD
                    g_object_steal_data (G_OBJECT (conversation_menu),
                                         "link_menuitem");
                    g_object_steal_data (G_OBJECT (conversation_menu),
                                         "ftp_link_menuitem");
#endif
                }
            }
        }
        /* remove signal */
        if ((insert_menu =
             g_object_get_data (G_OBJECT (gtkconv->toolbar),
                                "insert_menu")) != NULL) {
            gulong handler = g_signal_handler_find (insert_menu,
                                                    G_SIGNAL_MATCH_FUNC,
                                                    0,
                                                    0,
                                                    NULL,
                                                    G_CALLBACK
                                                    (on_insert_menu_show_cb),
                                                    NULL);
            if (handler)
                g_signal_handler_disconnect (insert_menu, handler);
        }

        screenshot_insert_menuitem =
            g_object_get_data (G_OBJECT (gtkconv->toolbar),
                               "screenshot_insert_menuitem");
        if (screenshot_insert_menuitem != NULL) {
            gtk_widget_destroy (screenshot_insert_menuitem);
            g_object_steal_data (G_OBJECT (gtkconv->toolbar),
                                 "screenshot_insert_menuitem");
        }
    }
}
示例#14
0
void
create_plugin_menuitems (PurpleConversation * conv) {
    if (PIDGIN_IS_PIDGIN_CONVERSATION (conv)) {
        PidginConversation *gtkconv;
        PurplePlugin *plugin;
        PidginWindow *win;
        GtkWidget *conversation_menu, *screenshot_menuitem;
        GtkWidget *screenshot_insert_menuitem;

        gtkconv = PIDGIN_CONVERSATION (conv);
        plugin = purple_plugins_find_with_id (PLUGIN_ID);
        win = pidgin_conv_get_window (gtkconv);

        conversation_menu =
            gtk_item_factory_get_widget (win->menu.item_factory,
                                         N_("/Conversation"));
        screenshot_insert_menuitem =
            g_object_get_data (G_OBJECT (gtkconv->toolbar),
                               "screenshot_insert_menuitem");
        screenshot_menuitem =
            g_object_get_data (G_OBJECT (conversation_menu),
                               "screenshot_menuitem");

        /* Intercept hotkeys defined in pref window */
        g_signal_connect_swapped (G_OBJECT
                                  (pidgin_conv_get_window (gtkconv)->window),
                                  "key_release_event",
                                  G_CALLBACK (catch_hotkeys_cb), win);

        /* Add us to the conv "Insert" menu */
        if (screenshot_insert_menuitem == NULL) {
	  GtkWidget *insert_menu;//, *submenu;
            if ((insert_menu =
                 g_object_get_data (G_OBJECT (gtkconv->toolbar),
                                    "insert_menu")) != NULL) {
                /* add us to the "insert" list */
                screenshot_insert_menuitem =
                    gtk_menu_item_new_with_mnemonic
                    (SCREENSHOT_INSERT_MENUITEM_LABEL);

                //submenu = create_plugin_submenu (gtkconv, FALSE);


                g_signal_connect_swapped (G_OBJECT (insert_menu), "show",
                                          G_CALLBACK (on_insert_menu_show_cb),
                                          screenshot_insert_menuitem);


		   g_signal_connect  (G_OBJECT (screenshot_insert_menuitem), "activate",
                                  G_CALLBACK (on_screenshot_insert_menuitem_activate_cb),
                                 gtkconv);

		/*
                gtk_menu_item_set_submenu (GTK_MENU_ITEM
                                           (screenshot_insert_menuitem),
                                           submenu);
		*/
                gtk_menu_shell_insert (GTK_MENU_SHELL (insert_menu), screenshot_insert_menuitem, 1);    /* 0 = Image */

                /* register new widget */
                g_object_set_data (G_OBJECT (gtkconv->toolbar),
                                   "screenshot_insert_menuitem",
                                   screenshot_insert_menuitem);
            }
        }

        /* Add us to the conv "Conversation" menu. */
        if (screenshot_menuitem == NULL) {
            GList *children = NULL, *head_chld = NULL;  /* don't g_list_free() it */
            guint i = 0;
            //GtkWidget *submenu = create_plugin_submenu (gtkconv, TRUE);

            screenshot_menuitem =
                gtk_menu_item_new_with_mnemonic (SCREENSHOT_MENUITEM_LABEL);

            /*gtk_menu_item_set_submenu (GTK_MENU_ITEM
	      (screenshot_menuitem), submenu); */

            /*gtk_widget_show_all (submenu);*/

            children =
                gtk_container_get_children (GTK_CONTAINER
                                            (conversation_menu));
            head_chld = children;       /* keep first element addr */

            /* pack our menuitem at correct place */
            while (children != NULL && children->data !=
                   (gpointer) win->menu.insert_image) {
                children = g_list_next (children);
                i++;
            }
            g_list_free (head_chld);

            gtk_menu_shell_insert (GTK_MENU_SHELL (conversation_menu),
                                   screenshot_menuitem, i + 1);
            gtk_widget_show (screenshot_menuitem);

            g_object_set_data (G_OBJECT (conversation_menu),
                               "screenshot_menuitem", screenshot_menuitem);
        }
    }
}
示例#15
0
文件: gestures.c 项目: bf4/pidgin-mac
static void
new_conv_cb(PurpleConversation *conv)
{
	if (PIDGIN_IS_PIDGIN_CONVERSATION(conv))
		attach_signals(conv);
}