*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
#include "ev-navigation-action.h"
#include "ev-navigation-action-widget.h"
-#include <gtk/gtklabel.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtkmenushell.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenutoolbutton.h>
-#include <glib/gi18n.h>
enum
{
#define EV_NAVIGATION_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_NAVIGATION_ACTION, EvNavigationActionPrivate))
+static void
+ev_navigation_action_history_changed (EvHistory *history,
+ gpointer data)
+{
+ EvNavigationAction *action = EV_NAVIGATION_ACTION (data);
+
+ gtk_action_set_sensitive (GTK_ACTION (action),
+ ev_history_get_n_links (history) > 0);
+}
+
void
ev_navigation_action_set_history (EvNavigationAction *action,
EvHistory *history)
g_object_add_weak_pointer (G_OBJECT (action->priv->history),
(gpointer) &action->priv->history);
+
+ g_signal_connect_object (history, "changed",
+ G_CALLBACK (ev_navigation_action_history_changed),
+ action, 0);
}
static void
title = ev_link_get_title (link);
item = gtk_image_menu_item_new_with_label (title);
- gtk_label_set_use_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (item))), TRUE);
+ label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (item)));
+ gtk_label_set_use_markup (label, TRUE);
g_object_set_data (G_OBJECT (item), "index",
GINT_TO_POINTER (index));
- label = GTK_LABEL (GTK_BIN (item)->child);
gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH);
return item;
}
-static GtkWidget *
-new_empty_history_menu_item (EvNavigationAction *action)
-{
- GtkWidget *item;
-
- item = gtk_image_menu_item_new_with_label (_("Empty"));
- gtk_widget_set_sensitive (item, FALSE);
- gtk_widget_show (item);
-
- return item;
-}
-
static GtkWidget *
build_menu (EvNavigationAction *action)
{
EvHistory *history = action->priv->history;
int start, end, i;
- menu = GTK_MENU_SHELL (gtk_menu_new ());
-
if (history == NULL || ev_history_get_n_links (history) <= 0) {
- item = new_empty_history_menu_item (action);
- gtk_menu_shell_append (menu, item);
- return GTK_WIDGET (menu);
+ return NULL;
}
+ menu = GTK_MENU_SHELL (gtk_menu_new ());
+
start = 0;
end = ev_history_get_n_links (history);
EvNavigationAction *action = EV_NAVIGATION_ACTION (object);
if (action->priv->history) {
- g_object_add_weak_pointer (G_OBJECT (action->priv->history),
- (gpointer) &action->priv->history);
+ g_object_remove_weak_pointer (G_OBJECT (action->priv->history),
+ (gpointer) &action->priv->history);
+ action->priv->history = NULL;
}
G_OBJECT_CLASS (ev_navigation_action_parent_class)->finalize (object);