1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/*
* This is a plug-in for the GIMP.
*
* Generates clickable image maps.
*
* Copyright (C) 1998-2003 Maurits Rijk lpeek.mrijk@consunet.nl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*
*/
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "imap_statusbar.h"
#include "imap_stock.h"
StatusBar_t*
make_statusbar(GtkWidget *main_vbox, GtkWidget *window)
{
StatusBar_t *statusbar = g_new(StatusBar_t, 1);
GtkWidget *hbox, *iconw;
hbox = gtk_hbox_new(FALSE, 1);
gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0);
/* Status info */
statusbar->status = gtk_statusbar_new();
statusbar->status_id = gtk_statusbar_get_context_id(
GTK_STATUSBAR(statusbar->status), "general_status");
gtk_box_pack_start(GTK_BOX(hbox), statusbar->status, TRUE, TRUE, 0);
gtk_widget_show(statusbar->status);
/* (x, y) coordinate */
iconw = gtk_image_new_from_stock(IMAP_STOCK_COORD,
GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_box_pack_start(GTK_BOX(hbox), iconw, FALSE, FALSE, 10);
gtk_widget_show(iconw);
statusbar->xy = gtk_entry_new();
gtk_widget_set_size_request(statusbar->xy, 96, -1);
gtk_editable_set_editable(GTK_EDITABLE(statusbar->xy), FALSE);
GTK_WIDGET_UNSET_FLAGS(statusbar->xy, GTK_CAN_FOCUS);
gtk_box_pack_start(GTK_BOX(hbox), statusbar->xy, FALSE, FALSE, 0);
gtk_widget_show(statusbar->xy);
/* Dimension info */
iconw = gtk_image_new_from_stock(IMAP_STOCK_DIMENSION,
GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_box_pack_start(GTK_BOX(hbox), iconw, FALSE, FALSE, 10);
gtk_widget_show(iconw);
statusbar->dimension = gtk_entry_new();
gtk_widget_set_size_request(statusbar->dimension, 96, -1);
gtk_editable_set_editable(GTK_EDITABLE(statusbar->dimension), FALSE);
GTK_WIDGET_UNSET_FLAGS(statusbar->dimension, GTK_CAN_FOCUS);
gtk_box_pack_start(GTK_BOX(hbox), statusbar->dimension, FALSE, FALSE, 0);
gtk_widget_show(statusbar->dimension);
/* Zoom info */
statusbar->zoom = gtk_statusbar_new();
gtk_widget_set_size_request(statusbar->zoom, 48, -1);
statusbar->zoom_id = gtk_statusbar_get_context_id(
GTK_STATUSBAR(statusbar->zoom), "zoom_status");
gtk_box_pack_start(GTK_BOX(hbox), statusbar->zoom, FALSE, FALSE, 5);
gtk_widget_show(statusbar->zoom);
gtk_widget_show(hbox);
return statusbar;
}
void
statusbar_set_status(StatusBar_t *statusbar, const gchar *format, ...)
{
va_list ap;
char scratch[256];
va_start(ap, format);
vsprintf(scratch, format, ap);
va_end(ap);
statusbar_clear_status(statusbar);
statusbar->message_id =
gtk_statusbar_push(GTK_STATUSBAR(statusbar->status),
statusbar->status_id, scratch);
}
void
statusbar_clear_status(StatusBar_t *statusbar)
{
if (statusbar->message_id)
gtk_statusbar_remove(GTK_STATUSBAR(statusbar->status),
statusbar->status_id,
statusbar->message_id);
}
void
statusbar_set_xy(StatusBar_t *statusbar, gint x, gint y)
{
char scratch[16];
sprintf(scratch, "%d, %d", (int) x, (int) y);
gtk_entry_set_text(GTK_ENTRY(statusbar->xy), scratch);
}
void statusbar_clear_xy(StatusBar_t *statusbar)
{
gtk_entry_set_text(GTK_ENTRY(statusbar->xy), "");
}
void
statusbar_set_dimension(StatusBar_t *statusbar, gint w, gint h)
{
char scratch[16];
sprintf(scratch, "%d x %d", (int) w, (int) h);
gtk_entry_set_text(GTK_ENTRY(statusbar->dimension), scratch);
}
void
statusbar_clear_dimension(StatusBar_t *statusbar)
{
gtk_entry_set_text(GTK_ENTRY(statusbar->dimension), "");
}
void
statusbar_set_zoom(StatusBar_t *statusbar, gint factor)
{
char scratch[16];
sprintf(scratch, "1:%d", factor);
gtk_statusbar_push(GTK_STATUSBAR(statusbar->zoom), statusbar->zoom_id,
scratch);
}
|